@e4779/pi-fabric 0.92.17-fork.3 → 0.92.28-fork.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actors/host-event-payload.d.ts.map +1 -1
- package/dist/agents/budget-ledger.d.ts.map +1 -1
- package/dist/agents/handoff-continuation.d.ts +4 -0
- package/dist/agents/handoff-continuation.d.ts.map +1 -0
- package/dist/agents/manager.d.ts.map +1 -1
- package/dist/agents/request.d.ts +4 -0
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents.js +5 -4
- package/dist/agents.js.map +1 -1
- package/dist/chunks/{chunk-GXNR6NRU.js → chunk-2IAVP4O2.js} +2 -2
- package/dist/chunks/{chunk-TPLMVELH.js → chunk-77PDIBK2.js} +15 -4
- package/dist/chunks/{chunk-TPLMVELH.js.map → chunk-77PDIBK2.js.map} +2 -2
- package/dist/chunks/chunk-7TX532EG.js +134 -0
- package/dist/chunks/chunk-7TX532EG.js.map +7 -0
- package/dist/chunks/chunk-BJOJX2UW.js +59 -0
- package/dist/chunks/chunk-BJOJX2UW.js.map +7 -0
- package/dist/chunks/{chunk-2PZWDVJB.js → chunk-BYOGRJME.js} +13 -4
- package/dist/chunks/chunk-BYOGRJME.js.map +7 -0
- package/dist/chunks/{chunk-RERA6YWA.js → chunk-CIODQX77.js} +12 -4
- package/dist/chunks/chunk-CIODQX77.js.map +7 -0
- package/dist/chunks/{chunk-OP2KTYQB.js → chunk-D6YSBP3R.js} +4 -4
- package/dist/chunks/chunk-EDL4JDW7.js +184 -0
- package/dist/chunks/chunk-EDL4JDW7.js.map +7 -0
- package/dist/chunks/{chunk-WVH324VF.js → chunk-FAMBJFFF.js} +1 -1
- package/dist/chunks/{chunk-WVH324VF.js.map → chunk-FAMBJFFF.js.map} +1 -1
- package/dist/chunks/{chunk-UDFDF7IY.js → chunk-G7UJLM33.js} +148 -251
- package/dist/chunks/chunk-G7UJLM33.js.map +7 -0
- package/dist/chunks/{chunk-RNOPHITP.js → chunk-H6DDV6E2.js} +180 -24
- package/dist/chunks/chunk-H6DDV6E2.js.map +7 -0
- package/dist/chunks/{chunk-ARLYAW2A.js → chunk-IR3PIHJM.js} +2 -1
- package/dist/chunks/chunk-IR3PIHJM.js.map +7 -0
- package/dist/chunks/{chunk-VRZNFNPB.js → chunk-IYQ5MNCW.js} +20 -17
- package/dist/chunks/chunk-IYQ5MNCW.js.map +7 -0
- package/dist/chunks/chunk-JNMTTJMQ.js +50 -0
- package/dist/chunks/chunk-JNMTTJMQ.js.map +7 -0
- package/dist/chunks/{chunk-CPSW2GW4.js → chunk-JOEFBOFN.js} +11 -7
- package/dist/chunks/chunk-JOEFBOFN.js.map +7 -0
- package/dist/chunks/chunk-KI277YNS.js +218 -0
- package/dist/chunks/chunk-KI277YNS.js.map +7 -0
- package/dist/chunks/{chunk-Y7KNRAFL.js → chunk-M3ZNZ6EZ.js} +28 -3
- package/dist/chunks/chunk-M3ZNZ6EZ.js.map +7 -0
- package/dist/chunks/{chunk-2DMJ7MEI.js → chunk-M7W57BRC.js} +172 -141
- package/dist/chunks/chunk-M7W57BRC.js.map +7 -0
- package/dist/chunks/{chunk-U6CTHPZC.js → chunk-MQG5QKGI.js} +2 -2
- package/dist/chunks/{chunk-CI56CW53.js → chunk-NPHCGLGH.js} +16 -10
- package/dist/chunks/chunk-NPHCGLGH.js.map +7 -0
- package/dist/chunks/{chunk-4SSMGBF4.js → chunk-QLV2IZ3F.js} +6 -7
- package/dist/chunks/chunk-QLV2IZ3F.js.map +7 -0
- package/dist/chunks/{chunk-PH7ZJ27F.js → chunk-RAEGNBRA.js} +210 -118
- package/dist/chunks/chunk-RAEGNBRA.js.map +7 -0
- package/dist/chunks/chunk-RAO6TQFP.js +187 -0
- package/dist/chunks/chunk-RAO6TQFP.js.map +7 -0
- package/dist/chunks/{chunk-ZZ4LHQYJ.js → chunk-RTXZHKMS.js} +22 -13
- package/dist/chunks/chunk-RTXZHKMS.js.map +7 -0
- package/dist/chunks/{chunk-BOTRGFQQ.js → chunk-RWDKJ24D.js} +26 -19
- package/dist/chunks/chunk-RWDKJ24D.js.map +7 -0
- package/dist/chunks/{chunk-2UQV52II.js → chunk-RZKN534S.js} +6 -6
- package/dist/chunks/{chunk-656HWVFU.js → chunk-SZUXWOO7.js} +5 -3
- package/dist/chunks/chunk-SZUXWOO7.js.map +7 -0
- package/dist/chunks/{chunk-YK5AZ7CZ.js → chunk-ULLIZPBH.js} +7 -7
- package/dist/chunks/{chunk-UTR3I23Z.js → chunk-W63E3WEO.js} +2 -2
- package/dist/chunks/{chunk-32BNQ75J.js → chunk-WG24VI7K.js} +56 -2
- package/dist/chunks/{chunk-32BNQ75J.js.map → chunk-WG24VI7K.js.map} +2 -2
- package/dist/chunks/{chunk-3MEHEH6B.js → chunk-X3OD47CL.js} +12 -2
- package/dist/chunks/chunk-X3OD47CL.js.map +7 -0
- package/dist/chunks/{chunk-4JETKRFE.js → chunk-ZHJNWM6A.js} +2 -2
- package/dist/compaction/hook.js +2 -2
- package/dist/components/configuration.d.ts +42 -0
- package/dist/components/configuration.d.ts.map +1 -0
- package/dist/components/configuration.js +18 -0
- package/dist/components/configuration.js.map +7 -0
- package/dist/components/control.d.ts +76 -0
- package/dist/components/control.d.ts.map +1 -0
- package/dist/components/loader.d.ts +12 -0
- package/dist/components/loader.d.ts.map +1 -1
- package/dist/components/supervisor.d.ts.map +1 -1
- package/dist/components/types.d.ts +2 -0
- package/dist/components/types.d.ts.map +1 -1
- package/dist/components/validation.d.ts +6 -0
- package/dist/components/validation.d.ts.map +1 -0
- package/dist/config.d.ts +4 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/core/action-registry.d.ts +1 -0
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/action-registry.js +3 -3
- package/dist/core/auto-approval-classifier.d.ts.map +1 -1
- package/dist/core/media-sanitize.d.ts +45 -0
- package/dist/core/media-sanitize.d.ts.map +1 -0
- package/dist/core/model-resolution.d.ts +20 -3
- package/dist/core/model-resolution.d.ts.map +1 -1
- package/dist/core/shell-jobs.d.ts +7 -1
- package/dist/core/shell-jobs.d.ts.map +1 -1
- package/dist/entropy/compiler.d.ts +8 -0
- package/dist/entropy/compiler.d.ts.map +1 -1
- package/dist/entropy/index.js +9 -1
- package/dist/entropy/meter.d.ts +10 -0
- package/dist/entropy/meter.d.ts.map +1 -1
- package/dist/entropy/pool.d.ts +5 -0
- package/dist/entropy/pool.d.ts.map +1 -1
- package/dist/entropy/sessions.d.ts +12 -1
- package/dist/entropy/sessions.d.ts.map +1 -1
- package/dist/execution-service.d.ts +3 -1
- package/dist/execution-service.d.ts.map +1 -1
- package/dist/fabric-exec-tool.d.ts.map +1 -1
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +424 -65
- package/dist/fabric-runtime-state.js.map +4 -4
- package/dist/fabric-state.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +130 -51
- package/dist/index.js.map +3 -3
- package/dist/jev/browser.d.ts.map +1 -1
- package/dist/jev/browser.js +2 -2
- package/dist/jev/config.d.ts +2 -0
- package/dist/jev/config.d.ts.map +1 -1
- package/dist/jev/model-key.d.ts +6 -0
- package/dist/jev/model-key.d.ts.map +1 -0
- package/dist/jev/observation.js +3 -2
- package/dist/jev.js +8 -7
- package/dist/memory/file-worker.d.ts +15 -0
- package/dist/memory/file-worker.d.ts.map +1 -0
- package/dist/memory/file-worker.js +44 -0
- package/dist/memory/file-worker.js.map +7 -0
- package/dist/memory/worker-provider.d.ts +24 -0
- package/dist/memory/worker-provider.d.ts.map +1 -0
- package/dist/memory/worker-provider.js +18 -0
- package/dist/memory/worker-provider.js.map +7 -0
- package/dist/output-budget.d.ts.map +1 -1
- package/dist/prewalk/arm.d.ts.map +1 -1
- package/dist/prewalk/handoff.d.ts.map +1 -1
- package/dist/protocol.d.ts +1 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +1 -1
- package/dist/providers/agents-actions.d.ts.map +1 -1
- package/dist/providers/captured-tools-provider.d.ts.map +1 -1
- package/dist/providers/components-provider.d.ts +5 -3
- package/dist/providers/components-provider.d.ts.map +1 -1
- package/dist/providers/jev-provider.js +7 -6
- package/dist/residency/actor-client.d.ts +2 -2
- package/dist/residency/actor-client.d.ts.map +1 -1
- package/dist/residency/actor-client.js +2 -2
- package/dist/residency/client.d.ts.map +1 -1
- package/dist/residency/host.js +11 -9
- package/dist/residency/pi-entry.js +11 -9
- package/dist/residency/pi-entry.js.map +1 -1
- package/dist/residency/protocol.d.ts +11 -2
- package/dist/residency/protocol.d.ts.map +1 -1
- package/dist/runtime/core-override-guest-types.js +2 -2
- package/dist/runtime/guest-types.d.ts +1 -1
- package/dist/runtime/guest-types.d.ts.map +1 -1
- package/dist/runtime/guest-types.js +1 -1
- package/dist/runtime/monty-runtime.js +4 -2
- package/dist/runtime/monty-runtime.js.map +1 -1
- package/dist/runtime/node-process-runtime.d.ts.map +1 -1
- package/dist/runtime/node-process-runtime.js +2 -2
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
- package/dist/runtime/quickjs-runtime.js +1 -1
- package/dist/runtime/typescript-kernel.js +6 -6
- package/dist/runtime-state-builtins.d.ts.map +1 -1
- package/dist/schema/policy.d.ts.map +1 -1
- package/dist/speculation/stream-tap.d.ts.map +1 -1
- package/dist/storage/retention.d.ts +3 -1
- package/dist/storage/retention.d.ts.map +1 -1
- package/dist/storage/scratch.d.ts +33 -0
- package/dist/storage/scratch.d.ts.map +1 -0
- package/dist/ui/code-preview-shell.d.ts.map +1 -1
- package/dist/ui/controller.d.ts.map +1 -1
- package/dist/ui/conversation-chrome.js +2 -2
- package/dist/ui/conversation-native-reader.js +4 -2
- package/dist/ui/conversation-native-reader.js.map +2 -2
- package/dist/ui/conversation.js +3 -3
- package/dist/ui/dashboard-presentation.d.ts.map +1 -1
- package/dist/ui/dashboard.js +13 -9
- package/dist/ui/dashboard.js.map +2 -2
- package/dist/ui/fabric-code-parser.d.ts.map +1 -1
- package/dist/ui/format.d.ts +1 -0
- package/dist/ui/format.d.ts.map +1 -1
- package/dist/ui/highlight.d.ts.map +1 -1
- package/dist/ui/settings-rpc.d.ts.map +1 -1
- package/dist/ui/settings-sections-execution.d.ts.map +1 -1
- package/dist/ui/settings-submenus.d.ts +12 -4
- package/dist/ui/settings-submenus.d.ts.map +1 -1
- package/dist/ui/settings.js +79 -31
- package/dist/ui/settings.js.map +2 -2
- package/dist/ui/shiki-catalog.d.ts +3 -0
- package/dist/ui/shiki-catalog.d.ts.map +1 -0
- package/dist/ui/structured.d.ts.map +1 -1
- package/dist/ui/tool-call-timing.d.ts.map +1 -1
- package/dist/ui/widget.d.ts +12 -1
- package/dist/ui/widget.d.ts.map +1 -1
- package/dist/worker/model-control.d.ts.map +1 -1
- package/dist/worker/model-control.js +0 -1
- package/dist/worker/model-control.js.map +2 -2
- package/dist/worker.js +14 -12
- package/dist/worker.js.map +2 -2
- package/docs/agents.md +7 -3
- package/docs/architecture.md +1 -1
- package/docs/components.md +30 -1
- package/docs/configuration.md +24 -10
- package/docs/entropy.md +17 -1
- package/docs/jev.md +68 -3
- package/docs/memory-recall.md +21 -0
- package/package.json +5 -2
- package/skillsets/python/fabric-exec/references/agents.md +2 -0
- package/skillsets/python/fabric-jev/SKILL.md +1 -1
- package/skillsets/typescript/fabric-exec/SKILL.md +5 -1
- package/skillsets/typescript/fabric-exec/references/agents.md +4 -0
- package/skillsets/typescript/fabric-jev/SKILL.md +1 -1
- package/dist/chunks/chunk-2DMJ7MEI.js.map +0 -7
- package/dist/chunks/chunk-2PZWDVJB.js.map +0 -7
- package/dist/chunks/chunk-3MEHEH6B.js.map +0 -7
- package/dist/chunks/chunk-4SSMGBF4.js.map +0 -7
- package/dist/chunks/chunk-656HWVFU.js.map +0 -7
- package/dist/chunks/chunk-ARLYAW2A.js.map +0 -7
- package/dist/chunks/chunk-BOTRGFQQ.js.map +0 -7
- package/dist/chunks/chunk-CI56CW53.js.map +0 -7
- package/dist/chunks/chunk-CPSW2GW4.js.map +0 -7
- package/dist/chunks/chunk-PH7ZJ27F.js.map +0 -7
- package/dist/chunks/chunk-RERA6YWA.js.map +0 -7
- package/dist/chunks/chunk-RNOPHITP.js.map +0 -7
- package/dist/chunks/chunk-TSRKCXNI.js +0 -17
- package/dist/chunks/chunk-TSRKCXNI.js.map +0 -7
- package/dist/chunks/chunk-UDFDF7IY.js.map +0 -7
- package/dist/chunks/chunk-VRZNFNPB.js.map +0 -7
- package/dist/chunks/chunk-Y7KNRAFL.js.map +0 -7
- package/dist/chunks/chunk-ZZ4LHQYJ.js.map +0 -7
- /package/dist/chunks/{chunk-GXNR6NRU.js.map → chunk-2IAVP4O2.js.map} +0 -0
- /package/dist/chunks/{chunk-OP2KTYQB.js.map → chunk-D6YSBP3R.js.map} +0 -0
- /package/dist/chunks/{chunk-U6CTHPZC.js.map → chunk-MQG5QKGI.js.map} +0 -0
- /package/dist/chunks/{chunk-2UQV52II.js.map → chunk-RZKN534S.js.map} +0 -0
- /package/dist/chunks/{chunk-YK5AZ7CZ.js.map → chunk-ULLIZPBH.js.map} +0 -0
- /package/dist/chunks/{chunk-UTR3I23Z.js.map → chunk-W63E3WEO.js.map} +0 -0
- /package/dist/chunks/{chunk-4JETKRFE.js.map → chunk-ZHJNWM6A.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/protocol.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\n\nexport const FABRIC_PROVIDER_REGISTER_EVENT = \"pi-fabric:provider:register:v1\";\nexport const FABRIC_PROVIDER_DISCOVER_EVENT = \"pi-fabric:provider:discover:v1\";\nexport const FABRIC_COMPONENT_REGISTER_EVENT = \"pi-fabric:component:register:v1\";\nexport const FABRIC_COMPONENT_DISCOVER_EVENT = \"pi-fabric:component:discover:v1\";\nexport const FABRIC_PREWALK_REQUEST_EVENT = \"pi-fabric:prewalk:request:v1\";\n\nexport type FabricPrewalkRequestResultV1 =\n | { ok: true }\n | { ok: false; error: string };\n\n/** Host-local request used by queue extensions that need an acknowledged prewalk arm. */\nexport interface FabricPrewalkRequestV1 {\n version: 1;\n context: ExtensionContext;\n claim: () => boolean;\n respond: (result: FabricPrewalkRequestResultV1) => void;\n}\n\nexport const readFabricPrewalkRequestV1 = (\n value: unknown,\n): FabricPrewalkRequestV1 | undefined => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined;\n const record = value as Record<string, unknown>;\n if (\n record.version !== 1 ||\n typeof record.context !== \"object\" ||\n record.context === null ||\n typeof record.claim !== \"function\" ||\n typeof record.respond !== \"function\"\n ) {\n return undefined;\n }\n return value as FabricPrewalkRequestV1;\n};\n\nexport const FABRIC_PEER_CARDS_EVENT = \"pi-fabric:peers:cards:v1\";\nexport const FABRIC_PEER_AWAIT_SETTLE_EVENT = \"pi-fabric:peer:await-settle:v1\";\n\n/** One root peer session on the project mesh, for pickers and status lines. */\nexport interface FabricPeerCardV1 {\n id: string;\n /** Linear-style project label (e.g. \"PQS-2\") minted by the owning host. */\n label: string;\n status: \"idle\" | \"running\";\n model?: string;\n cwd?: string;\n startedAt: number;\n updatedAt: number;\n pendingMessages: boolean;\n}\n\nexport type FabricPeerCardsResultV1 =\n | { ok: true; cards: FabricPeerCardV1[] }\n | { ok: false; error: string };\n\n/** Host-local request used by queue extensions to enumerate live peer sessions. */\nexport interface FabricPeerCardsRequestV1 {\n version: 1;\n context: ExtensionContext;\n claim: () => boolean;\n respond: (result: FabricPeerCardsResultV1) => void;\n}\n\nexport const readFabricPeerCardsRequestV1 = (\n value: unknown,\n): FabricPeerCardsRequestV1 | undefined => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined;\n const record = value as Record<string, unknown>;\n if (\n record.version !== 1 ||\n typeof record.context !== \"object\" ||\n record.context === null ||\n typeof record.claim !== \"function\" ||\n typeof record.respond !== \"function\"\n ) {\n return undefined;\n }\n return value as FabricPeerCardsRequestV1;\n};\n\nexport interface FabricPeerSettleProgressV1 {\n waiting: Array<{ label: string; status: \"idle\" | \"running\" }>;\n}\n\nexport type FabricPeerAwaitSettleResultV1 =\n | { ok: true }\n | { ok: false; error: string };\n\n/**\n * Host-local request used by queue extensions to hold dispatch until peer\n * sessions settle. A peer counts as settled once it has been quiet\n * (status-wide) for settledForMs; peers that vanish from the mesh count as\n * settled since they can no longer conflict. Selector matches a peer label\n * (case-insensitive) or exact participant id; omitted waits on all peers.\n */\nexport interface FabricPeerAwaitSettleRequestV1 {\n version: 1;\n context: ExtensionContext;\n selector?: string;\n settledForMs?: number;\n signal?: AbortSignal;\n update?: (progress: FabricPeerSettleProgressV1) => void;\n claim: () => boolean;\n respond: (result: FabricPeerAwaitSettleResultV1) => void;\n}\n\nexport const readFabricPeerAwaitSettleRequestV1 = (\n value: unknown,\n): FabricPeerAwaitSettleRequestV1 | undefined => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined;\n const record = value as Record<string, unknown>;\n const signal = record.signal as AbortSignal | undefined;\n if (\n record.version !== 1 ||\n typeof record.context !== \"object\" ||\n record.context === null ||\n typeof record.claim !== \"function\" ||\n typeof record.respond !== \"function\" ||\n (record.selector !== undefined && typeof record.selector !== \"string\") ||\n (record.settledForMs !== undefined && typeof record.settledForMs !== \"number\") ||\n (signal !== undefined && typeof signal.aborted !== \"boolean\") ||\n (record.update !== undefined && typeof record.update !== \"function\")\n ) {\n return undefined;\n }\n return value as FabricPeerAwaitSettleRequestV1;\n};\n\n/** Identifies host-side tool lifecycle events replayed for a nested Fabric call. */\nexport const FABRIC_NESTED_TOOL_CALL_ID_PREFIX = \"fabric_\";\n\n/** Discriminant for the transient details envelope on a proxied provider result. */\nexport const FABRIC_TOOL_RESULT_PROXY_KIND = \"pi-fabric.tool-result-proxy.v1\";\n\n/**\n * Host-only middleware details for non-Pi Fabric providers. `result` is the\n * exact value before maxNestedResultChars is enforced and is not persisted as\n * a separate Pi tool-result message.\n */\nexport interface FabricToolResultProxyDetailsV1 {\n kind: typeof FABRIC_TOOL_RESULT_PROXY_KIND;\n ref: string;\n result: unknown;\n}\n\nexport const readFabricToolResultProxyDetailsV1 = (\n value: unknown,\n): FabricToolResultProxyDetailsV1 | undefined => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined;\n const record = value as Record<string, unknown>;\n if (\n record.kind !== FABRIC_TOOL_RESULT_PROXY_KIND ||\n typeof record.ref !== \"string\" ||\n !Object.prototype.hasOwnProperty.call(record, \"result\")\n ) {\n return undefined;\n }\n return record as unknown as FabricToolResultProxyDetailsV1;\n};\n\nexport type FabricRisk = \"read\" | \"write\" | \"execute\" | \"network\" | \"agent\";\nexport type FabricEffectKind = \"none\" | \"scoped\" | \"transactional\" | \"emission\";\nexport type FabricEffectOrdering = \"commutative\" | \"ordered\" | \"unknown\";\n\nexport interface FabricActionEffect {\n kind: FabricEffectKind;\n resources?: string[];\n ordering?: FabricEffectOrdering;\n}\n\n/** MCP tool annotations (Model Context Protocol ToolAnnotations), cached when a runtime surfaces them. */\nexport interface FabricToolAnnotations {\n readOnlyHint?: boolean;\n idempotentHint?: boolean;\n destructiveHint?: boolean;\n openWorldHint?: boolean;\n}\nexport type FabricActivityEntityKind =\n | \"agent\"\n | \"actor\"\n | \"tool\"\n | \"extension\"\n | \"mcp\"\n | \"mesh\"\n | \"task\"\n | \"custom\";\n\nexport type FabricInvocationActivityUpdate =\n | { type: \"progress\"; message: string }\n | { type: \"entity\"; id: string; kind: FabricActivityEntityKind; name?: string }\n | { type: \"metrics\"; tokens?: number; toolCalls?: number; cost?: number };\n\nexport interface FabricMediaBlock {\n type: \"image\";\n data: string;\n mimeType: string;\n}\n\nexport interface FabricActionDescriptor {\n name: string;\n description: string;\n inputSchema: Record<string, unknown>;\n outputSchema?: Record<string, unknown>;\n risk: FabricRisk;\n namespace?: string;\n effect?: FabricActionEffect;\n annotations?: FabricToolAnnotations;\n}\n\nexport interface FabricCapabilityActionHead {\n key: string;\n parentKey: string;\n ref: string;\n name: string;\n description: string;\n descriptorHash: string;\n risk: FabricRisk;\n namespace?: string;\n effect?: FabricActionEffect;\n}\n\nexport interface FabricCapabilityProviderHead {\n key: string;\n parentKey: string;\n name: string;\n description: string;\n descriptorHash: string;\n actions: FabricCapabilityActionHead[];\n}\n\nexport interface FabricCapabilityBindingView {\n ref: string;\n provider: string;\n providerBindingId: string;\n generation: number;\n descriptorHash: string;\n}\n\nexport interface FabricCommittedCapabilityView {\n id: string;\n /** Runtime-local digest including provider binding generations. */\n digest: string;\n /** Portable digest of exact refs and descriptor semantics across runtimes. */\n semanticDigest: string;\n bindings: Record<string, FabricCapabilityBindingView>;\n}\n\nexport interface FabricCapabilityResolution {\n satisfied: boolean;\n missing: string[];\n optionalMissing: string[];\n view?: FabricCommittedCapabilityView;\n}\n\nexport interface 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}\n\nexport interface FabricProviderListRequest {\n namespace?: string;\n query?: string;\n limit?: number;\n}\n\n/** One named action whose arguments should be typed in guest declarations. */\nexport interface FabricNamedActionTypeSource {\n name: string;\n inputSchema: Record<string, unknown>;\n}\n\n/** One MCP server plus the tools to type for `mcp.<server>.*` guest calls. */\nexport interface FabricMcpServerTypeSource {\n server: string;\n tools: FabricNamedActionTypeSource[];\n}\n\nexport type {\n FabricKernel,\n FabricKernelRuntime,\n FabricHostCall,\n FabricSandboxOptions,\n FabricSandboxResult,\n FabricSandboxTerminationReason,\n} from \"./runtime/kernel.js\";\nexport type { FabricPythonRuntime } from \"./config.js\";\n\n/**\n * Live descriptor snapshot the registry hands to the guest declaration\n * builder so dynamic surfaces (mcp, extensions) get argument checking before\n * the sandbox runs. Empty/absent sections keep the loose static declarations.\n */\nexport interface FabricGuestTypeSources {\n mcpServers?: FabricMcpServerTypeSource[];\n extensionTools?: FabricNamedActionTypeSource[];\n}\n\n/**\n * Pre-rendered `declare const` blocks replacing the loose mcp/extensions\n * declaration lines. Values are full replacement text (helpers + declare).\n */\nexport interface FabricDynamicGuestDeclarations {\n mcp?: string;\n extensions?: string;\n}\n\nexport interface FabricInvocationContext {\n cwd: string;\n signal: AbortSignal | undefined;\n parentToolCallId: string;\n nestedToolCallId: string;\n extensionContext: ExtensionContext;\n update(message: string): void;\n activity?(update: FabricInvocationActivityUpdate): void;\n /** Host-supplied inside fabric_exec so agents.handoff schedules the outer-call boundary. */\n deferHandoff?(args: Record<string, unknown>): Record<string, unknown>;\n // Out-of-band image content blocks a provider (currently only pi.read of an\n // image file) wants attached to the call audit, so the single-call render can\n // re-attach them to the fabric_exec result content for pi core's kitty image\n // preview. Bypasses the result char bound that would truncate the base64.\n // `note` is the read tool's own text output (e.g. \"Read image file [image/png]\"),\n // captured after any tool_result patch so a handoff that strips pi's\n // non-vision note has run; used as the single-call body + content text so the\n // preview shows the clean note instead of the swapped description.\n attachMedia?(blocks: FabricMediaBlock[], note?: string): void;\n // Providers call this after mutable tool_call middleware has run so live and\n // durable audit surfaces reflect the arguments actually passed to the tool.\n updateArguments?(args: Record<string, unknown>): void;\n // Ephemeral renderer-only metadata. It is exposed to live Fabric previews but\n // never projected into the durable execution trace.\n attachPreview?(preview: unknown): void;\n capabilityView?: FabricCommittedCapabilityView;\n /** Advisory for ordinary calls; strict components reject concurrent conflicting effects. */\n effectPolicy?: \"advisory\" | \"strict\";\n}\n\nexport interface FabricScopedProviderResult {\n value: unknown;\n dispose(): void | Promise<void>;\n}\n\nexport interface FabricProvider {\n name: string;\n description: string;\n list(\n request: FabricProviderListRequest,\n context: FabricInvocationContext,\n ): Promise<FabricActionDescriptor[]>;\n describe(\n actionName: string,\n context: FabricInvocationContext,\n ): Promise<FabricActionDescriptor | undefined>;\n prepareArguments?(\n actionName: string,\n args: Record<string, unknown>,\n context: FabricInvocationContext,\n ): Record<string, unknown> | Promise<Record<string, unknown>>;\n invoke(\n actionName: string,\n args: Record<string, unknown>,\n context: FabricInvocationContext,\n ): Promise<unknown>;\n acquire?(\n actionName: string,\n args: Record<string, unknown>,\n context: FabricInvocationContext,\n ): Promise<FabricScopedProviderResult>;\n invocationEnded?(parentToolCallId: string): Promise<void>;\n subscribeCatalog?(listener: () => void): () => void;\n close?(): Promise<void>;\n}\n\nexport interface FabricProviderRegistration {\n version: 1;\n provider: FabricProvider;\n overwrite?: boolean;\n}\n\nexport interface FabricProviderDiscovery {\n version: 1;\n register(provider: FabricProvider, options?: { overwrite?: boolean }): void;\n}\n\nexport type {\n FabricCapabilityRequirement,\n FabricComponentChildOptions,\n FabricComponentContext,\n FabricComponentDefinition,\n FabricComponentDiscovery,\n FabricComponentDisposer,\n FabricComponentEffect,\n FabricComponentEffectConflict,\n FabricComponentEffectInfo,\n FabricComponentEffectOptions,\n FabricComponentEffectRegistration,\n FabricComponentEntry,\n FabricComponentGraph,\n FabricComponentGuarantee,\n FabricComponentHandle,\n FabricComponentInfo,\n FabricComponentProviderLease,\n FabricModelGuidance,\n FabricModelGuidanceInfo,\n FabricModelGuidancePlacement,\n FabricModelGuidanceTarget,\n FabricComponentProvision,\n FabricComponentRegistration,\n FabricComponentState,\n FabricComponentStopOptions,\n} from \"./components/types.js\";\n\nexport {\n FABRIC_EXECUTION_GUIDANCE_SLOT,\n MAX_FABRIC_MODEL_GUIDANCE_CONTENT_CHARS,\n MAX_FABRIC_MODEL_GUIDANCE_PER_COMPONENT,\n MAX_FABRIC_MODEL_GUIDANCE_REGISTRATIONS,\n MAX_FABRIC_MODEL_GUIDANCE_SNAPSHOT_CHARS,\n MAX_FABRIC_MODEL_GUIDANCE_TOTAL_CHARS,\n} from \"./components/model-guidance.js\";\n"],
|
|
4
|
+
"sourcesContent": ["import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\n\nexport const FABRIC_PROVIDER_REGISTER_EVENT = \"pi-fabric:provider:register:v1\";\nexport const FABRIC_PROVIDER_DISCOVER_EVENT = \"pi-fabric:provider:discover:v1\";\nexport const FABRIC_COMPONENT_REGISTER_EVENT = \"pi-fabric:component:register:v1\";\nexport const FABRIC_COMPONENT_DISCOVER_EVENT = \"pi-fabric:component:discover:v1\";\nexport const FABRIC_PREWALK_REQUEST_EVENT = \"pi-fabric:prewalk:request:v1\";\n\nexport type FabricPrewalkRequestResultV1 =\n | { ok: true }\n | { ok: false; error: string };\n\n/** Host-local request used by queue extensions that need an acknowledged prewalk arm. */\nexport interface FabricPrewalkRequestV1 {\n version: 1;\n context: ExtensionContext;\n claim: () => boolean;\n respond: (result: FabricPrewalkRequestResultV1) => void;\n}\n\nexport const readFabricPrewalkRequestV1 = (\n value: unknown,\n): FabricPrewalkRequestV1 | undefined => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined;\n const record = value as Record<string, unknown>;\n if (\n record.version !== 1 ||\n typeof record.context !== \"object\" ||\n record.context === null ||\n typeof record.claim !== \"function\" ||\n typeof record.respond !== \"function\"\n ) {\n return undefined;\n }\n return value as FabricPrewalkRequestV1;\n};\n\nexport const FABRIC_PEER_CARDS_EVENT = \"pi-fabric:peers:cards:v1\";\nexport const FABRIC_PEER_AWAIT_SETTLE_EVENT = \"pi-fabric:peer:await-settle:v1\";\n\n/** One root peer session on the project mesh, for pickers and status lines. */\nexport interface FabricPeerCardV1 {\n id: string;\n /** Linear-style project label (e.g. \"PQS-2\") minted by the owning host. */\n label: string;\n status: \"idle\" | \"running\";\n model?: string;\n cwd?: string;\n startedAt: number;\n updatedAt: number;\n pendingMessages: boolean;\n}\n\nexport type FabricPeerCardsResultV1 =\n | { ok: true; cards: FabricPeerCardV1[] }\n | { ok: false; error: string };\n\n/** Host-local request used by queue extensions to enumerate live peer sessions. */\nexport interface FabricPeerCardsRequestV1 {\n version: 1;\n context: ExtensionContext;\n claim: () => boolean;\n respond: (result: FabricPeerCardsResultV1) => void;\n}\n\nexport const readFabricPeerCardsRequestV1 = (\n value: unknown,\n): FabricPeerCardsRequestV1 | undefined => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined;\n const record = value as Record<string, unknown>;\n if (\n record.version !== 1 ||\n typeof record.context !== \"object\" ||\n record.context === null ||\n typeof record.claim !== \"function\" ||\n typeof record.respond !== \"function\"\n ) {\n return undefined;\n }\n return value as FabricPeerCardsRequestV1;\n};\n\nexport interface FabricPeerSettleProgressV1 {\n waiting: Array<{ label: string; status: \"idle\" | \"running\" }>;\n}\n\nexport type FabricPeerAwaitSettleResultV1 =\n | { ok: true }\n | { ok: false; error: string };\n\n/**\n * Host-local request used by queue extensions to hold dispatch until peer\n * sessions settle. A peer counts as settled once it has been quiet\n * (status-wide) for settledForMs; peers that vanish from the mesh count as\n * settled since they can no longer conflict. Selector matches a peer label\n * (case-insensitive) or exact participant id; omitted waits on all peers.\n */\nexport interface FabricPeerAwaitSettleRequestV1 {\n version: 1;\n context: ExtensionContext;\n selector?: string;\n settledForMs?: number;\n signal?: AbortSignal;\n update?: (progress: FabricPeerSettleProgressV1) => void;\n claim: () => boolean;\n respond: (result: FabricPeerAwaitSettleResultV1) => void;\n}\n\nexport const readFabricPeerAwaitSettleRequestV1 = (\n value: unknown,\n): FabricPeerAwaitSettleRequestV1 | undefined => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined;\n const record = value as Record<string, unknown>;\n const signal = record.signal as AbortSignal | undefined;\n if (\n record.version !== 1 ||\n typeof record.context !== \"object\" ||\n record.context === null ||\n typeof record.claim !== \"function\" ||\n typeof record.respond !== \"function\" ||\n (record.selector !== undefined && typeof record.selector !== \"string\") ||\n (record.settledForMs !== undefined && typeof record.settledForMs !== \"number\") ||\n (signal !== undefined && typeof signal.aborted !== \"boolean\") ||\n (record.update !== undefined && typeof record.update !== \"function\")\n ) {\n return undefined;\n }\n return value as FabricPeerAwaitSettleRequestV1;\n};\n\n/** Identifies host-side tool lifecycle events replayed for a nested Fabric call. */\nexport const FABRIC_NESTED_TOOL_CALL_ID_PREFIX = \"fabric_\";\n\n/** Discriminant for the transient details envelope on a proxied provider result. */\nexport const FABRIC_TOOL_RESULT_PROXY_KIND = \"pi-fabric.tool-result-proxy.v1\";\n\n/**\n * Host-only middleware details for non-Pi Fabric providers. `result` is the\n * exact value before maxNestedResultChars is enforced and is not persisted as\n * a separate Pi tool-result message.\n */\nexport interface FabricToolResultProxyDetailsV1 {\n kind: typeof FABRIC_TOOL_RESULT_PROXY_KIND;\n ref: string;\n result: unknown;\n}\n\nexport const readFabricToolResultProxyDetailsV1 = (\n value: unknown,\n): FabricToolResultProxyDetailsV1 | undefined => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined;\n const record = value as Record<string, unknown>;\n if (\n record.kind !== FABRIC_TOOL_RESULT_PROXY_KIND ||\n typeof record.ref !== \"string\" ||\n !Object.prototype.hasOwnProperty.call(record, \"result\")\n ) {\n return undefined;\n }\n return record as unknown as FabricToolResultProxyDetailsV1;\n};\n\nexport type FabricRisk = \"read\" | \"write\" | \"execute\" | \"network\" | \"agent\";\nexport type FabricEffectKind = \"none\" | \"scoped\" | \"transactional\" | \"emission\";\nexport type FabricEffectOrdering = \"commutative\" | \"ordered\" | \"unknown\";\n\nexport interface FabricActionEffect {\n kind: FabricEffectKind;\n resources?: string[];\n ordering?: FabricEffectOrdering;\n}\n\n/** MCP tool annotations (Model Context Protocol ToolAnnotations), cached when a runtime surfaces them. */\nexport interface FabricToolAnnotations {\n readOnlyHint?: boolean;\n idempotentHint?: boolean;\n destructiveHint?: boolean;\n openWorldHint?: boolean;\n}\nexport type FabricActivityEntityKind =\n | \"agent\"\n | \"actor\"\n | \"tool\"\n | \"extension\"\n | \"mcp\"\n | \"mesh\"\n | \"task\"\n | \"custom\";\n\nexport type FabricInvocationActivityUpdate =\n | { type: \"progress\"; message: string }\n | { type: \"entity\"; id: string; kind: FabricActivityEntityKind; name?: string }\n | { type: \"metrics\"; tokens?: number; toolCalls?: number; cost?: number };\n\nexport interface FabricMediaBlock {\n type: \"image\";\n data: string;\n mimeType: string;\n}\n\nexport interface FabricActionDescriptor {\n name: string;\n description: string;\n inputSchema: Record<string, unknown>;\n outputSchema?: Record<string, unknown>;\n risk: FabricRisk;\n namespace?: string;\n effect?: FabricActionEffect;\n annotations?: FabricToolAnnotations;\n}\n\nexport interface FabricCapabilityActionHead {\n key: string;\n parentKey: string;\n ref: string;\n name: string;\n description: string;\n descriptorHash: string;\n risk: FabricRisk;\n namespace?: string;\n effect?: FabricActionEffect;\n}\n\nexport interface FabricCapabilityProviderHead {\n key: string;\n parentKey: string;\n name: string;\n description: string;\n descriptorHash: string;\n actions: FabricCapabilityActionHead[];\n}\n\nexport interface FabricCapabilityBindingView {\n ref: string;\n provider: string;\n providerBindingId: string;\n generation: number;\n descriptorHash: string;\n}\n\nexport interface FabricCommittedCapabilityView {\n id: string;\n /** Runtime-local digest including provider binding generations. */\n digest: string;\n /** Portable digest of exact refs and descriptor semantics across runtimes. */\n semanticDigest: string;\n bindings: Record<string, FabricCapabilityBindingView>;\n}\n\nexport interface FabricCapabilityResolution {\n satisfied: boolean;\n missing: string[];\n optionalMissing: string[];\n view?: FabricCommittedCapabilityView;\n}\n\nexport interface 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}\n\nexport interface FabricProviderListRequest {\n namespace?: string;\n query?: string;\n limit?: number;\n}\n\n/** One named action whose arguments should be typed in guest declarations. */\nexport interface FabricNamedActionTypeSource {\n name: string;\n inputSchema: Record<string, unknown>;\n}\n\n/** One MCP server plus the tools to type for `mcp.<server>.*` guest calls. */\nexport interface FabricMcpServerTypeSource {\n server: string;\n tools: FabricNamedActionTypeSource[];\n}\n\nexport type {\n FabricKernel,\n FabricKernelRuntime,\n FabricHostCall,\n FabricSandboxOptions,\n FabricSandboxResult,\n FabricSandboxTerminationReason,\n} from \"./runtime/kernel.js\";\nexport type { FabricPythonRuntime } from \"./config.js\";\n\n/**\n * Live descriptor snapshot the registry hands to the guest declaration\n * builder so dynamic surfaces (mcp, extensions) get argument checking before\n * the sandbox runs. Empty/absent sections keep the loose static declarations.\n */\nexport interface FabricGuestTypeSources {\n mcpServers?: FabricMcpServerTypeSource[];\n extensionTools?: FabricNamedActionTypeSource[];\n}\n\n/**\n * Pre-rendered `declare const` blocks replacing the loose mcp/extensions\n * declaration lines. Values are full replacement text (helpers + declare).\n */\nexport interface FabricDynamicGuestDeclarations {\n mcp?: string;\n extensions?: string;\n}\n\nexport interface FabricInvocationContext {\n cwd: string;\n signal: AbortSignal | undefined;\n parentToolCallId: string;\n nestedToolCallId: string;\n extensionContext: ExtensionContext;\n update(message: string): void;\n activity?(update: FabricInvocationActivityUpdate): void;\n /** Host-supplied inside fabric_exec so agents.handoff schedules the outer-call boundary. */\n deferHandoff?(args: Record<string, unknown>): Record<string, unknown>;\n // Out-of-band image content blocks a provider (currently only pi.read of an\n // image file) wants attached to the call audit, so the single-call render can\n // re-attach them to the fabric_exec result content for pi core's kitty image\n // preview. Bypasses the result char bound that would truncate the base64.\n // `note` is the read tool's own text output (e.g. \"Read image file [image/png]\"),\n // captured after any tool_result patch so a handoff that strips pi's\n // non-vision note has run; used as the single-call body + content text so the\n // preview shows the clean note instead of the swapped description.\n attachMedia?(blocks: FabricMediaBlock[], note?: string): void;\n // Providers call this after mutable tool_call middleware has run so live and\n // durable audit surfaces reflect the arguments actually passed to the tool.\n updateArguments?(args: Record<string, unknown>): void;\n // Ephemeral renderer-only metadata. It is exposed to live Fabric previews but\n // never projected into the durable execution trace.\n attachPreview?(preview: unknown): void;\n capabilityView?: FabricCommittedCapabilityView;\n /** Advisory for ordinary calls; strict components reject concurrent conflicting effects. */\n effectPolicy?: \"advisory\" | \"strict\";\n}\n\nexport interface FabricScopedProviderResult {\n value: unknown;\n dispose(): void | Promise<void>;\n}\n\nexport interface FabricProvider {\n name: string;\n description: string;\n list(\n request: FabricProviderListRequest,\n context: FabricInvocationContext,\n ): Promise<FabricActionDescriptor[]>;\n describe(\n actionName: string,\n context: FabricInvocationContext,\n ): Promise<FabricActionDescriptor | undefined>;\n prepareArguments?(\n actionName: string,\n args: Record<string, unknown>,\n context: FabricInvocationContext,\n ): Record<string, unknown> | Promise<Record<string, unknown>>;\n invoke(\n actionName: string,\n args: Record<string, unknown>,\n context: FabricInvocationContext,\n ): Promise<unknown>;\n acquire?(\n actionName: string,\n args: Record<string, unknown>,\n context: FabricInvocationContext,\n ): Promise<FabricScopedProviderResult>;\n invocationEnded?(parentToolCallId: string): Promise<void>;\n subscribeCatalog?(listener: () => void): () => void;\n close?(): Promise<void>;\n}\n\nexport interface FabricProviderRegistration {\n version: 1;\n provider: FabricProvider;\n overwrite?: boolean;\n}\n\nexport interface FabricProviderDiscovery {\n version: 1;\n register(provider: FabricProvider, options?: { overwrite?: boolean }): void;\n}\n\nexport type {\n ComponentChangeRequest as FabricComponentChangeRequest,\n ComponentChangePlan as FabricComponentChangePlan,\n} from \"./components/control.js\";\n\nexport type {\n FabricCapabilityRequirement,\n FabricComponentChildOptions,\n FabricComponentContext,\n FabricComponentDefinition,\n FabricComponentDiscovery,\n FabricComponentDisposer,\n FabricComponentEffect,\n FabricComponentEffectConflict,\n FabricComponentEffectInfo,\n FabricComponentEffectOptions,\n FabricComponentEffectRegistration,\n FabricComponentEntry,\n FabricComponentGraph,\n FabricComponentGuarantee,\n FabricComponentHandle,\n FabricComponentInfo,\n FabricComponentProviderLease,\n FabricModelGuidance,\n FabricModelGuidanceInfo,\n FabricModelGuidancePlacement,\n FabricModelGuidanceTarget,\n FabricComponentProvision,\n FabricComponentRegistration,\n FabricComponentState,\n FabricComponentStopOptions,\n} from \"./components/types.js\";\n\nexport {\n FABRIC_EXECUTION_GUIDANCE_SLOT,\n MAX_FABRIC_MODEL_GUIDANCE_CONTENT_CHARS,\n MAX_FABRIC_MODEL_GUIDANCE_PER_COMPONENT,\n MAX_FABRIC_MODEL_GUIDANCE_REGISTRATIONS,\n MAX_FABRIC_MODEL_GUIDANCE_SNAPSHOT_CHARS,\n MAX_FABRIC_MODEL_GUIDANCE_TOTAL_CHARS,\n} from \"./components/model-guidance.js\";\n"],
|
|
5
5
|
"mappings": ";AAEO,IAAM,iCAAiC;AACvC,IAAM,iCAAiC;AACvC,IAAM,kCAAkC;AACxC,IAAM,kCAAkC;AACxC,IAAM,+BAA+B;AAcrC,IAAM,6BAA6B,CACxC,UACuC;AACvC,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,SAAS;AACf,MACE,OAAO,YAAY,KACnB,OAAO,OAAO,YAAY,YAC1B,OAAO,YAAY,QACnB,OAAO,OAAO,UAAU,cACxB,OAAO,OAAO,YAAY,YAC1B;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,IAAM,0BAA0B;AAChC,IAAM,iCAAiC;AA2BvC,IAAM,+BAA+B,CAC1C,UACyC;AACzC,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,SAAS;AACf,MACE,OAAO,YAAY,KACnB,OAAO,OAAO,YAAY,YAC1B,OAAO,YAAY,QACnB,OAAO,OAAO,UAAU,cACxB,OAAO,OAAO,YAAY,YAC1B;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AA4BO,IAAM,qCAAqC,CAChD,UAC+C;AAC/C,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,SAAS;AACf,QAAM,SAAS,OAAO;AACtB,MACE,OAAO,YAAY,KACnB,OAAO,OAAO,YAAY,YAC1B,OAAO,YAAY,QACnB,OAAO,OAAO,UAAU,cACxB,OAAO,OAAO,YAAY,cACzB,OAAO,aAAa,UAAa,OAAO,OAAO,aAAa,YAC5D,OAAO,iBAAiB,UAAa,OAAO,OAAO,iBAAiB,YACpE,WAAW,UAAa,OAAO,OAAO,YAAY,aAClD,OAAO,WAAW,UAAa,OAAO,OAAO,WAAW,YACzD;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAGO,IAAM,oCAAoC;AAG1C,IAAM,gCAAgC;AAatC,IAAM,qCAAqC,CAChD,UAC+C;AAC/C,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,SAAS;AACf,MACE,OAAO,SAAS,iCAChB,OAAO,OAAO,QAAQ,YACtB,CAAC,OAAO,UAAU,eAAe,KAAK,QAAQ,QAAQ,GACtD;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,222 +2,44 @@ import {
|
|
|
2
2
|
defaultCodePreviewSettings,
|
|
3
3
|
normalizeCodePreviewSettings
|
|
4
4
|
} from "./chunk-OKOHRXGF.js";
|
|
5
|
+
import {
|
|
6
|
+
closeScratch,
|
|
7
|
+
createScratch
|
|
8
|
+
} from "./chunk-RAO6TQFP.js";
|
|
5
9
|
import {
|
|
6
10
|
renameAtomic
|
|
7
11
|
} from "./chunk-KAD7UWT2.js";
|
|
12
|
+
import {
|
|
13
|
+
normalizeModelAliases
|
|
14
|
+
} from "./chunk-KI277YNS.js";
|
|
8
15
|
import {
|
|
9
16
|
DEFAULT_FABRIC_THINKING,
|
|
10
17
|
isFabricThinking
|
|
11
18
|
} from "./chunk-MGWQOKBV.js";
|
|
12
19
|
import {
|
|
13
20
|
DEFAULT_JEV_CONFIG,
|
|
21
|
+
normalizeJevApprovalModel,
|
|
14
22
|
normalizeJevConfig
|
|
15
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-X3OD47CL.js";
|
|
16
24
|
import {
|
|
17
25
|
PI_CORE_TOOL_NAME_SET
|
|
18
26
|
} from "./chunk-YU62DDKK.js";
|
|
19
27
|
|
|
20
|
-
// src/core/model-resolution.ts
|
|
21
|
-
var PROVIDER_MODEL_RE = /^[^\s/]+\/[^\s/]+$/;
|
|
22
|
-
var FUZZY_RESOLUTION_MARKERS = ["closest", "recent", "latest"];
|
|
23
|
-
var modelKey = (model) => `${model.provider}/${model.id}`;
|
|
24
|
-
var sameModel = (left, right) => right !== void 0 && left.provider.toLowerCase() === right.provider.toLowerCase() && left.id.toLowerCase() === right.id.toLowerCase();
|
|
25
|
-
var normalizeModelAliases = (input) => {
|
|
26
|
-
if (typeof input !== "object" || input === null || Array.isArray(input)) return {};
|
|
27
|
-
const aliases = {};
|
|
28
|
-
for (const [rawName, rawValue] of Object.entries(input)) {
|
|
29
|
-
const name = rawName.trim();
|
|
30
|
-
if (!name) continue;
|
|
31
|
-
const values = typeof rawValue === "string" ? [rawValue] : rawValue;
|
|
32
|
-
if (!Array.isArray(values) || values.length === 0) continue;
|
|
33
|
-
const targets = [];
|
|
34
|
-
let valid = true;
|
|
35
|
-
for (const candidate of values) {
|
|
36
|
-
if (typeof candidate !== "string") {
|
|
37
|
-
valid = false;
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
const target = candidate.trim();
|
|
41
|
-
if (!PROVIDER_MODEL_RE.test(target)) {
|
|
42
|
-
valid = false;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
if (!targets.includes(target)) targets.push(target);
|
|
46
|
-
}
|
|
47
|
-
if (valid && targets.length > 0) aliases[name] = targets;
|
|
48
|
-
}
|
|
49
|
-
return aliases;
|
|
50
|
-
};
|
|
51
|
-
var FUZZY_MIN_QUERY_LENGTH = 4;
|
|
52
|
-
var FUZZY_LEVENSHTEIN_MIN_RATIO = 0.55;
|
|
53
|
-
var subsequenceSpan = (needle, haystack) => {
|
|
54
|
-
let index = 0;
|
|
55
|
-
let first = -1;
|
|
56
|
-
let last = -1;
|
|
57
|
-
for (let i = 0; i < haystack.length && index < needle.length; i += 1) {
|
|
58
|
-
if (haystack[i] === needle[index]) {
|
|
59
|
-
if (first === -1) first = i;
|
|
60
|
-
last = i;
|
|
61
|
-
index += 1;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return index === needle.length ? last - first + 1 : Number.POSITIVE_INFINITY;
|
|
65
|
-
};
|
|
66
|
-
var levenshteinRatio = (left, right) => {
|
|
67
|
-
if (left === right) return 1;
|
|
68
|
-
if (left.length === 0 || right.length === 0) return 0;
|
|
69
|
-
let previous = Array.from({ length: right.length + 1 }, (_, column) => column);
|
|
70
|
-
for (let i = 0; i < left.length; i += 1) {
|
|
71
|
-
const current = [i + 1];
|
|
72
|
-
for (let j = 0; j < right.length; j += 1) {
|
|
73
|
-
current.push(Math.min(
|
|
74
|
-
previous[j] + 1,
|
|
75
|
-
current[j] + 1,
|
|
76
|
-
previous[j] + (left[i] === right[j] ? 0 : 1)
|
|
77
|
-
));
|
|
78
|
-
}
|
|
79
|
-
previous = current;
|
|
80
|
-
}
|
|
81
|
-
return 1 - previous[right.length] / Math.max(left.length, right.length);
|
|
82
|
-
};
|
|
83
|
-
var closenessScore = (query, model) => {
|
|
84
|
-
const id = model.id.toLowerCase();
|
|
85
|
-
const name = model.name?.toLowerCase();
|
|
86
|
-
if (id.startsWith(query)) return 60 + query.length / id.length * 20;
|
|
87
|
-
if (id.includes(query)) return 50 + query.length / id.length * 15;
|
|
88
|
-
if (name?.startsWith(query) === true) return 45 + query.length / name.length * 15;
|
|
89
|
-
if (name?.includes(query) === true) return 40 + query.length / name.length * 10;
|
|
90
|
-
if (model.provider.toLowerCase().includes(query)) return 25;
|
|
91
|
-
if (query.length >= 3 && query[0] === id[0] && subsequenceSpan(query, id) <= query.length + 2) {
|
|
92
|
-
return 18 + query.length / id.length * 6;
|
|
93
|
-
}
|
|
94
|
-
if (query.length >= FUZZY_MIN_QUERY_LENGTH) {
|
|
95
|
-
const idRatio = levenshteinRatio(query, id);
|
|
96
|
-
if (idRatio >= FUZZY_LEVENSHTEIN_MIN_RATIO) return 8 + idRatio * 10;
|
|
97
|
-
if (name !== void 0) {
|
|
98
|
-
const nameRatio = levenshteinRatio(query, name);
|
|
99
|
-
if (nameRatio >= FUZZY_LEVENSHTEIN_MIN_RATIO) return 6 + nameRatio * 8;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return 0;
|
|
103
|
-
};
|
|
104
|
-
var pickClosestCandidate = (query, pool, lastUsed) => {
|
|
105
|
-
const usage = {};
|
|
106
|
-
for (const [key, value] of Object.entries(lastUsed ?? {})) {
|
|
107
|
-
usage[key.toLowerCase()] = value;
|
|
108
|
-
}
|
|
109
|
-
const recency = (model) => usage[`${model.provider}/${model.id}`.toLowerCase()] ?? 0;
|
|
110
|
-
let best;
|
|
111
|
-
let bestScore = 0;
|
|
112
|
-
let tied = false;
|
|
113
|
-
for (const model of pool) {
|
|
114
|
-
const score = closenessScore(query, model);
|
|
115
|
-
if (score <= 0) continue;
|
|
116
|
-
if (best === void 0 || score > bestScore) {
|
|
117
|
-
best = model;
|
|
118
|
-
bestScore = score;
|
|
119
|
-
tied = false;
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
if (score === bestScore) {
|
|
123
|
-
tied = true;
|
|
124
|
-
const bestRecent = recency(best);
|
|
125
|
-
const nextRecent = recency(model);
|
|
126
|
-
if (nextRecent > bestRecent || nextRecent === bestRecent && modelKey(model) > modelKey(best)) {
|
|
127
|
-
best = model;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (best === void 0) return void 0;
|
|
132
|
-
const runnersUp = pool.filter(
|
|
133
|
-
(model) => model !== best && closenessScore(query, model) === bestScore
|
|
134
|
-
);
|
|
135
|
-
const wonOnRecency = tied && runnersUp.some((model) => recency(model) !== recency(best));
|
|
136
|
-
return {
|
|
137
|
-
model: best,
|
|
138
|
-
via: !tied ? "closest" : wonOnRecency ? "recent" : "latest"
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
var resolveFabricModel = (query, options) => {
|
|
142
|
-
const normalized = query.trim().toLowerCase();
|
|
143
|
-
if (!normalized) return { kind: "not-found", query };
|
|
144
|
-
const providerFilter = options.provider?.trim().toLowerCase();
|
|
145
|
-
const available = providerFilter ? options.available.filter((model) => model.provider.toLowerCase() === providerFilter) : [...options.available];
|
|
146
|
-
if (available.length === 0) return { kind: "not-found", query };
|
|
147
|
-
const aliasKey = Object.keys(options.aliases).find(
|
|
148
|
-
(key) => key.toLowerCase() === normalized
|
|
149
|
-
);
|
|
150
|
-
const tried = [];
|
|
151
|
-
if (aliasKey !== void 0) {
|
|
152
|
-
const chain = options.aliases[aliasKey] ?? [];
|
|
153
|
-
for (const target of chain) {
|
|
154
|
-
tried.push(target);
|
|
155
|
-
const separator = target.indexOf("/");
|
|
156
|
-
const provider = target.slice(0, separator);
|
|
157
|
-
const id = target.slice(separator + 1);
|
|
158
|
-
const match = available.find(
|
|
159
|
-
(model) => model.provider.toLowerCase() === provider.toLowerCase() && model.id.toLowerCase() === id.toLowerCase()
|
|
160
|
-
);
|
|
161
|
-
if (match) {
|
|
162
|
-
return sameModel(match, options.current) ? { kind: "already-active", model: match } : { kind: "resolved", model: match, via: aliasKey };
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return { kind: "not-found", query, tried };
|
|
166
|
-
}
|
|
167
|
-
const exact = available.find((model) => modelKey(model).toLowerCase() === normalized) ?? available.find((model) => model.id.toLowerCase() === normalized);
|
|
168
|
-
if (exact) {
|
|
169
|
-
return sameModel(exact, options.current) ? { kind: "already-active", model: exact } : { kind: "resolved", model: exact };
|
|
170
|
-
}
|
|
171
|
-
const candidates = available.filter(
|
|
172
|
-
(model) => model.id.toLowerCase().includes(normalized) || model.name !== void 0 && model.name.toLowerCase().includes(normalized) || model.provider.toLowerCase().includes(normalized)
|
|
173
|
-
);
|
|
174
|
-
if (candidates.length === 1) {
|
|
175
|
-
const match = candidates[0];
|
|
176
|
-
if (match === void 0) return { kind: "not-found", query };
|
|
177
|
-
return sameModel(match, options.current) ? { kind: "already-active", model: match } : { kind: "resolved", model: match };
|
|
178
|
-
}
|
|
179
|
-
const pool = candidates.length > 1 ? candidates : available;
|
|
180
|
-
const picked = pickClosestCandidate(normalized, pool, options.lastUsed);
|
|
181
|
-
if (picked) {
|
|
182
|
-
return sameModel(picked.model, options.current) ? { kind: "already-active", model: picked.model } : { kind: "resolved", model: picked.model, via: picked.via };
|
|
183
|
-
}
|
|
184
|
-
if (candidates.length > 1) return { kind: "ambiguous", query, candidates };
|
|
185
|
-
return { kind: "not-found", query };
|
|
186
|
-
};
|
|
187
|
-
var unavailablePiModelError = (query, resolution) => {
|
|
188
|
-
const detail = resolution?.kind === "not-found" && resolution.tried !== void 0 ? ` Alias targets tried: ${resolution.tried.join(", ")}.` : resolution?.kind === "ambiguous" ? ` Visible matches: ${resolution.candidates.map(modelKey).join(", ")}.` : "";
|
|
189
|
-
return new Error(
|
|
190
|
-
`Model ${JSON.stringify(query)} is not available to this Pi session.${detail} Use agents.models({ runner: "pi" }) to list the models visible to this session.`
|
|
191
|
-
);
|
|
192
|
-
};
|
|
193
|
-
var resolveAvailablePiModel = (selector, options) => {
|
|
194
|
-
const query = selector.trim();
|
|
195
|
-
const alias = Object.keys(options.aliases).some(
|
|
196
|
-
(name) => name.toLowerCase() === query.toLowerCase()
|
|
197
|
-
);
|
|
198
|
-
if (PROVIDER_MODEL_RE.test(query) && !alias) {
|
|
199
|
-
const exact = options.available.find(
|
|
200
|
-
(model) => modelKey(model).toLowerCase() === query.toLowerCase()
|
|
201
|
-
);
|
|
202
|
-
if (exact) return exact;
|
|
203
|
-
throw unavailablePiModelError(query);
|
|
204
|
-
}
|
|
205
|
-
const resolution = resolveFabricModel(query, options);
|
|
206
|
-
if (resolution.kind === "resolved" || resolution.kind === "already-active") {
|
|
207
|
-
return resolution.model;
|
|
208
|
-
}
|
|
209
|
-
throw unavailablePiModelError(query, resolution);
|
|
210
|
-
};
|
|
211
|
-
|
|
212
28
|
// src/core/shell-jobs.ts
|
|
213
|
-
import
|
|
214
|
-
import { readFile, unlink
|
|
29
|
+
import fs from "node:fs";
|
|
30
|
+
import { readFile, unlink } from "node:fs/promises";
|
|
215
31
|
import { tmpdir } from "node:os";
|
|
216
32
|
import path from "node:path";
|
|
217
33
|
import { randomUUID } from "node:crypto";
|
|
218
34
|
var DEFAULT_SHELL_HANG_MS = 12e4;
|
|
219
35
|
var SHELL_HANG_MAX_MS = 6e5;
|
|
220
36
|
var SHELL_HANG_SNAPSHOT_BYTES = 8e3;
|
|
37
|
+
var SHELL_TAIL_BYTES = 1024 * 1024;
|
|
38
|
+
var SHELL_LOG_BYTES = 8 * 1024 * 1024;
|
|
39
|
+
var SHELL_COMPLETED_HANDLES = 256;
|
|
40
|
+
var SHELL_COMPLETED_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
41
|
+
var LOG_HEADER = "[Bounded shell log: starts with retained pre-spill tail; 8 MiB total cap, then further output is omitted. Not a full-output archive.]\n";
|
|
42
|
+
var LOG_TRUNCATED = "\n[Shell log truncated: disk limit reached; subsequent output omitted.]\n";
|
|
221
43
|
var posixQuote = (value) => "'" + value.replaceAll("'", "'\\''") + "'";
|
|
222
44
|
var powershellQuote = (value) => "'" + value.replaceAll("'", "''") + "'";
|
|
223
45
|
var wrapShellCommandForPid = (command, pidPath, tool) => tool === "powershell" ? `Set-Content -LiteralPath ${powershellQuote(pidPath)} -Value $PID
|
|
@@ -226,7 +48,7 @@ ${command}`;
|
|
|
226
48
|
var formatShellHangNotice = (input) => {
|
|
227
49
|
const seconds = Math.max(1, Math.round(input.elapsedMs / 1e3));
|
|
228
50
|
const pid = input.pid !== void 0 ? ` (pid ${input.pid})` : "";
|
|
229
|
-
return `[Still running after ${seconds}s${pid}.
|
|
51
|
+
return `[Still running after ${seconds}s${pid}. Bounded live output (may be truncated): ${input.logPath}]`;
|
|
230
52
|
};
|
|
231
53
|
var appendShellHangNotice = (output, notice) => output ? `${output}
|
|
232
54
|
|
|
@@ -236,6 +58,14 @@ var parseShellPid = (text) => {
|
|
|
236
58
|
return Number.isSafeInteger(pid) && pid > 1 ? pid : void 0;
|
|
237
59
|
};
|
|
238
60
|
var FabricShellJob = class {
|
|
61
|
+
constructor(tool, command, onFinish, tempRoot) {
|
|
62
|
+
this.onFinish = onFinish;
|
|
63
|
+
this.id = randomUUID();
|
|
64
|
+
this.tool = tool;
|
|
65
|
+
this.command = command;
|
|
66
|
+
this.#directory = createScratch("shell", tempRoot);
|
|
67
|
+
this.pidPath = path.join(this.#directory, "child.pid");
|
|
68
|
+
}
|
|
239
69
|
id;
|
|
240
70
|
tool;
|
|
241
71
|
command;
|
|
@@ -250,33 +80,81 @@ var FabricShellJob = class {
|
|
|
250
80
|
finishedAt;
|
|
251
81
|
exitCode;
|
|
252
82
|
status = "running";
|
|
253
|
-
#
|
|
254
|
-
#
|
|
83
|
+
#tail = Buffer.alloc(0);
|
|
84
|
+
#omitted = false;
|
|
85
|
+
#directory;
|
|
86
|
+
#descriptor;
|
|
87
|
+
#logBytes = 0;
|
|
88
|
+
#logTruncated = false;
|
|
255
89
|
#spill = new AbortController();
|
|
256
90
|
#pidRead;
|
|
257
|
-
constructor(tool, command) {
|
|
258
|
-
this.id = randomUUID();
|
|
259
|
-
this.tool = tool;
|
|
260
|
-
this.command = command;
|
|
261
|
-
this.pidPath = path.join(tmpdir(), `pi-fabric-shell-${this.id}.pid`);
|
|
262
|
-
}
|
|
263
91
|
append(data) {
|
|
264
92
|
if (this.finished) return;
|
|
265
|
-
|
|
266
|
-
this.#
|
|
93
|
+
const keep = Math.max(0, SHELL_TAIL_BYTES - data.length);
|
|
94
|
+
if (this.#tail.length + data.length > SHELL_TAIL_BYTES) this.#omitted = true;
|
|
95
|
+
this.#tail = Buffer.concat([
|
|
96
|
+
this.#tail.subarray(Math.max(0, this.#tail.length - keep)),
|
|
97
|
+
data.subarray(Math.max(0, data.length - SHELL_TAIL_BYTES))
|
|
98
|
+
]);
|
|
99
|
+
this.#writeLog(data);
|
|
100
|
+
}
|
|
101
|
+
#writeLog(data) {
|
|
102
|
+
if (this.#descriptor === void 0 || this.#logTruncated) return;
|
|
103
|
+
const available = Math.max(0, SHELL_LOG_BYTES - Buffer.byteLength(LOG_TRUNCATED) - this.#logBytes);
|
|
104
|
+
try {
|
|
105
|
+
const chunk = data.subarray(0, available);
|
|
106
|
+
let offset = 0;
|
|
107
|
+
while (offset < chunk.length) {
|
|
108
|
+
const written = fs.writeSync(this.#descriptor, chunk, offset);
|
|
109
|
+
if (written <= 0) throw new Error("Shell log write made no progress");
|
|
110
|
+
offset += written;
|
|
111
|
+
}
|
|
112
|
+
this.#logBytes += chunk.length;
|
|
113
|
+
if (chunk.length < data.length) {
|
|
114
|
+
fs.writeSync(this.#descriptor, LOG_TRUNCATED);
|
|
115
|
+
this.#logTruncated = true;
|
|
116
|
+
}
|
|
117
|
+
} catch {
|
|
118
|
+
try {
|
|
119
|
+
fs.closeSync(this.#descriptor);
|
|
120
|
+
} catch {
|
|
121
|
+
}
|
|
122
|
+
this.#descriptor = void 0;
|
|
123
|
+
this.#logTruncated = true;
|
|
124
|
+
}
|
|
267
125
|
}
|
|
268
126
|
snapshotText(maxBytes = SHELL_HANG_SNAPSHOT_BYTES) {
|
|
269
|
-
const
|
|
270
|
-
const slice =
|
|
271
|
-
|
|
127
|
+
const limit = Number.isFinite(maxBytes) ? Math.max(0, Math.floor(maxBytes)) : SHELL_TAIL_BYTES;
|
|
128
|
+
const slice = this.#tail.subarray(Math.max(0, this.#tail.length - limit));
|
|
129
|
+
const truncated = this.#omitted || slice.length < this.#tail.length;
|
|
130
|
+
return `${truncated ? "[Output truncated; retained tail follows]\n" : ""}${slice.toString("utf8")}`;
|
|
272
131
|
}
|
|
273
132
|
async persistLog() {
|
|
274
133
|
if (this.logPath) return this.logPath;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
134
|
+
if (this.finished) throw new Error("Shell job finished before a log was requested");
|
|
135
|
+
const logPath = path.join(this.#directory, "output.log");
|
|
136
|
+
try {
|
|
137
|
+
this.#descriptor = fs.openSync(logPath, "wx", 384);
|
|
138
|
+
fs.writeSync(this.#descriptor, LOG_HEADER);
|
|
139
|
+
this.#logBytes = Buffer.byteLength(LOG_HEADER);
|
|
140
|
+
if (this.#omitted) this.#writeLog(Buffer.from("[Pre-spill output truncated: only the last 1 MiB was retained.]\n"));
|
|
141
|
+
this.#writeLog(this.#tail);
|
|
142
|
+
this.logPath = logPath;
|
|
143
|
+
return logPath;
|
|
144
|
+
} catch (error) {
|
|
145
|
+
if (this.#descriptor !== void 0) {
|
|
146
|
+
try {
|
|
147
|
+
fs.closeSync(this.#descriptor);
|
|
148
|
+
} catch {
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
this.#descriptor = void 0;
|
|
152
|
+
try {
|
|
153
|
+
fs.unlinkSync(logPath);
|
|
154
|
+
} catch {
|
|
155
|
+
}
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
280
158
|
}
|
|
281
159
|
async readPid() {
|
|
282
160
|
if (this.pid !== void 0) return this.pid;
|
|
@@ -311,7 +189,9 @@ var FabricShellJob = class {
|
|
|
311
189
|
}
|
|
312
190
|
async finish(exitCode, footer) {
|
|
313
191
|
if (this.finished) return;
|
|
192
|
+
const persistence = this.spilled && !this.logPath ? this.persistLog() : void 0;
|
|
314
193
|
this.finished = true;
|
|
194
|
+
await persistence?.catch(() => void 0);
|
|
315
195
|
this.finishedAt = Date.now();
|
|
316
196
|
if (exitCode !== void 0) this.exitCode = exitCode;
|
|
317
197
|
if (this.status === "running") {
|
|
@@ -319,20 +199,27 @@ var FabricShellJob = class {
|
|
|
319
199
|
} else if (this.abort.signal.aborted && this.status === "spilled") {
|
|
320
200
|
this.status = "killed";
|
|
321
201
|
}
|
|
322
|
-
if (footer
|
|
323
|
-
`);
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
202
|
+
if (footer) this.#writeLog(Buffer.from(footer.endsWith("\n") ? footer : `${footer}
|
|
203
|
+
`));
|
|
204
|
+
if (this.#descriptor !== void 0) {
|
|
205
|
+
try {
|
|
206
|
+
fs.closeSync(this.#descriptor);
|
|
207
|
+
} catch {
|
|
328
208
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
this.#
|
|
209
|
+
}
|
|
210
|
+
this.#descriptor = void 0;
|
|
211
|
+
this.#tail = Buffer.alloc(0);
|
|
212
|
+
this.#omitted = false;
|
|
332
213
|
if (!this.#spill.signal.aborted) this.#spill.abort();
|
|
333
|
-
|
|
334
|
-
|
|
214
|
+
await unlink(this.pidPath).catch(() => void 0);
|
|
215
|
+
if (this.logPath) closeScratch(this.#directory);
|
|
216
|
+
else {
|
|
217
|
+
try {
|
|
218
|
+
fs.rmSync(this.#directory, { recursive: true, force: true });
|
|
219
|
+
} catch {
|
|
220
|
+
}
|
|
335
221
|
}
|
|
222
|
+
this.onFinish();
|
|
336
223
|
}
|
|
337
224
|
info() {
|
|
338
225
|
return {
|
|
@@ -359,16 +246,29 @@ var trackShellOperations = (inner, job, tool) => ({
|
|
|
359
246
|
})
|
|
360
247
|
});
|
|
361
248
|
var FabricShellJobStore = class {
|
|
249
|
+
constructor(tempRoot = tmpdir()) {
|
|
250
|
+
this.tempRoot = tempRoot;
|
|
251
|
+
}
|
|
362
252
|
#jobs = /* @__PURE__ */ new Map();
|
|
253
|
+
#prune() {
|
|
254
|
+
const completed = [...this.#jobs.values()].filter((job) => job.finished);
|
|
255
|
+
completed.sort((a, b) => (a.finishedAt ?? 0) - (b.finishedAt ?? 0));
|
|
256
|
+
for (const [index, job] of completed.entries()) {
|
|
257
|
+
if (index < completed.length - SHELL_COMPLETED_HANDLES || Date.now() - (job.finishedAt ?? 0) >= SHELL_COMPLETED_MAX_AGE_MS) this.#jobs.delete(job.id);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
363
260
|
begin(tool, command) {
|
|
364
|
-
|
|
261
|
+
this.#prune();
|
|
262
|
+
const job = new FabricShellJob(tool, command, () => this.#prune(), this.tempRoot);
|
|
365
263
|
this.#jobs.set(job.id, job);
|
|
366
264
|
return job;
|
|
367
265
|
}
|
|
368
266
|
get(id) {
|
|
267
|
+
this.#prune();
|
|
369
268
|
return this.#jobs.get(id);
|
|
370
269
|
}
|
|
371
270
|
list() {
|
|
271
|
+
this.#prune();
|
|
372
272
|
return [...this.#jobs.values()].map((job) => job.info());
|
|
373
273
|
}
|
|
374
274
|
waiting() {
|
|
@@ -457,12 +357,12 @@ var raceShellHang = async (options) => {
|
|
|
457
357
|
};
|
|
458
358
|
|
|
459
359
|
// src/config.ts
|
|
460
|
-
import
|
|
360
|
+
import fs3 from "node:fs";
|
|
461
361
|
import os from "node:os";
|
|
462
362
|
import path3 from "node:path";
|
|
463
363
|
|
|
464
364
|
// src/core/damaged-file.ts
|
|
465
|
-
import
|
|
365
|
+
import fs2 from "node:fs";
|
|
466
366
|
import path2 from "node:path";
|
|
467
367
|
var quarantineDamagedFile = (filePath) => {
|
|
468
368
|
const destination = path2.join(
|
|
@@ -470,7 +370,7 @@ var quarantineDamagedFile = (filePath) => {
|
|
|
470
370
|
`${path2.basename(filePath)}.damaged.${process.pid}.${Date.now()}`
|
|
471
371
|
);
|
|
472
372
|
try {
|
|
473
|
-
|
|
373
|
+
fs2.renameSync(filePath, destination);
|
|
474
374
|
return destination;
|
|
475
375
|
} catch {
|
|
476
376
|
return void 0;
|
|
@@ -787,7 +687,7 @@ var DEFAULT_FABRIC_CONFIG = {
|
|
|
787
687
|
var readJsonObjectFile = (filePath) => {
|
|
788
688
|
let source;
|
|
789
689
|
try {
|
|
790
|
-
source =
|
|
690
|
+
source = fs3.readFileSync(filePath, "utf8");
|
|
791
691
|
} catch (error) {
|
|
792
692
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") return void 0;
|
|
793
693
|
return void 0;
|
|
@@ -822,7 +722,7 @@ var mergeObjects2 = (base, override) => {
|
|
|
822
722
|
};
|
|
823
723
|
var approvalMode = (value, fallback) => value === "allow" || value === "ask" || value === "auto" || value === "deny" ? value : fallback;
|
|
824
724
|
var booleanValue = (value, fallback) => typeof value === "boolean" ? value : fallback;
|
|
825
|
-
var boundedInteger = (value, fallback, min, max) => typeof value === "number" && Number.
|
|
725
|
+
var boundedInteger = (value, fallback, min, max) => typeof value === "number" && Number.isFinite(value) ? Math.max(min, Math.min(max, Math.floor(value))) : fallback;
|
|
826
726
|
var boundedFloat = (value, fallback, min, max) => typeof value === "number" && Number.isFinite(value) ? Math.max(min, Math.min(max, value)) : fallback;
|
|
827
727
|
var stringValue = (value) => typeof value === "string" && value.trim() ? value : void 0;
|
|
828
728
|
var runnerValue = (value, fallback) => value === "pi" || value === "claude" || value === "veda" ? value : fallback;
|
|
@@ -877,7 +777,7 @@ var normalizeFabricConfig = (input) => {
|
|
|
877
777
|
const configuredTools = Array.isArray(agents.defaultTools) ? agents.defaultTools.filter(
|
|
878
778
|
(tool) => typeof tool === "string" && Boolean(tool)
|
|
879
779
|
) : DEFAULT_FABRIC_CONFIG.agents.defaultTools;
|
|
880
|
-
const approvalModel = stringValue(approvals.model);
|
|
780
|
+
const approvalModel = normalizeJevApprovalModel(stringValue(approvals.model));
|
|
881
781
|
const configPath = stringValue(mcp.configPath);
|
|
882
782
|
const meshRoot = stringValue(mesh.root);
|
|
883
783
|
const memoryIndexDir = stringValue(memory.indexDir);
|
|
@@ -1426,30 +1326,30 @@ var planConfigFile = (filePath) => {
|
|
|
1426
1326
|
};
|
|
1427
1327
|
};
|
|
1428
1328
|
var writeJsonAtomic = (filePath, document, expectedSource) => {
|
|
1429
|
-
const resolvedPath =
|
|
1329
|
+
const resolvedPath = fs3.existsSync(filePath) ? fs3.realpathSync(filePath) : filePath;
|
|
1430
1330
|
const directory = path3.dirname(resolvedPath);
|
|
1431
|
-
if (!
|
|
1432
|
-
const mode =
|
|
1331
|
+
if (!fs3.existsSync(directory)) fs3.mkdirSync(directory, { recursive: true });
|
|
1332
|
+
const mode = fs3.existsSync(resolvedPath) ? fs3.statSync(resolvedPath).mode & 511 : 384;
|
|
1433
1333
|
const temporaryPath = path3.join(
|
|
1434
1334
|
directory,
|
|
1435
1335
|
`.${path3.basename(resolvedPath)}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`
|
|
1436
1336
|
);
|
|
1437
1337
|
let descriptor;
|
|
1438
1338
|
try {
|
|
1439
|
-
descriptor =
|
|
1440
|
-
|
|
1339
|
+
descriptor = fs3.openSync(temporaryPath, "wx", mode);
|
|
1340
|
+
fs3.writeFileSync(descriptor, `${JSON.stringify(document, null, 2)}
|
|
1441
1341
|
`, "utf8");
|
|
1442
|
-
|
|
1443
|
-
|
|
1342
|
+
fs3.fsyncSync(descriptor);
|
|
1343
|
+
fs3.closeSync(descriptor);
|
|
1444
1344
|
descriptor = void 0;
|
|
1445
1345
|
if (expectedSource === null) {
|
|
1446
|
-
if (
|
|
1346
|
+
if (fs3.existsSync(resolvedPath)) {
|
|
1447
1347
|
throw new Error(`Fabric configuration changed while updating ${filePath}`);
|
|
1448
1348
|
}
|
|
1449
1349
|
} else {
|
|
1450
1350
|
let currentSource;
|
|
1451
1351
|
try {
|
|
1452
|
-
currentSource =
|
|
1352
|
+
currentSource = fs3.readFileSync(resolvedPath, "utf8");
|
|
1453
1353
|
} catch (error) {
|
|
1454
1354
|
throw new Error(`Fabric configuration changed while updating ${filePath}`, { cause: error });
|
|
1455
1355
|
}
|
|
@@ -1459,19 +1359,19 @@ var writeJsonAtomic = (filePath, document, expectedSource) => {
|
|
|
1459
1359
|
}
|
|
1460
1360
|
renameAtomic(temporaryPath, resolvedPath);
|
|
1461
1361
|
try {
|
|
1462
|
-
const directoryDescriptor =
|
|
1362
|
+
const directoryDescriptor = fs3.openSync(directory, "r");
|
|
1463
1363
|
try {
|
|
1464
|
-
|
|
1364
|
+
fs3.fsyncSync(directoryDescriptor);
|
|
1465
1365
|
} finally {
|
|
1466
|
-
|
|
1366
|
+
fs3.closeSync(directoryDescriptor);
|
|
1467
1367
|
}
|
|
1468
1368
|
} catch (error) {
|
|
1469
1369
|
const code = error instanceof Error && "code" in error ? error.code : void 0;
|
|
1470
1370
|
if (code !== "EINVAL" && code !== "ENOTSUP" && code !== "EISDIR" && code !== "EPERM") throw error;
|
|
1471
1371
|
}
|
|
1472
1372
|
} catch (error) {
|
|
1473
|
-
if (descriptor !== void 0)
|
|
1474
|
-
|
|
1373
|
+
if (descriptor !== void 0) fs3.closeSync(descriptor);
|
|
1374
|
+
fs3.rmSync(temporaryPath, { force: true });
|
|
1475
1375
|
throw error;
|
|
1476
1376
|
}
|
|
1477
1377
|
};
|
|
@@ -1542,10 +1442,6 @@ var saveFabricConfig = (options, partial) => {
|
|
|
1542
1442
|
|
|
1543
1443
|
export {
|
|
1544
1444
|
quarantineDamagedFile,
|
|
1545
|
-
FUZZY_RESOLUTION_MARKERS,
|
|
1546
|
-
normalizeModelAliases,
|
|
1547
|
-
resolveFabricModel,
|
|
1548
|
-
resolveAvailablePiModel,
|
|
1549
1445
|
DEFAULT_SHELL_HANG_MS,
|
|
1550
1446
|
formatShellHangNotice,
|
|
1551
1447
|
appendShellHangNotice,
|
|
@@ -1565,8 +1461,9 @@ export {
|
|
|
1565
1461
|
maxExecutorMemoryLimitBytes,
|
|
1566
1462
|
DEFAULT_FABRIC_CONFIG,
|
|
1567
1463
|
effectiveToolCaptureConfig,
|
|
1464
|
+
writeJsonAtomic,
|
|
1568
1465
|
loadFabricConfigForScope,
|
|
1569
1466
|
loadFabricConfig,
|
|
1570
1467
|
saveFabricConfig
|
|
1571
1468
|
};
|
|
1572
|
-
//# sourceMappingURL=chunk-
|
|
1469
|
+
//# sourceMappingURL=chunk-G7UJLM33.js.map
|