pi-fabric 0.130.2 → 0.131.1
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/activity/store.d.ts +2 -1
- package/dist/activity/store.d.ts.map +1 -1
- package/dist/actors/directory.d.ts.map +1 -1
- package/dist/actors/global-registry.d.ts.map +1 -1
- package/dist/actors/manager.d.ts +4 -3
- package/dist/actors/manager.d.ts.map +1 -1
- package/dist/actors/mesh-monitor.d.ts +2 -0
- package/dist/actors/mesh-monitor.d.ts.map +1 -1
- package/dist/actors/name-policy.d.ts +3 -0
- package/dist/actors/name-policy.d.ts.map +1 -0
- package/dist/actors/registry-store.d.ts +1 -1
- package/dist/actors/registry-store.d.ts.map +1 -1
- package/dist/agents/agent-files.d.ts +8 -0
- package/dist/agents/agent-files.d.ts.map +1 -1
- package/dist/agents/agent-files.js +48 -3
- package/dist/agents/agent-files.js.map +2 -2
- package/dist/agents/child-skills.d.ts +60 -0
- package/dist/agents/child-skills.d.ts.map +1 -0
- package/dist/agents/child-skills.js +94 -0
- package/dist/agents/child-skills.js.map +7 -0
- package/dist/agents/clone-first-worktree.d.ts +6 -0
- package/dist/agents/clone-first-worktree.d.ts.map +1 -1
- package/dist/agents/cow-clone.d.ts.map +1 -1
- package/dist/agents/handoff.d.ts +12 -2
- package/dist/agents/handoff.d.ts.map +1 -1
- package/dist/agents/manager.d.ts +4 -1
- package/dist/agents/manager.d.ts.map +1 -1
- package/dist/agents/model-pin-guard.d.ts +27 -0
- package/dist/agents/model-pin-guard.d.ts.map +1 -0
- package/dist/agents/model-pin-guard.js +86 -0
- package/dist/agents/model-pin-guard.js.map +7 -0
- package/dist/agents/model-pin.d.ts +25 -0
- package/dist/agents/model-pin.d.ts.map +1 -0
- package/dist/agents/provider-bridge.d.ts +5 -4
- package/dist/agents/provider-bridge.d.ts.map +1 -1
- package/dist/agents/provider-bridge.js +32 -4
- package/dist/agents/provider-bridge.js.map +3 -3
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/service-schema.d.ts.map +1 -1
- package/dist/agents/types.d.ts +25 -0
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/worktree-manager.d.ts.map +1 -1
- package/dist/agents.js +6 -5
- package/dist/agents.js.map +2 -2
- package/dist/audit/details.d.ts +4 -0
- package/dist/audit/details.d.ts.map +1 -1
- package/dist/chunks/{chunk-SBAROA4Y.js → chunk-2RWNVCFD.js} +17 -1
- package/dist/chunks/{chunk-SBAROA4Y.js.map → chunk-2RWNVCFD.js.map} +2 -2
- package/dist/chunks/{chunk-6O6UWMBO.js → chunk-36XQFTEN.js} +2 -2
- package/dist/chunks/chunk-3PKZSIRA.js +1312 -0
- package/dist/chunks/chunk-3PKZSIRA.js.map +7 -0
- package/dist/chunks/{chunk-JJXUOXI5.js → chunk-4KX6BIPL.js} +17 -2
- package/dist/chunks/chunk-4KX6BIPL.js.map +7 -0
- package/dist/chunks/{chunk-EYHTTMSM.js → chunk-4PBW54I2.js} +5 -5
- package/dist/chunks/{chunk-WTIF3MIM.js → chunk-56NMRVTV.js} +8 -8
- package/dist/chunks/{chunk-WQFG7ZVC.js → chunk-5BOTHX47.js} +48 -13
- package/dist/chunks/chunk-5BOTHX47.js.map +7 -0
- package/dist/chunks/chunk-5QJFDKPN.js +179 -0
- package/dist/chunks/chunk-5QJFDKPN.js.map +7 -0
- package/dist/chunks/chunk-6HO2IUQ5.js +104 -0
- package/dist/chunks/chunk-6HO2IUQ5.js.map +7 -0
- package/dist/chunks/{chunk-NF6W327N.js → chunk-7CIES6X2.js} +9 -2
- package/dist/chunks/chunk-7CIES6X2.js.map +7 -0
- package/dist/chunks/{chunk-KDX3762L.js → chunk-DGERP4VL.js} +4 -4
- package/dist/chunks/{chunk-K3ZWBUUL.js → chunk-IOGDTIGN.js} +13 -13
- package/dist/chunks/chunk-IOGDTIGN.js.map +7 -0
- package/dist/chunks/{chunk-UXIBKMUM.js → chunk-KIFOEBYJ.js} +4 -4
- package/dist/chunks/{chunk-D5224P2R.js → chunk-LKYLD5SN.js} +7 -7
- package/dist/chunks/chunk-NENQZCGW.js +45 -0
- package/dist/chunks/chunk-NENQZCGW.js.map +7 -0
- package/dist/chunks/{chunk-YTYLKL3Z.js → chunk-OJ4HAALD.js} +8 -8
- package/dist/chunks/{chunk-TBB7F7WS.js → chunk-PQVUMJ5J.js} +84 -18
- package/dist/chunks/chunk-PQVUMJ5J.js.map +7 -0
- package/dist/chunks/chunk-UD7LFV43.js +28 -0
- package/dist/chunks/chunk-UD7LFV43.js.map +7 -0
- package/dist/chunks/{chunk-CH2QMORW.js → chunk-UFMYN5TA.js} +2 -2
- package/dist/chunks/chunk-V4OW2ULC.js +422 -0
- package/dist/chunks/chunk-V4OW2ULC.js.map +7 -0
- package/dist/chunks/{chunk-6C2DMTQC.js → chunk-VNWQIGQL.js} +552 -145
- package/dist/chunks/chunk-VNWQIGQL.js.map +7 -0
- package/dist/chunks/{chunk-OA5SJT2T.js → chunk-W3N72XYK.js} +199 -93
- package/dist/chunks/chunk-W3N72XYK.js.map +7 -0
- package/dist/chunks/{chunk-HAHRJMWY.js → chunk-WWTGWGH7.js} +6 -6
- package/dist/chunks/{chunk-F4HL6KJR.js → chunk-X7QETPBC.js} +7 -7
- package/dist/chunks/{chunk-SSRSCT2M.js → chunk-XFOSUGLU.js} +4 -4
- package/dist/chunks/{chunk-4VGB6HMU.js → chunk-ZFWICFNJ.js} +23 -18
- package/dist/chunks/{chunk-4VGB6HMU.js.map → chunk-ZFWICFNJ.js.map} +2 -2
- package/dist/commands/fabric-handler.d.ts.map +1 -1
- package/dist/commands/fabric-handler.js +43 -7
- package/dist/commands/fabric-handler.js.map +2 -2
- package/dist/compaction/claim-events.js +2 -2
- package/dist/components/configuration.js +3 -3
- package/dist/config.d.ts +9 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/core/action-registry.js +4 -4
- package/dist/core/model-aliases.d.ts +22 -0
- package/dist/core/model-aliases.d.ts.map +1 -0
- package/dist/core/model-resolution.d.ts +41 -20
- package/dist/core/model-resolution.d.ts.map +1 -1
- package/dist/core/prompt-guidance.js +9 -4
- package/dist/core/prompt-guidance.js.map +2 -2
- package/dist/core/system-guidance.d.ts.map +1 -1
- package/dist/decisions/command.d.ts +2 -1
- package/dist/decisions/command.d.ts.map +1 -1
- package/dist/decisions/command.js +31 -11
- package/dist/decisions/command.js.map +2 -2
- package/dist/decisions/events.js +2 -1
- package/dist/decisions/events.js.map +1 -1
- package/dist/decisions/host.d.ts +8 -0
- package/dist/decisions/host.d.ts.map +1 -1
- package/dist/decisions/render.d.ts +44 -0
- package/dist/decisions/render.d.ts.map +1 -0
- package/dist/durable/agent.d.ts +6 -0
- package/dist/durable/agent.d.ts.map +1 -1
- package/dist/durable/worker-host.d.ts.map +1 -1
- package/dist/durable/worker-host.js +7 -1283
- package/dist/durable/worker-host.js.map +4 -4
- package/dist/durable/worker-options.d.ts +2 -0
- package/dist/durable/worker-options.d.ts.map +1 -1
- package/dist/durable/worker-role-seed.d.ts +82 -0
- package/dist/durable/worker-role-seed.d.ts.map +1 -0
- package/dist/durable/worker.js +10 -1
- package/dist/durable/worker.js.map +2 -2
- package/dist/durable-extension.d.ts +1 -1
- package/dist/durable-extension.js +1 -1
- package/dist/durable-extension.js.map +1 -1
- package/dist/durable-host.d.ts +8 -0
- package/dist/durable-host.d.ts.map +1 -0
- package/dist/durable-host.js +20 -0
- package/dist/durable-host.js.map +7 -0
- package/dist/entropy/index.js +1 -1
- package/dist/execution-service.d.ts.map +1 -1
- package/dist/extension-bootstrap.d.ts.map +1 -1
- package/dist/extension-bootstrap.js +16 -16
- package/dist/extension.d.ts.map +1 -1
- package/dist/fabric-exec-tool.d.ts.map +1 -1
- package/dist/fabric-runtime-state.d.ts +2 -0
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +203 -124
- package/dist/fabric-runtime-state.js.map +2 -2
- package/dist/fabric-state.d.ts +26 -1
- package/dist/fabric-state.d.ts.map +1 -1
- package/dist/index.js +20 -16
- package/dist/index.js.map +1 -1
- package/dist/jev/client.js +2 -2
- package/dist/jev/observation.js +3 -3
- package/dist/jev.js +7 -7
- package/dist/protocol.d.ts +84 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +5 -1
- package/dist/providers/agents-actions.d.ts.map +1 -1
- package/dist/providers/agents-provider.d.ts +3 -0
- package/dist/providers/agents-provider.d.ts.map +1 -1
- package/dist/providers/jev-provider.js +7 -7
- package/dist/residency/host.d.ts.map +1 -1
- package/dist/residency/host.js +13 -10
- package/dist/residency/pi-entry.js +13 -10
- package/dist/residency/pi-entry.js.map +1 -1
- package/dist/runtime/core-override-guest-types.js +2 -2
- package/dist/runtime/cpython-runtime.js +3 -3
- package/dist/runtime/exec-journal.js +3 -3
- 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 +6 -6
- package/dist/runtime/node-process-runtime.js +5 -5
- package/dist/runtime/quickjs-runtime.js +3 -3
- package/dist/runtime/typescript-kernel.js +11 -11
- package/dist/storage/retention.d.ts.map +1 -1
- package/dist/type-error-guidance.js +1 -1
- package/dist/ui/conversation-chrome.js +2 -2
- package/dist/ui/conversation.js +10 -10
- package/dist/ui/dashboard.d.ts.map +1 -1
- package/dist/ui/dashboard.js +14 -12
- package/dist/ui/dashboard.js.map +2 -2
- package/dist/ui/settings-sections-presentation.d.ts.map +1 -1
- package/dist/ui/settings.js +12 -9
- package/dist/ui/settings.js.map +2 -2
- package/dist/ui/widget.d.ts.map +1 -1
- package/dist/verified/generated/actor-name.d.ts +4 -0
- package/dist/verified/generated/actor-name.js +17 -0
- package/dist/verified/generated/manifest.json +11 -3
- package/dist/worker/options.d.ts.map +1 -1
- package/dist/worker/options.js +20 -0
- package/dist/worker/options.js.map +2 -2
- package/dist/worker.js +57 -8
- package/dist/worker.js.map +2 -2
- package/docs/actor-name-policy-handoff.md +5 -0
- package/docs/agents.md +64 -5
- package/docs/audit-trace.md +2 -1
- package/docs/components.md +1 -1
- package/docs/configuration.md +7 -4
- package/docs/decisions.md +47 -2
- package/docs/durable-pi.md +162 -2
- package/docs/interface.md +1 -1
- package/docs/providers.md +1 -1
- package/docs/verified-kernels.md +1 -0
- package/package.json +5 -1
- package/proofs/actor-name.ts +27 -0
- package/proofs/index.ts +2 -0
- package/scripts/verified-kernels.ts +1 -1
- package/skillsets/python/fabric-exec/references/agents.md +6 -4
- package/skillsets/typescript/fabric-exec/references/agents.md +6 -3
- package/dist/chunks/chunk-6C2DMTQC.js.map +0 -7
- package/dist/chunks/chunk-JJXUOXI5.js.map +0 -7
- package/dist/chunks/chunk-K3ZWBUUL.js.map +0 -7
- package/dist/chunks/chunk-KJZAOENY.js +0 -212
- package/dist/chunks/chunk-KJZAOENY.js.map +0 -7
- package/dist/chunks/chunk-NF6W327N.js.map +0 -7
- package/dist/chunks/chunk-OA5SJT2T.js.map +0 -7
- package/dist/chunks/chunk-TBB7F7WS.js.map +0 -7
- package/dist/chunks/chunk-WQFG7ZVC.js.map +0 -7
- package/dist/chunks/chunk-ZLNJDTCN.js +0 -226
- package/dist/chunks/chunk-ZLNJDTCN.js.map +0 -7
- /package/dist/chunks/{chunk-6O6UWMBO.js.map → chunk-36XQFTEN.js.map} +0 -0
- /package/dist/chunks/{chunk-EYHTTMSM.js.map → chunk-4PBW54I2.js.map} +0 -0
- /package/dist/chunks/{chunk-WTIF3MIM.js.map → chunk-56NMRVTV.js.map} +0 -0
- /package/dist/chunks/{chunk-KDX3762L.js.map → chunk-DGERP4VL.js.map} +0 -0
- /package/dist/chunks/{chunk-UXIBKMUM.js.map → chunk-KIFOEBYJ.js.map} +0 -0
- /package/dist/chunks/{chunk-D5224P2R.js.map → chunk-LKYLD5SN.js.map} +0 -0
- /package/dist/chunks/{chunk-YTYLKL3Z.js.map → chunk-OJ4HAALD.js.map} +0 -0
- /package/dist/chunks/{chunk-CH2QMORW.js.map → chunk-UFMYN5TA.js.map} +0 -0
- /package/dist/chunks/{chunk-HAHRJMWY.js.map → chunk-WWTGWGH7.js.map} +0 -0
- /package/dist/chunks/{chunk-F4HL6KJR.js.map → chunk-X7QETPBC.js.map} +0 -0
- /package/dist/chunks/{chunk-SSRSCT2M.js.map → chunk-XFOSUGLU.js.map} +0 -0
package/dist/agents.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AGENTS_ACTION_DESCRIPTORS,
|
|
3
3
|
normalizeAgentRunRequest
|
|
4
|
-
} from "./chunks/chunk-
|
|
4
|
+
} from "./chunks/chunk-5BOTHX47.js";
|
|
5
5
|
import {
|
|
6
6
|
AgentAdmission,
|
|
7
7
|
assertAgentTask,
|
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
finishAgentSettlement,
|
|
11
11
|
terminalAgentStatuses,
|
|
12
12
|
waitForAgent
|
|
13
|
-
} from "./chunks/chunk-
|
|
13
|
+
} from "./chunks/chunk-V4OW2ULC.js";
|
|
14
14
|
import {
|
|
15
15
|
validateAgentResult
|
|
16
16
|
} from "./chunks/chunk-GJVKEHDL.js";
|
|
17
17
|
import "./chunks/chunk-HGD75NZY.js";
|
|
18
18
|
import "./chunks/chunk-IIPKG52D.js";
|
|
19
|
-
import "./chunks/chunk-
|
|
19
|
+
import "./chunks/chunk-NENQZCGW.js";
|
|
20
20
|
import "./chunks/chunk-V73NIH6B.js";
|
|
21
21
|
import {
|
|
22
22
|
actionArgNormalizer
|
|
@@ -33,7 +33,7 @@ var native = (name) => {
|
|
|
33
33
|
};
|
|
34
34
|
var run = native("run");
|
|
35
35
|
var properties = { ...run.inputSchema.properties };
|
|
36
|
-
for (const key of ["transport", "persona", "agent"]) delete properties[key];
|
|
36
|
+
for (const key of ["transport", "persona", "modelMatch", "agent", "skills"]) delete properties[key];
|
|
37
37
|
Object.assign(properties, {
|
|
38
38
|
runner: { type: "string", enum: ["pi"] },
|
|
39
39
|
kernel: { type: "string", enum: ["typescript", "inherit"] },
|
|
@@ -42,7 +42,8 @@ Object.assign(properties, {
|
|
|
42
42
|
timeoutMs: { type: "number", minimum: 1 },
|
|
43
43
|
cwd: { type: "string", description: "Host-authorized placement selector; never resolved by Fabric" },
|
|
44
44
|
images: { type: "array", items: { type: "object", properties: { type: { const: "image" }, data: { type: "string" }, mimeType: { type: "string" } }, required: ["type", "data", "mimeType"], additionalProperties: false } },
|
|
45
|
-
systemPrompt: { type: "string" }
|
|
45
|
+
systemPrompt: { type: "string" },
|
|
46
|
+
model: { type: "string", description: "Pi model selector for this child. The host resolves it with its own model registry and aliases; this hosted service has no exact-match mode." }
|
|
46
47
|
});
|
|
47
48
|
var runSchema = { type: "object", properties, required: ["task"], additionalProperties: false };
|
|
48
49
|
var spawnSchema = { type: "object", properties: { ...properties, residency: { type: "string", enum: ["session", "durable"] } }, required: ["task"], additionalProperties: false };
|
package/dist/agents.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/agents/service-schema.ts", "../src/agents/service.ts", "../src/agents/service-provider.ts", "../src/agents.ts"],
|
|
4
|
-
"sourcesContent": ["import { Value } from \"typebox/value\";\nimport { AGENTS_ACTION_DESCRIPTORS } from \"../providers/agents-actions.js\";\nimport { actionArgNormalizer } from \"../providers/arg-normalization.js\";\nimport type { FabricActionDescriptor } from \"../protocol.js\";\nimport { assertAgentTask } from \"./lifecycle.js\";\nimport { normalizeAgentRunRequest } from \"./request.js\";\nimport type { AgentServiceAction, AgentServiceCapabilities, AgentServiceRequest } from \"./service-types.js\";\n\nconst native = (name: string): FabricActionDescriptor => {\n const descriptor = AGENTS_ACTION_DESCRIPTORS.find((entry) => entry.name === name);\n if (!descriptor) throw new Error(`Missing native agent descriptor: ${name}`);\n return structuredClone(descriptor);\n};\nconst run = native(\"run\");\nconst properties = { ...(run.inputSchema as {properties: Record<string, unknown>}).properties };\n// Named agent files are a local-host feature; a hosted execution port never reads the caller's disk.\nfor (const key of [\"transport\", \"persona\", \"agent\"]) delete properties[key];\nObject.assign(properties, {\n runner: {type: \"string\", enum: [\"pi\"]},\n kernel: {type: \"string\", enum: [\"typescript\", \"inherit\"]},\n extensions: {type: \"boolean\", const: true},\n worktree: {type: \"boolean\", const: false},\n timeoutMs: {type: \"number\", minimum: 1},\n cwd: {type: \"string\", description: \"Host-authorized placement selector; never resolved by Fabric\"},\n images: {type: \"array\", items: {type: \"object\", properties: {type: {const: \"image\"}, data: {type: \"string\"}, mimeType: {type: \"string\"}}, required: [\"type\", \"data\", \"mimeType\"], additionalProperties: false}},\n systemPrompt: {type: \"string\"},\n});\nconst runSchema = {type: \"object\", properties, required: [\"task\"], additionalProperties: false};\nconst spawnSchema = {type: \"object\", properties: {...properties, residency: {type: \"string\", enum: [\"session\", \"durable\"]}}, required: [\"task\"], additionalProperties: false};\nconst id = {type: \"string\", minLength: 1};\nconst object = (properties: Record<string, unknown>, required: string[] = []): Record<string, unknown> => ({type: \"object\", properties, required, additionalProperties: false});\n\nexport function agentServiceDescriptors(capabilities: AgentServiceCapabilities = {}): FabricActionDescriptor[] {\n const descriptors: FabricActionDescriptor[] = [\n {...run, description: \"Run one host-authorized Pi child and wait for its result or pause\", inputSchema: runSchema},\n {...native(\"spawn\"), description: \"Admit one host-authorized Pi child, or residency durable for an independent host worker\", inputSchema: spawnSchema},\n ...[\"wait\", \"join\", \"status\", \"stop\"].map((name) => ({...native(name), inputSchema: object({id}, [\"id\"])})),\n {...native(\"list\"), description: \"List only the authenticated caller's direct children\", inputSchema: object({})},\n ];\n if (capabilities.steer) descriptors.push({...native(\"steer\"), inputSchema: object({id, message: {type: \"string\", minLength: 1}}, [\"id\", \"message\"])});\n if (capabilities.followUp) descriptors.push({...native(\"followUp\"), inputSchema: object({id, message: {type: \"string\", minLength: 1}}, [\"id\", \"message\"])});\n if (capabilities.compact) descriptors.push({...native(\"compact\"), inputSchema: object({id, instructions: {type: \"string\"}}, [\"id\"])});\n if (capabilities.resume) descriptors.push({name: \"resume\", description: \"Continue a paused, completed or failed direct child from its host checkpoint and wait for result or pause\", risk: \"agent\", inputSchema: object({id, task: {type: \"string\", minLength: 1}}, [\"id\"])});\n if (capabilities.topology) {\n descriptors.push(\n {...native(\"sessions\"), inputSchema: object({})},\n {...native(\"peers\"), inputSchema: object({})},\n {...native(\"self\"), inputSchema: object({})},\n {...native(\"members\"), inputSchema: object({})},\n {...native(\"create\"), description: \"Create a lasting session peer in this project\", inputSchema: object({name: {type: \"string\", minLength: 1}, instructions: {type: \"string\"}, task: {type: \"string\"}}, [\"name\"])},\n {...native(\"remove\"), description: \"Stop and remove a lasting session peer created in this project\", inputSchema: object({id: {type: \"string\", minLength: 1}, name: {type: \"string\"}}, [\"id\"])},\n );\n }\n return descriptors;\n}\n\n// The shared checker knows every action; each provider still lists and admits only its client's capabilities.\nconst descriptors = agentServiceDescriptors({steer: true, followUp: true, compact: true, resume: true, topology: true});\nconst normalize = actionArgNormalizer(() => descriptors);\nexport function agentServiceArgs(action: AgentServiceAction, input: Record<string, unknown>): Record<string, unknown> {\n const descriptor = descriptors.find((entry) => entry.name === action);\n if (!descriptor) throw new Error(`Unsupported hosted agents action: ${action}`);\n const args = normalize(action, input);\n if (!Value.Check(descriptor.inputSchema, args)) {\n const reasons = [...Value.Errors(descriptor.inputSchema, args)].slice(0, 5).map((error) => `${error.instancePath}: ${error.message}`);\n throw new Error(`Invalid hosted agents.${action} arguments: ${reasons.join(\"; \")}`);\n }\n return args;\n}\n\nexport function normalizeAgentServiceRequest(input: AgentServiceRequest): AgentServiceRequest {\n const {residency, ...rest} = input;\n const args = agentServiceArgs(\"run\", rest as unknown as Record<string, unknown>);\n const request = normalizeAgentRunRequest(args, {runner: \"pi\", timeoutMs: 0}) as AgentServiceRequest;\n if (args.images !== undefined) request.images = structuredClone(args.images) as NonNullable<AgentServiceRequest[\"images\"]>;\n if (args.systemPrompt !== undefined) request.systemPrompt = args.systemPrompt as string;\n if (residency === \"session\" || residency === \"durable\") request.residency = residency;\n assertAgentTask(request);\n return structuredClone(request);\n}\n", "import { AgentAdmission, beginAgentSettlement, createAgentLifecycle, finishAgentSettlement, terminalAgentStatuses, waitForAgent, type AgentLifecycleState } from \"./lifecycle.js\";\nimport { validateAgentResult } from \"./result.js\";\nimport { normalizeAgentServiceRequest } from \"./service-schema.js\";\nimport type { AgentAuthorityBoundary, AgentPublicRecord, AgentControlRequest, AgentExecutionEvent, AgentExecutionResponse, AgentServiceCapabilities, AgentServiceEvent, AgentServiceOptions, AgentServiceRecord, AgentServiceRequest, AgentSessionRecord, AgentServiceSnapshot } from \"./service-types.js\";\n\ntype Entry = {\n request: AgentServiceRequest;\n record: AgentServiceRecord;\n lifecycle: AgentLifecycleState<AgentServiceRecord>;\n controller: AbortController;\n done?: Promise<void>;\n stopping?: Promise<AgentPublicRecord>;\n resuming?: boolean;\n stopAck?: Promise<void>;\n pauseAck?: Promise<void>;\n suspendRequested?: boolean;\n executing?: boolean;\n stopReason?: \"stop\" | \"close\";\n controls?: Set<Promise<unknown>>;\n};\nconst copy = <T>(value: T): T => structuredClone(value);\nconst publicRecord = (record: AgentServiceRecord): AgentPublicRecord => {\n const keys = [\"id\", \"rootId\", \"parentId\", \"depth\", \"generation\", \"name\", \"task\", \"status\", \"runner\", \"kernel\", \"cwd\", \"model\", \"thinking\", \"recursive\", \"startedAt\", \"updatedAt\", \"finishedAt\", \"currentTool\", \"turns\", \"toolCalls\", \"text\", \"value\", \"error\", \"usage\", \"sessionId\"] as const;\n return copy(Object.fromEntries(keys.filter((key) => record[key] !== undefined).map((key) => [key, record[key]]))) as AgentPublicRecord;\n};\nconst errorText = (error: unknown): string => error instanceof Error ? error.message : String(error);\nconst idle = (): AgentLifecycleState<AgentServiceRecord> => ({settled: true, result: undefined, resolve: undefined, release() {}, abortSignal: undefined, abortHandler: undefined});\n\n/** Portable one-shot agent authority. The execution port runs one participant, never a tree. */\nexport class AgentService {\n readonly #options: AgentServiceOptions;\n readonly #entries = new Map<string, Entry>();\n readonly #admission: AgentAdmission;\n readonly #pending = new Map<AbortController, Promise<unknown>>();\n readonly #closing = new AbortController();\n #close: Promise<void> | undefined;\n #suspend: Promise<void> | undefined;\n #suspended = false;\n #sequence = 0;\n #publication: Promise<void> = Promise.resolve();\n readonly capabilities: AgentServiceCapabilities;\n\n constructor(options: AgentServiceOptions) {\n if (!options.rootId) throw new Error(\"Agent service requires a trusted rootId\");\n for (const [key, value] of Object.entries({maxStarts: options.maxStarts ?? 8, maxDepth: options.maxDepth ?? 3, maxConcurrent: options.maxConcurrent ?? 4})) {\n if (!Number.isSafeInteger(value) || value < 1) throw new Error(`${key} must be a positive integer`);\n }\n this.#options = {...options, port: options.port};\n this.#admission = new AgentAdmission(options.maxConcurrent ?? 4, options.maxStarts ?? 8, options.maxDepth ?? 3);\n this.capabilities = Object.freeze({\n steer: Boolean(options.port.steer || options.topology),\n compact: Boolean(options.port.compact),\n resume: Boolean(options.port.resume),\n followUp: Boolean(options.port.followUp || options.topology),\n topology: Boolean(options.topology),\n });\n if (options.snapshot) this.#restore(options.snapshot);\n }\n\n snapshot(): AgentServiceSnapshot {\n return copy({version: 1, rootId: this.#options.rootId, starts: this.#admission.starts, sequence: this.#sequence,\n records: [...this.#entries.values()].map(({request, record}) => ({request, record}))});\n }\n\n async run(callerId: string, request: AgentServiceRequest, signal?: AbortSignal): Promise<AgentPublicRecord> {\n const handle = await this.spawn(callerId, request, signal);\n return this.wait(callerId, handle.id, signal);\n }\n\n async spawn(callerId: string, request: AgentServiceRequest, signal?: AbortSignal): Promise<AgentPublicRecord | AgentSessionRecord> {\n const normalized = normalizeAgentServiceRequest(request);\n if (normalized.residency === \"durable\") {\n await this.#authorize(callerId);\n const dispatch = this.#topology().dispatch;\n if (!dispatch) throw new Error(\"Durable hosted spawn is unavailable\");\n const record = await dispatch({callerId, request: normalized, ...(signal ? {signal} : {})});\n await this.#authorize(callerId);\n return copy(record);\n }\n return this.#start(callerId, normalized, undefined, signal);\n }\n\n async wait(callerId: string, id: string, signal?: AbortSignal): Promise<AgentPublicRecord> {\n await this.#authorize(callerId);\n const entry = this.#child(callerId, id);\n const result = entry.lifecycle.result ?? Promise.resolve(copy(entry.record));\n const record = await waitForAgent(result, signal);\n await this.#authorize(callerId);\n return publicRecord(record);\n }\n\n /** Alias for wait; authorization and cancellation semantics are identical. */\n join(callerId: string, id: string, signal?: AbortSignal): Promise<AgentPublicRecord> {\n return this.wait(callerId, id, signal);\n }\n\n async status(callerId: string, id: string): Promise<AgentPublicRecord> {\n await this.#authorize(callerId);\n return publicRecord(this.#child(callerId, id).record);\n }\n\n async list(callerId: string): Promise<AgentPublicRecord[]> {\n await this.#authorize(callerId);\n return [...this.#entries.values()].filter((entry) => entry.record.parentId === callerId).map((entry) => publicRecord(entry.record));\n }\n\n async stop(callerId: string, id: string): Promise<AgentPublicRecord> {\n await this.#authorize(callerId);\n const result = await this.#stop(this.#child(callerId, id));\n await this.#authorize(callerId);\n return publicRecord(result);\n }\n\n async steer(callerId: string, id: string, message: string): Promise<AgentPublicRecord | AgentSessionRecord> {\n if (!message.trim()) throw new Error(\"Steering message must not be empty\");\n const child = this.#ownedChild(callerId, id);\n if (child) {\n if (!this.#options.port.steer) throw new Error(\"Hosted agents.steer is unsupported\");\n return this.#control(callerId, child.record.id, \"steer\", (request) => this.#options.port.steer!({...request, message}));\n }\n return this.#deliver(callerId, id, \"steer\", message);\n }\n\n async followUp(callerId: string, id: string, message: string): Promise<AgentPublicRecord | AgentSessionRecord> {\n if (!message.trim()) throw new Error(\"Follow-up message must not be empty\");\n const child = this.#ownedChild(callerId, id);\n if (child) {\n if (!this.#options.port.followUp) throw new Error(\"Hosted agents.followUp is unsupported\");\n if (child.record.status === \"running\" && !child.stopping) {\n return this.#control(callerId, child.record.id, \"followUp\", (request) => this.#options.port.followUp!({...request, message}));\n }\n await this.#authorize(callerId);\n await this.#options.port.followUp({...this.#identity(child), message});\n await this.#authorize(callerId);\n return publicRecord(child.record);\n }\n return this.#deliver(callerId, id, \"followUp\", message);\n }\n\n async sessions(callerId: string): Promise<AgentSessionRecord[]> {\n await this.#authorize(callerId);\n return copy(await this.#topology().sessions());\n }\n\n async peers(callerId: string): Promise<AgentSessionRecord[]> {\n await this.#authorize(callerId);\n return copy(await this.#topology().peers(callerId));\n }\n\n async self(callerId: string): Promise<AgentSessionRecord> {\n await this.#authorize(callerId);\n if (this.#options.topology) return copy(await this.#options.topology.self(callerId));\n const child = callerId === this.#options.rootId ? undefined : this.#entries.get(callerId);\n return {\n id: callerId,\n name: child?.record.name ?? \"main\",\n kind: callerId === this.#options.rootId ? \"root\" : \"agent\",\n status: child?.record.status ?? \"running\",\n capabilities: callerId === this.#options.rootId ? [\"steer\", \"followUp\", \"stop\"] : [\"steer\", \"followUp\", \"stop\"],\n };\n }\n\n async create(callerId: string, request: { name: string; instructions?: string; task?: string }, signal?: AbortSignal): Promise<AgentSessionRecord> {\n if (!request.name.trim()) throw new Error(\"Peer name is required\");\n await this.#authorize(callerId);\n const create = this.#topology().create;\n if (!create) throw new Error(\"Hosted agents.create is unavailable\");\n const record = await create({callerId, name: request.name.trim(), ...(request.instructions ? {instructions: request.instructions} : {}), ...(request.task ? {task: request.task} : {}), ...(signal ? {signal} : {})});\n await this.#authorize(callerId);\n return copy(record);\n }\n\n async remove(callerId: string, id: string, name?: string, signal?: AbortSignal): Promise<AgentSessionRecord> {\n if (!id.trim()) throw new Error(\"Peer id is required\");\n await this.#authorize(callerId);\n const remove = this.#topology().remove;\n if (!remove) throw new Error(\"Hosted agents.remove is unavailable\");\n const record = await remove({callerId, id, ...(name ? {name} : {}), ...(signal ? {signal} : {})});\n await this.#authorize(callerId);\n return copy(record);\n }\n\n async members(callerId: string): Promise<AgentSessionRecord[]> {\n await this.#authorize(callerId);\n const sessions = this.#options.topology ? copy(await this.#options.topology.sessions()) : [];\n const seen = new Set(sessions.map((item) => item.id));\n const children: AgentSessionRecord[] = [];\n for (const entry of this.#entries.values()) {\n if (seen.has(entry.record.id)) continue;\n children.push({\n id: entry.record.id,\n name: entry.record.name,\n kind: \"agent\",\n status: entry.record.status,\n capabilities: [\"steer\", \"followUp\", \"stop\"],\n });\n }\n return [...sessions, ...children];\n }\n\n async compact(callerId: string, id: string, instructions?: string): Promise<AgentPublicRecord> {\n if (!this.#options.port.compact) throw new Error(\"Hosted agents.compact is unsupported\");\n return this.#control(callerId, id, \"compact\", (request) => this.#options.port.compact!({...request, ...(instructions !== undefined ? {instructions} : {})}));\n }\n\n async resume(callerId: string, id: string, task?: string, signal?: AbortSignal): Promise<AgentPublicRecord> {\n if (!this.#options.port.resume) throw new Error(\"Hosted agents.resume is unsupported\");\n await this.#authorize(callerId);\n const entry = this.#child(callerId, id);\n if (![\"paused\", \"completed\", \"failed\"].includes(entry.record.status) || !entry.lifecycle.settled || entry.resuming || entry.stopping) throw new Error(\"Only an idle paused, completed or failed agent can resume\");\n entry.resuming = true;\n try {\n const request = normalizeAgentServiceRequest({...entry.request, ...(task !== undefined ? {task} : {})});\n await this.#start(callerId, request, entry, signal);\n return await this.wait(callerId, id, signal);\n } finally { entry.resuming = false; }\n }\n\n /** Natural root completion waits for all background descendants without fencing live parents. */\n async drain(): Promise<void> {\n for (;;) {\n const work: Promise<unknown>[] = [...this.#pending.values()];\n for (const entry of this.#entries.values()) {\n if (entry.lifecycle.result && entry.done) work.push(entry.done);\n }\n if (work.length === 0) return;\n await Promise.allSettled(work);\n }\n }\n\n /** Host-only graceful pause. The port, not the owner signal, quiesces participant effects. */\n suspend(): Promise<void> {\n if (this.#suspend) return this.#suspend;\n if (this.#closing.signal.aborted) return Promise.reject(new Error(\"Agent service is closed\"));\n if (!this.#options.port.pause && [...this.#entries.values()].some((entry) => !entry.lifecycle.settled)) {\n return Promise.reject(new Error(\"Hosted agent suspension requires port.pause\"));\n }\n this.#suspended = true;\n for (const entry of this.#entries.values()) {\n if (!entry.lifecycle.settled && !terminalAgentStatuses.has(entry.record.status)) entry.suspendRequested = true;\n }\n for (const controller of this.#pending.keys()) controller.abort();\n this.#suspend = (async () => {\n const roots = [...this.#entries.values()].filter((entry) => entry.record.parentId === this.#options.rootId);\n const paused = await Promise.allSettled(roots.map((entry) => this.#pause(entry)));\n await Promise.allSettled([...this.#pending.values()]);\n const errors = paused.filter((result): result is PromiseRejectedResult => result.status === \"rejected\");\n if (errors.length) throw new AggregateError(errors.map((result) => result.reason), \"Agent suspension failed\");\n await this.drain();\n })();\n return this.#suspend;\n }\n\n async #pause(entry: Entry): Promise<void> {\n const children = [...this.#entries.values()].filter((child) => child.record.parentId === entry.record.id);\n const paused = await Promise.allSettled(children.map((child) => this.#pause(child)));\n const errors = paused.filter((result): result is PromiseRejectedResult => result.status === \"rejected\").map((result) => result.reason);\n if (errors.length) throw new AggregateError(errors, \"Agent descendant suspension failed\");\n if (entry.executing && !entry.stopping) {\n entry.pauseAck = Promise.resolve().then(async () => {\n if (entry.executing && !entry.stopping) await this.#options.port.pause!(this.#identity(entry));\n });\n try { await entry.pauseAck; }\n catch (error) { throw new AggregateError([...errors, error], \"Agent pause acknowledgment failed\"); }\n }\n await entry.done;\n }\n\n close(): Promise<void> {\n if (this.#close) return this.#close;\n this.#closing.abort();\n for (const controller of this.#pending.keys()) controller.abort();\n this.#close = (async () => {\n const errors: unknown[] = [];\n const stopped = await Promise.allSettled([...this.#entries.values()].map((entry) => this.#stop(entry, true)));\n for (const result of stopped) if (result.status === \"rejected\") errors.push(result.reason);\n await Promise.allSettled([...this.#pending.values()]);\n if (errors.length) throw new AggregateError(errors, \"Agent shutdown failed\");\n })();\n return this.#close;\n }\n\n #start(callerId: string, request: AgentServiceRequest, previous?: Entry, signal?: AbortSignal): Promise<AgentPublicRecord> {\n const controller = new AbortController();\n const abort = () => controller.abort();\n signal?.addEventListener(\"abort\", abort, {once: true});\n if (signal?.aborted || this.#closing.signal.aborted || this.#suspended) controller.abort();\n const operation = (async () => {\n let release: (() => void) | undefined;\n try {\n await this.#authorize(callerId);\n const depth = this.#depth(callerId);\n if (controller.signal.aborted) throw new Error(\"Operation aborted\");\n if (depth > this.#admission.maxDepth) throw new Error(`Fabric agent depth limit reached (${this.#admission.maxDepth})`);\n const id = previous?.record.id ?? crypto.randomUUID().replaceAll(\"-\", \"\");\n const generation = (previous?.record.generation ?? 0) + 1;\n const prepare = {id, generation, rootId: this.#options.rootId, parentId: callerId, depth, request: copy(request), signal: controller.signal};\n const binding = await this.#options.port.prepare?.(prepare);\n release = await this.#admission.acquire(callerId, controller.signal);\n await this.#authorize(callerId);\n this.#depth(callerId);\n if (controller.signal.aborted || this.#closing.signal.aborted || previous?.stopping) throw new Error(\"Agent admission aborted\");\n // No await between the final authority/parent check and the root-wide charge.\n this.#admission.admit(depth);\n const now = Date.now();\n const record: AgentServiceRecord = previous ? {\n ...previous.record, task: request.task, status: \"queued\", generation: previous.record.generation + 1,\n text: \"\", turns: 0, toolCalls: 0, updatedAt: now,\n } : {\n id, rootId: this.#options.rootId, parentId: callerId, depth, generation: 1,\n name: (request.name ?? request.task.split(\"\\n\", 1)[0] ?? \"Fabric agent\").replace(/[\\r\\n\\t]+/g, \" \").trim().slice(0, 60) || \"Fabric agent\",\n task: request.task, status: \"queued\", runner: \"pi\", kernel: \"typescript\", startedAt: now, updatedAt: now,\n turns: 0, toolCalls: 0, text: \"\", usage: {input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0},\n ...(request.model ? {model: request.model} : {}), ...(request.thinking ? {thinking: request.thinking} : {}),\n ...(request.cwd !== undefined ? {cwd: request.cwd} : {}), ...(request.recursive !== undefined ? {recursive: request.recursive} : {}),\n };\n delete record.finishedAt; delete record.error; delete record.value; delete record.currentTool;\n const entry: Entry = previous ?? {request, record, lifecycle: idle(), controller};\n entry.request = copy(request); entry.record = record; entry.controller = controller;\n entry.lifecycle = createAgentLifecycle<AgentServiceRecord>(release);\n release = undefined;\n this.#entries.set(record.id, entry);\n this.#pending.delete(controller);\n // Admission cancellation detaches here. Background execution has a distinct owner signal.\n signal?.removeEventListener(\"abort\", abort);\n let acknowledge!: () => void;\n const admitted = new Promise<void>((resolve) => { acknowledge = resolve; });\n entry.done = this.#drive(entry, binding, Boolean(previous), acknowledge);\n await admitted;\n await this.#authorize(callerId);\n return publicRecord(record);\n } finally {\n release?.();\n signal?.removeEventListener(\"abort\", abort);\n }\n })();\n this.#pending.set(controller, operation);\n void operation.finally(() => this.#pending.delete(controller)).catch(() => {});\n return operation;\n }\n\n async #drive(entry: Entry, binding: unknown, resume: boolean, admitted: () => void): Promise<void> {\n const generation = entry.record.generation;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let timeout = false;\n let responded = false;\n try {\n await this.#publish(\"admitted\", entry);\n admitted();\n await this.#authorize(entry.record.parentId);\n if (entry.controller.signal.aborted) throw new Error(\"Agent start aborted\");\n entry.record.status = \"running\";\n await this.#publish(\"running\", entry);\n await this.#authorize(entry.record.parentId);\n if (entry.controller.signal.aborted) throw new Error(\"Agent start aborted\");\n const request = {\n ...this.#identity(entry), depth: entry.record.depth, request: copy(entry.request), signal: entry.controller.signal,\n binding, ...(entry.record.checkpoint !== undefined ? {checkpoint: copy(entry.record.checkpoint)} : {}),\n emit: async (event: AgentExecutionEvent) => {\n const assertCurrent = () => {\n if (!entry.executing || entry.lifecycle.settled || entry.controller.signal.aborted || entry.record.generation !== generation || entry.record.status !== \"running\") throw new Error(\"Stale agent execution event\");\n };\n assertCurrent();\n if (event.type !== \"checkpoint\" && event.type !== \"progress\") throw new Error(\"Unsupported agent execution event\");\n const saved = copy(event);\n await this.#publish(saved.type, entry, undefined, () => {\n if (saved.type === \"checkpoint\") entry.record.checkpoint = saved.checkpoint;\n else {\n for (const key of [\"text\", \"turns\", \"toolCalls\", \"currentTool\", \"usage\"] as const) {\n if (saved[key] !== undefined) Object.assign(entry.record, {[key]: saved[key]});\n }\n }\n }, assertCurrent);\n },\n };\n if (entry.request.timeoutMs) timer = setTimeout(() => {\n if (entry.suspendRequested) return;\n timeout = true;\n void this.#stop(entry).catch(() => {});\n }, entry.request.timeoutMs);\n const execute = resume ? this.#options.port.resume! : this.#options.port.execute;\n entry.executing = true;\n let response: AgentExecutionResponse;\n try { response = await execute.call(this.#options.port, request); }\n finally { entry.executing = false; }\n if (![\"completed\", \"failed\", \"stopped\", \"timed_out\", \"paused\"].includes(response.status)) throw new Error(\"Invalid agent execution response status\");\n await this.#authorize(entry.record.parentId, response.status === \"paused\" ? {checkpoint: true} : undefined);\n if (entry.record.generation !== generation || entry.lifecycle.settled) throw new Error(\"Stale agent execution response\");\n this.#applyResponse(entry, response);\n responded = true;\n } catch (error) {\n entry.record.status = \"failed\";\n entry.record.error = errorText(error);\n } finally {\n admitted();\n if (timer) clearTimeout(timer);\n await Promise.allSettled([...(entry.controls ?? []), ...(entry.stopAck ? [entry.stopAck] : []), ...(entry.pauseAck ? [entry.pauseAck] : [])]);\n if (entry.suspendRequested && !entry.controller.signal.aborted) {\n entry.record.status = \"paused\"; delete entry.record.error; delete entry.record.finishedAt;\n }\n if (entry.controller.signal.aborted) {\n if (entry.stopReason === \"close\") {\n if (!responded || ![\"completed\", \"failed\"].includes(entry.record.status)) { entry.record.status = \"paused\"; delete entry.record.error; }\n } else entry.record.status = timeout ? \"timed_out\" : \"stopped\";\n }\n try { await this.#options.port.cleanup?.(this.#identity(entry)); }\n catch (error) { entry.record.status = \"failed\"; entry.record.error = `Agent cleanup failed: ${errorText(error)}`; }\n validateAgentResult(entry.record, entry.request.schema);\n delete entry.record.currentTool;\n if (terminalAgentStatuses.has(entry.record.status)) entry.record.finishedAt = Date.now();\n if (beginAgentSettlement(entry.lifecycle)) {\n try { await this.#publish(\"settled\", entry); }\n catch (error) { entry.record.status = \"failed\"; entry.record.error = `Agent publication failed: ${errorText(error)}`; }\n finishAgentSettlement(entry.lifecycle, copy(entry.record));\n }\n }\n }\n\n #applyResponse(entry: Entry, response: AgentExecutionResponse): void {\n // Port output cannot overwrite host-owned identifiers, lineage or admission metadata.\n entry.record.status = response.status;\n for (const key of [\"text\", \"value\", \"error\", \"usage\", \"checkpoint\", \"sessionId\"] as const) {\n if (response[key] !== undefined) Object.assign(entry.record, {[key]: copy(response[key])});\n }\n }\n\n #stop(entry: Entry, preservePaused = false): Promise<AgentPublicRecord> {\n if (entry.stopping) return entry.stopping;\n entry.stopReason = preservePaused ? \"close\" : \"stop\";\n const work = (async () => {\n const active = !entry.lifecycle.settled;\n entry.controller.abort();\n const descendants = [...this.#entries.values()].filter((child) => child.record.parentId === entry.record.id);\n const operations: Promise<unknown>[] = descendants.map((child) => this.#stop(child, preservePaused));\n if (active && this.#options.port.stop) {\n entry.stopAck = Promise.resolve().then(() => this.#options.port.stop!(this.#identity(entry)));\n operations.push(entry.stopAck);\n }\n if (entry.done) operations.push(entry.done);\n const settled = await Promise.allSettled(operations);\n if (entry.record.status === \"paused\" && !preservePaused) {\n entry.record.status = \"stopped\"; entry.record.finishedAt = Date.now();\n await this.#publish(\"settled\", entry);\n }\n const errors = settled.filter((result): result is PromiseRejectedResult => result.status === \"rejected\");\n if (errors.length) throw new AggregateError(errors.map((result) => result.reason), \"Agent stop failed\");\n return publicRecord(entry.record);\n })();\n entry.stopping = work;\n return work;\n }\n\n async #control(callerId: string, id: string, control: \"steer\" | \"compact\" | \"followUp\", invoke: (request: AgentControlRequest) => Promise<void>): Promise<AgentPublicRecord> {\n await this.#authorize(callerId);\n const entry = this.#child(callerId, id);\n if (entry.record.status !== \"running\" || entry.stopping) throw new Error(\"Agent is not running\");\n const generation = entry.record.generation;\n const pending = Promise.resolve().then(async () => {\n await this.#authorize(callerId);\n if (entry.record.generation !== generation || entry.controller.signal.aborted || entry.lifecycle.settled) throw new Error(\"Stale agent control\");\n await invoke(this.#identity(entry));\n });\n (entry.controls ??= new Set()).add(pending);\n try { await pending; } finally { entry.controls.delete(pending); }\n await this.#authorize(callerId);\n if (entry.record.generation !== generation || entry.controller.signal.aborted) throw new Error(\"Stale agent control acknowledgment\");\n await this.#publish(\"control\", entry, control);\n return publicRecord(entry.record);\n }\n\n #identity(entry: Entry): AgentControlRequest {\n const {id, rootId, parentId, generation} = entry.record;\n return {id, rootId, parentId, generation};\n }\n\n async #authorize(callerId: string, boundary?: AgentAuthorityBoundary): Promise<void> {\n if (callerId !== this.#options.rootId && !this.#entries.has(callerId)) throw new Error(\"Unknown agent caller\");\n if (this.#suspended && !boundary?.checkpoint) throw new Error(\"Agent service is paused\");\n await this.#options.assertAuthority?.(callerId, boundary);\n if (this.#suspended && !boundary?.checkpoint) throw new Error(\"Agent service is paused\");\n }\n\n #child(callerId: string, id: string): Entry {\n const entry = this.#ownedChild(callerId, id);\n if (!entry) throw new Error(`Unknown direct child agent: ${id}`);\n return entry;\n }\n\n #ownedChild(callerId: string, id: string): Entry | undefined {\n const entry = this.#entries.get(id);\n return entry && entry.record.parentId === callerId ? entry : undefined;\n }\n\n #topology(): NonNullable<AgentServiceOptions[\"topology\"]> {\n if (!this.#options.topology) throw new Error(\"Hosted agent topology is unavailable\");\n return this.#options.topology;\n }\n\n async #deliver(callerId: string, id: string, operation: \"steer\" | \"followUp\", message: string): Promise<AgentSessionRecord> {\n const topology = this.#topology();\n await this.#authorize(callerId);\n const target = id === \"main\" ? this.#options.rootId : id;\n const record = await topology.deliver({callerId, id: target, operation, message});\n await this.#authorize(callerId);\n return copy(record);\n }\n\n #depth(callerId: string): number {\n if (this.#closing.signal.aborted) throw new Error(\"Agent service is closed\");\n if (this.#suspended) throw new Error(\"Agent service is paused\");\n if (callerId === this.#options.rootId) return 1;\n const parent = this.#entries.get(callerId);\n if (!parent || parent.record.status !== \"running\" || parent.stopping || parent.controller.signal.aborted || parent.request.recursive === false) throw new Error(\"Agent parent cannot admit children\");\n return parent.record.depth + 1;\n }\n\n async #publish(type: AgentServiceEvent[\"type\"], entry: Entry, control?: AgentServiceEvent[\"control\"], update?: () => void, assertCurrent?: () => void): Promise<void> {\n const boundary = type === \"checkpoint\" || type === \"settled\" ? {checkpoint: true} : undefined;\n const generation = entry.record.generation;\n await this.#authorize(entry.record.parentId, boundary);\n const publication = this.#publication.then(async () => {\n await this.#authorize(entry.record.parentId, boundary);\n if (entry.record.generation !== generation) throw new Error(\"Stale agent publication\");\n assertCurrent?.();\n // Commit event mutations only after serialized, phase-matched lease authorization.\n update?.();\n entry.record.updatedAt = Date.now();\n const event: AgentServiceEvent = {version: 1, sequence: ++this.#sequence, type, record: copy(entry.record), ...(control ? {control} : {})};\n await this.#options.onEvent?.(event);\n });\n this.#publication = publication.catch(() => {});\n await publication;\n }\n\n #restore(snapshot: AgentServiceSnapshot): void {\n const saved = copy(snapshot);\n const newRoot = this.#options.restorePolicy === \"new-root\";\n if (newRoot && saved.rootId !== this.#options.rootId) {\n const oldRoot = saved.rootId;\n saved.rootId = this.#options.rootId;\n for (const {record} of saved.records) {\n if (record.rootId !== oldRoot) throw new Error(\"Invalid agent snapshot root\");\n record.rootId = saved.rootId;\n if (record.parentId === oldRoot) record.parentId = saved.rootId;\n }\n }\n if (saved.version !== 1 || saved.rootId !== this.#options.rootId || !Number.isSafeInteger(saved.starts) || saved.starts < 0 || (!newRoot && saved.starts > this.#admission.maxStarts) || !Number.isSafeInteger(saved.sequence) || saved.sequence < 0 || !Array.isArray(saved.records)) throw new Error(\"Invalid agent service snapshot\");\n let generations = 0;\n for (const item of saved.records) {\n const request = normalizeAgentServiceRequest(item.request);\n const record = item.record;\n if (!record.id || record.id === saved.rootId || this.#entries.has(record.id) || record.rootId !== saved.rootId || !Number.isSafeInteger(record.depth) || record.depth < 1 || record.depth > this.#admission.maxDepth || !Number.isSafeInteger(record.generation) || record.generation < 1 || ![\"queued\", \"running\", \"paused\", ...terminalAgentStatuses].includes(record.status)) throw new Error(\"Invalid agent snapshot record\");\n generations += record.generation;\n if (record.status === \"running\" || record.status === \"queued\") { record.status = \"paused\"; delete record.finishedAt; }\n this.#entries.set(record.id, {request, record, lifecycle: idle(), controller: new AbortController()});\n }\n for (const {record} of this.#entries.values()) {\n const parent = this.#entries.get(record.parentId);\n if (record.parentId === saved.rootId ? record.depth !== 1 : !parent || parent.record.depth + 1 !== record.depth) throw new Error(\"Invalid agent snapshot lineage\");\n }\n if (saved.starts > generations) throw new Error(\"Invalid agent snapshot admission count\");\n this.#admission.starts = newRoot ? 0 : saved.starts;\n this.#sequence = saved.sequence;\n }\n}\n", "import type { FabricProvider } from \"../protocol.js\";\nimport { AgentService } from \"./service.js\";\nimport { agentServiceArgs, agentServiceDescriptors } from \"./service-schema.js\";\nimport type { AgentServiceAction, AgentServiceCapabilities, AgentServiceClient, AgentServiceDispatcher, AgentPublicRecord, AgentServiceRequest, AgentSessionRecord } from \"./service-types.js\";\n\n/** Bind only authenticated host identity here. Guest arguments never carry the caller. */\nexport function createAgentServiceHandler(service: AgentService, callerId: string): AgentServiceDispatcher {\n return async (action, input, signal) => {\n const args = agentServiceArgs(action, input);\n switch (action) {\n case \"run\": return service.run(callerId, args as unknown as AgentServiceRequest, signal);\n case \"spawn\": return service.spawn(callerId, args as unknown as AgentServiceRequest, signal);\n case \"join\":\n case \"wait\": return service.wait(callerId, args.id as string, signal);\n case \"status\": return service.status(callerId, args.id as string);\n case \"list\": return service.list(callerId);\n case \"stop\": return service.stop(callerId, args.id as string);\n case \"steer\": return service.steer(callerId, args.id as string, args.message as string);\n case \"followUp\": return service.followUp(callerId, args.id as string, args.message as string);\n case \"compact\": return service.compact(callerId, args.id as string, args.instructions as string | undefined);\n case \"resume\": return service.resume(callerId, args.id as string, args.task as string | undefined, signal);\n case \"sessions\": return service.sessions(callerId);\n case \"peers\": return service.peers(callerId);\n case \"self\": return service.self(callerId);\n case \"members\": return service.members(callerId);\n case \"create\": return service.create(callerId, args as {name: string; instructions?: string; task?: string}, signal);\n case \"remove\": return service.remove(callerId, args.id as string, args.name as string | undefined, signal);\n default: throw new Error(`Unsupported hosted agents action: ${String(action)}`);\n }\n };\n}\n\n/** A transport client only; all admission and lifecycle remain in the root service. */\nexport function createAgentServiceClient(dispatch: AgentServiceDispatcher, capabilities: AgentServiceCapabilities = {}): AgentServiceClient {\n const record = (action: AgentServiceAction, args: Record<string, unknown>, signal?: AbortSignal) => dispatch(action, args, signal) as Promise<AgentPublicRecord>;\n return {\n capabilities: Object.freeze({...capabilities}), dispatch,\n run: (request, signal) => record(\"run\", request as unknown as Record<string, unknown>, signal),\n spawn: (request, signal) => record(\"spawn\", request as unknown as Record<string, unknown>, signal),\n wait: (id, signal) => record(\"wait\", {id}, signal),\n join: (id, signal) => record(\"wait\", {id}, signal),\n status: (id) => record(\"status\", {id}),\n list: () => dispatch(\"list\", {}) as Promise<AgentPublicRecord[]>,\n stop: (id) => record(\"stop\", {id}),\n steer: (id, message) => record(\"steer\", {id, message}),\n compact: (id, instructions) => record(\"compact\", {id, ...(instructions !== undefined ? {instructions} : {})}),\n resume: (id, task, signal) => record(\"resume\", {id, ...(task !== undefined ? {task} : {})}, signal),\n followUp: (id, message) => record(\"followUp\", {id, message}),\n sessions: () => dispatch(\"sessions\", {}) as Promise<AgentSessionRecord[]>,\n peers: () => dispatch(\"peers\", {}) as Promise<AgentSessionRecord[]>,\n self: () => dispatch(\"self\", {}) as Promise<AgentSessionRecord>,\n members: () => dispatch(\"members\", {}) as Promise<AgentSessionRecord[]>,\n create: (request, signal) => dispatch(\"create\", request as unknown as Record<string, unknown>, signal) as Promise<AgentSessionRecord>,\n remove: (id, name, signal) => dispatch(\"remove\", {id, ...(name !== undefined ? {name} : {})}, signal) as Promise<AgentSessionRecord>,\n };\n}\n\nexport function createAgentsProvider(client: AgentServiceClient): FabricProvider {\n const descriptors = agentServiceDescriptors(client.capabilities);\n const allowed = new Set(descriptors.map((descriptor) => descriptor.name));\n const validate = (action: string, args: Record<string, unknown>) => {\n if (!allowed.has(action)) throw new Error(`Unsupported hosted agents action: ${action}`);\n return agentServiceArgs(action as AgentServiceAction, args);\n };\n return {\n name: \"agents\", description: \"Fabric host-authorized Pi agents\",\n list: async () => structuredClone(descriptors),\n describe: async (name) => structuredClone(descriptors.find((descriptor) => descriptor.name === name)),\n prepareArguments: (action, args) => validate(action, args),\n invoke: async (action, args, context) => client.dispatch(action as AgentServiceAction, validate(action, args), context.signal),\n };\n}\n", "/** Portable hosted agents: no local manager, filesystem, model registry or ambient configuration. */\nexport { AgentService } from \"./agents/service.js\";\nexport { createAgentsProvider, createAgentServiceClient, createAgentServiceHandler } from \"./agents/service-provider.js\";\nexport { agentServiceDescriptors } from \"./agents/service-schema.js\";\nexport type * from \"./agents/service-types.js\";\nexport type { AgentRunRequest, AgentRunRecord, AgentRunResult, AgentHandleInfo, AgentUsage } from \"./agents/types.js\";\nexport const HOSTED_AGENTS_PROTOCOL_VERSION = 1 as const;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AAQtB,IAAM,SAAS,CAAC,SAAyC;AACvD,QAAM,aAAa,0BAA0B,KAAK,CAAC,UAAU,MAAM,SAAS,IAAI;AAChF,MAAI,CAAC,WAAY,OAAM,IAAI,MAAM,oCAAoC,IAAI,EAAE;AAC3E,SAAO,gBAAgB,UAAU;AACnC;AACA,IAAM,MAAM,OAAO,KAAK;AACxB,IAAM,aAAa,EAAE,GAAI,IAAI,YAAsD,WAAW;AAE9F,WAAW,OAAO,CAAC,aAAa,WAAW,OAAO,EAAG,QAAO,WAAW,GAAG;AAC1E,OAAO,OAAO,YAAY;AAAA,EACxB,QAAQ,EAAC,MAAM,UAAU,MAAM,CAAC,IAAI,EAAC;AAAA,EACrC,QAAQ,EAAC,MAAM,UAAU,MAAM,CAAC,cAAc,SAAS,EAAC;AAAA,EACxD,YAAY,EAAC,MAAM,WAAW,OAAO,KAAI;AAAA,EACzC,UAAU,EAAC,MAAM,WAAW,OAAO,MAAK;AAAA,EACxC,WAAW,EAAC,MAAM,UAAU,SAAS,EAAC;AAAA,EACtC,KAAK,EAAC,MAAM,UAAU,aAAa,+DAA8D;AAAA,EACjG,QAAQ,EAAC,MAAM,SAAS,OAAO,EAAC,MAAM,UAAU,YAAY,EAAC,MAAM,EAAC,OAAO,QAAO,GAAG,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AM,MAAM,SAAS,QAAQ,CAAC,CAAC;AAAA,IAC/B,SAAS,MAAM,SAAS,WAAW,CAAC,CAAC;AAAA,IACrC,QAAQ,CAAC,SAAS,WAAW,SAAS,UAAU,SAA+C,MAAM;AAAA,IACrG,QAAQ,CAACA,KAAI,MAAM,WAAW,SAAS,UAAU,EAAC,IAAAA,KAAI,GAAI,SAAS,SAAY,EAAC,KAAI,IAAI,CAAC,EAAE,GAAG,MAAM;AAAA,EACtG;AACF;AAEO,SAAS,qBAAqB,QAA4C;AAC/E,QAAMC,eAAc,wBAAwB,OAAO,YAAY;AAC/D,QAAM,UAAU,IAAI,IAAIA,aAAY,IAAI,CAAC,eAAe,WAAW,IAAI,CAAC;AACxE,QAAM,WAAW,CAAC,QAAgB,SAAkC;AAClE,QAAI,CAAC,QAAQ,IAAI,MAAM,EAAG,OAAM,IAAI,MAAM,qCAAqC,MAAM,EAAE;AACvF,WAAO,iBAAiB,QAA8B,IAAI;AAAA,EAC5D;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IAAU,aAAa;AAAA,IAC7B,MAAM,YAAY,gBAAgBA,YAAW;AAAA,IAC7C,UAAU,OAAO,SAAS,gBAAgBA,aAAY,KAAK,CAAC,eAAe,WAAW,SAAS,IAAI,CAAC;AAAA,IACpG,kBAAkB,CAAC,QAAQ,SAAS,SAAS,QAAQ,IAAI;AAAA,IACzD,QAAQ,OAAO,QAAQ,MAAM,YAAY,OAAO,SAAS,QAA8B,SAAS,QAAQ,IAAI,GAAG,QAAQ,MAAM;AAAA,EAC/H;AACF;;;ACjEO,IAAM,iCAAiC;",
|
|
4
|
+
"sourcesContent": ["import { Value } from \"typebox/value\";\nimport { AGENTS_ACTION_DESCRIPTORS } from \"../providers/agents-actions.js\";\nimport { actionArgNormalizer } from \"../providers/arg-normalization.js\";\nimport type { FabricActionDescriptor } from \"../protocol.js\";\nimport { assertAgentTask } from \"./lifecycle.js\";\nimport { normalizeAgentRunRequest } from \"./request.js\";\nimport type { AgentServiceAction, AgentServiceCapabilities, AgentServiceRequest } from \"./service-types.js\";\n\nconst native = (name: string): FabricActionDescriptor => {\n const descriptor = AGENTS_ACTION_DESCRIPTORS.find((entry) => entry.name === name);\n if (!descriptor) throw new Error(`Missing native agent descriptor: ${name}`);\n return structuredClone(descriptor);\n};\nconst run = native(\"run\");\nconst properties = { ...(run.inputSchema as {properties: Record<string, unknown>}).properties };\n// modelMatch is resolved against this process's registry; the host owns model selection here.\n// Named agent files are a local-host feature; a hosted execution port never reads the caller's disk.\nfor (const key of [\"transport\", \"persona\", \"modelMatch\", \"agent\", \"skills\"]) delete properties[key];\nObject.assign(properties, {\n runner: {type: \"string\", enum: [\"pi\"]},\n kernel: {type: \"string\", enum: [\"typescript\", \"inherit\"]},\n extensions: {type: \"boolean\", const: true},\n worktree: {type: \"boolean\", const: false},\n timeoutMs: {type: \"number\", minimum: 1},\n cwd: {type: \"string\", description: \"Host-authorized placement selector; never resolved by Fabric\"},\n images: {type: \"array\", items: {type: \"object\", properties: {type: {const: \"image\"}, data: {type: \"string\"}, mimeType: {type: \"string\"}}, required: [\"type\", \"data\", \"mimeType\"], additionalProperties: false}},\n systemPrompt: {type: \"string\"},\n model: {type: \"string\", description: \"Pi model selector for this child. The host resolves it with its own model registry and aliases; this hosted service has no exact-match mode.\"},\n});\nconst runSchema = {type: \"object\", properties, required: [\"task\"], additionalProperties: false};\nconst spawnSchema = {type: \"object\", properties: {...properties, residency: {type: \"string\", enum: [\"session\", \"durable\"]}}, required: [\"task\"], additionalProperties: false};\nconst id = {type: \"string\", minLength: 1};\nconst object = (properties: Record<string, unknown>, required: string[] = []): Record<string, unknown> => ({type: \"object\", properties, required, additionalProperties: false});\n\nexport function agentServiceDescriptors(capabilities: AgentServiceCapabilities = {}): FabricActionDescriptor[] {\n const descriptors: FabricActionDescriptor[] = [\n {...run, description: \"Run one host-authorized Pi child and wait for its result or pause\", inputSchema: runSchema},\n {...native(\"spawn\"), description: \"Admit one host-authorized Pi child, or residency durable for an independent host worker\", inputSchema: spawnSchema},\n ...[\"wait\", \"join\", \"status\", \"stop\"].map((name) => ({...native(name), inputSchema: object({id}, [\"id\"])})),\n {...native(\"list\"), description: \"List only the authenticated caller's direct children\", inputSchema: object({})},\n ];\n if (capabilities.steer) descriptors.push({...native(\"steer\"), inputSchema: object({id, message: {type: \"string\", minLength: 1}}, [\"id\", \"message\"])});\n if (capabilities.followUp) descriptors.push({...native(\"followUp\"), inputSchema: object({id, message: {type: \"string\", minLength: 1}}, [\"id\", \"message\"])});\n if (capabilities.compact) descriptors.push({...native(\"compact\"), inputSchema: object({id, instructions: {type: \"string\"}}, [\"id\"])});\n if (capabilities.resume) descriptors.push({name: \"resume\", description: \"Continue a paused, completed or failed direct child from its host checkpoint and wait for result or pause\", risk: \"agent\", inputSchema: object({id, task: {type: \"string\", minLength: 1}}, [\"id\"])});\n if (capabilities.topology) {\n descriptors.push(\n {...native(\"sessions\"), inputSchema: object({})},\n {...native(\"peers\"), inputSchema: object({})},\n {...native(\"self\"), inputSchema: object({})},\n {...native(\"members\"), inputSchema: object({})},\n {...native(\"create\"), description: \"Create a lasting session peer in this project\", inputSchema: object({name: {type: \"string\", minLength: 1}, instructions: {type: \"string\"}, task: {type: \"string\"}}, [\"name\"])},\n {...native(\"remove\"), description: \"Stop and remove a lasting session peer created in this project\", inputSchema: object({id: {type: \"string\", minLength: 1}, name: {type: \"string\"}}, [\"id\"])},\n );\n }\n return descriptors;\n}\n\n// The shared checker knows every action; each provider still lists and admits only its client's capabilities.\nconst descriptors = agentServiceDescriptors({steer: true, followUp: true, compact: true, resume: true, topology: true});\nconst normalize = actionArgNormalizer(() => descriptors);\nexport function agentServiceArgs(action: AgentServiceAction, input: Record<string, unknown>): Record<string, unknown> {\n const descriptor = descriptors.find((entry) => entry.name === action);\n if (!descriptor) throw new Error(`Unsupported hosted agents action: ${action}`);\n const args = normalize(action, input);\n if (!Value.Check(descriptor.inputSchema, args)) {\n const reasons = [...Value.Errors(descriptor.inputSchema, args)].slice(0, 5).map((error) => `${error.instancePath}: ${error.message}`);\n throw new Error(`Invalid hosted agents.${action} arguments: ${reasons.join(\"; \")}`);\n }\n return args;\n}\n\nexport function normalizeAgentServiceRequest(input: AgentServiceRequest): AgentServiceRequest {\n const {residency, ...rest} = input;\n const args = agentServiceArgs(\"run\", rest as unknown as Record<string, unknown>);\n const request = normalizeAgentRunRequest(args, {runner: \"pi\", timeoutMs: 0}) as AgentServiceRequest;\n if (args.images !== undefined) request.images = structuredClone(args.images) as NonNullable<AgentServiceRequest[\"images\"]>;\n if (args.systemPrompt !== undefined) request.systemPrompt = args.systemPrompt as string;\n if (residency === \"session\" || residency === \"durable\") request.residency = residency;\n assertAgentTask(request);\n return structuredClone(request);\n}\n", "import { AgentAdmission, beginAgentSettlement, createAgentLifecycle, finishAgentSettlement, terminalAgentStatuses, waitForAgent, type AgentLifecycleState } from \"./lifecycle.js\";\nimport { validateAgentResult } from \"./result.js\";\nimport { normalizeAgentServiceRequest } from \"./service-schema.js\";\nimport type { AgentAuthorityBoundary, AgentPublicRecord, AgentControlRequest, AgentExecutionEvent, AgentExecutionResponse, AgentServiceCapabilities, AgentServiceEvent, AgentServiceOptions, AgentServiceRecord, AgentServiceRequest, AgentSessionRecord, AgentServiceSnapshot } from \"./service-types.js\";\n\ntype Entry = {\n request: AgentServiceRequest;\n record: AgentServiceRecord;\n lifecycle: AgentLifecycleState<AgentServiceRecord>;\n controller: AbortController;\n done?: Promise<void>;\n stopping?: Promise<AgentPublicRecord>;\n resuming?: boolean;\n stopAck?: Promise<void>;\n pauseAck?: Promise<void>;\n suspendRequested?: boolean;\n executing?: boolean;\n stopReason?: \"stop\" | \"close\";\n controls?: Set<Promise<unknown>>;\n};\nconst copy = <T>(value: T): T => structuredClone(value);\nconst publicRecord = (record: AgentServiceRecord): AgentPublicRecord => {\n const keys = [\"id\", \"rootId\", \"parentId\", \"depth\", \"generation\", \"name\", \"task\", \"status\", \"runner\", \"kernel\", \"cwd\", \"model\", \"thinking\", \"recursive\", \"startedAt\", \"updatedAt\", \"finishedAt\", \"currentTool\", \"turns\", \"toolCalls\", \"text\", \"value\", \"error\", \"usage\", \"sessionId\"] as const;\n return copy(Object.fromEntries(keys.filter((key) => record[key] !== undefined).map((key) => [key, record[key]]))) as AgentPublicRecord;\n};\nconst errorText = (error: unknown): string => error instanceof Error ? error.message : String(error);\nconst idle = (): AgentLifecycleState<AgentServiceRecord> => ({settled: true, result: undefined, resolve: undefined, release() {}, abortSignal: undefined, abortHandler: undefined});\n\n/** Portable one-shot agent authority. The execution port runs one participant, never a tree. */\nexport class AgentService {\n readonly #options: AgentServiceOptions;\n readonly #entries = new Map<string, Entry>();\n readonly #admission: AgentAdmission;\n readonly #pending = new Map<AbortController, Promise<unknown>>();\n readonly #closing = new AbortController();\n #close: Promise<void> | undefined;\n #suspend: Promise<void> | undefined;\n #suspended = false;\n #sequence = 0;\n #publication: Promise<void> = Promise.resolve();\n readonly capabilities: AgentServiceCapabilities;\n\n constructor(options: AgentServiceOptions) {\n if (!options.rootId) throw new Error(\"Agent service requires a trusted rootId\");\n for (const [key, value] of Object.entries({maxStarts: options.maxStarts ?? 8, maxDepth: options.maxDepth ?? 3, maxConcurrent: options.maxConcurrent ?? 4})) {\n if (!Number.isSafeInteger(value) || value < 1) throw new Error(`${key} must be a positive integer`);\n }\n this.#options = {...options, port: options.port};\n this.#admission = new AgentAdmission(options.maxConcurrent ?? 4, options.maxStarts ?? 8, options.maxDepth ?? 3);\n this.capabilities = Object.freeze({\n steer: Boolean(options.port.steer || options.topology),\n compact: Boolean(options.port.compact),\n resume: Boolean(options.port.resume),\n followUp: Boolean(options.port.followUp || options.topology),\n topology: Boolean(options.topology),\n });\n if (options.snapshot) this.#restore(options.snapshot);\n }\n\n snapshot(): AgentServiceSnapshot {\n return copy({version: 1, rootId: this.#options.rootId, starts: this.#admission.starts, sequence: this.#sequence,\n records: [...this.#entries.values()].map(({request, record}) => ({request, record}))});\n }\n\n async run(callerId: string, request: AgentServiceRequest, signal?: AbortSignal): Promise<AgentPublicRecord> {\n const handle = await this.spawn(callerId, request, signal);\n return this.wait(callerId, handle.id, signal);\n }\n\n async spawn(callerId: string, request: AgentServiceRequest, signal?: AbortSignal): Promise<AgentPublicRecord | AgentSessionRecord> {\n const normalized = normalizeAgentServiceRequest(request);\n if (normalized.residency === \"durable\") {\n await this.#authorize(callerId);\n const dispatch = this.#topology().dispatch;\n if (!dispatch) throw new Error(\"Durable hosted spawn is unavailable\");\n const record = await dispatch({callerId, request: normalized, ...(signal ? {signal} : {})});\n await this.#authorize(callerId);\n return copy(record);\n }\n return this.#start(callerId, normalized, undefined, signal);\n }\n\n async wait(callerId: string, id: string, signal?: AbortSignal): Promise<AgentPublicRecord> {\n await this.#authorize(callerId);\n const entry = this.#child(callerId, id);\n const result = entry.lifecycle.result ?? Promise.resolve(copy(entry.record));\n const record = await waitForAgent(result, signal);\n await this.#authorize(callerId);\n return publicRecord(record);\n }\n\n /** Alias for wait; authorization and cancellation semantics are identical. */\n join(callerId: string, id: string, signal?: AbortSignal): Promise<AgentPublicRecord> {\n return this.wait(callerId, id, signal);\n }\n\n async status(callerId: string, id: string): Promise<AgentPublicRecord> {\n await this.#authorize(callerId);\n return publicRecord(this.#child(callerId, id).record);\n }\n\n async list(callerId: string): Promise<AgentPublicRecord[]> {\n await this.#authorize(callerId);\n return [...this.#entries.values()].filter((entry) => entry.record.parentId === callerId).map((entry) => publicRecord(entry.record));\n }\n\n async stop(callerId: string, id: string): Promise<AgentPublicRecord> {\n await this.#authorize(callerId);\n const result = await this.#stop(this.#child(callerId, id));\n await this.#authorize(callerId);\n return publicRecord(result);\n }\n\n async steer(callerId: string, id: string, message: string): Promise<AgentPublicRecord | AgentSessionRecord> {\n if (!message.trim()) throw new Error(\"Steering message must not be empty\");\n const child = this.#ownedChild(callerId, id);\n if (child) {\n if (!this.#options.port.steer) throw new Error(\"Hosted agents.steer is unsupported\");\n return this.#control(callerId, child.record.id, \"steer\", (request) => this.#options.port.steer!({...request, message}));\n }\n return this.#deliver(callerId, id, \"steer\", message);\n }\n\n async followUp(callerId: string, id: string, message: string): Promise<AgentPublicRecord | AgentSessionRecord> {\n if (!message.trim()) throw new Error(\"Follow-up message must not be empty\");\n const child = this.#ownedChild(callerId, id);\n if (child) {\n if (!this.#options.port.followUp) throw new Error(\"Hosted agents.followUp is unsupported\");\n if (child.record.status === \"running\" && !child.stopping) {\n return this.#control(callerId, child.record.id, \"followUp\", (request) => this.#options.port.followUp!({...request, message}));\n }\n await this.#authorize(callerId);\n await this.#options.port.followUp({...this.#identity(child), message});\n await this.#authorize(callerId);\n return publicRecord(child.record);\n }\n return this.#deliver(callerId, id, \"followUp\", message);\n }\n\n async sessions(callerId: string): Promise<AgentSessionRecord[]> {\n await this.#authorize(callerId);\n return copy(await this.#topology().sessions());\n }\n\n async peers(callerId: string): Promise<AgentSessionRecord[]> {\n await this.#authorize(callerId);\n return copy(await this.#topology().peers(callerId));\n }\n\n async self(callerId: string): Promise<AgentSessionRecord> {\n await this.#authorize(callerId);\n if (this.#options.topology) return copy(await this.#options.topology.self(callerId));\n const child = callerId === this.#options.rootId ? undefined : this.#entries.get(callerId);\n return {\n id: callerId,\n name: child?.record.name ?? \"main\",\n kind: callerId === this.#options.rootId ? \"root\" : \"agent\",\n status: child?.record.status ?? \"running\",\n capabilities: callerId === this.#options.rootId ? [\"steer\", \"followUp\", \"stop\"] : [\"steer\", \"followUp\", \"stop\"],\n };\n }\n\n async create(callerId: string, request: { name: string; instructions?: string; task?: string }, signal?: AbortSignal): Promise<AgentSessionRecord> {\n if (!request.name.trim()) throw new Error(\"Peer name is required\");\n await this.#authorize(callerId);\n const create = this.#topology().create;\n if (!create) throw new Error(\"Hosted agents.create is unavailable\");\n const record = await create({callerId, name: request.name.trim(), ...(request.instructions ? {instructions: request.instructions} : {}), ...(request.task ? {task: request.task} : {}), ...(signal ? {signal} : {})});\n await this.#authorize(callerId);\n return copy(record);\n }\n\n async remove(callerId: string, id: string, name?: string, signal?: AbortSignal): Promise<AgentSessionRecord> {\n if (!id.trim()) throw new Error(\"Peer id is required\");\n await this.#authorize(callerId);\n const remove = this.#topology().remove;\n if (!remove) throw new Error(\"Hosted agents.remove is unavailable\");\n const record = await remove({callerId, id, ...(name ? {name} : {}), ...(signal ? {signal} : {})});\n await this.#authorize(callerId);\n return copy(record);\n }\n\n async members(callerId: string): Promise<AgentSessionRecord[]> {\n await this.#authorize(callerId);\n const sessions = this.#options.topology ? copy(await this.#options.topology.sessions()) : [];\n const seen = new Set(sessions.map((item) => item.id));\n const children: AgentSessionRecord[] = [];\n for (const entry of this.#entries.values()) {\n if (seen.has(entry.record.id)) continue;\n children.push({\n id: entry.record.id,\n name: entry.record.name,\n kind: \"agent\",\n status: entry.record.status,\n capabilities: [\"steer\", \"followUp\", \"stop\"],\n });\n }\n return [...sessions, ...children];\n }\n\n async compact(callerId: string, id: string, instructions?: string): Promise<AgentPublicRecord> {\n if (!this.#options.port.compact) throw new Error(\"Hosted agents.compact is unsupported\");\n return this.#control(callerId, id, \"compact\", (request) => this.#options.port.compact!({...request, ...(instructions !== undefined ? {instructions} : {})}));\n }\n\n async resume(callerId: string, id: string, task?: string, signal?: AbortSignal): Promise<AgentPublicRecord> {\n if (!this.#options.port.resume) throw new Error(\"Hosted agents.resume is unsupported\");\n await this.#authorize(callerId);\n const entry = this.#child(callerId, id);\n if (![\"paused\", \"completed\", \"failed\"].includes(entry.record.status) || !entry.lifecycle.settled || entry.resuming || entry.stopping) throw new Error(\"Only an idle paused, completed or failed agent can resume\");\n entry.resuming = true;\n try {\n const request = normalizeAgentServiceRequest({...entry.request, ...(task !== undefined ? {task} : {})});\n await this.#start(callerId, request, entry, signal);\n return await this.wait(callerId, id, signal);\n } finally { entry.resuming = false; }\n }\n\n /** Natural root completion waits for all background descendants without fencing live parents. */\n async drain(): Promise<void> {\n for (;;) {\n const work: Promise<unknown>[] = [...this.#pending.values()];\n for (const entry of this.#entries.values()) {\n if (entry.lifecycle.result && entry.done) work.push(entry.done);\n }\n if (work.length === 0) return;\n await Promise.allSettled(work);\n }\n }\n\n /** Host-only graceful pause. The port, not the owner signal, quiesces participant effects. */\n suspend(): Promise<void> {\n if (this.#suspend) return this.#suspend;\n if (this.#closing.signal.aborted) return Promise.reject(new Error(\"Agent service is closed\"));\n if (!this.#options.port.pause && [...this.#entries.values()].some((entry) => !entry.lifecycle.settled)) {\n return Promise.reject(new Error(\"Hosted agent suspension requires port.pause\"));\n }\n this.#suspended = true;\n for (const entry of this.#entries.values()) {\n if (!entry.lifecycle.settled && !terminalAgentStatuses.has(entry.record.status)) entry.suspendRequested = true;\n }\n for (const controller of this.#pending.keys()) controller.abort();\n this.#suspend = (async () => {\n const roots = [...this.#entries.values()].filter((entry) => entry.record.parentId === this.#options.rootId);\n const paused = await Promise.allSettled(roots.map((entry) => this.#pause(entry)));\n await Promise.allSettled([...this.#pending.values()]);\n const errors = paused.filter((result): result is PromiseRejectedResult => result.status === \"rejected\");\n if (errors.length) throw new AggregateError(errors.map((result) => result.reason), \"Agent suspension failed\");\n await this.drain();\n })();\n return this.#suspend;\n }\n\n async #pause(entry: Entry): Promise<void> {\n const children = [...this.#entries.values()].filter((child) => child.record.parentId === entry.record.id);\n const paused = await Promise.allSettled(children.map((child) => this.#pause(child)));\n const errors = paused.filter((result): result is PromiseRejectedResult => result.status === \"rejected\").map((result) => result.reason);\n if (errors.length) throw new AggregateError(errors, \"Agent descendant suspension failed\");\n if (entry.executing && !entry.stopping) {\n entry.pauseAck = Promise.resolve().then(async () => {\n if (entry.executing && !entry.stopping) await this.#options.port.pause!(this.#identity(entry));\n });\n try { await entry.pauseAck; }\n catch (error) { throw new AggregateError([...errors, error], \"Agent pause acknowledgment failed\"); }\n }\n await entry.done;\n }\n\n close(): Promise<void> {\n if (this.#close) return this.#close;\n this.#closing.abort();\n for (const controller of this.#pending.keys()) controller.abort();\n this.#close = (async () => {\n const errors: unknown[] = [];\n const stopped = await Promise.allSettled([...this.#entries.values()].map((entry) => this.#stop(entry, true)));\n for (const result of stopped) if (result.status === \"rejected\") errors.push(result.reason);\n await Promise.allSettled([...this.#pending.values()]);\n if (errors.length) throw new AggregateError(errors, \"Agent shutdown failed\");\n })();\n return this.#close;\n }\n\n #start(callerId: string, request: AgentServiceRequest, previous?: Entry, signal?: AbortSignal): Promise<AgentPublicRecord> {\n const controller = new AbortController();\n const abort = () => controller.abort();\n signal?.addEventListener(\"abort\", abort, {once: true});\n if (signal?.aborted || this.#closing.signal.aborted || this.#suspended) controller.abort();\n const operation = (async () => {\n let release: (() => void) | undefined;\n try {\n await this.#authorize(callerId);\n const depth = this.#depth(callerId);\n if (controller.signal.aborted) throw new Error(\"Operation aborted\");\n if (depth > this.#admission.maxDepth) throw new Error(`Fabric agent depth limit reached (${this.#admission.maxDepth})`);\n const id = previous?.record.id ?? crypto.randomUUID().replaceAll(\"-\", \"\");\n const generation = (previous?.record.generation ?? 0) + 1;\n const prepare = {id, generation, rootId: this.#options.rootId, parentId: callerId, depth, request: copy(request), signal: controller.signal};\n const binding = await this.#options.port.prepare?.(prepare);\n release = await this.#admission.acquire(callerId, controller.signal);\n await this.#authorize(callerId);\n this.#depth(callerId);\n if (controller.signal.aborted || this.#closing.signal.aborted || previous?.stopping) throw new Error(\"Agent admission aborted\");\n // No await between the final authority/parent check and the root-wide charge.\n this.#admission.admit(depth);\n const now = Date.now();\n const record: AgentServiceRecord = previous ? {\n ...previous.record, task: request.task, status: \"queued\", generation: previous.record.generation + 1,\n text: \"\", turns: 0, toolCalls: 0, updatedAt: now,\n } : {\n id, rootId: this.#options.rootId, parentId: callerId, depth, generation: 1,\n name: (request.name ?? request.task.split(\"\\n\", 1)[0] ?? \"Fabric agent\").replace(/[\\r\\n\\t]+/g, \" \").trim().slice(0, 60) || \"Fabric agent\",\n task: request.task, status: \"queued\", runner: \"pi\", kernel: \"typescript\", startedAt: now, updatedAt: now,\n turns: 0, toolCalls: 0, text: \"\", usage: {input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0},\n ...(request.model ? {model: request.model} : {}), ...(request.thinking ? {thinking: request.thinking} : {}),\n ...(request.cwd !== undefined ? {cwd: request.cwd} : {}), ...(request.recursive !== undefined ? {recursive: request.recursive} : {}),\n };\n delete record.finishedAt; delete record.error; delete record.value; delete record.currentTool;\n const entry: Entry = previous ?? {request, record, lifecycle: idle(), controller};\n entry.request = copy(request); entry.record = record; entry.controller = controller;\n entry.lifecycle = createAgentLifecycle<AgentServiceRecord>(release);\n release = undefined;\n this.#entries.set(record.id, entry);\n this.#pending.delete(controller);\n // Admission cancellation detaches here. Background execution has a distinct owner signal.\n signal?.removeEventListener(\"abort\", abort);\n let acknowledge!: () => void;\n const admitted = new Promise<void>((resolve) => { acknowledge = resolve; });\n entry.done = this.#drive(entry, binding, Boolean(previous), acknowledge);\n await admitted;\n await this.#authorize(callerId);\n return publicRecord(record);\n } finally {\n release?.();\n signal?.removeEventListener(\"abort\", abort);\n }\n })();\n this.#pending.set(controller, operation);\n void operation.finally(() => this.#pending.delete(controller)).catch(() => {});\n return operation;\n }\n\n async #drive(entry: Entry, binding: unknown, resume: boolean, admitted: () => void): Promise<void> {\n const generation = entry.record.generation;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let timeout = false;\n let responded = false;\n try {\n await this.#publish(\"admitted\", entry);\n admitted();\n await this.#authorize(entry.record.parentId);\n if (entry.controller.signal.aborted) throw new Error(\"Agent start aborted\");\n entry.record.status = \"running\";\n await this.#publish(\"running\", entry);\n await this.#authorize(entry.record.parentId);\n if (entry.controller.signal.aborted) throw new Error(\"Agent start aborted\");\n const request = {\n ...this.#identity(entry), depth: entry.record.depth, request: copy(entry.request), signal: entry.controller.signal,\n binding, ...(entry.record.checkpoint !== undefined ? {checkpoint: copy(entry.record.checkpoint)} : {}),\n emit: async (event: AgentExecutionEvent) => {\n const assertCurrent = () => {\n if (!entry.executing || entry.lifecycle.settled || entry.controller.signal.aborted || entry.record.generation !== generation || entry.record.status !== \"running\") throw new Error(\"Stale agent execution event\");\n };\n assertCurrent();\n if (event.type !== \"checkpoint\" && event.type !== \"progress\") throw new Error(\"Unsupported agent execution event\");\n const saved = copy(event);\n await this.#publish(saved.type, entry, undefined, () => {\n if (saved.type === \"checkpoint\") entry.record.checkpoint = saved.checkpoint;\n else {\n for (const key of [\"text\", \"turns\", \"toolCalls\", \"currentTool\", \"usage\"] as const) {\n if (saved[key] !== undefined) Object.assign(entry.record, {[key]: saved[key]});\n }\n }\n }, assertCurrent);\n },\n };\n if (entry.request.timeoutMs) timer = setTimeout(() => {\n if (entry.suspendRequested) return;\n timeout = true;\n void this.#stop(entry).catch(() => {});\n }, entry.request.timeoutMs);\n const execute = resume ? this.#options.port.resume! : this.#options.port.execute;\n entry.executing = true;\n let response: AgentExecutionResponse;\n try { response = await execute.call(this.#options.port, request); }\n finally { entry.executing = false; }\n if (![\"completed\", \"failed\", \"stopped\", \"timed_out\", \"paused\"].includes(response.status)) throw new Error(\"Invalid agent execution response status\");\n await this.#authorize(entry.record.parentId, response.status === \"paused\" ? {checkpoint: true} : undefined);\n if (entry.record.generation !== generation || entry.lifecycle.settled) throw new Error(\"Stale agent execution response\");\n this.#applyResponse(entry, response);\n responded = true;\n } catch (error) {\n entry.record.status = \"failed\";\n entry.record.error = errorText(error);\n } finally {\n admitted();\n if (timer) clearTimeout(timer);\n await Promise.allSettled([...(entry.controls ?? []), ...(entry.stopAck ? [entry.stopAck] : []), ...(entry.pauseAck ? [entry.pauseAck] : [])]);\n if (entry.suspendRequested && !entry.controller.signal.aborted) {\n entry.record.status = \"paused\"; delete entry.record.error; delete entry.record.finishedAt;\n }\n if (entry.controller.signal.aborted) {\n if (entry.stopReason === \"close\") {\n if (!responded || ![\"completed\", \"failed\"].includes(entry.record.status)) { entry.record.status = \"paused\"; delete entry.record.error; }\n } else entry.record.status = timeout ? \"timed_out\" : \"stopped\";\n }\n try { await this.#options.port.cleanup?.(this.#identity(entry)); }\n catch (error) { entry.record.status = \"failed\"; entry.record.error = `Agent cleanup failed: ${errorText(error)}`; }\n validateAgentResult(entry.record, entry.request.schema);\n delete entry.record.currentTool;\n if (terminalAgentStatuses.has(entry.record.status)) entry.record.finishedAt = Date.now();\n if (beginAgentSettlement(entry.lifecycle)) {\n try { await this.#publish(\"settled\", entry); }\n catch (error) { entry.record.status = \"failed\"; entry.record.error = `Agent publication failed: ${errorText(error)}`; }\n finishAgentSettlement(entry.lifecycle, copy(entry.record));\n }\n }\n }\n\n #applyResponse(entry: Entry, response: AgentExecutionResponse): void {\n // Port output cannot overwrite host-owned identifiers, lineage or admission metadata.\n entry.record.status = response.status;\n for (const key of [\"text\", \"value\", \"error\", \"usage\", \"checkpoint\", \"sessionId\"] as const) {\n if (response[key] !== undefined) Object.assign(entry.record, {[key]: copy(response[key])});\n }\n }\n\n #stop(entry: Entry, preservePaused = false): Promise<AgentPublicRecord> {\n if (entry.stopping) return entry.stopping;\n entry.stopReason = preservePaused ? \"close\" : \"stop\";\n const work = (async () => {\n const active = !entry.lifecycle.settled;\n entry.controller.abort();\n const descendants = [...this.#entries.values()].filter((child) => child.record.parentId === entry.record.id);\n const operations: Promise<unknown>[] = descendants.map((child) => this.#stop(child, preservePaused));\n if (active && this.#options.port.stop) {\n entry.stopAck = Promise.resolve().then(() => this.#options.port.stop!(this.#identity(entry)));\n operations.push(entry.stopAck);\n }\n if (entry.done) operations.push(entry.done);\n const settled = await Promise.allSettled(operations);\n if (entry.record.status === \"paused\" && !preservePaused) {\n entry.record.status = \"stopped\"; entry.record.finishedAt = Date.now();\n await this.#publish(\"settled\", entry);\n }\n const errors = settled.filter((result): result is PromiseRejectedResult => result.status === \"rejected\");\n if (errors.length) throw new AggregateError(errors.map((result) => result.reason), \"Agent stop failed\");\n return publicRecord(entry.record);\n })();\n entry.stopping = work;\n return work;\n }\n\n async #control(callerId: string, id: string, control: \"steer\" | \"compact\" | \"followUp\", invoke: (request: AgentControlRequest) => Promise<void>): Promise<AgentPublicRecord> {\n await this.#authorize(callerId);\n const entry = this.#child(callerId, id);\n if (entry.record.status !== \"running\" || entry.stopping) throw new Error(\"Agent is not running\");\n const generation = entry.record.generation;\n const pending = Promise.resolve().then(async () => {\n await this.#authorize(callerId);\n if (entry.record.generation !== generation || entry.controller.signal.aborted || entry.lifecycle.settled) throw new Error(\"Stale agent control\");\n await invoke(this.#identity(entry));\n });\n (entry.controls ??= new Set()).add(pending);\n try { await pending; } finally { entry.controls.delete(pending); }\n await this.#authorize(callerId);\n if (entry.record.generation !== generation || entry.controller.signal.aborted) throw new Error(\"Stale agent control acknowledgment\");\n await this.#publish(\"control\", entry, control);\n return publicRecord(entry.record);\n }\n\n #identity(entry: Entry): AgentControlRequest {\n const {id, rootId, parentId, generation} = entry.record;\n return {id, rootId, parentId, generation};\n }\n\n async #authorize(callerId: string, boundary?: AgentAuthorityBoundary): Promise<void> {\n if (callerId !== this.#options.rootId && !this.#entries.has(callerId)) throw new Error(\"Unknown agent caller\");\n if (this.#suspended && !boundary?.checkpoint) throw new Error(\"Agent service is paused\");\n await this.#options.assertAuthority?.(callerId, boundary);\n if (this.#suspended && !boundary?.checkpoint) throw new Error(\"Agent service is paused\");\n }\n\n #child(callerId: string, id: string): Entry {\n const entry = this.#ownedChild(callerId, id);\n if (!entry) throw new Error(`Unknown direct child agent: ${id}`);\n return entry;\n }\n\n #ownedChild(callerId: string, id: string): Entry | undefined {\n const entry = this.#entries.get(id);\n return entry && entry.record.parentId === callerId ? entry : undefined;\n }\n\n #topology(): NonNullable<AgentServiceOptions[\"topology\"]> {\n if (!this.#options.topology) throw new Error(\"Hosted agent topology is unavailable\");\n return this.#options.topology;\n }\n\n async #deliver(callerId: string, id: string, operation: \"steer\" | \"followUp\", message: string): Promise<AgentSessionRecord> {\n const topology = this.#topology();\n await this.#authorize(callerId);\n const target = id === \"main\" ? this.#options.rootId : id;\n const record = await topology.deliver({callerId, id: target, operation, message});\n await this.#authorize(callerId);\n return copy(record);\n }\n\n #depth(callerId: string): number {\n if (this.#closing.signal.aborted) throw new Error(\"Agent service is closed\");\n if (this.#suspended) throw new Error(\"Agent service is paused\");\n if (callerId === this.#options.rootId) return 1;\n const parent = this.#entries.get(callerId);\n if (!parent || parent.record.status !== \"running\" || parent.stopping || parent.controller.signal.aborted || parent.request.recursive === false) throw new Error(\"Agent parent cannot admit children\");\n return parent.record.depth + 1;\n }\n\n async #publish(type: AgentServiceEvent[\"type\"], entry: Entry, control?: AgentServiceEvent[\"control\"], update?: () => void, assertCurrent?: () => void): Promise<void> {\n const boundary = type === \"checkpoint\" || type === \"settled\" ? {checkpoint: true} : undefined;\n const generation = entry.record.generation;\n await this.#authorize(entry.record.parentId, boundary);\n const publication = this.#publication.then(async () => {\n await this.#authorize(entry.record.parentId, boundary);\n if (entry.record.generation !== generation) throw new Error(\"Stale agent publication\");\n assertCurrent?.();\n // Commit event mutations only after serialized, phase-matched lease authorization.\n update?.();\n entry.record.updatedAt = Date.now();\n const event: AgentServiceEvent = {version: 1, sequence: ++this.#sequence, type, record: copy(entry.record), ...(control ? {control} : {})};\n await this.#options.onEvent?.(event);\n });\n this.#publication = publication.catch(() => {});\n await publication;\n }\n\n #restore(snapshot: AgentServiceSnapshot): void {\n const saved = copy(snapshot);\n const newRoot = this.#options.restorePolicy === \"new-root\";\n if (newRoot && saved.rootId !== this.#options.rootId) {\n const oldRoot = saved.rootId;\n saved.rootId = this.#options.rootId;\n for (const {record} of saved.records) {\n if (record.rootId !== oldRoot) throw new Error(\"Invalid agent snapshot root\");\n record.rootId = saved.rootId;\n if (record.parentId === oldRoot) record.parentId = saved.rootId;\n }\n }\n if (saved.version !== 1 || saved.rootId !== this.#options.rootId || !Number.isSafeInteger(saved.starts) || saved.starts < 0 || (!newRoot && saved.starts > this.#admission.maxStarts) || !Number.isSafeInteger(saved.sequence) || saved.sequence < 0 || !Array.isArray(saved.records)) throw new Error(\"Invalid agent service snapshot\");\n let generations = 0;\n for (const item of saved.records) {\n const request = normalizeAgentServiceRequest(item.request);\n const record = item.record;\n if (!record.id || record.id === saved.rootId || this.#entries.has(record.id) || record.rootId !== saved.rootId || !Number.isSafeInteger(record.depth) || record.depth < 1 || record.depth > this.#admission.maxDepth || !Number.isSafeInteger(record.generation) || record.generation < 1 || ![\"queued\", \"running\", \"paused\", ...terminalAgentStatuses].includes(record.status)) throw new Error(\"Invalid agent snapshot record\");\n generations += record.generation;\n if (record.status === \"running\" || record.status === \"queued\") { record.status = \"paused\"; delete record.finishedAt; }\n this.#entries.set(record.id, {request, record, lifecycle: idle(), controller: new AbortController()});\n }\n for (const {record} of this.#entries.values()) {\n const parent = this.#entries.get(record.parentId);\n if (record.parentId === saved.rootId ? record.depth !== 1 : !parent || parent.record.depth + 1 !== record.depth) throw new Error(\"Invalid agent snapshot lineage\");\n }\n if (saved.starts > generations) throw new Error(\"Invalid agent snapshot admission count\");\n this.#admission.starts = newRoot ? 0 : saved.starts;\n this.#sequence = saved.sequence;\n }\n}\n", "import type { FabricProvider } from \"../protocol.js\";\nimport { AgentService } from \"./service.js\";\nimport { agentServiceArgs, agentServiceDescriptors } from \"./service-schema.js\";\nimport type { AgentServiceAction, AgentServiceCapabilities, AgentServiceClient, AgentServiceDispatcher, AgentPublicRecord, AgentServiceRequest, AgentSessionRecord } from \"./service-types.js\";\n\n/** Bind only authenticated host identity here. Guest arguments never carry the caller. */\nexport function createAgentServiceHandler(service: AgentService, callerId: string): AgentServiceDispatcher {\n return async (action, input, signal) => {\n const args = agentServiceArgs(action, input);\n switch (action) {\n case \"run\": return service.run(callerId, args as unknown as AgentServiceRequest, signal);\n case \"spawn\": return service.spawn(callerId, args as unknown as AgentServiceRequest, signal);\n case \"join\":\n case \"wait\": return service.wait(callerId, args.id as string, signal);\n case \"status\": return service.status(callerId, args.id as string);\n case \"list\": return service.list(callerId);\n case \"stop\": return service.stop(callerId, args.id as string);\n case \"steer\": return service.steer(callerId, args.id as string, args.message as string);\n case \"followUp\": return service.followUp(callerId, args.id as string, args.message as string);\n case \"compact\": return service.compact(callerId, args.id as string, args.instructions as string | undefined);\n case \"resume\": return service.resume(callerId, args.id as string, args.task as string | undefined, signal);\n case \"sessions\": return service.sessions(callerId);\n case \"peers\": return service.peers(callerId);\n case \"self\": return service.self(callerId);\n case \"members\": return service.members(callerId);\n case \"create\": return service.create(callerId, args as {name: string; instructions?: string; task?: string}, signal);\n case \"remove\": return service.remove(callerId, args.id as string, args.name as string | undefined, signal);\n default: throw new Error(`Unsupported hosted agents action: ${String(action)}`);\n }\n };\n}\n\n/** A transport client only; all admission and lifecycle remain in the root service. */\nexport function createAgentServiceClient(dispatch: AgentServiceDispatcher, capabilities: AgentServiceCapabilities = {}): AgentServiceClient {\n const record = (action: AgentServiceAction, args: Record<string, unknown>, signal?: AbortSignal) => dispatch(action, args, signal) as Promise<AgentPublicRecord>;\n return {\n capabilities: Object.freeze({...capabilities}), dispatch,\n run: (request, signal) => record(\"run\", request as unknown as Record<string, unknown>, signal),\n spawn: (request, signal) => record(\"spawn\", request as unknown as Record<string, unknown>, signal),\n wait: (id, signal) => record(\"wait\", {id}, signal),\n join: (id, signal) => record(\"wait\", {id}, signal),\n status: (id) => record(\"status\", {id}),\n list: () => dispatch(\"list\", {}) as Promise<AgentPublicRecord[]>,\n stop: (id) => record(\"stop\", {id}),\n steer: (id, message) => record(\"steer\", {id, message}),\n compact: (id, instructions) => record(\"compact\", {id, ...(instructions !== undefined ? {instructions} : {})}),\n resume: (id, task, signal) => record(\"resume\", {id, ...(task !== undefined ? {task} : {})}, signal),\n followUp: (id, message) => record(\"followUp\", {id, message}),\n sessions: () => dispatch(\"sessions\", {}) as Promise<AgentSessionRecord[]>,\n peers: () => dispatch(\"peers\", {}) as Promise<AgentSessionRecord[]>,\n self: () => dispatch(\"self\", {}) as Promise<AgentSessionRecord>,\n members: () => dispatch(\"members\", {}) as Promise<AgentSessionRecord[]>,\n create: (request, signal) => dispatch(\"create\", request as unknown as Record<string, unknown>, signal) as Promise<AgentSessionRecord>,\n remove: (id, name, signal) => dispatch(\"remove\", {id, ...(name !== undefined ? {name} : {})}, signal) as Promise<AgentSessionRecord>,\n };\n}\n\nexport function createAgentsProvider(client: AgentServiceClient): FabricProvider {\n const descriptors = agentServiceDescriptors(client.capabilities);\n const allowed = new Set(descriptors.map((descriptor) => descriptor.name));\n const validate = (action: string, args: Record<string, unknown>) => {\n if (!allowed.has(action)) throw new Error(`Unsupported hosted agents action: ${action}`);\n return agentServiceArgs(action as AgentServiceAction, args);\n };\n return {\n name: \"agents\", description: \"Fabric host-authorized Pi agents\",\n list: async () => structuredClone(descriptors),\n describe: async (name) => structuredClone(descriptors.find((descriptor) => descriptor.name === name)),\n prepareArguments: (action, args) => validate(action, args),\n invoke: async (action, args, context) => client.dispatch(action as AgentServiceAction, validate(action, args), context.signal),\n };\n}\n", "/** Portable hosted agents: no local manager, filesystem, model registry or ambient configuration. */\nexport { AgentService } from \"./agents/service.js\";\nexport { createAgentsProvider, createAgentServiceClient, createAgentServiceHandler } from \"./agents/service-provider.js\";\nexport { agentServiceDescriptors } from \"./agents/service-schema.js\";\nexport type * from \"./agents/service-types.js\";\nexport type { AgentRunRequest, AgentRunRecord, AgentRunResult, AgentHandleInfo, AgentUsage } from \"./agents/types.js\";\nexport const HOSTED_AGENTS_PROTOCOL_VERSION = 1 as const;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AAQtB,IAAM,SAAS,CAAC,SAAyC;AACvD,QAAM,aAAa,0BAA0B,KAAK,CAAC,UAAU,MAAM,SAAS,IAAI;AAChF,MAAI,CAAC,WAAY,OAAM,IAAI,MAAM,oCAAoC,IAAI,EAAE;AAC3E,SAAO,gBAAgB,UAAU;AACnC;AACA,IAAM,MAAM,OAAO,KAAK;AACxB,IAAM,aAAa,EAAE,GAAI,IAAI,YAAsD,WAAW;AAG9F,WAAW,OAAO,CAAC,aAAa,WAAW,cAAc,SAAS,QAAQ,EAAG,QAAO,WAAW,GAAG;AAClG,OAAO,OAAO,YAAY;AAAA,EACxB,QAAQ,EAAC,MAA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;AAAA,IACpG,kBAAkB,CAAC,QAAQ,SAAS,SAAS,QAAQ,IAAI;AAAA,IACzD,QAAQ,OAAO,QAAQ,MAAM,YAAY,OAAO,SAAS,QAA8B,SAAS,QAAQ,IAAI,GAAG,QAAQ,MAAM;AAAA,EAC/H;AACF;;;ACjEO,IAAM,iCAAiC;",
|
|
6
6
|
"names": ["properties", "descriptors", "id", "id", "descriptors"]
|
|
7
7
|
}
|
package/dist/audit/details.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export interface FabricPersistedExecutionDetailsV1 {
|
|
|
15
15
|
outputFormat?: "yaml" | "json";
|
|
16
16
|
outputFormatStartLine?: number;
|
|
17
17
|
outputFormatLines?: number;
|
|
18
|
+
/** Audits the size bound dropped; the resumed card still counts them. */
|
|
19
|
+
omittedCalls?: FabricOmittedCalls;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* The audit fields that cross into the session record; read back by
|
|
@@ -69,6 +71,8 @@ export interface FabricOmittedCalls {
|
|
|
69
71
|
count: number;
|
|
70
72
|
/** How many of the omitted calls had finished. */
|
|
71
73
|
done: number;
|
|
74
|
+
/** How many omitted calls failed (absent in older records). */
|
|
75
|
+
failed?: number;
|
|
72
76
|
}
|
|
73
77
|
/**
|
|
74
78
|
* Creates the only object stored in final fabric_exec details. The
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"details.d.ts","sourceRoot":"","sources":["../../src/audit/details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,kCAAkC,QAAa,CAAC;AAE7D,MAAM,WAAW,iCAAiC;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,KAA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MG;AACH,eAAO,MAAM,mCAAmC,GAAI,OAAO;IACzD,MAAM,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAC/C,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,KAAG,6BA4DH,CAAC"}
|
|
@@ -403,6 +403,20 @@ var readFabricDecisionRequestV1 = (value) => {
|
|
|
403
403
|
}
|
|
404
404
|
return value;
|
|
405
405
|
};
|
|
406
|
+
var FABRIC_QUESTION_RENDERER_REGISTER_EVENT = "pi-fabric:question-renderer:register:v1";
|
|
407
|
+
var readFabricQuestionRendererRegistrationV1 = (value) => {
|
|
408
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
409
|
+
const record = value;
|
|
410
|
+
if (record.version !== 1 || typeof record.name !== "string" || typeof record.render !== "function" || record.respond !== void 0 && typeof record.respond !== "function") {
|
|
411
|
+
return void 0;
|
|
412
|
+
}
|
|
413
|
+
return {
|
|
414
|
+
version: 1,
|
|
415
|
+
name: record.name,
|
|
416
|
+
render: record.render,
|
|
417
|
+
...record.respond ? { respond: record.respond } : {}
|
|
418
|
+
};
|
|
419
|
+
};
|
|
406
420
|
var FABRIC_NESTED_TOOL_CALL_ID_PREFIX = "fabric_";
|
|
407
421
|
var FABRIC_TOOL_RESULT_PROXY_KIND = "pi-fabric.tool-result-proxy.v1";
|
|
408
422
|
var readFabricToolResultProxyDetailsV1 = (value) => {
|
|
@@ -460,8 +474,10 @@ export {
|
|
|
460
474
|
FABRIC_DECISION_REQUEST_EVENT,
|
|
461
475
|
readFabricDecisionsCapabilityRequestV1,
|
|
462
476
|
readFabricDecisionRequestV1,
|
|
477
|
+
FABRIC_QUESTION_RENDERER_REGISTER_EVENT,
|
|
478
|
+
readFabricQuestionRendererRegistrationV1,
|
|
463
479
|
FABRIC_NESTED_TOOL_CALL_ID_PREFIX,
|
|
464
480
|
FABRIC_TOOL_RESULT_PROXY_KIND,
|
|
465
481
|
readFabricToolResultProxyDetailsV1
|
|
466
482
|
};
|
|
467
|
-
//# sourceMappingURL=chunk-
|
|
483
|
+
//# sourceMappingURL=chunk-2RWNVCFD.js.map
|