pi-fabric 0.109.0 → 0.109.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/durable/worker.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// src/durable/worker.ts
|
|
4
|
+
import { registerHooks } from "node:module";
|
|
5
|
+
|
|
3
6
|
// src/durable/worker-options.ts
|
|
4
7
|
import path from "node:path";
|
|
5
8
|
function parseDurableWorkerOptions(argv, cwd = process.cwd()) {
|
|
@@ -71,6 +74,20 @@ function parseDurableWorkerOptions(argv, cwd = process.cwd()) {
|
|
|
71
74
|
// src/durable/worker.ts
|
|
72
75
|
try {
|
|
73
76
|
const options = parseDurableWorkerOptions(process.argv.slice(2));
|
|
77
|
+
const sdkEntry = import.meta.resolve("pi-fabric-worker-sdk");
|
|
78
|
+
const sdkName = "@earendil-works/pi-coding-agent";
|
|
79
|
+
const peers = ["@earendil-works/pi-agent-core", "@earendil-works/pi-ai", "@earendil-works/pi-tui", "typebox"];
|
|
80
|
+
registerHooks({
|
|
81
|
+
resolve(specifier, context, nextResolve) {
|
|
82
|
+
if (specifier === sdkName || specifier.startsWith(`${sdkName}/`)) {
|
|
83
|
+
return nextResolve(`pi-fabric-worker-sdk${specifier.slice(sdkName.length)}`, { ...context, parentURL: import.meta.url });
|
|
84
|
+
}
|
|
85
|
+
if (peers.some((name) => specifier === name || specifier.startsWith(`${name}/`))) {
|
|
86
|
+
return nextResolve(specifier, { ...context, parentURL: sdkEntry });
|
|
87
|
+
}
|
|
88
|
+
return nextResolve(specifier, context);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
74
91
|
const { runDurableWorker } = await import("./worker-host.js");
|
|
75
92
|
await runDurableWorker(options);
|
|
76
93
|
} catch (error) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/durable/worker
|
|
4
|
-
"sourcesContent": ["import path from \"node:path\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\n\nexport interface DurableWorkerOptions {\n directory: string;\n runId: string;\n sessionFile?: string;\n model?: string;\n provider?: string;\n thinking?: ThinkingLevel;\n tools?: string[];\n noTools?: \"all\";\n extensions: string[];\n noExtensions: boolean;\n appendSystemPrompt: string;\n}\n\n/** Internal worker protocol, deliberately not a second general-purpose Pi CLI. */\nexport function parseDurableWorkerOptions(argv: readonly string[], cwd = process.cwd()): DurableWorkerOptions {\n const options: DurableWorkerOptions = {\n directory: \"\", runId: \"\", extensions: [], noExtensions: false, appendSystemPrompt: \"\",\n };\n const prompts: string[] = [];\n for (let i = 0; i < argv.length; i++) {\n const flag = argv[i]!;\n if (flag === \"--no-session\") continue;\n if (flag === \"--no-extensions\") { options.noExtensions = true; continue; }\n if (flag === \"--no-tools\") { options.noTools = \"all\"; continue; }\n if (![\"--mode\", \"--durable-directory\", \"--durable-run-id\", \"--session\", \"--model\", \"--provider\", \"--thinking\", \"--tools\", \"-e\", \"--extension\", \"--append-system-prompt\"].includes(flag)) {\n throw new Error(`Unsupported durable worker option: ${flag}`);\n }\n const value = argv[++i];\n if (value === undefined || value.startsWith(\"--\")) throw new Error(`Missing value for ${flag}`);\n switch (flag) {\n case \"--mode\": if (value !== \"rpc\") throw new Error(\"The durable worker only supports RPC mode\"); break;\n case \"--durable-directory\": options.directory = path.resolve(cwd, value); break;\n case \"--durable-run-id\": options.runId = value.trim(); break;\n case \"--session\": options.sessionFile = path.resolve(cwd, value); break;\n case \"--model\": options.model = value; break;\n case \"--provider\": options.provider = value; break;\n case \"--thinking\":\n if (![\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"].includes(value)) throw new Error(`Invalid thinking level: ${value}`);\n options.thinking = value as ThinkingLevel;\n break;\n case \"--tools\": options.tools = value.split(\",\").map(tool => tool.trim()).filter(Boolean); break;\n case \"-e\": case \"--extension\": options.extensions.push(value.startsWith(\"builtin:\") ? value : path.resolve(cwd, value)); break;\n case \"--append-system-prompt\": prompts.push(value); break;\n }\n }\n if (!options.directory || !options.runId) throw new Error(\"Durable workers require --durable-directory and --durable-run-id\");\n if (options.tools && options.noTools) throw new Error(\"--tools and --no-tools are mutually exclusive\");\n options.appendSystemPrompt = prompts.join(\"\\n\\n\");\n return options;\n}\n"
|
|
5
|
-
"mappings": ";;;
|
|
3
|
+
"sources": ["../../src/durable/worker.ts", "../../src/durable/worker-options.ts"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\nimport { registerHooks } from \"node:module\";\nimport { parseDurableWorkerOptions } from \"./worker-options.js\";\n\ntry {\n // This process-only entry is never imported by extension registration.\n const options = parseDurableWorkerOptions(process.argv.slice(2));\n // Managed Pi installs omit host peers. A subprocess cannot use Main's virtual\n // modules, so it owns a pinned SDK under a non-peer name. Resolve all Pi peers\n // through that SDK's dependency tree (also with non-hoisting installers), not\n // an ambient checkout or another extension's SDK. This hook is process-local\n // and must be installed before importing any durable host/engine modules.\n const sdkEntry = import.meta.resolve(\"pi-fabric-worker-sdk\");\n const sdkName = \"@earendil-works/pi-coding-agent\";\n const peers = [\"@earendil-works/pi-agent-core\", \"@earendil-works/pi-ai\", \"@earendil-works/pi-tui\", \"typebox\"];\n registerHooks({\n resolve(specifier, context, nextResolve) {\n if (specifier === sdkName || specifier.startsWith(`${sdkName}/`)) {\n return nextResolve(`pi-fabric-worker-sdk${specifier.slice(sdkName.length)}`, { ...context, parentURL: import.meta.url });\n }\n if (peers.some(name => specifier === name || specifier.startsWith(`${name}/`))) {\n return nextResolve(specifier, { ...context, parentURL: sdkEntry });\n }\n return nextResolve(specifier, context);\n },\n });\n const { runDurableWorker } = await import(\"./worker-host.js\");\n await runDurableWorker(options);\n} catch (error) {\n process.stderr.write(`Durable Pi worker failed: ${error instanceof Error ? error.stack ?? error.message : String(error)}\\n`);\n process.exitCode = 1;\n}\n", "import path from \"node:path\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\n\nexport interface DurableWorkerOptions {\n directory: string;\n runId: string;\n sessionFile?: string;\n model?: string;\n provider?: string;\n thinking?: ThinkingLevel;\n tools?: string[];\n noTools?: \"all\";\n extensions: string[];\n noExtensions: boolean;\n appendSystemPrompt: string;\n}\n\n/** Internal worker protocol, deliberately not a second general-purpose Pi CLI. */\nexport function parseDurableWorkerOptions(argv: readonly string[], cwd = process.cwd()): DurableWorkerOptions {\n const options: DurableWorkerOptions = {\n directory: \"\", runId: \"\", extensions: [], noExtensions: false, appendSystemPrompt: \"\",\n };\n const prompts: string[] = [];\n for (let i = 0; i < argv.length; i++) {\n const flag = argv[i]!;\n if (flag === \"--no-session\") continue;\n if (flag === \"--no-extensions\") { options.noExtensions = true; continue; }\n if (flag === \"--no-tools\") { options.noTools = \"all\"; continue; }\n if (![\"--mode\", \"--durable-directory\", \"--durable-run-id\", \"--session\", \"--model\", \"--provider\", \"--thinking\", \"--tools\", \"-e\", \"--extension\", \"--append-system-prompt\"].includes(flag)) {\n throw new Error(`Unsupported durable worker option: ${flag}`);\n }\n const value = argv[++i];\n if (value === undefined || value.startsWith(\"--\")) throw new Error(`Missing value for ${flag}`);\n switch (flag) {\n case \"--mode\": if (value !== \"rpc\") throw new Error(\"The durable worker only supports RPC mode\"); break;\n case \"--durable-directory\": options.directory = path.resolve(cwd, value); break;\n case \"--durable-run-id\": options.runId = value.trim(); break;\n case \"--session\": options.sessionFile = path.resolve(cwd, value); break;\n case \"--model\": options.model = value; break;\n case \"--provider\": options.provider = value; break;\n case \"--thinking\":\n if (![\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"].includes(value)) throw new Error(`Invalid thinking level: ${value}`);\n options.thinking = value as ThinkingLevel;\n break;\n case \"--tools\": options.tools = value.split(\",\").map(tool => tool.trim()).filter(Boolean); break;\n case \"-e\": case \"--extension\": options.extensions.push(value.startsWith(\"builtin:\") ? value : path.resolve(cwd, value)); break;\n case \"--append-system-prompt\": prompts.push(value); break;\n }\n }\n if (!options.directory || !options.runId) throw new Error(\"Durable workers require --durable-directory and --durable-run-id\");\n if (options.tools && options.noTools) throw new Error(\"--tools and --no-tools are mutually exclusive\");\n options.appendSystemPrompt = prompts.join(\"\\n\\n\");\n return options;\n}\n"],
|
|
5
|
+
"mappings": ";;;AACA,SAAS,qBAAqB;;;ACD9B,OAAO,UAAU;AAkBV,SAAS,0BAA0B,MAAyB,MAAM,QAAQ,IAAI,GAAyB;AAC5G,QAAM,UAAgC;AAAA,IACpC,WAAW;AAAA,IAAI,OAAO;AAAA,IAAI,YAAY,CAAC;AAAA,IAAG,cAAc;AAAA,IAAO,oBAAoB;AAAA,EACrF;AACA,QAAM,UAAoB,CAAC;AAC3B,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,OAAO,KAAK,CAAC;AACnB,QAAI,SAAS,eAAgB;AAC7B,QAAI,SAAS,mBAAmB;AAAE,cAAQ,eAAe;AAAM;AAAA,IAAU;AACzE,QAAI,SAAS,cAAc;AAAE,cAAQ,UAAU;AAAO;AAAA,IAAU;AAChE,QAAI,CAAC,CAAC,UAAU,uBAAuB,oBAAoB,aAAa,WAAW,cAAc,cAAc,WAAW,MAAM,eAAe,wBAAwB,EAAE,SAAS,IAAI,GAAG;AACvL,YAAM,IAAI,MAAM,sCAAsC,IAAI,EAAE;AAAA,IAC9D;AACA,UAAM,QAAQ,KAAK,EAAE,CAAC;AACtB,QAAI,UAAU,UAAa,MAAM,WAAW,IAAI,EAAG,OAAM,IAAI,MAAM,qBAAqB,IAAI,EAAE;AAC9F,YAAQ,MAAM;AAAA,MACZ,KAAK;AAAU,YAAI,UAAU,MAAO,OAAM,IAAI,MAAM,2CAA2C;AAAG;AAAA,MAClG,KAAK;AAAuB,gBAAQ,YAAY,KAAK,QAAQ,KAAK,KAAK;AAAG;AAAA,MAC1E,KAAK;AAAoB,gBAAQ,QAAQ,MAAM,KAAK;AAAG;AAAA,MACvD,KAAK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YAAY,IAAI,CAAC;AAAA,MACzH;AACA,UAAI,MAAM,KAAK,UAAQ,cAAc,QAAQ,UAAU,WAAW,GAAG,IAAI,GAAG,CAAC,GAAG;AAC9E,eAAO,YAAY,WAAW,EAAE,GAAG,SAAS,WAAW,SAAS,CAAC;AAAA,MACnE;AACA,aAAO,YAAY,WAAW,OAAO;AAAA,IACvC;AAAA,EACF,CAAC;AACD,QAAM,EAAE,iBAAiB,IAAI,MAAM,OAAO,kBAAkB;AAC5D,QAAM,iBAAiB,OAAO;AAChC,SAAS,OAAO;AACd,UAAQ,OAAO,MAAM,6BAA6B,iBAAiB,QAAQ,MAAM,SAAS,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,CAAI;AAC3H,UAAQ,WAAW;AACrB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { FABRIC_MANAGED_HOST_VERSION } from "./extension.js";
|
|
2
2
|
export type { FabricManagedHostOptions } from "./managed-host.js";
|
|
3
|
-
declare const _default: (pi: import("
|
|
3
|
+
declare const _default: (pi: import("pi-fabric-worker-sdk").ExtensionAPI, options?: {
|
|
4
4
|
managedHost?: import("./managed-host.js").FabricManagedHostOptions;
|
|
5
5
|
}) => Promise<void>;
|
|
6
6
|
export default _default;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { FABRIC_MANAGED_HOST_VERSION } from "./extension.js";
|
|
2
2
|
export type { FabricManagedHostOptions } from "./managed-host.js";
|
|
3
|
-
declare const _default: (pi: import("
|
|
3
|
+
declare const _default: (pi: import("pi-fabric-worker-sdk").ExtensionAPI, options?: {
|
|
4
4
|
managedHost?: import("./managed-host.js").FabricManagedHostOptions;
|
|
5
5
|
}) => Promise<void>;
|
|
6
6
|
export default _default;
|
package/docs/durable-pi.md
CHANGED
|
@@ -6,6 +6,13 @@ Harness. Pinned worker dependencies ship with Fabric; registration and idle hook
|
|
|
6
6
|
do not load the worker or engines.
|
|
7
7
|
No manual setup is required. Main's outer Pi session is unchanged.
|
|
8
8
|
|
|
9
|
+
The subprocess owns a pinned SDK installed as `pi-fabric-worker-sdk` (an npm
|
|
10
|
+
alias), because Pi-managed installs deliberately omit host-provided peers.
|
|
11
|
+
Only the durable worker maps Pi imports to that SDK and its dependencies; the
|
|
12
|
+
extension continues to use Main's host modules. If a partial/older installation
|
|
13
|
+
reports a missing worker SDK, reinstall or update Fabric to restore its runtime
|
|
14
|
+
dependencies. Installing Pi peers manually is not required.
|
|
15
|
+
|
|
9
16
|
Set `agents.runner: "pi"` (or `runner: "pi"` per request) for the previous Pi CLI
|
|
10
17
|
worker. Existing explicit configurations and stored actor runners are not
|
|
11
18
|
rewritten. Pi JSONL remains the history interchange format. Custom Pi CLI wrappers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-fabric",
|
|
3
|
-
"version": "0.109.
|
|
3
|
+
"version": "0.109.1",
|
|
4
4
|
"description": "A programmable tool and agent runtime for Pi",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"test:jev:dist": "node scripts/smoke-jev.mjs",
|
|
76
76
|
"test:changed": "node scripts/test-affected.mjs",
|
|
77
77
|
"test:affected": "node scripts/test-affected.mjs --base $PI_TEST_BASE",
|
|
78
|
-
"test:smoke": "vitest run tests/optional-preview-startup.test.ts tests/script-runtime.test.ts tests/pi-binary.test.ts tests/host-compatibility.test.ts tests/output-budget.test.ts tests/actor-mesh-monitor.test.ts tests/handoff.test.ts tests/config-migrations.test.ts tests/monty-payload-preflight.test.ts tests/bundled-binary-spawn.test.ts tests/worker-installation.test.ts tests/conversation-native-reader-suspension.test.ts",
|
|
78
|
+
"test:smoke": "vitest run tests/optional-preview-startup.test.ts tests/script-runtime.test.ts tests/pi-binary.test.ts tests/host-compatibility.test.ts tests/output-budget.test.ts tests/actor-mesh-monitor.test.ts tests/handoff.test.ts tests/config-migrations.test.ts tests/monty-payload-preflight.test.ts tests/bundled-binary-spawn.test.ts tests/worker-installation.test.ts tests/durable-worker-installation.test.ts tests/conversation-native-reader-suspension.test.ts",
|
|
79
79
|
"test:related": "vitest related --run",
|
|
80
80
|
"check:fast": "bun run typecheck && bun run test:changed",
|
|
81
81
|
"certify:context": "bun run build && node scripts/certify-context.mjs",
|
|
@@ -144,6 +144,7 @@
|
|
|
144
144
|
"cross-spawn": "^7.0.6",
|
|
145
145
|
"diff": "^9.0.0",
|
|
146
146
|
"mcporter": "^0.12.3",
|
|
147
|
+
"pi-fabric-worker-sdk": "npm:@earendil-works/pi-coding-agent@1.0.0",
|
|
147
148
|
"quickjs-emscripten-core": "^0.32.0",
|
|
148
149
|
"shiki": "4.4.3",
|
|
149
150
|
"typescript": "^6.0.3",
|