psyclaw 0.25.2 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -60
- package/{apps → dist/apps}/panel/index.html +50 -28
- package/dist/src/adapters/pi/extension.d.ts +19 -0
- package/dist/src/adapters/pi/extension.js +735 -0
- package/dist/src/adapters/pi/extension.js.map +1 -0
- package/dist/src/adapters/pi/model.d.ts +72 -0
- package/dist/src/adapters/pi/model.js +152 -0
- package/dist/src/adapters/pi/model.js.map +1 -0
- package/dist/src/adapters/pi/resources.d.ts +23 -0
- package/dist/src/adapters/pi/resources.js +54 -0
- package/dist/src/adapters/pi/resources.js.map +1 -0
- package/dist/src/adapters/pi/rpc.d.ts +58 -0
- package/dist/src/adapters/pi/rpc.js +253 -0
- package/dist/src/adapters/pi/rpc.js.map +1 -0
- package/dist/src/adapters/pi/session.d.ts +30 -0
- package/dist/src/adapters/pi/session.js +64 -0
- package/dist/src/adapters/pi/session.js.map +1 -0
- package/dist/src/agents/catalog.d.ts +30 -0
- package/dist/src/agents/catalog.js +118 -0
- package/dist/src/agents/catalog.js.map +1 -0
- package/dist/src/agents/discover.d.ts +28 -0
- package/dist/src/agents/discover.js +127 -0
- package/dist/src/agents/discover.js.map +1 -0
- package/dist/src/agents/import.d.ts +67 -0
- package/dist/src/agents/import.js +789 -0
- package/dist/src/agents/import.js.map +1 -0
- package/dist/src/analysis/hooks.d.ts +81 -0
- package/dist/src/analysis/hooks.js +139 -0
- package/dist/src/analysis/hooks.js.map +1 -0
- package/dist/src/analysis/pre-registration.d.ts +18 -0
- package/dist/src/analysis/pre-registration.js +86 -0
- package/dist/src/analysis/pre-registration.js.map +1 -0
- package/dist/src/branding.d.ts +44 -0
- package/dist/src/branding.js +128 -0
- package/dist/src/branding.js.map +1 -0
- package/dist/src/chat.d.ts +16 -0
- package/dist/src/chat.js +95 -0
- package/dist/src/chat.js.map +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +316 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/core/citations.d.ts +44 -0
- package/dist/src/core/citations.js +48 -0
- package/dist/src/core/citations.js.map +1 -0
- package/dist/src/core/contracts.d.ts +119 -0
- package/dist/src/core/contracts.js +2 -0
- package/dist/src/core/contracts.js.map +1 -0
- package/dist/src/core/docx.d.ts +11 -0
- package/dist/src/core/docx.js +46 -0
- package/dist/src/core/docx.js.map +1 -0
- package/dist/src/core/doi.d.ts +41 -0
- package/dist/src/core/doi.js +82 -0
- package/dist/src/core/doi.js.map +1 -0
- package/dist/src/core/evidence-policy.d.ts +24 -0
- package/dist/src/core/evidence-policy.js +308 -0
- package/dist/src/core/evidence-policy.js.map +1 -0
- package/dist/src/core/filekind.d.ts +15 -0
- package/dist/src/core/filekind.js +82 -0
- package/dist/src/core/filekind.js.map +1 -0
- package/dist/src/core/hash.d.ts +2 -0
- package/dist/src/core/hash.js +17 -0
- package/dist/src/core/hash.js.map +1 -0
- package/dist/src/core/pricing.d.ts +38 -0
- package/dist/src/core/pricing.js +110 -0
- package/dist/src/core/pricing.js.map +1 -0
- package/dist/src/core/redact.d.ts +12 -0
- package/dist/src/core/redact.js +48 -0
- package/dist/src/core/redact.js.map +1 -0
- package/dist/src/core/references.d.ts +55 -0
- package/dist/src/core/references.js +102 -0
- package/dist/src/core/references.js.map +1 -0
- package/dist/src/core/schemas.d.ts +162 -0
- package/dist/src/core/schemas.js +160 -0
- package/dist/src/core/schemas.js.map +1 -0
- package/dist/src/extension.d.ts +1 -0
- package/dist/src/extension.js +2 -0
- package/dist/src/extension.js.map +1 -0
- package/dist/src/index.d.ts +72 -0
- package/dist/src/index.js +73 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/install/installer.d.ts +147 -0
- package/dist/src/install/installer.js +721 -0
- package/dist/src/install/installer.js.map +1 -0
- package/dist/src/integrations/contracts.d.ts +35 -0
- package/dist/src/integrations/contracts.js +27 -0
- package/dist/src/integrations/contracts.js.map +1 -0
- package/dist/src/integrations/mcp.d.ts +155 -0
- package/dist/src/integrations/mcp.js +826 -0
- package/dist/src/integrations/mcp.js.map +1 -0
- package/dist/src/knowledge-map/contracts.d.ts +20 -0
- package/dist/src/knowledge-map/contracts.js +2 -0
- package/dist/src/knowledge-map/contracts.js.map +1 -0
- package/dist/src/knowledge-map/index.d.ts +4 -0
- package/dist/src/knowledge-map/index.js +39 -0
- package/dist/src/knowledge-map/index.js.map +1 -0
- package/dist/src/literature/contracts.d.ts +106 -0
- package/dist/src/literature/contracts.js +2 -0
- package/dist/src/literature/contracts.js.map +1 -0
- package/dist/src/literature/fulltext.d.ts +7 -0
- package/dist/src/literature/fulltext.js +24 -0
- package/dist/src/literature/fulltext.js.map +1 -0
- package/dist/src/literature/knowledge-map.d.ts +2 -0
- package/dist/src/literature/knowledge-map.js +20 -0
- package/dist/src/literature/knowledge-map.js.map +1 -0
- package/dist/src/literature/ledger.d.ts +3 -0
- package/dist/src/literature/ledger.js +17 -0
- package/dist/src/literature/ledger.js.map +1 -0
- package/dist/src/literature/metadata.d.ts +6 -0
- package/dist/src/literature/metadata.js +32 -0
- package/dist/src/literature/metadata.js.map +1 -0
- package/dist/src/memory/store.d.ts +22 -0
- package/dist/src/memory/store.js +73 -0
- package/dist/src/memory/store.js.map +1 -0
- package/dist/src/orchestration/contracts.d.ts +61 -0
- package/dist/src/orchestration/contracts.js +2 -0
- package/dist/src/orchestration/contracts.js.map +1 -0
- package/dist/src/orchestration/pi-executor.d.ts +28 -0
- package/dist/src/orchestration/pi-executor.js +169 -0
- package/dist/src/orchestration/pi-executor.js.map +1 -0
- package/dist/src/orchestration/runner.d.ts +196 -0
- package/dist/src/orchestration/runner.js +991 -0
- package/dist/src/orchestration/runner.js.map +1 -0
- package/dist/src/orchestration/scheduler.d.ts +8 -0
- package/dist/src/orchestration/scheduler.js +335 -0
- package/dist/src/orchestration/scheduler.js.map +1 -0
- package/dist/src/panel/events.d.ts +20 -0
- package/dist/src/panel/events.js +93 -0
- package/dist/src/panel/events.js.map +1 -0
- package/dist/src/panel/extension.d.ts +8 -0
- package/dist/src/panel/extension.js +115 -0
- package/dist/src/panel/extension.js.map +1 -0
- package/dist/src/panel/literature-map.d.ts +26 -0
- package/dist/src/panel/literature-map.js +34 -0
- package/dist/src/panel/literature-map.js.map +1 -0
- package/dist/src/panel/projection.d.ts +51 -0
- package/dist/src/panel/projection.js +288 -0
- package/dist/src/panel/projection.js.map +1 -0
- package/dist/src/panel/server.d.ts +46 -0
- package/dist/src/panel/server.js +1610 -0
- package/dist/src/panel/server.js.map +1 -0
- package/dist/src/panel/usage.d.ts +53 -0
- package/dist/src/panel/usage.js +150 -0
- package/dist/src/panel/usage.js.map +1 -0
- package/dist/src/project/bootstrap.d.ts +10 -0
- package/dist/src/project/bootstrap.js +83 -0
- package/dist/src/project/bootstrap.js.map +1 -0
- package/dist/src/project/hitl.d.ts +12 -0
- package/dist/src/project/hitl.js +43 -0
- package/dist/src/project/hitl.js.map +1 -0
- package/dist/src/project/jsonl.d.ts +16 -0
- package/dist/src/project/jsonl.js +93 -0
- package/dist/src/project/jsonl.js.map +1 -0
- package/dist/src/project/manuscript.d.ts +21 -0
- package/dist/src/project/manuscript.js +74 -0
- package/dist/src/project/manuscript.js.map +1 -0
- package/dist/src/project/paths.d.ts +38 -0
- package/dist/src/project/paths.js +166 -0
- package/dist/src/project/paths.js.map +1 -0
- package/dist/src/project/versions.d.ts +10 -0
- package/dist/src/project/versions.js +14 -0
- package/dist/src/project/versions.js.map +1 -0
- package/dist/src/psyclaw-theme.d.ts +88 -0
- package/dist/src/psyclaw-theme.js +89 -0
- package/dist/src/psyclaw-theme.js.map +1 -0
- package/dist/src/research/brief.d.ts +11 -0
- package/dist/src/research/brief.js +81 -0
- package/dist/src/research/brief.js.map +1 -0
- package/dist/src/research/ledger.d.ts +12 -0
- package/dist/src/research/ledger.js +43 -0
- package/dist/src/research/ledger.js.map +1 -0
- package/dist/src/run.d.ts +20 -0
- package/dist/src/run.js +34 -0
- package/dist/src/run.js.map +1 -0
- package/dist/src/setup.d.ts +54 -0
- package/dist/src/setup.js +221 -0
- package/dist/src/setup.js.map +1 -0
- package/dist/src/skills/contracts.d.ts +105 -0
- package/dist/src/skills/contracts.js +3 -0
- package/dist/src/skills/contracts.js.map +1 -0
- package/dist/src/skills/preflight.d.ts +10 -0
- package/dist/src/skills/preflight.js +39 -0
- package/dist/src/skills/preflight.js.map +1 -0
- package/dist/src/skills/registry.d.ts +28 -0
- package/dist/src/skills/registry.js +540 -0
- package/dist/src/skills/registry.js.map +1 -0
- package/dist/src/style/artifact.d.ts +6 -0
- package/dist/src/style/artifact.js +61 -0
- package/dist/src/style/artifact.js.map +1 -0
- package/dist/src/style/cli-ui.d.ts +41 -0
- package/dist/src/style/cli-ui.js +119 -0
- package/dist/src/style/cli-ui.js.map +1 -0
- package/dist/src/style/contracts.d.ts +34 -0
- package/dist/src/style/contracts.js +2 -0
- package/dist/src/style/contracts.js.map +1 -0
- package/dist/src/style/registry.d.ts +16 -0
- package/dist/src/style/registry.js +50 -0
- package/dist/src/style/registry.js.map +1 -0
- package/dist/src/trust/manifest.d.ts +42 -0
- package/dist/src/trust/manifest.js +53 -0
- package/dist/src/trust/manifest.js.map +1 -0
- package/dist/src/trust/sbom.d.ts +54 -0
- package/dist/src/trust/sbom.js +77 -0
- package/dist/src/trust/sbom.js.map +1 -0
- package/dist/src/tui/app.d.ts +3 -0
- package/dist/src/tui/app.js +103 -0
- package/dist/src/tui/app.js.map +1 -0
- package/dist/src/tui/model.d.ts +13 -0
- package/dist/src/tui/model.js +25 -0
- package/dist/src/tui/model.js.map +1 -0
- package/dist/src/updates/check.d.ts +43 -0
- package/dist/src/updates/check.js +68 -0
- package/dist/src/updates/check.js.map +1 -0
- package/dist/src/updates/manifest.d.ts +19 -0
- package/dist/src/updates/manifest.js +58 -0
- package/dist/src/updates/manifest.js.map +1 -0
- package/dist/src/updates/registry.d.ts +21 -0
- package/dist/src/updates/registry.js +82 -0
- package/dist/src/updates/registry.js.map +1 -0
- package/dist/src/updates/skills.d.ts +15 -0
- package/dist/src/updates/skills.js +39 -0
- package/dist/src/updates/skills.js.map +1 -0
- package/dist/src/updates/status.d.ts +7 -0
- package/dist/src/updates/status.js +37 -0
- package/dist/src/updates/status.js.map +1 -0
- package/dist/src/updates/update.d.ts +43 -0
- package/dist/src/updates/update.js +128 -0
- package/dist/src/updates/update.js.map +1 -0
- package/dist/src/wizard.d.ts +7 -0
- package/dist/src/wizard.js +90 -0
- package/dist/src/wizard.js.map +1 -0
- package/dist/src/workflows/analysis-delegation.d.ts +3 -0
- package/dist/src/workflows/analysis-delegation.js +96 -0
- package/dist/src/workflows/analysis-delegation.js.map +1 -0
- package/dist/src/workflows/expert-review-runner.d.ts +29 -0
- package/dist/src/workflows/expert-review-runner.js +35 -0
- package/dist/src/workflows/expert-review-runner.js.map +1 -0
- package/dist/src/workflows/expert-review.d.ts +140 -0
- package/dist/src/workflows/expert-review.js +111 -0
- package/dist/src/workflows/expert-review.js.map +1 -0
- package/dist/src/workflows/institutional-fulltext.d.ts +16 -0
- package/dist/src/workflows/institutional-fulltext.js +110 -0
- package/dist/src/workflows/institutional-fulltext.js.map +1 -0
- package/dist/src/workflows/literature-review.d.ts +3 -0
- package/dist/src/workflows/literature-review.js +76 -0
- package/dist/src/workflows/literature-review.js.map +1 -0
- package/dist/src/workflows/meta-analysis.d.ts +38 -0
- package/dist/src/workflows/meta-analysis.js +185 -0
- package/dist/src/workflows/meta-analysis.js.map +1 -0
- package/dist/src/workflows/publish.d.ts +51 -0
- package/dist/src/workflows/publish.js +153 -0
- package/dist/src/workflows/publish.js.map +1 -0
- package/dist/src/workflows/spec.d.ts +51 -0
- package/dist/src/workflows/spec.js +157 -0
- package/dist/src/workflows/spec.js.map +1 -0
- package/dist/src/workflows/style-contract.d.ts +24 -0
- package/dist/src/workflows/style-contract.js +23 -0
- package/dist/src/workflows/style-contract.js.map +1 -0
- package/dist/src/workflows/writing-review.d.ts +15 -0
- package/dist/src/workflows/writing-review.js +82 -0
- package/dist/src/workflows/writing-review.js.map +1 -0
- package/package.json +20 -8
- package/scripts/rebrand-pi.mjs +3 -3
- package/scripts/__pycache__/build_dist.cpython-314.pyc +0 -0
- package/scripts/__pycache__/build_whitepaper_docx.cpython-314.pyc +0 -0
- package/scripts/build_preprint_docx.py +0 -729
- package/scripts/build_preprint_figures.py +0 -238
- package/scripts/build_three_line_table_fixture.py +0 -56
- package/scripts/build_whitepaper_docx.py +0 -768
- package/scripts/check-branding.mjs +0 -159
- package/scripts/copy-panel.mjs +0 -11
- package/scripts/verify_docx.py +0 -41
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { BoundedOrchestrator, } from "./runner.js";
|
|
2
|
+
import { PiRpcClient } from "../adapters/pi/rpc.js";
|
|
3
|
+
function blockedReport(task, context, summary) {
|
|
4
|
+
return {
|
|
5
|
+
schemaVersion: "psyclaw/worker-report/v1",
|
|
6
|
+
taskId: task.id,
|
|
7
|
+
dispatchId: context.dispatchId,
|
|
8
|
+
outcome: "blocked",
|
|
9
|
+
summary,
|
|
10
|
+
filesModified: [],
|
|
11
|
+
verification: [],
|
|
12
|
+
blockers: [summary],
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function textFromMessage(message) {
|
|
16
|
+
if (!message || typeof message !== "object")
|
|
17
|
+
return undefined;
|
|
18
|
+
const content = message.content;
|
|
19
|
+
if (!Array.isArray(content))
|
|
20
|
+
return undefined;
|
|
21
|
+
const text = content
|
|
22
|
+
.filter((part) => Boolean(part && typeof part === "object" && part.type === "text" && typeof part.text === "string"))
|
|
23
|
+
.map((part) => part.text)
|
|
24
|
+
.join("");
|
|
25
|
+
return text || undefined;
|
|
26
|
+
}
|
|
27
|
+
function extractJson(text) {
|
|
28
|
+
const trimmed = text.trim();
|
|
29
|
+
const fenced = trimmed.match(/```(?:json)?\s*([\s\S]*?)\s*```/i)?.[1];
|
|
30
|
+
const candidate = (fenced ?? trimmed).trim();
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(candidate);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
const start = candidate.indexOf("{");
|
|
36
|
+
const end = candidate.lastIndexOf("}");
|
|
37
|
+
if (start < 0 || end <= start)
|
|
38
|
+
return undefined;
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse(candidate.slice(start, end + 1));
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function parseWorkerReport(value, task, context) {
|
|
48
|
+
if (!value || typeof value !== "object")
|
|
49
|
+
return undefined;
|
|
50
|
+
const record = value;
|
|
51
|
+
if (record.schemaVersion !== "psyclaw/worker-report/v1")
|
|
52
|
+
return undefined;
|
|
53
|
+
if (record.taskId !== task.id || record.dispatchId !== context.dispatchId)
|
|
54
|
+
return undefined;
|
|
55
|
+
if (record.outcome !== "succeeded" && record.outcome !== "blocked" && record.outcome !== "failed")
|
|
56
|
+
return undefined;
|
|
57
|
+
if (typeof record.summary !== "string" || record.summary.trim() === "")
|
|
58
|
+
return undefined;
|
|
59
|
+
if (!Array.isArray(record.filesModified) || !record.filesModified.every((item) => typeof item === "string"))
|
|
60
|
+
return undefined;
|
|
61
|
+
if (!Array.isArray(record.blockers) || !record.blockers.every((item) => typeof item === "string"))
|
|
62
|
+
return undefined;
|
|
63
|
+
if (!Array.isArray(record.verification))
|
|
64
|
+
return undefined;
|
|
65
|
+
if (record.filesModified.length > 0)
|
|
66
|
+
return undefined;
|
|
67
|
+
return {
|
|
68
|
+
schemaVersion: "psyclaw/worker-report/v1",
|
|
69
|
+
taskId: task.id,
|
|
70
|
+
dispatchId: context.dispatchId,
|
|
71
|
+
outcome: record.outcome,
|
|
72
|
+
summary: record.summary,
|
|
73
|
+
filesModified: [],
|
|
74
|
+
verification: record.verification.filter((item) => {
|
|
75
|
+
if (!item || typeof item !== "object")
|
|
76
|
+
return false;
|
|
77
|
+
const candidate = item;
|
|
78
|
+
return typeof candidate.command === "string" && candidate.command.trim() !== ""
|
|
79
|
+
&& Number.isInteger(candidate.exitCode) && (candidate.outputDigest === undefined || typeof candidate.outputDigest === "string");
|
|
80
|
+
}),
|
|
81
|
+
blockers: record.blockers,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function lastAssistantText(events) {
|
|
85
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
86
|
+
const event = events[index];
|
|
87
|
+
if (event?.type !== "message_end")
|
|
88
|
+
continue;
|
|
89
|
+
const text = textFromMessage(event.message);
|
|
90
|
+
if (text)
|
|
91
|
+
return text;
|
|
92
|
+
}
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
function taskPrompt(task, context) {
|
|
96
|
+
return [
|
|
97
|
+
"You are a read-only psyclaw research worker.",
|
|
98
|
+
"Do not write, edit, delete, execute shell commands, access network services, or modify credentials.",
|
|
99
|
+
"Inspect only the supplied task inputs and project files with read/grep/find/ls.",
|
|
100
|
+
"At the end return ONLY one JSON object matching this schema:",
|
|
101
|
+
'{"schemaVersion":"psyclaw/worker-report/v1","taskId":"...","dispatchId":"...","outcome":"succeeded|blocked|failed","summary":"...","filesModified":[],"verification":[{"command":"...","exitCode":0}],"blockers":[]}',
|
|
102
|
+
`taskId=${task.id}`,
|
|
103
|
+
`dispatchId=${context.dispatchId}`,
|
|
104
|
+
`objective=${task.objective}`,
|
|
105
|
+
`inputs=${JSON.stringify(task.inputs)}`,
|
|
106
|
+
].join("\n");
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Execute one task in a separate Pi process with extensions, skills, context
|
|
110
|
+
* files and all mutating tools disabled. This is a process boundary, not a
|
|
111
|
+
* complete OS sandbox; deployments needing hostile-code isolation must add a
|
|
112
|
+
* container or equivalent runtime policy.
|
|
113
|
+
*/
|
|
114
|
+
export function createPiReadOnlyExecutor(options) {
|
|
115
|
+
return async (task, context) => {
|
|
116
|
+
const effects = task.allowedEffects ?? ["read"];
|
|
117
|
+
if (effects.some((effect) => effect !== "read")) {
|
|
118
|
+
return { report: blockedReport(task, context, "Pi read-only executor cannot run side-effecting tasks") };
|
|
119
|
+
}
|
|
120
|
+
const client = new PiRpcClient({
|
|
121
|
+
cwd: options.cwd,
|
|
122
|
+
...(options.cliPath === undefined ? {} : { cliPath: options.cliPath }),
|
|
123
|
+
...(options.command === undefined ? {} : { command: options.command }),
|
|
124
|
+
...(options.provider === undefined ? {} : { provider: options.provider }),
|
|
125
|
+
...(options.model === undefined ? {} : { model: options.model }),
|
|
126
|
+
...(options.agentDir === undefined ? {} : { agentDir: options.agentDir }),
|
|
127
|
+
...(options.env === undefined ? {} : { env: options.env }),
|
|
128
|
+
...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
|
|
129
|
+
tools: ["read", "grep", "find", "ls"],
|
|
130
|
+
});
|
|
131
|
+
try {
|
|
132
|
+
await client.start();
|
|
133
|
+
const events = await client.promptAndWait(taskPrompt(task, context), options.timeoutMs);
|
|
134
|
+
const report = parseWorkerReport(extractJson(lastAssistantText(events) ?? ""), task, context);
|
|
135
|
+
if (!report)
|
|
136
|
+
return { report: blockedReport(task, context, "Worker did not return a valid structured report") };
|
|
137
|
+
return { report };
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return { report: blockedReport(task, context, "Pi worker process failed or timed out") };
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
await client.stop();
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export async function runPlanWithPi(plan, options = { cwd: process.cwd() }) {
|
|
148
|
+
const executor = createPiReadOnlyExecutor(options);
|
|
149
|
+
return new BoundedOrchestrator({
|
|
150
|
+
executor,
|
|
151
|
+
root: options.root ?? options.cwd,
|
|
152
|
+
...(options.maxWorkers === undefined ? {} : { maxWorkers: options.maxWorkers }),
|
|
153
|
+
allowWrites: false,
|
|
154
|
+
...(options.pauseRequested === undefined ? {} : { pauseRequested: options.pauseRequested }),
|
|
155
|
+
...(options.onEvent === undefined ? {} : { onEvent: options.onEvent }),
|
|
156
|
+
}).run(plan);
|
|
157
|
+
}
|
|
158
|
+
export async function resumePlanWithPi(plan, options = { cwd: process.cwd() }) {
|
|
159
|
+
const executor = createPiReadOnlyExecutor(options);
|
|
160
|
+
return new BoundedOrchestrator({
|
|
161
|
+
executor,
|
|
162
|
+
root: options.root ?? options.cwd,
|
|
163
|
+
...(options.maxWorkers === undefined ? {} : { maxWorkers: options.maxWorkers }),
|
|
164
|
+
allowWrites: false,
|
|
165
|
+
...(options.pauseRequested === undefined ? {} : { pauseRequested: options.pauseRequested }),
|
|
166
|
+
...(options.onEvent === undefined ? {} : { onEvent: options.onEvent }),
|
|
167
|
+
}).resume(plan);
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=pi-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-executor.js","sourceRoot":"","sources":["../../../src/orchestration/pi-executor.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,GAMpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAqB,MAAM,uBAAuB,CAAC;AAevE,SAAS,aAAa,CAAC,IAAc,EAAE,OAAsB,EAAE,OAAe;IAC5E,OAAO;QACL,aAAa,EAAE,0BAA0B;QACzC,MAAM,EAAE,IAAI,CAAC,EAAE;QACf,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,OAAO,EAAE,SAAS;QAClB,OAAO;QACP,aAAa,EAAE,EAAE;QACjB,YAAY,EAAE,EAAE;QAChB,QAAQ,EAAE,CAAC,OAAO,CAAC;KACpB,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,OAAgB;IACvC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC9D,MAAM,OAAO,GAAI,OAAiC,CAAC,OAAO,CAAC;IAC3D,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AAC;QAC/E,WAAW,EAAE,KAAK;QAClB,GAAG,CAAC,OAAO,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC;QAC3F,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;KACvE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import type { Effect, ToolReceipt } from "../core/contracts.js";
|
|
3
|
+
import type { Plan, TaskNode, WorkerReport } from "./contracts.js";
|
|
4
|
+
/**
|
|
5
|
+
* The planner boundary intentionally has no tool or filesystem capability.
|
|
6
|
+
* A caller gives us an opaque planner result and we only accept a strict Plan.
|
|
7
|
+
*/
|
|
8
|
+
export interface PlannerRequest {
|
|
9
|
+
goal: string;
|
|
10
|
+
paradigm?: string;
|
|
11
|
+
runId?: string;
|
|
12
|
+
}
|
|
13
|
+
export type Planner = (request: PlannerRequest) => unknown | Promise<unknown>;
|
|
14
|
+
export declare const PlanSchema: Type.TObject<{
|
|
15
|
+
schemaVersion: Type.TLiteral<"psyclaw/plan/v1">;
|
|
16
|
+
runId: Type.TString;
|
|
17
|
+
tasks: Type.TArray<Type.TObject<{
|
|
18
|
+
id: Type.TString;
|
|
19
|
+
role: Type.TUnion<[Type.TLiteral<"planner">, Type.TLiteral<"researcher">, Type.TLiteral<"analyst">, Type.TLiteral<"critic">, Type.TLiteral<"writer">, Type.TLiteral<"verifier">]>;
|
|
20
|
+
objective: Type.TString;
|
|
21
|
+
deps: Type.TArray<Type.TString>;
|
|
22
|
+
ownedPaths: Type.TArray<Type.TString>;
|
|
23
|
+
parallelSafe: Type.TBoolean;
|
|
24
|
+
inputs: Type.TArray<Type.TString>;
|
|
25
|
+
outputs: Type.TArray<Type.TString>;
|
|
26
|
+
allowedEffects: Type.TOptional<Type.TArray<Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"write">, Type.TLiteral<"network">, Type.TLiteral<"destructive">]>>>;
|
|
27
|
+
completionContract: Type.TObject<{
|
|
28
|
+
requiredArtifacts: Type.TArray<Type.TString>;
|
|
29
|
+
requiredReceiptEffects: Type.TArray<Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"write">, Type.TLiteral<"network">, Type.TLiteral<"destructive">]>>;
|
|
30
|
+
mustPassGates: Type.TArray<Type.TString>;
|
|
31
|
+
}>;
|
|
32
|
+
}>>;
|
|
33
|
+
budget: Type.TObject<{
|
|
34
|
+
maxTurns: Type.TInteger;
|
|
35
|
+
maxWorkers: Type.TInteger;
|
|
36
|
+
}>;
|
|
37
|
+
horizon: Type.TOptional<Type.TObject<{
|
|
38
|
+
strategy: Type.TLiteral<"hierarchical-plan-act-reflect">;
|
|
39
|
+
maxIterations: Type.TInteger;
|
|
40
|
+
reflectionEvery: Type.TInteger;
|
|
41
|
+
}>>;
|
|
42
|
+
}>;
|
|
43
|
+
export declare class PlanSchemaError extends Error {
|
|
44
|
+
readonly diagnostics: string[];
|
|
45
|
+
constructor(diagnostics: string[]);
|
|
46
|
+
}
|
|
47
|
+
/** Parse and validate the only value a planner is allowed to hand to runtime. */
|
|
48
|
+
export declare function validatePlanSchema(value: unknown): Plan;
|
|
49
|
+
/** Alias used by integrations that call the boundary an "accepted plan". */
|
|
50
|
+
export declare const acceptPlan: typeof validatePlanSchema;
|
|
51
|
+
/** Execute a planner with no ambient tool context, then enforce the Plan schema. */
|
|
52
|
+
export declare function planOnly(planner: Planner, request: PlannerRequest): Promise<Plan>;
|
|
53
|
+
export interface WorkerArtifact {
|
|
54
|
+
path: string;
|
|
55
|
+
sha256?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface WorkerExecutionResult {
|
|
58
|
+
report: WorkerReport;
|
|
59
|
+
artifacts?: (string | WorkerArtifact)[];
|
|
60
|
+
receipts?: ToolReceipt[];
|
|
61
|
+
passedGates?: string[];
|
|
62
|
+
/** Optional revision generated by the coordinator; stale revisions are rejected. */
|
|
63
|
+
specRevision?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface WorkerContext {
|
|
66
|
+
runId: string;
|
|
67
|
+
dispatchId: string;
|
|
68
|
+
attempt: number;
|
|
69
|
+
task: TaskNode;
|
|
70
|
+
/** MVP workers receive this as true and should only inspect inputs. */
|
|
71
|
+
readOnly: boolean;
|
|
72
|
+
signal: AbortSignal;
|
|
73
|
+
}
|
|
74
|
+
export type WorkerExecutor = (task: TaskNode, context: WorkerContext) => WorkerExecutionResult | WorkerReport | Promise<WorkerExecutionResult | WorkerReport>;
|
|
75
|
+
export interface OrchestratorOptions {
|
|
76
|
+
executor: WorkerExecutor;
|
|
77
|
+
/** Project root used for the default checkpoint location. */
|
|
78
|
+
root?: string;
|
|
79
|
+
checkpointPath?: string;
|
|
80
|
+
/** An input fingerprint that must remain stable across resume. */
|
|
81
|
+
inputDigest?: string;
|
|
82
|
+
/** Coordinator revision that must remain stable across resume. */
|
|
83
|
+
specRevision?: string;
|
|
84
|
+
/** Runtime budget; a resume may explicitly raise this after human approval. */
|
|
85
|
+
maxTurns?: number;
|
|
86
|
+
/** Can only lower the plan's worker count; never raises the hard cap of four. */
|
|
87
|
+
maxWorkers?: number;
|
|
88
|
+
/** Explicit human-approved write mode. It is false by default. */
|
|
89
|
+
allowWrites?: boolean;
|
|
90
|
+
/** Grants network effects. `allowWrites` never implies this. */
|
|
91
|
+
allowNetwork?: boolean;
|
|
92
|
+
/** Grants destructive effects. `allowWrites` never implies this. */
|
|
93
|
+
allowDestructive?: boolean;
|
|
94
|
+
now?: () => string;
|
|
95
|
+
onEvent?: (event: RunnerEvent) => void | Promise<void>;
|
|
96
|
+
/** Cooperative pause hook checked between task batches. */
|
|
97
|
+
pauseRequested?: () => boolean | Promise<boolean>;
|
|
98
|
+
}
|
|
99
|
+
export interface RunnerEvent {
|
|
100
|
+
type: "planned" | "started" | "completed" | "blocked" | "checkpoint";
|
|
101
|
+
runId: string;
|
|
102
|
+
at: string;
|
|
103
|
+
taskId?: string;
|
|
104
|
+
dispatchId?: string;
|
|
105
|
+
message?: string;
|
|
106
|
+
}
|
|
107
|
+
export type TaskRunStatus = "pending" | "running" | "succeeded" | "failed" | "blocked";
|
|
108
|
+
export interface TaskCheckpoint {
|
|
109
|
+
status: TaskRunStatus;
|
|
110
|
+
dispatchId?: string;
|
|
111
|
+
attempt: number;
|
|
112
|
+
report?: WorkerReport;
|
|
113
|
+
artifacts: string[];
|
|
114
|
+
artifactRecords?: WorkerArtifact[];
|
|
115
|
+
receipts: ToolReceipt[];
|
|
116
|
+
passedGates: string[];
|
|
117
|
+
}
|
|
118
|
+
export interface RunnerCheckpoint {
|
|
119
|
+
schemaVersion: "psyclaw/orchestrator-checkpoint/v1";
|
|
120
|
+
runId: string;
|
|
121
|
+
planHash: string;
|
|
122
|
+
inputDigest?: string;
|
|
123
|
+
specRevision?: string;
|
|
124
|
+
budgetLimit: number;
|
|
125
|
+
budgetUsed: number;
|
|
126
|
+
tasks: Record<string, TaskCheckpoint>;
|
|
127
|
+
writtenPaths: string[];
|
|
128
|
+
updatedAt: string;
|
|
129
|
+
}
|
|
130
|
+
export interface OrchestrationResult {
|
|
131
|
+
runId: string;
|
|
132
|
+
status: "completed" | "paused" | "blocked";
|
|
133
|
+
planHash: string;
|
|
134
|
+
budgetUsed: number;
|
|
135
|
+
checkpoint?: RunnerCheckpoint;
|
|
136
|
+
reports: WorkerReport[];
|
|
137
|
+
diagnostics: string[];
|
|
138
|
+
}
|
|
139
|
+
export interface NormalizedWorkerResult {
|
|
140
|
+
report: WorkerReport;
|
|
141
|
+
artifacts: string[];
|
|
142
|
+
artifactRecords?: WorkerArtifact[];
|
|
143
|
+
artifactErrors?: string[];
|
|
144
|
+
receipts: ToolReceipt[];
|
|
145
|
+
passedGates: string[];
|
|
146
|
+
specRevision?: string;
|
|
147
|
+
schemaValid: boolean;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* A deliberately small coordinator. It owns scheduling and acceptance, while
|
|
151
|
+
* the executor owns the actual Pi/skill/MCP call. No model output can mutate
|
|
152
|
+
* task state without passing the checks below.
|
|
153
|
+
*/
|
|
154
|
+
export declare class BoundedOrchestrator {
|
|
155
|
+
private readonly options;
|
|
156
|
+
private checkpointWrite;
|
|
157
|
+
constructor(options: OrchestratorOptions);
|
|
158
|
+
run(planValue: unknown): Promise<OrchestrationResult>;
|
|
159
|
+
resume(planValue: unknown): Promise<OrchestrationResult>;
|
|
160
|
+
private execute;
|
|
161
|
+
private dispatch;
|
|
162
|
+
/** Persist failure experience as a pending lesson; human approval promotes it. */
|
|
163
|
+
private draftReflection;
|
|
164
|
+
private checkpointPath;
|
|
165
|
+
private allowedEffects;
|
|
166
|
+
private taskAllowsWrite;
|
|
167
|
+
private taskIsReadOnly;
|
|
168
|
+
private persist;
|
|
169
|
+
private markBlocked;
|
|
170
|
+
private emit;
|
|
171
|
+
private timestamp;
|
|
172
|
+
private assertCheckpointPath;
|
|
173
|
+
private blocked;
|
|
174
|
+
private blockedWithoutPlan;
|
|
175
|
+
private result;
|
|
176
|
+
}
|
|
177
|
+
/** Alias kept short for callers that do not need the implementation name. */
|
|
178
|
+
export declare const Orchestrator: typeof BoundedOrchestrator;
|
|
179
|
+
export declare function runPlan(plan: unknown, options: OrchestratorOptions): Promise<OrchestrationResult>;
|
|
180
|
+
export declare function resumePlan(plan: unknown, options: OrchestratorOptions): Promise<OrchestrationResult>;
|
|
181
|
+
export interface CompletionAcceptance {
|
|
182
|
+
ok: boolean;
|
|
183
|
+
reasons: string[];
|
|
184
|
+
}
|
|
185
|
+
export declare function verifyWorkerCompletion(task: TaskNode, result: NormalizedWorkerResult | WorkerExecutionResult, policy?: {
|
|
186
|
+
readOnly: boolean;
|
|
187
|
+
writtenPaths?: readonly string[];
|
|
188
|
+
artifactRoot?: string;
|
|
189
|
+
allowedEffects?: ReadonlySet<Effect>;
|
|
190
|
+
seenIdempotencyKeys?: readonly string[];
|
|
191
|
+
expectedRunId?: string;
|
|
192
|
+
expectedTaskId?: string;
|
|
193
|
+
expectedDispatchId?: string;
|
|
194
|
+
expectedSpecRevision?: string;
|
|
195
|
+
reservedPaths?: readonly string[];
|
|
196
|
+
}): CompletionAcceptance;
|