buckyos 0.7.205 → 0.7.208

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.
Files changed (94) hide show
  1. package/cli/dist/cli.mjs +1 -1
  2. package/cli/dist/cli.mjs.map +1 -1
  3. package/cli/version.ts +1 -1
  4. package/dist/{aiws_write-eeea8ed3.js → aiws_write-825bb6ba.js} +3 -3
  5. package/dist/aiws_write-825bb6ba.js.map +1 -0
  6. package/dist/{aiws_write-47c90e76.mjs → aiws_write-83ddc6cc.mjs} +30 -2
  7. package/dist/aiws_write-83ddc6cc.mjs.map +1 -0
  8. package/dist/app-frame.cjs +1 -1
  9. package/dist/app-frame.cjs.map +1 -1
  10. package/dist/app-frame.d.ts +221 -2
  11. package/dist/app-frame.d.ts.map +1 -1
  12. package/dist/app-frame.mjs +531 -15
  13. package/dist/app-frame.mjs.map +1 -1
  14. package/dist/browser.cjs +1 -1
  15. package/dist/browser.cjs.map +1 -1
  16. package/dist/browser.d.ts +4 -0
  17. package/dist/browser.d.ts.map +1 -1
  18. package/dist/browser.mjs +11 -6
  19. package/dist/browser.mjs.map +1 -1
  20. package/dist/content.cjs +1 -1
  21. package/dist/content.cjs.map +1 -1
  22. package/dist/content.d.ts +2 -0
  23. package/dist/content.d.ts.map +1 -1
  24. package/dist/content.mjs +14 -7
  25. package/dist/content.mjs.map +1 -1
  26. package/dist/{content_objid-0a095cbd.mjs → content_objid-76434848.mjs} +2 -2
  27. package/dist/{content_objid-0a095cbd.mjs.map → content_objid-76434848.mjs.map} +1 -1
  28. package/dist/{content_objid-4742308a.js → content_objid-addf9e2b.js} +2 -2
  29. package/dist/{content_objid-4742308a.js.map → content_objid-addf9e2b.js.map} +1 -1
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.ts +4 -0
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.mjs +11 -6
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/internal/html_tokens.d.ts +13 -0
  37. package/dist/internal/html_tokens.d.ts.map +1 -0
  38. package/dist/node.cjs +1 -1
  39. package/dist/node.cjs.map +1 -1
  40. package/dist/node.d.ts +4 -0
  41. package/dist/node.d.ts.map +1 -1
  42. package/dist/node.mjs +10 -5
  43. package/dist/node.mjs.map +1 -1
  44. package/dist/sdk_core.d.ts +18 -0
  45. package/dist/sdk_core.d.ts.map +1 -1
  46. package/dist/{site_manager-91b4d899.mjs → site_manager-604ee369.mjs} +207 -141
  47. package/dist/site_manager-604ee369.mjs.map +1 -0
  48. package/dist/site_manager-70710895.js +2 -0
  49. package/dist/site_manager-70710895.js.map +1 -0
  50. package/dist/transfer.cjs +2 -0
  51. package/dist/transfer.cjs.map +1 -0
  52. package/dist/transfer.d.ts +148 -0
  53. package/dist/transfer.d.ts.map +1 -0
  54. package/dist/transfer.mjs +655 -0
  55. package/dist/transfer.mjs.map +1 -0
  56. package/dist/user_preferences-1d49850a.mjs +158 -0
  57. package/dist/user_preferences-1d49850a.mjs.map +1 -0
  58. package/dist/user_preferences-7288c989.js +2 -0
  59. package/dist/user_preferences-7288c989.js.map +1 -0
  60. package/dist/user_preferences.d.ts +50 -0
  61. package/dist/user_preferences.d.ts.map +1 -0
  62. package/dist/xllm/core/loop.d.ts.map +1 -1
  63. package/dist/xllm/core/types.d.ts +0 -2
  64. package/dist/xllm/core/types.d.ts.map +1 -1
  65. package/dist/xllm/hosts/deno/native_runtime.d.ts.map +1 -1
  66. package/dist/xllm/hosts/deno/native_tools.d.ts +2 -1
  67. package/dist/xllm/hosts/deno/native_tools.d.ts.map +1 -1
  68. package/dist/xllm/index.d.ts +3 -2
  69. package/dist/xllm/index.d.ts.map +1 -1
  70. package/dist/xllm/runtime/hints.d.ts +9 -4
  71. package/dist/xllm/runtime/hints.d.ts.map +1 -1
  72. package/dist/xllm/runtime/step_renderer.d.ts +4 -4
  73. package/dist/xllm/runtime/step_renderer.d.ts.map +1 -1
  74. package/dist/xllm/runtime/text_budget.d.ts +5 -0
  75. package/dist/xllm/runtime/text_budget.d.ts.map +1 -0
  76. package/dist/xllm/runtime/tool_result.d.ts +14 -1
  77. package/dist/xllm/runtime/tool_result.d.ts.map +1 -1
  78. package/dist/xllm.cjs +1 -1
  79. package/dist/xllm.cjs.map +1 -1
  80. package/dist/xllm.mjs +35 -29
  81. package/dist/xllm_deno.cjs +1 -1
  82. package/dist/xllm_deno.cjs.map +1 -1
  83. package/dist/xllm_deno.mjs +123 -42
  84. package/dist/xllm_deno.mjs.map +1 -1
  85. package/package.json +6 -1
  86. package/dist/aiws_write-47c90e76.mjs.map +0 -1
  87. package/dist/aiws_write-eeea8ed3.js.map +0 -1
  88. package/dist/runtime_env-39e4df98.mjs +0 -44
  89. package/dist/runtime_env-39e4df98.mjs.map +0 -1
  90. package/dist/runtime_env-6396e1eb.js +0 -2
  91. package/dist/runtime_env-6396e1eb.js.map +0 -1
  92. package/dist/site_manager-716a2cf5.js +0 -2
  93. package/dist/site_manager-716a2cf5.js.map +0 -1
  94. package/dist/site_manager-91b4d899.mjs.map +0 -1
package/dist/xllm.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"xllm.cjs","sources":["../src/xllm/runtime/site.ts","../src/internal/command_args.ts","../src/xllm/runtime/site_tools.ts","../src/xllm/runtime/did_object_resources.ts","../src/xllm/hosts/browser/store.ts"],"sourcesContent":["// `createSiteRuntime`: a page turns the tools of one scene into an\n// AgentRuntime. The SDK ships no tools here; what the scene can do is the\n// page's own JS functions, so xllm never exceeds what the page's JS can do.\n//\n// descriptor: { kind: \"site\", runtime_id: \"site:<scene>\", host: null,\n// target: { origin, scene }, workdir: \"/\", capabilities: { tools: {}, network: true, os: \"browser\" } }\n// Neither the user agent nor the tool list is part of it: a browser update or\n// a new page tool must not make old runs unresumable, while a run of scene A\n// cannot be resumed in scene B (the descriptors differ).\n\nimport type { AiToolCall, EffectiveTools, ResolvedTool, RuntimeConfig, RuntimeDescriptor, RuntimeInfo, ToolSource, ToolsConfig } from '../core/types'\nimport { XllmError } from '../core/errors'\nimport { describeToolSource, shellSettings, taskWaitMs } from '../core/config'\nimport type { AgentRuntime, OpenedTools, RunBinding, RuntimeOpenCtx, SiteTool } from './types'\nimport { unresolvedReason } from './types'\nimport { SiteToolManager } from './site_manager'\n\nexport const SITE_RUNTIME_KIND = 'site'\n\nconst TOOL_NAME = /^[A-Za-z0-9_-]{1,64}$/\n\nexport interface SiteRuntimeOptions {\n /** The scene name, e.g. `aiws.wish`: part of the runtime's identity. */\n scene: string\n /** The page's origin (passed in: the runtime never reads `location`). */\n origin: string\n hostname: string\n /** Every tool of this scene. */\n tools: Record<string, SiteTool>\n /** What `{{env.NAME}}` may read. */\n env?: Record<string, string>\n /** `runtime.task_wait_ms` (in-call wait budget for tasks, M2). */\n task_wait_ms?: number\n}\n\nexport interface SiteRuntime extends AgentRuntime {\n readonly scene: string\n /** The scene's tools, by name. */\n readonly tools: ReadonlyMap<string, SiteTool>\n}\n\nfunction resolveTool(name: string, tool: SiteTool, source: string): ResolvedTool {\n return { name, description: tool.spec.description, args_schema: tool.spec.args_schema, source }\n}\n\nfunction namedSources(cfg: ToolSource[] | undefined, field: string): string[] {\n return (cfg ?? []).map(s => {\n if (s.kind !== 'named') {\n throw XllmError.capability(`${field}: \\`${describeToolSource(s)}\\` is not available in a site runtime; only the page's tools can be named`)\n }\n return s.name\n })\n}\n\nexport function createSiteRuntime(options: SiteRuntimeOptions): SiteRuntime {\n const scene = options.scene?.trim()\n if (!scene) throw XllmError.input('createSiteRuntime: `scene` is required')\n if (!options.origin) throw XllmError.input('createSiteRuntime: `origin` is required')\n const tools = new Map<string, SiteTool>()\n for (const [name, tool] of Object.entries(options.tools ?? {})) {\n if (!TOOL_NAME.test(name)) throw XllmError.tools(`site tool name \\`${name}\\` must match ${TOOL_NAME}`)\n if (!tool || typeof tool.call !== 'function' || !tool.spec) throw XllmError.tools(`site tool \\`${name}\\` needs \\`spec\\` and \\`call\\``)\n tools.set(name, tool)\n }\n const env = { ...(options.env ?? {}) }\n const descriptor: RuntimeDescriptor = {\n runtime_id: `site:${scene}`,\n kind: SITE_RUNTIME_KIND,\n host: null,\n target: { origin: options.origin, scene },\n workdir: '/',\n capabilities: { tools: {}, network: true, os: 'browser' },\n }\n const config: RuntimeConfig = { kind: SITE_RUNTIME_KIND, env: {} }\n if (options.task_wait_ms !== undefined) config.task_wait_ms = options.task_wait_ms\n\n const runtime: SiteRuntime = {\n scene,\n tools,\n descriptor: () => JSON.parse(JSON.stringify(descriptor)),\n config: () => JSON.parse(JSON.stringify(config)),\n async info(): Promise<RuntimeInfo> {\n let timezone = ''\n try {\n timezone = Intl.DateTimeFormat().resolvedOptions().timeZone ?? ''\n } catch {\n timezone = ''\n }\n return {\n id: descriptor.runtime_id, kind: SITE_RUNTIME_KIND, os: 'browser', arch: '', hostname: options.hostname, shell: '',\n cwd: '/', tools: [], current_time: new Date().toISOString(), timezone, target: descriptor.target,\n platform: 'browser', shell_kind: '', baseline: '',\n }\n },\n async open(ctx: RuntimeOpenCtx, cfg: ToolsConfig): Promise<OpenedTools> {\n const enabled = cfg.enabled ?? false\n const tools2actions = cfg.tools2actions ?? false\n if (ctx.loop_model === 'function_call' && (tools2actions || (cfg.actions ?? []).length > 0)) {\n throw XllmError.capability('actions / tools2actions need loop_model behavior')\n }\n const pick = (names: string[], field: string): ResolvedTool[] => names.map(name => {\n const tool = tools.get(name)\n if (!tool) {\n throw XllmError.capability(`${field}: \\`${name}\\` is not a tool of scene \\`${scene}\\` (scene tools: ${[...tools.keys()].join(', ') || 'none'})`)\n }\n return resolveTool(name, tool, `name:${name}`)\n })\n let native: ResolvedTool[] = []\n let actions: ResolvedTool[] = []\n const toolSources = cfg.tools ?? []\n const actionSources = cfg.actions ?? []\n if (enabled) {\n const toolNames = cfg.tools === undefined ? [...tools.keys()] : namedSources(cfg.tools, 'tools.tools')\n native = pick(toolNames, 'tools.tools')\n actions = pick(namedSources(cfg.actions, 'tools.actions'), 'tools.actions')\n if (tools2actions) {\n actions = [...actions, ...native.filter(t => !actions.some(a => a.name === t.name))]\n native = []\n }\n }\n const selected = new Map<string, SiteTool>()\n for (const t of [...native, ...actions]) selected.set(t.name, tools.get(t.name) as SiteTool)\n const effective: EffectiveTools = {\n enabled,\n filesystem_policy: cfg.filesystem_policy ?? 'workspace',\n tools2actions,\n tool_sources: cfg.tools === undefined && enabled ? native.map(t => ({ kind: 'named', name: t.name })) : toolSources,\n action_sources: actionSources,\n native,\n actions,\n bash_tools: [],\n shell: shellSettings(cfg.shell, taskWaitMs(config)),\n exec_enabled: false,\n sources: { ...ctx.sources },\n }\n return { tools: effective, manager: new SiteToolManager(selected, { tasks: ctx.tasks, taskWaitMs: ctx.task_wait_ms }) }\n },\n async describeInterrupted(run: RunBinding, call: AiToolCall): Promise<string> {\n const tool = tools.get(call.name)\n if (tool?.describeInterrupted) {\n try {\n return await tool.describeInterrupted(call.args ?? {}, { run_id: run.run_id, call_id: call.call_id, signal: new AbortController().signal })\n } catch (e) {\n return `${unresolvedReason(call.name)} (describing it failed: ${e instanceof Error ? e.message : String(e)})`\n }\n }\n return unresolvedReason(call.name)\n },\n env: (name: string) => env[name],\n }\n return runtime\n}\n","// Command-line parsing shared by the `buckyos` CLI (`cli/core/argv.ts`,\n// `cli/core/command.ts`) and the xllm site tools' `exec`. Self-contained on\n// purpose: the CLI imports it by relative path. Errors carry the CLI's usage\n// codes; the CLI turns them into its `UsageError`.\n\nexport type JsonSchema = {\n type?: 'object' | 'array' | 'string' | 'boolean' | 'integer' | 'number' | 'null'\n title?: string\n description?: string\n properties?: Record<string, JsonSchema>\n required?: string[]\n additionalProperties?: boolean\n items?: JsonSchema\n enum?: unknown[]\n minLength?: number\n minimum?: number\n default?: unknown\n secret?: boolean\n}\n\nexport interface PositionalDefinition {\n name: string\n description: string\n required?: boolean\n}\n\nexport interface OptionDefinition {\n name: string\n property?: string\n description: string\n type: 'string' | 'boolean' | 'integer' | 'number'\n required?: boolean\n secret?: boolean\n enum?: string[]\n}\n\nexport type AccessLevel = 'read' | 'write' | 'destructive' | 'privileged'\n\n/** A usage error with the CLI's code (`UNKNOWN_OPTION`, `SCHEMA_VALIDATION_FAILED`, …). */\nexport class CommandArgsError extends Error {\n readonly code: string\n\n constructor(code: string, message: string) {\n super(message)\n this.name = 'CommandArgsError'\n this.code = code\n }\n}\n\nfunction hasOwn(o: object, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(o, key)\n}\n\nexport function optionProperty(option: OptionDefinition): string {\n return option.property ?? option.name.split('-').join('_')\n}\n\nexport interface LongOption {\n name: string\n inlineValue?: string\n}\n\nexport function splitLongOption(token: string): LongOption {\n const content = token.slice(2)\n const equalIndex = content.indexOf('=')\n return equalIndex < 0 ? { name: content } : { name: content.slice(0, equalIndex), inlineValue: content.slice(equalIndex + 1) }\n}\n\nexport function readOptionValue(argv: string[], index: number, option: LongOption): { value: string; consumed: number } {\n if (option.inlineValue !== undefined) {\n if (!option.inlineValue) throw new CommandArgsError('MISSING_ARGUMENT', `--${option.name} requires a value`)\n return { value: option.inlineValue, consumed: 1 }\n }\n const value = argv[index + 1]\n if (value === undefined || value.startsWith('--')) throw new CommandArgsError('MISSING_ARGUMENT', `--${option.name} requires a value`)\n return { value, consumed: 2 }\n}\n\nfunction parseOptionValue(type: string, value: string, name: string): unknown {\n if (type === 'string') return value\n const number = Number(value)\n if (!Number.isFinite(number) || (type === 'integer' && !Number.isInteger(number))) {\n throw new CommandArgsError('INVALID_ARGUMENT', `--${name} requires a ${type}`)\n }\n return number\n}\n\nfunction assignPositional(input: Record<string, unknown>, positionals: PositionalDefinition[], index: number, value: string): number {\n const positional = positionals[index]\n if (!positional) throw new CommandArgsError('TOO_MANY_ARGUMENTS', `unexpected positional argument: ${value}`)\n input[positional.name] = value\n return index + 1\n}\n\nexport interface ArgvSpec {\n positionals?: PositionalDefinition[]\n options?: OptionDefinition[]\n}\n\n/**\n * Looks at every long option before the command's own: the CLI handles its\n * interactive session options here. Return how many tokens it consumed, or\n * `undefined` to leave the option to the command.\n */\nexport type LongOptionHook = (option: LongOption, argv: string[], index: number) => number | undefined\n\n/** Positionals, `--opt value` / `--opt=value`, boolean options, `--`; `--help` / `-h` sets `help`. */\nexport function parseArgv(spec: ArgvSpec, argv: string[], beforeOption?: LongOptionHook): {\n input: Record<string, unknown>\n help: boolean\n positionalCount: number\n} {\n const input: Record<string, unknown> = {}\n const positionals = spec.positionals ?? []\n const optionByName = new Map((spec.options ?? []).map(o => [o.name, o]))\n let positionalIndex = 0\n let help = false\n for (let index = 0; index < argv.length;) {\n const token = argv[index]\n if (token === '--help' || token === '-h') {\n help = true\n index += 1\n continue\n }\n if (token === '--') {\n for (const value of argv.slice(index + 1)) positionalIndex = assignPositional(input, positionals, positionalIndex, value)\n break\n }\n if (!token.startsWith('--')) {\n positionalIndex = assignPositional(input, positionals, positionalIndex, token)\n index += 1\n continue\n }\n const parsed = splitLongOption(token)\n const handled = beforeOption?.(parsed, argv, index)\n if (handled !== undefined) {\n index += handled\n continue\n }\n const option = optionByName.get(parsed.name)\n if (!option) throw new CommandArgsError('UNKNOWN_OPTION', `unknown option: --${parsed.name}`)\n const property = optionProperty(option)\n if (hasOwn(input, property)) throw new CommandArgsError('DUPLICATE_ARGUMENT', `argument provided more than once: ${property}`)\n if (option.type === 'boolean') {\n if (parsed.inlineValue !== undefined) throw new CommandArgsError('INVALID_ARGUMENT', `--${parsed.name} does not accept a value`)\n input[property] = true\n index += 1\n continue\n }\n const { value, consumed } = readOptionValue(argv, index, parsed)\n input[property] = parseOptionValue(option.type, value, parsed.name)\n index += consumed\n }\n return { input, help, positionalCount: positionalIndex }\n}\n\n/** Required positionals after `positionalCount` must be in `inputObject`. */\nexport function checkRequiredPositionals(positionals: PositionalDefinition[], positionalCount: number, inputObject: Record<string, unknown> | undefined) {\n for (let index = positionalCount; index < positionals.length; index++) {\n if (positionals[index].required !== false && !hasOwn(inputObject ?? {}, positionals[index].name)) {\n throw new CommandArgsError('MISSING_ARGUMENT', `missing positional argument: ${positionals[index].name}`)\n }\n }\n}\n\nexport function mergeCommandInput(inputObject: Record<string, unknown> | undefined, cliInput: Record<string, unknown>): Record<string, unknown> {\n const result = { ...(inputObject ?? {}) }\n for (const [key, value] of Object.entries(cliInput)) {\n if (hasOwn(result, key)) throw new CommandArgsError('ARGUMENT_CONFLICT', `${key} is present in both --input and argv`)\n result[key] = value\n }\n return result\n}\n\n/** Split a command line into words: single and double quotes, backslash escapes (not inside single quotes). */\nexport function parseShellLine(line: string): string[] {\n const tokens: string[] = []\n let current = ''\n let quote: 'single' | 'double' | null = null\n let escaped = false\n let started = false\n for (const character of line) {\n if (escaped) {\n current += character\n escaped = false\n started = true\n continue\n }\n if (character === '\\\\' && quote !== 'single') {\n escaped = true\n started = true\n continue\n }\n if (quote === 'single') {\n if (character === \"'\") quote = null\n else current += character\n continue\n }\n if (quote === 'double') {\n if (character === '\"') quote = null\n else current += character\n continue\n }\n if (character === \"'\") {\n quote = 'single'\n started = true\n continue\n }\n if (character === '\"') {\n quote = 'double'\n started = true\n continue\n }\n if (/\\s/.test(character)) {\n if (started) {\n tokens.push(current)\n current = ''\n started = false\n }\n continue\n }\n current += character\n started = true\n }\n if (escaped) throw new CommandArgsError('INVALID_COMMAND_LINE', 'unfinished escape sequence')\n if (quote) throw new CommandArgsError('INVALID_COMMAND_LINE', `unterminated ${quote} quote`)\n if (started) tokens.push(current)\n return tokens\n}\n\nexport function validateSchema(value: unknown, schema: JsonSchema, path: string): void {\n if (schema.enum && !schema.enum.some(candidate => Object.is(candidate, value))) {\n throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be one of ${schema.enum.join(', ')}`)\n }\n if (schema.type === 'object') {\n if (!value || typeof value !== 'object' || Array.isArray(value)) throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be an object`)\n const object = value as Record<string, unknown>\n for (const required of schema.required ?? []) {\n if (!hasOwn(object, required)) throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path}.${required} is required`)\n }\n if (schema.additionalProperties === false) {\n for (const key of Object.keys(object)) {\n if (!hasOwn(schema.properties ?? {}, key)) throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path}.${key} is not allowed`)\n }\n }\n for (const [key, propertyValue] of Object.entries(object)) {\n const propertySchema = schema.properties?.[key]\n if (propertySchema) validateSchema(propertyValue, propertySchema, `${path}.${key}`)\n }\n return\n }\n if (schema.type === 'array') {\n if (!Array.isArray(value)) throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be an array`)\n const items = schema.items\n if (items) value.forEach((item, index) => validateSchema(item, items, `${path}[${index}]`))\n return\n }\n if (schema.type === 'string') {\n if (typeof value !== 'string') throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be a string`)\n if (schema.minLength !== undefined && value.length < schema.minLength) throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} is too short`)\n return\n }\n if (schema.type === 'boolean' && typeof value !== 'boolean') throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be a boolean`)\n if (schema.type === 'integer' && (!Number.isInteger(value) || typeof value !== 'number')) {\n throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be an integer`)\n }\n if (schema.type === 'number' && typeof value !== 'number') throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be a number`)\n}\n","// Optional basic tools for a site (TODO §2.1, a trial): what `bash_core`'s four\n// tools are for files, `read` / `write` / `edit` / `exec` are for a page's\n// resources and commands. REST semantics: read = GET (a collection's read is\n// its list, filter with a query), write = PUT, edit = PATCH; everything REST\n// cannot say is a command run by `exec` — `xcall <object> <action>` for the\n// actions declared on resources (DID Object style, with `risk`), and the\n// page's own commands. The four specs are fixed: more resources and commands\n// cost no tokens per round. Every resource, action and command is declared by\n// the page; nothing is forwarded to `fetch` or turned into a raw RPC.\n\nimport type { JsonValue } from '../core/types'\nimport { isObject } from '../core/json'\nimport { validateJson } from '../core/json_check'\nimport { utf8Length } from '../core/tokenizer'\nimport type { SiteTool, SiteToolCtx } from './types'\nimport {\n CommandArgsError, parseArgv, parseShellLine, validateSchema,\n} from '../../internal/command_args'\nimport type { AccessLevel, JsonSchema, OptionDefinition, PositionalDefinition } from '../../internal/command_args'\n\nexport type ActionRisk = 'read_only' | 'idempotent_write' | 'write' | 'destructive' | 'admin'\nexport const ACTION_RISKS: ActionRisk[] = ['read_only', 'idempotent_write', 'write', 'destructive', 'admin']\n\nexport const XCALL_USAGE = 'xcall <object> <action> [--params <json>] [key=value ...] [--key=value ...]'\n/** Result text cap of `read` (one page) and `exec`. */\nexport const MAX_RESULT_BYTES = 64 * 1024\n\n/** What a resource method gets: the URI as normalized, the `{name}` parameters, the query. */\nexport interface ResourceMatch {\n uri: string\n pattern: string\n params: Record<string, string>\n query: URLSearchParams\n ctx: SiteToolCtx\n}\n\n/** A read may return a version: `write` (and the default `edit`) gets it back as `ifVersion`. */\nexport interface Versioned {\n content: unknown\n version?: string\n}\n\nexport interface WriteBody {\n content: string\n mode: 'write' | 'new' | 'append'\n ifVersion?: string\n}\n\nexport interface ActionDecl {\n description: string\n risk: ActionRisk\n /** JSON Schema of the params. */\n input?: JsonValue\n call(m: ResourceMatch, params: Record<string, JsonValue>): unknown\n}\n\nexport interface ResourceDecl {\n description: string\n read?(m: ResourceMatch): unknown\n write?(m: ResourceMatch, body: WriteBody): unknown\n edit?(m: ResourceMatch, body: { old_string: string; new_string: string }): unknown\n actions?: Record<string, ActionDecl>\n}\n\n/** A page command: a subset of the CLI `CommandDefinition`; `call(input)` replaces its handler. */\nexport interface CommandDecl {\n summary: string\n description?: string\n positionals?: PositionalDefinition[]\n options?: OptionDefinition[]\n inputSchema?: JsonSchema\n access?: { mode: 'fixed'; level: AccessLevel }\n examples?: string[]\n call(input: Record<string, unknown>, ctx: SiteToolCtx): unknown\n}\n\nexport interface SiteToolsOptions {\n resources?: Record<string, ResourceDecl>\n commands?: Record<string, CommandDecl>\n}\n\nconst LOCAL_BASE = 'site://page/'\nconst SHELL_CHARS = /[|;&><`$]/\n\ninterface Pattern {\n raw: string\n origin?: string\n segments: string[]\n decl: ResourceDecl\n}\n\nfunction parsePattern(raw: string, decl: ResourceDecl): Pattern {\n const i = raw.indexOf('://')\n if (i >= 0) {\n const rest = raw.slice(i + 3)\n const slash = rest.indexOf('/')\n const host = slash < 0 ? rest : rest.slice(0, slash)\n const path = slash < 0 ? '' : rest.slice(slash + 1)\n return { raw, origin: `${raw.slice(0, i).toLowerCase()}://${host.toLowerCase()}`, segments: path ? path.split('/') : [], decl }\n }\n const path = raw.replace(/^\\/+/, '').replace(/\\/+$/, '')\n return { raw, segments: path ? path.split('/') : [], decl }\n}\n\nfunction fail(message: string): never {\n throw new Error(message)\n}\n\n/** Normalize a URI the model gave: relative paths and declared absolute origins only, no `..`, no encoded separators. */\nexport function normalizeUri(uri: string, origins: Set<string>): { origin?: string; segments: string[]; query: URLSearchParams; text: string } {\n const raw = uri.trim()\n if (!raw) fail('uri is empty')\n const absolute = /^[A-Za-z][A-Za-z0-9+.-]*:/.test(raw)\n let url: URL\n try {\n url = absolute ? new URL(raw) : new URL(raw.replace(/^\\/+/, ''), LOCAL_BASE)\n } catch {\n fail(`invalid uri \\`${raw}\\``)\n }\n let origin: string | undefined\n if (absolute) {\n origin = `${url.protocol.slice(0, -1).toLowerCase()}://${url.host.toLowerCase()}`\n if (!origins.has(origin)) fail(`uri \\`${raw}\\` is not a resource of this page (absolute URIs are limited to the declared ones)`)\n } else if (url.protocol !== 'site:' || url.host !== 'page') {\n fail(`uri \\`${raw}\\` is not a resource of this page`)\n }\n const segments: string[] = []\n for (const part of url.pathname.split('/')) {\n if (part === '') continue\n let decoded: string\n try {\n decoded = decodeURIComponent(part)\n } catch {\n fail(`invalid uri \\`${raw}\\``)\n }\n if (decoded === '..' || decoded === '.' || decoded.includes('/') || decoded.includes('\\\\')) fail(`uri \\`${raw}\\` is not a resource of this page`)\n segments.push(decoded)\n }\n const text = (origin ? `${origin}/` : '') + segments.join('/') + (url.search || '')\n return { origin, segments, query: url.searchParams, text }\n}\n\nfunction matchPattern(p: Pattern, origin: string | undefined, segments: string[]): Record<string, string> | undefined {\n if (p.origin !== origin || p.segments.length !== segments.length) return undefined\n const params: Record<string, string> = {}\n for (let i = 0; i < segments.length; i++) {\n const s = p.segments[i]\n if (s.startsWith('{') && s.endsWith('}')) params[s.slice(1, -1)] = segments[i]\n else if (s !== segments[i]) return undefined\n }\n return params\n}\n\nfunction asText(value: unknown): string {\n if (value === undefined || value === null) return ''\n if (typeof value === 'string') return value\n try {\n return JSON.stringify(value, null, 2)\n } catch {\n return String(value)\n }\n}\n\nfunction versioned(value: unknown): { text: string; version?: string } {\n if (isObject(value) && 'content' in value && Object.keys(value).every(k => k === 'content' || k === 'version')) {\n const version = value.version\n return { text: asText(value.content), version: typeof version === 'string' ? version : version === undefined ? undefined : String(version) }\n }\n return { text: asText(value) }\n}\n\nfunction clipBytes(text: string, max: number): { text: string; clipped: boolean } {\n if (utf8Length(text) <= max) return { text, clipped: false }\n let out = ''\n let bytes = 0\n for (const ch of text) {\n const n = utf8Length(ch)\n if (bytes + n > max) break\n out += ch\n bytes += n\n }\n return { text: out, clipped: true }\n}\n\n/** One page of a text by lines: `offset` is the 1-based first line. */\nexport function pageText(text: string, offset = 1, limit?: number): string {\n const lines = text.split('\\n')\n const start = Math.max(1, Math.floor(offset))\n if (start > lines.length && !(start === 1 && lines.length === 1)) return `[offset ${start} is past the end: ${lines.length} lines]`\n const wanted = limit === undefined ? lines.length : Math.max(1, Math.floor(limit))\n const out: string[] = []\n let bytes = 0\n let i = start - 1\n for (; i < lines.length && out.length < wanted; i++) {\n const n = utf8Length(lines[i]) + 1\n if (out.length > 0 && bytes + n > MAX_RESULT_BYTES) break\n out.push(lines[i])\n bytes += n\n }\n let body = out.join('\\n')\n if (out.length === 1 && utf8Length(body) > MAX_RESULT_BYTES) body = clipBytes(body, MAX_RESULT_BYTES).text + ' …'\n if (i < lines.length) body += `\\n[lines ${start}–${i} of ${lines.length}; read on with offset=${i + 1}]`\n return body\n}\n\nfunction parseScalar(raw: string): JsonValue {\n const v = raw.trim()\n if (v === 'true') return true\n if (v === 'false') return false\n if (v === 'null') return null\n if (/^-?\\d+(\\.\\d+)?([eE][+-]?\\d+)?$/.test(v)) return Number(v)\n if (v.startsWith('{') || v.startsWith('[')) {\n try {\n return JSON.parse(v)\n } catch {\n return v\n }\n }\n return v\n}\n\nconst UNSUPPORTED_XCALL_KEYS = ['config', 'route-config', 'session-id', 'session_id', 'idempotency-key', 'idempotency_key',\n 'confirm-token', 'confirm_token', 'trace-id', 'trace_id']\n\n/** `xcall` arguments as Rust parses them (`parse_object_x_call_cli_command`), minus routing and confirmation flags. */\nfunction parseXcall(tokens: string[]): { object: string; action: string; params: Record<string, JsonValue> } {\n let object: string | undefined\n let action: string | undefined\n let params: JsonValue = {}\n const pairs: Record<string, JsonValue> = {}\n const positionals: string[] = []\n const json = (raw: string, name: string): JsonValue => {\n try {\n return JSON.parse(raw)\n } catch (e) {\n fail(`invalid \\`${name}\\` JSON value \\`${raw}\\`: ${e instanceof Error ? e.message : String(e)}\\nusage: ${XCALL_USAGE}`)\n }\n }\n const unsupported = (t: string): never => fail(`unsupported flag \\`${t}\\` (routing and confirmation are the page's)\\nusage: ${XCALL_USAGE}`)\n for (let i = 0; i < tokens.length; i++) {\n const t = tokens[i]\n if (t === '--params') {\n const v = tokens[++i]\n if (v === undefined) fail(`missing value for --params\\nusage: ${XCALL_USAGE}`)\n params = json(v, '--params')\n } else if (t.startsWith('--')) {\n const eq = t.indexOf('=')\n if (eq < 0) unsupported(t)\n const key = t.slice(2, eq)\n const value = t.slice(eq + 1)\n if (key === 'params') params = json(value, '--params')\n else if (!key.trim() || key.startsWith('-') || UNSUPPORTED_XCALL_KEYS.includes(key)) unsupported(t)\n else pairs[key] = parseScalar(value)\n } else if (t.includes('=')) {\n const eq = t.indexOf('=')\n const key = t.slice(0, eq)\n const value = t.slice(eq + 1)\n if (key === 'object') object = value\n else if (key === 'action') action = value\n else if (key === 'params') params = json(value, 'params')\n else if (UNSUPPORTED_XCALL_KEYS.includes(key)) unsupported(t)\n else pairs[key] = parseScalar(value)\n } else {\n positionals.push(t)\n }\n }\n object = object ?? positionals[0]\n action = action ?? positionals[1]\n if (positionals[2] !== undefined) params = json(positionals[2], 'params')\n if (positionals.length > 3) fail(`unexpected positional argument \\`${positionals[3]}\\`\\nusage: ${XCALL_USAGE}`)\n if (Object.keys(pairs).length) {\n if (!isObject(params)) fail(`key=value params require object params\\nusage: ${XCALL_USAGE}`)\n params = { ...params, ...pairs }\n }\n if (!object || !action) fail(`xcall needs an object and an action\\nusage: ${XCALL_USAGE}`)\n if (!isObject(params)) fail(`params must be a JSON object\\nusage: ${XCALL_USAGE}`)\n return { object, action, params }\n}\n\nfunction commandUsage(name: string, c: CommandDecl): string {\n const lines = [`${name} — ${c.summary}`]\n if (c.description) lines.push('', c.description)\n const pos = (c.positionals ?? []).map(p => (p.required === false ? `[${p.name}]` : `<${p.name}>`)).join(' ')\n lines.push('', `usage: ${name}${pos ? ` ${pos}` : ''}${(c.options ?? []).length ? ' [options]' : ''}`)\n for (const p of c.positionals ?? []) lines.push(` ${p.name} ${p.description}`)\n if ((c.options ?? []).length) lines.push('options:')\n for (const o of c.options ?? []) {\n lines.push(` --${o.name}${o.type === 'boolean' ? '' : ` <${o.type}>`}${o.required ? ' (required)' : ''} ${o.description}${o.enum ? ` (${o.enum.join(' | ')})` : ''}`)\n }\n if (c.examples?.length) {\n lines.push('examples:')\n for (const e of c.examples) lines.push(` ${e}`)\n }\n return lines.join('\\n')\n}\n\nconst OBJECT_ARGS = (props: Record<string, JsonValue>, required: string[]): JsonValue => ({ type: 'object', properties: props, required })\n\n/**\n * The four basic tools over the page's resources and commands. Spread them\n * into `createSiteRuntime({ tools })`, alongside named tools if wanted.\n */\nexport function siteTools(options: SiteToolsOptions): Record<string, SiteTool> {\n const patterns = Object.entries(options.resources ?? {}).map(([raw, decl]) => parsePattern(raw, decl))\n const origins = new Set(patterns.map(p => p.origin).filter((o): o is string => o !== undefined))\n const commands = new Map(Object.entries(options.commands ?? {}))\n if (commands.has('xcall')) throw new Error('siteTools: `xcall` is built in; declare actions on resources instead')\n\n const resolve = (uri: string, ctx: SiteToolCtx): ResourceMatch & { decl: ResourceDecl } => {\n const n = normalizeUri(uri, origins)\n for (const p of patterns) {\n const params = matchPattern(p, n.origin, n.segments)\n if (params) return { uri: n.text, pattern: p.raw, params, query: n.query, ctx, decl: p.decl }\n }\n fail(`uri \\`${uri}\\` is not a resource of this page; read uri=\"/\" lists them`)\n }\n\n const discovery = (): string => {\n const lines = ['Resources (read uri=\"<resource>\"; {name} is one path segment):']\n for (const p of patterns) {\n const methods = (['read', 'write', 'edit'] as const).filter(m => m === 'edit' ? !!(p.decl.edit || (p.decl.read && p.decl.write)) : !!p.decl[m])\n lines.push(`- ${p.raw} — ${p.decl.description} [${methods.join(', ') || 'no methods'}]`)\n for (const [name, a] of Object.entries(p.decl.actions ?? {})) lines.push(` action ${name} (risk: ${a.risk}) — ${a.description}`)\n }\n if (patterns.length === 0) lines.push('(none)')\n lines.push('', 'Commands (exec \"<command> --help\" for usage):')\n lines.push(`- xcall — call an action of a resource: ${XCALL_USAGE}`)\n for (const [name, c] of commands) lines.push(`- ${name} — ${c.summary}`)\n return lines.join('\\n')\n }\n\n const exec = async (command: string, ctx: SiteToolCtx): Promise<string> => {\n const words = (() => {\n try {\n return parseShellLine(command)\n } catch (e) {\n fail(`${e instanceof Error ? e.message : String(e)}; exec runs one command, it is not a shell`)\n }\n })()\n const available = `available commands: xcall${commands.size ? `, ${[...commands.keys()].join(', ')}` : ''}`\n const unquoted = command.replace(/'[^']*'|\"(?:[^\"\\\\]|\\\\.)*\"/g, '')\n if (SHELL_CHARS.test(unquoted)) {\n fail(`exec runs exactly one command and is not a shell: pipes, redirects, \\`;\\`, \\`&\\`, backquotes and \\`$\\` are not supported (quote them to pass them as text). ${available}`)\n }\n const [name, ...args] = words\n if (!name) fail(`empty command; ${available}`)\n if (name === 'xcall') {\n if (args.includes('--help') || args.includes('-h')) return `usage: ${XCALL_USAGE}\\nThe actions of each resource are listed by read uri=\"/\".`\n const { object, action, params } = parseXcall(args)\n const m = resolve(object, ctx)\n const decl = m.decl.actions?.[action]\n if (!decl) {\n const known = Object.keys(m.decl.actions ?? {})\n fail(`resource \\`${m.pattern}\\` has no action \\`${action}\\` (actions: ${known.length ? known.join(', ') : 'none'})`)\n }\n if (decl.input !== undefined) {\n const invalid = validateJson(decl.input, params)\n if (invalid) fail(`invalid params for ${action}: ${invalid}`)\n }\n const { decl: _decl, ...match } = m\n void _decl\n const result = await decl.call(match, params)\n return `[risk: ${decl.risk}]\\n${clipBytes(asText(result) || 'ok', MAX_RESULT_BYTES).text}`\n }\n const c = commands.get(name)\n if (!c) fail(`unknown command \\`${name}\\`; exec runs one command, it is not a shell. ${available}`)\n let input: Record<string, unknown>\n try {\n const parsed = parseArgv({ positionals: c.positionals, options: c.options }, args)\n if (parsed.help) return commandUsage(name, c)\n for (let i = parsed.positionalCount; i < (c.positionals ?? []).length; i++) {\n if ((c.positionals ?? [])[i].required !== false) throw new CommandArgsError('MISSING_ARGUMENT', `missing positional argument: ${(c.positionals ?? [])[i].name}`)\n }\n for (const o of c.options ?? []) {\n const prop = o.property ?? o.name.split('-').join('_')\n if (o.required && !(prop in parsed.input)) throw new CommandArgsError('MISSING_ARGUMENT', `--${o.name} is required`)\n }\n input = parsed.input\n if (c.inputSchema) validateSchema(input, c.inputSchema, 'input')\n } catch (e) {\n if (e instanceof CommandArgsError) fail(`${name}: ${e.message}\\n\\n${commandUsage(name, c)}`)\n throw e\n }\n return clipBytes(asText(await c.call(input, ctx)) || 'ok', MAX_RESULT_BYTES).text\n }\n\n const readRaw = async (m: ResourceMatch & { decl: ResourceDecl }) => {\n if (!m.decl.read) fail(`resource \\`${m.pattern}\\` cannot be read`)\n const { decl: _d, ...match } = m\n void _d\n return versioned(await m.decl.read(match))\n }\n\n return {\n read: {\n spec: {\n description: 'Read a resource of this page by URI (GET). Start with uri \"/\": it lists the resources, their actions (with risk) and the commands. A collection\\'s read is its list; filter and page with a query (notes?tag=x). Text comes in pages of lines: offset is the first line (1-based), limit the number of lines.',\n args_schema: OBJECT_ARGS({\n uri: { type: 'string', description: 'Resource URI, e.g. \"/\" or \"notes/1\"' },\n offset: { type: 'integer', description: 'First line, 1-based' },\n limit: { type: 'integer', description: 'Number of lines' },\n }, ['uri']),\n },\n idempotent: true,\n async call(args, ctx) {\n const uri = String(args.uri)\n const offset = typeof args.offset === 'number' ? args.offset : undefined\n const limit = typeof args.limit === 'number' ? args.limit : undefined\n if (uri.trim() === '/' || uri.trim() === '') return pageText(discovery(), offset, limit)\n const r = await readRaw(resolve(uri, ctx))\n return pageText(r.text, offset, limit)\n },\n },\n write: {\n spec: {\n description: 'Write a resource\\'s content (PUT). mode: \"write\" (default) replaces it, \"new\" only creates it and fails if it exists, \"append\" adds to its end. Use edit to change part of it.',\n args_schema: OBJECT_ARGS({\n uri: { type: 'string', description: 'Resource URI' },\n content: { type: 'string', description: 'The content' },\n mode: { type: 'string', enum: ['write', 'new', 'append'], description: 'write | new | append' },\n }, ['uri', 'content']),\n },\n async call(args, ctx) {\n const m = resolve(String(args.uri), ctx)\n if (!m.decl.write) fail(`resource \\`${m.pattern}\\` is read-only`)\n const { decl, ...match } = m\n const mode = (typeof args.mode === 'string' ? args.mode : 'write') as WriteBody['mode']\n return asText(await decl.write!(match, { content: String(args.content), mode })) || 'written'\n },\n },\n edit: {\n spec: {\n description: 'Change part of a resource (PATCH): old_string must occur exactly once in its current content and is replaced by new_string.',\n args_schema: OBJECT_ARGS({\n uri: { type: 'string', description: 'Resource URI' },\n old_string: { type: 'string', description: 'Text to replace; must occur exactly once' },\n new_string: { type: 'string', description: 'Replacement text' },\n }, ['uri', 'old_string', 'new_string']),\n },\n async call(args, ctx) {\n const m = resolve(String(args.uri), ctx)\n const body = { old_string: String(args.old_string), new_string: String(args.new_string) }\n const { decl, ...match } = m\n if (decl.edit) return asText(await decl.edit(match, body)) || 'edited'\n if (!decl.read || !decl.write) fail(`resource \\`${m.pattern}\\` cannot be edited`)\n if (!body.old_string) fail('old_string is empty')\n const current = versioned(await decl.read(match))\n const count = current.text.split(body.old_string).length - 1\n if (count === 0) fail('old_string was not found in the current content; read it again')\n if (count > 1) fail(`old_string occurs ${count} times; give more context so it occurs exactly once`)\n const content = current.text.replace(body.old_string, () => body.new_string)\n const w: WriteBody = { content, mode: 'write' }\n if (current.version !== undefined) w.ifVersion = current.version\n return asText(await decl.write(match, w)) || 'edited'\n },\n },\n exec: {\n spec: {\n description: `Run one command (not a shell: no pipes, redirects, ;, &, backquotes or $). Built in: ${XCALL_USAGE} — calls an action listed by read uri=\"/\". The page's commands are listed there too; \"<command> --help\" shows a command's usage.`,\n args_schema: OBJECT_ARGS({ command: { type: 'string', description: 'One command line' } }, ['command']),\n },\n idempotent: (args: Record<string, JsonValue>) => execIsIdempotent(String(args.command ?? ''), patterns, origins, commands),\n call: (args, ctx) => exec(String(args.command), ctx),\n },\n }\n}\n\n/** Resume rule of `exec`: `xcall` re-runs `read_only` / `idempotent_write` actions, commands re-run at `access: read`. */\nfunction execIsIdempotent(command: string, patterns: Pattern[], origins: Set<string>, commands: Map<string, CommandDecl>): boolean {\n let words: string[]\n try {\n words = parseShellLine(command)\n } catch {\n return false\n }\n const [name, ...args] = words\n if (name === 'xcall') {\n try {\n const { object, action } = parseXcall(args)\n const n = normalizeUri(object, origins)\n const p = patterns.find(q => matchPattern(q, n.origin, n.segments))\n const risk = p?.decl.actions?.[action]?.risk\n return risk === 'read_only' || risk === 'idempotent_write'\n } catch {\n return false\n }\n }\n const c = name ? commands.get(name) : undefined\n return c?.access?.level === 'read'\n}\n\n","// `siteTools` resources from DID Objects a BuckyOS service already serves\n// (`KrpcObjectProvider`): for each root the page lists, its Profile decides\n// what the model can do — properties are read, an IndexTrait collection is\n// read with a query, actions become `xcall` actions with the Profile's\n// `x-buckyos:risk` (above `maxRisk` they are not exposed). What can be reached\n// is decided by the Profile and the roots, never by a URI the model gives.\n\nimport type { JsonValue } from '../core/types'\nimport { isObject } from '../core/json'\nimport type { DIDObjectClient } from '../../did_object_client'\nimport { ACTION_RISKS } from './site_tools'\nimport type { ActionDecl, ActionRisk, ResourceDecl, ResourceMatch } from './site_tools'\n\nexport const INDEX_TRAIT_URI = 'https://buckyos.org/traits/index@1'\n\n/** What `didObjectResources` needs of a DID Object client. */\nexport type DidObjectReader = Pick<DIDObjectClient, 'card' | 'profile' | 'readProperty' | 'invoke'>\n\nexport interface DidObjectResourcesOptions {\n client: DidObjectReader\n /** Object URLs (`obj://…`) the page lets the model reach. */\n roots: string[]\n /** Actions above this risk are not exposed (default `read_only`). */\n maxRisk?: ActionRisk\n}\n\nfunction text(v: JsonValue | undefined, key: string): string {\n return isObject(v) && typeof v[key] === 'string' ? (v[key] as string) : ''\n}\n\nfunction riskRank(r: string): number {\n const i = ACTION_RISKS.indexOf(r as ActionRisk)\n return i < 0 ? ACTION_RISKS.length : i\n}\n\n/** The object document a read shows (as `render_object_document` in agent-did-object-lib). */\nexport function renderObjectDocument(canonical: string, card: { id: string; alsoKnownAs?: string[] }, profile: JsonValue,\n summary: Record<string, JsonValue>): string {\n const lines = [`Object: ${canonical}`, `Object DID: ${card.id}`]\n const aliases = (card.alsoKnownAs ?? []).filter(a => a !== canonical)\n if (aliases.length) lines.push(`Also known as: ${aliases.join(', ')}`)\n for (const [label, key] of [['Title', 'title'], ['Description', 'description']]) {\n const v = text(profile, key)\n if (v) lines.push(`${label}: ${v}`)\n }\n for (const [section, key] of [['Properties', 'properties'], ['Actions', 'actions'], ['Events', 'events']]) {\n const entries = isObject(profile) ? profile[key] : undefined\n if (!isObject(entries) || Object.keys(entries).length === 0) continue\n lines.push(`${section}:`)\n for (const name of Object.keys(entries).sort()) {\n const e = entries[name]\n let line = `- ${name}`\n const d = text(e, 'description')\n if (d) line += `: ${d}`\n const risk = text(e, 'x-buckyos:risk')\n if (risk) line += ` (risk: ${risk})`\n lines.push(line)\n }\n }\n const names = Object.keys(summary)\n if (names.length) {\n lines.push('Summary:')\n for (const name of names) lines.push(`- ${name}:`, JSON.stringify(summary[name], null, 2))\n }\n return lines.join('\\n')\n}\n\nfunction isCollection(profile: JsonValue): boolean {\n const traits = isObject(profile) ? profile['x-buckyos:traits'] : undefined\n return Array.isArray(traits) && traits.includes(INDEX_TRAIT_URI)\n}\n\n/** Resources for `siteTools({ resources })` from the Profiles of `roots`. */\nexport async function didObjectResources(options: DidObjectResourcesOptions): Promise<Record<string, ResourceDecl>> {\n const maxRank = riskRank(options.maxRisk ?? 'read_only')\n const out: Record<string, ResourceDecl> = {}\n for (const root of options.roots) {\n const client = options.client\n const profile = await client.profile(root) as JsonValue\n const collection = isCollection(profile)\n const actions: Record<string, ActionDecl> = {}\n const declared = isObject(profile) && isObject(profile.actions) ? profile.actions : {}\n for (const [name, a] of Object.entries(declared)) {\n if (collection && (name === 'query' || name === 'page')) continue\n const risk = text(a, 'x-buckyos:risk') as ActionRisk\n if (riskRank(risk) > maxRank) continue\n const input = isObject(a) ? a.input : undefined\n actions[name] = {\n description: text(a, 'description'),\n risk,\n ...(input !== undefined && input !== null ? { input } : {}),\n call: (_m: ResourceMatch, params: Record<string, JsonValue>) => client.invoke(root, name, params),\n }\n }\n const description = [text(profile, 'title'), text(profile, 'description')].filter(Boolean).join(' — ') || root\n out[root] = {\n description: collection ? `${description} (a collection: read it with a query, ?cursor=… for the next page)` : description,\n actions,\n async read(m: ResourceMatch) {\n if (collection && [...m.query.keys()].length > 0) {\n const cursor = m.query.get('cursor')\n const pageSize = m.query.get('page_size')\n if (cursor) return client.invoke(root, 'page', { cursor, ...(pageSize ? { page_size: Number(pageSize) } : {}) })\n const query: Record<string, JsonValue> = {}\n for (const [k, v] of m.query) if (k !== 'page_size') query[k] = v\n return client.invoke(root, 'query', { query, ...(pageSize ? { page_size: Number(pageSize) } : {}) })\n }\n const card = await client.card(root)\n const props = isObject(profile) && isObject(profile.properties) ? Object.keys(profile.properties).filter(p => p !== 'index_schema') : []\n const listed = isObject(profile) && Array.isArray(profile['x-buckyos:summary_props'])\n ? (profile['x-buckyos:summary_props'] as JsonValue[]).filter((p): p is string => typeof p === 'string') : props\n const summary: Record<string, JsonValue> = {}\n for (const p of listed) summary[p] = await client.readProperty(root, p) as JsonValue\n return renderObjectDocument(root, { id: String(card.id), alsoKnownAs: card.alsoKnownAs }, profile, summary)\n },\n }\n }\n return out\n}\n","// A run store in the page's IndexedDB (database `xllm-runs`): run.json and\n// numbered snapshots as Rust lays them out, so a run survives a reload of the\n// page and resumes. The run lock is a Web Lock (`navigator.locks`) held while\n// an executor runs; without Web Locks the page is assumed to be the only tab.\n// Data read back is not trusted: `XllmRun.resume` checks it against the\n// page's runtime before anything runs.\n\nimport type { LLMContextSnapshot, RunRecord } from '../../core/types'\nimport { RUN_RECORD_VERSION, generateRunId } from '../../core/store'\nimport type { ExportedRun, RunLock, RunStore } from '../../core/store'\nimport { XllmError } from '../../core/errors'\n\nexport const XLLM_RUNS_DB = 'xllm-runs'\nconst RECORDS = 'records'\nconst SNAPSHOTS = 'snapshots'\n\nfunction req<T>(r: IDBRequest<T>): Promise<T> {\n return new Promise((resolve, reject) => {\n r.onsuccess = () => resolve(r.result)\n r.onerror = () => reject(r.error)\n })\n}\n\nfunction done(tx: IDBTransaction): Promise<void> {\n return new Promise((resolve, reject) => {\n tx.oncomplete = () => resolve()\n tx.onerror = () => reject(tx.error)\n tx.onabort = () => reject(tx.error ?? new Error('transaction aborted'))\n })\n}\n\ninterface LockLike {\n request(name: string, options: { ifAvailable: boolean }, cb: (lock: unknown) => Promise<void>): Promise<void>\n query(): Promise<{ held?: { name?: string }[] }>\n}\n\nexport class IndexedDbRunStore implements RunStore {\n readonly persistent = true\n private db: Promise<IDBDatabase> | undefined\n private readonly localLocks = new Set<string>()\n\n constructor(private readonly options: { dbName?: string; idb?: IDBFactory; locks?: LockLike | null } = {}) {}\n\n private open(): Promise<IDBDatabase> {\n if (!this.db) {\n const factory = this.options.idb ?? globalThis.indexedDB\n if (!factory) return Promise.reject(XllmError.storage('IndexedDB is not available here'))\n const r = factory.open(this.options.dbName ?? XLLM_RUNS_DB, 1)\n r.onupgradeneeded = () => {\n const db = r.result\n if (!db.objectStoreNames.contains(RECORDS)) db.createObjectStore(RECORDS, { keyPath: 'run_id' })\n if (!db.objectStoreNames.contains(SNAPSHOTS)) db.createObjectStore(SNAPSHOTS)\n }\n this.db = req(r)\n }\n return this.db\n }\n\n private locks(): LockLike | undefined {\n if (this.options.locks === null) return undefined\n return this.options.locks ?? (globalThis.navigator as unknown as { locks?: LockLike } | undefined)?.locks\n }\n\n runsDir(): string | undefined {\n return undefined\n }\n\n runDir(): string | undefined {\n return undefined\n }\n\n async createRun(): Promise<string> {\n const db = await this.open()\n for (let i = 0; i < 8; i++) {\n const id = generateRunId()\n const existing = await req(db.transaction(RECORDS).objectStore(RECORDS).get(id))\n if (!existing) return id\n }\n throw XllmError.storage('cannot allocate a unique run id')\n }\n\n async writeRecord(record: RunRecord): Promise<void> {\n const db = await this.open()\n const tx = db.transaction(RECORDS, 'readwrite')\n tx.objectStore(RECORDS).put(JSON.parse(JSON.stringify(record)))\n await done(tx)\n }\n\n async readRecord(runId: string): Promise<RunRecord> {\n const db = await this.open()\n const rec = await req(db.transaction(RECORDS).objectStore(RECORDS).get(runId)) as RunRecord | undefined\n if (!rec) throw new XllmError({ kind: 'run_not_found', run_id: runId, runs_dir: `indexeddb:${this.options.dbName ?? XLLM_RUNS_DB}` })\n if (rec.version !== RUN_RECORD_VERSION) throw XllmError.notResumable(runId, 'unsupported run record version')\n return rec\n }\n\n async listRecords(): Promise<RunRecord[]> {\n const db = await this.open()\n return await req(db.transaction(RECORDS).objectStore(RECORDS).getAll()) as RunRecord[]\n }\n\n async putSnapshot(runId: string, snapshot: LLMContextSnapshot): Promise<number> {\n const db = await this.open()\n const tx = db.transaction(SNAPSHOTS, 'readwrite')\n const store = tx.objectStore(SNAPSHOTS)\n const keys = await req(store.getAllKeys(IDBKeyRange.bound([runId, 0], [runId, Number.MAX_SAFE_INTEGER]))) as [string, number][]\n const next = keys.length ? Math.max(...keys.map(k => k[1])) + 1 : 1\n store.put(JSON.parse(JSON.stringify(snapshot)), [runId, next])\n await done(tx)\n return next\n }\n\n async getSnapshot(runId: string, idx: number): Promise<LLMContextSnapshot> {\n const db = await this.open()\n const s = await req(db.transaction(SNAPSHOTS).objectStore(SNAPSHOTS).get([runId, idx])) as LLMContextSnapshot | undefined\n if (!s) throw new XllmError({ kind: 'corrupted_run', run_id: runId, reason: `snapshot ${idx} missing` })\n return s\n }\n\n async listSnapshots(runId: string): Promise<number[]> {\n const db = await this.open()\n const keys = await req(db.transaction(SNAPSHOTS).objectStore(SNAPSHOTS)\n .getAllKeys(IDBKeyRange.bound([runId, 0], [runId, Number.MAX_SAFE_INTEGER]))) as [string, number][]\n return keys.map(k => k[1]).sort((a, b) => a - b)\n }\n\n async lockRun(runId: string): Promise<RunLock | null> {\n const name = `xllm-run:${runId}`\n const locks = this.locks()\n if (!locks) {\n if (this.localLocks.has(name)) return null\n this.localLocks.add(name)\n return { release: () => { this.localLocks.delete(name) } }\n }\n return new Promise<RunLock | null>((resolve, reject) => {\n locks.request(name, { ifAvailable: true }, lock => {\n if (!lock) {\n resolve(null)\n return Promise.resolve()\n }\n return new Promise<void>(release => resolve({ release: () => release() }))\n }).catch(reject)\n })\n }\n\n async isRunLive(runId: string): Promise<boolean> {\n const name = `xllm-run:${runId}`\n const locks = this.locks()\n if (!locks) return this.localLocks.has(name)\n const state = await locks.query()\n return (state.held ?? []).some(l => l.name === name)\n }\n\n async removeRun(runId: string): Promise<void> {\n const db = await this.open()\n const tx = db.transaction([RECORDS, SNAPSHOTS], 'readwrite')\n tx.objectStore(RECORDS).delete(runId)\n tx.objectStore(SNAPSHOTS).delete(IDBKeyRange.bound([runId, 0], [runId, Number.MAX_SAFE_INTEGER]))\n await done(tx)\n }\n\n async importRun(run: ExportedRun): Promise<void> {\n const db = await this.open()\n const tx = db.transaction([RECORDS, SNAPSHOTS], 'readwrite')\n tx.objectStore(RECORDS).put(JSON.parse(JSON.stringify(run.record)))\n for (const [idx, s] of run.snapshots) tx.objectStore(SNAPSHOTS).put(JSON.parse(JSON.stringify(s)), [run.record.run_id, idx])\n await done(tx)\n }\n}\n"],"names":["SITE_RUNTIME_KIND","TOOL_NAME","namedSources","cfg","field","map","s","kind","XllmError","capability","describeToolSource","name","CommandArgsError","Error","constructor","code","message","super","this","hasOwn","o","key","Object","prototype","hasOwnProperty","call","optionProperty","option","property","split","join","splitLongOption","token","content","slice","equalIndex","indexOf","inlineValue","readOptionValue","argv","index","value","consumed","startsWith","parseOptionValue","type","number","Number","isFinite","isInteger","assignPositional","input","positionals","positional","parseShellLine","line","tokens","current","quote","escaped","started","character","test","push","validateSchema","schema","path","enum","some","candidate","is","minLength","length","Array","isArray","items","forEach","item","object","required","additionalProperties","keys","properties","propertyValue","entries","propertySchema","_a","ACTION_RISKS","XCALL_USAGE","MAX_RESULT_BYTES","SHELL_CHARS","fail","normalizeUri","uri","origins","raw","trim","absolute","url","origin","URL","replace","protocol","toLowerCase","host","has","segments","part","pathname","decoded","decodeURIComponent","includes","text","search","query","searchParams","matchPattern","p","params","i","endsWith","asText","JSON","stringify","String","versioned","isObject","every","k","version","clipBytes","max","utf8Length","clipped","out","bytes","ch","n","pageText","offset","limit","lines","start","Math","floor","wanted","body","parseScalar","v","parse","UNSUPPORTED_XCALL_KEYS","parseXcall","action","pairs","json","e","unsupported","t","eq","commandUsage","c","summary","description","pos","options","examples","OBJECT_ARGS","props","INDEX_TRAIT_URI","riskRank","r","renderObjectDocument","canonical","card","profile","id","aliases","alsoKnownAs","filter","a","label","section","sort","d","risk","names","isCollection","traits","XLLM_RUNS_DB","RECORDS","SNAPSHOTS","req","Promise","resolve","reject","onsuccess","result","onerror","error","done","tx","oncomplete","onabort","persistent","localLocks","Set","open","db","factory","idb","globalThis","indexedDB","storage","dbName","onupgradeneeded","objectStoreNames","contains","createObjectStore","keyPath","locks","navigator","runsDir","runDir","createRun","generateRunId","transaction","objectStore","get","writeRecord","record","put","readRecord","runId","rec","run_id","runs_dir","RUN_RECORD_VERSION","notResumable","listRecords","getAll","putSnapshot","snapshot","store","getAllKeys","IDBKeyRange","bound","MAX_SAFE_INTEGER","next","getSnapshot","idx","reason","listSnapshots","b","lockRun","request","ifAvailable","lock","release","catch","add","delete","isRunLive","held","l","removeRun","importRun","run","snapshots","scene","tools","Map","tool","spec","set","env","descriptor","runtime_id","target","workdir","capabilities","network","os","config","task_wait_ms","info","timezone","Intl","DateTimeFormat","resolvedOptions","timeZone","arch","hostname","shell","cwd","current_time","Date","toISOString","platform","shell_kind","baseline","ctx","enabled","tools2actions","loop_model","actions","pick","source","args_schema","resolveTool","native","toolSources","actionSources","selected","filesystem_policy","tool_sources","action_sources","bash_tools","shellSettings","taskWaitMs","exec_enabled","sources","manager","SiteToolManager","tasks","describeInterrupted","args","call_id","signal","AbortController","unresolvedReason","async","maxRank","maxRisk","root","roots","client","collection","declared","_m","invoke","Boolean","read","m","cursor","pageSize","page_size","listed","readProperty","patterns","resources","decl","rest","slash","parsePattern","commands","pattern","exec","command","words","available","size","unquoted","known","invalid","validateJson","_decl","match","parsed","beforeOption","optionByName","positionalIndex","help","handled","positionalCount","parseArgv","prop","inputSchema","idempotent","methods","edit","write","discovery","_d","readRaw","mode","old_string","new_string","count","w","ifVersion","find","q","_b","_c","access","level","execIsIdempotent"],"mappings":"uTAiBO,MAAMA,EAAoB,OAE3BC,EAAY,wBA0BlB,SAASC,EAAaC,EAA+BC,GACnD,OAAQD,GAAO,IAAIE,KAASC,IACtB,GAAW,UAAXA,EAAEC,KACEC,MAAAA,EAAAA,UAAUC,WAAW,GAAGL,QAAYM,EAAAA,mBAAmBJ,+EAE/D,OAAOA,EAAEK,IAAA,GAEb,CCbO,MAAMC,UAAyBC,MAGpC,WAAAC,CAAYC,EAAcC,GACxBC,MAA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AAhN,KACjC,MAAS,cAATA,GAAiC,qBAATA,CAAS,CAClC,MACC,OAAA,CACT,CAEF,MAAMxB,EAAIrJ,EAAOuV,EAAS/H,IAAIxN,QAAQ,EAC/B,MAAqB,UAArB,OAAA8X,EAAA,MAAAzO,OAAA,EAAAA,EAAG0O,aAAH,EAAAD,EAAWE,MACpB,CA5BuDC,CAAiBhR,OAAOyM,EAAKgC,SAAW,IAAKT,EAAU9P,EAASoQ,GACjHzU,KAAM,CAAC4S,EAAMzB,IAAQwD,EAAKxO,OAAOyM,EAAKgC,SAAUzD,IAGtD"}
1
+ {"version":3,"file":"xllm.cjs","sources":["../src/xllm/runtime/site.ts","../src/internal/command_args.ts","../src/xllm/runtime/site_tools.ts","../src/xllm/runtime/did_object_resources.ts","../src/xllm/hosts/browser/store.ts"],"sourcesContent":["// `createSiteRuntime`: a page turns the tools of one scene into an\n// AgentRuntime. The SDK ships no tools here; what the scene can do is the\n// page's own JS functions, so xllm never exceeds what the page's JS can do.\n//\n// descriptor: { kind: \"site\", runtime_id: \"site:<scene>\", host: null,\n// target: { origin, scene }, workdir: \"/\", capabilities: { tools: {}, network: true, os: \"browser\" } }\n// Neither the user agent nor the tool list is part of it: a browser update or\n// a new page tool must not make old runs unresumable, while a run of scene A\n// cannot be resumed in scene B (the descriptors differ).\n\nimport type { AiToolCall, EffectiveTools, ResolvedTool, RuntimeConfig, RuntimeDescriptor, RuntimeInfo, ToolSource, ToolsConfig } from '../core/types'\nimport { XllmError } from '../core/errors'\nimport { describeToolSource, shellSettings, taskWaitMs } from '../core/config'\nimport type { AgentRuntime, OpenedTools, RunBinding, RuntimeOpenCtx, SiteTool } from './types'\nimport { unresolvedReason } from './types'\nimport { SiteToolManager } from './site_manager'\n\nexport const SITE_RUNTIME_KIND = 'site'\n\nconst TOOL_NAME = /^[A-Za-z0-9_-]{1,64}$/\n\nexport interface SiteRuntimeOptions {\n /** The scene name, e.g. `aiws.wish`: part of the runtime's identity. */\n scene: string\n /** The page's origin (passed in: the runtime never reads `location`). */\n origin: string\n hostname: string\n /** Every tool of this scene. */\n tools: Record<string, SiteTool>\n /** What `{{env.NAME}}` may read. */\n env?: Record<string, string>\n /** `runtime.task_wait_ms` (in-call wait budget for tasks, M2). */\n task_wait_ms?: number\n}\n\nexport interface SiteRuntime extends AgentRuntime {\n readonly scene: string\n /** The scene's tools, by name. */\n readonly tools: ReadonlyMap<string, SiteTool>\n}\n\nfunction resolveTool(name: string, tool: SiteTool, source: string): ResolvedTool {\n return { name, description: tool.spec.description, args_schema: tool.spec.args_schema, source }\n}\n\nfunction namedSources(cfg: ToolSource[] | undefined, field: string): string[] {\n return (cfg ?? []).map(s => {\n if (s.kind !== 'named') {\n throw XllmError.capability(`${field}: \\`${describeToolSource(s)}\\` is not available in a site runtime; only the page's tools can be named`)\n }\n return s.name\n })\n}\n\nexport function createSiteRuntime(options: SiteRuntimeOptions): SiteRuntime {\n const scene = options.scene?.trim()\n if (!scene) throw XllmError.input('createSiteRuntime: `scene` is required')\n if (!options.origin) throw XllmError.input('createSiteRuntime: `origin` is required')\n const tools = new Map<string, SiteTool>()\n for (const [name, tool] of Object.entries(options.tools ?? {})) {\n if (!TOOL_NAME.test(name)) throw XllmError.tools(`site tool name \\`${name}\\` must match ${TOOL_NAME}`)\n if (!tool || typeof tool.call !== 'function' || !tool.spec) throw XllmError.tools(`site tool \\`${name}\\` needs \\`spec\\` and \\`call\\``)\n tools.set(name, tool)\n }\n const env = { ...(options.env ?? {}) }\n const descriptor: RuntimeDescriptor = {\n runtime_id: `site:${scene}`,\n kind: SITE_RUNTIME_KIND,\n host: null,\n target: { origin: options.origin, scene },\n workdir: '/',\n capabilities: { tools: {}, network: true, os: 'browser' },\n }\n const config: RuntimeConfig = { kind: SITE_RUNTIME_KIND, env: {} }\n if (options.task_wait_ms !== undefined) config.task_wait_ms = options.task_wait_ms\n\n const runtime: SiteRuntime = {\n scene,\n tools,\n descriptor: () => JSON.parse(JSON.stringify(descriptor)),\n config: () => JSON.parse(JSON.stringify(config)),\n async info(): Promise<RuntimeInfo> {\n let timezone = ''\n try {\n timezone = Intl.DateTimeFormat().resolvedOptions().timeZone ?? ''\n } catch {\n timezone = ''\n }\n return {\n id: descriptor.runtime_id, kind: SITE_RUNTIME_KIND, os: 'browser', arch: '', hostname: options.hostname, shell: '',\n cwd: '/', tools: [], current_time: new Date().toISOString(), timezone, target: descriptor.target,\n platform: 'browser', shell_kind: '', baseline: '',\n }\n },\n async open(ctx: RuntimeOpenCtx, cfg: ToolsConfig): Promise<OpenedTools> {\n const enabled = cfg.enabled ?? false\n const tools2actions = cfg.tools2actions ?? false\n if (ctx.loop_model === 'function_call' && (tools2actions || (cfg.actions ?? []).length > 0)) {\n throw XllmError.capability('actions / tools2actions need loop_model behavior')\n }\n const pick = (names: string[], field: string): ResolvedTool[] => names.map(name => {\n const tool = tools.get(name)\n if (!tool) {\n throw XllmError.capability(`${field}: \\`${name}\\` is not a tool of scene \\`${scene}\\` (scene tools: ${[...tools.keys()].join(', ') || 'none'})`)\n }\n return resolveTool(name, tool, `name:${name}`)\n })\n let native: ResolvedTool[] = []\n let actions: ResolvedTool[] = []\n const toolSources = cfg.tools ?? []\n const actionSources = cfg.actions ?? []\n if (enabled) {\n const toolNames = cfg.tools === undefined ? [...tools.keys()] : namedSources(cfg.tools, 'tools.tools')\n native = pick(toolNames, 'tools.tools')\n actions = pick(namedSources(cfg.actions, 'tools.actions'), 'tools.actions')\n if (tools2actions) {\n actions = [...actions, ...native.filter(t => !actions.some(a => a.name === t.name))]\n native = []\n }\n }\n const selected = new Map<string, SiteTool>()\n for (const t of [...native, ...actions]) selected.set(t.name, tools.get(t.name) as SiteTool)\n const effective: EffectiveTools = {\n enabled,\n filesystem_policy: cfg.filesystem_policy ?? 'workspace',\n tools2actions,\n tool_sources: cfg.tools === undefined && enabled ? native.map(t => ({ kind: 'named', name: t.name })) : toolSources,\n action_sources: actionSources,\n native,\n actions,\n bash_tools: [],\n shell: shellSettings(cfg.shell, taskWaitMs(config)),\n exec_enabled: false,\n sources: { ...ctx.sources },\n }\n return { tools: effective, manager: new SiteToolManager(selected, { tasks: ctx.tasks, taskWaitMs: ctx.task_wait_ms }) }\n },\n async describeInterrupted(run: RunBinding, call: AiToolCall): Promise<string> {\n const tool = tools.get(call.name)\n if (tool?.describeInterrupted) {\n try {\n return await tool.describeInterrupted(call.args ?? {}, { run_id: run.run_id, call_id: call.call_id, signal: new AbortController().signal })\n } catch (e) {\n return `${unresolvedReason(call.name)} (describing it failed: ${e instanceof Error ? e.message : String(e)})`\n }\n }\n return unresolvedReason(call.name)\n },\n env: (name: string) => env[name],\n }\n return runtime\n}\n","// Command-line parsing shared by the `buckyos` CLI (`cli/core/argv.ts`,\n// `cli/core/command.ts`) and the xllm site tools' `exec`. Self-contained on\n// purpose: the CLI imports it by relative path. Errors carry the CLI's usage\n// codes; the CLI turns them into its `UsageError`.\n\nexport type JsonSchema = {\n type?: 'object' | 'array' | 'string' | 'boolean' | 'integer' | 'number' | 'null'\n title?: string\n description?: string\n properties?: Record<string, JsonSchema>\n required?: string[]\n additionalProperties?: boolean\n items?: JsonSchema\n enum?: unknown[]\n minLength?: number\n minimum?: number\n default?: unknown\n secret?: boolean\n}\n\nexport interface PositionalDefinition {\n name: string\n description: string\n required?: boolean\n}\n\nexport interface OptionDefinition {\n name: string\n property?: string\n description: string\n type: 'string' | 'boolean' | 'integer' | 'number'\n required?: boolean\n secret?: boolean\n enum?: string[]\n}\n\nexport type AccessLevel = 'read' | 'write' | 'destructive' | 'privileged'\n\n/** A usage error with the CLI's code (`UNKNOWN_OPTION`, `SCHEMA_VALIDATION_FAILED`, …). */\nexport class CommandArgsError extends Error {\n readonly code: string\n\n constructor(code: string, message: string) {\n super(message)\n this.name = 'CommandArgsError'\n this.code = code\n }\n}\n\nfunction hasOwn(o: object, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(o, key)\n}\n\nexport function optionProperty(option: OptionDefinition): string {\n return option.property ?? option.name.split('-').join('_')\n}\n\nexport interface LongOption {\n name: string\n inlineValue?: string\n}\n\nexport function splitLongOption(token: string): LongOption {\n const content = token.slice(2)\n const equalIndex = content.indexOf('=')\n return equalIndex < 0 ? { name: content } : { name: content.slice(0, equalIndex), inlineValue: content.slice(equalIndex + 1) }\n}\n\nexport function readOptionValue(argv: string[], index: number, option: LongOption): { value: string; consumed: number } {\n if (option.inlineValue !== undefined) {\n if (!option.inlineValue) throw new CommandArgsError('MISSING_ARGUMENT', `--${option.name} requires a value`)\n return { value: option.inlineValue, consumed: 1 }\n }\n const value = argv[index + 1]\n if (value === undefined || value.startsWith('--')) throw new CommandArgsError('MISSING_ARGUMENT', `--${option.name} requires a value`)\n return { value, consumed: 2 }\n}\n\nfunction parseOptionValue(type: string, value: string, name: string): unknown {\n if (type === 'string') return value\n const number = Number(value)\n if (!Number.isFinite(number) || (type === 'integer' && !Number.isInteger(number))) {\n throw new CommandArgsError('INVALID_ARGUMENT', `--${name} requires a ${type}`)\n }\n return number\n}\n\nfunction assignPositional(input: Record<string, unknown>, positionals: PositionalDefinition[], index: number, value: string): number {\n const positional = positionals[index]\n if (!positional) throw new CommandArgsError('TOO_MANY_ARGUMENTS', `unexpected positional argument: ${value}`)\n input[positional.name] = value\n return index + 1\n}\n\nexport interface ArgvSpec {\n positionals?: PositionalDefinition[]\n options?: OptionDefinition[]\n}\n\n/**\n * Looks at every long option before the command's own: the CLI handles its\n * interactive session options here. Return how many tokens it consumed, or\n * `undefined` to leave the option to the command.\n */\nexport type LongOptionHook = (option: LongOption, argv: string[], index: number) => number | undefined\n\n/** Positionals, `--opt value` / `--opt=value`, boolean options, `--`; `--help` / `-h` sets `help`. */\nexport function parseArgv(spec: ArgvSpec, argv: string[], beforeOption?: LongOptionHook): {\n input: Record<string, unknown>\n help: boolean\n positionalCount: number\n} {\n const input: Record<string, unknown> = {}\n const positionals = spec.positionals ?? []\n const optionByName = new Map((spec.options ?? []).map(o => [o.name, o]))\n let positionalIndex = 0\n let help = false\n for (let index = 0; index < argv.length;) {\n const token = argv[index]\n if (token === '--help' || token === '-h') {\n help = true\n index += 1\n continue\n }\n if (token === '--') {\n for (const value of argv.slice(index + 1)) positionalIndex = assignPositional(input, positionals, positionalIndex, value)\n break\n }\n if (!token.startsWith('--')) {\n positionalIndex = assignPositional(input, positionals, positionalIndex, token)\n index += 1\n continue\n }\n const parsed = splitLongOption(token)\n const handled = beforeOption?.(parsed, argv, index)\n if (handled !== undefined) {\n index += handled\n continue\n }\n const option = optionByName.get(parsed.name)\n if (!option) throw new CommandArgsError('UNKNOWN_OPTION', `unknown option: --${parsed.name}`)\n const property = optionProperty(option)\n if (hasOwn(input, property)) throw new CommandArgsError('DUPLICATE_ARGUMENT', `argument provided more than once: ${property}`)\n if (option.type === 'boolean') {\n if (parsed.inlineValue !== undefined) throw new CommandArgsError('INVALID_ARGUMENT', `--${parsed.name} does not accept a value`)\n input[property] = true\n index += 1\n continue\n }\n const { value, consumed } = readOptionValue(argv, index, parsed)\n input[property] = parseOptionValue(option.type, value, parsed.name)\n index += consumed\n }\n return { input, help, positionalCount: positionalIndex }\n}\n\n/** Required positionals after `positionalCount` must be in `inputObject`. */\nexport function checkRequiredPositionals(positionals: PositionalDefinition[], positionalCount: number, inputObject: Record<string, unknown> | undefined) {\n for (let index = positionalCount; index < positionals.length; index++) {\n if (positionals[index].required !== false && !hasOwn(inputObject ?? {}, positionals[index].name)) {\n throw new CommandArgsError('MISSING_ARGUMENT', `missing positional argument: ${positionals[index].name}`)\n }\n }\n}\n\nexport function mergeCommandInput(inputObject: Record<string, unknown> | undefined, cliInput: Record<string, unknown>): Record<string, unknown> {\n const result = { ...(inputObject ?? {}) }\n for (const [key, value] of Object.entries(cliInput)) {\n if (hasOwn(result, key)) throw new CommandArgsError('ARGUMENT_CONFLICT', `${key} is present in both --input and argv`)\n result[key] = value\n }\n return result\n}\n\n/** Split a command line into words: single and double quotes, backslash escapes (not inside single quotes). */\nexport function parseShellLine(line: string): string[] {\n const tokens: string[] = []\n let current = ''\n let quote: 'single' | 'double' | null = null\n let escaped = false\n let started = false\n for (const character of line) {\n if (escaped) {\n current += character\n escaped = false\n started = true\n continue\n }\n if (character === '\\\\' && quote !== 'single') {\n escaped = true\n started = true\n continue\n }\n if (quote === 'single') {\n if (character === \"'\") quote = null\n else current += character\n continue\n }\n if (quote === 'double') {\n if (character === '\"') quote = null\n else current += character\n continue\n }\n if (character === \"'\") {\n quote = 'single'\n started = true\n continue\n }\n if (character === '\"') {\n quote = 'double'\n started = true\n continue\n }\n if (/\\s/.test(character)) {\n if (started) {\n tokens.push(current)\n current = ''\n started = false\n }\n continue\n }\n current += character\n started = true\n }\n if (escaped) throw new CommandArgsError('INVALID_COMMAND_LINE', 'unfinished escape sequence')\n if (quote) throw new CommandArgsError('INVALID_COMMAND_LINE', `unterminated ${quote} quote`)\n if (started) tokens.push(current)\n return tokens\n}\n\nexport function validateSchema(value: unknown, schema: JsonSchema, path: string): void {\n if (schema.enum && !schema.enum.some(candidate => Object.is(candidate, value))) {\n throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be one of ${schema.enum.join(', ')}`)\n }\n if (schema.type === 'object') {\n if (!value || typeof value !== 'object' || Array.isArray(value)) throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be an object`)\n const object = value as Record<string, unknown>\n for (const required of schema.required ?? []) {\n if (!hasOwn(object, required)) throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path}.${required} is required`)\n }\n if (schema.additionalProperties === false) {\n for (const key of Object.keys(object)) {\n if (!hasOwn(schema.properties ?? {}, key)) throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path}.${key} is not allowed`)\n }\n }\n for (const [key, propertyValue] of Object.entries(object)) {\n const propertySchema = schema.properties?.[key]\n if (propertySchema) validateSchema(propertyValue, propertySchema, `${path}.${key}`)\n }\n return\n }\n if (schema.type === 'array') {\n if (!Array.isArray(value)) throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be an array`)\n const items = schema.items\n if (items) value.forEach((item, index) => validateSchema(item, items, `${path}[${index}]`))\n return\n }\n if (schema.type === 'string') {\n if (typeof value !== 'string') throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be a string`)\n if (schema.minLength !== undefined && value.length < schema.minLength) throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} is too short`)\n return\n }\n if (schema.type === 'boolean' && typeof value !== 'boolean') throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be a boolean`)\n if (schema.type === 'integer' && (!Number.isInteger(value) || typeof value !== 'number')) {\n throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be an integer`)\n }\n if (schema.type === 'number' && typeof value !== 'number') throw new CommandArgsError('SCHEMA_VALIDATION_FAILED', `${path} must be a number`)\n}\n","// Optional basic tools for a site (TODO §2.1, a trial): what `bash_core`'s four\n// tools are for files, `read` / `write` / `edit` / `exec` are for a page's\n// resources and commands. REST semantics: read = GET (a collection's read is\n// its list, filter with a query), write = PUT, edit = PATCH; everything REST\n// cannot say is a command run by `exec` — `xcall <object> <action>` for the\n// actions declared on resources (DID Object style, with `risk`), and the\n// page's own commands. The four specs are fixed: more resources and commands\n// cost no tokens per round. Every resource, action and command is declared by\n// the page; nothing is forwarded to `fetch` or turned into a raw RPC.\n\nimport type { JsonValue } from '../core/types'\nimport { isObject } from '../core/json'\nimport { validateJson } from '../core/json_check'\nimport { utf8Length } from '../core/tokenizer'\nimport type { SiteTool, SiteToolCtx } from './types'\nimport {\n CommandArgsError, parseArgv, parseShellLine, validateSchema,\n} from '../../internal/command_args'\nimport type { AccessLevel, JsonSchema, OptionDefinition, PositionalDefinition } from '../../internal/command_args'\n\nexport type ActionRisk = 'read_only' | 'idempotent_write' | 'write' | 'destructive' | 'admin'\nexport const ACTION_RISKS: ActionRisk[] = ['read_only', 'idempotent_write', 'write', 'destructive', 'admin']\n\nexport const XCALL_USAGE = 'xcall <object> <action> [--params <json>] [key=value ...] [--key=value ...]'\n/** Result text cap of `read` (one page) and `exec`. */\nexport const MAX_RESULT_BYTES = 64 * 1024\n\n/** What a resource method gets: the URI as normalized, the `{name}` parameters, the query. */\nexport interface ResourceMatch {\n uri: string\n pattern: string\n params: Record<string, string>\n query: URLSearchParams\n ctx: SiteToolCtx\n}\n\n/** A read may return a version: `write` (and the default `edit`) gets it back as `ifVersion`. */\nexport interface Versioned {\n content: unknown\n version?: string\n}\n\nexport interface WriteBody {\n content: string\n mode: 'write' | 'new' | 'append'\n ifVersion?: string\n}\n\nexport interface ActionDecl {\n description: string\n risk: ActionRisk\n /** JSON Schema of the params. */\n input?: JsonValue\n call(m: ResourceMatch, params: Record<string, JsonValue>): unknown\n}\n\nexport interface ResourceDecl {\n description: string\n read?(m: ResourceMatch): unknown\n write?(m: ResourceMatch, body: WriteBody): unknown\n edit?(m: ResourceMatch, body: { old_string: string; new_string: string }): unknown\n actions?: Record<string, ActionDecl>\n}\n\n/** A page command: a subset of the CLI `CommandDefinition`; `call(input)` replaces its handler. */\nexport interface CommandDecl {\n summary: string\n description?: string\n positionals?: PositionalDefinition[]\n options?: OptionDefinition[]\n inputSchema?: JsonSchema\n access?: { mode: 'fixed'; level: AccessLevel }\n examples?: string[]\n call(input: Record<string, unknown>, ctx: SiteToolCtx): unknown\n}\n\nexport interface SiteToolsOptions {\n resources?: Record<string, ResourceDecl>\n commands?: Record<string, CommandDecl>\n}\n\nconst LOCAL_BASE = 'site://page/'\nconst SHELL_CHARS = /[|;&><`$]/\n\ninterface Pattern {\n raw: string\n origin?: string\n segments: string[]\n decl: ResourceDecl\n}\n\nfunction parsePattern(raw: string, decl: ResourceDecl): Pattern {\n const i = raw.indexOf('://')\n if (i >= 0) {\n const rest = raw.slice(i + 3)\n const slash = rest.indexOf('/')\n const host = slash < 0 ? rest : rest.slice(0, slash)\n const path = slash < 0 ? '' : rest.slice(slash + 1)\n return { raw, origin: `${raw.slice(0, i).toLowerCase()}://${host.toLowerCase()}`, segments: path ? path.split('/') : [], decl }\n }\n const path = raw.replace(/^\\/+/, '').replace(/\\/+$/, '')\n return { raw, segments: path ? path.split('/') : [], decl }\n}\n\nfunction fail(message: string): never {\n throw new Error(message)\n}\n\n/** Normalize a URI the model gave: relative paths and declared absolute origins only, no `..`, no encoded separators. */\nexport function normalizeUri(uri: string, origins: Set<string>): { origin?: string; segments: string[]; query: URLSearchParams; text: string } {\n const raw = uri.trim()\n if (!raw) fail('uri is empty')\n const absolute = /^[A-Za-z][A-Za-z0-9+.-]*:/.test(raw)\n let url: URL\n try {\n url = absolute ? new URL(raw) : new URL(raw.replace(/^\\/+/, ''), LOCAL_BASE)\n } catch {\n fail(`invalid uri \\`${raw}\\``)\n }\n let origin: string | undefined\n if (absolute) {\n origin = `${url.protocol.slice(0, -1).toLowerCase()}://${url.host.toLowerCase()}`\n if (!origins.has(origin)) fail(`uri \\`${raw}\\` is not a resource of this page (absolute URIs are limited to the declared ones)`)\n } else if (url.protocol !== 'site:' || url.host !== 'page') {\n fail(`uri \\`${raw}\\` is not a resource of this page`)\n }\n const segments: string[] = []\n for (const part of url.pathname.split('/')) {\n if (part === '') continue\n let decoded: string\n try {\n decoded = decodeURIComponent(part)\n } catch {\n fail(`invalid uri \\`${raw}\\``)\n }\n if (decoded === '..' || decoded === '.' || decoded.includes('/') || decoded.includes('\\\\')) fail(`uri \\`${raw}\\` is not a resource of this page`)\n segments.push(decoded)\n }\n const text = (origin ? `${origin}/` : '') + segments.join('/') + (url.search || '')\n return { origin, segments, query: url.searchParams, text }\n}\n\nfunction matchPattern(p: Pattern, origin: string | undefined, segments: string[]): Record<string, string> | undefined {\n if (p.origin !== origin || p.segments.length !== segments.length) return undefined\n const params: Record<string, string> = {}\n for (let i = 0; i < segments.length; i++) {\n const s = p.segments[i]\n if (s.startsWith('{') && s.endsWith('}')) params[s.slice(1, -1)] = segments[i]\n else if (s !== segments[i]) return undefined\n }\n return params\n}\n\nfunction asText(value: unknown): string {\n if (value === undefined || value === null) return ''\n if (typeof value === 'string') return value\n try {\n return JSON.stringify(value, null, 2)\n } catch {\n return String(value)\n }\n}\n\nfunction versioned(value: unknown): { text: string; version?: string } {\n if (isObject(value) && 'content' in value && Object.keys(value).every(k => k === 'content' || k === 'version')) {\n const version = value.version\n return { text: asText(value.content), version: typeof version === 'string' ? version : version === undefined ? undefined : String(version) }\n }\n return { text: asText(value) }\n}\n\nfunction clipBytes(text: string, max: number): { text: string; clipped: boolean } {\n if (utf8Length(text) <= max) return { text, clipped: false }\n let out = ''\n let bytes = 0\n for (const ch of text) {\n const n = utf8Length(ch)\n if (bytes + n > max) break\n out += ch\n bytes += n\n }\n return { text: out, clipped: true }\n}\n\n/** One page of a text by lines: `offset` is the 1-based first line. */\nexport function pageText(text: string, offset = 1, limit?: number): string {\n const lines = text.split('\\n')\n const start = Math.max(1, Math.floor(offset))\n if (start > lines.length && !(start === 1 && lines.length === 1)) return `[offset ${start} is past the end: ${lines.length} lines]`\n const wanted = limit === undefined ? lines.length : Math.max(1, Math.floor(limit))\n const out: string[] = []\n let bytes = 0\n let i = start - 1\n for (; i < lines.length && out.length < wanted; i++) {\n const n = utf8Length(lines[i]) + 1\n if (out.length > 0 && bytes + n > MAX_RESULT_BYTES) break\n out.push(lines[i])\n bytes += n\n }\n let body = out.join('\\n')\n if (out.length === 1 && utf8Length(body) > MAX_RESULT_BYTES) body = clipBytes(body, MAX_RESULT_BYTES).text + ' …'\n if (i < lines.length) body += `\\n[lines ${start}–${i} of ${lines.length}; read on with offset=${i + 1}]`\n return body\n}\n\nfunction parseScalar(raw: string): JsonValue {\n const v = raw.trim()\n if (v === 'true') return true\n if (v === 'false') return false\n if (v === 'null') return null\n if (/^-?\\d+(\\.\\d+)?([eE][+-]?\\d+)?$/.test(v)) return Number(v)\n if (v.startsWith('{') || v.startsWith('[')) {\n try {\n return JSON.parse(v)\n } catch {\n return v\n }\n }\n return v\n}\n\nconst UNSUPPORTED_XCALL_KEYS = ['config', 'route-config', 'session-id', 'session_id', 'idempotency-key', 'idempotency_key',\n 'confirm-token', 'confirm_token', 'trace-id', 'trace_id']\n\n/** `xcall` arguments as Rust parses them (`parse_object_x_call_cli_command`), minus routing and confirmation flags. */\nfunction parseXcall(tokens: string[]): { object: string; action: string; params: Record<string, JsonValue> } {\n let object: string | undefined\n let action: string | undefined\n let params: JsonValue = {}\n const pairs: Record<string, JsonValue> = {}\n const positionals: string[] = []\n const json = (raw: string, name: string): JsonValue => {\n try {\n return JSON.parse(raw)\n } catch (e) {\n fail(`invalid \\`${name}\\` JSON value \\`${raw}\\`: ${e instanceof Error ? e.message : String(e)}\\nusage: ${XCALL_USAGE}`)\n }\n }\n const unsupported = (t: string): never => fail(`unsupported flag \\`${t}\\` (routing and confirmation are the page's)\\nusage: ${XCALL_USAGE}`)\n for (let i = 0; i < tokens.length; i++) {\n const t = tokens[i]\n if (t === '--params') {\n const v = tokens[++i]\n if (v === undefined) fail(`missing value for --params\\nusage: ${XCALL_USAGE}`)\n params = json(v, '--params')\n } else if (t.startsWith('--')) {\n const eq = t.indexOf('=')\n if (eq < 0) unsupported(t)\n const key = t.slice(2, eq)\n const value = t.slice(eq + 1)\n if (key === 'params') params = json(value, '--params')\n else if (!key.trim() || key.startsWith('-') || UNSUPPORTED_XCALL_KEYS.includes(key)) unsupported(t)\n else pairs[key] = parseScalar(value)\n } else if (t.includes('=')) {\n const eq = t.indexOf('=')\n const key = t.slice(0, eq)\n const value = t.slice(eq + 1)\n if (key === 'object') object = value\n else if (key === 'action') action = value\n else if (key === 'params') params = json(value, 'params')\n else if (UNSUPPORTED_XCALL_KEYS.includes(key)) unsupported(t)\n else pairs[key] = parseScalar(value)\n } else {\n positionals.push(t)\n }\n }\n object = object ?? positionals[0]\n action = action ?? positionals[1]\n if (positionals[2] !== undefined) params = json(positionals[2], 'params')\n if (positionals.length > 3) fail(`unexpected positional argument \\`${positionals[3]}\\`\\nusage: ${XCALL_USAGE}`)\n if (Object.keys(pairs).length) {\n if (!isObject(params)) fail(`key=value params require object params\\nusage: ${XCALL_USAGE}`)\n params = { ...params, ...pairs }\n }\n if (!object || !action) fail(`xcall needs an object and an action\\nusage: ${XCALL_USAGE}`)\n if (!isObject(params)) fail(`params must be a JSON object\\nusage: ${XCALL_USAGE}`)\n return { object, action, params }\n}\n\nfunction commandUsage(name: string, c: CommandDecl): string {\n const lines = [`${name} — ${c.summary}`]\n if (c.description) lines.push('', c.description)\n const pos = (c.positionals ?? []).map(p => (p.required === false ? `[${p.name}]` : `<${p.name}>`)).join(' ')\n lines.push('', `usage: ${name}${pos ? ` ${pos}` : ''}${(c.options ?? []).length ? ' [options]' : ''}`)\n for (const p of c.positionals ?? []) lines.push(` ${p.name} ${p.description}`)\n if ((c.options ?? []).length) lines.push('options:')\n for (const o of c.options ?? []) {\n lines.push(` --${o.name}${o.type === 'boolean' ? '' : ` <${o.type}>`}${o.required ? ' (required)' : ''} ${o.description}${o.enum ? ` (${o.enum.join(' | ')})` : ''}`)\n }\n if (c.examples?.length) {\n lines.push('examples:')\n for (const e of c.examples) lines.push(` ${e}`)\n }\n return lines.join('\\n')\n}\n\nconst OBJECT_ARGS = (props: Record<string, JsonValue>, required: string[]): JsonValue => ({ type: 'object', properties: props, required })\n\n/**\n * The four basic tools over the page's resources and commands. Spread them\n * into `createSiteRuntime({ tools })`, alongside named tools if wanted.\n */\nexport function siteTools(options: SiteToolsOptions): Record<string, SiteTool> {\n const patterns = Object.entries(options.resources ?? {}).map(([raw, decl]) => parsePattern(raw, decl))\n const origins = new Set(patterns.map(p => p.origin).filter((o): o is string => o !== undefined))\n const commands = new Map(Object.entries(options.commands ?? {}))\n if (commands.has('xcall')) throw new Error('siteTools: `xcall` is built in; declare actions on resources instead')\n\n const resolve = (uri: string, ctx: SiteToolCtx): ResourceMatch & { decl: ResourceDecl } => {\n const n = normalizeUri(uri, origins)\n for (const p of patterns) {\n const params = matchPattern(p, n.origin, n.segments)\n if (params) return { uri: n.text, pattern: p.raw, params, query: n.query, ctx, decl: p.decl }\n }\n fail(`uri \\`${uri}\\` is not a resource of this page; read uri=\"/\" lists them`)\n }\n\n const discovery = (): string => {\n const lines = ['Resources (read uri=\"<resource>\"; {name} is one path segment):']\n for (const p of patterns) {\n const methods = (['read', 'write', 'edit'] as const).filter(m => m === 'edit' ? !!(p.decl.edit || (p.decl.read && p.decl.write)) : !!p.decl[m])\n lines.push(`- ${p.raw} — ${p.decl.description} [${methods.join(', ') || 'no methods'}]`)\n for (const [name, a] of Object.entries(p.decl.actions ?? {})) lines.push(` action ${name} (risk: ${a.risk}) — ${a.description}`)\n }\n if (patterns.length === 0) lines.push('(none)')\n lines.push('', 'Commands (exec \"<command> --help\" for usage):')\n lines.push(`- xcall — call an action of a resource: ${XCALL_USAGE}`)\n for (const [name, c] of commands) lines.push(`- ${name} — ${c.summary}`)\n return lines.join('\\n')\n }\n\n const exec = async (command: string, ctx: SiteToolCtx): Promise<string> => {\n const words = (() => {\n try {\n return parseShellLine(command)\n } catch (e) {\n fail(`${e instanceof Error ? e.message : String(e)}; exec runs one command, it is not a shell`)\n }\n })()\n const available = `available commands: xcall${commands.size ? `, ${[...commands.keys()].join(', ')}` : ''}`\n const unquoted = command.replace(/'[^']*'|\"(?:[^\"\\\\]|\\\\.)*\"/g, '')\n if (SHELL_CHARS.test(unquoted)) {\n fail(`exec runs exactly one command and is not a shell: pipes, redirects, \\`;\\`, \\`&\\`, backquotes and \\`$\\` are not supported (quote them to pass them as text). ${available}`)\n }\n const [name, ...args] = words\n if (!name) fail(`empty command; ${available}`)\n if (name === 'xcall') {\n if (args.includes('--help') || args.includes('-h')) return `usage: ${XCALL_USAGE}\\nThe actions of each resource are listed by read uri=\"/\".`\n const { object, action, params } = parseXcall(args)\n const m = resolve(object, ctx)\n const decl = m.decl.actions?.[action]\n if (!decl) {\n const known = Object.keys(m.decl.actions ?? {})\n fail(`resource \\`${m.pattern}\\` has no action \\`${action}\\` (actions: ${known.length ? known.join(', ') : 'none'})`)\n }\n if (decl.input !== undefined) {\n const invalid = validateJson(decl.input, params)\n if (invalid) fail(`invalid params for ${action}: ${invalid}`)\n }\n const { decl: _decl, ...match } = m\n void _decl\n const result = await decl.call(match, params)\n return `[risk: ${decl.risk}]\\n${clipBytes(asText(result) || 'ok', MAX_RESULT_BYTES).text}`\n }\n const c = commands.get(name)\n if (!c) fail(`unknown command \\`${name}\\`; exec runs one command, it is not a shell. ${available}`)\n let input: Record<string, unknown>\n try {\n const parsed = parseArgv({ positionals: c.positionals, options: c.options }, args)\n if (parsed.help) return commandUsage(name, c)\n for (let i = parsed.positionalCount; i < (c.positionals ?? []).length; i++) {\n if ((c.positionals ?? [])[i].required !== false) throw new CommandArgsError('MISSING_ARGUMENT', `missing positional argument: ${(c.positionals ?? [])[i].name}`)\n }\n for (const o of c.options ?? []) {\n const prop = o.property ?? o.name.split('-').join('_')\n if (o.required && !(prop in parsed.input)) throw new CommandArgsError('MISSING_ARGUMENT', `--${o.name} is required`)\n }\n input = parsed.input\n if (c.inputSchema) validateSchema(input, c.inputSchema, 'input')\n } catch (e) {\n if (e instanceof CommandArgsError) fail(`${name}: ${e.message}\\n\\n${commandUsage(name, c)}`)\n throw e\n }\n return clipBytes(asText(await c.call(input, ctx)) || 'ok', MAX_RESULT_BYTES).text\n }\n\n const readRaw = async (m: ResourceMatch & { decl: ResourceDecl }) => {\n if (!m.decl.read) fail(`resource \\`${m.pattern}\\` cannot be read`)\n const { decl: _d, ...match } = m\n void _d\n return versioned(await m.decl.read(match))\n }\n\n return {\n read: {\n spec: {\n description: 'Read a resource of this page by URI (GET). Start with uri \"/\": it lists the resources, their actions (with risk) and the commands. A collection\\'s read is its list; filter and page with a query (notes?tag=x). Text comes in pages of lines: offset is the first line (1-based), limit the number of lines.',\n args_schema: OBJECT_ARGS({\n uri: { type: 'string', description: 'Resource URI, e.g. \"/\" or \"notes/1\"' },\n offset: { type: 'integer', description: 'First line, 1-based' },\n limit: { type: 'integer', description: 'Number of lines' },\n }, ['uri']),\n },\n idempotent: true,\n async call(args, ctx) {\n const uri = String(args.uri)\n const offset = typeof args.offset === 'number' ? args.offset : undefined\n const limit = typeof args.limit === 'number' ? args.limit : undefined\n if (uri.trim() === '/' || uri.trim() === '') return pageText(discovery(), offset, limit)\n const r = await readRaw(resolve(uri, ctx))\n return pageText(r.text, offset, limit)\n },\n },\n write: {\n spec: {\n description: 'Write a resource\\'s content (PUT). mode: \"write\" (default) replaces it, \"new\" only creates it and fails if it exists, \"append\" adds to its end. Use edit to change part of it.',\n args_schema: OBJECT_ARGS({\n uri: { type: 'string', description: 'Resource URI' },\n content: { type: 'string', description: 'The content' },\n mode: { type: 'string', enum: ['write', 'new', 'append'], description: 'write | new | append' },\n }, ['uri', 'content']),\n },\n async call(args, ctx) {\n const m = resolve(String(args.uri), ctx)\n if (!m.decl.write) fail(`resource \\`${m.pattern}\\` is read-only`)\n const { decl, ...match } = m\n const mode = (typeof args.mode === 'string' ? args.mode : 'write') as WriteBody['mode']\n return asText(await decl.write!(match, { content: String(args.content), mode })) || 'written'\n },\n },\n edit: {\n spec: {\n description: 'Change part of a resource (PATCH): old_string must occur exactly once in its current content and is replaced by new_string.',\n args_schema: OBJECT_ARGS({\n uri: { type: 'string', description: 'Resource URI' },\n old_string: { type: 'string', description: 'Text to replace; must occur exactly once' },\n new_string: { type: 'string', description: 'Replacement text' },\n }, ['uri', 'old_string', 'new_string']),\n },\n async call(args, ctx) {\n const m = resolve(String(args.uri), ctx)\n const body = { old_string: String(args.old_string), new_string: String(args.new_string) }\n const { decl, ...match } = m\n if (decl.edit) return asText(await decl.edit(match, body)) || 'edited'\n if (!decl.read || !decl.write) fail(`resource \\`${m.pattern}\\` cannot be edited`)\n if (!body.old_string) fail('old_string is empty')\n const current = versioned(await decl.read(match))\n const count = current.text.split(body.old_string).length - 1\n if (count === 0) fail('old_string was not found in the current content; read it again')\n if (count > 1) fail(`old_string occurs ${count} times; give more context so it occurs exactly once`)\n const content = current.text.replace(body.old_string, () => body.new_string)\n const w: WriteBody = { content, mode: 'write' }\n if (current.version !== undefined) w.ifVersion = current.version\n return asText(await decl.write(match, w)) || 'edited'\n },\n },\n exec: {\n spec: {\n description: `Run one command (not a shell: no pipes, redirects, ;, &, backquotes or $). Built in: ${XCALL_USAGE} — calls an action listed by read uri=\"/\". The page's commands are listed there too; \"<command> --help\" shows a command's usage.`,\n args_schema: OBJECT_ARGS({ command: { type: 'string', description: 'One command line' } }, ['command']),\n },\n idempotent: (args: Record<string, JsonValue>) => execIsIdempotent(String(args.command ?? ''), patterns, origins, commands),\n call: (args, ctx) => exec(String(args.command), ctx),\n },\n }\n}\n\n/** Resume rule of `exec`: `xcall` re-runs `read_only` / `idempotent_write` actions, commands re-run at `access: read`. */\nfunction execIsIdempotent(command: string, patterns: Pattern[], origins: Set<string>, commands: Map<string, CommandDecl>): boolean {\n let words: string[]\n try {\n words = parseShellLine(command)\n } catch {\n return false\n }\n const [name, ...args] = words\n if (name === 'xcall') {\n try {\n const { object, action } = parseXcall(args)\n const n = normalizeUri(object, origins)\n const p = patterns.find(q => matchPattern(q, n.origin, n.segments))\n const risk = p?.decl.actions?.[action]?.risk\n return risk === 'read_only' || risk === 'idempotent_write'\n } catch {\n return false\n }\n }\n const c = name ? commands.get(name) : undefined\n return c?.access?.level === 'read'\n}\n\n","// `siteTools` resources from DID Objects a BuckyOS service already serves\n// (`KrpcObjectProvider`): for each root the page lists, its Profile decides\n// what the model can do — properties are read, an IndexTrait collection is\n// read with a query, actions become `xcall` actions with the Profile's\n// `x-buckyos:risk` (above `maxRisk` they are not exposed). What can be reached\n// is decided by the Profile and the roots, never by a URI the model gives.\n\nimport type { JsonValue } from '../core/types'\nimport { isObject } from '../core/json'\nimport type { DIDObjectClient } from '../../did_object_client'\nimport { ACTION_RISKS } from './site_tools'\nimport type { ActionDecl, ActionRisk, ResourceDecl, ResourceMatch } from './site_tools'\n\nexport const INDEX_TRAIT_URI = 'https://buckyos.org/traits/index@1'\n\n/** What `didObjectResources` needs of a DID Object client. */\nexport type DidObjectReader = Pick<DIDObjectClient, 'card' | 'profile' | 'readProperty' | 'invoke'>\n\nexport interface DidObjectResourcesOptions {\n client: DidObjectReader\n /** Object URLs (`obj://…`) the page lets the model reach. */\n roots: string[]\n /** Actions above this risk are not exposed (default `read_only`). */\n maxRisk?: ActionRisk\n}\n\nfunction text(v: JsonValue | undefined, key: string): string {\n return isObject(v) && typeof v[key] === 'string' ? (v[key] as string) : ''\n}\n\nfunction riskRank(r: string): number {\n const i = ACTION_RISKS.indexOf(r as ActionRisk)\n return i < 0 ? ACTION_RISKS.length : i\n}\n\n/** The object document a read shows (as `render_object_document` in agent-did-object-lib). */\nexport function renderObjectDocument(canonical: string, card: { id: string; alsoKnownAs?: string[] }, profile: JsonValue,\n summary: Record<string, JsonValue>): string {\n const lines = [`Object: ${canonical}`, `Object DID: ${card.id}`]\n const aliases = (card.alsoKnownAs ?? []).filter(a => a !== canonical)\n if (aliases.length) lines.push(`Also known as: ${aliases.join(', ')}`)\n for (const [label, key] of [['Title', 'title'], ['Description', 'description']]) {\n const v = text(profile, key)\n if (v) lines.push(`${label}: ${v}`)\n }\n for (const [section, key] of [['Properties', 'properties'], ['Actions', 'actions'], ['Events', 'events']]) {\n const entries = isObject(profile) ? profile[key] : undefined\n if (!isObject(entries) || Object.keys(entries).length === 0) continue\n lines.push(`${section}:`)\n for (const name of Object.keys(entries).sort()) {\n const e = entries[name]\n let line = `- ${name}`\n const d = text(e, 'description')\n if (d) line += `: ${d}`\n const risk = text(e, 'x-buckyos:risk')\n if (risk) line += ` (risk: ${risk})`\n lines.push(line)\n }\n }\n const names = Object.keys(summary)\n if (names.length) {\n lines.push('Summary:')\n for (const name of names) lines.push(`- ${name}:`, JSON.stringify(summary[name], null, 2))\n }\n return lines.join('\\n')\n}\n\nfunction isCollection(profile: JsonValue): boolean {\n const traits = isObject(profile) ? profile['x-buckyos:traits'] : undefined\n return Array.isArray(traits) && traits.includes(INDEX_TRAIT_URI)\n}\n\n/** Resources for `siteTools({ resources })` from the Profiles of `roots`. */\nexport async function didObjectResources(options: DidObjectResourcesOptions): Promise<Record<string, ResourceDecl>> {\n const maxRank = riskRank(options.maxRisk ?? 'read_only')\n const out: Record<string, ResourceDecl> = {}\n for (const root of options.roots) {\n const client = options.client\n const profile = await client.profile(root) as JsonValue\n const collection = isCollection(profile)\n const actions: Record<string, ActionDecl> = {}\n const declared = isObject(profile) && isObject(profile.actions) ? profile.actions : {}\n for (const [name, a] of Object.entries(declared)) {\n if (collection && (name === 'query' || name === 'page')) continue\n const risk = text(a, 'x-buckyos:risk') as ActionRisk\n if (riskRank(risk) > maxRank) continue\n const input = isObject(a) ? a.input : undefined\n actions[name] = {\n description: text(a, 'description'),\n risk,\n ...(input !== undefined && input !== null ? { input } : {}),\n call: (_m: ResourceMatch, params: Record<string, JsonValue>) => client.invoke(root, name, params),\n }\n }\n const description = [text(profile, 'title'), text(profile, 'description')].filter(Boolean).join(' — ') || root\n out[root] = {\n description: collection ? `${description} (a collection: read it with a query, ?cursor=… for the next page)` : description,\n actions,\n async read(m: ResourceMatch) {\n if (collection && [...m.query.keys()].length > 0) {\n const cursor = m.query.get('cursor')\n const pageSize = m.query.get('page_size')\n if (cursor) return client.invoke(root, 'page', { cursor, ...(pageSize ? { page_size: Number(pageSize) } : {}) })\n const query: Record<string, JsonValue> = {}\n for (const [k, v] of m.query) if (k !== 'page_size') query[k] = v\n return client.invoke(root, 'query', { query, ...(pageSize ? { page_size: Number(pageSize) } : {}) })\n }\n const card = await client.card(root)\n const props = isObject(profile) && isObject(profile.properties) ? Object.keys(profile.properties).filter(p => p !== 'index_schema') : []\n const listed = isObject(profile) && Array.isArray(profile['x-buckyos:summary_props'])\n ? (profile['x-buckyos:summary_props'] as JsonValue[]).filter((p): p is string => typeof p === 'string') : props\n const summary: Record<string, JsonValue> = {}\n for (const p of listed) summary[p] = await client.readProperty(root, p) as JsonValue\n return renderObjectDocument(root, { id: String(card.id), alsoKnownAs: card.alsoKnownAs }, profile, summary)\n },\n }\n }\n return out\n}\n","// A run store in the page's IndexedDB (database `xllm-runs`): run.json and\n// numbered snapshots as Rust lays them out, so a run survives a reload of the\n// page and resumes. The run lock is a Web Lock (`navigator.locks`) held while\n// an executor runs; without Web Locks the page is assumed to be the only tab.\n// Data read back is not trusted: `XllmRun.resume` checks it against the\n// page's runtime before anything runs.\n\nimport type { LLMContextSnapshot, RunRecord } from '../../core/types'\nimport { RUN_RECORD_VERSION, generateRunId } from '../../core/store'\nimport type { ExportedRun, RunLock, RunStore } from '../../core/store'\nimport { XllmError } from '../../core/errors'\n\nexport const XLLM_RUNS_DB = 'xllm-runs'\nconst RECORDS = 'records'\nconst SNAPSHOTS = 'snapshots'\n\nfunction req<T>(r: IDBRequest<T>): Promise<T> {\n return new Promise((resolve, reject) => {\n r.onsuccess = () => resolve(r.result)\n r.onerror = () => reject(r.error)\n })\n}\n\nfunction done(tx: IDBTransaction): Promise<void> {\n return new Promise((resolve, reject) => {\n tx.oncomplete = () => resolve()\n tx.onerror = () => reject(tx.error)\n tx.onabort = () => reject(tx.error ?? new Error('transaction aborted'))\n })\n}\n\ninterface LockLike {\n request(name: string, options: { ifAvailable: boolean }, cb: (lock: unknown) => Promise<void>): Promise<void>\n query(): Promise<{ held?: { name?: string }[] }>\n}\n\nexport class IndexedDbRunStore implements RunStore {\n readonly persistent = true\n private db: Promise<IDBDatabase> | undefined\n private readonly localLocks = new Set<string>()\n\n constructor(private readonly options: { dbName?: string; idb?: IDBFactory; locks?: LockLike | null } = {}) {}\n\n private open(): Promise<IDBDatabase> {\n if (!this.db) {\n const factory = this.options.idb ?? globalThis.indexedDB\n if (!factory) return Promise.reject(XllmError.storage('IndexedDB is not available here'))\n const r = factory.open(this.options.dbName ?? XLLM_RUNS_DB, 1)\n r.onupgradeneeded = () => {\n const db = r.result\n if (!db.objectStoreNames.contains(RECORDS)) db.createObjectStore(RECORDS, { keyPath: 'run_id' })\n if (!db.objectStoreNames.contains(SNAPSHOTS)) db.createObjectStore(SNAPSHOTS)\n }\n this.db = req(r)\n }\n return this.db\n }\n\n private locks(): LockLike | undefined {\n if (this.options.locks === null) return undefined\n return this.options.locks ?? (globalThis.navigator as unknown as { locks?: LockLike } | undefined)?.locks\n }\n\n runsDir(): string | undefined {\n return undefined\n }\n\n runDir(): string | undefined {\n return undefined\n }\n\n async createRun(): Promise<string> {\n const db = await this.open()\n for (let i = 0; i < 8; i++) {\n const id = generateRunId()\n const existing = await req(db.transaction(RECORDS).objectStore(RECORDS).get(id))\n if (!existing) return id\n }\n throw XllmError.storage('cannot allocate a unique run id')\n }\n\n async writeRecord(record: RunRecord): Promise<void> {\n const db = await this.open()\n const tx = db.transaction(RECORDS, 'readwrite')\n tx.objectStore(RECORDS).put(JSON.parse(JSON.stringify(record)))\n await done(tx)\n }\n\n async readRecord(runId: string): Promise<RunRecord> {\n const db = await this.open()\n const rec = await req(db.transaction(RECORDS).objectStore(RECORDS).get(runId)) as RunRecord | undefined\n if (!rec) throw new XllmError({ kind: 'run_not_found', run_id: runId, runs_dir: `indexeddb:${this.options.dbName ?? XLLM_RUNS_DB}` })\n if (rec.version !== RUN_RECORD_VERSION) throw XllmError.notResumable(runId, 'unsupported run record version')\n return rec\n }\n\n async listRecords(): Promise<RunRecord[]> {\n const db = await this.open()\n return await req(db.transaction(RECORDS).objectStore(RECORDS).getAll()) as RunRecord[]\n }\n\n async putSnapshot(runId: string, snapshot: LLMContextSnapshot): Promise<number> {\n const db = await this.open()\n const tx = db.transaction(SNAPSHOTS, 'readwrite')\n const store = tx.objectStore(SNAPSHOTS)\n const keys = await req(store.getAllKeys(IDBKeyRange.bound([runId, 0], [runId, Number.MAX_SAFE_INTEGER]))) as [string, number][]\n const next = keys.length ? Math.max(...keys.map(k => k[1])) + 1 : 1\n store.put(JSON.parse(JSON.stringify(snapshot)), [runId, next])\n await done(tx)\n return next\n }\n\n async getSnapshot(runId: string, idx: number): Promise<LLMContextSnapshot> {\n const db = await this.open()\n const s = await req(db.transaction(SNAPSHOTS).objectStore(SNAPSHOTS).get([runId, idx])) as LLMContextSnapshot | undefined\n if (!s) throw new XllmError({ kind: 'corrupted_run', run_id: runId, reason: `snapshot ${idx} missing` })\n return s\n }\n\n async listSnapshots(runId: string): Promise<number[]> {\n const db = await this.open()\n const keys = await req(db.transaction(SNAPSHOTS).objectStore(SNAPSHOTS)\n .getAllKeys(IDBKeyRange.bound([runId, 0], [runId, Number.MAX_SAFE_INTEGER]))) as [string, number][]\n return keys.map(k => k[1]).sort((a, b) => a - b)\n }\n\n async lockRun(runId: string): Promise<RunLock | null> {\n const name = `xllm-run:${runId}`\n const locks = this.locks()\n if (!locks) {\n if (this.localLocks.has(name)) return null\n this.localLocks.add(name)\n return { release: () => { this.localLocks.delete(name) } }\n }\n return new Promise<RunLock | null>((resolve, reject) => {\n locks.request(name, { ifAvailable: true }, lock => {\n if (!lock) {\n resolve(null)\n return Promise.resolve()\n }\n return new Promise<void>(release => resolve({ release: () => release() }))\n }).catch(reject)\n })\n }\n\n async isRunLive(runId: string): Promise<boolean> {\n const name = `xllm-run:${runId}`\n const locks = this.locks()\n if (!locks) return this.localLocks.has(name)\n const state = await locks.query()\n return (state.held ?? []).some(l => l.name === name)\n }\n\n async removeRun(runId: string): Promise<void> {\n const db = await this.open()\n const tx = db.transaction([RECORDS, SNAPSHOTS], 'readwrite')\n tx.objectStore(RECORDS).delete(runId)\n tx.objectStore(SNAPSHOTS).delete(IDBKeyRange.bound([runId, 0], [runId, Number.MAX_SAFE_INTEGER]))\n await done(tx)\n }\n\n async importRun(run: ExportedRun): Promise<void> {\n const db = await this.open()\n const tx = db.transaction([RECORDS, SNAPSHOTS], 'readwrite')\n tx.objectStore(RECORDS).put(JSON.parse(JSON.stringify(run.record)))\n for (const [idx, s] of run.snapshots) tx.objectStore(SNAPSHOTS).put(JSON.parse(JSON.stringify(s)), [run.record.run_id, idx])\n await done(tx)\n }\n}\n"],"names":["SITE_RUNTIME_KIND","TOOL_NAME","namedSources","cfg","field","map","s","kind","XllmError","capability","describeToolSource","name","CommandArgsError","Error","constructor","code","message","super","this","hasOwn","o","key","Object","prototype","hasOwnProperty","call","optionProperty","option","property","split","join","splitLongOption","token","content","slice","equalIndex","indexOf","inlineValue","readOptionValue","argv","index","value","consumed","startsWith","parseOptionValue","type","number","Number","isFinite","isInteger","assignPositional","input","positionals","positional","parseShellLine","line","tokens","current","quote","escaped","started","character","test","push","validateSchema","schema","path","enum","some","candidate","is","minLength","length","Array","isArray","items","forEach","item","object","required","additionalProperties","keys","properties","propertyValue","entries","propertySchema","_a","ACTION_RISKS","XCALL_USAGE","MAX_RESULT_BYTES","SHELL_CHARS","fail","normalizeUri","uri","origins","raw","trim","absolute","url","origin","URL","replace","protocol","toLowerCase","host","has","segments","part","pathname","decoded","decodeURIComponent","includes","text","search","query","searchParams","matchPattern","p","params","i","endsWith","asText","JSON","stringify","String","versioned","isObject","every","k","version","clipBytes","max","utf8Length","clipped","out","bytes","ch","n","pageText","offset","limit","lines","start","Math","floor","wanted","body","parseScalar","v","parse","UNSUPPORTED_XCALL_KEYS","parseXcall","action","pairs","json","e","unsupported","t","eq","commandUsage","c","summary","description","pos","options","examples","OBJECT_ARGS","props","INDEX_TRAIT_URI","riskRank","r","renderObjectDocument","canonical","card","profile","id","aliases","alsoKnownAs","filter","a","label","section","sort","d","risk","names","isCollection","traits","XLLM_RUNS_DB","RECORDS","SNAPSHOTS","req","Promise","resolve","reject","onsuccess","result","onerror","error","done","tx","oncomplete","onabort","persistent","localLocks","Set","open","db","factory","idb","globalThis","indexedDB","storage","dbName","onupgradeneeded","objectStoreNames","contains","createObjectStore","keyPath","locks","navigator","runsDir","runDir","createRun","generateRunId","transaction","objectStore","get","writeRecord","record","put","readRecord","runId","rec","run_id","runs_dir","RUN_RECORD_VERSION","notResumable","listRecords","getAll","putSnapshot","snapshot","store","getAllKeys","IDBKeyRange","bound","MAX_SAFE_INTEGER","next","getSnapshot","idx","reason","listSnapshots","b","lockRun","request","ifAvailable","lock","release","catch","add","delete","isRunLive","held","l","removeRun","importRun","run","snapshots","scene","tools","Map","tool","spec","set","env","descriptor","runtime_id","target","workdir","capabilities","network","os","config","task_wait_ms","info","timezone","Intl","DateTimeFormat","resolvedOptions","timeZone","arch","hostname","shell","cwd","current_time","Date","toISOString","platform","shell_kind","baseline","ctx","enabled","tools2actions","loop_model","actions","pick","source","args_schema","resolveTool","native","toolSources","actionSources","selected","filesystem_policy","tool_sources","action_sources","bash_tools","shellSettings","taskWaitMs","exec_enabled","sources","manager","SiteToolManager","tasks","describeInterrupted","args","call_id","signal","AbortController","unresolvedReason","async","maxRank","maxRisk","root","roots","client","collection","declared","_m","invoke","Boolean","read","m","cursor","pageSize","page_size","listed","readProperty","patterns","resources","decl","rest","slash","parsePattern","commands","pattern","exec","command","words","available","size","unquoted","known","invalid","validateJson","_decl","match","parsed","beforeOption","optionByName","positionalIndex","help","handled","positionalCount","parseArgv","prop","inputSchema","idempotent","methods","edit","write","discovery","_d","readRaw","mode","old_string","new_string","count","w","ifVersion","find","q","_b","_c","access","level","execIsIdempotent"],"mappings":"uTAiBO,MAAMA,EAAoB,OAE3BC,EAAY,wBA0BlB,SAASC,EAAaC,EAA+BC,GACnD,OAAQD,GAAO,IAAIE,KAASC,IACtB,GAAW,UAAXA,EAAEC,KACEC,MAAAA,EAAAA,UAAUC,WAAW,GAAGL,QAAYM,EAAAA,mBAAmBJ,+EAE/D,OAAOA,EAAEK,IAAA,GAEb,CCbO,MAAMC,UAAyBC,MAGpC,WAAAC,CAAYC,EAAcC,GACxBC,MAAMD,GACNE,KAAKP,KAAO,mBACZO,KAAKH,KAAOA,CACd,EAGF,SAASI,EAAOC,EAAWC,GACzB,OAAOC,OAAOC,UAAUC,eAAeC,KAAKL,EAAGC,EACjD,CAEO,SAASK,EAAeC,GACtB,OAAAA,EAAOC,UAAYD,EAAOhB,KAAKkB,MAAM,KAAKC,KAAK,IACxD,CAOO,SAASC,EAAgBC,GACxB,MAAAC,EAAUD,EAAME,MAAM,GACtBC,EAAaF,EAAQG,QAAQ,KACnC,OAAOD,EAAa,EAAI,CAAExB,KAAM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AAKgC,SAAUzD,IAGtD"}
package/dist/xllm.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { X as XllmError, i as isObject } from "./aicc-67851c41.mjs";
2
2
  import { A, L, h, j, a, d, c, e, b, l, p, k, r, f, g, s } from "./aicc-67851c41.mjs";
3
- import { s as shellSettings, t as taskWaitMs, S as SiteToolManager, u as unresolvedReason, d as describeToolSource, a as utf8Length, v as validateJson, g as generateRunId, R as RUN_RECORD_VERSION } from "./site_manager-91b4d899.mjs";
4
- import { a8, B, D, h as h2, i, j as j2, k as k2, l as l2, ao, ap, V, W, L as L2, e as e2, ae, a4, M, m, a5, aq, G, Y, K, z, b as b2, af, x, aA, T, X, Z, _, $, ac, f as f2, ar, a9, y, A as A2, C, E, F, a0, ag, ah, ai, aj, o, a6, H, J, au, av, I, aw, a1, a7, ak, a2, P, q, n, aa, w, p as p2, al, as, Q, at, N, r as r2, ax, U, a3, O, c as c2, am, an, ay, ab, ad, az } from "./site_manager-91b4d899.mjs";
3
+ import { s as shellSettings, t as taskWaitMs, S as SiteToolManager, u as unresolvedReason, d as describeToolSource, a as utf8Length, v as validateJson, g as generateRunId, R as RUN_RECORD_VERSION } from "./site_manager-604ee369.mjs";
4
+ import { a8, B, D, h as h2, i, j as j2, k as k2, l as l2, at, au, V, W, L as L2, e as e2, aj, a4, M, m, a5, av, G, Y, K, ae, z, b as b2, ak, x, aG, T, X, Z, _, $, ah, f as f2, aw, a9, y, A as A2, C, E, F, a0, af, ag, al, am, an, ao, o, ax, a6, H, J, aa, aA, aB, ab, I, aC, a1, a7, ap, a2, P, q, n, ac, w, p as p2, aq, ay, Q, az, N, r as r2, aD, U, a3, O, c as c2, ar, as, aE, ad, ai, aF } from "./site_manager-604ee369.mjs";
5
5
  import { D as D2, a as a10 } from "./did_object_client-c6dae827.mjs";
6
6
  import "./krpc_client-673448e5.mjs";
7
7
  import "./object_url-20e94b67.mjs";
@@ -1056,8 +1056,8 @@ export {
1056
1056
  l2 as DEFAULT_TIMEOUT_SECS,
1057
1057
  D2 as DIDObjectClient,
1058
1058
  a10 as DIDObjectError,
1059
- ao as HINT_NS_DEDUP,
1060
- ap as HINT_NS_ONCE,
1059
+ at as HINT_NS_DEDUP,
1060
+ au as HINT_NS_ONCE,
1061
1061
  V as HOST_PROMPT_SECTIONS_ALL,
1062
1062
  W as HOST_PROMPT_SECTIONS_NONE,
1063
1063
  INDEX_TRAIT_URI,
@@ -1065,24 +1065,25 @@ export {
1065
1065
  L as LLMComputeException,
1066
1066
  L2 as LLMContext,
1067
1067
  e2 as LLMContextInterruptHandle,
1068
- ae as LlmSummarizeCompressor,
1068
+ aj as LlmSummarizeCompressor,
1069
1069
  a4 as MAX_IMAGE_ATTACHMENT_BYTES,
1070
1070
  M as MAX_INJECTIONS_PER_BOUNDARY,
1071
1071
  m as MAX_IN_TOOL_WAIT_MS,
1072
1072
  MAX_RESULT_BYTES,
1073
1073
  a5 as MAX_TEXT_ATTACHMENT_BYTES,
1074
- aq as MemoryHintLedger,
1074
+ av as MemoryHintLedger,
1075
1075
  G as MemoryRunStore,
1076
1076
  Y as REFUSED_CREDENTIALS,
1077
1077
  K as REPORT_ARTIFACTS_KEY,
1078
+ ae as RESULT_BUDGET_TOKENS,
1078
1079
  z as RUNTIME_PROTOCOL_VERSION,
1079
1080
  RUN_RECORD_VERSION,
1080
1081
  SITE_RUNTIME_KIND,
1081
1082
  b2 as SNAPSHOT_FORMAT_VERSION,
1082
- af as SUMMARIZE_MODEL_ALIAS,
1083
+ ak as SUMMARIZE_MODEL_ALIAS,
1083
1084
  SiteToolManager,
1084
1085
  x as TemplateEnv,
1085
- aA as TimeoutLlmClient,
1086
+ aG as TimeoutLlmClient,
1086
1087
  T as ToolDispatchException,
1087
1088
  XCALL_USAGE,
1088
1089
  XLLM_RUNS_DB,
@@ -1091,11 +1092,11 @@ export {
1091
1092
  Z as XllmInterrupter,
1092
1093
  _ as XllmRun,
1093
1094
  $ as XllmTask,
1094
- ac as XmlStepRenderer,
1095
+ ah as XmlStepRenderer,
1095
1096
  h as aiccProviderFailure,
1096
1097
  f2 as allowAllPolicy,
1097
1098
  j as anyJsonObjectSchema,
1098
- ar as applyHints,
1099
+ aw as applyHints,
1099
1100
  a as asComputeError,
1100
1101
  a9 as asToolResult,
1101
1102
  y as assemblePrompt,
@@ -1105,47 +1106,52 @@ export {
1105
1106
  F as buildRuntimeProtocolFor,
1106
1107
  d as charCount,
1107
1108
  a0 as classifyError,
1108
- ag as compactionTargetTokens,
1109
- ah as compress,
1110
- ai as compressHistory,
1111
- aj as compressOptions,
1109
+ af as clipToBudget,
1110
+ ag as clipToDefaultBudget,
1111
+ al as compactionTargetTokens,
1112
+ am as compress,
1113
+ an as compressHistory,
1114
+ ao as compressOptions,
1112
1115
  c as computeErrorMessage,
1113
1116
  o as computeToolsConfig,
1114
1117
  createSiteRuntime,
1118
+ ax as dedupText,
1115
1119
  didObjectResources,
1116
1120
  a6 as envelopeObservation,
1117
1121
  e as errorSource,
1118
1122
  H as exportRun,
1119
1123
  J as extractResult,
1120
- au as followupGeneralHint,
1121
- av as followupHint,
1124
+ aa as fitResultBudget,
1125
+ aA as followupGeneralHint,
1126
+ aB as followupHint,
1127
+ ab as fullText,
1122
1128
  generateRunId,
1123
1129
  I as importRun,
1124
- aw as inCallWaitMs,
1130
+ aC as inCallWaitMs,
1125
1131
  a1 as inFlightCall,
1126
1132
  b as infraRetrySafe,
1127
1133
  a7 as isIdempotent,
1128
- ak as isSummaryMessage,
1134
+ ap as isSummaryMessage,
1129
1135
  a2 as isTerminal,
1130
1136
  l as llmCorrectable,
1131
1137
  P as materializeHistory,
1132
1138
  q as mergeConfigLayers,
1133
1139
  n as noopWorklog,
1134
1140
  normalizeUri,
1135
- aa as observationText,
1141
+ ac as observationText,
1136
1142
  pageText,
1137
1143
  w as parseLlmContextJson,
1138
1144
  p2 as parseReply,
1139
- al as parseSummaryMessage,
1145
+ aq as parseSummaryMessage,
1140
1146
  p as providerError,
1141
1147
  k as providerErrorFromRpc,
1142
- as as renderHintBlock,
1148
+ ay as renderHintBlock,
1143
1149
  renderObjectDocument,
1144
1150
  Q as renderStepHistory,
1145
- at as renderWithHints,
1151
+ az as renderWithHints,
1146
1152
  N as reportArtifacts,
1147
1153
  r2 as resolveToolSpecs,
1148
- ax as resultView,
1154
+ aD as resultView,
1149
1155
  U as rewritableHistory,
1150
1156
  a3 as runRequest,
1151
1157
  r as rustTrim,
@@ -1155,13 +1161,13 @@ export {
1155
1161
  siteTools,
1156
1162
  O as splitReportResult,
1157
1163
  c2 as stateFromRequest,
1158
- am as summaryMessage,
1159
- an as summaryModel,
1160
- ay as taskStateObservation,
1161
- ab as toHost,
1162
- ad as toolResultViewFromHost,
1164
+ ar as summaryMessage,
1165
+ as as summaryModel,
1166
+ aE as taskStateObservation,
1167
+ ad as toHost,
1168
+ ai as toolResultViewFromHost,
1163
1169
  unresolvedReason,
1164
1170
  validateJson,
1165
- az as waitUntilMs
1171
+ aF as waitUntilMs
1166
1172
  };
1167
1173
  //# sourceMappingURL=xllm.mjs.map