@nodetool-ai/app-export 0.8.14 → 0.8.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
2026-11-
|
|
1
|
+
2026-11-26T15:01:47.250Z
|
|
@@ -3,7 +3,7 @@ export const TEMPLATE_FILES = new Map([
|
|
|
3
3
|
["gitignore", "node_modules\ndist\n.env\n.nodetool-data\n"],
|
|
4
4
|
["index.html", "<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <link rel=\"icon\" href=\"data:,\" />\n <title>NodeTool app</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"/src/main.tsx\"></script>\n </body>\n</html>\n"],
|
|
5
5
|
["server/index.mjs", "/**\n * The app's server: one process, one port.\n *\n * POST /api/run run one of the app's workflows or JS scripts,\n * streamed as SSE\n * POST /api/upload store a file the user picked, answer its URL\n * GET /api/models models the configured providers offer, by kind\n * GET /api/storage/<key> serve stored uploads and run outputs\n * GET /api/package-assets/<package>/<path>\n * serve the sample files copied under assets/\n * everything else the UI (Vite in dev, `dist/` after `npm run build`)\n *\n * It listens on 127.0.0.1 unless HOST says otherwise. Every run spends the\n * provider keys in `.env`, so think before exposing it to a network.\n */\nimport { createReadStream, existsSync } from \"node:fs\";\nimport { mkdir, readFile, stat } from \"node:fs/promises\";\nimport { createServer } from \"node:http\";\nimport { dirname, extname, join, normalize, resolve, sep } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { randomUUID } from \"node:crypto\";\nimport { storageResponseHeaders } from \"./storage-policy.mjs\";\n\nconst ROOT = resolve(dirname(fileURLToPath(import.meta.url)), \"..\");\nif (existsSync(join(ROOT, \".env\"))) {\n process.loadEnvFile(join(ROOT, \".env\"));\n}\n\nconst DEV = process.argv.includes(\"--dev\");\nconst PORT = Number(process.env.PORT ?? 5180);\nconst HOST = process.env.HOST ?? \"127.0.0.1\";\nconst DATA_DIR = resolve(ROOT, process.env.NODETOOL_DATA_DIR ?? \".nodetool-data\");\nconst MAX_UPLOAD_BYTES = Number(process.env.MAX_UPLOAD_MB ?? 200) * 1024 * 1024;\n\nconst CONTENT_TYPES = {\n \".html\": \"text/html; charset=utf-8\",\n \".js\": \"text/javascript; charset=utf-8\",\n \".css\": \"text/css; charset=utf-8\",\n \".json\": \"application/json\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".webp\": \"image/webp\",\n \".gif\": \"image/gif\",\n \".mp3\": \"audio/mpeg\",\n \".wav\": \"audio/wav\",\n \".ogg\": \"audio/ogg\",\n \".mp4\": \"video/mp4\",\n \".webm\": \"video/webm\",\n \".pdf\": \"application/pdf\",\n \".glb\": \"model/gltf-binary\",\n \".txt\": \"text/plain; charset=utf-8\"\n};\n\nawait mkdir(DATA_DIR, { recursive: true });\nconst { createRunner } = await import(\"./runner.mjs\");\nconst runner = createRunner({ root: ROOT, dataDir: DATA_DIR });\nconst { createModelCatalog } = await import(\"./models.mjs\");\nconst models = createModelCatalog();\n\nfunction sendJson(res, status, body) {\n res.writeHead(status, { \"content-type\": \"application/json\" });\n res.end(JSON.stringify(body));\n}\n\nasync function readBody(req, limit) {\n const chunks = [];\n let size = 0;\n for await (const chunk of req) {\n size += chunk.length;\n if (size > limit) {\n throw new Error(`Body exceeds ${Math.round(limit / 1024 / 1024)} MB`);\n }\n chunks.push(chunk);\n }\n return Buffer.concat(chunks);\n}\n\n/** A path under `base`, or null when the request tries to leave it. */\nfunction safeJoin(base, requested) {\n const target = normalize(join(base, requested));\n return target === base || target.startsWith(base + sep) ? target : null;\n}\n\nasync function serveFile(res, path, fallback, untrusted = false) {\n try {\n const info = await stat(path);\n if (!info.isFile()) throw new Error(\"not a file\");\n res.writeHead(200, {\n \"content-type\": CONTENT_TYPES[extname(path).toLowerCase()] ?? \"application/octet-stream\",\n \"content-length\": info.size,\n ...(untrusted && storageResponseHeaders(path))\n });\n createReadStream(path).pipe(res);\n } catch {\n if (fallback) {\n await serveFile(res, fallback, null);\n return;\n }\n sendJson(res, 404, { error: \"not_found\" });\n }\n}\n\nasync function handleRun(req, res) {\n let body;\n try {\n body = JSON.parse((await readBody(req, MAX_UPLOAD_BYTES)).toString(\"utf8\"));\n } catch {\n sendJson(res, 400, { error: \"invalid_json\" });\n return;\n }\n const workflow = typeof body?.workflow === \"string\" ? body.workflow : null;\n const script = typeof body?.script === \"string\" ? body.script : null;\n if (!workflow && !script) {\n sendJson(res, 400, { error: \"missing_workflow\" });\n return;\n }\n const jobId = typeof body.job_id === \"string\" ? body.job_id : randomUUID();\n const abort = new AbortController();\n res.on(\"close\", () => {\n if (!res.writableEnded) abort.abort();\n });\n res.writeHead(200, {\n \"content-type\": \"text/event-stream; charset=utf-8\",\n \"cache-control\": \"no-cache, no-transform\",\n connection: \"keep-alive\"\n });\n const send = (message) => {\n if (!res.writableEnded) res.write(`data: ${JSON.stringify(message)}\\n\\n`);\n };\n try {\n const request = { params: body.params, propertyOverrides: body.property_overrides, operationId: body.operation_id, jobId, signal: abort.signal, send };\n if (script) await runner.runScript({ ...request, scriptKey: script });\n else await runner.run({ ...request, workflowKey: workflow });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`[run ${jobId}] ${message}`);\n send({ type: \"job_update\", status: \"failed\", job_id: jobId, error: message });\n } finally {\n res.end();\n }\n}\n\nasync function handleUpload(req, res, url) {\n const name = (url.searchParams.get(\"name\") ?? \"upload\").replace(/[^A-Za-z0-9._-]+/g, \"_\");\n const contentType = req.headers[\"content-type\"] ?? \"application/octet-stream\";\n try {\n const bytes = await readBody(req, MAX_UPLOAD_BYTES);\n const key = `uploads/${randomUUID()}-${name}`;\n await runner.storage.store(key, bytes, contentType);\n sendJson(res, 200, { uri: `/api/storage/${key}`, content_type: contentType });\n } catch (error) {\n sendJson(res, 413, { error: error instanceof Error ? error.message : String(error) });\n }\n}\n\nlet vite = null;\nif (DEV) {\n const { createServer: createViteServer } = await import(\"vite\");\n vite = await createViteServer({\n root: ROOT,\n server: { middlewareMode: true },\n appType: \"spa\"\n });\n}\n\nconst DIST = join(ROOT, \"dist\");\n\nconst server = createServer(async (req, res) => {\n const url = new URL(req.url ?? \"/\", \"http://localhost\");\n try {\n if (url.pathname === \"/api/run\" && req.method === \"POST\") {\n await handleRun(req, res);\n return;\n }\n if (url.pathname === \"/api/upload\" && req.method === \"POST\") {\n await handleUpload(req, res, url);\n return;\n }\n if (url.pathname === \"/api/models\" && req.method === \"GET\") {\n const kind = url.searchParams.get(\"kind\") ?? \"\";\n const task = url.searchParams.get(\"task\") || undefined;\n sendJson(res, 200, { models: await models.list(kind, task) });\n return;\n }\n if (url.pathname.startsWith(\"/api/storage/\") && req.method === \"GET\") {\n const key = decodeURIComponent(url.pathname.slice(\"/api/storage/\".length));\n const path = safeJoin(runner.storage.rootDir, key);\n if (!path) {\n sendJson(res, 400, { error: \"invalid_path\" });\n return;\n }\n await serveFile(res, path, null, true);\n return;\n }\n if (url.pathname.startsWith(\"/api/package-assets/\") && req.method === \"GET\") {\n const rel = decodeURIComponent(url.pathname.slice(\"/api/package-assets/\".length));\n const path = safeJoin(join(ROOT, \"assets\"), rel);\n if (!path) {\n sendJson(res, 400, { error: \"invalid_path\" });\n return;\n }\n await serveFile(res, path, null);\n return;\n }\n if (url.pathname.startsWith(\"/api/\")) {\n sendJson(res, 404, { error: \"not_found\" });\n return;\n }\n if (vite) {\n vite.middlewares(req, res);\n return;\n }\n const path = safeJoin(DIST, url.pathname === \"/\" ? \"index.html\" : url.pathname);\n await serveFile(res, path ?? join(DIST, \"index.html\"), join(DIST, \"index.html\"));\n } catch (error) {\n console.error(error);\n if (!res.headersSent) sendJson(res, 500, { error: \"internal_error\" });\n else res.end();\n }\n});\n\nserver.listen(PORT, HOST, async () => {\n console.log(`App running at http://${HOST}:${PORT}`);\n if (!DEV && !existsSync(join(DIST, \"index.html\"))) {\n console.log(\"No UI build found. Run `npm run build` first, or `npm run dev`.\");\n }\n const example = join(ROOT, \".env.example\");\n if (existsSync(example)) {\n const names = (await readFile(example, \"utf8\"))\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => /^[A-Z0-9_]+=/.test(line))\n .map((line) => line.split(\"=\")[0]);\n const missing = names.filter((name) => !process.env[name]);\n if (missing.length > 0) {\n console.log(`Not set (see .env.example): ${missing.join(\", \")}`);\n }\n }\n});\n"],
|
|
6
|
-
["server/input-boundary.mjs", "import { lstat, readlink, realpath } from \"node:fs/promises\";\nimport { dirname, extname, isAbsolute, resolve, sep } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\n\nconst PATH_PROPERTIES = new Set([\"path\", \"file_path\", \"folder_path\", \"folder\", \"directory\", \"input_path\", \"output_path\"]);\nconst MEDIA_TYPES = new Set([\"image\", \"audio\", \"video\", \"document\", \"folder\", \"model3d\", \"model_3d\"]);\nconst
|
|
6
|
+
["server/input-boundary.mjs", "import { lstat, readlink, realpath } from \"node:fs/promises\";\nimport { dirname, extname, isAbsolute, resolve, sep } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\n\nconst PATH_PROPERTIES = new Set([\"path\", \"file_path\", \"folder_path\", \"folder\", \"directory\", \"input_path\", \"output_path\"]);\nconst MEDIA_TYPES = new Set([\"image\", \"audio\", \"video\", \"document\", \"folder\", \"model3d\", \"model_3d\"]);\nconst WRITERS = new Set([\"nodetool.text.SaveText\", \"nodetool.document.SaveDocument\", \"nodetool.image.SaveImage\", \"nodetool.audio.SaveAudio\", \"nodetool.video.SaveVideo\", \"nodetool.model3d.SaveModel3D\"]);\nconst FALLBACK_FILENAMES = {\n \"nodetool.document.SaveDocument\": \"document.txt\",\n \"nodetool.audio.SaveAudio\": \"audio.wav\",\n \"nodetool.video.SaveVideo\": \"video.mp4\",\n \"nodetool.image.SaveImage\": \"image_%Y-%m-%d_%H-%M-%S\",\n \"nodetool.model3d.SaveModel3D\": \"model_%Y-%m-%d_%H-%M-%S\"\n};\n\nfunction datedName(name) {\n const now = new Date();\n const fields = { Y: now.getFullYear(), m: now.getMonth() + 1, d: now.getDate(), H: now.getHours(), M: now.getMinutes(), S: now.getSeconds() };\n return name.replace(/%([YmdHMS])/g, (_, field) => String(fields[field]).padStart(field === \"Y\" ? 4 : 2, \"0\"));\n}\n\nasync function existingPath(path) {\n try {\n return await realpath(path);\n } catch (error) {\n if (error.code !== \"ENOENT\") throw error;\n try {\n if ((await lstat(path)).isSymbolicLink()) return existingPath(resolve(dirname(path), await readlink(path)));\n } catch (missing) {\n if (missing.code !== \"ENOENT\") throw missing;\n }\n const parent = dirname(path);\n if (parent === path) throw error;\n return resolve(await existingPath(parent), path.slice(parent.length + 1));\n }\n}\n\nexport function createNodeInputBoundary(roots) {\n const base = resolve(roots[0]);\n async function localPath(value) {\n if (value === null || value === undefined || value === \"\") return base;\n if (typeof value !== \"string\") {\n if (typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"Invalid node input path\");\n const result = { ...value };\n if (Object.hasOwn(result, \"path\")) result.path = await localPath(result.path);\n result.uri = typeof result.uri === \"string\" && result.uri !== \"\" ? result.uri : pathToFileURL(base).href;\n return result;\n }\n const path = /^file:/i.test(value) ? fileURLToPath(value) : isAbsolute(value) ? value : resolve(base, value);\n const actual = await existingPath(path);\n const allowed = await Promise.all(roots.map(existingPath));\n if (!allowed.some((root) => actual === root || actual.startsWith(root + sep))) {\n throw new Error(\"Node input path leaves this application's storage\");\n }\n return actual;\n }\n async function media(value) {\n if (Array.isArray(value)) return Promise.all(value.map(media));\n if (value === null || typeof value !== \"object\" || value instanceof Uint8Array) return value;\n const entries = await Promise.all(Object.entries(value).map(async ([key, entry]) => [key,\n key === \"uri\" && typeof entry === \"string\" && !/^(https?:|data:|asset:|package:|memory:)/i.test(entry)\n ? entry === \"\" ? \"\" : pathToFileURL(await localPath(entry)).href\n : await media(entry)\n ]));\n return Object.fromEntries(entries);\n }\n return async (inputs, metadata) => {\n const writer = WRITERS.has(metadata?.node_type);\n const defaults = Object.fromEntries((metadata?.properties ?? []).filter((property) => property.default !== undefined && (PATH_PROPERTIES.has(property.name) || MEDIA_TYPES.has(property.type?.type) || writer && [\"filename\", \"save_to_workspace\"].includes(property.name))).map((property) => [property.name, property.default]));\n const result = await media({ ...defaults, ...inputs });\n async function typed(value, type) {\n if (type?.type === \"list\" && Array.isArray(value)) return Promise.all(value.map((item) => typed(item, type.type_args?.[0])));\n if (type?.type === \"folder\") return localPath(value);\n if (MEDIA_TYPES.has(type?.type) && typeof value === \"string\" && !/^(https?:|data:|asset:|package:|memory:)/i.test(value)) return value === \"\" ? \"\" : pathToFileURL(await localPath(value)).href;\n return value;\n }\n for (const property of metadata?.properties ?? []) {\n if (!Object.hasOwn(result, property.name)) continue;\n if (writer && property.name === \"folder\" && result.save_to_workspace === true) {\n result.folder = base;\n continue;\n }\n if (PATH_PROPERTIES.has(property.name) || [\"file_path\", \"folder_path\"].includes(property.json_schema_extra?.type)) {\n result[property.name] = await localPath(result[property.name]);\n } else result[property.name] = await typed(result[property.name], property.type);\n }\n if (writer) {\n const folder = result.save_to_workspace === true ? base : typeof result.folder === \"string\" ? result.folder : result.folder?.path ?? result.folder?.uri ?? base;\n const destination = /^file:/i.test(folder) ? fileURLToPath(folder) : folder;\n const rawName = (result.filename == null ? \"\" : String(result.filename)).trim() || FALLBACK_FILENAMES[metadata.node_type] || \"\";\n const name = datedName(rawName);\n if (name.trim() !== \"\") {\n const writableRoot = await existingPath(base);\n const names = [...new Set([rawName, name])];\n if (!extname(name) && metadata.node_type === \"nodetool.image.SaveImage\") names.push(...[\"png\", \"jpg\", \"webp\", \"gif\", \"bmp\"].map((extension) => `${name}.${extension}`));\n if (!extname(name) && metadata.node_type === \"nodetool.model3d.SaveModel3D\") names.push(`${name}.${String(result.model?.format || extname(result.model?.uri ?? \"\").slice(1) || \"glb\").toLowerCase()}`);\n for (const filename of names) {\n const target = await localPath(resolve(destination || base, filename));\n if (target !== writableRoot && !target.startsWith(writableRoot + sep)) throw new Error(\"Node output path leaves this application's storage\");\n }\n }\n if (metadata.node_type === \"nodetool.document.SaveDocument\" && result.path) {\n result.path = await localPath(result.path);\n const writableRoot = await existingPath(base);\n if (typeof result.path !== \"string\" || result.path !== writableRoot && !result.path.startsWith(writableRoot + sep)) throw new Error(\"Node output path leaves this application's storage\");\n }\n }\n return result;\n };\n}\n\nexport function guardExecutor(executor, metadata, boundary, properties = {}) {\n return new Proxy(executor, {\n get(target, key) {\n const method = Reflect.get(target, key);\n if (key === \"initialize\") return async () => {\n const guarded = await boundary(properties, metadata);\n target.applyProperties?.(guarded);\n await method?.call(target);\n };\n if (typeof method !== \"function\") return method;\n if (key === \"process\") return async (inputs, ...args) => method.call(target, await boundary(inputs, metadata), ...args);\n if (key === \"genProcess\") return async function* (inputs, ...args) {\n yield* method.call(target, await boundary(inputs, metadata), ...args);\n };\n return method.bind(target);\n }\n });\n}\n"],
|
|
7
7
|
["server/lifecycle.mjs", "export function observeSessionCancellation(session, signal) {\n const cancel = () => session.cancel(\"cancelled\");\n signal?.addEventListener(\"abort\", cancel, { once: true });\n if (signal?.aborted) cancel();\n return () => signal?.removeEventListener(\"abort\", cancel);\n}\n"],
|
|
8
8
|
["server/media.mjs", "/**\n * Rewrites the media inside a run message into URLs the browser can load.\n *\n * A node emits a media ref in one of four shapes: inline bytes (`data`), a\n * `file://` URI inside this server's storage folder, an `asset://` reference\n * to a file the local store saved, or a URL some provider already hosts. The\n * first three mean nothing to a browser, so inline bytes are written to\n * storage and all three become `/api/storage/<key>`. Provider URLs and\n * `data:` URIs pass through unchanged.\n *\n * Run params go the other way: a file the browser uploaded arrives as\n * `/api/storage/<key>` and becomes the `file://` URI of the stored file.\n */\nimport { randomUUID } from \"node:crypto\";\nimport { join, normalize as normalizePath, sep } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nconst MEDIA_TYPES = new Set([\"image\", \"audio\", \"video\", \"document\", \"model_3d\", \"model3d\"]);\n\nconst EXTENSIONS = {\n \"image/png\": \"png\",\n \"image/jpeg\": \"jpg\",\n \"image/webp\": \"webp\",\n \"image/gif\": \"gif\",\n \"audio/mpeg\": \"mp3\",\n \"audio/wav\": \"wav\",\n \"audio/x-wav\": \"wav\",\n \"audio/ogg\": \"ogg\",\n \"video/mp4\": \"mp4\",\n \"video/webm\": \"webm\",\n \"application/pdf\": \"pdf\",\n \"model/gltf-binary\": \"glb\"\n};\n\nconst DEFAULT_EXTENSIONS = {\n image: \"png\",\n audio: \"mp3\",\n video: \"mp4\",\n document: \"bin\",\n model_3d: \"glb\",\n model3d: \"glb\"\n};\n\nconst isRecord = (value) =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/** Inline bytes as a Uint8Array, or null when `data` holds none. */\nconst bytesOf = (data) => {\n if (data instanceof Uint8Array) return data.length > 0 ? data : null;\n if (typeof data === \"string\" && data.length > 0) {\n // Raw base64 (never a data: URI) is the protocol's other inline form.\n return Buffer.from(data, \"base64\");\n }\n if (isRecord(data) && data.type === \"Buffer\" && Array.isArray(data.data)) {\n return Uint8Array.from(data.data);\n }\n return null;\n};\n\nexport function createMediaNormalizer(storage, assetKey = () => null) {\n const storagePrefix = `${pathToFileURL(storage.rootDir).toString()}/`;\n\n const storageUrl = (key) =>\n `/api/storage/${key.split(\"/\").map(encodeURIComponent).join(\"/\")}`;\n\n async function normalizeRef(ref) {\n const next = { ...ref };\n const bytes = bytesOf(ref.data);\n if (bytes) {\n const contentType = ref.content_type ?? ref.mime_type ?? undefined;\n const ext = EXTENSIONS[contentType] ?? DEFAULT_EXTENSIONS[ref.type] ?? \"bin\";\n const key = `outputs/${randomUUID()}.${ext}`;\n await storage.store(key, bytes, contentType);\n next.uri = storageUrl(key);\n delete next.data;\n } else if (typeof ref.uri === \"string\" && ref.uri.startsWith(storagePrefix)) {\n next.uri = storageUrl(decodeURIComponent(ref.uri.slice(storagePrefix.length)));\n } else if (typeof ref.uri === \"string\" && ref.uri.startsWith(\"asset://\")) {\n const key = assetKey(ref.uri);\n if (key) next.uri = storageUrl(key);\n } else if (!ref.uri && typeof ref.asset_id === \"string\") {\n const key = assetKey(`asset://${ref.asset_id}`);\n if (key) next.uri = storageUrl(key);\n }\n return next;\n }\n\n async function normalize(value, depth = 0) {\n if (depth > 32 || value == null) return value;\n if (Array.isArray(value)) {\n return Promise.all(value.map((item) => normalize(item, depth + 1)));\n }\n if (value instanceof Uint8Array) {\n return Buffer.from(value).toString(\"base64\");\n }\n if (!isRecord(value)) return value;\n const record =\n typeof value.type === \"string\" && MEDIA_TYPES.has(value.type)\n ? await normalizeRef(value)\n : value;\n const out = {};\n for (const [key, entry] of Object.entries(record)) {\n out[key] = await normalize(entry, depth + 1);\n }\n return out;\n }\n\n return normalize;\n}\n\n/**\n * Turns the `/api/storage/<key>` URIs of uploaded files inside run params back\n * into `file://` URIs a node can read. A key that leaves the storage folder is\n * dropped rather than resolved.\n */\nexport function createInputResolver(storage, { workspaceRelative = false } = {}) {\n const root = normalizePath(storage.rootDir);\n const PREFIX = \"/api/storage/\";\n\n const resolveUri = (uri) => {\n const key = uri.slice(PREFIX.length).split(\"/\").map(decodeURIComponent).join(\"/\");\n const path = normalizePath(join(root, key));\n if (!path.startsWith(root + sep)) throw new Error(\"Input storage handle leaves the storage directory\");\n return workspaceRelative ? path.slice(root.length + 1) : pathToFileURL(path).toString();\n };\n\n function resolve(value, depth = 0) {\n if (depth > 32) throw new Error(\"Input media exceeds the supported nesting depth\");\n if (value == null) return value;\n if (typeof value === \"string\" && value.startsWith(PREFIX)) return resolveUri(value);\n if (Array.isArray(value)) return value.map((item) => resolve(item, depth + 1));\n if (!isRecord(value)) return value;\n const out = {};\n for (const [key, entry] of Object.entries(value)) {\n if (key === \"uri\" && typeof entry === \"string\") {\n if (entry.startsWith(PREFIX)) out[key] = resolveUri(entry);\n else if (/^(https?:|data:|asset:|package:)/i.test(entry)) out[key] = entry;\n else throw new Error(\"Input media must use an uploaded storage handle or a supported media URI\");\n } else out[key] = resolve(entry, depth + 1);\n }\n return out;\n }\n\n return resolve;\n}\n"],
|
|
9
9
|
["server/models.mjs", "/**\n * The model catalog behind `ModelSelect`: every model the providers with a key\n * in `.env` can list, as model references a graph property accepts.\n *\n * Listing asks each configured provider once per model kind and keeps the\n * answer for the life of the process. Restart the server after changing keys.\n */\nimport {\n getProvider,\n isProviderConfigured,\n listRegisteredProviderIds\n} from \"@nodetool-ai/runtime\";\n\n/** Model reference type → the provider method that lists that kind. */\nconst LISTERS = {\n language_model: \"getAvailableLanguageModels\",\n image_model: \"getAvailableImageModels\",\n video_model: \"getAvailableVideoModels\",\n tts_model: \"getAvailableTTSModels\",\n asr_model: \"getAvailableASRModels\",\n music_model: \"getAvailableMusicModels\",\n embedding_model: \"getAvailableEmbeddingModels\",\n audio_to_audio_model: \"getAvailableAudioToAudioModels\"\n};\n\nexport const MODEL_KINDS = Object.keys(LISTERS);\n\nconst getSecret = (key) => Promise.resolve(process.env[key] ?? null);\n\nexport function createModelCatalog() {\n const cache = new Map();\n\n async function listKind(kind) {\n const method = LISTERS[kind];\n const out = [];\n for (const providerId of listRegisteredProviderIds()) {\n try {\n if (!(await isProviderConfigured(providerId, getSecret))) continue;\n const provider = await getProvider(providerId, getSecret);\n if (typeof provider[method] !== \"function\") continue;\n for (const model of await provider[method]()) {\n out.push({\n type: kind,\n provider: model.provider ?? providerId,\n id: model.id,\n name: model.name ?? model.id,\n ...(Array.isArray(model.supportedTasks) ? { supported_tasks: model.supportedTasks } : {})\n });\n }\n } catch (error) {\n console.warn(`[models] ${providerId} could not list ${kind}: ${error instanceof Error ? error.message : error}`);\n }\n }\n return out;\n }\n\n /** Models of one kind, narrowed to a task (`image_to_image`, ...) when given. */\n async function list(kind, task) {\n if (!LISTERS[kind]) return [];\n if (!cache.has(kind)) {\n const pending = listKind(kind);\n cache.set(kind, pending);\n pending.catch(() => cache.delete(kind));\n }\n const models = await cache.get(kind);\n return task\n ? models.filter((model) => !model.supported_tasks || model.supported_tasks.length === 0 || model.supported_tasks.includes(task))\n : models;\n }\n\n return { list };\n}\n"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-files.generated.js","sourceRoot":"","sources":["../src/template-files.generated.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAEvE,MAAM,CAAC,MAAM,cAAc,GAAgC,IAAI,GAAG,CAAC;IACjE,CAAC,WAAW,EAAE,4CAA4C,CAAC;IAC3D,CAAC,YAAY,EAAE,kXAAkX,CAAC;IAClY,CAAC,kBAAkB,EAAE,s1RAAs1R,CAAC;IAC52R,CAAC,2BAA2B,EAAE,
|
|
1
|
+
{"version":3,"file":"template-files.generated.js","sourceRoot":"","sources":["../src/template-files.generated.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAEvE,MAAM,CAAC,MAAM,cAAc,GAAgC,IAAI,GAAG,CAAC;IACjE,CAAC,WAAW,EAAE,4CAA4C,CAAC;IAC3D,CAAC,YAAY,EAAE,kXAAkX,CAAC;IAClY,CAAC,kBAAkB,EAAE,s1RAAs1R,CAAC;IAC52R,CAAC,2BAA2B,EAAE,g3OAAg3O,CAAC;IAC/4O,CAAC,sBAAsB,EAAE,6RAA6R,CAAC;IACvT,CAAC,kBAAkB,EAAE,0iLAA0iL,CAAC;IAChkL,CAAC,mBAAmB,EAAE,6hFAA6hF,CAAC;IACpjF,CAAC,uBAAuB,EAAE,03DAA03D,CAAC;IACr5D,CAAC,mBAAmB,EAAE,onTAAonT,CAAC;IAC3oT,CAAC,2BAA2B,EAAE,uXAAuX,CAAC;IACtZ,CAAC,kBAAkB,EAAE,m/NAAm/N,CAAC;IACzgO,CAAC,aAAa,EAAE,ytCAAytC,CAAC;IAC1uC,CAAC,cAAc,EAAE,8SAA8S,CAAC;IAChU,CAAC,wBAAwB,EAAE,u7LAAu7L,CAAC;IACn9L,CAAC,uBAAuB,EAAE,8lDAA8lD,CAAC;IACznD,CAAC,4BAA4B,EAAE,kpDAAkpD,CAAC;IAClrD,CAAC,uBAAuB,EAAE,8uJAA8uJ,CAAC;IACzwJ,CAAC,sBAAsB,EAAE,s/DAAs/D,CAAC;IAChhE,CAAC,8BAA8B,EAAE,ghdAAghd,CAAC;IACljd,CAAC,2BAA2B,EAAE,g+QAAg+Q,CAAC;IAC//Q,CAAC,gBAAgB,EAAE,+1TAA+1T,CAAC;IACn3T,CAAC,0BAA0B,EAAE,qjIAAqjI,CAAC;IACnlI,CAAC,yBAAyB,EAAE,0zmBAA0zmB,CAAC;IACv1mB,CAAC,wBAAwB,EAAE,m09BAAm09B,CAAC;IAC/19B,CAAC,wBAAwB,EAAE,i5DAAi5D,CAAC;IAC76D,CAAC,sBAAsB,EAAE,g4UAAg4U,CAAC;IAC15U,CAAC,+BAA+B,EAAE,wnFAAwnF,CAAC;IAC3pF,CAAC,eAAe,EAAE,uaAAua,CAAC;IAC1b,CAAC,gBAAgB,EAAE,mJAAmJ,CAAC;CACxK,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodetool-ai/app-export",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.17",
|
|
4
4
|
"description": "Export a NodeTool mini app as a standalone JavaScript project: a Vite UI plus a local Node server that runs the app's workflows in process",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"lint": "node ../../scripts/run-tsc.mjs --noEmit && node ../../scripts/run-tsc.mjs --noEmit -p template/tsconfig.json && node ../../scripts/run-tsc.mjs --noEmit -p mcp-app/tsconfig.json"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@nodetool-ai/app-runtime": "0.8.
|
|
22
|
+
"@nodetool-ai/app-runtime": "0.8.17"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^22.0.0",
|