@agimon-ai/po-codemode 0.0.1-alpha.11 → 0.0.1-alpha.111

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.mjs","names":["ToolMessageRenderProps","CodeBlock","fontOf","Markdown","MessageItem","MessageItemBody","MessageItemHeader","toolTone","ToolResultImage","PoNativeTheme","useState","StyleSheet","callArgsSummary","execCalls","execCode","execResultView","execSummary","execToolName","readsAsDocument","returnSummary","ExecCall","ExecImage","ExecToolCardProps","defaultExpanded","Visuals","text","images","label","host","map","image","index","mimeType","String","data","styles","CallRow","call","open","setOpen","view","result","lines","join","printed","ok","hasArgs","Object","keys","args","length","opens","error","undefined","value","expanded","press","argsLine","mono","name","shrink","sans","dim","keep","ms","JSON","stringify","Returned","isError","document","leaf","stack","ExecToolCard","props","running","renderTool","code","calls","details","failed","filter","settled","summary","rail","card","tool","toolName","create","theme","flex","flexDirection","alignItems","gap","spacing","minWidth","uni__dependencies","flexShrink","marginHorizontal","marginBottom","paddingLeft","borderLeftWidth","borderColor","colors","minHeight","justifyContent","paddingVertical","fontFamily","fontSize","sm","lineHeight","fontWeight","color","green","red","width","aspectRatio","borderWidth","borderRadius","md","toolExec"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/execToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/ExecToolCard.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/exec.native.tsx","../../generated/native.ts"],"sourcesContent":["// Imports nothing at runtime: the web and native cards share it, and the native\n// bundle may not load the web contract.\nimport type { ToolResultView } from '@agimon-ai/po-core/web';\n\n/** Tool names this package registers (registerTool's `name`). */\nexport const execToolName = 'exec' as const;\nexport const discoverToolName = 'discover' as const;\n\nconst SUMMARY_MAX = 120;\nconst ARGS_MAX = 160;\nconst CALLS_MAX = 50;\nconst IMAGE_TYPES = /^image\\/(?:png|jpeg|webp|gif)$/u;\nconst SAVED_LINE = /^Saved as (\\S+) \\((.+)\\)$/u;\n// A heading or a fence starts a line of Markdown, never one of JSON or a log.\nconst DOCUMENT_LINE = /^(?:#{1,6} |```)/mu;\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction clip(text: string, max: number): string {\n return text.length <= max ? text : `${text.slice(0, max - 1)}…`;\n}\n\n/** The script the call ran, exactly as the agent wrote it. */\nexport function execCode(args: Readonly<Record<string, unknown>>): string {\n return typeof args.code === 'string' ? args.code : '';\n}\n\n/** The header line: the script's first line, with a leading `//` comment marker dropped. */\nexport function execSummary(args: Readonly<Record<string, unknown>>): string {\n const first = execCode(args)\n .split('\\n')\n .map((line) => line.trim())\n .find((line) => line !== '');\n if (first === undefined) return 'script';\n return clip(first.replace(/^\\/\\/+\\s*/u, ''), SUMMARY_MAX);\n}\n\n/** One namespace call the script made, as exec reports it in the result's details. */\nexport interface ExecCall {\n /** The member called, such as `browser.click` or `mcp.github.search_issues`. */\n name: string;\n args: Record<string, unknown>;\n ok: boolean;\n ms: number;\n /** The tool name whose own card shows this call, when another package has one. */\n tool?: string;\n error?: string;\n result?: ToolResultView;\n}\n\nfunction callOf(value: unknown): ExecCall | undefined {\n const call = record(value);\n if (call === undefined || typeof call.name !== 'string' || call.name === '') return undefined;\n const result = record(call.result);\n return {\n name: call.name,\n args: record(call.args) ?? {},\n ok: call.ok !== false,\n ms: typeof call.ms === 'number' && Number.isFinite(call.ms) && call.ms >= 0 ? Math.round(call.ms) : 0,\n ...(typeof call.tool === 'string' && call.tool !== '' ? { tool: call.tool } : {}),\n ...(typeof call.error === 'string' && call.error !== '' ? { error: call.error } : {}),\n ...(result !== undefined && Array.isArray(result.content)\n ? { result: { content: result.content, details: result.details } }\n : {}),\n };\n}\n\n/** The nested calls recorded in a result's details; anything malformed is skipped. */\nexport function execCalls(details: unknown): ExecCall[] {\n const calls = record(details)?.calls;\n if (!Array.isArray(calls)) return [];\n return calls\n .slice(0, CALLS_MAX)\n .map(callOf)\n .filter((call): call is ExecCall => call !== undefined);\n}\n\n/** A call's arguments on one line, for a row that has no card of its own: `key: value · key: value`, strings unquoted. */\nexport function callArgsSummary(args: Readonly<Record<string, unknown>>): string {\n const pairs = Object.entries(args).map(\n ([key, value]) => `${key}: ${typeof value === 'string' ? value : (JSON.stringify(value) ?? String(value))}`,\n );\n return clip(pairs.join(' · '), ARGS_MAX);\n}\n\n/** A script's return on one line: a JSON object folds like call arguments, other JSON compacts, plain text joins its lines. */\nexport function returnSummary(text: string): string {\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch {\n return text.split('\\n').join(' ');\n }\n const object = record(value);\n return object !== undefined && Object.keys(object).length > 0\n ? callArgsSummary(object)\n : clip(JSON.stringify(value), ARGS_MAX);\n}\n\nexport interface ExecImage {\n mimeType: string;\n data: string;\n}\n\nexport interface ExecResultView {\n lines: string[];\n /** The saved-script footer exec appends: the id to import it by, and where it lives. */\n saved?: { id: string; path: string };\n images: ExecImage[];\n}\n\n/** What a result holds, with the saved-script footer and the pictures taken out of the text. */\nexport function execResultView(result: ToolResultView | null): ExecResultView {\n if (result === null) return { lines: [], images: [] };\n let saved: ExecResultView['saved'];\n const texts: string[] = [];\n const images: ExecImage[] = [];\n for (const block of result.content) {\n const item = record(block);\n if (item?.type === 'text' && typeof item.text === 'string') {\n const match = SAVED_LINE.exec(item.text.trim());\n if (match?.[1] !== undefined && match[2] !== undefined) saved = { id: match[1], path: match[2] };\n else texts.push(item.text);\n } else if (\n item?.type === 'image' &&\n typeof item.data === 'string' &&\n typeof item.mimeType === 'string' &&\n IMAGE_TYPES.test(item.mimeType)\n ) {\n images.push({ mimeType: item.mimeType, data: item.data });\n }\n }\n // As po-core's toolResultTextLines: CRLF folded, tabs widened, trailing blank lines dropped.\n const lines = texts.join('\\n').replaceAll('\\r\\n', '\\n').replaceAll('\\r', '\\n').replaceAll('\\t', ' ').split('\\n');\n while (lines.length > 0 && lines.at(-1)?.trim() === '') lines.pop();\n return { lines, ...(saved === undefined ? {} : { saved }), images };\n}\n\n/** Whether result text is a document, such as a report or a mermaid diagram, to draw rather than print. */\nexport function readsAsDocument(text: string): boolean {\n return DOCUMENT_LINE.test(text);\n}\n\n/** The header line for discover: what was asked for. */\nexport function discoverSummary(args: Readonly<Record<string, unknown>>): string {\n if (typeof args.namespace === 'string' && args.namespace !== '') return args.namespace;\n if (typeof args.query === 'string' && args.query !== '') return `find \"${clip(args.query, SUMMARY_MAX)}\"`;\n return 'namespaces and scripts';\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/native';\nimport {\n CodeBlock,\n fontOf,\n Markdown,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n toolTone,\n ToolResultImage,\n} from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { useState } from 'react';\nimport { Pressable, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport {\n callArgsSummary,\n execCalls,\n execCode,\n execResultView,\n execSummary,\n execToolName,\n readsAsDocument,\n returnSummary,\n type ExecCall,\n type ExecImage,\n} from '../_lib/execToolView';\n\nexport type ExecToolCardProps = ToolMessageRenderProps & { defaultExpanded?: boolean };\n\n/** Pictures and documents stay on screen whether or not their row is open: they are the point of the call. */\nfunction Visuals({\n text,\n images,\n label,\n host,\n}: {\n text: string;\n images: readonly ExecImage[];\n label: string;\n host: ToolMessageRenderProps;\n}) {\n return (\n <>\n {readsAsDocument(text) ? <Markdown text={text} /> : null}\n {images.map((image, index) => (\n <ToolResultImage\n key={`${image.mimeType}-${String(index)}`}\n host={host}\n data={image.data}\n mimeType={image.mimeType}\n accessibilityLabel={`${label} image ${String(index + 1)}`}\n resizeMode=\"contain\"\n style={styles.image}\n />\n ))}\n </>\n );\n}\n\n/** One call on the rail. Tapping it opens its whole args and result; its pictures and documents show either way. */\nfunction CallRow({ call, host }: { call: ExecCall; host: ToolMessageRenderProps }) {\n const [open, setOpen] = useState(false);\n const view = execResultView(call.result ?? null);\n const text = view.lines.join('\\n');\n const printed = text !== '' && (!call.ok || !readsAsDocument(text));\n const hasArgs = Object.keys(call.args).length > 0;\n const opens = hasArgs || printed || call.error !== undefined;\n return (\n <View testID=\"exec-call\" style={styles.call}>\n <Pressable\n disabled={!opens}\n onPress={() => setOpen((value) => !value)}\n accessibilityRole={opens ? 'button' : undefined}\n accessibilityState={opens ? { expanded: open } : undefined}\n accessibilityHint={opens ? 'Shows the whole arguments and result' : undefined}\n style={styles.press}\n >\n <View style={styles.argsLine}>\n <Text numberOfLines={1} style={[styles.mono, styles.name, styles.shrink]}>\n {call.name}\n </Text>\n {opens ? <Text style={[styles.sans, styles.dim, styles.keep]}>{open ? '\\u2304' : '\\u203a'}</Text> : null}\n </View>\n <View style={styles.argsLine}>\n <Text numberOfLines={1} style={[styles.mono, styles.args]}>\n {open ? '' : callArgsSummary(call.args)}\n </Text>\n <Text\n accessibilityLabel={call.ok ? 'completed' : 'failed'}\n style={[styles.sans, call.ok ? styles.ok : styles.error]}\n >\n {call.ok ? '\\u2713' : '\\u2717'}\n </Text>\n <Text style={[styles.sans, styles.dim]}>{call.ms} ms</Text>\n </View>\n </Pressable>\n {open && hasArgs ? <CodeBlock text={JSON.stringify(call.args, null, 2)} language=\"json\" /> : null}\n {open && printed ? (\n <Text testID=\"exec-call-output\" selectable style={[styles.mono, styles.text]}>\n {text}\n </Text>\n ) : null}\n {open && call.error !== undefined ? <Text style={[styles.sans, styles.error]}>{call.error}</Text> : null}\n <Visuals text={call.ok ? text : ''} images={view.images} label={call.name} host={host} />\n </View>\n );\n}\n\n/** The script's outcome as the rail's last leaf: one line while the card is folded, all of it once opened. */\nfunction Returned({\n result,\n isError,\n expanded,\n host,\n}: {\n result: ExecToolCardProps['result'];\n isError: boolean;\n expanded: boolean;\n host: ToolMessageRenderProps;\n}) {\n const view = execResultView(result);\n const text = view.lines.join('\\n');\n const document = !isError && readsAsDocument(text);\n return (\n <View testID={`tool-result-${execToolName}`} style={styles.leaf}>\n {view.lines.length === 0 ? (\n <Text style={[styles.sans, styles.dim]}>{isError ? 'Failed with no output.' : 'Returned nothing.'}</Text>\n ) : document ? (\n <Text style={[styles.sans, styles.dim, styles.label]}>{isError ? 'Error' : 'Returned'}</Text>\n ) : (\n <View style={expanded ? styles.stack : styles.argsLine}>\n <Text style={[styles.sans, styles.dim, styles.label]}>{isError ? 'Error' : 'Returned'}</Text>\n <Text\n selectable\n numberOfLines={expanded ? undefined : 1}\n style={[styles.mono, styles.args, isError ? styles.error : styles.text]}\n >\n {expanded ? text : returnSummary(text)}\n </Text>\n </View>\n )}\n <Visuals text={isError ? '' : text} images={view.images} label=\"Script\" host={host} />\n </View>\n );\n}\n\n/**\n * The exec tool's timeline item on native, as the web's ExecToolCard: the\n * calls the script made hang under it on a rail, each as the owning tool's own\n * card when one exists, with what it returned as the last leaf. Opening the\n * item shows the script itself.\n */\nexport function ExecToolCard(props: ExecToolCardProps) {\n const { args, result, running, isError, defaultExpanded = false, renderTool } = props;\n const code = execCode(args);\n const calls = execCalls(result?.details);\n const failed = calls.filter((call) => !call.ok).length;\n const settled = !running || result !== null;\n return (\n <MessageItem\n tone={toolTone({ running, isError })}\n expandable={code !== '' || isError}\n defaultExpanded={defaultExpanded}\n >\n {({ expanded }) => (\n <>\n <MessageItemHeader title={execToolName}>\n <View testID={`tool-call-${execToolName}`} style={styles.summary}>\n <Text numberOfLines={1} style={[styles.sans, styles.text, styles.shrink]}>\n {execSummary(args)}\n </Text>\n {calls.length > 0 ? (\n <Text numberOfLines={1} style={[styles.sans, styles.dim, styles.keep]}>\n {calls.length} {calls.length === 1 ? 'call' : 'calls'}\n {failed > 0 ? <Text style={styles.error}>, {failed} failed</Text> : null}\n </Text>\n ) : null}\n </View>\n </MessageItemHeader>\n {expanded ? (\n <MessageItemBody>\n <CodeBlock text={code} language=\"ts\" />\n </MessageItemBody>\n ) : null}\n {settled ? (\n <View accessibilityLabel=\"Script calls\" style={styles.rail}>\n {calls.map((call, index) => {\n const card =\n call.tool === undefined || renderTool === undefined\n ? null\n : renderTool({\n toolName: call.tool,\n args: call.args,\n result: call.result ?? null,\n isError: !call.ok,\n });\n // ponytail: as on the web, another tool's card folds as it likes, so its pictures are repeated\n // under it; drop this once cards keep pictures visible when folded.\n return card === null || card === undefined ? (\n <CallRow key={`${String(index)}-${call.name}`} call={call} host={props} />\n ) : (\n <View key={`${String(index)}-${call.name}`} style={styles.call}>\n {card}\n <Visuals\n text=\"\"\n images={execResultView(call.result ?? null).images}\n label={call.name}\n host={props}\n />\n </View>\n );\n })}\n <Returned result={result} isError={isError} expanded={expanded} host={props} />\n </View>\n ) : null}\n </>\n )}\n </MessageItem>\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n shrink: { flexShrink: 1 },\n keep: { flexShrink: 0 },\n rail: {\n gap: theme.spacing(2),\n marginHorizontal: theme.spacing(4),\n marginBottom: theme.spacing(3),\n paddingLeft: theme.spacing(3),\n borderLeftWidth: 1,\n borderColor: theme.colors['border-soft'],\n },\n // A row on the rail, not a card: the rail already groups the calls.\n call: { gap: theme.spacing(2) },\n // 44pt: the smallest comfortable touch target.\n press: { minHeight: 44, justifyContent: 'center', gap: theme.spacing(0.5), paddingVertical: theme.spacing(1) },\n argsLine: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2) },\n stack: { gap: theme.spacing(1) },\n leaf: { gap: theme.spacing(2) },\n sans: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n mono: {\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n name: { fontWeight: '600', color: theme.colors.text },\n args: { flex: 1, minWidth: 0, color: theme.colors.dim },\n label: { fontWeight: '600' },\n text: { color: theme.colors.text },\n dim: { color: theme.colors.dim },\n ok: { color: theme.colors.green },\n error: { color: theme.colors.red },\n image: {\n width: '100%',\n aspectRatio: 16 / 9,\n borderWidth: 1,\n borderRadius: theme.borderRadius.md,\n borderColor: theme.colors['border-soft'],\n },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { ExecToolCard } from './_components/ExecToolCard.native';\n\nexport default defineToolRenderer({ message: ExecToolCard });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport toolExec from '../src/extensions/workspaces/sessions/(frontend)/tool/exec.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'codemode',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['exec'] }, toolExec)]; },\n },\n});\n"],"mappings":";;;;;;;;;;AAKA,MAAa,eAAe;AAG5B,MAAM,cAAc;AACpB,MAAM,WAAW;AACjB,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,aAAa;AAEnB,MAAM,gBAAgB;AAEtB,SAAS,OAAO,OAAqD;CACnE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,IACrE,QACD,KAAA;AACN;AAEA,SAAS,KAAK,MAAc,KAAqB;CAC/C,OAAO,KAAK,UAAU,MAAM,OAAO,GAAG,KAAK,MAAM,GAAG,MAAM,CAAC,EAAE;AAC/D;;AAGA,SAAgB,SAAS,MAAiD;CACxE,OAAO,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;AACrD;;AAGA,SAAgB,YAAY,MAAiD;CAC3E,MAAM,QAAQ,SAAS,IAAI,CAAC,CACzB,MAAM,IAAI,CAAC,CACX,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,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,CAAA;CAAC;CACtDpE,OAAO,EAAEmF,YAAY,MAAM;CAC3BrF,MAAM;EAAEsF,OAAOvB,MAAMc,OAAO7E;EAAIsE,mBAAA,CAAA,CAAA;CAAC;CACjCjC,KAAK;EAAEiD,OAAOvB,MAAMc,OAAOxC;EAAGiC,mBAAA,CAAA,CAAA;CAAC;CAC/BlD,IAAI;EAAEkE,OAAOvB,MAAMc,OAAOU;EAAKjB,mBAAA,CAAA,CAAA;CAAC;CAChC3C,OAAO;EAAE2D,OAAOvB,MAAMc,OAAOW;EAAGlB,mBAAA,CAAA,CAAA;CAAC;CACjCjE,OAAO;EACLoF,OAAO;EACPC,aAAa,KAAK;EAClBC,aAAa;EACbC,cAAc7B,MAAM6B,aAAaC;EACjCjB,aAAab,MAAMc,OAAO;EAAcP,mBAAA,CAAA,CAAA;CAC1C;AACF,EAAE;;;ACtQF,IAAA,sBAAe,mBAAmB,EAAE,SAAS,aAAa,CAAC;;;ACC3D,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,GAAGwB,mBAAQ,CAAC;CAAG,EAC9G;AACF,CAAC"}
@@ -2,14 +2,16 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_codemodeTools = require("../codemodeTools-B3n6iodq.cjs");
5
+ const require_codemodeTools = require("../codemodeTools-Dcbn7U7P.cjs");
6
6
  let _agimon_ai_po_core_codemode = require("@agimon-ai/po-core/codemode");
7
+ let _agimon_ai_po_core_approval = require("@agimon-ai/po-core/approval");
8
+ let _agimon_ai_po_core_headless = require("@agimon-ai/po-core/headless");
7
9
  let typebox = require("typebox");
10
+ let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
8
11
  let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
9
12
  let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
10
13
  let _agimon_ai_po_config = require("@agimon-ai/po-config");
11
14
  let _agimon_ai_po_core_backgroundWork = require("@agimon-ai/po-core/backgroundWork");
12
- let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
13
15
  let _agimon_ai_po_config_majorModes = require("@agimon-ai/po-config/majorModes");
14
16
  let typebox_value = require("typebox/value");
15
17
  let typebox_schema = require("typebox/schema");
@@ -101,10 +103,13 @@ var FileSystemCodemodeScriptsService = class {
101
103
  const fs = this.options.fs();
102
104
  if (!fs) return [];
103
105
  const found = [];
104
- for (const source of this.sources(domains)) for (const name of await this.names(fs, source.directory)) found.push({
105
- specifier: `${source.domain}/${name.slice(0, -3)}`,
106
- path: `${source.directory}/${name}`
107
- });
106
+ for (const source of this.sources(domains)) {
107
+ const names = await this.names(fs, source.directory).catch(() => []);
108
+ for (const name of names) found.push({
109
+ specifier: `${source.domain}/${name.slice(0, -3)}`,
110
+ path: `${source.directory}/${name}`
111
+ });
112
+ }
108
113
  const session = this.sessionDirectory();
109
114
  if (session !== void 0) for (const name of (await this.names(fs, session)).reverse()) found.push({
110
115
  specifier: `${SESSION_PREFIX}${name.slice(0, -3)}`,
@@ -188,7 +193,7 @@ const MAX_TOKENS = 4096;
188
193
  const RESULT_TOOL = "return_result";
189
194
  const MODEL = /^[^/\s]+\/\S+$/u;
190
195
  const META = typebox_schema.Meta["http://json-schema.org/draft-07/schema#"];
191
- const DECLARATIONS$1 = `interface LlmRequest {
196
+ const DECLARATIONS$2 = `interface LlmRequest {
192
197
  prompt: string;
193
198
  /** Explicit JSON input only, never the surrounding conversation. */
194
199
  input?: unknown;
@@ -298,7 +303,7 @@ function createLlmNamespace(options) {
298
303
  return {
299
304
  name: "llm",
300
305
  summary: "One-shot LLM text and schema-validated JSON transforms. Explicit input only, bounded calls, no tools or retries.",
301
- declarations: DECLARATIONS$1,
306
+ declarations: DECLARATIONS$2,
302
307
  portable: true,
303
308
  bind(run) {
304
309
  if (run.sessionId !== context.sessionId) throw new Error("LLM namespace belongs to another session.");
@@ -402,6 +407,80 @@ function createLlmNamespace(options) {
402
407
  };
403
408
  }
404
409
  //#endregion
410
+ //#region src/services/pageNamespace/index.ts
411
+ const MAX_URL_CHARS = 2048;
412
+ const DECLARATIONS$1 = `interface RenderedPage {
413
+ /** Final URL after redirects the host allowed. */
414
+ url: string;
415
+ status?: number;
416
+ title: string;
417
+ }
418
+
419
+ declare const page: {
420
+ /** Renders the page in a remote browser and returns its visible text, capped. */
421
+ fetchPage(url: string): Promise<RenderedPage & { text: string; truncated: boolean }>;
422
+ /** The rendered DOM as HTML plus its links, capped. */
423
+ snapshot(url: string): Promise<RenderedPage & { html: string; links: { text: string; href: string }[]; truncated: boolean }>;
424
+ /** Shows a PNG of the page to you in this exec result. Resolves to page info, not image data. */
425
+ screenshot(input: string | { url: string; fullPage?: boolean }): Promise<RenderedPage & { shown: boolean; warning?: string }>;
426
+ };`;
427
+ function target(method, input) {
428
+ const value = typeof input === "string" ? { url: input } : input;
429
+ if (value === null || typeof value !== "object" || Array.isArray(value)) throw new TypeError(`page.${method} expects a URL string or { url }.`);
430
+ const { url, fullPage } = value;
431
+ if (typeof url !== "string" || !url.trim() || url.length > MAX_URL_CHARS) throw new TypeError(`page.${method} url must be nonempty text of at most ${MAX_URL_CHARS} characters.`);
432
+ if (fullPage !== void 0 && typeof fullPage !== "boolean") throw new TypeError(`page.${method} fullPage must be a boolean.`);
433
+ return {
434
+ url,
435
+ ...fullPage === void 0 ? {} : { fullPage }
436
+ };
437
+ }
438
+ /** Rendered pages from the host's remote browser (`po/browser`). Portable: JSON in, JSON out. */
439
+ function createPageNamespace(options) {
440
+ return {
441
+ name: "page",
442
+ summary: "Render public web pages in the host's remote browser: page.fetchPage for text, page.snapshot for HTML and links, page.screenshot to see the page.",
443
+ declarations: DECLARATIONS$1,
444
+ portable: true,
445
+ bind(run) {
446
+ if (run.sessionId !== options.context.sessionId) throw new Error("Page namespace belongs to another session.");
447
+ const disposal = new AbortController();
448
+ const lifetime = AbortSignal.any([run.signal, disposal.signal]);
449
+ run.onDispose(() => disposal.abort(/* @__PURE__ */ new Error("Page namespace run is disposed.")));
450
+ const ready = () => lifetime.throwIfAborted();
451
+ return {
452
+ fetchPage: async (input) => {
453
+ ready();
454
+ return options.browser.fetchPage(target("fetchPage", input).url, lifetime);
455
+ },
456
+ snapshot: async (input) => {
457
+ ready();
458
+ return options.browser.snapshot(target("snapshot", input).url, lifetime);
459
+ },
460
+ screenshot: async (input) => {
461
+ ready();
462
+ const request = target("screenshot", input);
463
+ if (!run.emitImage) throw new Error("page.screenshot needs a host that shows images; use page.fetchPage or page.snapshot.");
464
+ const { data, mimeType, ...page } = await options.browser.screenshot(request, lifetime);
465
+ ready();
466
+ const shown = run.emitImage({
467
+ data,
468
+ mimeType
469
+ });
470
+ return shown.emitted ? {
471
+ ...page,
472
+ shown: true
473
+ } : {
474
+ ...page,
475
+ shown: false,
476
+ warning: shown.warning
477
+ };
478
+ }
479
+ };
480
+ }
481
+ };
482
+ }
483
+ //#endregion
405
484
  //#region src/services/shellNamespace/index.ts
406
485
  const DEFAULT_TIMEOUT_MS = 1e4;
407
486
  const MAX_TIMEOUT_MS = 12e4;
@@ -413,7 +492,8 @@ const DECLARATIONS = `declare const shell: {
413
492
  bash(input: { command: string; timeoutMs?: number }): Promise<{ stdout: string; stderr: string; exitCode: number }>;
414
493
  };`;
415
494
  function request(input) {
416
- if (input === null || typeof input !== "object" || Array.isArray(input)) throw new TypeError("shell.bash expects an object.");
495
+ if (typeof input === "string") input = { command: input };
496
+ if (input === null || typeof input !== "object" || Array.isArray(input)) throw new TypeError("shell.bash expects { command, timeoutMs? } or a command string.");
417
497
  const value = input;
418
498
  if (Object.keys(value).some((key) => key !== "command" && key !== "timeoutMs")) throw new TypeError("shell.bash accepts only command and timeoutMs.");
419
499
  if (typeof value.command !== "string" || !value.command.trim() || value.command.length > MAX_COMMAND_CHARS) throw new TypeError(`shell.bash command must be nonempty text of at most ${MAX_COMMAND_CHARS} characters.`);
@@ -435,7 +515,7 @@ function createShellNamespace(options) {
435
515
  const disposal = new AbortController();
436
516
  const lifetime = AbortSignal.any([run.signal, disposal.signal]);
437
517
  run.onDispose(() => disposal.abort(/* @__PURE__ */ new Error("Shell namespace run is disposed.")));
438
- return { async bash(input) {
518
+ const bash = async (input) => {
439
519
  lifetime.throwIfAborted();
440
520
  const params = request(input);
441
521
  const shell = options.shell();
@@ -485,7 +565,11 @@ function createShellNamespace(options) {
485
565
  ...failure === void 0 ? {} : { error: failure }
486
566
  });
487
567
  }
488
- } };
568
+ };
569
+ return {
570
+ bash,
571
+ run: bash
572
+ };
489
573
  }
490
574
  };
491
575
  }
@@ -493,7 +577,7 @@ function createShellNamespace(options) {
493
577
  //#region src/extensions/workspaces/sessions/(backend)/_lib/root.server.ts
494
578
  /** One registry per session: contributors register into it, `discover` and `exec` read it. */
495
579
  function createCodemodeSession({ context, agent, host, signal }) {
496
- const registry = require_codemodeTools.createCodemodeRegistry();
580
+ const registry = require_codemodeTools.createCodemodeRegistry({ isActive: (source) => (0, _agimon_ai_po_core_headless.readPoHeadlessHost)(context)?.isSourceActive(source) ?? true });
497
581
  context.inject([_agimon_ai_po_core_serverPlugin.PO_SERVER_SCOPE_SERVICE], (scoped) => (0, _agimon_ai_po_core_serverPlugin.requirePoServerScope)(scoped).provide(_agimon_ai_po_core_codemode.PO_CODEMODE_CONTRACT, registry));
498
582
  let temporaryDirectory;
499
583
  context.inject([_agimon_ai_po_core_platform.PO_SESSION_FILES_SERVICE], (scoped) => {
@@ -531,16 +615,28 @@ function createCodemodeSession({ context, agent, host, signal }) {
531
615
  registration.dispose();
532
616
  shellRegistration.dispose();
533
617
  };
618
+ context.inject([_agimon_ai_po_core_platform.PO_BROWSER_SERVICE], (scoped) => {
619
+ const browser = (0, _agimon_ai_po_core_platform.readPoBrowser)(scoped);
620
+ if (!browser) return void 0;
621
+ const pageRegistration = registry.register("@agimon-ai/po-codemode", createPageNamespace({
622
+ context: execution,
623
+ browser
624
+ }));
625
+ return () => pageRegistration.dispose();
626
+ });
534
627
  }
535
628
  let background;
536
629
  const tools = require_codemodeTools.createCodemodeTools({
537
630
  registry,
538
631
  isolate: () => (0, _agimon_ai_po_core_platform.readPoIsolate)(context),
539
632
  npm: () => (0, _agimon_ai_po_core_platform.readPoNpm)(context),
633
+ fs: () => (0, _agimon_ai_po_core_platform.readPoFs)(context),
540
634
  scripts,
541
635
  signal,
542
- onBackgroundChange: () => background?.update()
636
+ onBackgroundChange: () => background?.update(),
637
+ approval: () => (0, _agimon_ai_po_core_approval.readPoApproval)(context)
543
638
  });
639
+ if (execution) context.inject([_agimon_ai_po_core_approval.PO_APPROVAL_SERVICE], (scoped) => (0, _agimon_ai_po_core_approval.readPoApproval)(scoped)?.registerExecutor("codemode", (call, signal) => tools.runApproved(call, signal, execution.sessionId)));
544
640
  context.inject([_agimon_ai_po_core_backgroundWork.PO_BACKGROUND_WORK_SERVICE], (scoped) => {
545
641
  const registration = (0, _agimon_ai_po_core_backgroundWork.readPoBackgroundWorkService)(scoped)?.register(tools.backgroundWork);
546
642
  background = registration;
@@ -569,7 +665,7 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(createCodemodeSess
569
665
  var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(root);
570
666
  //#endregion
571
667
  //#region src/extensions/workspaces/sessions/(backend)/contract/codemode.server.ts
572
- var codemode_server_default = (0, _agimon_ai_po_core_extensionFile.defineServiceContract)(_agimon_ai_po_core_codemode.PO_CODEMODE_SERVICE, { scope: "session" });
668
+ var codemode_server_default = (0, _agimon_ai_po_core_extensionFile.defineServiceContract)(_agimon_ai_po_core_codemode.PO_CODEMODE_CONTRACT.name, _agimon_ai_po_core_codemode.PO_CODEMODE_CONTRACT);
573
669
  //#endregion
574
670
  //#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-llm.server.ts
575
671
  var codemode_how_to_llm_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
@@ -581,6 +677,16 @@ var codemode_how_to_llm_server_default = (0, _agimon_ai_po_core_extensionFile.de
581
677
  read: () => (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/codemode-how-to-llm/SKILL.md")
582
678
  });
583
679
  //#endregion
680
+ //#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-page.server.ts
681
+ var codemode_how_to_page_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
682
+ name: "codemode-how-to-page",
683
+ description: "Read or look at a public web page rendered in a remote browser. Use when a cloud session needs page text, links or a screenshot and the page namespace is listed.",
684
+ pinned: true,
685
+ kind: "skill",
686
+ path: (0, _agimon_ai_po_core_serverPlugin.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/codemode-how-to-page/SKILL.md"),
687
+ read: () => (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/codemode-how-to-page/SKILL.md")
688
+ });
689
+ //#endregion
584
690
  //#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-shell.server.ts
585
691
  var codemode_how_to_shell_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
586
692
  name: "codemode-how-to-shell",
@@ -635,6 +741,7 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
635
741
  get resources() {
636
742
  return [
637
743
  at(codemode_how_to_llm_server_default, contextSession),
744
+ at(codemode_how_to_page_server_default, contextSession),
638
745
  at(codemode_how_to_shell_server_default, contextSession),
639
746
  at(how_to_codemode_server_default, contextSession)
640
747
  ];