pi-fabric 0.105.0 → 0.106.0

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 (110) hide show
  1. package/README.md +2 -0
  2. package/dist/agents.js +3 -3
  3. package/dist/chunks/{chunk-KYXZJNV6.js → chunk-4O3PFVTC.js} +3 -1
  4. package/dist/chunks/{chunk-KYXZJNV6.js.map → chunk-4O3PFVTC.js.map} +2 -2
  5. package/dist/chunks/{chunk-TFFZVLR2.js → chunk-5HZJ5LTB.js} +44 -2
  6. package/dist/chunks/chunk-5HZJ5LTB.js.map +7 -0
  7. package/dist/chunks/{chunk-5MNLVHF5.js → chunk-6YLQ73DF.js} +25 -10
  8. package/dist/chunks/chunk-6YLQ73DF.js.map +7 -0
  9. package/dist/chunks/{chunk-QLFDPXK7.js → chunk-BOONFV43.js} +109 -6
  10. package/dist/chunks/chunk-BOONFV43.js.map +7 -0
  11. package/dist/chunks/{chunk-3KDUMDPZ.js → chunk-L6PAMWV7.js} +2 -2
  12. package/dist/chunks/{chunk-OVBKQCYL.js → chunk-LOJO6DYE.js} +2 -2
  13. package/dist/chunks/{chunk-VON4TSO3.js → chunk-LWRRPPH2.js} +24 -1
  14. package/dist/chunks/chunk-LWRRPPH2.js.map +7 -0
  15. package/dist/chunks/{chunk-KQ6R5EWR.js → chunk-MQK7POVM.js} +9 -9
  16. package/dist/chunks/{chunk-6VXPACGC.js → chunk-NHJCMJWX.js} +86 -18
  17. package/dist/chunks/chunk-NHJCMJWX.js.map +7 -0
  18. package/dist/chunks/{chunk-WLLXKS6I.js → chunk-OQJGPLN5.js} +2 -2
  19. package/dist/chunks/{chunk-CGL7QP4A.js → chunk-PK4NIJEV.js} +10 -1
  20. package/dist/chunks/{chunk-CGL7QP4A.js.map → chunk-PK4NIJEV.js.map} +2 -2
  21. package/dist/chunks/{chunk-W7X4XEQU.js → chunk-PM7NQXS7.js} +2 -2
  22. package/dist/chunks/{chunk-VPRJOD4Y.js → chunk-TFYVSAFU.js} +2 -2
  23. package/dist/components/configuration.js +2 -2
  24. package/dist/config.d.ts +13 -0
  25. package/dist/config.d.ts.map +1 -1
  26. package/dist/core/media-sanitize.d.ts.map +1 -1
  27. package/dist/execution-service.d.ts +4 -0
  28. package/dist/execution-service.d.ts.map +1 -1
  29. package/dist/extension-bootstrap.js +5 -5
  30. package/dist/extension.d.ts.map +1 -1
  31. package/dist/fabric-exec-arguments.d.ts.map +1 -1
  32. package/dist/fabric-exec-tool.d.ts.map +1 -1
  33. package/dist/fabric-runtime-state.d.ts.map +1 -1
  34. package/dist/fabric-runtime-state.js +437 -227
  35. package/dist/fabric-runtime-state.js.map +4 -4
  36. package/dist/index.js +5 -5
  37. package/dist/jev/observation.js +2 -2
  38. package/dist/jev.js +3 -3
  39. package/dist/memory/extractive-history.d.ts +29 -0
  40. package/dist/memory/extractive-history.d.ts.map +1 -0
  41. package/dist/memory/extractive-history.js +340 -0
  42. package/dist/memory/extractive-history.js.map +7 -0
  43. package/dist/memory/extractive-index.d.ts +46 -0
  44. package/dist/memory/extractive-index.d.ts.map +1 -0
  45. package/dist/native-codemode.d.ts +34 -0
  46. package/dist/native-codemode.d.ts.map +1 -0
  47. package/dist/native-discovery.d.ts +16 -0
  48. package/dist/native-discovery.d.ts.map +1 -0
  49. package/dist/native-discovery.js +19 -0
  50. package/dist/native-discovery.js.map +7 -0
  51. package/dist/providers/jev-provider.js +3 -3
  52. package/dist/residency/host.js +5 -5
  53. package/dist/residency/pi-entry.js +5 -5
  54. package/dist/runtime/core-override-guest-types.js +2 -2
  55. package/dist/runtime/dynamic-guest-types.d.ts +2 -0
  56. package/dist/runtime/dynamic-guest-types.d.ts.map +1 -1
  57. package/dist/runtime/dynamic-guest-types.js +5 -3
  58. package/dist/runtime/guest-types.d.ts +1 -1
  59. package/dist/runtime/guest-types.d.ts.map +1 -1
  60. package/dist/runtime/guest-types.js +1 -1
  61. package/dist/runtime/kernel.d.ts +3 -0
  62. package/dist/runtime/kernel.d.ts.map +1 -1
  63. package/dist/runtime/monty-runtime.js +4 -4
  64. package/dist/runtime/native-codemode-guest.d.ts +2 -0
  65. package/dist/runtime/native-codemode-guest.d.ts.map +1 -0
  66. package/dist/runtime/native-codemode-types.d.ts +2 -0
  67. package/dist/runtime/native-codemode-types.d.ts.map +1 -0
  68. package/dist/runtime/node-process-child-source.d.ts.map +1 -1
  69. package/dist/runtime/node-process-runtime.d.ts.map +1 -1
  70. package/dist/runtime/node-process-runtime.js +2 -2
  71. package/dist/runtime/quickjs-runtime.d.ts +1 -1
  72. package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
  73. package/dist/runtime/quickjs-runtime.js +1 -1
  74. package/dist/runtime/typescript-kernel.js +9 -9
  75. package/dist/type-error-guidance.js +1 -1
  76. package/dist/ui/border-status-editor.d.ts +3 -0
  77. package/dist/ui/border-status-editor.d.ts.map +1 -1
  78. package/dist/ui/conversation.d.ts +1 -0
  79. package/dist/ui/conversation.d.ts.map +1 -1
  80. package/dist/ui/conversation.js +24 -1
  81. package/dist/ui/conversation.js.map +2 -2
  82. package/dist/ui/dashboard.js +6 -6
  83. package/dist/ui/settings-section-context.d.ts +2 -0
  84. package/dist/ui/settings-section-context.d.ts.map +1 -1
  85. package/dist/ui/settings-sections-lifecycle.d.ts +1 -0
  86. package/dist/ui/settings-sections-lifecycle.d.ts.map +1 -1
  87. package/dist/ui/settings-sections.d.ts +2 -0
  88. package/dist/ui/settings-sections.d.ts.map +1 -1
  89. package/dist/ui/settings-values.d.ts +3 -0
  90. package/dist/ui/settings-values.d.ts.map +1 -1
  91. package/dist/ui/settings.d.ts.map +1 -1
  92. package/dist/ui/settings.js +56 -1
  93. package/dist/ui/settings.js.map +2 -2
  94. package/docs/codemode-parity.md +50 -0
  95. package/docs/configuration.md +25 -0
  96. package/docs/extractive-history.md +171 -0
  97. package/docs/interface.md +1 -1
  98. package/package.json +1 -1
  99. package/skillsets/typescript/fabric-exec/SKILL.md +2 -2
  100. package/dist/chunks/chunk-5MNLVHF5.js.map +0 -7
  101. package/dist/chunks/chunk-6VXPACGC.js.map +0 -7
  102. package/dist/chunks/chunk-QLFDPXK7.js.map +0 -7
  103. package/dist/chunks/chunk-TFFZVLR2.js.map +0 -7
  104. package/dist/chunks/chunk-VON4TSO3.js.map +0 -7
  105. /package/dist/chunks/{chunk-3KDUMDPZ.js.map → chunk-L6PAMWV7.js.map} +0 -0
  106. /package/dist/chunks/{chunk-OVBKQCYL.js.map → chunk-LOJO6DYE.js.map} +0 -0
  107. /package/dist/chunks/{chunk-KQ6R5EWR.js.map → chunk-MQK7POVM.js.map} +0 -0
  108. /package/dist/chunks/{chunk-WLLXKS6I.js.map → chunk-OQJGPLN5.js.map} +0 -0
  109. /package/dist/chunks/{chunk-W7X4XEQU.js.map → chunk-PM7NQXS7.js.map} +0 -0
  110. /package/dist/chunks/{chunk-VPRJOD4Y.js.map → chunk-TFYVSAFU.js.map} +0 -0
package/README.md CHANGED
@@ -158,12 +158,14 @@ See the [interface & commands reference](docs/interface.md) for every view, keyb
158
158
 
159
159
  - [Configuration](docs/configuration.md): `fabric.json`, code modes, tool capture, approvals, and budgets.
160
160
  - [Execution kernels](docs/kernels.md): exclusive TypeScript/Python selection, Monty sandboxing, CPython escape hatch, agent inheritance, and examples.
161
+ - [Native codemode APIs](docs/codemode-parity.md): the `models` namespace, native classifiers and images, branch-local script state, output helpers, and per-call limits.
161
162
  - [Prompt cache](docs/prompt-cache.md): honest cache observations and optional, time-bounded native warming leases.
162
163
  - [Thinking control](docs/thinking.md): scoped host-session reasoning effort with configured bounds that children inherit and never widen.
163
164
  - [Optional durable Pi runner](docs/durable-pi.md): explicit hosted-backend registration, persistent submissions, recovery boundaries, and unchanged default runner behavior.
164
165
  - [Durable decisions](docs/decisions.md): pending approvals and questions in the project mesh, headless approvals, routed child dialogs, `/fabric decisions`, and the `pi-fabric decisions` CLI.
165
166
  - [Saved programs](docs/programs.md): content-addressed programs, nested `programs.run` with the caller's capabilities, `/fabric programs`, and host runs through `/fabric run` or an event.
166
167
  - [Memory & recall](docs/memory-recall.md): compact ranked hits, uniform follow calls, lossless expansion, and guest-local `memory.walk` computation.
168
+ - [Extractive history](docs/extractive-history.md): opt-in native-classifier salience, source-preserving selection, bounded context, and deterministic fallback; configure it through JSON or the TUI.
167
169
  - [Interface & commands](docs/interface.md): dashboard, settings, keybindings, slash commands, and headless runs.
168
170
  - [Agents, actors & mesh](docs/agents.md): model handoff, `/fabric prewalk`, runners, transports, actors, councils, recursive queries, and durable coordination.
169
171
  - [Durable residency through Pi](docs/residency-runtime.md): background host lifecycle and the Pi-runtime launcher boundary.
package/dist/agents.js CHANGED
@@ -1,10 +1,10 @@
1
+ import {
2
+ validateAgentResult
3
+ } from "./chunks/chunk-3QECYQGA.js";
1
4
  import {
2
5
  AGENTS_ACTION_DESCRIPTORS,
3
6
  normalizeAgentRunRequest
4
7
  } from "./chunks/chunk-GJVPP3NN.js";
5
- import {
6
- validateAgentResult
7
- } from "./chunks/chunk-3QECYQGA.js";
8
8
  import {
9
9
  AgentAdmission,
10
10
  assertAgentTask,
@@ -210,6 +210,7 @@ ${memberBlock.lines.join("\n")}
210
210
  declare const extensions: FabricExtensionsApiDynamic;
211
211
  `;
212
212
  };
213
+ var describeFabricActionDeclaration = (name, inputSchema) => `${JSON.stringify(name)}: (args: ${schemaType(inputSchema, 0)}) => Promise<unknown>`;
213
214
  var buildDynamicGuestDeclarations = (sources) => {
214
215
  const dynamic = {};
215
216
  if (sources.mcpServers && sources.mcpServers.length > 0) {
@@ -222,6 +223,7 @@ var buildDynamicGuestDeclarations = (sources) => {
222
223
  };
223
224
 
224
225
  export {
226
+ describeFabricActionDeclaration,
225
227
  buildDynamicGuestDeclarations
226
228
  };
227
- //# sourceMappingURL=chunk-KYXZJNV6.js.map
229
+ //# sourceMappingURL=chunk-4O3PFVTC.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/runtime/dynamic-guest-types.ts"],
4
- "sourcesContent": ["import { sanitizeMcpRefPart } from \"../ref-names.js\";\nimport type {\n FabricDynamicGuestDeclarations,\n FabricGuestTypeSources,\n FabricNamedActionTypeSource,\n} from \"../protocol.js\";\n\n// Renders guest .d.ts fragments for the dynamic call surfaces\n// (mcp.<server>.<tool> and extensions.<tool>) from live provider descriptors,\n// closing the type-check gap those globals had as Record<string, unknown>\n// callables: argument-shape mistakes surfaced only at dispatch time. The\n// generated surface stays advisory \u2014 the registry still validates every\n// call's args against the action's own inputSchema before invoke, so drift\n// between these declarations and a live server fails at the usual validate\n// stage rather than silently.\n\nconst MAX_DEPTH = 6;\nconst MAX_UNION_MEMBERS = 12;\nconst MAX_SCHEMA_SOURCE_CHARS = 4_096;\nconst MAX_MEMBER_TYPE_CHARS = 2_500;\nconst MAX_SECTION_CHARS = 60_000;\nconst MAX_MCP_SERVERS = 64;\nconst MAX_TOOLS_PER_SERVER = 128;\nconst MAX_EXTENSION_TOOLS = 256;\n\nconst IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst propertyKey = (name: string): string =>\n IDENTIFIER.test(name) ? name : JSON.stringify(name);\n\nconst literalType = (value: unknown): string => {\n if (value === null) return \"null\";\n if (typeof value === \"string\") return JSON.stringify(value);\n if (typeof value === \"number\" && Number.isFinite(value)) return JSON.stringify(value);\n if (typeof value === \"boolean\") return value ? \"true\" : \"false\";\n return \"unknown\";\n};\n\nconst unionType = (parts: string[]): string => {\n const unique = [...new Set(parts)];\n if (unique.length === 0) return \"unknown\";\n return unique.length === 1 ? unique[0]! : unique.join(\" | \");\n};\n\nconst typeList = (value: unknown): string[] => {\n if (typeof value === \"string\") return [value];\n if (Array.isArray(value)) {\n return value.filter((entry): entry is string => typeof entry === \"string\");\n }\n return [];\n};\n\nconst objectType = (schema: Record<string, unknown>, depth: number): string => {\n const properties = isRecord(schema.properties) ? schema.properties : {};\n const required = new Set(\n Array.isArray(schema.required)\n ? schema.required.filter((entry): entry is string => typeof entry === \"string\")\n : [],\n );\n const members: string[] = [];\n for (const key of Object.keys(properties).sort()) {\n members.push(\n `${propertyKey(key)}${required.has(key) ? \"\" : \"?\"}: ${schemaType(properties[key], depth + 1)}`,\n );\n }\n const additional = schema.additionalProperties;\n if (additional !== false) {\n members.push(\n isRecord(additional)\n ? `[key: string]: ${schemaType(additional, depth + 1)}`\n : \"[key: string]: unknown\",\n );\n }\n return `{ ${members.join(\"; \")} }`;\n};\n\nconst schemaType = (schema: unknown, depth: number): string => {\n if (depth > MAX_DEPTH) return \"unknown\";\n if (schema === true || schema === undefined) return \"unknown\";\n if (schema === false) return \"never\";\n if (!isRecord(schema)) return \"unknown\";\n if (\"const\" in schema) return literalType(schema.const);\n if (Array.isArray(schema.enum) && schema.enum.length > 0) {\n return unionType(schema.enum.slice(0, MAX_UNION_MEMBERS).map(literalType));\n }\n const alternates = Array.isArray(schema.anyOf)\n ? schema.anyOf\n : Array.isArray(schema.oneOf)\n ? schema.oneOf\n : undefined;\n if (alternates) {\n if (alternates.length === 0) return \"unknown\";\n return unionType(\n alternates.slice(0, MAX_UNION_MEMBERS).map((entry) => schemaType(entry, depth + 1)),\n );\n }\n if (Array.isArray(schema.allOf) && schema.allOf.length > 0) {\n return schema.allOf\n .slice(0, MAX_UNION_MEMBERS)\n .map((entry) => {\n const rendered = schemaType(entry, depth + 1);\n return rendered.includes(\" | \") ? `(${rendered})` : rendered;\n })\n .join(\" & \");\n }\n const types = typeList(schema.type);\n if (types.length > 1) {\n return unionType(types.map((type) => schemaType({ ...schema, type }, depth + 1)));\n }\n const type = types[0];\n if (type === \"object\" || (!type && isRecord(schema.properties))) {\n return objectType(schema, depth);\n }\n if (type === \"string\") return \"string\";\n if (type === \"number\" || type === \"integer\") return \"number\";\n if (type === \"boolean\") return \"boolean\";\n if (type === \"null\") return \"null\";\n if (type === \"array\") {\n const items = schema.items;\n if (Array.isArray(items)) {\n return `[${items\n .slice(0, MAX_UNION_MEMBERS)\n .map((entry) => schemaType(entry, depth + 1))\n .join(\", \")}]`;\n }\n return isRecord(items) || items === true\n ? `Array<${schemaType(items, depth + 1)}>`\n : \"unknown[]\";\n }\n return \"unknown\";\n};\n\ninterface FabricRenderBudget {\n chars: number;\n}\n\nconst spend = (budget: FabricRenderBudget, text: string): boolean => {\n if (budget.chars < text.length) return false;\n budget.chars -= text.length;\n return true;\n};\n\nconst hasRequiredArgs = (source: FabricNamedActionTypeSource): boolean =>\n Array.isArray(source.inputSchema.required) &&\n source.inputSchema.required.length > 0 &&\n isRecord(source.inputSchema.properties);\n\nconst renderMember = (\n name: string,\n source: FabricNamedActionTypeSource,\n resultType: string,\n): string => {\n const loose = `${propertyKey(name)}(args?: Record<string, unknown>): ${resultType};`;\n const schemaJson = JSON.stringify(source.inputSchema);\n if (!schemaJson || schemaJson.length > MAX_SCHEMA_SOURCE_CHARS) return loose;\n const rendered = schemaType(source.inputSchema, 0);\n if (rendered.length > MAX_MEMBER_TYPE_CHARS) return loose;\n return `${propertyKey(name)}(args${hasRequiredArgs(source) ? \"\" : \"?\"}: ${rendered}): ${resultType};`;\n};\n\n// Name collisions after sanitization are ambiguous: the MCP provider refuses\n// ambiguous sanitized server names and resolves colliding tools to the first\n// match, so mirrored members would promise a shape dispatch does not\n// guarantee. Unique names render in up to two forms \u2014 the sanitized\n// identifier the model types and a quoted raw alias for bracket access\n// (mcp[\"my-server\"]) \u2014 and ambiguous groups render nothing. A raw alias can\n// never collide with a sanitized member: aliases always contain a character\n// the sanitizer would replace or a leading digit it would prefix.\nconst renderMemberBlock = (\n sources: FabricNamedActionTypeSource[],\n resultType: string,\n limit: number,\n budget: FabricRenderBudget,\n): { lines: string[]; dropped: number } => {\n const bySanitized = new Map<string, FabricNamedActionTypeSource[]>();\n for (const source of sources.slice(0, limit)) {\n const key = sanitizeMcpRefPart(source.name);\n const group = bySanitized.get(key);\n if (group) group.push(source);\n else bySanitized.set(key, [source]);\n }\n const lines: string[] = [];\n let dropped = Math.max(0, sources.length - limit);\n const sortedGroups = [...bySanitized.entries()].sort(([a], [b]) => a.localeCompare(b));\n for (const [sanitized, group] of sortedGroups) {\n if (group.length > 1) {\n dropped += group.length;\n continue;\n }\n const source = group[0]!;\n const text =\n source.name === sanitized\n ? ` ${renderMember(sanitized, source, resultType)}`\n : ` ${renderMember(sanitized, source, resultType)}\\n ${renderMember(source.name, source, resultType)}`;\n if (!spend(budget, text)) {\n dropped += 1;\n continue;\n }\n lines.push(text);\n }\n return { lines, dropped };\n};\n\nconst renderMcpDeclaration = (\n sources: NonNullable<FabricGuestTypeSources[\"mcpServers\"]>,\n): string => {\n const bySanitized = new Map<string, typeof sources>();\n const rawNames = new Set<string>();\n for (const source of sources.slice(0, MAX_MCP_SERVERS)) {\n if (rawNames.has(source.server)) continue;\n rawNames.add(source.server);\n const key = sanitizeMcpRefPart(source.server);\n const group = bySanitized.get(key);\n if (group) group.push(source);\n else bySanitized.set(key, [source]);\n }\n const budget: FabricRenderBudget = { chars: MAX_SECTION_CHARS };\n const interfaces: string[] = [];\n const mapEntries: string[] = [];\n let droppedServers = Math.max(0, sources.length - rawNames.size);\n let droppedTools = 0;\n const sortedGroups = [...bySanitized.entries()].sort(([a], [b]) => a.localeCompare(b));\n for (const [sanitized, group] of sortedGroups) {\n if (group.length > 1) {\n droppedServers += group.length;\n droppedTools += group.reduce((total, entry) => total + entry.tools.length, 0);\n continue;\n }\n const source = group[0]!;\n const interfaceName = `FabricMcpServer_${sanitized}`;\n const memberBlock = renderMemberBlock(\n source.tools,\n \"Promise<FabricMcpResult | unknown>\",\n MAX_TOOLS_PER_SERVER,\n budget,\n );\n droppedTools += memberBlock.dropped;\n const header = `interface ${interfaceName} {\\n${memberBlock.lines.join(\"\\n\")}\\n}`;\n if (!spend(budget, header)) {\n droppedServers += 1;\n droppedTools += source.tools.length;\n break;\n }\n interfaces.push(header);\n mapEntries.push(` ${sanitized}: ${interfaceName};`);\n if (source.server !== sanitized) {\n mapEntries.push(` ${propertyKey(source.server)}: ${interfaceName};`);\n }\n }\n const notes: string[] = [];\n if (droppedServers > 0) notes.push(`${droppedServers} server(s) untyped`);\n if (droppedTools > 0) notes.push(`${droppedTools} tool(s) untyped`);\n const note =\n notes.length > 0\n ? `// Omitted from this surface (${notes.join(\", \")}); those calls compile\\n// as the loose fallback would and still validate at dispatch.\\n`\n : \"\";\n return (\n \"// Generated from the live MCP descriptor cache for this execution. Known\\n\" +\n \"// servers and tools carry their schemas so argument-shape mistakes fail\\n\" +\n \"// type-check before the sandbox runs, like pi.* calls do; anything absent\\n\" +\n \"// (cold cache, ambiguous sanitized names) compiles as it would with the\\n\" +\n \"// loose declarations and is validated by the registry at dispatch.\\n\" +\n note +\n interfaces.join(\"\\n\") +\n (interfaces.length > 0 ? \"\\n\" : \"\") +\n `declare const mcp: {\\n${mapEntries.join(\"\\n\")}\\n} & FabricMcpManagement;\\n`\n );\n};\n\nconst renderExtensionsDeclaration = (\n sources: NonNullable<FabricGuestTypeSources[\"extensionTools\"]>,\n): string => {\n const budget: FabricRenderBudget = { chars: MAX_SECTION_CHARS };\n const memberBlock = renderMemberBlock(\n sources,\n \"Promise<FabricCapturedToolResult>\",\n MAX_EXTENSION_TOOLS,\n budget,\n );\n const note =\n memberBlock.dropped > 0\n ? `// Omitted ${memberBlock.dropped} tool(s) from this surface; those calls\\n// compile as the loose fallback would and still validate at dispatch.\\n`\n : \"\";\n return (\n \"// Generated from the captured extension tool catalog for this execution,\\n\" +\n \"// with the same advisory semantics as the generated mcp surface above.\\n\" +\n note +\n `interface FabricExtensionsApiDynamic {\\n${memberBlock.lines.join(\"\\n\")}\\n}\\n` +\n \"declare const extensions: FabricExtensionsApiDynamic;\\n\"\n );\n};\n\n// Renders replacement `declare const mcp` / `declare const extensions` blocks\n// for guestTypeDeclarations(). Missing or empty sections return undefined so\n// the loose static lines survive, matching cold-cache behavior.\nexport const buildDynamicGuestDeclarations = (\n sources: FabricGuestTypeSources,\n): FabricDynamicGuestDeclarations => {\n const dynamic: FabricDynamicGuestDeclarations = {};\n if (sources.mcpServers && sources.mcpServers.length > 0) {\n dynamic.mcp = renderMcpDeclaration(sources.mcpServers);\n }\n if (sources.extensionTools && sources.extensionTools.length > 0) {\n dynamic.extensions = renderExtensionsDeclaration(sources.extensionTools);\n }\n return dynamic;\n};\n"],
5
- "mappings": ";;;;;AAgBA,IAAM,YAAY;AAClB,IAAM,oBAAoB;AAC1B,IAAM,0BAA0B;AAChC,IAAM,wBAAwB;AAC9B,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB;AACxB,IAAM,uBAAuB;AAC7B,IAAM,sBAAsB;AAE5B,IAAM,aAAa;AAEnB,IAAM,WAAW,CAAC,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,IAAM,cAAc,CAAC,SACnB,WAAW,KAAK,IAAI,IAAI,OAAO,KAAK,UAAU,IAAI;AAEpD,IAAM,cAAc,CAAC,UAA2B;AAC9C,MAAI,UAAU,KAAM,QAAO;AAC3B,MAAI,OAAO,UAAU,SAAU,QAAO,KAAK,UAAU,KAAK;AAC1D,MAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,EAAG,QAAO,KAAK,UAAU,KAAK;AACpF,MAAI,OAAO,UAAU,UAAW,QAAO,QAAQ,SAAS;AACxD,SAAO;AACT;AAEA,IAAM,YAAY,CAAC,UAA4B;AAC7C,QAAM,SAAS,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC;AACjC,MAAI,OAAO,WAAW,EAAG,QAAO;AAChC,SAAO,OAAO,WAAW,IAAI,OAAO,CAAC,IAAK,OAAO,KAAK,KAAK;AAC7D;AAEA,IAAM,WAAW,CAAC,UAA6B;AAC7C,MAAI,OAAO,UAAU,SAAU,QAAO,CAAC,KAAK;AAC5C,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,OAAO,CAAC,UAA2B,OAAO,UAAU,QAA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gCAAgC,CAC3C,YACmC;AACnC,QAAM,UAA0C,CAAC;AACjD,MAAI,QAAQ,cAAc,QAAQ,WAAW,SAAS,GAAG;AACvD,YAAQ,MAAM,qBAAqB,QAAQ,UAAU;AAAA,EACvD;AACA,MAAI,QAAQ,kBAAkB,QAAQ,eAAe,SAAS,GAAG;AAC/D,YAAQ,aAAa,4BAA4B,QAAQ,cAAc;AAAA,EACzE;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["import { sanitizeMcpRefPart } from \"../ref-names.js\";\nimport type {\n FabricDynamicGuestDeclarations,\n FabricGuestTypeSources,\n FabricNamedActionTypeSource,\n} from \"../protocol.js\";\n\n// Renders guest .d.ts fragments for the dynamic call surfaces\n// (mcp.<server>.<tool> and extensions.<tool>) from live provider descriptors,\n// closing the type-check gap those globals had as Record<string, unknown>\n// callables: argument-shape mistakes surfaced only at dispatch time. The\n// generated surface stays advisory \u2014 the registry still validates every\n// call's args against the action's own inputSchema before invoke, so drift\n// between these declarations and a live server fails at the usual validate\n// stage rather than silently.\n\nconst MAX_DEPTH = 6;\nconst MAX_UNION_MEMBERS = 12;\nconst MAX_SCHEMA_SOURCE_CHARS = 4_096;\nconst MAX_MEMBER_TYPE_CHARS = 2_500;\nconst MAX_SECTION_CHARS = 60_000;\nconst MAX_MCP_SERVERS = 64;\nconst MAX_TOOLS_PER_SERVER = 128;\nconst MAX_EXTENSION_TOOLS = 256;\n\nconst IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst propertyKey = (name: string): string =>\n IDENTIFIER.test(name) ? name : JSON.stringify(name);\n\nconst literalType = (value: unknown): string => {\n if (value === null) return \"null\";\n if (typeof value === \"string\") return JSON.stringify(value);\n if (typeof value === \"number\" && Number.isFinite(value)) return JSON.stringify(value);\n if (typeof value === \"boolean\") return value ? \"true\" : \"false\";\n return \"unknown\";\n};\n\nconst unionType = (parts: string[]): string => {\n const unique = [...new Set(parts)];\n if (unique.length === 0) return \"unknown\";\n return unique.length === 1 ? unique[0]! : unique.join(\" | \");\n};\n\nconst typeList = (value: unknown): string[] => {\n if (typeof value === \"string\") return [value];\n if (Array.isArray(value)) {\n return value.filter((entry): entry is string => typeof entry === \"string\");\n }\n return [];\n};\n\nconst objectType = (schema: Record<string, unknown>, depth: number): string => {\n const properties = isRecord(schema.properties) ? schema.properties : {};\n const required = new Set(\n Array.isArray(schema.required)\n ? schema.required.filter((entry): entry is string => typeof entry === \"string\")\n : [],\n );\n const members: string[] = [];\n for (const key of Object.keys(properties).sort()) {\n members.push(\n `${propertyKey(key)}${required.has(key) ? \"\" : \"?\"}: ${schemaType(properties[key], depth + 1)}`,\n );\n }\n const additional = schema.additionalProperties;\n if (additional !== false) {\n members.push(\n isRecord(additional)\n ? `[key: string]: ${schemaType(additional, depth + 1)}`\n : \"[key: string]: unknown\",\n );\n }\n return `{ ${members.join(\"; \")} }`;\n};\n\nconst schemaType = (schema: unknown, depth: number): string => {\n if (depth > MAX_DEPTH) return \"unknown\";\n if (schema === true || schema === undefined) return \"unknown\";\n if (schema === false) return \"never\";\n if (!isRecord(schema)) return \"unknown\";\n if (\"const\" in schema) return literalType(schema.const);\n if (Array.isArray(schema.enum) && schema.enum.length > 0) {\n return unionType(schema.enum.slice(0, MAX_UNION_MEMBERS).map(literalType));\n }\n const alternates = Array.isArray(schema.anyOf)\n ? schema.anyOf\n : Array.isArray(schema.oneOf)\n ? schema.oneOf\n : undefined;\n if (alternates) {\n if (alternates.length === 0) return \"unknown\";\n return unionType(\n alternates.slice(0, MAX_UNION_MEMBERS).map((entry) => schemaType(entry, depth + 1)),\n );\n }\n if (Array.isArray(schema.allOf) && schema.allOf.length > 0) {\n return schema.allOf\n .slice(0, MAX_UNION_MEMBERS)\n .map((entry) => {\n const rendered = schemaType(entry, depth + 1);\n return rendered.includes(\" | \") ? `(${rendered})` : rendered;\n })\n .join(\" & \");\n }\n const types = typeList(schema.type);\n if (types.length > 1) {\n return unionType(types.map((type) => schemaType({ ...schema, type }, depth + 1)));\n }\n const type = types[0];\n if (type === \"object\" || (!type && isRecord(schema.properties))) {\n return objectType(schema, depth);\n }\n if (type === \"string\") return \"string\";\n if (type === \"number\" || type === \"integer\") return \"number\";\n if (type === \"boolean\") return \"boolean\";\n if (type === \"null\") return \"null\";\n if (type === \"array\") {\n const items = schema.items;\n if (Array.isArray(items)) {\n return `[${items\n .slice(0, MAX_UNION_MEMBERS)\n .map((entry) => schemaType(entry, depth + 1))\n .join(\", \")}]`;\n }\n return isRecord(items) || items === true\n ? `Array<${schemaType(items, depth + 1)}>`\n : \"unknown[]\";\n }\n return \"unknown\";\n};\n\ninterface FabricRenderBudget {\n chars: number;\n}\n\nconst spend = (budget: FabricRenderBudget, text: string): boolean => {\n if (budget.chars < text.length) return false;\n budget.chars -= text.length;\n return true;\n};\n\nconst hasRequiredArgs = (source: FabricNamedActionTypeSource): boolean =>\n Array.isArray(source.inputSchema.required) &&\n source.inputSchema.required.length > 0 &&\n isRecord(source.inputSchema.properties);\n\nconst renderMember = (\n name: string,\n source: FabricNamedActionTypeSource,\n resultType: string,\n): string => {\n const loose = `${propertyKey(name)}(args?: Record<string, unknown>): ${resultType};`;\n const schemaJson = JSON.stringify(source.inputSchema);\n if (!schemaJson || schemaJson.length > MAX_SCHEMA_SOURCE_CHARS) return loose;\n const rendered = schemaType(source.inputSchema, 0);\n if (rendered.length > MAX_MEMBER_TYPE_CHARS) return loose;\n return `${propertyKey(name)}(args${hasRequiredArgs(source) ? \"\" : \"?\"}: ${rendered}): ${resultType};`;\n};\n\n// Name collisions after sanitization are ambiguous: the MCP provider refuses\n// ambiguous sanitized server names and resolves colliding tools to the first\n// match, so mirrored members would promise a shape dispatch does not\n// guarantee. Unique names render in up to two forms \u2014 the sanitized\n// identifier the model types and a quoted raw alias for bracket access\n// (mcp[\"my-server\"]) \u2014 and ambiguous groups render nothing. A raw alias can\n// never collide with a sanitized member: aliases always contain a character\n// the sanitizer would replace or a leading digit it would prefix.\nconst renderMemberBlock = (\n sources: FabricNamedActionTypeSource[],\n resultType: string,\n limit: number,\n budget: FabricRenderBudget,\n): { lines: string[]; dropped: number } => {\n const bySanitized = new Map<string, FabricNamedActionTypeSource[]>();\n for (const source of sources.slice(0, limit)) {\n const key = sanitizeMcpRefPart(source.name);\n const group = bySanitized.get(key);\n if (group) group.push(source);\n else bySanitized.set(key, [source]);\n }\n const lines: string[] = [];\n let dropped = Math.max(0, sources.length - limit);\n const sortedGroups = [...bySanitized.entries()].sort(([a], [b]) => a.localeCompare(b));\n for (const [sanitized, group] of sortedGroups) {\n if (group.length > 1) {\n dropped += group.length;\n continue;\n }\n const source = group[0]!;\n const text =\n source.name === sanitized\n ? ` ${renderMember(sanitized, source, resultType)}`\n : ` ${renderMember(sanitized, source, resultType)}\\n ${renderMember(source.name, source, resultType)}`;\n if (!spend(budget, text)) {\n dropped += 1;\n continue;\n }\n lines.push(text);\n }\n return { lines, dropped };\n};\n\nconst renderMcpDeclaration = (\n sources: NonNullable<FabricGuestTypeSources[\"mcpServers\"]>,\n): string => {\n const bySanitized = new Map<string, typeof sources>();\n const rawNames = new Set<string>();\n for (const source of sources.slice(0, MAX_MCP_SERVERS)) {\n if (rawNames.has(source.server)) continue;\n rawNames.add(source.server);\n const key = sanitizeMcpRefPart(source.server);\n const group = bySanitized.get(key);\n if (group) group.push(source);\n else bySanitized.set(key, [source]);\n }\n const budget: FabricRenderBudget = { chars: MAX_SECTION_CHARS };\n const interfaces: string[] = [];\n const mapEntries: string[] = [];\n let droppedServers = Math.max(0, sources.length - rawNames.size);\n let droppedTools = 0;\n const sortedGroups = [...bySanitized.entries()].sort(([a], [b]) => a.localeCompare(b));\n for (const [sanitized, group] of sortedGroups) {\n if (group.length > 1) {\n droppedServers += group.length;\n droppedTools += group.reduce((total, entry) => total + entry.tools.length, 0);\n continue;\n }\n const source = group[0]!;\n const interfaceName = `FabricMcpServer_${sanitized}`;\n const memberBlock = renderMemberBlock(\n source.tools,\n \"Promise<FabricMcpResult | unknown>\",\n MAX_TOOLS_PER_SERVER,\n budget,\n );\n droppedTools += memberBlock.dropped;\n const header = `interface ${interfaceName} {\\n${memberBlock.lines.join(\"\\n\")}\\n}`;\n if (!spend(budget, header)) {\n droppedServers += 1;\n droppedTools += source.tools.length;\n break;\n }\n interfaces.push(header);\n mapEntries.push(` ${sanitized}: ${interfaceName};`);\n if (source.server !== sanitized) {\n mapEntries.push(` ${propertyKey(source.server)}: ${interfaceName};`);\n }\n }\n const notes: string[] = [];\n if (droppedServers > 0) notes.push(`${droppedServers} server(s) untyped`);\n if (droppedTools > 0) notes.push(`${droppedTools} tool(s) untyped`);\n const note =\n notes.length > 0\n ? `// Omitted from this surface (${notes.join(\", \")}); those calls compile\\n// as the loose fallback would and still validate at dispatch.\\n`\n : \"\";\n return (\n \"// Generated from the live MCP descriptor cache for this execution. Known\\n\" +\n \"// servers and tools carry their schemas so argument-shape mistakes fail\\n\" +\n \"// type-check before the sandbox runs, like pi.* calls do; anything absent\\n\" +\n \"// (cold cache, ambiguous sanitized names) compiles as it would with the\\n\" +\n \"// loose declarations and is validated by the registry at dispatch.\\n\" +\n note +\n interfaces.join(\"\\n\") +\n (interfaces.length > 0 ? \"\\n\" : \"\") +\n `declare const mcp: {\\n${mapEntries.join(\"\\n\")}\\n} & FabricMcpManagement;\\n`\n );\n};\n\nconst renderExtensionsDeclaration = (\n sources: NonNullable<FabricGuestTypeSources[\"extensionTools\"]>,\n): string => {\n const budget: FabricRenderBudget = { chars: MAX_SECTION_CHARS };\n const memberBlock = renderMemberBlock(\n sources,\n \"Promise<FabricCapturedToolResult>\",\n MAX_EXTENSION_TOOLS,\n budget,\n );\n const note =\n memberBlock.dropped > 0\n ? `// Omitted ${memberBlock.dropped} tool(s) from this surface; those calls\\n// compile as the loose fallback would and still validate at dispatch.\\n`\n : \"\";\n return (\n \"// Generated from the captured extension tool catalog for this execution,\\n\" +\n \"// with the same advisory semantics as the generated mcp surface above.\\n\" +\n note +\n `interface FabricExtensionsApiDynamic {\\n${memberBlock.lines.join(\"\\n\")}\\n}\\n` +\n \"declare const extensions: FabricExtensionsApiDynamic;\\n\"\n );\n};\n\n// Renders replacement `declare const mcp` / `declare const extensions` blocks\n// for guestTypeDeclarations(). Missing or empty sections return undefined so\n// the loose static lines survive, matching cold-cache behavior.\n/** Bounded advisory declaration for native describeTool compatibility. */\nexport const describeFabricActionDeclaration = (name: string, inputSchema: Record<string, unknown>): string =>\n `${JSON.stringify(name)}: (args: ${schemaType(inputSchema, 0)}) => Promise<unknown>`;\n\nexport const buildDynamicGuestDeclarations = (\n sources: FabricGuestTypeSources,\n): FabricDynamicGuestDeclarations => {\n const dynamic: FabricDynamicGuestDeclarations = {};\n if (sources.mcpServers && sources.mcpServers.length > 0) {\n dynamic.mcp = renderMcpDeclaration(sources.mcpServers);\n }\n if (sources.extensionTools && sources.extensionTools.length > 0) {\n dynamic.extensions = renderExtensionsDeclaration(sources.extensionTools);\n }\n return dynamic;\n};\n"],
5
+ "mappings": ";;;;;AAgBA,IAAM,YAAY;AAClB,IAAM,oBAAoB;AAC1B,IAAM,0BAA0B;AAChC,IAAM,wBAAwB;AAC9B,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB;AACxB,IAAM,uBAAuB;AAC7B,IAAM,sBAAsB;AAE5B,IAAM,aAAa;AAEnB,IAAM,WAAW,CAAC,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,IAAM,cAAc,CAAC,SACnB,WAAW,KAAK,IAAI,IAAI,OAAO,KAAK,UAAU,IAAI;AAEpD,IAAM,cAAc,CAAC,UAA2B;AAC9C,MAAI,UAAU,KAAM,QAAO;AAC3B,MAAI,OAAO,UAAU,SAAU,QAAO,KAAK,UAAU,KAAK;AAC1D,MAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,EAAG,QAAO,KAAK,UAAU,KAAK;AACpF,MAAI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W,KAAK,IAAI,KACnB,WAAW,SAAS,IAAI,OAAO,MAChC;AAAA,EAAyB,WAAW,KAAK,IAAI,CAAC;AAAA;AAAA;AAElD;AAEA,IAAM,8BAA8B,CAClC,YACW;AACX,QAAM,SAA6B,EAAE,OAAO,kBAAkB;AAC9D,QAAM,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,OACJ,YAAY,UAAU,IAClB,cAAc,YAAY,OAAO;AAAA;AAAA,IACjC;AACN,SACE,yJAEA,OACA;AAAA,EAA2C,YAAY,MAAM,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA;AAG3E;AAMO,IAAM,kCAAkC,CAAC,MAAc,gBAC5D,GAAG,KAAK,UAAU,IAAI,CAAC,YAAY,WAAW,aAAa,CAAC,CAAC;AAExD,IAAM,gCAAgC,CAC3C,YACmC;AACnC,QAAM,UAA0C,CAAC;AACjD,MAAI,QAAQ,cAAc,QAAQ,WAAW,SAAS,GAAG;AACvD,YAAQ,MAAM,qBAAqB,QAAQ,UAAU;AAAA,EACvD;AACA,MAAI,QAAQ,kBAAkB,QAAQ,eAAe,SAAS,GAAG;AAC/D,YAAQ,aAAa,4BAA4B,QAAQ,cAAc;AAAA,EACzE;AACA,SAAO;AACT;",
6
6
  "names": ["type"]
7
7
  }
@@ -1,3 +1,44 @@
1
+ // src/runtime/native-codemode-types.ts
2
+ var NATIVE_CODEMODE_TYPES = `
3
+ type NativeModelType = "chat" | "image" | "classifier";
4
+ interface NativeModelInfo { type?: NativeModelType; provider: string; id: string; name: string; api: string; input: ("text" | "image")[]; contextWindow?: number; [key: string]: unknown }
5
+ type NativeModelSelector = { provider: string; id: string };
6
+ type NativeClassifierQuestion =
7
+ | { type: "choice"; instructions: string; criteria: Record<string, string> }
8
+ | { type: "score"; instructions: string; criteria: string[] }
9
+ | { type: "bool"; instructions: string; criteria: { true: string; false: string } };
10
+ type NativeClassifierAnswer =
11
+ | { type: "choice"; choice: string; probabilities: Record<string, number>; confidence: number }
12
+ | { type: "score"; score: number; confidence: number }
13
+ | { type: "bool"; probability: number };
14
+ interface NativeClassifierContext { state: Record<string, unknown>; questions: Record<string, NativeClassifierQuestion> }
15
+ interface NativeModelUsage { input: number; output: number; totalTokens: number; cost: { total: number } }
16
+ interface NativeClassifierResult { provider: string; model: string; answers: Record<string, NativeClassifierAnswer>; usage?: NativeModelUsage; stopReason: "stop" | "error" | "aborted"; errorMessage?: string }
17
+ type NativeImageBlock = { type: "image"; data: string; mimeType: string };
18
+ type NativeTextBlock = { type: "text"; text: string };
19
+ interface NativeImagesContext { input: (NativeImageBlock | NativeTextBlock)[] }
20
+ interface NativeImagesResult { provider: string; model: string; output: (NativeImageBlock | NativeTextBlock)[]; usage?: NativeModelUsage; stopReason: "stop" | "error" | "aborted"; errorMessage?: string }
21
+ interface FabricNativeModels {
22
+ (): Promise<FabricModelInfo[]>;
23
+ getModelsOfType(type: NativeModelType, provider?: string): Promise<NativeModelInfo[]>;
24
+ getAvailableOfType(type: NativeModelType, provider?: string): Promise<NativeModelInfo[]>;
25
+ getModelOfType(type: NativeModelType, provider: string, id: string): Promise<NativeModelInfo | undefined>;
26
+ classify(model: NativeModelSelector, context: NativeClassifierContext): Promise<NativeClassifierResult>;
27
+ generateImages(model: NativeModelSelector, context: NativeImagesContext): Promise<NativeImagesResult>;
28
+ }
29
+ interface NativeToolInfo { name: string; description: string }
30
+ declare const ALL_TOOLS: readonly NativeToolInfo[];
31
+ declare function searchTools(query: string, options?: { limit?: number; namespace?: string }): Promise<NativeToolInfo[]>;
32
+ declare function describeTool(name: string): Promise<(NativeToolInfo & { declaration: string }) | undefined>;
33
+ declare function describeNamespace(name: string): Promise<{ name: string; description?: string; instructions?: string; tools: NativeToolInfo[] } | undefined>;
34
+ declare const models: FabricNativeModels;
35
+ declare function store(key: string, value: unknown): void;
36
+ declare function load<T = unknown>(key: string): T | undefined;
37
+ declare function text(value: unknown): void;
38
+ declare function image(value: NativeImageBlock | string | { image_url: string | { url: string } }): void;
39
+ declare function exit(): never;
40
+ `;
41
+
1
42
  // src/jev/guest-types.ts
2
43
  var JEV_GUEST_DECLARATIONS = `
3
44
  type FabricJevJson = null | boolean | number | string | FabricJevJson[] | { [key: string]: FabricJevJson };
@@ -84,6 +125,7 @@ var PI_CORE_NUMERIC_FIELDS = {
84
125
  ls: ["limit"]
85
126
  };
86
127
  var GUEST_TYPE_DECLARATIONS = `
128
+ ${NATIVE_CODEMODE_TYPES}
87
129
  type JsonPrimitive = string | number | boolean | null;
88
130
  type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };
89
131
  type FabricTransport = "auto" | "process" | "tmux" | "screen" | "localterm" | "herdr";
@@ -475,7 +517,7 @@ interface FabricToolsApi {
475
517
  describe(args: { ref: string }): Promise<FabricAction>;
476
518
  call(args: { ref: string; args?: Record<string, unknown> }): Promise<unknown>;
477
519
  progress(args: { message: string }): Promise<void>;
478
- models(): Promise<FabricModelInfo[]>;
520
+ models: FabricNativeModels;
479
521
  }
480
522
  interface FabricCapturedToolResult {
481
523
  content: Array<{ type: string; text?: string; [key: string]: unknown }>;
@@ -1714,4 +1756,4 @@ export {
1714
1756
  GUEST_TYPE_DECLARATIONS,
1715
1757
  guestTypeDeclarations
1716
1758
  };
1717
- //# sourceMappingURL=chunk-TFFZVLR2.js.map
1759
+ //# sourceMappingURL=chunk-5HZJ5LTB.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/runtime/native-codemode-types.ts", "../../src/jev/guest-types.ts", "../../src/runtime/guest-types.ts"],
4
+ "sourcesContent": ["export const NATIVE_CODEMODE_TYPES = `\ntype NativeModelType = \"chat\" | \"image\" | \"classifier\";\ninterface NativeModelInfo { type?: NativeModelType; provider: string; id: string; name: string; api: string; input: (\"text\" | \"image\")[]; contextWindow?: number; [key: string]: unknown }\ntype NativeModelSelector = { provider: string; id: string };\ntype NativeClassifierQuestion =\n | { type: \"choice\"; instructions: string; criteria: Record<string, string> }\n | { type: \"score\"; instructions: string; criteria: string[] }\n | { type: \"bool\"; instructions: string; criteria: { true: string; false: string } };\ntype NativeClassifierAnswer =\n | { type: \"choice\"; choice: string; probabilities: Record<string, number>; confidence: number }\n | { type: \"score\"; score: number; confidence: number }\n | { type: \"bool\"; probability: number };\ninterface NativeClassifierContext { state: Record<string, unknown>; questions: Record<string, NativeClassifierQuestion> }\ninterface NativeModelUsage { input: number; output: number; totalTokens: number; cost: { total: number } }\ninterface NativeClassifierResult { provider: string; model: string; answers: Record<string, NativeClassifierAnswer>; usage?: NativeModelUsage; stopReason: \"stop\" | \"error\" | \"aborted\"; errorMessage?: string }\ntype NativeImageBlock = { type: \"image\"; data: string; mimeType: string };\ntype NativeTextBlock = { type: \"text\"; text: string };\ninterface NativeImagesContext { input: (NativeImageBlock | NativeTextBlock)[] }\ninterface NativeImagesResult { provider: string; model: string; output: (NativeImageBlock | NativeTextBlock)[]; usage?: NativeModelUsage; stopReason: \"stop\" | \"error\" | \"aborted\"; errorMessage?: string }\ninterface FabricNativeModels {\n (): Promise<FabricModelInfo[]>;\n getModelsOfType(type: NativeModelType, provider?: string): Promise<NativeModelInfo[]>;\n getAvailableOfType(type: NativeModelType, provider?: string): Promise<NativeModelInfo[]>;\n getModelOfType(type: NativeModelType, provider: string, id: string): Promise<NativeModelInfo | undefined>;\n classify(model: NativeModelSelector, context: NativeClassifierContext): Promise<NativeClassifierResult>;\n generateImages(model: NativeModelSelector, context: NativeImagesContext): Promise<NativeImagesResult>;\n}\ninterface NativeToolInfo { name: string; description: string }\ndeclare const ALL_TOOLS: readonly NativeToolInfo[];\ndeclare function searchTools(query: string, options?: { limit?: number; namespace?: string }): Promise<NativeToolInfo[]>;\ndeclare function describeTool(name: string): Promise<(NativeToolInfo & { declaration: string }) | undefined>;\ndeclare function describeNamespace(name: string): Promise<{ name: string; description?: string; instructions?: string; tools: NativeToolInfo[] } | undefined>;\ndeclare const models: FabricNativeModels;\ndeclare function store(key: string, value: unknown): void;\ndeclare function load<T = unknown>(key: string): T | undefined;\ndeclare function text(value: unknown): void;\ndeclare function image(value: NativeImageBlock | string | { image_url: string | { url: string } }): void;\ndeclare function exit(): never;\n`;\n", "export const JEV_GUEST_DECLARATIONS = `\ntype FabricJevJson = null | boolean | number | string | FabricJevJson[] | { [key: string]: FabricJevJson };\ntype FabricJevDescription = string | FabricJevJson[] | { [key: string]: FabricJevJson };\ntype FabricJevQuestion =\n | { type: \"noul\"; instructions: FabricJevDescription; criteria?: { true?: FabricJevDescription; false?: FabricJevDescription } }\n | { type: \"choice\"; instructions: FabricJevDescription; criteria: Record<string, FabricJevDescription | null> }\n | { type: \"score\"; instructions: FabricJevDescription; criteria: FabricJevDescription[] };\ntype FabricJevAnswer<Q extends FabricJevQuestion> = Q extends { type: \"noul\" }\n ? { type: \"noul\"; noul: number }\n : Q extends { type: \"choice\"; criteria: infer C }\n ? { type: \"choice\"; choice: Extract<keyof C, string>; confidence: number; probabilities: Record<Extract<keyof C, string>, number> }\n : { type: \"score\"; score: number; confidence: number; probabilities: Record<string, number>; legend: Record<string, FabricJevJson> };\ninterface FabricJevProgram {\n name: string;\n code: string;\n inputSchema: Record<string, unknown>;\n outputSchema: Record<string, unknown>;\n requires: string[];\n limits?: { timeoutMs?: number; maxEvaluations?: number; maxToolCalls?: number; maxTokens?: number };\n}\ntype FabricJevHostEventName = \"input\" | \"turn_end\" | \"tool_error\" | \"agent_end\" | \"agent_settled\";\ninterface FabricJevObserve {\n events: FabricJevHostEventName[];\n include?: Array<\"inputText\" | \"assistantText\" | \"toolResults\">;\n maxChars?: number; queueSize?: number; maxEventAgeMs?: number;\n delivery?: \"steer\" | \"followUp\"; triggerTurn?: boolean; maxAdvice?: number;\n}\ninterface FabricJevHostEvent {\n id: string; sequence: number; event: FabricJevHostEventName; source: \"main\";\n sessionId: string; revision: number; at: number; payload: FabricJevJson; truncated: boolean;\n}\ninterface FabricJevObservationStats {\n events: FabricJevHostEventName[]; received: number; consumed: number; dropped: number; queued: number;\n adviceDelivered: number; adviceSuppressed: number;\n}\ninterface FabricJevAdviceResult {\n delivered: boolean;\n reason?: \"disabled\" | \"stale\" | \"duplicate\" | \"budget\" | \"feedback\" | \"delivery_failed\";\n}\ninterface FabricJevRun<T = unknown> {\n id: string; name: string; state: \"running\" | \"completed\" | \"failed\" | \"cancelled\" | \"timed_out\";\n background: boolean; startedAt: number; endedAt?: number; result?: T; error?: string;\n evaluations: number; toolCalls: number; usage: { input_tokens: number; output_tokens: number };\n events: Array<{ sequence: number; at: number; value: FabricJevJson }>; nextSequence: number; logs: string[];\n observation?: FabricJevObservationStats;\n}\ninterface FabricJevApi {\n evaluate<Q extends Record<string, FabricJevQuestion>>(args: {\n state: string | FabricJevJson[] | { [key: string]: FabricJevJson }; questions: Q; model?: string;\n }): Promise<{ model: string; answers: { [K in keyof Q]: FabricJevAnswer<Q[K]> }; usage: { input_tokens: number; output_tokens: number } }>;\n run<T = unknown>(args: { program: FabricJevProgram; input: FabricJevJson }): Promise<FabricJevRun<T>>;\n spawn(args: { program: FabricJevProgram; input: FabricJevJson; observe?: FabricJevObserve }): Promise<FabricJevRun>;\n status(args?: { id?: never; after?: never }): Promise<{ credentials: { configured: boolean; source: \"pi\" | \"environment\" | \"command\" | \"missing\"; verified: boolean }; model: string; runs: Array<{ id: string; name: string; state: string; background: boolean; startedAt: number; evaluations: number; toolCalls: number; observation?: FabricJevObservationStats }> }>;\n status<T = unknown>(args: { id: string; after?: number }): Promise<FabricJevRun<T>>;\n wait<T = unknown>(args: { id: string }): Promise<FabricJevRun<T>>;\n /** Alias for wait. */\n join<T = unknown>(args: { id: string }): Promise<FabricJevRun<T>>;\n advise(args: { id: string; eventId: string; message: string }): Promise<FabricJevAdviceResult>;\n stop(args: { id: string }): Promise<FabricJevRun>;\n}\ndeclare const jev: FabricJevApi;\n`;\n", "import type { FabricDynamicGuestDeclarations } from \"../protocol.js\";\nimport { NATIVE_CODEMODE_TYPES } from \"./native-codemode-types.js\";\nimport { JEV_GUEST_DECLARATIONS } from \"../jev/guest-types.js\";\n\n// These names and compatibility fields are the single source of truth for\n// generated core-override overloads. Keep them beside PiToolsApi below so an\n// override extends the same guest contract rather than copying its signatures.\n// Numeric fields widen to `number | string` in generated overloads too,\n// mirroring built-in runtime normalization; a strict override schema still\n// rejects the string form at validation time, and the registry error wins.\nexport const PI_CORE_COMPATIBILITY_ARGUMENT_TYPE_NAMES = {\n read: \"PiReadCompatibilityArgument\",\n bash: \"PiBashCompatibilityArgument\",\n powershell: \"PiPowerShellCompatibilityArgument\",\n edit: \"PiEditCompatibilityArgument\",\n write: \"PiWriteCompatibilityArgument\",\n grep: \"PiGrepCompatibilityArgument\",\n find: \"PiFindCompatibilityArgument\",\n ls: \"PiLsCompatibilityArgument\",\n} as const;\n\nexport const PI_CORE_NUMERIC_FIELDS = {\n read: [\"offset\", \"limit\"],\n bash: [\"timeout\"],\n powershell: [\"timeout\"],\n edit: [],\n write: [],\n grep: [\"context\", \"limit\"],\n find: [\"limit\"],\n ls: [\"limit\"],\n} as const;\n\nexport const GUEST_TYPE_DECLARATIONS = `\n${NATIVE_CODEMODE_TYPES}\ntype JsonPrimitive = string | number | boolean | null;\ntype JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };\ntype FabricTransport = \"auto\" | \"process\" | \"tmux\" | \"screen\" | \"localterm\" | \"herdr\";\ntype FabricAgentRunner = \"pi\" | \"claude\" | \"veda\" | (string & {});\ntype FabricKernel = \"typescript\" | \"python\";\ntype FabricThinking = \"off\" | \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\";\ninterface FabricActionEffect {\n kind: \"none\" | \"scoped\" | \"transactional\" | \"emission\";\n resources?: string[];\n ordering?: \"commutative\" | \"ordered\" | \"unknown\";\n}\ninterface FabricAction {\n ref: string;\n provider: string;\n name: string;\n description: string;\n inputSchema: Record<string, unknown>;\n outputSchema?: Record<string, unknown>;\n risk: \"read\" | \"write\" | \"execute\" | \"network\" | \"agent\";\n namespace?: string;\n effect?: FabricActionEffect;\n}\ninterface FabricAgentRequest {\n /** Omitted/inherit uses caller executor.kernel; concrete choices require Pi with extensions. */\n kernel?: FabricKernel | \"inherit\";\n task: string;\n name?: string;\n runner?: FabricAgentRunner;\n transport?: FabricTransport;\n model?: string;\n persona?: string;\n thinking?: FabricThinking;\n /** Child thinking bounds; must lie inside this session's bounds. Levels outside are clamped. */\n thinkingBounds?: FabricThinkingBounds;\n tools?: string[];\n timeoutMs?: number;\n extensions?: boolean;\n recursive?: boolean;\n /** Filesystem execution directory; relative paths resolve from the parent agent cwd. */\n cwd?: string;\n worktree?: boolean;\n /** Shell command run in the new worktree before launch. */\n worktreeSetup?: string;\n /** Pi only. branch: fork this conversation (last completed turn); snippet: prefix recent messages. */\n seed?: \"task\" | \"branch\" | \"snippet\";\n seedMessages?: number;\n /** Pi only write confinement; bash needs shell: \"unconfined\". */\n readOnly?: boolean;\n writableRoots?: string[];\n shell?: \"deny\" | \"unconfined\";\n /** Narrow the host-issued scope; omitted inherits it. Refused when this session is unscoped. */\n scope?: { grants: { resource: string; actions: (\"read\" | \"write\" | \"execute\")[] }[] };\n schema?: Record<string, unknown>;\n prompt?: string;\n instructions?: string;\n timeout_ms?: number;\n residency?: FabricParticipantResidency;\n /** Opt in to session persistence for hook-based observability and external trace ingestion. */\n persistSession?: boolean;\n}\ninterface FabricHandoffCall {\n readonly ref: string;\n}\ninterface FabricHandoffFacts {\n readonly calls: readonly FabricHandoffCall[];\n count(ref?: string | readonly string[]): number;\n}\ntype FabricHandoffPredicate = (facts: Readonly<FabricHandoffFacts>) => boolean;\ninterface FabricHandoffRequest {\n kernel?: FabricKernel | \"inherit\";\n model: string;\n task?: string;\n when?: FabricHandoffPredicate;\n name?: string;\n transport?: FabricTransport;\n thinking?: FabricThinking;\n tools?: string[];\n timeoutMs?: number;\n extensions?: boolean;\n recursive?: boolean;\n schema?: Record<string, unknown>;\n prompt?: string;\n instructions?: string;\n timeout_ms?: number;\n}\ninterface FabricHandoffResult {\n scheduled: true;\n status: \"deferred\";\n boundary: \"fabric_exec_end\";\n}\ninterface FabricMainAgentInfo {\n id: string;\n name: \"Main\";\n kind: \"main\";\n status: \"idle\" | \"running\" | \"remote\";\n runner: \"pi\";\n transport: \"host\";\n cwd?: string;\n sessionId?: string;\n model?: string;\n thinking?: string;\n startedAt?: number;\n updatedAt: number;\n pendingMessages: boolean;\n local: boolean;\n}\ninterface FabricPeerInfo {\n id: string;\n name: string;\n kind: \"peer\";\n status: \"idle\" | \"running\";\n runner: \"pi\";\n transport: \"host\";\n cwd: string;\n sessionId: string;\n model?: string;\n thinking?: string;\n startedAt: number;\n updatedAt: number;\n pendingMessages: boolean;\n local: false;\n}\ntype FabricParticipantKind = \"root\" | \"agent\" | \"actor\";\ntype FabricParticipantResidency = \"session\" | \"durable\";\ntype FabricParticipantScope = \"local\" | \"lineage\" | \"project\";\ntype FabricParticipantCapability = \"steer\" | \"followUp\" | \"stop\" | \"ask\" | \"actor-bindings\" | \"attach\" | \"fabric\";\ninterface FabricParticipantInfo {\n format: 1;\n id: string;\n kind: FabricParticipantKind | \"provider\";\n rootId: string;\n ownerHostId: string;\n ownerIdentityId: string;\n ownerIncarnation?: string;\n parentId?: string;\n name: string;\n status: string;\n runner?: FabricAgentRunner;\n provider?: string;\n transport: FabricTransport | \"host\";\n capabilities: FabricParticipantCapability[];\n cwd?: string;\n sessionId?: string;\n model?: string;\n thinking?: string;\n startedAt: number;\n updatedAt: number;\n finishedAt?: number;\n pendingMessages?: boolean;\n currentTool?: string;\n turns?: number;\n toolCalls?: number;\n usage?: { input: number; output: number; cacheRead: number; cacheWrite: number; cost: number };\n actorQueued?: number;\n actorMessages?: number;\n controlProtocol: \"v1\" | \"legacy\";\n residency: FabricParticipantResidency;\n local: boolean;\n stale: boolean;\n}\ntype FabricLifecycleEventType =\n | \"pi.input\"\n | \"pi.agent_start\"\n | \"pi.agent_end\"\n | \"pi.turn_end\"\n | \"pi.agent_settled\"\n | \"pi.tool_error\"\n | \"pi.session_compact\"\n | \"run.completed\"\n | \"run.failed\"\n | \"run.stopped\"\n | \"run.timed_out\"\n | \"run.resumed\"\n | \"run.detached\"\n | \"tokens.usage\"\n | \"component.state\";\ntype FabricLifecycleDelivery = \"steer\" | \"followUp\";\ninterface FabricLifecycleSource {\n id: string;\n name: string;\n kind: FabricParticipantKind;\n rootId: string;\n runner: FabricAgentRunner;\n ownerHostId?: string;\n ownerIdentityId?: string;\n}\ninterface FabricLifecycleEvent {\n version: 1;\n id: string;\n sequence: number;\n event: FabricLifecycleEventType;\n source: FabricLifecycleSource;\n occurredAt: number;\n publishedAt: number;\n runId?: string;\n status?: string;\n data?: unknown;\n}\ninterface FabricLifecycleSubscription {\n format: 1;\n id: string;\n from: string;\n events: FabricLifecycleEventType[];\n to: string;\n delivery: FabricLifecycleDelivery;\n triggerTurn: boolean;\n once: boolean;\n afterSequence: number;\n createdAt: number;\n updatedAt: number;\n createdBy: { id: string; name: string; kind: \"main\" | \"agent\" | \"actor\"; sessionId?: string };\n lastDeliveredAt?: number;\n lastEventId?: string;\n lastError?: string;\n}\ninterface FabricAgentHandle {\n /** Resolved Fabric kernel, absent for non-Fabric runners. */\n kernel?: FabricKernel;\n id: string;\n name: string;\n status: string;\n runner: FabricAgentRunner;\n /** Local execution metadata is absent for hosted participants. */\n transport?: FabricTransport;\n cwd?: string;\n rootId?: string;\n parentId?: string;\n depth?: number;\n generation?: number;\n model?: string;\n thinking?: FabricThinking;\n /** Present only when the requested level was clamped into thinking bounds. */\n requestedThinking?: FabricThinking;\n actorId?: string;\n actorName?: string;\n sessionId?: string;\n runnerSessionId?: string;\n attachCommand?: string;\n branch?: string;\n worktree?: string;\n text?: string;\n value?: unknown;\n error?: string;\n logFile?: string;\n residency?: FabricParticipantResidency;\n}\ninterface FabricRemoteControlResult {\n queued: true;\n messageId: string;\n routed: \"mesh\";\n acknowledged: true;\n}\ninterface FabricAgentResult extends FabricAgentHandle {\n task: string;\n startedAt: number;\n finishedAt?: number;\n turns: number;\n toolCalls: number;\n text: string;\n value?: unknown;\n error?: string;\n usage: { input: number; output: number; cacheRead: number; cacheWrite: number; cost: number };\n pendingMessages?: { steering: string[]; followUp: string[] };\n /** worktree: true runs; worktree stays the path. */\n worktreeResult?: {\n path: string; branch?: string; baseRef?: string; changedFiles: string[];\n diffstat: { files: number; insertions: number; deletions: number }; kept: boolean; diffError?: string;\n };\n}\ninterface FabricModelInfo {\n runner?: FabricAgentRunner;\n provider: string;\n id: string;\n name: string;\n key: string;\n value?: string;\n resolvedModel?: string;\n displayName?: string;\n description?: string;\n supportsEffort?: boolean;\n supportedEffortLevels?: string[];\n supportsAdaptiveThinking?: boolean;\n supportsFastMode?: boolean;\n supportsAutoMode?: boolean;\n}\ninterface FabricLogLine {\n index?: number;\n offset: number;\n raw: string;\n parsed?: unknown;\n}\ninterface FabricAgentLog {\n id: string;\n runDirectory: string;\n logFile: string;\n status?: FabricAgentResult;\n events: FabricLogLine[];\n hasMore: boolean;\n before?: number;\n}\ninterface FabricActorLog {\n actorId: string;\n actorName: string;\n sessionFile: string;\n logDir: string;\n session: FabricLogLine[];\n sessionHasMore: boolean;\n sessionBefore?: number;\n run?: {\n runId: string;\n eventsFile: string;\n status?: FabricAgentResult;\n events: FabricLogLine[];\n hasMore: boolean;\n before?: number;\n };\n retainedRuns: string[];\n}\ninterface FabricCapabilityActionHead {\n key: string;\n parentKey: string;\n ref: string;\n name: string;\n description: string;\n descriptorHash: string;\n risk: \"read\" | \"write\" | \"execute\" | \"network\" | \"agent\";\n namespace?: string;\n effect?: FabricActionEffect;\n}\ninterface FabricCapabilityProviderHead {\n key: string;\n parentKey: string;\n name: string;\n description: string;\n descriptorHash: string;\n actions: FabricCapabilityActionHead[];\n}\ninterface FabricCapabilityCatalog {\n kind: \"pi-fabric.capability-catalog\";\n version: 1;\n root: {\n key: \"capability:fabric\";\n name: \"Fabric capabilities\";\n description: string;\n descriptorHash: string;\n };\n providers: FabricCapabilityProviderHead[];\n totalActions: number;\n indexedActions: number;\n complete: boolean;\n reasons: string[];\n}\ninterface FabricToolsApi {\ninterface FabricActionListEnvelope {\n kind: \"pi-fabric.action-list\";\n version: 1;\n actions: FabricAction[];\n /** Full visible-action count before paging. */\n total: number;\n /** True when total exceeds the returned page: more actions exist. */\n truncated: boolean;\n limit: number;\n}\ninterface FabricActionSearchBackend {\n requested: \"semantic\";\n used: \"semantic\" | \"lexical\";\n degraded: boolean;\n model?: string;\n usage?: { inputTokens: number; outputTokens: number };\n abstained?: boolean;\n reason?: \"timeout\" | \"rate_limited\" | \"service_unavailable\";\n}\ninterface FabricActionSearchEnvelope {\n kind: \"pi-fabric.action-search\";\n version: 1;\n actions: FabricAction[];\n backend: FabricActionSearchBackend;\n}\ninterface FabricToolsApi {\n providers(): Promise<Array<{ name: string; description: string }>>;\n catalog(args?: { provider?: string; limit?: number }): Promise<FabricCapabilityCatalog>;\n /**\n * Capped discovery page: default 100 entries, silently truncated (hard cap\n * 1000). A short result never proves an action is absent \u2014 confirm with\n * search() or pass envelope: true to get totals and a truncated flag.\n */\n list(args?: { provider?: string; namespace?: string; query?: string; limit?: number; envelope?: boolean }): Promise<FabricAction[] | FabricActionListEnvelope>;\n search(args: { query: string; limit?: number; searchMode?: \"lexical\" | \"semantic\" }): Promise<FabricAction[] | FabricActionSearchEnvelope>;\n describe(args: { ref: string }): Promise<FabricAction>;\n call(args: { ref: string; args?: Record<string, unknown> }): Promise<unknown>;\n progress(args: { message: string }): Promise<void>;\n models: FabricNativeModels;\n}\ninterface FabricCapturedToolResult {\n content: Array<{ type: string; text?: string; [key: string]: unknown }>;\n text: string;\n details?: unknown;\n isError: boolean;\n terminate?: boolean;\n source: { path: string; source: string; scope: string; origin: string; baseDir?: string };\n}\ninterface FabricCapturedTool {\n (args?: Record<string, unknown>): Promise<FabricCapturedToolResult>;\n}\ntype FabricExtensionsApi = Record<string, FabricCapturedTool>;\n// String-primary tools (read/bash/powershell/grep/find/ls) accept a bare string; the\n// runtime proxy coerces it to { <primaryField>: string }. Lets the model write\n// the natural form (pi.bash(\"ls\")) instead of pi.bash({ command: \"ls\" }).\n// Return shapes differ by tool: read/grep/find/ls return their text as a bare\n// string (e.g. const src: string = await pi.read({ path })); shell/edit/write\n// return { ok, output, details } (e.g. const { output } = await pi.bash(...)).\n// Common alias keys (cmd\u2192command, query\u2192pattern, file\u2192path, dir\u2192path) and a\n// flat edit shape ({ path, oldText, newText }) are also accepted; the runtime\n// proxy normalizes them to the canonical form before the host validates args.\n// Bash timeout is measured in seconds; timeoutMs is converted from milliseconds.\n// After executor.shellHangMs the await still resolves ok: true with a still-running\n// notice, pid, and live output path in details; background: true (alias\n// run_in_background) detaches immediately. The process keeps writing that file.\n// Extended near-miss repairs: find's name/filename/glob \u2192 pattern, write's\n// data \u2192 content, ls's folder \u2192 path, bash's script \u2192 command; numeric option\n// fields (limit/offset/context/timeout) also accept numeric strings, coerced\n// at runtime (2322 diagnostics are suppressed by the type-checker by design).\n// String-primary tools also take a two-arg (primary, options) form \u2014\n// pi.read(\"index.ts\", { limit: 120 }) merges to { path, ...options } at\n// runtime, the positional string winning the primary field on conflict.\n// shell/edit/write envelopes are proxy-guarded so string-method access\n// (.trim(), .split(), iteration) fails with an actionable TypeError pointing\n// at .output instead of QuickJS's context-free \"not a function\" \u2014 property-\n// miss (2339) checks are suppressed by design, so the runtime gives the hint.\ntype PiPathArgument = {\n path?: string;\n file?: string;\n absolutePath?: string;\n file_path?: string;\n filePath?: string;\n filepath?: string;\n pathname?: string;\n target_file?: string;\n targetFile?: string;\n absolute_path?: string;\n fileAbsolutePath?: string;\n};\ntype PiOptionalPathArgument = {\n path?: string;\n file?: string;\n absolutePath?: string;\n file_path?: string;\n filePath?: string;\n filepath?: string;\n pathname?: string;\n target_file?: string;\n targetFile?: string;\n absolute_path?: string;\n fileAbsolutePath?: string;\n dir?: string;\n folder?: string;\n directory?: string;\n directoryPath?: string;\n};\ntype PiOldTextArgument = {\n oldText?: string;\n old?: string;\n old_string?: string;\n oldString?: string;\n old_str?: string;\n oldStr?: string;\n from?: string;\n old_value?: string;\n old_text?: string;\n oldContent?: string;\n old_content?: string;\n};\ntype PiNewTextArgument = {\n newText?: string;\n new?: string;\n replacement?: string;\n new_string?: string;\n newString?: string;\n new_str?: string;\n newStr?: string;\n to?: string;\n new_value?: string;\n new_text?: string;\n newContent?: string;\n new_content?: string;\n};\ntype PiEditOperation = PiOldTextArgument & PiNewTextArgument & { all?: boolean };\ntype PiCommandArgument = { command?: string; cmd?: string; shell?: string; cmdline?: string; script?: string; commandLine?: string };\ntype PiContentArgument = { content?: string; contents?: string; body?: string; text?: string; data?: string; fileContent?: string };\ntype PiGrepPatternArgument = { pattern?: string; query?: string; regex?: string; search?: string; q?: string; expression?: string; text?: string };\ntype PiFindPatternArgument = { pattern?: string; query?: string; regex?: string; search?: string; name?: string; filename?: string; glob?: string; expression?: string; include?: string };\n// Two-arg (primary, options) bags for the string-primary tools. Only option\n// aliases belong here (max/start/ctx/ic/...), never primary-field aliases \u2014\n// the primary field comes from the positional string.\ntype PiReadOptions = { offset?: number; limit?: number; start?: number; max?: number };\n// cwd is honored per call by the pi provider, which binds the command to a\n// shell definition rooted there; relative paths resolve from the session cwd.\n// The alias spellings mirror the shell entries in __piArgAliases: the\n// runtime repairs them, so the checker has to accept the same spellings or a\n// repairable call is rejected before it ever reaches the sandbox.\ntype PiShellOptions = {\n timeout?: number; timeoutMs?: number; settle?: boolean;\n background?: boolean; run_in_background?: boolean;\n description?: string;\n /** Opt-in line events; implies background. ui never wakes the model; wake may start an owning-agent turn. */\n monitor?: { delivery: \"ui\" | \"wake\"; timeoutMs?: number; intervalMs?: number; match?: string };\n cwd?: string; workdir?: string; directory?: string; workingDirectory?: string;\n};\ntype PiBashOptions = PiShellOptions & {\n /** Owned by an external jev-fabric store (macOS/Linux): keeps running if Pi exits and reattaches on resume. Implies background. */\n durable?: boolean;\n /** Durable only: on exit publish {kind ?? \"task.completed\", data:{taskId, exitCode, description?}}. */\n notify?: { topic: string; kind?: string };\n};\ntype PiPowerShellOptions = PiShellOptions;\ntype PiGrepOptions = { path?: string; glob?: string; globPattern?: string; ignoreCase?: boolean; ic?: boolean; caseInsensitive?: boolean; literal?: boolean; context?: number; ctx?: number; limit?: number; max?: number };\ntype PiFindOptions = { path?: string; limit?: number; max?: number };\ntype PiLsOptions = { limit?: number; max?: number };\ntype PiReadArgument = string | (PiPathArgument & PiReadOptions);\ntype PiBashArgument = string | (PiCommandArgument & PiBashOptions);\ntype PiPowerShellArgument = string | (PiCommandArgument & PiPowerShellOptions);\ntype PiEditFlatArgument = PiPathArgument & PiOldTextArgument & PiNewTextArgument & { all?: boolean };\ntype PiEditArgument = PiPathArgument & ({ edits: PiEditOperation[]; all?: boolean } | PiEditFlatArgument);\ntype PiWriteArgument = string | (PiPathArgument & PiContentArgument);\ntype PiGrepArgument = string | (PiGrepPatternArgument & PiGrepOptions);\ntype PiFindArgument = string | (PiFindPatternArgument & PiFindOptions);\ntype PiLsArgument = string | (PiOptionalPathArgument & PiLsOptions);\ntype PiNumericString<T> = T extends number ? T | string : T;\ntype PiNumericStringOptions<T> = { [K in keyof T]: PiNumericString<T[K]> };\ntype PiReadCompatibilityArgument = string | (PiPathArgument & PiNumericStringOptions<PiReadOptions>);\ntype PiBashCompatibilityArgument = string | (PiCommandArgument & PiNumericStringOptions<PiBashOptions>);\ntype PiPowerShellCompatibilityArgument = string | (PiCommandArgument & PiNumericStringOptions<PiPowerShellOptions>);\ntype PiEditCompatibilityArgument = PiEditFlatArgument;\ntype PiWriteCompatibilityArgument = PiWriteArgument;\ntype PiGrepCompatibilityArgument = string | (PiGrepPatternArgument & PiNumericStringOptions<PiGrepOptions>);\ntype PiFindCompatibilityArgument = string | (PiFindPatternArgument & PiNumericStringOptions<PiFindOptions>);\ntype PiLsCompatibilityArgument = string | (PiOptionalPathArgument & PiNumericStringOptions<PiLsOptions>);\ninterface PiToolsApi {\n read(args: PiReadArgument, options?: PiReadOptions): Promise<string>;\n bash(args: PiBashArgument, options?: PiBashOptions): Promise<{ ok: true; output: string; details: unknown } | { ok: false; output: string; details: null; exitCode: number; error: string }>;\n powershell(args: PiPowerShellArgument, options?: PiPowerShellOptions): Promise<{ ok: true; output: string; details: unknown } | { ok: false; output: string; details: null; exitCode: number; error: string }>;\n edit(args: PiEditArgument): Promise<{ ok: true; output: string; details: unknown }>;\n edit(path: string, oldText: string, newText: string): Promise<{ ok: true; output: string; details: unknown }>;\n write(args: PiWriteArgument): Promise<{ ok: true; output: string; details: unknown }>;\n write(path: string, content: string): Promise<{ ok: true; output: string; details: unknown }>;\n grep(args: PiGrepArgument): Promise<string>;\n grep(pattern: string, path?: string | PiGrepOptions, limit?: number): Promise<string>;\n find(args: PiFindArgument): Promise<string>;\n find(pattern: string, path?: string | PiFindOptions, limit?: number): Promise<string>;\n ls(args?: PiLsArgument, options?: PiLsOptions): Promise<string>;\n}\ntype FabricActorHostEvent =\n | \"resources_discover\"\n | \"session_start\"\n | \"session_info_changed\"\n | \"session_before_switch\"\n | \"session_before_fork\"\n | \"session_before_compact\"\n | \"session_compact\"\n | \"session_shutdown\"\n | \"session_before_tree\"\n | \"session_tree\"\n | \"input\"\n | \"before_agent_start\"\n | \"agent_start\"\n | \"agent_end\"\n | \"agent_settled\"\n | \"turn_start\"\n | \"turn_end\"\n | \"message_start\"\n | \"message_update\"\n | \"message_end\"\n | \"context\"\n | \"before_provider_headers\"\n | \"before_provider_request\"\n | \"after_provider_response\"\n | \"tool_execution_start\"\n | \"tool_call\"\n | \"tool_execution_update\"\n | \"tool_result\"\n | \"tool_execution_end\"\n | \"model_select\"\n | \"thinking_level_select\"\n | \"user_bash\"\n | \"tool_error\";\ntype FabricActorDelivery = \"mailbox\" | \"steer\" | \"followUp\" | \"nextTurn\";\ninterface FabricActorHostMediaDescriptor {\n readonly type: \"image\";\n readonly mediaIndex: number;\n readonly mimeType: string;\n}\ninterface FabricActorHostSignal {\n readonly payload: unknown;\n readonly media?: readonly FabricActorHostMediaDescriptor[];\n readonly idle: boolean;\n readonly observedAt: number;\n}\ntype FabricActorActivation =\n | { readonly kind: \"hostEvent\"; readonly id: string; readonly source: string; readonly sequence: number; readonly createdAt: number; readonly event: FabricActorHostEvent; readonly mainRevision: number; readonly taskRevision: number; readonly signal?: FabricActorHostSignal }\n | { readonly kind: \"direct\"; readonly id: string; readonly source: string; readonly sequence: number; readonly createdAt: number }\n | { readonly kind: \"mesh\"; readonly id: string; readonly source: string; readonly sequence: number; readonly createdAt: number; readonly topic: string };\ninterface FabricActorValidityFacts {\n readonly activation: Readonly<FabricActorActivation>;\n readonly current: Readonly<{ latestActivationSequence: number; mainRevision: number; taskRevision: number; idle: boolean; now: number }>;\n}\ntype FabricActorValidityDecision = boolean | { valid: boolean; reason?: string };\ntype FabricActorBindingScope = \"session\" | \"project\";\ninterface FabricActorRunBinding { model?: string; thinking?: FabricThinking }\ntype FabricActorValidWhile = (facts: Readonly<FabricActorValidityFacts>) => FabricActorValidityDecision;\ninterface FabricActorRequestBase {\n /** Fixed at creation; ask/tell cannot change language. Global templates resolve inheritance on import. */\n kernel?: FabricKernel | \"inherit\";\n scope?: \"session\" | \"project\" | \"global\";\n name: string;\n instructions: string;\n events?: FabricActorHostEvent[];\n topics?: string[];\n responseMode?: \"text\" | \"directive\";\n coalesce?: boolean;\n runner?: FabricAgentRunner;\n model?: string;\n thinking?: FabricThinking;\n tools?: string[];\n transport?: FabricTransport;\n timeoutMs?: number;\n timeout_ms?: number;\n extensions?: boolean;\n requires?: Array<string | { ref: string; optional?: boolean }>;\n validWhile?: FabricActorValidWhile;\n residency?: FabricParticipantResidency;\n}\ntype FabricActorRequest = FabricActorRequestBase & (\n | { delivery?: \"mailbox\"; triggerTurn?: false }\n | { delivery: \"nextTurn\"; triggerTurn?: false }\n | { delivery: \"steer\" | \"followUp\"; triggerTurn: boolean }\n);\ninterface FabricActorInfo {\n kernel?: FabricKernel;\n pythonRuntime?: \"cpython\" | \"monty\";\n id: string;\n scope: \"session\" | \"project\";\n name: string;\n status: \"idle\" | \"queued\" | \"running\" | \"stopped\";\n runner: FabricAgentRunner;\n events: FabricActorHostEvent[];\n topics: string[];\n delivery: FabricActorDelivery;\n responseMode: \"text\" | \"directive\";\n triggerTurn: boolean;\n coalesce: boolean;\n model?: string;\n thinking?: FabricThinking;\n binding?: FabricActorRunBinding & { scope: \"session\"; sessionId: string; updatedAt?: number };\n projectDefaults?: FabricActorRunBinding & { scope: \"project\" };\n tools?: string[];\n timeoutMs?: number;\n extensions?: boolean;\n requirements?: Array<{ ref: string; optional?: boolean }>;\n capabilityDigest?: string;\n missingCapabilities?: string[];\n validWhile?: { version: 1; source: string };\n residency: FabricParticipantResidency;\n queued: number;\n messages: number;\n createdAt: number;\n updatedAt: number;\n lastRunId?: string;\n lastError?: string;\n sessionFile?: string;\n logDir?: string;\n}\ninterface FabricModelSwitchRequest {\n /** provider/id, a models.aliases name, or a search term; resolution tries aliases first, then exact matches, then the closest fuzzy match (recency from pi-model-sort breaks ties) against authenticated models. */\n model: string;\n /** Optional provider filter applied before matching (e.g. \"anthropic\"). */\n provider?: string;\n}\ninterface FabricModelSwitchResult {\n switched: boolean;\n /** Active model as provider/id after the call (unchanged when reason is \"already-active\"). */\n model: string;\n name?: string;\n /** Previously active provider/id when known. Absent for already-active results. */\n previous?: string;\n /** Set when the selector resolved through a configured models.aliases name. */\n alias?: string;\n /** How the selector resolved: the alias name, or one of closest/recent/latest for inexact picks. Absent for exact provider/id or bare-id matches. */\n via?: string;\n reason?: \"already-active\";\n}\ninterface FabricActorMessage {\n id: string;\n actorId: string;\n actorName: string;\n direction: \"in\" | \"out\";\n source: string;\n createdAt: number;\n text?: string;\n data?: unknown;\n action?: \"silent\" | \"message\" | \"stop\";\n runId?: string;\n error?: string;\n stale?: boolean;\n reason?: string;\n}\n// agentId/agent_id spellings repair to id during agent arg normalization.\ntype FabricAgentTargetArgs = { id: string; agentId?: string; agent_id?: string };\ninterface FabricAgentsApi {\n run(args: FabricAgentRequest): Promise<FabricAgentResult>;\n /** Hosted capability only; resumes a paused direct child without exposing its checkpoint. */\n resume(args: FabricAgentTargetArgs & { task?: string }): Promise<FabricAgentResult>;\n handoff(args: FabricHandoffRequest): Promise<FabricHandoffResult>;\n spawn(args: FabricAgentRequest): Promise<FabricAgentHandle>;\n wait(args: FabricAgentTargetArgs): Promise<FabricAgentResult>;\n /** Alias for wait. */\n join(args: FabricAgentTargetArgs): Promise<FabricAgentResult>;\n status(args: FabricAgentTargetArgs): Promise<FabricAgentResult | FabricAgentHandle | FabricMainAgentInfo | FabricActorInfo | FabricParticipantInfo>;\n list(args?: { scope?: FabricParticipantScope }): Promise<Array<FabricAgentResult | FabricAgentHandle | FabricParticipantInfo>>;\n members(args?: { scope?: FabricParticipantScope; kinds?: FabricParticipantKind[]; includeStale?: boolean }): Promise<FabricParticipantInfo[]>;\n /** lineage mirrors PI_FABRIC_LINEAGE in child workers. */\n self(): Promise<FabricParticipantInfo & { lineage?: {\n version: 1; rootSessionId: string; parentSessionId?: string; parentRunId?: string;\n runId: string; depth: number; childIndex: number; worker: true;\n } }>;\n main(): Promise<FabricMainAgentInfo>;\n sessions(): Promise<FabricParticipantInfo[]>;\n peers(): Promise<FabricPeerInfo[]>;\n subscribe(args: {\n from: string;\n events: FabricLifecycleEventType[];\n to?: string;\n delivery: FabricLifecycleDelivery;\n triggerTurn: boolean;\n once?: boolean;\n }): Promise<FabricLifecycleSubscription>;\n subscriptions(args?: { from?: string; to?: string }): Promise<FabricLifecycleSubscription[]>;\n unsubscribe(args: FabricAgentTargetArgs): Promise<{ removed: boolean }>;\n models(args?: { runner?: FabricAgentRunner; refresh?: boolean }): Promise<FabricModelInfo[]>;\n stop(args: FabricAgentTargetArgs): Promise<FabricAgentResult | FabricActorInfo | FabricRemoteControlResult>;\n cleanup(args: FabricAgentTargetArgs & { deleteBranch?: boolean; delete_branch?: boolean }): Promise<{ cleaned: boolean }>;\n create(args: FabricActorRequest): Promise<FabricActorInfo>;\n setModel(args: { id: string; model?: string; scope?: FabricActorBindingScope }): Promise<FabricActorInfo>;\n switchModel(args: FabricModelSwitchRequest): Promise<FabricModelSwitchResult>;\n setThinking(args: { id: string; thinking?: FabricThinking; scope?: FabricActorBindingScope }): Promise<FabricActorInfo>;\n setTools(args: { id: string; tools: string[]; scope?: \"project\" | \"global\" }): Promise<FabricActorInfo>;\n setEvents(args: { id: string; events: FabricActorHostEvent[] }): Promise<FabricActorInfo>;\n setDeliveryPolicy(args: {\n id: string;\n delivery: FabricActorDelivery;\n triggerTurn: boolean;\n scope?: \"project\" | \"global\";\n }): Promise<FabricActorInfo>;\n setInstructions(args: {\n id: string;\n instructions: string;\n scope?: \"project\" | \"global\";\n }): Promise<FabricActorInfo>;\n ask(args: { id: string; message: string; data?: unknown; model?: string; thinking?: FabricThinking }): Promise<FabricActorMessage>;\n tell(args: { id: string; message: string; data?: unknown; model?: string; thinking?: FabricThinking }): Promise<{ queued: true; messageId: string }>;\n steer(args: { id: string; message: string; data?: unknown }): Promise<{ queued: true; messageId: string; routed?: \"local\" | \"main\" | \"mesh\"; acknowledged?: boolean }>;\n followUp(args: { id: string; message: string; data?: unknown }): Promise<{ queued: true; messageId: string; routed?: \"local\" | \"main\" | \"mesh\"; acknowledged?: boolean }>;\n setSteeringMode(args: { id: string; mode: \"all\" | \"one-at-a-time\" }): Promise<{ queued: true; messageId: string }>;\n setFollowUpMode(args: { id: string; mode: \"all\" | \"one-at-a-time\" }): Promise<{ queued: true; messageId: string }>;\n /** Advisory compaction of a running Pi-runner child at its next safe turn boundary. */\n compact(args: { id: string; instructions?: string }): Promise<{ queued: true; messageId: string }>;\n actorStatus(args: FabricAgentTargetArgs): Promise<FabricActorInfo>;\n actors(): Promise<FabricActorInfo[]>;\n messages(args: { id: string; limit?: number }): Promise<FabricActorMessage[]>;\n remove(args: { id: string }): Promise<{ removed: boolean }>;\n /** Drop an actor's mailbox history without stopping the actor. */\n clearMessages(args: { id: string }): Promise<FabricActorInfo>;\n /** Stamp a global template into the current project as a fresh live actor with no inherited history. */\n \"import\"(args: { id?: string; name?: string; as?: string }): Promise<FabricActorInfo>;\n /** Export a live project actor's definition to the global registry as a project-independent template. */\n \"export\"(args: { id: string; overwrite?: boolean }): Promise<FabricActorRequest & { id: string; createdAt: number; updatedAt: number }>;\n log(args: {\n id: string;\n type?: \"session\" | \"run\" | \"all\";\n lines?: number;\n before?: number;\n runId?: string;\n }): Promise<FabricActorLog | FabricAgentLog>;\n}\ninterface FabricMcpResult {\n text: string;\n content: unknown[];\n structuredContent: unknown;\n}\ninterface FabricMcpTool {\n (args?: Record<string, unknown>): Promise<FabricMcpResult | unknown>;\n}\ninterface FabricMcpServer {\n [tool: string]: FabricMcpTool;\n}\n// Management verbs stay members of mcp even when the declare line below is\n// replaced by generated per-server declarations (see the dynamic option on\n// guestTypeDeclarations), so generated surfaces intersect with this type\n// rather than re-declaring them.\ninterface FabricMcpManagement {\n servers(): Promise<Array<{ name: string; description: string | null; transport: \"http\" | \"stdio\" }>>;\n reload(): Promise<{ servers: string[] }>;\n register(args: {\n name: string;\n description?: string;\n command?: string;\n args?: string[];\n cwd?: string;\n baseUrl?: string;\n headers?: Record<string, string>;\n env?: Record<string, string>;\n overwrite?: boolean;\n }): Promise<{ registered: string }>;\n call(args: { server: string; tool: string; args?: Record<string, unknown> }): Promise<unknown>;\n}\n// Loose static surface: any server/tool name compiles and argument shapes are\n// enforced at dispatch by the registry. With descriptor data available the\n// execution service replaces the declare-const-mcp line below with a\n// schema-typed rendering of the live cache (runtime/dynamic-guest-types.ts).\ntype FabricMcpApi = Record<string, FabricMcpServer> & FabricMcpManagement;\ninterface FabricCouncilRunOptions extends FabricAgentRequest {\n roles: string[];\n}\ninterface FabricCouncilApi {\n run(args: FabricCouncilRunOptions & { synthesize?: true }): Promise<FabricAgentResult>;\n run(args: FabricCouncilRunOptions & { synthesize: false }): Promise<FabricAgentResult[]>;\n}\ninterface FabricMeshIdentity {\n id: string;\n name: string;\n kind: \"main\" | \"actor\" | \"agent\";\n sessionId?: string;\n}\ninterface FabricMeshEvent {\n id: string;\n sequence: number;\n topic: string;\n kind: string;\n from: FabricMeshIdentity;\n to?: string;\n text?: string;\n data?: unknown;\n createdAt: number;\n /** External grant post: untrusted data. */\n origin?: \"external\"; untrusted?: true; grantId?: string;\n scheduled?: { dueAt: number; key?: string };\n /** Host-stamped publisher authority: unscoped \"host\" or a scope principal. */\n sender?: { authority: \"host\" } | { authority: \"scope\"; principalId: string; digest: string };\n}\ntype FabricMeshSchedule = Omit<FabricMeshEvent, \"sequence\" | \"origin\" | \"untrusted\" | \"grantId\" | \"scheduled\"> & { key?: string; dueAt: number };\ninterface FabricMeshGrant { grantId: string; topic: string; kind?: string; createdAt: number; expiresAt: number; uses: number; maxUses: number; createdBy: FabricMeshIdentity }\ninterface FabricMeshStateEntry<T = unknown> {\n key: string;\n value: T;\n version: number;\n updatedAt: number;\n updatedBy: FabricMeshIdentity;\n}\ninterface FabricMeshApi {\n self(): Promise<FabricMeshIdentity>;\n publish(args: { topic: string; kind?: string; to?: string; text?: string; data?: unknown; message?: string; body?: string }): Promise<FabricMeshEvent>;\n /** Schedules instead: notBefore (epoch ms/ISO) or afterMs, \u2264366 days; key replaces. */\n publish(args: { topic: string; kind?: string; to?: string; text?: string; data?: unknown; notBefore?: number | string; afterMs?: number; key?: string }): Promise<FabricMeshSchedule & { scheduled: true }>;\n scheduled(args?: { topic?: string; limit?: number }): Promise<FabricMeshSchedule[]>;\n unschedule(args: { key: string }): Promise<{ removed: boolean }>;\n /** External post token, shown once. ttlMs 1 min..30 days; uses 1..10000, default 1. */\n grant(args: { topic: string; ttlMs: number; uses?: number; kind?: string }): Promise<FabricMeshGrant & { token: string; command: string }>;\n revoke(args: { grantId: string }): Promise<{ revoked: boolean }>;\n grants(): Promise<FabricMeshGrant[]>;\n read(args?: { after?: number; topic?: string; to?: string; limit?: number; max?: number }): Promise<FabricMeshEvent[]>;\n members(args?: { scope?: FabricParticipantScope; kinds?: FabricParticipantKind[]; includeStale?: boolean; limit?: number; max?: number; include_stale?: boolean }): Promise<FabricParticipantInfo[]>;\n get<T = unknown>(args: { key: string }): Promise<FabricMeshStateEntry<T> | null>;\n list<T = unknown>(args?: { prefix?: string; limit?: number; max?: number }): Promise<Array<FabricMeshStateEntry<T>>>;\n put<T = unknown>(args: { key: string; value: T; ifVersion?: number; if_version?: number; version?: number }): Promise<FabricMeshStateEntry<T>>;\n delete(args: { key: string; ifVersion?: number; if_version?: number; version?: number }): Promise<{ deleted: boolean; version?: number }>;\n}\n// Stable-provider argument bags declare the canonical keys plus the\n// near-miss spellings repaired during argument normalization\n// (providers/arg-normalization.ts and each provider's per-action table). The\n// registry's prepare stage repairs aliases before schema validation, so a\n// call spelled with an alias typechecks instead of tripping the\n// excess-property check; the canonical key wins on conflict, and anything\n// else fails additionalProperties:false validation with the offending\n// property path named. Keep these spillover fields in sync with the provider\n// normalization tables.\ntype FabricMemoryBranches = \"active\" | \"all\";\ntype FabricMemoryQueryMode = \"literal\" | \"phrase\" | \"regex\";\ntype FabricMemoryQueryMatch = \"all\" | \"any\";\ninterface FabricMemoryEntryRange {\n first: number;\n last: number;\n}\ninterface FabricMemoryRecallArgs {\n source?: string;\n query?: string;\n queryMode?: FabricMemoryQueryMode;\n queryMatch?: FabricMemoryQueryMatch;\n expectedSourceHash?: string;\n expectedLineageFingerprint?: string;\n branches?: FabricMemoryBranches;\n scope?: string;\n offset?: number;\n pageSize?: number;\n snippetChars?: number;\n role?: string;\n tool?: string;\n ref?: string;\n provider?: string;\n action?: string;\n outcome?: \"succeeded\" | \"failed\" | \"aborted\" | \"timed_out\";\n since?: number;\n until?: number;\n entryRange?: FabricMemoryEntryRange;\n q?: string;\n limit?: number;\n max?: number;\n page_size?: number;\n snippet_chars?: number;\n query_mode?: FabricMemoryQueryMode;\n query_match?: FabricMemoryQueryMatch;\n entry_range?: FabricMemoryEntryRange;\n}\ninterface FabricMemoryExpandArgs {\n source?: string;\n session: string;\n expectedSourceHash?: string;\n expectedLineageFingerprint?: string;\n branches?: FabricMemoryBranches;\n indices?: number[];\n entryIds?: string[];\n operationAddresses?: string[];\n entryRange?: FabricMemoryEntryRange;\n before?: number;\n after?: number;\n entryOffset?: number;\n textOffset?: number;\n maxChars?: number;\n maxEntries?: number;\n id?: string;\n file?: string;\n path?: string;\n session_id?: string;\n index?: number;\n entry_ids?: string[];\n operation_addresses?: string[];\n entry_range?: FabricMemoryEntryRange;\n entry_offset?: number;\n text_offset?: number;\n max_chars?: number;\n max_entries?: number;\n}\ninterface FabricMemoryCall<Ref extends string, Args> {\n ref: Ref;\n args: Args;\n}\ninterface FabricMemoryRecallEntryHit {\n kind: \"entry\";\n sessionId: string;\n tier: \"hot\" | \"cold\";\n index: number;\n entryId: string | null;\n parentId: string | null;\n operationAddress: string | null;\n type: string;\n role: string | null;\n tool: string | null;\n ref: string | null;\n provider: string | null;\n action: string | null;\n timestamp: number | null;\n isError: boolean;\n outcome?: \"succeeded\" | \"failed\" | \"aborted\" | \"timed_out\";\n score: number;\n snippet: string;\n truncated: boolean;\n follow: FabricMemoryCall<\"memory.expand\", FabricMemoryExpandArgs>;\n}\ninterface FabricMemoryRecallSessionHit {\n kind: \"session\";\n sessionId: string;\n tier: \"cold\";\n cwd: string;\n lastTimestamp: number | null;\n score: number;\n matchedTerms: number;\n matchedStructuralEntries: number;\n follow: FabricMemoryCall<\"memory.recall\", FabricMemoryRecallArgs>;\n}\ntype FabricMemoryRecallHit = FabricMemoryRecallEntryHit | FabricMemoryRecallSessionHit;\ninterface FabricMemoryError {\n code: string;\n message: string;\n [key: string]: unknown;\n}\ninterface FabricMemoryCoverage {\n complete: boolean;\n indexedSessions: number;\n eligibleSessions: number;\n staleSessions: number;\n incompleteSessions: number;\n reasons: string[];\n error?: FabricMemoryError;\n}\ninterface FabricMemoryRecallResult {\n total: number;\n hits: FabricMemoryRecallHit[];\n next: FabricMemoryCall<\"memory.recall\", FabricMemoryRecallArgs> | null;\n coverage: FabricMemoryCoverage;\n error?: FabricMemoryError;\n}\ninterface FabricMemoryExpandedEntry {\n index: number;\n entryId: string | null;\n parentId: string | null;\n type: string | null;\n role: string | null;\n timestamp: number | null;\n isError: boolean;\n anchor?: boolean;\n text: string;\n textRange: { start: number; end: number; total: number; complete: boolean };\n parentEntryId?: string | null;\n operationAddress?: string | null;\n tool?: string | null;\n ref?: string | null;\n provider?: string | null;\n action?: string | null;\n outcome?: \"succeeded\" | \"failed\" | \"aborted\" | \"timed_out\";\n filesTouched?: Array<string | null>;\n operation?: unknown;\n branchFact?: unknown;\n structuredTruncated?: boolean;\n factAddress?: string | null;\n carrierEntryId?: string | null;\n carrierParentId?: string | null;\n carrierFromId?: string | null;\n}\ninterface FabricMemoryExpandResult {\n session?: string;\n sourceHash?: string;\n branches?: FabricMemoryBranches;\n lineageFingerprint?: string;\n entryCount?: number;\n entries: FabricMemoryExpandedEntry[];\n next?: FabricMemoryCall<\"memory.expand\", FabricMemoryExpandArgs> | null;\n error?: FabricMemoryError;\n}\ninterface FabricMemoryWalkResult {\n visited: number;\n stopped: boolean;\n error?: FabricMemoryError;\n}\ninterface FabricMemorySessionInfo {\n id: string;\n file: string;\n cwd: string;\n mtime: number;\n entryCount: number;\n tier: \"hot\" | \"cold\";\n branches: FabricMemoryBranches;\n lineageFingerprint: string | null;\n}\ninterface FabricMemoryApi {\n recall(args?: FabricMemoryRecallArgs): Promise<FabricMemoryRecallResult>;\n expand(args: FabricMemoryExpandArgs): Promise<FabricMemoryExpandResult>;\n walk(\n args: FabricMemoryExpandArgs,\n visitor: (\n entry: FabricMemoryExpandedEntry,\n index: number,\n ) => boolean | void | Promise<boolean | void>,\n ): Promise<FabricMemoryWalkResult>;\n sessions(args?: {\n source?: string;\n scope?: string;\n branches?: FabricMemoryBranches;\n limit?: number;\n max?: number;\n }): Promise<{\n scope?: string;\n branches?: FabricMemoryBranches;\n sessions?: FabricMemorySessionInfo[];\n error?: FabricMemoryError;\n }>;\n}\ninterface FabricStateTransitionArgs {\n label: string;\n from?: string;\n to: string;\n summary: string;\n evidence?: string[];\n tags?: string[];\n kind?: \"state\" | \"representation\";\n complexity?: { files: string[] };\n force?: boolean;\n name?: string;\n description?: string;\n}\ninterface FabricStateComplexityFile {\n file: string;\n supported: boolean;\n language?: string;\n current?: number;\n recorded?: number;\n delta?: number;\n recordedDelta?: number;\n}\ninterface FabricStateVerificationResult {\n certified: boolean;\n violated: boolean;\n certificationStatus: \"certified\" | \"failed\";\n results: unknown[];\n failures: unknown[];\n certificate?: unknown;\n reportingError?: string;\n evidenceDigest: string;\n resultDigest: string;\n binding?: Record<string, string>;\n observed?: { commit?: string; dirty?: boolean };\n requestedBy?: \"program\" | \"host\";\n}\ninterface FabricStateApi {\n transition(args: FabricStateTransitionArgs): Promise<{ event: FabricMeshEvent; head: unknown }>;\n get(): Promise<{\n head: unknown | null;\n goal: { check: string; description?: string } | null;\n complexity: { files: number; decisionPoints: number; lastNetDelta: number };\n certification: { current: unknown | null; recent: unknown[] };\n recentLabels: string[];\n }>;\n history(args?: { label?: string; limit?: number; includeArchived?: boolean; name?: string; max?: number }): Promise<{\n transitions: unknown[];\n labels: string[];\n certifications: unknown[];\n }>;\n complexity(args?: { files?: string[]; paths?: string[] }): Promise<{ files: FabricStateComplexityFile[]; netDelta: number }>;\n verify(args?: { labels?: string[]; includeArchived?: boolean; timeoutMs?: number; label?: string; binding?: Record<string, string> }): Promise<FabricStateVerificationResult>;\n goal(args: { check: string; description?: string; command?: string; cmd?: string; predicate?: string }): Promise<FabricMeshStateEntry<{ check: string; description?: string }>>;\n checkGoal(args?: { timeoutMs?: number }): Promise<{\n passed: boolean;\n output: string;\n exitCode: number | null;\n error?: string;\n }>;\n}\ntype FabricSchemaEvidence =\n | { kind: \"file_exists\"; path: string }\n | { kind: \"file_absent\"; path: string }\n | { kind: \"file_contains\"; path: string; literal: string }\n | { kind: \"file_sha256\"; path: string; sha256: string }\n | { kind: \"trusted_command\"; name: string };\ntype FabricSchemaFileOperation =\n | { kind: \"write\"; path: string; content: string; expected: { absent: true } | { sha256: string } }\n | { kind: \"edit\"; path: string; oldText: string; newText: string; expectedSha256: string }\n | { kind: \"delete\"; path: string; expectedSha256: string };\ninterface FabricSchemaEvidenceResult {\n evidence: FabricSchemaEvidence;\n status: \"confirmed\" | \"nonconfirmed\" | \"error\";\n detail: string;\n exitCode?: number | null;\n output?: string;\n observedSha256?: string;\n}\ninterface FabricSchemaStatus {\n mode: \"off\" | \"audit\" | \"enforce\";\n certificateTtlMs: number;\n maxFiles: number;\n maxBytes: number;\n trustedCommands: string[];\n generation: number;\n lastOutcome: \"committed\" | \"rolled_back\" | \"quarantined\" | null;\n hypotheses: Array<{\n id: string;\n label: string;\n status: string;\n generation: number;\n updatedAt: number;\n }>;\n}\ninterface FabricSchemaVerificationResult {\n verified: boolean;\n hypothesisId: string;\n certificate?: string;\n issuedAt?: number;\n expiresAt?: number;\n reason?: string;\n results: FabricSchemaEvidenceResult[];\n}\ninterface FabricSchemaCommitResult {\n outcome: \"committed\" | \"rolled_back\" | \"quarantined\";\n transactionId: string;\n generation?: number;\n paths?: string[];\n postconditions?: FabricSchemaEvidenceResult[];\n complexityReductionCertified?: boolean;\n stateTransition?: unknown;\n error?: string;\n rollbackError?: string;\n}\ninterface FabricSchemaApi {\n status(): Promise<FabricSchemaStatus>;\n hypothesize(args: {\n label: string;\n summary: string;\n evidence: FabricSchemaEvidence[];\n complexityReduction?: boolean;\n name?: string;\n description?: string;\n complexity_reduction?: boolean;\n }): Promise<{\n hypothesisId: string;\n status: string;\n state: unknown;\n fingerprint: string;\n generation: number;\n }>;\n verify(args: { hypothesisId: string; id?: string; hypothesis_id?: string }): Promise<FabricSchemaVerificationResult>;\n commit(args: {\n hypothesisId: string;\n certificate: string;\n operations: FabricSchemaFileOperation[];\n postconditions: FabricSchemaEvidence[];\n id?: string;\n hypothesis_id?: string;\n }): Promise<FabricSchemaCommitResult>;\n abort(args: { hypothesisId: string; certificate?: string; id?: string; hypothesis_id?: string }): Promise<{\n aborted: true;\n hypothesisId: string;\n }>;\n}\ninterface FabricCompactPendingIntent {\n reason?: string;\n instructions?: string;\n preserve?: string[];\n requestedBy: string;\n requestedAt: number;\n}\ntype FabricCompactionOwner = \"fabric\" | \"pi\" | \"external\" | \"none\";\ninterface FabricCompactLastCommit {\n at: number;\n requestedBy: string;\n status: \"committed\" | \"cancelled\" | \"failed\";\n summary?: string;\n tokensBefore?: number;\n estimatedTokensAfter?: number;\n error?: string;\n}\ntype FabricComponentState = \"waiting\" | \"loading\" | \"active\" | \"unloading\" | \"failed\" | \"quarantined\" | \"disposed\";\ninterface FabricComponentEffectInfo {\n label: string;\n kind: \"none\" | \"scoped\" | \"transactional\" | \"emission\";\n resources: string[];\n ordering: \"commutative\" | \"ordered\" | \"unknown\";\n}\ninterface FabricComponentEffectConflict {\n withComponent: string;\n resources: string[];\n reason: \"shared_resource\" | \"unknown_resource\";\n}\ninterface FabricComponentInfo {\n id: string;\n component: string;\n parentId?: string;\n state: FabricComponentState;\n guarantee: \"managed\" | \"revertible\";\n requirements: string[];\n provisions: string[];\n missing: string[];\n optionalMissing: string[];\n effects?: FabricComponentEffectInfo[];\n effectConflicts?: FabricComponentEffectConflict[];\n targetDigest?: string;\n error?: string;\n cleanupErrors?: string[];\n revision: number;\n createdAt: number;\n updatedAt: number;\n}\ninterface FabricComponentEntry {\n id: string;\n component: string;\n config?: unknown;\n disabled?: boolean;\n}\ninterface FabricComponentDefinitionInfo {\n name: string;\n description?: string;\n revision: number;\n configSchema?: Record<string, unknown>;\n requirements: string[];\n provisions: string[];\n}\ninterface FabricComponentConfigSource {\n scope: \"global\" | \"project\";\n path: string;\n trusted: boolean;\n present: boolean;\n selected: boolean;\n}\ninterface FabricComponentConfigurationInfo {\n sources: FabricComponentConfigSource[];\n warnings: string[];\n sessionOverrides: string[];\n removalPolicy: \"drain\";\n error?: string;\n}\ninterface FabricComponentChangeRequest {\n scope?: \"session\" | \"global\" | \"project\";\n entries?: FabricComponentEntry[];\n remove?: string[];\n reset?: string[];\n}\ninterface FabricComponentChangePlan {\n revision: string;\n request: Required<FabricComponentChangeRequest>;\n changes: Array<{ id: string; operation: \"add\" | \"replace\" | \"remove\"; component: string; requirements: string[]; provisions: string[] }>;\n warnings: string[];\n sources: FabricComponentConfigSource[];\n}\ninterface FabricComponentsApi {\n list(): Promise<{\n definitions: FabricComponentDefinitionInfo[];\n components: FabricComponentInfo[];\n configuration: FabricComponentConfigurationInfo;\n }>;\n describe(args: { component: string }): Promise<FabricComponentDefinitionInfo & { instances: FabricComponentInfo[] }>;\n plan(args: FabricComponentChangeRequest): Promise<FabricComponentChangePlan>;\n apply(args: FabricComponentChangeRequest & { expectedRevision: string }): Promise<{ components: FabricComponentInfo[]; configuration: FabricComponentConfigurationInfo; scope: \"session\" | \"global\" | \"project\" }>;\n reconcile(): Promise<{ components: FabricComponentInfo[]; configuration: FabricComponentConfigurationInfo }>;\n status(args: { id: string }): Promise<FabricComponentInfo>;\n graph(): Promise<{\n components: FabricComponentInfo[];\n edges: Array<{ from: string; to: string; ref: string; kind?: \"dependency\" | \"ownership\" }>;\n cycles: string[][];\n }>;\n reload(args?: { id?: string }): Promise<{ components: FabricComponentInfo[] }>;\n}\n\ninterface FabricCacheHoldOptions {\n target?: \"self\" | \"main\";\n durationMs: number;\n /** Currently unsupported: requesting this bound rejects acquisition. */\n maxRefreshes?: number;\n /** Currently unsupported: requesting this bound rejects acquisition. */\n maxCostUsd?: number;\n}\ninterface FabricCacheLease {\n id: string; scope: \"session\" | \"component\"; sessionId: string; model: string; expiresAt: number;\n}\ntype FabricCacheHoldResult = ({ status: \"held\" } & FabricCacheLease)\n | { status: \"unsupported\" | \"unavailable\"; reason: string };\ninterface FabricCacheSample {\n entryId: string; observedAt: number; input: number; cacheRead: number; cacheWrite: number;\n output: number; totalInput: number; cacheReadShare: number; reportedCostUsd: number | null;\n}\ninterface FabricCacheObservation {\n lastRequest: FabricCacheSample | null; lastRefresh: FabricCacheSample | null;\n maintenance: { requests: number; tokens: number; reportedCostUsd: number; unknownCostRequests: number; unknownTokenRequests: number };\n window: { entries: number; limit: number; truncated: boolean; stoppedAt: string | null };\n}\ninterface FabricCacheStatus {\n target: \"self\"; sessionId: string; model: string | null; supported: boolean; reason: string | null;\n limits: { durationMs: true; maxRefreshes: false; maxCostUsd: false };\n leases: FabricCacheLease[]; scheduled: null; cleanupError: string | null; observation: FabricCacheObservation;\n}\ninterface FabricCacheApi {\n status(args?: { target?: \"self\" | \"main\" }): Promise<FabricCacheStatus>;\n hold(args: FabricCacheHoldOptions): Promise<FabricCacheHoldResult>;\n release(args: { id: string }): Promise<{ released: boolean; cleanupError: string | null }>;\n}\n\ninterface FabricThinkingBounds { min?: FabricThinking; max?: FabricThinking }\ninterface FabricThinkingOverride {\n level: FabricThinking;\n scope: \"turn\" | \"turns\" | \"session\";\n remainingTurns?: number;\n reason?: string;\n setAt: number;\n}\ninterface FabricThinkingStatus {\n level: FabricThinking;\n available: FabricThinking[];\n bounds: { min: FabricThinking; max: FabricThinking };\n baseline: FabricThinking;\n override?: FabricThinkingOverride;\n}\ninterface FabricThinkingApi {\n status(): Promise<FabricThinkingStatus>;\n set(args: { level: FabricThinking; scope?: \"turn\" | \"turns\" | \"session\"; turns?: number; reason?: string }): Promise<FabricThinkingStatus & { clamped?: true; requested?: FabricThinking }>;\n reset(): Promise<FabricThinkingStatus>;\n}\n\ninterface FabricDecision {\n id: string; kind: \"approval\" | \"question\" | \"escalation\"; title: string; body?: string;\n options?: Array<{ id: string; label: string }>; input: \"text\" | \"confirm\" | \"select\" | \"editor\";\n raisedBy: { participantId: string; runId?: string; sessionId?: string };\n holder: string; createdAt: number; deadline?: number; onExpire: \"cancel\" | \"default\" | \"escalate\"; defaultOptionId?: string;\n escalation?: { chain: string[]; hop: number; hopTimeoutMs: number; onFinal: \"cancel\" | \"default\" };\n history?: Array<{ holder: string; until: number; reason: \"expired\" | \"escalated\"; text?: string; by?: string }>;\n status: \"open\" | \"answered\" | \"expired\" | \"cancelled\";\n answer?: { optionId?: string; text?: string; answeredBy: string; via: string; at: number };\n}\ninterface FabricDecisionsApi {\n raise(args: { title: string; kind?: FabricDecision[\"kind\"]; body?: string; options?: Array<{ id: string; label: string }>; input?: FabricDecision[\"input\"]; holder?: string; deadline?: number; timeoutMs?: number; onExpire?: \"cancel\" | \"default\" | \"escalate\"; defaultOptionId?: string; escalation?: { chain?: string[]; hopTimeoutMs?: number; onFinal?: \"cancel\" | \"default\" } }): Promise<{ id: string }>;\n wait(args: { id: string; timeoutMs?: number }): Promise<FabricDecision>;\n list(args?: { status?: FabricDecision[\"status\"]; holder?: string; limit?: number }): Promise<FabricDecision[]>;\n answer(args: { id: string; optionId?: string; text?: string }): Promise<FabricDecision>;\n escalate(args: { id: string; reason?: string }): Promise<FabricDecision>;\n cancel(args: { id: string }): Promise<FabricDecision>;\n}\n\ntype FabricProgramStatus = \"candidate\" | \"promoted\" | \"retired\";\ninterface FabricProgramSummary {\n /** name@digest12 */\n ref: string; name: string; digest: string; kind: \"fabric\" | \"jev\"; kernel?: \"typescript\" | \"python\";\n description?: string; createdAt: number; status: FabricProgramStatus;\n}\ninterface FabricProgramRecord extends FabricProgramSummary {\n version: 1; code?: string; jevProgram?: Record<string, unknown>; inputSchema?: Record<string, unknown>; trial?: unknown;\n}\ninterface FabricProgramsApi {\n /** Always saved as a candidate; identical content returns the same ref. */\n save(args: { name: string; kind?: \"fabric\" | \"jev\"; kernel?: \"typescript\" | \"python\"; code?: string; jevProgram?: Record<string, unknown>; description?: string; inputSchema?: Record<string, unknown> }): Promise<{ ref: string; digest: string }>;\n list(args?: { name?: string; status?: FabricProgramStatus }): Promise<FabricProgramSummary[]>;\n /** ref: name (latest promoted, else latest candidate), name@<digest prefix >= 12>, or a full digest. */\n get(args: { ref: string }): Promise<FabricProgramRecord>;\n /** Runs nested with this program's capabilities; args.input becomes the saved program's input global. */\n run<T = unknown>(args: { ref: string; input?: unknown; requirePromoted?: boolean }): Promise<T>;\n}\n\ninterface FabricCompactApi {\n request(args?: {\n reason?: string;\n instructions?: string;\n preserve?: string[];\n requestedBy?: string;\n instruction?: string;\n requested_by?: string;\n }): Promise<{ requested: true; intent: FabricCompactPendingIntent }>;\n status(): Promise<{\n pending?: FabricCompactPendingIntent;\n last?: FabricCompactLastCommit;\n lastAuto?: { at: number; trigger: \"headroom\" | \"tokens\" | \"ratio\"; committed: boolean };\n owner: FabricCompactionOwner;\n outputReserveTokens: number;\n }>;\n /** Read-only context pressure; never compacts. */\n pressure(): Promise<{\n tokens: number | null;\n contextWindow: number | null;\n fraction: number | null;\n headroomTokens: number | null;\n band: \"ok\" | \"warn\" | \"urgent\" | \"unknown\";\n outputReserveTokens: number;\n thresholdFraction?: number;\n thresholdTokens?: number;\n owner: FabricCompactionOwner;\n }>;\n /** Persistent carry-forward focus rendered in every Fabric summary until cleared; no args reads. */\n carry(args?: { items?: string[]; add?: string[]; remove?: string[]; clear?: boolean }): Promise<{ items: string[] }>;\n cancel(): Promise<{ cancelled: true }>;\n}\n\ninterface FabricPrewalkFileIdentityStatus {\n path: string;\n loadedSha256: string;\n diskSha256: string;\n stale: boolean;\n}\ninterface FabricPrewalkApi {\n /** Only when Fabric's armed advisory or checkpoint requests an executor handoff plan.\n * Not a task planner, checklist, or acceptance-ledger store; unavailable otherwise. */\n plan(args: {\n outcome: string;\n steps: string[];\n verification: string[];\n risks: string;\n }): Promise<{ recorded: true; readiness: \"ready\"; plan: string }>;\n status(): Promise<{\n state: \"idle\" | \"armed\" | \"handing_off\" | \"continuation_pending\";\n planRequired: boolean;\n planReady: boolean;\n planPrompts: number;\n claimedReadiness: \"planned\" | \"disabled\" | \"unplanned\" | null;\n runtime?: {\n entry: FabricPrewalkFileIdentityStatus | null;\n lazyRuntime: FabricPrewalkFileIdentityStatus | null;\n };\n }>;\n}\n\ninterface FabricWorkflowAgentOptions extends Omit<FabricAgentRequest, \"task\"> {\n label?: string;\n}\ntype FabricActivityStatus = \"pending\" | \"running\" | \"completed\" | \"failed\" | \"blocked\" | \"stopped\";\ntype FabricActivityKind = \"agent\" | \"actor\" | \"tool\" | \"extension\" | \"mcp\" | \"mesh\" | \"task\" | \"custom\";\ninterface FabricWorkflowDisplay {\n name?: string;\n description?: string;\n}\ninterface FabricWorkflowPhaseOptions {\n id?: string;\n description?: string;\n total?: number;\n}\ninterface FabricWorkflowPhaseInput extends FabricWorkflowPhaseOptions {\n name: string;\n}\ninterface FabricWorkflowItem {\n /** Stable id, 1-128 chars of [A-Za-z0-9._:/-]; omitted ids become item-<n> per invocation. */\n id?: string;\n label: string;\n status?: FabricActivityStatus;\n phase?: string;\n detail?: string;\n kind?: FabricActivityKind;\n current?: string;\n total?: number;\n completed?: number;\n data?: unknown;\n /** Plain JSON object (<= 2 KiB) carried only on the host pi-fabric:workflow-item:v1 event. */\n meta?: Record<string, unknown>;\n}\ninterface FabricWorkflowApi {\n agent<T = string>(prompt: string, options?: FabricWorkflowAgentOptions): Promise<T>;\n parallel<T, R>(items: T[], mapper: (item: T, index: number) => Promise<R> | R, concurrency?: number | { concurrency?: number }): Promise<R[]>;\n parallel<T>(thunks: Array<() => Promise<T> | T>, concurrency?: number | { concurrency?: number }): Promise<T[]>;\n pipeline<T>(items: T[], ...stages: Array<(value: unknown, original: T, index: number) => Promise<unknown> | unknown>): Promise<unknown[]>;\n configure(display: FabricWorkflowDisplay): Promise<FabricWorkflowDisplay>;\n phase(name: string, options?: FabricWorkflowPhaseOptions): Promise<{ name: string; index: number; id?: string }>;\n phase(input: FabricWorkflowPhaseInput): Promise<{ name: string; index: number; id?: string }>;\n item(item: FabricWorkflowItem): Promise<FabricWorkflowItem>;\n event(event: { message: string; level?: \"info\" | \"success\" | \"warning\" | \"error\"; data?: unknown }): Promise<void>;\n log(...values: unknown[]): void;\n budget: { total: number; spent(): number; remaining(): number };\n}\ndeclare const tools: FabricToolsApi;\ndeclare const pi: PiToolsApi;\ndeclare const extensions: FabricExtensionsApi;\ndeclare const agents: FabricAgentsApi;\ndeclare const mesh: FabricMeshApi;\ndeclare const mcp: FabricMcpApi;\ndeclare const memory: FabricMemoryApi;\ndeclare const state: FabricStateApi;\ndeclare const schema: FabricSchemaApi;\ndeclare const components: FabricComponentsApi;\ndeclare const compact: FabricCompactApi;\ndeclare const cache: FabricCacheApi;\ndeclare const thinking: FabricThinkingApi;\ndeclare const decisions: FabricDecisionsApi;\ndeclare const programs: FabricProgramsApi;\ndeclare const prewalk: FabricPrewalkApi;\n${JEV_GUEST_DECLARATIONS}\ndeclare const council: FabricCouncilApi;\ndeclare const workflow: FabricWorkflowApi;\ndeclare function agent<T = string>(prompt: string, options?: FabricWorkflowAgentOptions): Promise<T>;\ndeclare function parallel<T, R>(items: T[], mapper: (item: T, index: number) => Promise<R> | R, concurrency?: number | { concurrency?: number }): Promise<R[]>;\ndeclare function parallel<T>(thunks: Array<() => Promise<T> | T>, concurrency?: number | { concurrency?: number }): Promise<T[]>;\ndeclare function pipeline<T>(items: T[], ...stages: Array<(value: unknown, original: T, index: number) => Promise<unknown> | unknown>): Promise<unknown[]>;\ndeclare function phase(name: string, options?: FabricWorkflowPhaseOptions): Promise<{ name: string; index: number; id?: string }>;\ndeclare function phase(input: FabricWorkflowPhaseInput): Promise<{ name: string; index: number; id?: string }>;\ndeclare function log(...values: unknown[]): void;\ndeclare const budget: FabricWorkflowApi[\"budget\"];\ntype FabricRlmRequest = Omit<FabricAgentRequest, \"runner\" | \"recursive\"> & { runner?: \"pi\" };\ndeclare const rlm: { query(args: FabricRlmRequest): Promise<FabricAgentResult> };\ninterface FabricConsole {\n log(...args: unknown[]): void;\n info(...args: unknown[]): void;\n warn(...args: unknown[]): void;\n error(...args: unknown[]): void;\n}\ndeclare const console: FabricConsole;\ndeclare const \u03C0: Readonly<Record<string, string>>;\n// Process runtimes only: node/bun children bridge native-module imports;\n// quickjs has no module loader and rejects __fabricImport at runtime.\ndeclare function __fabricImport(specifier: string): Promise<any>;\ndeclare function print(...args: unknown[]): void;\ndeclare function setTimeout(handler: (...args: any[]) => void, timeout?: number): number;\ndeclare function clearTimeout(handle: number): void;\ndeclare function setInterval(handler: (...args: any[]) => void, timeout?: number): number;\ndeclare function clearInterval(handle: number): void;\n// Process runtimes only: the bun-process child binds the host's real Bun\n// module namespace as __bun; undefined under node-process and quickjs.\ndeclare const __bun: any;\n`;\n\nconst FULL_CODE_GLOBAL_DECLARATIONS = [\n \"declare const pi: PiToolsApi;\\n\",\n \"declare const extensions: FabricExtensionsApi;\\n\",\n];\n\nconst PI_LOOSE_DECLARATION = \"declare const pi: PiToolsApi;\\n\";\nconst MCP_LOOSE_DECLARATION = \"declare const mcp: FabricMcpApi;\\n\";\nconst EXTENSIONS_LOOSE_DECLARATION = \"declare const extensions: FabricExtensionsApi;\\n\";\n\nexport interface FabricGuestDeclarationOptions {\n /** Global names to omit (for example providers disabled by configuration). */\n excludeGlobals?: readonly string[];\n /**\n * Pre-rendered replacement blocks from buildDynamicGuestDeclarations().\n * Applied only when the loose anchor line is still present \u2014 excluded\n * globals (or orchestration-only mode, for extensions) keep nothing to\n * replace, and missing/undefined sections keep the loose surface.\n */\n dynamic?: FabricDynamicGuestDeclarations;\n /**\n * Additive overloads for the current captured exact-name core overrides.\n * The block is applied only to the full-code `pi` declaration.\n */\n coreOverrides?: string;\n}\n\nconst globalDeclarationLine = (name: string): RegExp =>\n new RegExp(`^declare const ${name}: [^\\\\n]*;\\\\n`, \"m\");\n\nconst terminatedDeclaration = (block: string): string =>\n block.endsWith(\"\\n\") ? block : `${block}\\n`;\n\nexport const guestTypeDeclarations = (\n fullCodeMode: boolean,\n options: FabricGuestDeclarationOptions = {},\n): string => {\n const base = fullCodeMode\n ? GUEST_TYPE_DECLARATIONS\n : FULL_CODE_GLOBAL_DECLARATIONS.reduce(\n (declarations, declaration) => declarations.replace(declaration, \"\"),\n GUEST_TYPE_DECLARATIONS,\n );\n let result = (options.excludeGlobals ?? []).reduce(\n (declarations, name) => declarations.replace(globalDeclarationLine(name), \"\"),\n base,\n );\n if (fullCodeMode && options.coreOverrides && result.includes(PI_LOOSE_DECLARATION)) {\n result = result.replace(\n PI_LOOSE_DECLARATION,\n terminatedDeclaration(options.coreOverrides),\n );\n }\n if (options.dynamic?.mcp && result.includes(MCP_LOOSE_DECLARATION)) {\n result = result.replace(\n MCP_LOOSE_DECLARATION,\n terminatedDeclaration(options.dynamic.mcp),\n );\n }\n if (options.dynamic?.extensions && result.includes(EXTENSIONS_LOOSE_DECLARATION)) {\n result = result.replace(\n EXTENSIONS_LOOSE_DECLARATION,\n terminatedDeclaration(options.dynamic.extensions),\n );\n }\n return result;\n};\n"],
5
+ "mappings": ";AAAO,IAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACA9B,IAAM,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACU/B,IAAM,4CAA4C;AAAA,EACvD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,IAAI;AACN;AAEO,IAAM,yBAAyB;AAAA,EACpC,MAAM,CAAC,UAAU,OAAO;AAAA,EACxB,M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,IAAM,wBAAwB;AAC9B,IAAM,+BAA+B;AAmBrC,IAAM,wBAAwB,CAAC,SAC7B,IAAI,OAAO,kBAAkB,IAAI,iBAAiB,GAAG;AAEvD,IAAM,wBAAwB,CAAC,UAC7B,MAAM,SAAS,IAAI,IAAI,QAAQ,GAAG,KAAK;AAAA;AAElC,IAAM,wBAAwB,CACnC,cACA,UAAyC,CAAC,MAC/B;AACX,QAAM,OAAO,eACT,0BACA,8BAA8B;AAAA,IAC5B,CAAC,cAAc,gBAAgB,aAAa,QAAQ,aAAa,EAAE;AAAA,IACnE;AAAA,EACF;AACJ,MAAI,UAAU,QAAQ,kBAAkB,CAAC,GAAG;AAAA,IAC1C,CAAC,cAAc,SAAS,aAAa,QAAQ,sBAAsB,IAAI,GAAG,EAAE;AAAA,IAC5E;AAAA,EACF;AACA,MAAI,gBAAgB,QAAQ,iBAAiB,OAAO,SAAS,oBAAoB,GAAG;AAClF,aAAS,OAAO;AAAA,MACd;AAAA,MACA,sBAAsB,QAAQ,aAAa;AAAA,IAC7C;AAAA,EACF;AACA,MAAI,QAAQ,SAAS,OAAO,OAAO,SAAS,qBAAqB,GAAG;AAClE,aAAS,OAAO;AAAA,MACd;AAAA,MACA,sBAAsB,QAAQ,QAAQ,GAAG;AAAA,IAC3C;AAAA,EACF;AACA,MAAI,QAAQ,SAAS,cAAc,OAAO,SAAS,4BAA4B,GAAG;AAChF,aAAS,OAAO;AAAA,MACd;AAAA,MACA,sBAAsB,QAAQ,QAAQ,UAAU;AAAA,IAClD;AAAA,EACF;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -2,7 +2,7 @@ import {
2
2
  createGuestStackMap,
3
3
  guestSetupSource,
4
4
  remapGuestErrorText
5
- } from "./chunk-QLFDPXK7.js";
5
+ } from "./chunk-BOONFV43.js";
6
6
  import {
7
7
  HumanWaitDeadlinePause
8
8
  } from "./chunk-7QKKLBHJ.js";
@@ -73,17 +73,18 @@ const run = async (message) => {
73
73
  });
74
74
  });
75
75
  };
76
+ const emitLog = line => { logs.push(line); send({ type: "output", text: line }); };
76
77
  const print = (...values) => {
77
78
  if (logsTruncated) return;
78
79
  const line = values.map(formatValue).join(" ");
79
80
  const remaining = message.maxLogChars - logChars;
80
81
  if (line.length > remaining) {
81
- if (remaining > 0) logs.push(line.slice(0, remaining));
82
- logs.push("[Pi Fabric log output truncated]");
82
+ if (remaining > 0) emitLog(line.slice(0, remaining));
83
+ emitLog("[Pi Fabric log output truncated]");
83
84
  logsTruncated = true;
84
85
  return;
85
86
  }
86
- logs.push(line);
87
+ emitLog(line);
87
88
  logChars += line.length;
88
89
  };
89
90
 
@@ -94,6 +95,7 @@ const run = async (message) => {
94
95
  const __bun = await import("bun").catch(() => undefined);
95
96
  const sandbox = {
96
97
  __fabricHostCall: hostCall,
98
+ __fabricEmitImage: image => send({ type: "output", image }),
97
99
  __fabricTokenBudget: message.tokenBudget ?? Number.POSITIVE_INFINITY,
98
100
  // Native-module bridge for guests whose vm lacks the dynamic-import
99
101
  // callback. Bun >= 1.4 honors importModuleDynamically on runInContext
@@ -113,7 +115,7 @@ const run = async (message) => {
113
115
 
114
116
  try {
115
117
  vm.runInContext(message.setup, context, { filename: "pi-fabric-setup.js" });
116
- const promise = vm.runInContext(message.code + "\n__piFabricMain()", context, {
118
+ const promise = vm.runInContext(message.code + "\nglobalThis.__fabricRun(__piFabricMain)", context, {
117
119
  filename: "pi-fabric-guest.js",
118
120
  // Node requires --experimental-vm-modules (set at spawn). Bun >= 1.4
119
121
  // honors this option on runInContext (unlike on createContext), so
@@ -121,12 +123,13 @@ const run = async (message) => {
121
123
  importModuleDynamically: (specifier) => import(specifier),
122
124
  });
123
125
  const value = jsonCompatible(await promise);
124
- send({ type: "result", result: { value, logs, terminationReason: "completed" } });
126
+ send({ type: "result", result: { value, logs, emitted: jsonCompatible(context.__fabricEmitted), terminationReason: "completed" } });
125
127
  } catch (error) {
126
128
  send({
127
129
  type: "result",
128
130
  result: {
129
131
  logs,
132
+ emitted: jsonCompatible(context.__fabricEmitted),
130
133
  terminationReason: "runtime_error",
131
134
  error: error?.stack ?? error?.message ?? String(error),
132
135
  },
@@ -221,6 +224,9 @@ var NodeProcessRuntime = class {
221
224
  let settled = false;
222
225
  let finishing = false;
223
226
  const hostTasks = /* @__PURE__ */ new Set();
227
+ const partialLogs = [];
228
+ const partialImages = [];
229
+ let partialChars = 0;
224
230
  const guestBundle = options.transpiledCode === void 0 ? transpileFabricCodeWithSourceMap(code) : { code: options.transpiledCode, sourceMap: options.transpiledSourceMap };
225
231
  const guestStackMap = createGuestStackMap(guestBundle.sourceMap);
226
232
  const guestLineCount = guestBundle.code.split("\n").length;
@@ -236,7 +242,7 @@ var NodeProcessRuntime = class {
236
242
  child.removeAllListeners();
237
243
  if (child.connected) child.disconnect();
238
244
  if (child.exitCode === null && child.signalCode === null) child.kill("SIGKILL");
239
- resolve(result);
245
+ resolve(result.terminationReason === "completed" ? result : { ...result, logs: result.logs.length ? result.logs : partialLogs, emitted: result.emitted?.length ? result.emitted : partialImages });
240
246
  };
241
247
  const scheduleDeadline = () => {
242
248
  clearTimeout(deadline);
@@ -283,10 +289,19 @@ var NodeProcessRuntime = class {
283
289
  child.on("message", (raw) => {
284
290
  if (settled || finishing || typeof raw !== "object" || raw === null) return;
285
291
  const message = raw;
292
+ if (message.type === "output") {
293
+ const chars = typeof message.text === "string" ? message.text.length : JSON.stringify(message.image ?? null).length;
294
+ partialChars += chars;
295
+ if (partialChars <= 16777216) {
296
+ if (typeof message.text === "string") partialLogs.push(message.text);
297
+ else if (message.image !== void 0) partialImages.push(message.image);
298
+ }
299
+ return;
300
+ }
286
301
  if (message.type === "result") {
287
302
  finishing = true;
288
303
  if (deadline) clearTimeout(deadline);
289
- if (message.result.terminationReason !== "completed" && !hostAbortController.signal.aborted) {
304
+ if (hostTasks.size > 0 && !hostAbortController.signal.aborted) {
290
305
  hostAbortController.abort(new Error(message.result.error ?? "Process execution stopped"));
291
306
  }
292
307
  void (async () => {
@@ -368,7 +383,7 @@ var NodeProcessRuntime = class {
368
383
  scheduleDeadline();
369
384
  send(child, {
370
385
  type: "execute",
371
- setup: guestSetupSource(options.piToolCanonicalFields),
386
+ setup: guestSetupSource(options.piToolCanonicalFields, options.nativeStoreEnabled),
372
387
  code: guestBundle.code,
373
388
  strings: options.strings ?? {},
374
389
  tokenBudget: options.tokenBudget,
@@ -387,4 +402,4 @@ export {
387
402
  NodeProcessRuntime,
388
403
  BunProcessRuntime
389
404
  };
390
- //# sourceMappingURL=chunk-5MNLVHF5.js.map
405
+ //# sourceMappingURL=chunk-6YLQ73DF.js.map