@agimon-ai/po-codemode 0.0.1-alpha.14 → 0.0.1-alpha.141
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 +19 -67
- package/dist/apiContracts.cjs +20 -3
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts +4 -3
- package/dist/apiContracts.d.mts.map +1 -1
- package/dist/apiContracts.mjs +18 -2
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/codemodeTools-DQOpNO5B.cjs +1032 -0
- package/dist/codemodeTools-DQOpNO5B.cjs.map +1 -0
- package/dist/codemodeTools-butGjhru.mjs +992 -0
- package/dist/codemodeTools-butGjhru.mjs.map +1 -0
- package/dist/extensions/native.mjs +622 -0
- package/dist/extensions/native.mjs.map +1 -0
- package/dist/extensions/server.cjs +186 -13
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +187 -14
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +435 -124
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +29 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/po-runtime-identity.json +1 -0
- package/llms.txt +1 -0
- package/package.json +90 -11
- package/src/prompts/codemode-how-to-page/SKILL.md +38 -0
- package/src/prompts/codemode-how-to-shell/SKILL.md +4 -0
- package/src/prompts/how-to-codemode/SKILL.md +6 -0
- package/dist/codemodeTools-A-6aAXeW.cjs +0 -622
- package/dist/codemodeTools-A-6aAXeW.cjs.map +0 -1
- package/dist/codemodeTools-gfHLLrAt.mjs +0 -611
- package/dist/codemodeTools-gfHLLrAt.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.mjs","names":["WebPluginSlotProps","Button","Dot","fontOf","LiveDuration","PoNativeTheme","useCallback","useSyncExternalStore","StyleSheet","backgroundScripts","requestScriptStop","BackgroundScriptsSection","sessionId","sendSessionFrame","subscribe","listener","subscription","store","unsubscribe","session","select","state","scripts","length","map","script","stopping","stopRequested","includes","id","styles","row","line","status","name","meta","Date","parse","startedAt","label","create","theme","gap","spacing","paddingVertical","uni__dependencies","flexDirection","alignItems","flex","color","colors","hi","fontFamily","sans","fontSize","base","lineHeight","fontWeight","medium","paddingLeft","dim","mono","sm","styles","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","channelCodemodeBackground","fillBackgroundScripts","toolExec"],"sources":["../../src/constants/backgroundScripts.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/backgroundScriptsFeed.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/backgroundScriptsStore.native.ts","../../src/extensions/workspaces/sessions/(frontend)/channel/codemode-background.native.ts","../../src/extensions/workspaces/sessions/(frontend)/fill/_components/BackgroundScriptsSection.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/fill/BackgroundScripts.activity.runners.native.tsx","../../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":["/** The hub channel frame carrying one session's running background scripts. */\nexport const CODEMODE_BACKGROUND_TYPE = 'codemode_background';\n\n/** The slash command the page sends to stop one background script. */\nexport const CODEMODE_STOP_COMMAND = 'background-scripts-stop';\n","import type { BackgroundScriptsPayload, BackgroundScriptView } from '../../../../../types/backgroundScripts';\n\n/** One session's record: the hub's last report plus the stops this page asked for. */\nexport interface BackgroundScriptsSession extends BackgroundScriptsPayload {\n stopRequested: string[];\n}\n\nexport const EMPTY_BACKGROUND_SCRIPTS: BackgroundScriptsSession = { scripts: [], stopRequested: [] };\n\nfunction isScript(value: unknown): value is BackgroundScriptView {\n if (typeof value !== 'object' || value === null) return false;\n const script = value as Record<string, unknown>;\n return (\n typeof script.id === 'string' &&\n typeof script.label === 'string' &&\n typeof script.startedAt === 'string' &&\n (script.status === 'running' || script.status === 'reporting')\n );\n}\n\n/** Gates the wire: a payload without a script list is dropped, malformed scripts are skipped. */\nexport function parseBackgroundScripts(input: unknown): BackgroundScriptsPayload | null {\n if (typeof input !== 'object' || input === null) return null;\n const scripts = (input as { scripts?: unknown }).scripts;\n return Array.isArray(scripts) ? { scripts: scripts.filter(isScript) } : null;\n}\n\n/** A stop request is spent once its script stops running or leaves the feed. */\nexport function reduceBackgroundScripts(\n current: BackgroundScriptsSession,\n payload: BackgroundScriptsPayload,\n): BackgroundScriptsSession {\n const live = new Set(payload.scripts.filter((script) => script.status === 'running').map((script) => script.id));\n return { ...payload, stopRequested: current.stopRequested.filter((id) => live.has(id)) };\n}\n\n/** Records a stop the page asked for, once. */\nexport function withStopRequested(current: BackgroundScriptsSession, id: string): BackgroundScriptsSession {\n return { ...current, stopRequested: [...current.stopRequested.filter((known) => known !== id), id] };\n}\n","import { defineSessionStore, type SessionFrameSender } from '@agimon-ai/po-core/native';\n\nimport { CODEMODE_BACKGROUND_TYPE, CODEMODE_STOP_COMMAND } from '../../../../../constants/backgroundScripts';\nimport type { BackgroundScriptsPayload } from '../../../../../types/backgroundScripts';\nimport {\n type BackgroundScriptsSession,\n EMPTY_BACKGROUND_SCRIPTS,\n parseBackgroundScripts,\n reduceBackgroundScripts,\n withStopRequested,\n} from './backgroundScriptsFeed';\n\nexport const backgroundScripts = defineSessionStore<BackgroundScriptsSession>(EMPTY_BACKGROUND_SCRIPTS);\n\n/** Asks the session to stop one script; the request holds until the script leaves the feed. */\nexport function requestScriptStop(send: SessionFrameSender, sessionId: string, id: string): void {\n send(sessionId, { type: 'prompt', message: `/${CODEMODE_STOP_COMMAND} ${id}` });\n backgroundScripts.update(sessionId, (current) => withStopRequested(current, id));\n}\n\n/** The session's background-script channel: 'codemode_background' payloads into the store. */\nexport const backgroundScriptsChannel = backgroundScripts.channel<BackgroundScriptsPayload>({\n channel: CODEMODE_BACKGROUND_TYPE,\n parse: parseBackgroundScripts,\n reduce: reduceBackgroundScripts,\n});\n","import { defineChannelFile } from '@agimon-ai/po-core/native';\n\nimport { backgroundScriptsChannel } from '../_lib/backgroundScriptsStore.native';\n\nexport default defineChannelFile(backgroundScriptsChannel);\n","import type { WebPluginSlotProps } from '@agimon-ai/po-core/native';\nimport { Button, Dot, fontOf, LiveDuration } from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { useCallback, useSyncExternalStore } from 'react';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { backgroundScripts, requestScriptStop } from '../../_lib/backgroundScriptsStore.native';\n\n/**\n * The session's running `exec_background` scripts, under the runners in the Runners group.\n * Nothing renders while none runs, so the runners' own idle line stays the group's only line.\n */\nexport function BackgroundScriptsSection({ sessionId, sendSessionFrame }: WebPluginSlotProps) {\n const subscribe = useCallback((listener: () => void) => {\n const subscription = backgroundScripts.store.subscribe(listener);\n return () => subscription.unsubscribe();\n }, []);\n const session = useSyncExternalStore(subscribe, () =>\n backgroundScripts.select(backgroundScripts.store.state, sessionId),\n );\n if (session.scripts.length === 0) return null;\n return (\n <View testID=\"activity-background-scripts\">\n {session.scripts.map((script) => {\n const stopping = session.stopRequested.includes(script.id);\n return (\n <View key={script.id} testID={`activity-background-script-${script.id}`} style={styles.row}>\n <View style={styles.line}>\n <Dot tone=\"yellow\" pulse={script.status === 'running'} />\n <Text numberOfLines={1} style={styles.name}>\n Background script\n </Text>\n {script.status === 'reporting' ? (\n <Text style={styles.meta}>finishing…</Text>\n ) : (\n <LiveDuration label=\"up\" since={Date.parse(script.startedAt)} style={styles.meta} />\n )}\n {sessionId !== null && script.status === 'running' ? (\n <Button\n testID={`activity-background-script-stop-${script.id}`}\n size=\"xs\"\n variant={stopping ? 'outline' : 'danger-outline'}\n disabled={stopping}\n onPress={() => requestScriptStop(sendSessionFrame, sessionId, script.id)}\n >\n {stopping ? 'Stopping…' : 'Stop'}\n </Button>\n ) : null}\n </View>\n <Text numberOfLines={1} style={styles.label}>\n {script.label}\n </Text>\n </View>\n );\n })}\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n row: { gap: theme.spacing(1), paddingVertical: theme.spacing(2) },\n line: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2) },\n name: {\n flex: 1,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.medium,\n },\n label: {\n // Under the name: the small dot plus the line's gap.\n paddingLeft: theme.spacing(3.5),\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n meta: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n}));\n","import { defineFill } from '@agimon-ai/po-core/native';\n\nimport { BackgroundScriptsSection } from './_components/BackgroundScriptsSection.native';\n\n// After the runners' own fill (default order 1000), so their idle line stays on top.\nexport default defineFill({\n slot: 'activity.runners',\n id: 'background-scripts',\n order: 1100,\n component: BackgroundScriptsSection,\n});\n","// 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 {/* A running script streams its finished calls; it has returned nothing yet. */}\n {running ? null : <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 channelCodemodeBackground from '../src/extensions/workspaces/sessions/(frontend)/channel/codemode-background.native';\nimport fillBackgroundScripts from '../src/extensions/workspaces/sessions/(frontend)/fill/BackgroundScripts.activity.runners.native';\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 packageName: '@agimon-ai/po-codemode',\n session: {\n get channels(): WebPluginContributions['channels'] { return [via({ channel: 'codemode_background' }, channelCodemodeBackground)]; },\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'activity.runners', id: 'background-scripts' }, fillBackgroundScripts)]; },\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['exec'] }, toolExec)]; },\n },\n});\n"],"mappings":";;;;;;;;;;AACA,MAAa,2BAA2B;;AAGxC,MAAa,wBAAwB;;;ACGrC,MAAa,2BAAqD;CAAE,SAAS,CAAC;CAAG,eAAe,CAAC;AAAE;AAEnG,SAAS,SAAS,OAA+C;CAC/D,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,SAAS;CACf,OACE,OAAO,OAAO,OAAO,YACrB,OAAO,OAAO,UAAU,YACxB,OAAO,OAAO,cAAc,aAC3B,OAAO,WAAW,aAAa,OAAO,WAAW;AAEtD;;AAGA,SAAgB,uBAAuB,OAAiD;CACtF,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,UAAW,MAAgC;CACjD,OAAO,MAAM,QAAQ,OAAO,IAAI,EAAE,SAAS,QAAQ,OAAO,QAAQ,EAAE,IAAI;AAC1E;;AAGA,SAAgB,wBACd,SACA,SAC0B;CAC1B,MAAM,OAAO,IAAI,IAAI,QAAQ,QAAQ,QAAQ,WAAW,OAAO,WAAW,SAAS,CAAC,CAAC,KAAK,WAAW,OAAO,EAAE,CAAC;CAC/G,OAAO;EAAE,GAAG;EAAS,eAAe,QAAQ,cAAc,QAAQ,OAAO,KAAK,IAAI,EAAE,CAAC;CAAE;AACzF;;AAGA,SAAgB,kBAAkB,SAAmC,IAAsC;CACzG,OAAO;EAAE,GAAG;EAAS,eAAe,CAAC,GAAG,QAAQ,cAAc,QAAQ,UAAU,UAAU,EAAE,GAAG,EAAE;CAAE;AACrG;;;AC3BA,MAAa,oBAAoB,mBAA6C,wBAAwB;;AAGtG,SAAgB,kBAAkB,MAA0B,WAAmB,IAAkB;CAC/F,KAAK,WAAW;EAAE,MAAM;EAAU,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,EAAE,SAAS,aAAa,CAAC;;;ACG3D,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,aAAa;CACb,SAAS;EACP,IAAI,WAA+C;GAAE,OAAO,CAAC,IAAI,EAAE,SAAS,sBAAsB,GAAGwB,kCAAyB,CAAC;EAAG;EAClI,IAAI,QAAyC;GAAE,OAAO,CAAC,IAAI;IAAE,MAAM;IAAoB,IAAI;GAAqB,GAAGC,iDAAqB,CAAC;EAAG;EAC5I,IAAI,gBAAyD;GAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,GAAGC,mBAAQ,CAAC;EAAG;CAC9G;AACF,CAAC"}
|
|
@@ -2,15 +2,17 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_codemodeTools = require("../codemodeTools-
|
|
5
|
+
const require_codemodeTools = require("../codemodeTools-DQOpNO5B.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
|
|
13
|
-
let _agimon_ai_po_config_majorModes = require("@agimon-ai/po-config/majorModes");
|
|
15
|
+
let _agimon_ai_po_config_presets = require("@agimon-ai/po-config/presets");
|
|
14
16
|
let typebox_value = require("typebox/value");
|
|
15
17
|
let typebox_schema = require("typebox/schema");
|
|
16
18
|
//#region src/services/codemodeScripts/index.ts
|
|
@@ -163,11 +165,11 @@ var LlmConfigService = class {
|
|
|
163
165
|
const { environment, homeDirectory } = this.io;
|
|
164
166
|
const fs = this.io.fs();
|
|
165
167
|
if (!fs || !homeDirectory) throw new Error("Code mode LLM configuration requires host filesystem and home.");
|
|
166
|
-
const modes = await (0,
|
|
168
|
+
const modes = await (0, _agimon_ai_po_config_presets.readPresetsConfig)(fs, snapshot.harness.root, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT, {
|
|
167
169
|
environment,
|
|
168
170
|
homeDirectory
|
|
169
171
|
});
|
|
170
|
-
const configurations = await (0,
|
|
172
|
+
const configurations = await (0, _agimon_ai_po_config_presets.readPackageConfigurations)(fs, modes, [...snapshot.harness.layers], CODEMODE_PACKAGE, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT);
|
|
171
173
|
let merged = {};
|
|
172
174
|
for (const entry of configurations) {
|
|
173
175
|
if (!(0, typebox_value.Check)(CodemodePackageConfigSchema, entry.config)) throw new TypeError("Invalid code mode package configuration: llmModel must be provider/modelId.");
|
|
@@ -191,7 +193,7 @@ const MAX_TOKENS = 4096;
|
|
|
191
193
|
const RESULT_TOOL = "return_result";
|
|
192
194
|
const MODEL = /^[^/\s]+\/\S+$/u;
|
|
193
195
|
const META = typebox_schema.Meta["http://json-schema.org/draft-07/schema#"];
|
|
194
|
-
const DECLARATIONS$
|
|
196
|
+
const DECLARATIONS$2 = `interface LlmRequest {
|
|
195
197
|
prompt: string;
|
|
196
198
|
/** Explicit JSON input only, never the surrounding conversation. */
|
|
197
199
|
input?: unknown;
|
|
@@ -301,7 +303,7 @@ function createLlmNamespace(options) {
|
|
|
301
303
|
return {
|
|
302
304
|
name: "llm",
|
|
303
305
|
summary: "One-shot LLM text and schema-validated JSON transforms. Explicit input only, bounded calls, no tools or retries.",
|
|
304
|
-
declarations: DECLARATIONS$
|
|
306
|
+
declarations: DECLARATIONS$2,
|
|
305
307
|
portable: true,
|
|
306
308
|
bind(run) {
|
|
307
309
|
if (run.sessionId !== context.sessionId) throw new Error("LLM namespace belongs to another session.");
|
|
@@ -405,6 +407,80 @@ function createLlmNamespace(options) {
|
|
|
405
407
|
};
|
|
406
408
|
}
|
|
407
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
|
|
408
484
|
//#region src/services/shellNamespace/index.ts
|
|
409
485
|
const DEFAULT_TIMEOUT_MS = 1e4;
|
|
410
486
|
const MAX_TIMEOUT_MS = 12e4;
|
|
@@ -416,7 +492,8 @@ const DECLARATIONS = `declare const shell: {
|
|
|
416
492
|
bash(input: { command: string; timeoutMs?: number }): Promise<{ stdout: string; stderr: string; exitCode: number }>;
|
|
417
493
|
};`;
|
|
418
494
|
function request(input) {
|
|
419
|
-
if (
|
|
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.");
|
|
420
497
|
const value = input;
|
|
421
498
|
if (Object.keys(value).some((key) => key !== "command" && key !== "timeoutMs")) throw new TypeError("shell.bash accepts only command and timeoutMs.");
|
|
422
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.`);
|
|
@@ -438,7 +515,7 @@ function createShellNamespace(options) {
|
|
|
438
515
|
const disposal = new AbortController();
|
|
439
516
|
const lifetime = AbortSignal.any([run.signal, disposal.signal]);
|
|
440
517
|
run.onDispose(() => disposal.abort(/* @__PURE__ */ new Error("Shell namespace run is disposed.")));
|
|
441
|
-
|
|
518
|
+
const bash = async (input) => {
|
|
442
519
|
lifetime.throwIfAborted();
|
|
443
520
|
const params = request(input);
|
|
444
521
|
const shell = options.shell();
|
|
@@ -488,7 +565,11 @@ function createShellNamespace(options) {
|
|
|
488
565
|
...failure === void 0 ? {} : { error: failure }
|
|
489
566
|
});
|
|
490
567
|
}
|
|
491
|
-
}
|
|
568
|
+
};
|
|
569
|
+
return {
|
|
570
|
+
bash,
|
|
571
|
+
run: bash
|
|
572
|
+
};
|
|
492
573
|
}
|
|
493
574
|
};
|
|
494
575
|
}
|
|
@@ -496,7 +577,7 @@ function createShellNamespace(options) {
|
|
|
496
577
|
//#region src/extensions/workspaces/sessions/(backend)/_lib/root.server.ts
|
|
497
578
|
/** One registry per session: contributors register into it, `discover` and `exec` read it. */
|
|
498
579
|
function createCodemodeSession({ context, agent, host, signal }) {
|
|
499
|
-
const registry = require_codemodeTools.createCodemodeRegistry();
|
|
580
|
+
const registry = require_codemodeTools.createCodemodeRegistry({ isActive: (source) => (0, _agimon_ai_po_core_headless.readPoHeadlessHost)(context)?.isSourceActive(source) ?? true });
|
|
500
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));
|
|
501
582
|
let temporaryDirectory;
|
|
502
583
|
context.inject([_agimon_ai_po_core_platform.PO_SESSION_FILES_SERVICE], (scoped) => {
|
|
@@ -534,16 +615,35 @@ function createCodemodeSession({ context, agent, host, signal }) {
|
|
|
534
615
|
registration.dispose();
|
|
535
616
|
shellRegistration.dispose();
|
|
536
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
|
+
});
|
|
537
627
|
}
|
|
538
628
|
let background;
|
|
629
|
+
const publishScripts = () => {
|
|
630
|
+
if (!execution) return;
|
|
631
|
+
host.context.directEvents?.publish(require_codemodeTools.CODEMODE_BACKGROUND_TYPE, execution.sessionId, { scripts: tools.backgroundScripts(execution.sessionId) });
|
|
632
|
+
};
|
|
539
633
|
const tools = require_codemodeTools.createCodemodeTools({
|
|
540
634
|
registry,
|
|
541
635
|
isolate: () => (0, _agimon_ai_po_core_platform.readPoIsolate)(context),
|
|
542
636
|
npm: () => (0, _agimon_ai_po_core_platform.readPoNpm)(context),
|
|
637
|
+
fs: () => (0, _agimon_ai_po_core_platform.readPoFs)(context),
|
|
543
638
|
scripts,
|
|
544
639
|
signal,
|
|
545
|
-
onBackgroundChange: () =>
|
|
640
|
+
onBackgroundChange: () => {
|
|
641
|
+
background?.update();
|
|
642
|
+
publishScripts();
|
|
643
|
+
},
|
|
644
|
+
approval: () => (0, _agimon_ai_po_core_approval.readPoApproval)(context)
|
|
546
645
|
});
|
|
646
|
+
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)));
|
|
547
647
|
context.inject([_agimon_ai_po_core_backgroundWork.PO_BACKGROUND_WORK_SERVICE], (scoped) => {
|
|
548
648
|
const registration = (0, _agimon_ai_po_core_backgroundWork.readPoBackgroundWorkService)(scoped)?.register(tools.backgroundWork);
|
|
549
649
|
background = registration;
|
|
@@ -572,7 +672,55 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(createCodemodeSess
|
|
|
572
672
|
var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(root);
|
|
573
673
|
//#endregion
|
|
574
674
|
//#region src/extensions/workspaces/sessions/(backend)/contract/codemode.server.ts
|
|
575
|
-
var codemode_server_default = (0, _agimon_ai_po_core_extensionFile.defineServiceContract)(_agimon_ai_po_core_codemode.
|
|
675
|
+
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);
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region src/services/backgroundScriptsChannel/index.ts
|
|
678
|
+
function scriptsPayload(value) {
|
|
679
|
+
return typeof value === "object" && value !== null && Array.isArray(value.scripts);
|
|
680
|
+
}
|
|
681
|
+
/** Relays each session's background-script snapshots, published on the direct event bus, to the page. */
|
|
682
|
+
function createBackgroundScriptsChannel() {
|
|
683
|
+
return {
|
|
684
|
+
frameType: require_codemodeTools.CODEMODE_BACKGROUND_TYPE,
|
|
685
|
+
start(host) {
|
|
686
|
+
const latest = /* @__PURE__ */ new Map();
|
|
687
|
+
const subscriptions = /* @__PURE__ */ new Map();
|
|
688
|
+
return {
|
|
689
|
+
payloadFor(scope) {
|
|
690
|
+
return latest.get(scope.sessionId);
|
|
691
|
+
},
|
|
692
|
+
sessionAdded(scope) {
|
|
693
|
+
subscriptions.get(scope.sessionId)?.();
|
|
694
|
+
latest.delete(scope.sessionId);
|
|
695
|
+
const unsubscribe = host.directEvents.subscribe(require_codemodeTools.CODEMODE_BACKGROUND_TYPE, scope.sessionId, (payload) => {
|
|
696
|
+
if (!scriptsPayload(payload)) return;
|
|
697
|
+
latest.set(scope.sessionId, payload);
|
|
698
|
+
host.publish(scope.sessionId, payload);
|
|
699
|
+
}, { replayLatest: true });
|
|
700
|
+
subscriptions.set(scope.sessionId, unsubscribe);
|
|
701
|
+
},
|
|
702
|
+
sessionRemoved(sessionId) {
|
|
703
|
+
subscriptions.get(sessionId)?.();
|
|
704
|
+
subscriptions.delete(sessionId);
|
|
705
|
+
latest.delete(sessionId);
|
|
706
|
+
},
|
|
707
|
+
close() {
|
|
708
|
+
for (const unsubscribe of subscriptions.values()) unsubscribe();
|
|
709
|
+
subscriptions.clear();
|
|
710
|
+
latest.clear();
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
//#endregion
|
|
717
|
+
//#region src/extensions/(backend)/channel/codemodeBackground.server.ts
|
|
718
|
+
var codemodeBackground_server_default = (0, _agimon_ai_po_core_extensionFile.defineChannel)(function codemodeBackgroundChannel() {
|
|
719
|
+
return createBackgroundScriptsChannel();
|
|
720
|
+
});
|
|
721
|
+
//#endregion
|
|
722
|
+
//#region src/extensions/workspaces/sessions/(backend)/command/background-scripts-stop.server.ts
|
|
723
|
+
var background_scripts_stop_server_default = (0, _agimon_ai_po_core_extensionFile.defineServerCommand)((context) => context.root.stopCommand);
|
|
576
724
|
//#endregion
|
|
577
725
|
//#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-llm.server.ts
|
|
578
726
|
var codemode_how_to_llm_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
|
|
@@ -584,6 +732,16 @@ var codemode_how_to_llm_server_default = (0, _agimon_ai_po_core_extensionFile.de
|
|
|
584
732
|
read: () => (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/codemode-how-to-llm/SKILL.md")
|
|
585
733
|
});
|
|
586
734
|
//#endregion
|
|
735
|
+
//#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-page.server.ts
|
|
736
|
+
var codemode_how_to_page_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
|
|
737
|
+
name: "codemode-how-to-page",
|
|
738
|
+
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.",
|
|
739
|
+
pinned: true,
|
|
740
|
+
kind: "skill",
|
|
741
|
+
path: (0, _agimon_ai_po_core_serverPlugin.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/codemode-how-to-page/SKILL.md"),
|
|
742
|
+
read: () => (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/codemode-how-to-page/SKILL.md")
|
|
743
|
+
});
|
|
744
|
+
//#endregion
|
|
587
745
|
//#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-shell.server.ts
|
|
588
746
|
var codemode_how_to_shell_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
|
|
589
747
|
name: "codemode-how-to-shell",
|
|
@@ -618,6 +776,8 @@ var exec_server_default = (0, _agimon_ai_po_core_extensionFile.defineServerTool)
|
|
|
618
776
|
//#endregion
|
|
619
777
|
//#region generated/server.ts
|
|
620
778
|
const at = (value, context) => typeof value === "function" ? value(context) : value;
|
|
779
|
+
/* v8 ignore next -- generated normalization branch */
|
|
780
|
+
const defined = (values) => values.filter((value) => value !== void 0);
|
|
621
781
|
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
622
782
|
...identity,
|
|
623
783
|
...value
|
|
@@ -627,6 +787,12 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
|
|
|
627
787
|
providerOverrides: (0, _agimon_ai_po_core_serverPlugin.composeServerProviderOverrides)(root_server_default),
|
|
628
788
|
provides: { session: [codemode_server_default] },
|
|
629
789
|
injects: (0, _agimon_ai_po_core_extensionFile.composeRootInjects)({ session: [root_server_default] }),
|
|
790
|
+
host: (context) => ({ get channels() {
|
|
791
|
+
return [() => via({ frameType: "codemode_background" }, at(codemodeBackground_server_default, context))];
|
|
792
|
+
} }),
|
|
793
|
+
workspace: (context) => ({ get channels() {
|
|
794
|
+
return defined([context.hosted("host") ? void 0 : () => via({ frameType: "codemode_background" }, at(codemodeBackground_server_default, context))]);
|
|
795
|
+
} }),
|
|
630
796
|
session: async (context) => {
|
|
631
797
|
const scopeSession = await context.scopeRoot("session", root_server_default, context);
|
|
632
798
|
const contextSession = {
|
|
@@ -635,9 +801,16 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
|
|
|
635
801
|
};
|
|
636
802
|
return {
|
|
637
803
|
...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeSession),
|
|
804
|
+
get channels() {
|
|
805
|
+
return defined([context.hosted("host") ? void 0 : () => via({ frameType: "codemode_background" }, at(codemodeBackground_server_default, context))]);
|
|
806
|
+
},
|
|
807
|
+
get commands() {
|
|
808
|
+
return [via({ name: "background-scripts-stop" }, at(background_scripts_stop_server_default, contextSession))];
|
|
809
|
+
},
|
|
638
810
|
get resources() {
|
|
639
811
|
return [
|
|
640
812
|
at(codemode_how_to_llm_server_default, contextSession),
|
|
813
|
+
at(codemode_how_to_page_server_default, contextSession),
|
|
641
814
|
at(codemode_how_to_shell_server_default, contextSession),
|
|
642
815
|
at(how_to_codemode_server_default, contextSession)
|
|
643
816
|
];
|