@agimon-ai/po-codemode 0.0.1-alpha.2 → 0.0.1-alpha.4
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.
- package/README.md +22 -10
- package/dist/{codemodeTools-CLgSDqfU.cjs → codemodeTools-BQDVk-4P.cjs} +41 -3
- package/dist/codemodeTools-BQDVk-4P.cjs.map +1 -0
- package/dist/{codemodeTools-BdwOARH8.mjs → codemodeTools-D7CcAB18.mjs} +41 -3
- package/dist/codemodeTools-D7CcAB18.mjs.map +1 -0
- package/dist/extensions/server.cjs +445 -17
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +446 -18
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/llms.txt +3 -1
- package/package.json +7 -6
- package/src/prompts/codemode-how-to-llm/SKILL.md +29 -0
- package/src/prompts/codemode-how-to-shell/SKILL.md +21 -0
- package/src/prompts/{po-use-codemode → how-to-codemode}/SKILL.md +15 -2
- package/dist/codemodeTools-BdwOARH8.mjs.map +0 -1
- package/dist/codemodeTools-CLgSDqfU.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -19,26 +19,38 @@ The package declares poServer metadata for native server discovery. Include it t
|
|
|
19
19
|
|
|
20
20
|
## Use
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Call `discover({})` to list the session's contributed namespaces and reusable scripts. Use `exec` to run a TypeScript async function body against them.
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
/po-codemode
|
|
26
|
-
```
|
|
24
|
+
## Package behavior
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
Call `discover({ namespace: 'browser' })` for current types, then `exec({ code: 'return await browser.snapshot({});' })`. Namespace plugins supply their own `codemode-how-to-<plugin>` guides. Their summaries and the base `how-to-codemode` guide stay in the system prompt, outside skill search; `load_skill` still reads their full instructions by exact name.
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
### npm imports
|
|
29
|
+
|
|
30
|
+
On Node hosts, `await import('npm:is-number@7')` auto-installs through upm and returns the real module namespace. Registry names, scopes, versions, ranges, tags and subpaths are supported. The shared store uses the existing two-day release-age policy (exact and locked versions bypass it); lifecycle scripts are skipped. First installs may need a larger exec `timeoutMs`.
|
|
31
|
+
|
|
32
|
+
Packages run with full Node authority. Native code is not preemptible, package resources are not automatically closed, and cancellation cannot stop an install already in progress. `new` works on imported constructors; subclassing and `instanceof` are unsupported. Edge hosts cannot import. Script globals still omit `fetch`, `require` and `process`.
|
|
33
|
+
|
|
34
|
+
### Short Bash commands
|
|
35
|
+
|
|
36
|
+
`shell.bash({ command, timeoutMs? })` returns `{ stdout, stderr, exitCode }` for code-side post-processing. It runs in the session cwd with its admitted environment. Nonzero exits are returned; startup failures, timeout and cancellation reject. The deadline defaults to 10 seconds (maximum 120 seconds) and the command is cancelled when exec ends. Each output stream is capped at 32768 characters with a `[truncated]` marker.
|
|
37
|
+
|
|
38
|
+
This is foreground-only execution, not Runner supervision: no background option, interactive terminal, Runner IDs or persistent logs. The standalone Runner `bash` tool remains visible for those workflows. See [shell guidance](./src/prompts/codemode-how-to-shell/SKILL.md).
|
|
39
|
+
|
|
40
|
+
### LLM transformations
|
|
41
|
+
|
|
42
|
+
`llm.complete({ prompt, input? })` returns `{ text, model }`; `llm.json({ prompt, input?, schema })` returns `{ value, model }`. Calls are stateless, use no session history, and count toward session usage. JSON results require one private `return_result` call and local schema validation; tool choice is prompt-directed.
|
|
31
43
|
|
|
32
|
-
|
|
44
|
+
Set the optional `llmModel: provider/id` in the `@agimon-ai/po-codemode` package configuration to choose a default. A per-call `model` wins, otherwise the current session model is used. Limits per exec are 8 calls and 2 concurrent calls, with 64 KiB input per call and 1024 default / 4096 maximum output tokens. There are no retries. See [LLM guidance](./src/prompts/codemode-how-to-llm/SKILL.md) for pipelines and schema constraints.
|
|
33
45
|
|
|
34
|
-
##
|
|
46
|
+
## How-to guide
|
|
35
47
|
|
|
36
|
-
The published package includes `llms.txt` and `src/prompts/
|
|
48
|
+
The published package includes `llms.txt` and `src/prompts/how-to-codemode/SKILL.md`. Link additional prompts from `llms.txt` and declare them through named `resource/*.server.ts` routes using `defineResource`. Server lifecycle registration owns their disposal. Publish prompts under `src/prompts`, never export Markdown or copy it into `dist`.
|
|
37
49
|
|
|
38
50
|
## Public API
|
|
39
51
|
|
|
40
52
|
```ts
|
|
41
|
-
import {
|
|
53
|
+
import { createCodemodeRegistry, createCodemodeTools } from '@agimon-ai/po-codemode';
|
|
42
54
|
```
|
|
43
55
|
|
|
44
56
|
The native server entry is also available at:
|
|
@@ -248,7 +248,7 @@ function sleep(ms, signal) {
|
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
/** `discover` and `exec` for one session, over the namespaces its packages contributed. */
|
|
251
|
-
function createCodemodeTools({ registry, isolate, scripts }) {
|
|
251
|
+
function createCodemodeTools({ registry, isolate, scripts, npm }) {
|
|
252
252
|
let running = 0;
|
|
253
253
|
const visible = (service) => registry.list().filter((namespace) => service.liveObjects || namespace.portable === true);
|
|
254
254
|
return {
|
|
@@ -364,7 +364,45 @@ function createCodemodeTools({ registry, isolate, scripts }) {
|
|
|
364
364
|
signal: runSignal,
|
|
365
365
|
deny: [...deny],
|
|
366
366
|
onDiagnostic: output.note,
|
|
367
|
-
|
|
367
|
+
resolveImport: async (specifier) => {
|
|
368
|
+
if (!specifier.startsWith("npm:")) {
|
|
369
|
+
if (!scripts) throw new Error("Script imports are not available on this host.");
|
|
370
|
+
return scripts.resolve(specifier, activeDomains(execution));
|
|
371
|
+
}
|
|
372
|
+
const loader = npm?.();
|
|
373
|
+
if (!loader) throw new Error("npm imports are not available on this host.");
|
|
374
|
+
run.signal.throwIfAborted();
|
|
375
|
+
const started = Date.now();
|
|
376
|
+
try {
|
|
377
|
+
const exports = await loader.import(specifier, {
|
|
378
|
+
sessionId: run.sessionId,
|
|
379
|
+
signal: run.signal
|
|
380
|
+
});
|
|
381
|
+
run.signal.throwIfAborted();
|
|
382
|
+
run.record?.({
|
|
383
|
+
name: "npm.import",
|
|
384
|
+
tool: "npm",
|
|
385
|
+
args: { specifier },
|
|
386
|
+
ms: Date.now() - started,
|
|
387
|
+
ok: true
|
|
388
|
+
});
|
|
389
|
+
return {
|
|
390
|
+
kind: "module",
|
|
391
|
+
id: specifier,
|
|
392
|
+
exports
|
|
393
|
+
};
|
|
394
|
+
} catch (error) {
|
|
395
|
+
run.record?.({
|
|
396
|
+
name: "npm.import",
|
|
397
|
+
tool: "npm",
|
|
398
|
+
args: { specifier },
|
|
399
|
+
ms: Date.now() - started,
|
|
400
|
+
ok: false,
|
|
401
|
+
error: error instanceof Error ? error.message : String(error)
|
|
402
|
+
});
|
|
403
|
+
throw error;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
368
406
|
}), output, saved, calls);
|
|
369
407
|
} catch (error) {
|
|
370
408
|
return text(`Code mode could not run the script: ${error instanceof Error ? error.message : String(error)}`, true);
|
|
@@ -391,4 +429,4 @@ Object.defineProperty(exports, "createCodemodeTools", {
|
|
|
391
429
|
}
|
|
392
430
|
});
|
|
393
431
|
|
|
394
|
-
//# sourceMappingURL=codemodeTools-
|
|
432
|
+
//# sourceMappingURL=codemodeTools-BQDVk-4P.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemodeTools-BQDVk-4P.cjs","names":["Type","invalidImageReason"],"sources":["../src/services/codemodeRegistry/index.ts","../src/schemas/codemodeTools.ts","../src/services/codemodeTools/index.ts"],"sourcesContent":["import {\n assertCodemodeNamespaceName,\n type PoCodemodeNamespace,\n type PoCodemodeRegistration,\n type PoCodemodeScriptSource,\n type PoCodemodeService,\n} from '@agimon-ai/po-core/codemode';\n\n/** The session's namespaces and script folders, in registration order. One name per session. */\nexport function createCodemodeRegistry(): PoCodemodeService {\n const entries = new Map<string, { source: string; namespace: PoCodemodeNamespace }>();\n const scripts = new Set<PoCodemodeScriptSource>();\n const listeners = new Set<() => void>();\n const notify = (): void => {\n for (const listener of listeners) listener();\n };\n return {\n register(source: string, namespace: PoCodemodeNamespace): PoCodemodeRegistration {\n assertCodemodeNamespaceName(namespace.name);\n const taken = entries.get(namespace.name);\n if (taken) {\n throw new Error(\n `Code-mode namespace \"${namespace.name}\" from ${source} is already registered by ${taken.source}.`,\n );\n }\n const entry = { source, namespace };\n entries.set(namespace.name, entry);\n notify();\n return {\n dispose: () => {\n if (entries.get(namespace.name) !== entry) return;\n entries.delete(namespace.name);\n notify();\n },\n };\n },\n list: () => [...entries.values()].map((entry) => entry.namespace),\n registerScripts(_source: string, entry: PoCodemodeScriptSource): PoCodemodeRegistration {\n const owned = { domain: entry.domain, directory: entry.directory };\n scripts.add(owned);\n notify();\n return { dispose: () => void (scripts.delete(owned) && notify()) };\n },\n listScripts: () => [...scripts],\n subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n","import { Type, type Static } from 'typebox';\n\nexport const DiscoverToolSchema = Type.Object({\n namespace: Type.Optional(Type.String({ description: 'Show the full TypeScript declarations of one namespace.' })),\n query: Type.Optional(Type.String({ description: 'Find matching members across every namespace.' })),\n});\nexport type DiscoverToolParams = Static<typeof DiscoverToolSchema>;\n\nexport const ExecToolSchema = Type.Object({\n code: Type.String({\n description:\n 'TypeScript body of an async function. Top-level await and return work. The returned value, console output and image() calls come back.',\n }),\n timeoutMs: Type.Optional(\n Type.Integer({ minimum: 1_000, maximum: 120_000, description: 'Deadline in milliseconds. Default 30000.' }),\n ),\n});\nexport type ExecToolParams = Static<typeof ExecToolSchema>;\n","import type {\n PoCodemodeCall,\n PoCodemodeNamespace,\n PoCodemodeRun,\n PoCodemodeService,\n} from '@agimon-ai/po-core/codemode';\nimport {\n invalidImageReason,\n type PoHeadlessContent,\n type PoHeadlessExecutionContext,\n type PoHeadlessTool,\n type PoHeadlessToolResult,\n} from '@agimon-ai/po-core/headless';\nimport type { PoIsolateResult, PoIsolateService, PoNpm } from '@agimon-ai/po-core/platform';\n\nimport {\n DiscoverToolSchema,\n ExecToolSchema,\n type DiscoverToolParams,\n type ExecToolParams,\n} from '../../schemas/codemodeTools';\nimport type { CodemodeScriptsPort } from '../codemodeScripts/type';\n\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst MAX_TIMEOUT_MS = 120_000;\nconst MIN_TIMEOUT_MS = 1_000;\nconst MAX_LOG_CHARS = 10_000;\nconst MAX_VALUE_CHARS = 64 * 1024;\nconst MAX_DECLARATION_CHARS = 24_000;\nconst MAX_QUERY_LINES = 40;\n// The main agent and its subagents share one exec tool, so several runs can overlap.\nconst MAX_CONCURRENT_RUNS = 8;\n// Recorded calls ride the result's details into the transcript, so they are few and small.\nconst MAX_RECORDED_CALLS = 50;\nconst MAX_RECORDED_TEXT = 8_000;\nconst MAX_RECORDED_JSON = 16_000;\nconst MAX_LISTED_SCRIPTS = 20;\nconst MAX_IMAGES = 4;\nconst MAX_IMAGE_BYTES = 5 * 1024 * 1024;\nconst DEFAULT_IMAGE_MIME = 'image/png';\nconst MEMBER_LINE = /^\\s{2}(?:readonly\\s+)?(\\w+)\\s*[(?:<]/u;\n\nconst GLOBALS_HELP =\n 'Globals: console.log/info/warn/error, image(data, mimeType?) to return a screenshot, sleep(ms). ' +\n 'Return a value with `return`.';\nconst SCRIPTS_HELP =\n 'Every exec run is saved. Call a saved script with `await (await import(specifier))(args)`; ' +\n 'inside it, `args` is the argument and its `return` is the result.';\n\nexport interface CodemodeToolsOptions {\n readonly registry: PoCodemodeService;\n /** Resolved per call, so a host that binds the isolate late still works. */\n readonly isolate: () => PoIsolateService | undefined;\n /** Saves every exec body and backs `import()`; without it nothing is saved or importable. */\n readonly scripts?: CodemodeScriptsPort;\n readonly npm?: () => PoNpm | undefined;\n}\n\nexport interface CodemodeTools {\n readonly discover: PoHeadlessTool<typeof DiscoverToolSchema>;\n readonly exec: PoHeadlessTool<typeof ExecToolSchema>;\n}\n\nfunction text(value: string, isError = false): PoHeadlessToolResult {\n return { content: [{ type: 'text', text: value }], ...(isError ? { isError: true } : {}) };\n}\n\nfunction truncate(value: string, limit: number): string {\n return value.length <= limit ? value : `${value.slice(0, limit)}\\n[truncated ${value.length - limit} chars]`;\n}\n\nfunction format(value: unknown): string {\n if (typeof value === 'string') return value;\n try {\n const json = JSON.stringify(value, null, 2);\n if (json !== undefined) return json;\n } catch {\n // Cyclic or exotic values fall back to their string form.\n }\n return String(value);\n}\n\nfunction memberNames(namespace: PoCodemodeNamespace): string[] {\n const names = new Set<string>();\n const declaration =\n new RegExp(`^declare const ${namespace.name}: \\\\{([\\\\s\\\\S]*?)^\\\\};`, 'mu').exec(namespace.declarations)?.[1] ?? '';\n for (const line of declaration.split('\\n')) {\n const name = MEMBER_LINE.exec(line)?.[1];\n if (name) names.add(name);\n }\n return [...names];\n}\n\nfunction bytesToBase64(bytes: Uint8Array): string {\n let binary = '';\n for (let index = 0; index < bytes.length; index += 0x8000) {\n binary += String.fromCharCode(...bytes.subarray(index, index + 0x8000));\n }\n return btoa(binary);\n}\n\n/** Collects what a script prints and the images it returns, within the output caps. */\nfunction createOutput() {\n const lines: string[] = [];\n const images: { data: string; mimeType: string }[] = [];\n let imageBytes = 0;\n const log =\n (level: string) =>\n (...args: unknown[]) => {\n const line = args.map(format).join(' ');\n lines.push(level === 'log' || level === 'info' ? line : `[${level}] ${line}`);\n };\n const note = (message: string): void => void lines.push(`[note] ${message}`);\n const addImage = (input: unknown, mimeType?: unknown): void => {\n if (typeof input === 'object' && input !== null && 'images' in input && Array.isArray(input.images)) {\n for (const image of input.images) addImage(image);\n return;\n }\n let data: string;\n let mime = typeof mimeType === 'string' ? mimeType : DEFAULT_IMAGE_MIME;\n if (typeof input === 'string')\n data = input.replace(/^data:([^;]+);base64,/u, (_match, type: string) => ((mime = type), ''));\n else if (ArrayBuffer.isView(input))\n data = bytesToBase64(new Uint8Array(input.buffer, input.byteOffset, input.byteLength));\n else if (typeof input === 'object' && input !== null && 'data' in input && typeof input.data === 'string') {\n data = input.data;\n if ('mimeType' in input && typeof input.mimeType === 'string') mime = input.mimeType;\n } else throw new TypeError('image() takes base64 text, bytes, or { data, mimeType }.');\n if (images.length >= MAX_IMAGES) throw new RangeError(`An exec run returns at most ${MAX_IMAGES} images.`);\n imageBytes += Math.ceil((data.length * 3) / 4);\n if (imageBytes > MAX_IMAGE_BYTES) throw new RangeError('Images from one exec run exceed 5 MB.');\n const invalid = invalidImageReason(data, mime);\n if (invalid !== undefined) throw new TypeError(`image() rejected an undecodable image: ${invalid}.`);\n images.push({ data, mimeType: mime });\n };\n const console = { log: log('log'), info: log('info'), warn: log('warn'), error: log('error'), debug: log('debug') };\n return { console, note, addImage, lines, images };\n}\n\n/** The session's active domains; every registered domain when the host reports none. */\nfunction activeDomains(execution: PoHeadlessExecutionContext | undefined): readonly string[] | undefined {\n return execution?.selection?.domains;\n}\n\n/** A JSON copy of `value`, or undefined when it does not serialise or is larger than `limit` characters. */\nfunction bounded<T>(value: T, limit: number): T | undefined {\n try {\n const json = JSON.stringify(value);\n return json !== undefined && json.length <= limit ? (JSON.parse(json) as T) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** The call as it is kept in the transcript: text blocks only, clipped, with args and details dropped when large. */\nfunction recordedCall(call: PoCodemodeCall): PoCodemodeCall {\n const content = (call.result?.content ?? []).flatMap((block) => {\n const { type, text } = (block ?? {}) as { type?: unknown; text?: unknown };\n return type === 'text' && typeof text === 'string'\n ? [{ type: 'text', text: truncate(text, MAX_RECORDED_TEXT) }]\n : [];\n });\n const details = bounded(call.result?.details, MAX_RECORDED_JSON);\n return {\n name: call.name,\n tool: call.tool,\n args: bounded(call.args, MAX_RECORDED_JSON) ?? {},\n ok: call.ok,\n ms: Math.max(0, Math.round(call.ms)),\n ...(call.error === undefined ? {} : { error: truncate(call.error, MAX_RECORDED_TEXT) }),\n ...(call.result === undefined ? {} : { result: { content, ...(details === undefined ? {} : { details }) } }),\n };\n}\n\nfunction toResult(\n result: PoIsolateResult,\n output: ReturnType<typeof createOutput>,\n saved: string | undefined,\n calls: readonly PoCodemodeCall[],\n): PoHeadlessToolResult {\n const content: PoHeadlessContent[] = [];\n if (output.lines.length > 0) content.push({ type: 'text', text: truncate(output.lines.join('\\n'), MAX_LOG_CHARS) });\n if (result.ok) {\n if (ArrayBuffer.isView(result.value)) {\n content.push({ type: 'text', text: 'The script returned bytes. Pass them to image(data, mimeType) instead.' });\n } else if (result.value !== undefined) {\n content.push({ type: 'text', text: truncate(format(result.value), MAX_VALUE_CHARS) });\n }\n } else {\n const { kind, name, message } = result.error;\n const hint = kind === 'timeout' ? ' Raise timeoutMs or split the work into smaller exec calls.' : '';\n content.push({ type: 'text', text: `${name}: ${message}${hint}` });\n }\n if (content.length === 0) content.push({ type: 'text', text: '(no return value)' });\n if (saved !== undefined) content.push({ type: 'text', text: saved });\n for (const image of output.images) content.push({ type: 'image', data: image.data, mimeType: image.mimeType });\n return {\n content,\n ...(calls.length > 0 ? { details: { calls } } : {}),\n ...(result.ok ? {} : { isError: true }),\n };\n}\n\nfunction sleep(ms: number, signal: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal.aborted) return reject(new Error('Run ended.'));\n const timer = setTimeout(resolve, Math.max(0, ms));\n signal.addEventListener(\n 'abort',\n () => {\n clearTimeout(timer);\n reject(new Error('Run ended.'));\n },\n { once: true },\n );\n });\n}\n\n/** `discover` and `exec` for one session, over the namespaces its packages contributed. */\nexport function createCodemodeTools({ registry, isolate, scripts, npm }: CodemodeToolsOptions): CodemodeTools {\n let running = 0;\n\n const visible = (service: PoIsolateService): PoCodemodeNamespace[] =>\n registry.list().filter((namespace) => service.liveObjects || namespace.portable === true);\n\n // ponytail: the cockpit's generic tool item renders both for now; add a poWeb renderer for exec code and images when it earns one.\n // web-plugin-tool-renderers: ignore discover, plain text result\n const discover: CodemodeTools['discover'] = {\n name: 'discover',\n label: 'Discover',\n description:\n 'List the code-mode namespaces and reusable scripts you can use from `exec`, show one namespace in full, ' +\n 'or search members and scripts. ' +\n 'Not required before exec: its description already names the namespaces.',\n parameters: DiscoverToolSchema,\n promptSnippet: 'List code-mode namespaces and their TypeScript declarations',\n executionMode: 'parallel',\n async execute(_toolCallId, parameters: DiscoverToolParams, _signal, _onUpdate, execution) {\n const service = isolate();\n if (!service) return text('Code mode is not available on this host.', true);\n const namespaces = visible(service);\n // Imports need a host with live objects; the edge saves scripts but cannot chain them.\n const listed = scripts && service.liveObjects ? await scripts.list(activeDomains(execution)) : [];\n if (parameters.namespace !== undefined) {\n const found = namespaces.find((namespace) => namespace.name === parameters.namespace);\n if (!found) {\n const names = namespaces.map((namespace) => namespace.name).join(', ') || 'none';\n return text(`Unknown namespace \"${parameters.namespace}\". Registered: ${names}.`, true);\n }\n return text(truncate(found.declarations, MAX_DECLARATION_CHARS));\n }\n if (parameters.query !== undefined) {\n const needle = parameters.query.toLowerCase();\n const hits: string[] = [];\n for (const namespace of namespaces) {\n const lines = namespace.declarations.split('\\n');\n lines.forEach((line, index) => {\n if (!line.toLowerCase().includes(needle) || hits.length >= MAX_QUERY_LINES) return;\n const doc = lines[index - 1]?.trim().startsWith('/**') ? `${lines[index - 1]?.trim()} ` : '';\n hits.push(`${namespace.name}: ${doc}${line.trim()}`);\n });\n }\n for (const script of listed) {\n if (hits.length >= MAX_QUERY_LINES) break;\n if (`${script.specifier} ${script.description}`.toLowerCase().includes(needle)) {\n hits.push(`script ${script.specifier}: ${script.description}`);\n }\n }\n return text(hits.length > 0 ? hits.join('\\n') : `No members or scripts match \"${parameters.query}\".`);\n }\n const sections: string[] = [];\n if (namespaces.length === 0) sections.push('No namespaces are registered in this session.');\n for (const namespace of namespaces) {\n sections.push(`- ${namespace.name}: ${namespace.summary}\\n members: ${memberNames(namespace).join(', ')}`);\n }\n sections.push(GLOBALS_HELP);\n if (!service.liveObjects) sections.push('This host runs plain JavaScript with JSON-only functions.');\n if (listed.length > 0) {\n sections.push(`Scripts. ${SCRIPTS_HELP}`);\n for (const script of listed.slice(0, MAX_LISTED_SCRIPTS)) {\n sections.push(`- ${script.specifier}${script.description ? `: ${script.description}` : ''}`);\n }\n if (listed.length > MAX_LISTED_SCRIPTS) {\n sections.push(`...and ${listed.length - MAX_LISTED_SCRIPTS} more; use discover({ query }) to search.`);\n }\n }\n if (namespaces.length > 0) sections.push('Call discover({ namespace }) for full types.');\n return text(sections.join('\\n'));\n },\n };\n\n // web-plugin-tool-renderers: ignore exec, generic item until a code and image renderer exists\n const exec: CodemodeTools['exec'] = {\n name: 'exec',\n label: 'Exec',\n get description(): string {\n const service = isolate();\n const namespaces = service ? visible(service) : [];\n const listed = namespaces.map((namespace) => `- ${namespace.name}: ${namespace.summary}`).join('\\n');\n return [\n 'Run a TypeScript script inside the Po server with live objects from the namespaces below in scope.',\n 'It runs with full server trust, like bash. Keep each call to one logical step.',\n listed || '(no namespaces registered yet; call discover to check)',\n GLOBALS_HELP,\n ...(scripts && service?.liveObjects ? [`${SCRIPTS_HELP} discover lists saved and domain scripts.`] : []),\n 'Use discover({ namespace }) for full signatures when needed.',\n ].join('\\n');\n },\n parameters: ExecToolSchema,\n promptSnippet: 'Run a TypeScript script against live Po objects (browser and other namespaces)',\n executionMode: 'serial',\n async execute(_toolCallId, parameters: ExecToolParams, signal, _onUpdate, execution) {\n const service = isolate();\n if (!service) return text('Code mode is not available on this host.', true);\n if (running >= MAX_CONCURRENT_RUNS)\n return text(`This session already has ${MAX_CONCURRENT_RUNS} exec runs active. Wait for one to finish.`, true);\n running += 1;\n const controller = new AbortController();\n const runSignal = signal ? AbortSignal.any([signal, controller.signal]) : controller.signal;\n const cleanups: (() => void | Promise<void>)[] = [];\n const calls: PoCodemodeCall[] = [];\n const output = createOutput();\n const run: PoCodemodeRun = {\n sessionId: execution.sessionId,\n signal: runSignal,\n onDispose: (cleanup) => void cleanups.push(cleanup),\n record: (call) => {\n if (calls.length < MAX_RECORDED_CALLS) calls.push(recordedCall(call));\n },\n };\n try {\n let saved: string | undefined;\n try {\n const file = await scripts?.save(parameters.code);\n if (file) saved = `Saved as ${file.specifier} (${file.path})`;\n } catch (error) {\n output.note(`Could not save the script: ${error instanceof Error ? error.message : String(error)}`);\n }\n const globals: Record<string, unknown> = {\n console: output.console,\n image: output.addImage,\n sleep: (ms: number) => sleep(ms, runSignal),\n };\n const deny = new Set<string>();\n for (const namespace of visible(service)) {\n globals[namespace.name] = namespace.bind(run);\n for (const member of namespace.deny ?? []) deny.add(member);\n }\n const deadlineMs = Math.min(\n MAX_TIMEOUT_MS,\n Math.max(MIN_TIMEOUT_MS, parameters.timeoutMs ?? DEFAULT_TIMEOUT_MS),\n );\n const result = await service.run({\n source: parameters.code,\n globals,\n deadlineMs,\n signal: runSignal,\n deny: [...deny],\n onDiagnostic: output.note,\n resolveImport: async (specifier) => {\n if (!specifier.startsWith('npm:')) {\n if (!scripts) throw new Error('Script imports are not available on this host.');\n return scripts.resolve(specifier, activeDomains(execution));\n }\n const loader = npm?.();\n if (!loader) throw new Error('npm imports are not available on this host.');\n run.signal.throwIfAborted();\n const started = Date.now();\n try {\n const exports = await loader.import(specifier, { sessionId: run.sessionId, signal: run.signal });\n run.signal.throwIfAborted();\n run.record?.({\n name: 'npm.import',\n tool: 'npm',\n args: { specifier },\n ms: Date.now() - started,\n ok: true,\n });\n return { kind: 'module', id: specifier, exports };\n } catch (error) {\n run.record?.({\n name: 'npm.import',\n tool: 'npm',\n args: { specifier },\n ms: Date.now() - started,\n ok: false,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n },\n });\n return toResult(result, output, saved, calls);\n } catch (error) {\n return text(\n `Code mode could not run the script: ${error instanceof Error ? error.message : String(error)}`,\n true,\n );\n } finally {\n controller.abort();\n for (const cleanup of cleanups.reverse()) {\n await Promise.resolve()\n .then(cleanup)\n .catch((error: unknown) => output.note(`cleanup failed: ${String(error)}`));\n }\n running -= 1;\n }\n },\n };\n\n return { discover, exec };\n}\n"],"mappings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I;SAAW,QAAQ,IAAI;QAAO,CAAC;QAC/F,IAAI,OAAO,eAAe;QAC1B,IAAI,SAAS;SACX,MAAM;SACN,MAAM;SACN,MAAM,EAAE,UAAU;SAClB,IAAI,KAAK,IAAI,IAAI;SACjB,IAAI;QACN,CAAC;QACD,OAAO;SAAE,MAAM;SAAU,IAAI;SAAW;QAAQ;OAClD,SAAS,OAAO;QACd,IAAI,SAAS;SACX,MAAM;SACN,MAAM;SACN,MAAM,EAAE,UAAU;SAClB,IAAI,KAAK,IAAI,IAAI;SACjB,IAAI;SACJ,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;QAC9D,CAAC;QACD,MAAM;OACR;MACF;KACF,CAAC,GACuB,QAAQ,OAAO,KAAK;IAC9C,SAAS,OAAO;KACd,OAAO,KACL,uCAAuC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,KAC5F,IACF;IACF,UAAU;KACR,WAAW,MAAM;KACjB,KAAK,MAAM,WAAW,SAAS,QAAQ,GACrC,MAAM,QAAQ,QAAQ,CAAC,CACpB,KAAK,OAAO,CAAC,CACb,OAAO,UAAmB,OAAO,KAAK,mBAAmB,OAAO,KAAK,GAAG,CAAC;KAE9E,WAAW;IACb;GACF;EAGoB;CAAE;AAC1B"}
|
|
@@ -248,7 +248,7 @@ function sleep(ms, signal) {
|
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
/** `discover` and `exec` for one session, over the namespaces its packages contributed. */
|
|
251
|
-
function createCodemodeTools({ registry, isolate, scripts }) {
|
|
251
|
+
function createCodemodeTools({ registry, isolate, scripts, npm }) {
|
|
252
252
|
let running = 0;
|
|
253
253
|
const visible = (service) => registry.list().filter((namespace) => service.liveObjects || namespace.portable === true);
|
|
254
254
|
return {
|
|
@@ -364,7 +364,45 @@ function createCodemodeTools({ registry, isolate, scripts }) {
|
|
|
364
364
|
signal: runSignal,
|
|
365
365
|
deny: [...deny],
|
|
366
366
|
onDiagnostic: output.note,
|
|
367
|
-
|
|
367
|
+
resolveImport: async (specifier) => {
|
|
368
|
+
if (!specifier.startsWith("npm:")) {
|
|
369
|
+
if (!scripts) throw new Error("Script imports are not available on this host.");
|
|
370
|
+
return scripts.resolve(specifier, activeDomains(execution));
|
|
371
|
+
}
|
|
372
|
+
const loader = npm?.();
|
|
373
|
+
if (!loader) throw new Error("npm imports are not available on this host.");
|
|
374
|
+
run.signal.throwIfAborted();
|
|
375
|
+
const started = Date.now();
|
|
376
|
+
try {
|
|
377
|
+
const exports = await loader.import(specifier, {
|
|
378
|
+
sessionId: run.sessionId,
|
|
379
|
+
signal: run.signal
|
|
380
|
+
});
|
|
381
|
+
run.signal.throwIfAborted();
|
|
382
|
+
run.record?.({
|
|
383
|
+
name: "npm.import",
|
|
384
|
+
tool: "npm",
|
|
385
|
+
args: { specifier },
|
|
386
|
+
ms: Date.now() - started,
|
|
387
|
+
ok: true
|
|
388
|
+
});
|
|
389
|
+
return {
|
|
390
|
+
kind: "module",
|
|
391
|
+
id: specifier,
|
|
392
|
+
exports
|
|
393
|
+
};
|
|
394
|
+
} catch (error) {
|
|
395
|
+
run.record?.({
|
|
396
|
+
name: "npm.import",
|
|
397
|
+
tool: "npm",
|
|
398
|
+
args: { specifier },
|
|
399
|
+
ms: Date.now() - started,
|
|
400
|
+
ok: false,
|
|
401
|
+
error: error instanceof Error ? error.message : String(error)
|
|
402
|
+
});
|
|
403
|
+
throw error;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
368
406
|
}), output, saved, calls);
|
|
369
407
|
} catch (error) {
|
|
370
408
|
return text(`Code mode could not run the script: ${error instanceof Error ? error.message : String(error)}`, true);
|
|
@@ -380,4 +418,4 @@ function createCodemodeTools({ registry, isolate, scripts }) {
|
|
|
380
418
|
//#endregion
|
|
381
419
|
export { createCodemodeRegistry as n, createCodemodeTools as t };
|
|
382
420
|
|
|
383
|
-
//# sourceMappingURL=codemodeTools-
|
|
421
|
+
//# sourceMappingURL=codemodeTools-D7CcAB18.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemodeTools-D7CcAB18.mjs","names":[],"sources":["../src/services/codemodeRegistry/index.ts","../src/schemas/codemodeTools.ts","../src/services/codemodeTools/index.ts"],"sourcesContent":["import {\n assertCodemodeNamespaceName,\n type PoCodemodeNamespace,\n type PoCodemodeRegistration,\n type PoCodemodeScriptSource,\n type PoCodemodeService,\n} from '@agimon-ai/po-core/codemode';\n\n/** The session's namespaces and script folders, in registration order. One name per session. */\nexport function createCodemodeRegistry(): PoCodemodeService {\n const entries = new Map<string, { source: string; namespace: PoCodemodeNamespace }>();\n const scripts = new Set<PoCodemodeScriptSource>();\n const listeners = new Set<() => void>();\n const notify = (): void => {\n for (const listener of listeners) listener();\n };\n return {\n register(source: string, namespace: PoCodemodeNamespace): PoCodemodeRegistration {\n assertCodemodeNamespaceName(namespace.name);\n const taken = entries.get(namespace.name);\n if (taken) {\n throw new Error(\n `Code-mode namespace \"${namespace.name}\" from ${source} is already registered by ${taken.source}.`,\n );\n }\n const entry = { source, namespace };\n entries.set(namespace.name, entry);\n notify();\n return {\n dispose: () => {\n if (entries.get(namespace.name) !== entry) return;\n entries.delete(namespace.name);\n notify();\n },\n };\n },\n list: () => [...entries.values()].map((entry) => entry.namespace),\n registerScripts(_source: string, entry: PoCodemodeScriptSource): PoCodemodeRegistration {\n const owned = { domain: entry.domain, directory: entry.directory };\n scripts.add(owned);\n notify();\n return { dispose: () => void (scripts.delete(owned) && notify()) };\n },\n listScripts: () => [...scripts],\n subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n","import { Type, type Static } from 'typebox';\n\nexport const DiscoverToolSchema = Type.Object({\n namespace: Type.Optional(Type.String({ description: 'Show the full TypeScript declarations of one namespace.' })),\n query: Type.Optional(Type.String({ description: 'Find matching members across every namespace.' })),\n});\nexport type DiscoverToolParams = Static<typeof DiscoverToolSchema>;\n\nexport const ExecToolSchema = Type.Object({\n code: Type.String({\n description:\n 'TypeScript body of an async function. Top-level await and return work. The returned value, console output and image() calls come back.',\n }),\n timeoutMs: Type.Optional(\n Type.Integer({ minimum: 1_000, maximum: 120_000, description: 'Deadline in milliseconds. Default 30000.' }),\n ),\n});\nexport type ExecToolParams = Static<typeof ExecToolSchema>;\n","import type {\n PoCodemodeCall,\n PoCodemodeNamespace,\n PoCodemodeRun,\n PoCodemodeService,\n} from '@agimon-ai/po-core/codemode';\nimport {\n invalidImageReason,\n type PoHeadlessContent,\n type PoHeadlessExecutionContext,\n type PoHeadlessTool,\n type PoHeadlessToolResult,\n} from '@agimon-ai/po-core/headless';\nimport type { PoIsolateResult, PoIsolateService, PoNpm } from '@agimon-ai/po-core/platform';\n\nimport {\n DiscoverToolSchema,\n ExecToolSchema,\n type DiscoverToolParams,\n type ExecToolParams,\n} from '../../schemas/codemodeTools';\nimport type { CodemodeScriptsPort } from '../codemodeScripts/type';\n\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst MAX_TIMEOUT_MS = 120_000;\nconst MIN_TIMEOUT_MS = 1_000;\nconst MAX_LOG_CHARS = 10_000;\nconst MAX_VALUE_CHARS = 64 * 1024;\nconst MAX_DECLARATION_CHARS = 24_000;\nconst MAX_QUERY_LINES = 40;\n// The main agent and its subagents share one exec tool, so several runs can overlap.\nconst MAX_CONCURRENT_RUNS = 8;\n// Recorded calls ride the result's details into the transcript, so they are few and small.\nconst MAX_RECORDED_CALLS = 50;\nconst MAX_RECORDED_TEXT = 8_000;\nconst MAX_RECORDED_JSON = 16_000;\nconst MAX_LISTED_SCRIPTS = 20;\nconst MAX_IMAGES = 4;\nconst MAX_IMAGE_BYTES = 5 * 1024 * 1024;\nconst DEFAULT_IMAGE_MIME = 'image/png';\nconst MEMBER_LINE = /^\\s{2}(?:readonly\\s+)?(\\w+)\\s*[(?:<]/u;\n\nconst GLOBALS_HELP =\n 'Globals: console.log/info/warn/error, image(data, mimeType?) to return a screenshot, sleep(ms). ' +\n 'Return a value with `return`.';\nconst SCRIPTS_HELP =\n 'Every exec run is saved. Call a saved script with `await (await import(specifier))(args)`; ' +\n 'inside it, `args` is the argument and its `return` is the result.';\n\nexport interface CodemodeToolsOptions {\n readonly registry: PoCodemodeService;\n /** Resolved per call, so a host that binds the isolate late still works. */\n readonly isolate: () => PoIsolateService | undefined;\n /** Saves every exec body and backs `import()`; without it nothing is saved or importable. */\n readonly scripts?: CodemodeScriptsPort;\n readonly npm?: () => PoNpm | undefined;\n}\n\nexport interface CodemodeTools {\n readonly discover: PoHeadlessTool<typeof DiscoverToolSchema>;\n readonly exec: PoHeadlessTool<typeof ExecToolSchema>;\n}\n\nfunction text(value: string, isError = false): PoHeadlessToolResult {\n return { content: [{ type: 'text', text: value }], ...(isError ? { isError: true } : {}) };\n}\n\nfunction truncate(value: string, limit: number): string {\n return value.length <= limit ? value : `${value.slice(0, limit)}\\n[truncated ${value.length - limit} chars]`;\n}\n\nfunction format(value: unknown): string {\n if (typeof value === 'string') return value;\n try {\n const json = JSON.stringify(value, null, 2);\n if (json !== undefined) return json;\n } catch {\n // Cyclic or exotic values fall back to their string form.\n }\n return String(value);\n}\n\nfunction memberNames(namespace: PoCodemodeNamespace): string[] {\n const names = new Set<string>();\n const declaration =\n new RegExp(`^declare const ${namespace.name}: \\\\{([\\\\s\\\\S]*?)^\\\\};`, 'mu').exec(namespace.declarations)?.[1] ?? '';\n for (const line of declaration.split('\\n')) {\n const name = MEMBER_LINE.exec(line)?.[1];\n if (name) names.add(name);\n }\n return [...names];\n}\n\nfunction bytesToBase64(bytes: Uint8Array): string {\n let binary = '';\n for (let index = 0; index < bytes.length; index += 0x8000) {\n binary += String.fromCharCode(...bytes.subarray(index, index + 0x8000));\n }\n return btoa(binary);\n}\n\n/** Collects what a script prints and the images it returns, within the output caps. */\nfunction createOutput() {\n const lines: string[] = [];\n const images: { data: string; mimeType: string }[] = [];\n let imageBytes = 0;\n const log =\n (level: string) =>\n (...args: unknown[]) => {\n const line = args.map(format).join(' ');\n lines.push(level === 'log' || level === 'info' ? line : `[${level}] ${line}`);\n };\n const note = (message: string): void => void lines.push(`[note] ${message}`);\n const addImage = (input: unknown, mimeType?: unknown): void => {\n if (typeof input === 'object' && input !== null && 'images' in input && Array.isArray(input.images)) {\n for (const image of input.images) addImage(image);\n return;\n }\n let data: string;\n let mime = typeof mimeType === 'string' ? mimeType : DEFAULT_IMAGE_MIME;\n if (typeof input === 'string')\n data = input.replace(/^data:([^;]+);base64,/u, (_match, type: string) => ((mime = type), ''));\n else if (ArrayBuffer.isView(input))\n data = bytesToBase64(new Uint8Array(input.buffer, input.byteOffset, input.byteLength));\n else if (typeof input === 'object' && input !== null && 'data' in input && typeof input.data === 'string') {\n data = input.data;\n if ('mimeType' in input && typeof input.mimeType === 'string') mime = input.mimeType;\n } else throw new TypeError('image() takes base64 text, bytes, or { data, mimeType }.');\n if (images.length >= MAX_IMAGES) throw new RangeError(`An exec run returns at most ${MAX_IMAGES} images.`);\n imageBytes += Math.ceil((data.length * 3) / 4);\n if (imageBytes > MAX_IMAGE_BYTES) throw new RangeError('Images from one exec run exceed 5 MB.');\n const invalid = invalidImageReason(data, mime);\n if (invalid !== undefined) throw new TypeError(`image() rejected an undecodable image: ${invalid}.`);\n images.push({ data, mimeType: mime });\n };\n const console = { log: log('log'), info: log('info'), warn: log('warn'), error: log('error'), debug: log('debug') };\n return { console, note, addImage, lines, images };\n}\n\n/** The session's active domains; every registered domain when the host reports none. */\nfunction activeDomains(execution: PoHeadlessExecutionContext | undefined): readonly string[] | undefined {\n return execution?.selection?.domains;\n}\n\n/** A JSON copy of `value`, or undefined when it does not serialise or is larger than `limit` characters. */\nfunction bounded<T>(value: T, limit: number): T | undefined {\n try {\n const json = JSON.stringify(value);\n return json !== undefined && json.length <= limit ? (JSON.parse(json) as T) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** The call as it is kept in the transcript: text blocks only, clipped, with args and details dropped when large. */\nfunction recordedCall(call: PoCodemodeCall): PoCodemodeCall {\n const content = (call.result?.content ?? []).flatMap((block) => {\n const { type, text } = (block ?? {}) as { type?: unknown; text?: unknown };\n return type === 'text' && typeof text === 'string'\n ? [{ type: 'text', text: truncate(text, MAX_RECORDED_TEXT) }]\n : [];\n });\n const details = bounded(call.result?.details, MAX_RECORDED_JSON);\n return {\n name: call.name,\n tool: call.tool,\n args: bounded(call.args, MAX_RECORDED_JSON) ?? {},\n ok: call.ok,\n ms: Math.max(0, Math.round(call.ms)),\n ...(call.error === undefined ? {} : { error: truncate(call.error, MAX_RECORDED_TEXT) }),\n ...(call.result === undefined ? {} : { result: { content, ...(details === undefined ? {} : { details }) } }),\n };\n}\n\nfunction toResult(\n result: PoIsolateResult,\n output: ReturnType<typeof createOutput>,\n saved: string | undefined,\n calls: readonly PoCodemodeCall[],\n): PoHeadlessToolResult {\n const content: PoHeadlessContent[] = [];\n if (output.lines.length > 0) content.push({ type: 'text', text: truncate(output.lines.join('\\n'), MAX_LOG_CHARS) });\n if (result.ok) {\n if (ArrayBuffer.isView(result.value)) {\n content.push({ type: 'text', text: 'The script returned bytes. Pass them to image(data, mimeType) instead.' });\n } else if (result.value !== undefined) {\n content.push({ type: 'text', text: truncate(format(result.value), MAX_VALUE_CHARS) });\n }\n } else {\n const { kind, name, message } = result.error;\n const hint = kind === 'timeout' ? ' Raise timeoutMs or split the work into smaller exec calls.' : '';\n content.push({ type: 'text', text: `${name}: ${message}${hint}` });\n }\n if (content.length === 0) content.push({ type: 'text', text: '(no return value)' });\n if (saved !== undefined) content.push({ type: 'text', text: saved });\n for (const image of output.images) content.push({ type: 'image', data: image.data, mimeType: image.mimeType });\n return {\n content,\n ...(calls.length > 0 ? { details: { calls } } : {}),\n ...(result.ok ? {} : { isError: true }),\n };\n}\n\nfunction sleep(ms: number, signal: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal.aborted) return reject(new Error('Run ended.'));\n const timer = setTimeout(resolve, Math.max(0, ms));\n signal.addEventListener(\n 'abort',\n () => {\n clearTimeout(timer);\n reject(new Error('Run ended.'));\n },\n { once: true },\n );\n });\n}\n\n/** `discover` and `exec` for one session, over the namespaces its packages contributed. */\nexport function createCodemodeTools({ registry, isolate, scripts, npm }: CodemodeToolsOptions): CodemodeTools {\n let running = 0;\n\n const visible = (service: PoIsolateService): PoCodemodeNamespace[] =>\n registry.list().filter((namespace) => service.liveObjects || namespace.portable === true);\n\n // ponytail: the cockpit's generic tool item renders both for now; add a poWeb renderer for exec code and images when it earns one.\n // web-plugin-tool-renderers: ignore discover, plain text result\n const discover: CodemodeTools['discover'] = {\n name: 'discover',\n label: 'Discover',\n description:\n 'List the code-mode namespaces and reusable scripts you can use from `exec`, show one namespace in full, ' +\n 'or search members and scripts. ' +\n 'Not required before exec: its description already names the namespaces.',\n parameters: DiscoverToolSchema,\n promptSnippet: 'List code-mode namespaces and their TypeScript declarations',\n executionMode: 'parallel',\n async execute(_toolCallId, parameters: DiscoverToolParams, _signal, _onUpdate, execution) {\n const service = isolate();\n if (!service) return text('Code mode is not available on this host.', true);\n const namespaces = visible(service);\n // Imports need a host with live objects; the edge saves scripts but cannot chain them.\n const listed = scripts && service.liveObjects ? await scripts.list(activeDomains(execution)) : [];\n if (parameters.namespace !== undefined) {\n const found = namespaces.find((namespace) => namespace.name === parameters.namespace);\n if (!found) {\n const names = namespaces.map((namespace) => namespace.name).join(', ') || 'none';\n return text(`Unknown namespace \"${parameters.namespace}\". Registered: ${names}.`, true);\n }\n return text(truncate(found.declarations, MAX_DECLARATION_CHARS));\n }\n if (parameters.query !== undefined) {\n const needle = parameters.query.toLowerCase();\n const hits: string[] = [];\n for (const namespace of namespaces) {\n const lines = namespace.declarations.split('\\n');\n lines.forEach((line, index) => {\n if (!line.toLowerCase().includes(needle) || hits.length >= MAX_QUERY_LINES) return;\n const doc = lines[index - 1]?.trim().startsWith('/**') ? `${lines[index - 1]?.trim()} ` : '';\n hits.push(`${namespace.name}: ${doc}${line.trim()}`);\n });\n }\n for (const script of listed) {\n if (hits.length >= MAX_QUERY_LINES) break;\n if (`${script.specifier} ${script.description}`.toLowerCase().includes(needle)) {\n hits.push(`script ${script.specifier}: ${script.description}`);\n }\n }\n return text(hits.length > 0 ? hits.join('\\n') : `No members or scripts match \"${parameters.query}\".`);\n }\n const sections: string[] = [];\n if (namespaces.length === 0) sections.push('No namespaces are registered in this session.');\n for (const namespace of namespaces) {\n sections.push(`- ${namespace.name}: ${namespace.summary}\\n members: ${memberNames(namespace).join(', ')}`);\n }\n sections.push(GLOBALS_HELP);\n if (!service.liveObjects) sections.push('This host runs plain JavaScript with JSON-only functions.');\n if (listed.length > 0) {\n sections.push(`Scripts. ${SCRIPTS_HELP}`);\n for (const script of listed.slice(0, MAX_LISTED_SCRIPTS)) {\n sections.push(`- ${script.specifier}${script.description ? `: ${script.description}` : ''}`);\n }\n if (listed.length > MAX_LISTED_SCRIPTS) {\n sections.push(`...and ${listed.length - MAX_LISTED_SCRIPTS} more; use discover({ query }) to search.`);\n }\n }\n if (namespaces.length > 0) sections.push('Call discover({ namespace }) for full types.');\n return text(sections.join('\\n'));\n },\n };\n\n // web-plugin-tool-renderers: ignore exec, generic item until a code and image renderer exists\n const exec: CodemodeTools['exec'] = {\n name: 'exec',\n label: 'Exec',\n get description(): string {\n const service = isolate();\n const namespaces = service ? visible(service) : [];\n const listed = namespaces.map((namespace) => `- ${namespace.name}: ${namespace.summary}`).join('\\n');\n return [\n 'Run a TypeScript script inside the Po server with live objects from the namespaces below in scope.',\n 'It runs with full server trust, like bash. Keep each call to one logical step.',\n listed || '(no namespaces registered yet; call discover to check)',\n GLOBALS_HELP,\n ...(scripts && service?.liveObjects ? [`${SCRIPTS_HELP} discover lists saved and domain scripts.`] : []),\n 'Use discover({ namespace }) for full signatures when needed.',\n ].join('\\n');\n },\n parameters: ExecToolSchema,\n promptSnippet: 'Run a TypeScript script against live Po objects (browser and other namespaces)',\n executionMode: 'serial',\n async execute(_toolCallId, parameters: ExecToolParams, signal, _onUpdate, execution) {\n const service = isolate();\n if (!service) return text('Code mode is not available on this host.', true);\n if (running >= MAX_CONCURRENT_RUNS)\n return text(`This session already has ${MAX_CONCURRENT_RUNS} exec runs active. Wait for one to finish.`, true);\n running += 1;\n const controller = new AbortController();\n const runSignal = signal ? AbortSignal.any([signal, controller.signal]) : controller.signal;\n const cleanups: (() => void | Promise<void>)[] = [];\n const calls: PoCodemodeCall[] = [];\n const output = createOutput();\n const run: PoCodemodeRun = {\n sessionId: execution.sessionId,\n signal: runSignal,\n onDispose: (cleanup) => void cleanups.push(cleanup),\n record: (call) => {\n if (calls.length < MAX_RECORDED_CALLS) calls.push(recordedCall(call));\n },\n };\n try {\n let saved: string | undefined;\n try {\n const file = await scripts?.save(parameters.code);\n if (file) saved = `Saved as ${file.specifier} (${file.path})`;\n } catch (error) {\n output.note(`Could not save the script: ${error instanceof Error ? error.message : String(error)}`);\n }\n const globals: Record<string, unknown> = {\n console: output.console,\n image: output.addImage,\n sleep: (ms: number) => sleep(ms, runSignal),\n };\n const deny = new Set<string>();\n for (const namespace of visible(service)) {\n globals[namespace.name] = namespace.bind(run);\n for (const member of namespace.deny ?? []) deny.add(member);\n }\n const deadlineMs = Math.min(\n MAX_TIMEOUT_MS,\n Math.max(MIN_TIMEOUT_MS, parameters.timeoutMs ?? DEFAULT_TIMEOUT_MS),\n );\n const result = await service.run({\n source: parameters.code,\n globals,\n deadlineMs,\n signal: runSignal,\n deny: [...deny],\n onDiagnostic: output.note,\n resolveImport: async (specifier) => {\n if (!specifier.startsWith('npm:')) {\n if (!scripts) throw new Error('Script imports are not available on this host.');\n return scripts.resolve(specifier, activeDomains(execution));\n }\n const loader = npm?.();\n if (!loader) throw new Error('npm imports are not available on this host.');\n run.signal.throwIfAborted();\n const started = Date.now();\n try {\n const exports = await loader.import(specifier, { sessionId: run.sessionId, signal: run.signal });\n run.signal.throwIfAborted();\n run.record?.({\n name: 'npm.import',\n tool: 'npm',\n args: { specifier },\n ms: Date.now() - started,\n ok: true,\n });\n return { kind: 'module', id: specifier, exports };\n } catch (error) {\n run.record?.({\n name: 'npm.import',\n tool: 'npm',\n args: { specifier },\n ms: Date.now() - started,\n ok: false,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n },\n });\n return toResult(result, output, saved, calls);\n } catch (error) {\n return text(\n `Code mode could not run the script: ${error instanceof Error ? error.message : String(error)}`,\n true,\n );\n } finally {\n controller.abort();\n for (const cleanup of cleanups.reverse()) {\n await Promise.resolve()\n .then(cleanup)\n .catch((error: unknown) => output.note(`cleanup failed: ${String(error)}`));\n }\n running -= 1;\n }\n },\n };\n\n return { discover, exec };\n}\n"],"mappings":";;;;;AASA,SAAgB,yBAA4C;CAC1D,MAAM,0BAAU,IAAI,IAAgE;CACpF,MAAM,0BAAU,IAAI,IAA4B;CAChD,MAAM,4BAAY,IAAI,IAAgB;CACtC,MAAM,eAAqB;EACzB,KAAK,MAAM,YAAY,WAAW,SAAS;CAC7C;CACA,OAAO;EACL,SAAS,QAAgB,WAAwD;GAC/E,4BAA4B,UAAU,IAAI;GAC1C,MAAM,QAAQ,QAAQ,IAAI,UAAU,IAAI;GACxC,IAAI,OACF,MAAM,IAAI,MACR,wBAAwB,UAAU,KAAK,SAAS,OAAO,4BAA4B,MAAM,OAAO,EAClG;GAEF,MAAM,QAAQ;IAAE;IAAQ;GAAU;GAClC,QAAQ,IAAI,UAAU,MAAM,KAAK;GACjC,OAAO;GACP,OAAO,EACL,eAAe;IACb,IAAI,QAAQ,IAAI,UAAU,IAAI,MAAM,OAAO;IAC3C,QAAQ,OAAO,UAAU,IAAI;IAC7B,OAAO;GACT,EACF;EACF;EACA,YAAY,CAAC,GAAG,QAAQ,OAAO,CAAC,CAAC,CAAC,KAAK,UAAU,MAAM,SAAS;EAChE,gBAAgB,SAAiB,OAAuD;GACtF,MAAM,QAAQ;IAAE,QAAQ,MAAM;IAAQ,WAAW,MAAM;GAAU;GACjE,QAAQ,IAAI,KAAK;GACjB,OAAO;GACP,OAAO,EAAE,eAAe,MAAM,QAAQ,OAAO,KAAK,K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