Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions cli-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13676,6 +13676,163 @@
"modulePath": "mercury/reimbursement-plan.js",
"sourceFile": "mercury/reimbursement-plan.js"
},
{
"site": "nasa-images",
"name": "asset",
"description": "List downloadable asset files for a NASA media item",
"access": "read",
"domain": "images-api.nasa.gov",
"strategy": "public",
"browser": false,
"args": [
{
"name": "nasaId",
"type": "str",
"required": true,
"positional": true,
"help": "NASA media id, e.g. as11-40-5874"
}
],
"columns": [
"rank",
"nasaId",
"variant",
"extension",
"url"
],
"type": "js",
"modulePath": "nasa-images/asset.js",
"sourceFile": "nasa-images/asset.js"
},
{
"site": "nasa-images",
"name": "captions",
"description": "Get the caption file URL for a NASA video item",
"access": "read",
"domain": "images-api.nasa.gov",
"strategy": "public",
"browser": false,
"args": [
{
"name": "nasaId",
"type": "str",
"required": true,
"positional": true,
"help": "NASA video id, e.g. 172_ISS-Slosh"
}
],
"columns": [
"nasaId",
"captionsUrl"
],
"type": "js",
"modulePath": "nasa-images/captions.js",
"sourceFile": "nasa-images/captions.js"
},
{
"site": "nasa-images",
"name": "metadata",
"description": "Get the metadata JSON URL for a NASA media item",
"access": "read",
"domain": "images-api.nasa.gov",
"strategy": "public",
"browser": false,
"args": [
{
"name": "nasaId",
"type": "str",
"required": true,
"positional": true,
"help": "NASA media id, e.g. as11-40-5874"
}
],
"columns": [
"nasaId",
"metadataUrl"
],
"type": "js",
"modulePath": "nasa-images/metadata.js",
"sourceFile": "nasa-images/metadata.js"
},
{
"site": "nasa-images",
"name": "search",
"description": "Search NASA Images and Video Library media",
"access": "read",
"domain": "images-api.nasa.gov",
"strategy": "public",
"browser": false,
"args": [
{
"name": "query",
"type": "str",
"required": true,
"positional": true,
"help": "Search terms, e.g. \"apollo 11\""
},
{
"name": "media-type",
"type": "str",
"default": "image",
"required": false,
"help": "image, video, audio, or all",
"choices": [
"image",
"video",
"audio",
"all"
]
},
{
"name": "limit",
"type": "int",
"default": 20,
"required": false,
"help": "Max results (1-100)"
},
{
"name": "page",
"type": "int",
"default": 1,
"required": false,
"help": "Result page (1-1000)"
},
{
"name": "year-start",
"type": "int",
"required": false,
"help": "Filter start year, e.g. 1969"
},
{
"name": "year-end",
"type": "int",
"required": false,
"help": "Filter end year, e.g. 1972"
},
{
"name": "center",
"type": "str",
"required": false,
"help": "NASA center filter, e.g. JSC"
}
],
"columns": [
"rank",
"nasaId",
"title",
"mediaType",
"center",
"dateCreated",
"description",
"keywords",
"previewUrl",
"assetUrl",
"url"
],
"type": "js",
"modulePath": "nasa-images/search.js",
"sourceFile": "nasa-images/search.js"
},
{
"site": "notebooklm",
"name": "add-source",
Expand Down
57 changes: 57 additions & 0 deletions clis/nasa-images/asset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { EmptyResultError } from '@agentrhq/webcmd/errors';
import { cli, Strategy } from '@agentrhq/webcmd/registry';
import { API_BASE, collectionItems, fetchJson, requireNasaId } from './utils.js';

function fileNameFromHref(href) {
try {
return decodeURIComponent(new URL(href).pathname.split('/').pop() ?? '');
} catch {
return decodeURIComponent(String(href).split('/').pop() ?? '');
}
}

function fileVariant(href) {
const name = fileNameFromHref(href);
if (/metadata\.json$/i.test(name)) return 'metadata';
const match = name.match(/~([^./]+)(?:\.[^.]+)?$/);
return match ? match[1] : '';
}

function fileExtension(href) {
const match = fileNameFromHref(href).match(/\.([A-Za-z0-9]+)$/);
return match ? match[1].toLowerCase() : '';
}

cli({
site: 'nasa-images',
name: 'asset',
access: 'read',
description: 'List downloadable asset files for a NASA media item',
domain: 'images-api.nasa.gov',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'nasaId', positional: true, required: true, help: 'NASA media id, e.g. as11-40-5874' },
],
columns: ['rank', 'nasaId', 'variant', 'extension', 'url'],
func: async (args) => {
const nasaId = requireNasaId(args.nasaId);
const url = new URL(`${API_BASE}/asset/${encodeURIComponent(nasaId)}`);
const body = await fetchJson(url, 'nasa-images asset', { emptyOn404: true });
const items = collectionItems(body).filter((item) => String(item?.href ?? '').trim());
if (!items.length) {
throw new EmptyResultError('nasa-images asset', `No asset files found for "${nasaId}".`);
}

return items.map((item, i) => {
const href = String(item.href).trim();
return {
rank: i + 1,
nasaId,
variant: fileVariant(href),
extension: fileExtension(href),
url: href,
};
});
},
});
27 changes: 27 additions & 0 deletions clis/nasa-images/captions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { EmptyResultError } from '@agentrhq/webcmd/errors';
import { cli, Strategy } from '@agentrhq/webcmd/registry';
import { API_BASE, fetchJson, requireNasaId } from './utils.js';

cli({
site: 'nasa-images',
name: 'captions',
access: 'read',
description: 'Get the caption file URL for a NASA video item',
domain: 'images-api.nasa.gov',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'nasaId', positional: true, required: true, help: 'NASA video id, e.g. 172_ISS-Slosh' },
],
columns: ['nasaId', 'captionsUrl'],
func: async (args) => {
const nasaId = requireNasaId(args.nasaId);
const url = new URL(`${API_BASE}/captions/${encodeURIComponent(nasaId)}`);
const body = await fetchJson(url, 'nasa-images captions', { emptyOn404: true });
const captionsUrl = String(body?.location ?? '').trim();
if (!captionsUrl) {
throw new EmptyResultError('nasa-images captions', `No captions URL found for "${nasaId}".`);
}
return [{ nasaId, captionsUrl }];
},
});
27 changes: 27 additions & 0 deletions clis/nasa-images/metadata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { EmptyResultError } from '@agentrhq/webcmd/errors';
import { cli, Strategy } from '@agentrhq/webcmd/registry';
import { API_BASE, fetchJson, requireNasaId } from './utils.js';

cli({
site: 'nasa-images',
name: 'metadata',
access: 'read',
description: 'Get the metadata JSON URL for a NASA media item',
domain: 'images-api.nasa.gov',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'nasaId', positional: true, required: true, help: 'NASA media id, e.g. as11-40-5874' },
],
columns: ['nasaId', 'metadataUrl'],
func: async (args) => {
const nasaId = requireNasaId(args.nasaId);
const url = new URL(`${API_BASE}/metadata/${encodeURIComponent(nasaId)}`);
const body = await fetchJson(url, 'nasa-images metadata', { emptyOn404: true });
const metadataUrl = String(body?.location ?? '').trim();
if (!metadataUrl) {
throw new EmptyResultError('nasa-images metadata', `No metadata URL found for "${nasaId}".`);
}
return [{ nasaId, metadataUrl }];
},
});
Loading
Loading