blun-king-cli 9.1.643 → 9.1.645
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/CHANGELOG.md +19 -123
- package/LIESMICH.txt +17 -45
- package/README.md +15 -76
- package/RELEASE-9.1.645.md +29 -0
- package/bin/blun.js +3 -3
- package/bin/king.js +3 -3
- package/bin/launcher-mode.js +125 -126
- package/bin/launcher-runtime.js +603 -616
- package/bin/plugin-bootstrap.js +339 -405
- package/bin/rename-private-staging.cjs +2 -2
- package/bin/retired-bundled-plugins.cjs +84 -0
- package/bin/startup-security-host.cjs +105 -0
- package/bin/startup-security.cjs +9 -105
- package/bin/startup-warning-policy.cjs +22 -0
- package/bin/update-lease-installer.cjs +125 -0
- package/bin/update-lease-sockets.cjs +228 -0
- package/bin/update-lease.js +22 -327
- package/bin/verify-bundled-agent-sources.cjs +2 -4
- package/blun.mjs +77 -180
- package/bundled-agent-sources.json +1 -552
- package/package.json +3 -6
- package/tool-liveness642/receipt.json +1 -1
- package/worker-host.mjs +62 -120
- package/agent-spine-plugin/.claude-plugin/marketplace.json +0 -20
- package/agent-spine-plugin/.claude-plugin/plugin.json +0 -14
- package/agent-spine-plugin/.codex-plugin/plugin.json +0 -47
- package/agent-spine-plugin/.mcp.json +0 -8
- package/agent-spine-plugin/CHANGELOG.md +0 -1614
- package/agent-spine-plugin/LICENSE +0 -186
- package/agent-spine-plugin/README.md +0 -432
- package/agent-spine-plugin/assets/agentspine-banner.svg +0 -32
- package/agent-spine-plugin/bin/agentspine-mcp.js +0 -4
- package/agent-spine-plugin/bin/agentspine.js +0 -7
- package/agent-spine-plugin/blun.plugin.json +0 -68
- package/agent-spine-plugin/docs/acceptance.md +0 -61
- package/agent-spine-plugin/docs/artifact-evaluation.md +0 -93
- package/agent-spine-plugin/docs/host-integration.md +0 -193
- package/agent-spine-plugin/docs/preflight-recall.md +0 -71
- package/agent-spine-plugin/docs/preservation-contract.md +0 -53
- package/agent-spine-plugin/docs/quality-gates.md +0 -50
- package/agent-spine-plugin/docs/session-timeline.md +0 -112
- package/agent-spine-plugin/docs/source-roots.md +0 -113
- package/agent-spine-plugin/docs/world-model.md +0 -119
- package/agent-spine-plugin/hooks/codex.json +0 -47
- package/agent-spine-plugin/hooks/hooks.json +0 -106
- package/agent-spine-plugin/hooks/version.json +0 -5
- package/agent-spine-plugin/package.json +0 -77
- package/agent-spine-plugin/scripts/check-codex-install.js +0 -226
- package/agent-spine-plugin/scripts/check-hosts.js +0 -208
- package/agent-spine-plugin/scripts/check-install-hook.js +0 -227
- package/agent-spine-plugin/scripts/check-install-selfstarter.js +0 -154
- package/agent-spine-plugin/scripts/check-install.js +0 -478
- package/agent-spine-plugin/scripts/check-line-budget.js +0 -58
- package/agent-spine-plugin/scripts/check-syntax.js +0 -29
- package/agent-spine-plugin/scripts/github-actions.js +0 -11
- package/agent-spine-plugin/scripts/hermetic-process.js +0 -191
- package/agent-spine-plugin/scripts/release-check.js +0 -150
- package/agent-spine-plugin/scripts/run-acceptance.js +0 -19
- package/agent-spine-plugin/scripts/run-checks.js +0 -50
- package/agent-spine-plugin/scripts/run-tests-hermetic.js +0 -112
- package/agent-spine-plugin/skills/agent-spine/SKILL.md +0 -99
- package/agent-spine-plugin/spine-example/1-identity.md +0 -12
- package/agent-spine-plugin/spine-example/2-voice.md +0 -6
- package/agent-spine-plugin/spine-example/3-conduct.md +0 -8
- package/agent-spine-plugin/spine-example/4-history.md +0 -4
- package/agent-spine-plugin/src/cli-agent.js +0 -315
- package/agent-spine-plugin/src/cli-attention.js +0 -95
- package/agent-spine-plugin/src/cli-autonomy.js +0 -36
- package/agent-spine-plugin/src/cli-common.js +0 -71
- package/agent-spine-plugin/src/cli-continuity.js +0 -116
- package/agent-spine-plugin/src/cli-core.js +0 -128
- package/agent-spine-plugin/src/cli-diagnostics.js +0 -291
- package/agent-spine-plugin/src/cli-host.js +0 -21
- package/agent-spine-plugin/src/cli-learning.js +0 -320
- package/agent-spine-plugin/src/cli-premortem.js +0 -16
- package/agent-spine-plugin/src/cli-sharing.js +0 -230
- package/agent-spine-plugin/src/cli.js +0 -181
- package/agent-spine-plugin/src/codex-reader-launcher.js +0 -182
- package/agent-spine-plugin/src/hook.js +0 -500
- package/agent-spine-plugin/src/index.js +0 -108
- package/agent-spine-plugin/src/lib/acceptance.js +0 -435
- package/agent-spine-plugin/src/lib/action-lesson-recall.js +0 -118
- package/agent-spine-plugin/src/lib/attention-context.js +0 -167
- package/agent-spine-plugin/src/lib/attention-events.js +0 -113
- package/agent-spine-plugin/src/lib/attention-privacy.js +0 -72
- package/agent-spine-plugin/src/lib/attention-schema.js +0 -164
- package/agent-spine-plugin/src/lib/attention-storage.js +0 -93
- package/agent-spine-plugin/src/lib/attention.js +0 -164
- package/agent-spine-plugin/src/lib/audit-premortem.js +0 -223
- package/agent-spine-plugin/src/lib/audit.js +0 -401
- package/agent-spine-plugin/src/lib/authentication.js +0 -515
- package/agent-spine-plugin/src/lib/autonomy-policy.js +0 -110
- package/agent-spine-plugin/src/lib/autonomy-store.js +0 -202
- package/agent-spine-plugin/src/lib/autonomy.js +0 -8
- package/agent-spine-plugin/src/lib/briefing.js +0 -493
- package/agent-spine-plugin/src/lib/catalog-document-read.js +0 -51
- package/agent-spine-plugin/src/lib/catalog.js +0 -167
- package/agent-spine-plugin/src/lib/channel-continuity.js +0 -19
- package/agent-spine-plugin/src/lib/channel-runtime.js +0 -665
- package/agent-spine-plugin/src/lib/codex-installation.js +0 -231
- package/agent-spine-plugin/src/lib/codex-skill-installation.js +0 -211
- package/agent-spine-plugin/src/lib/context.js +0 -156
- package/agent-spine-plugin/src/lib/continuity.js +0 -338
- package/agent-spine-plugin/src/lib/coordination.js +0 -577
- package/agent-spine-plugin/src/lib/delivery-agent-usage.js +0 -231
- package/agent-spine-plugin/src/lib/delivery-assignment.js +0 -220
- package/agent-spine-plugin/src/lib/delivery-command-actions.js +0 -462
- package/agent-spine-plugin/src/lib/delivery-knowledge.js +0 -78
- package/agent-spine-plugin/src/lib/delivery-premortem-binding.js +0 -107
- package/agent-spine-plugin/src/lib/delivery-premortem-closure.js +0 -171
- package/agent-spine-plugin/src/lib/delivery-premortem-codec.js +0 -45
- package/agent-spine-plugin/src/lib/delivery-premortem-correction.js +0 -101
- package/agent-spine-plugin/src/lib/delivery-premortem-file.js +0 -21
- package/agent-spine-plugin/src/lib/delivery-premortem-index.js +0 -493
- package/agent-spine-plugin/src/lib/delivery-premortem-inspection.js +0 -37
- package/agent-spine-plugin/src/lib/delivery-premortem-recovery.js +0 -120
- package/agent-spine-plugin/src/lib/delivery-premortem-rejection.js +0 -65
- package/agent-spine-plugin/src/lib/delivery-premortem-results.js +0 -28
- package/agent-spine-plugin/src/lib/delivery-premortem-session-guard.js +0 -46
- package/agent-spine-plugin/src/lib/delivery-premortem-write-ledger.js +0 -285
- package/agent-spine-plugin/src/lib/delivery-premortem.js +0 -499
- package/agent-spine-plugin/src/lib/delivery-shell-heredoc.js +0 -115
- package/agent-spine-plugin/src/lib/delivery-shell-substitutions.js +0 -111
- package/agent-spine-plugin/src/lib/delivery-shell-wrapper.js +0 -64
- package/agent-spine-plugin/src/lib/delivery-target.js +0 -73
- package/agent-spine-plugin/src/lib/delivery-verification.js +0 -445
- package/agent-spine-plugin/src/lib/documents.js +0 -239
- package/agent-spine-plugin/src/lib/feed-transport.js +0 -499
- package/agent-spine-plugin/src/lib/filesystem-retry.js +0 -34
- package/agent-spine-plugin/src/lib/gateway-common.js +0 -68
- package/agent-spine-plugin/src/lib/gateway-control.js +0 -370
- package/agent-spine-plugin/src/lib/gateway-delivery.js +0 -103
- package/agent-spine-plugin/src/lib/gateway-execution.js +0 -350
- package/agent-spine-plugin/src/lib/gateway-group-response.js +0 -128
- package/agent-spine-plugin/src/lib/gateway-host-fencing.js +0 -92
- package/agent-spine-plugin/src/lib/gateway-host-lifecycle.js +0 -193
- package/agent-spine-plugin/src/lib/gateway-inspection.js +0 -85
- package/agent-spine-plugin/src/lib/gateway-knowledge.js +0 -129
- package/agent-spine-plugin/src/lib/gateway-policy-provenance.js +0 -197
- package/agent-spine-plugin/src/lib/gateway-premortem-disposition.js +0 -82
- package/agent-spine-plugin/src/lib/gateway-premortem.js +0 -363
- package/agent-spine-plugin/src/lib/gateway-prepared-host.js +0 -28
- package/agent-spine-plugin/src/lib/gateway-runs.js +0 -345
- package/agent-spine-plugin/src/lib/gateway-runtime-identity.js +0 -31
- package/agent-spine-plugin/src/lib/gateway-runtime-records.js +0 -21
- package/agent-spine-plugin/src/lib/gateway-runtime.js +0 -18
- package/agent-spine-plugin/src/lib/gateway-state-transaction.js +0 -356
- package/agent-spine-plugin/src/lib/gateway-state.js +0 -344
- package/agent-spine-plugin/src/lib/graph.js +0 -337
- package/agent-spine-plugin/src/lib/hook-artifact-guards.js +0 -356
- package/agent-spine-plugin/src/lib/hook-audit.js +0 -43
- package/agent-spine-plugin/src/lib/hook-briefing-use.js +0 -78
- package/agent-spine-plugin/src/lib/hook-context.js +0 -441
- package/agent-spine-plugin/src/lib/hook-final-message.js +0 -26
- package/agent-spine-plugin/src/lib/hook-input.js +0 -27
- package/agent-spine-plugin/src/lib/hook-output.js +0 -284
- package/agent-spine-plugin/src/lib/hook-premortem.js +0 -257
- package/agent-spine-plugin/src/lib/hook-process-advisory.js +0 -36
- package/agent-spine-plugin/src/lib/hook-protection.js +0 -95
- package/agent-spine-plugin/src/lib/hook-stop-verification.js +0 -84
- package/agent-spine-plugin/src/lib/hook-timeline.js +0 -102
- package/agent-spine-plugin/src/lib/host-instruction-budget.js +0 -11
- package/agent-spine-plugin/src/lib/https-transport.js +0 -392
- package/agent-spine-plugin/src/lib/identifier-analysis.js +0 -446
- package/agent-spine-plugin/src/lib/indexed-memory-offline.js +0 -40
- package/agent-spine-plugin/src/lib/indexed-memory.js +0 -298
- package/agent-spine-plugin/src/lib/knowledge-evidence.js +0 -431
- package/agent-spine-plugin/src/lib/learning-applications.js +0 -441
- package/agent-spine-plugin/src/lib/learning-artifact-evaluator.js +0 -114
- package/agent-spine-plugin/src/lib/learning-candidates.js +0 -274
- package/agent-spine-plugin/src/lib/learning-context.js +0 -137
- package/agent-spine-plugin/src/lib/learning-delivery-contracts.js +0 -310
- package/agent-spine-plugin/src/lib/learning-evaluation-contracts.js +0 -350
- package/agent-spine-plugin/src/lib/learning-evaluation-registration.js +0 -372
- package/agent-spine-plugin/src/lib/learning-evaluation-revocation.js +0 -292
- package/agent-spine-plugin/src/lib/learning-evidence-contracts.js +0 -321
- package/agent-spine-plugin/src/lib/learning-findings.js +0 -458
- package/agent-spine-plugin/src/lib/learning-measurement-contracts.js +0 -285
- package/agent-spine-plugin/src/lib/learning-measurements.js +0 -265
- package/agent-spine-plugin/src/lib/learning-outcome-contracts.js +0 -165
- package/agent-spine-plugin/src/lib/learning-outcomes.js +0 -343
- package/agent-spine-plugin/src/lib/learning-reconciliation.js +0 -290
- package/agent-spine-plugin/src/lib/learning-retry-contracts.js +0 -188
- package/agent-spine-plugin/src/lib/learning-schema.js +0 -229
- package/agent-spine-plugin/src/lib/learning-scope-targets.js +0 -424
- package/agent-spine-plugin/src/lib/learning-state-upgrade.js +0 -477
- package/agent-spine-plugin/src/lib/learning-status-configuration.js +0 -476
- package/agent-spine-plugin/src/lib/learning-storage.js +0 -203
- package/agent-spine-plugin/src/lib/learning-trial-recovery.js +0 -218
- package/agent-spine-plugin/src/lib/learning-validation-contracts.js +0 -375
- package/agent-spine-plugin/src/lib/learning-validation-renewal.js +0 -298
- package/agent-spine-plugin/src/lib/learning-validation-runtime.js +0 -234
- package/agent-spine-plugin/src/lib/learning.js +0 -36
- package/agent-spine-plugin/src/lib/lesson-recall-session.js +0 -172
- package/agent-spine-plugin/src/lib/mcp-autonomy-tools.js +0 -37
- package/agent-spine-plugin/src/lib/mcp-delivery-completion.js +0 -124
- package/agent-spine-plugin/src/lib/mcp-delivery-tools.js +0 -45
- package/agent-spine-plugin/src/lib/mcp-premortem.js +0 -68
- package/agent-spine-plugin/src/lib/mcp-runtime.js +0 -355
- package/agent-spine-plugin/src/lib/mcp-source-context.js +0 -61
- package/agent-spine-plugin/src/lib/mcp-timeline-tools.js +0 -240
- package/agent-spine-plugin/src/lib/mcp-world-tools.js +0 -52
- package/agent-spine-plugin/src/lib/object-transport.js +0 -206
- package/agent-spine-plugin/src/lib/owned-file-lock.js +0 -182
- package/agent-spine-plugin/src/lib/paths.js +0 -109
- package/agent-spine-plugin/src/lib/peer-transport.js +0 -283
- package/agent-spine-plugin/src/lib/persona-runtime.js +0 -581
- package/agent-spine-plugin/src/lib/pre-answer-timeline-recall.js +0 -104
- package/agent-spine-plugin/src/lib/preflight-delivery-id.js +0 -27
- package/agent-spine-plugin/src/lib/preflight.js +0 -688
- package/agent-spine-plugin/src/lib/project-portfolio.js +0 -176
- package/agent-spine-plugin/src/lib/runtime.js +0 -13
- package/agent-spine-plugin/src/lib/selfstarter-core.js +0 -382
- package/agent-spine-plugin/src/lib/selfstarter-jobs.js +0 -149
- package/agent-spine-plugin/src/lib/selfstarter-lease.js +0 -204
- package/agent-spine-plugin/src/lib/selfstarter-policy.js +0 -90
- package/agent-spine-plugin/src/lib/selfstarter-workspace.js +0 -111
- package/agent-spine-plugin/src/lib/selfstarter.js +0 -11
- package/agent-spine-plugin/src/lib/session-timeline-auth.js +0 -316
- package/agent-spine-plugin/src/lib/session-timeline-codex.js +0 -69
- package/agent-spine-plugin/src/lib/session-timeline-contract.js +0 -56
- package/agent-spine-plugin/src/lib/session-timeline-enrollment-source.js +0 -38
- package/agent-spine-plugin/src/lib/session-timeline-enrollment-storage.js +0 -128
- package/agent-spine-plugin/src/lib/session-timeline-enrollment-transport.js +0 -15
- package/agent-spine-plugin/src/lib/session-timeline-enrollment.js +0 -478
- package/agent-spine-plugin/src/lib/session-timeline-event-extract.js +0 -186
- package/agent-spine-plugin/src/lib/session-timeline-host-origin.js +0 -73
- package/agent-spine-plugin/src/lib/session-timeline-host-receipt.js +0 -117
- package/agent-spine-plugin/src/lib/session-timeline-invocation.js +0 -201
- package/agent-spine-plugin/src/lib/session-timeline-king.js +0 -93
- package/agent-spine-plugin/src/lib/session-timeline-prior.js +0 -57
- package/agent-spine-plugin/src/lib/session-timeline-provider.js +0 -36
- package/agent-spine-plugin/src/lib/session-timeline-query.js +0 -56
- package/agent-spine-plugin/src/lib/session-timeline-results.js +0 -56
- package/agent-spine-plugin/src/lib/session-timeline-root.js +0 -11
- package/agent-spine-plugin/src/lib/session-timeline-search.js +0 -82
- package/agent-spine-plugin/src/lib/session-timeline-sid-acl.js +0 -213
- package/agent-spine-plugin/src/lib/session-timeline-source-open.js +0 -30
- package/agent-spine-plugin/src/lib/session-timeline-source.js +0 -80
- package/agent-spine-plugin/src/lib/session-timeline-state.js +0 -45
- package/agent-spine-plugin/src/lib/session-timeline-transport.js +0 -42
- package/agent-spine-plugin/src/lib/session-timeline-windows-acl.js +0 -145
- package/agent-spine-plugin/src/lib/session-timeline.js +0 -462
- package/agent-spine-plugin/src/lib/sharing.js +0 -969
- package/agent-spine-plugin/src/lib/source-roots.js +0 -475
- package/agent-spine-plugin/src/lib/source-tree-scan.js +0 -178
- package/agent-spine-plugin/src/lib/sqlite-transport.js +0 -501
- package/agent-spine-plugin/src/lib/task-knowledge-context.js +0 -99
- package/agent-spine-plugin/src/lib/telegram-adapter.js +0 -119
- package/agent-spine-plugin/src/lib/timeline-continuation-update.js +0 -100
- package/agent-spine-plugin/src/lib/timeline-tool-guard.js +0 -225
- package/agent-spine-plugin/src/lib/timeline-user-feedback.js +0 -216
- package/agent-spine-plugin/src/lib/timeline-world-capture.js +0 -233
- package/agent-spine-plugin/src/lib/voice-runtime.js +0 -39
- package/agent-spine-plugin/src/lib/world-knowledge.js +0 -306
- package/agent-spine-plugin/src/lib/world-model.js +0 -333
- package/agent-spine-plugin/src/mcp.js +0 -456
- package/agent-spine-plugin/src/version.js +0 -1
- package/agent-spine-plugin/src/worker.js +0 -257
- package/bin/agentspine-king-goal-inbox.mjs +0 -127
- package/bin/agentspine-king-goal-intake.mjs +0 -106
- package/bin/agentspine-king-host-runner.mjs +0 -109
- package/bin/agentspine-king-snapshot-policy.cjs +0 -80
- package/bin/agentspine-king-status-policy.mjs +0 -226
- package/bin/agentspine-king-worker-host.mjs +0 -160
- package/bin/managed-plugin-selection.cjs +0 -141
- package/bin/verify-agent-behavior.cjs +0 -122
- package/bin/verify-agent-components.cjs +0 -104
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { spawn, spawnSync } from "node:child_process";
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
4
|
-
import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
5
|
-
import { basename, join, resolve } from "node:path";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
import { installCodexMcp, stripManagedCodexBlock } from "../src/lib/codex-installation.js";
|
|
8
|
-
import { VERSION } from "../src/version.js";
|
|
9
|
-
|
|
10
|
-
function sha256(value) {
|
|
11
|
-
return createHash("sha256").update(value).digest("hex");
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function copyFilter(source) {
|
|
15
|
-
const name = basename(source);
|
|
16
|
-
return !new Set([".git", "node_modules"]).has(name) && !name.endsWith(".tgz");
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function toolValue(response) {
|
|
20
|
-
const text = response.result?.content?.[0]?.text;
|
|
21
|
-
return text ? JSON.parse(text) : null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async function invokeLauncher(launcher, cwd, env, requests, timeoutMs = 10000) {
|
|
25
|
-
return new Promise((resolveResult, reject) => {
|
|
26
|
-
const child = spawn(process.execPath, [launcher], {
|
|
27
|
-
cwd, env: { ...process.env, ...env }, stdio: ["pipe", "pipe", "pipe"]
|
|
28
|
-
});
|
|
29
|
-
const expected = new Set(requests.map((request) => request.id));
|
|
30
|
-
const responses = new Map();
|
|
31
|
-
let stdout = "";
|
|
32
|
-
let stderr = "";
|
|
33
|
-
let settled = false;
|
|
34
|
-
let complete = false;
|
|
35
|
-
const finish = (error) => {
|
|
36
|
-
if (settled) return;
|
|
37
|
-
settled = true;
|
|
38
|
-
clearTimeout(timer);
|
|
39
|
-
if (error) child.kill();
|
|
40
|
-
if (error) reject(error);
|
|
41
|
-
else resolveResult(responses);
|
|
42
|
-
};
|
|
43
|
-
const timer = setTimeout(() => finish(new Error(`Codex launcher probe timed out${stderr ? `: ${stderr}` : ""}`)), timeoutMs);
|
|
44
|
-
child.stderr.setEncoding("utf8");
|
|
45
|
-
child.stderr.on("data", (chunk) => { stderr += chunk; });
|
|
46
|
-
child.stdout.setEncoding("utf8");
|
|
47
|
-
child.stdout.on("data", (chunk) => {
|
|
48
|
-
stdout += chunk;
|
|
49
|
-
let newline;
|
|
50
|
-
while ((newline = stdout.indexOf("\n")) >= 0) {
|
|
51
|
-
const line = stdout.slice(0, newline).trim();
|
|
52
|
-
stdout = stdout.slice(newline + 1);
|
|
53
|
-
if (!line) continue;
|
|
54
|
-
let response;
|
|
55
|
-
try { response = JSON.parse(line); } catch (error) { return finish(error); }
|
|
56
|
-
if (expected.has(response.id)) responses.set(response.id, response);
|
|
57
|
-
if (responses.size === expected.size && !complete) {
|
|
58
|
-
complete = true;
|
|
59
|
-
child.stdin.end();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
child.on("error", finish);
|
|
64
|
-
child.on("close", (code) => {
|
|
65
|
-
if (!settled) finish(complete ? null
|
|
66
|
-
: new Error(`Codex launcher exited with ${code}${stderr ? `: ${stderr}` : ""}`));
|
|
67
|
-
});
|
|
68
|
-
for (const request of requests) child.stdin.write(`${JSON.stringify(request)}\n`);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function hookRequirement(packageRoot, projectRoot, stateRoot) {
|
|
73
|
-
const input = {
|
|
74
|
-
host: "codex", cwd: projectRoot, session_id: "session:synthetic-codex-install",
|
|
75
|
-
hook_event_name: "UserPromptSubmit", event_id: "prompt:synthetic-codex-install",
|
|
76
|
-
prompt: "Continue the synthetic installed delivery.",
|
|
77
|
-
agent_spine_scope: { project_id: "project:synthetic-codex-install" }
|
|
78
|
-
};
|
|
79
|
-
const result = spawnSync(process.execPath, [join(packageRoot, "src", "hook.js")], {
|
|
80
|
-
cwd: projectRoot, env: { ...process.env, AGENTSPINE_STATE_DIR: stateRoot },
|
|
81
|
-
encoding: "utf8", input: JSON.stringify(input)
|
|
82
|
-
});
|
|
83
|
-
if (result.status !== 0) throw new Error(`installed Codex hook failed: ${result.stderr}`);
|
|
84
|
-
const context = JSON.parse(JSON.parse(result.stdout).hookSpecificOutput.additionalContext);
|
|
85
|
-
const requirementId = context.preflight?.premortem?.requirementId;
|
|
86
|
-
if (!requirementId) throw new Error("installed Codex hook did not issue a delivery requirement");
|
|
87
|
-
return requirementId;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async function oldPackage(root, target) {
|
|
91
|
-
await cp(root, target, { recursive: true, filter: copyFilter });
|
|
92
|
-
const pkgPath = join(target, "package.json");
|
|
93
|
-
const pkg = JSON.parse(await readFile(pkgPath, "utf8"));
|
|
94
|
-
pkg.version = "0.72.5";
|
|
95
|
-
await writeFile(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
|
|
96
|
-
await writeFile(join(target, "src", "version.js"), 'export const VERSION = "0.72.5";\n', "utf8");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export async function checkCodexInstall(root, workspace) {
|
|
100
|
-
root = resolve(root);
|
|
101
|
-
const codexHome = join(workspace, "codex-home");
|
|
102
|
-
const skillsRoot = join(workspace, "user-home", ".agents", "skills");
|
|
103
|
-
const projectRoot = join(workspace, "project");
|
|
104
|
-
const stateRoot = join(workspace, "state");
|
|
105
|
-
const previousRoot = join(workspace, "cache-0.72.5");
|
|
106
|
-
await Promise.all([
|
|
107
|
-
mkdir(codexHome, { recursive: true }), mkdir(join(projectRoot, ".git"), { recursive: true }),
|
|
108
|
-
mkdir(stateRoot, { recursive: true }), oldPackage(root, previousRoot)
|
|
109
|
-
]);
|
|
110
|
-
const foreignConfig = [
|
|
111
|
-
'model = "gpt-synthetic"',
|
|
112
|
-
"[mcp_servers.foreign]",
|
|
113
|
-
'command = "foreign-server"',
|
|
114
|
-
'args = ["--keep-byte-exact"]',
|
|
115
|
-
""
|
|
116
|
-
].join("\r\n");
|
|
117
|
-
const source = "# Synthetic Codex project\n\nKeep this source byte-exact.\n";
|
|
118
|
-
const unknown = '{"schema":"external.unknown-event/v99","decision":"not-authority"}\n';
|
|
119
|
-
const configPath = join(codexHome, "config.toml");
|
|
120
|
-
const sourcePath = join(projectRoot, "AGENTS.md");
|
|
121
|
-
const unknownPath = join(stateRoot, "external-event.json");
|
|
122
|
-
await Promise.all([
|
|
123
|
-
writeFile(configPath, foreignConfig, "utf8"),
|
|
124
|
-
writeFile(sourcePath, source, "utf8"),
|
|
125
|
-
writeFile(unknownPath, unknown, "utf8")
|
|
126
|
-
]);
|
|
127
|
-
const initial = await installCodexMcp({ codexHome, skillsRoot, packageRoot: previousRoot });
|
|
128
|
-
const requirementId = hookRequirement(previousRoot, projectRoot, stateRoot);
|
|
129
|
-
const oldResponses = await invokeLauncher(initial.launcherPath, projectRoot, {
|
|
130
|
-
AGENTSPINE_STATE_DIR: stateRoot, PLUGIN_ROOT: join(workspace, "wrong-plugin-root")
|
|
131
|
-
}, [
|
|
132
|
-
{ jsonrpc: "2.0", id: 1, method: "initialize", params: { protocolVersion: "2025-06-18" } },
|
|
133
|
-
{ jsonrpc: "2.0", id: 2, method: "tools/list", params: {} },
|
|
134
|
-
{ jsonrpc: "2.0", id: 3, method: "tools/call", params: { name: "session_briefing",
|
|
135
|
-
arguments: { root: projectRoot, cwd: projectRoot, host: "codex", maxBytes: 4096,
|
|
136
|
-
includeSourceContent: false } } }
|
|
137
|
-
]);
|
|
138
|
-
if (oldResponses.get(1)?.result?.serverInfo?.version !== "0.72.5"
|
|
139
|
-
|| (oldResponses.get(2)?.result?.tools || []).length < 3 || oldResponses.get(3)?.result?.isError) {
|
|
140
|
-
throw new Error("pre-update Codex process did not load the registered reader");
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const updated = await installCodexMcp({ codexHome, skillsRoot, packageRoot: root });
|
|
144
|
-
await rm(previousRoot, { recursive: true, force: true });
|
|
145
|
-
const requests = [
|
|
146
|
-
{ jsonrpc: "2.0", id: 10, method: "initialize", params: { protocolVersion: "2025-06-18" } },
|
|
147
|
-
{ jsonrpc: "2.0", id: 11, method: "tools/list", params: {} },
|
|
148
|
-
{ jsonrpc: "2.0", id: 12, method: "tools/call", params: { name: "read_document",
|
|
149
|
-
arguments: { root: projectRoot, host: "codex", path: "AGENTS.md", offset: 0, length: 4096 } } },
|
|
150
|
-
{ jsonrpc: "2.0", id: 13, method: "tools/call", params: { name: "session_briefing",
|
|
151
|
-
arguments: { root: projectRoot, cwd: projectRoot, host: "codex", projectId: "project:synthetic-codex-install",
|
|
152
|
-
requirementId, maxBytes: 4096, includeSourceContent: false } } },
|
|
153
|
-
{ jsonrpc: "2.0", id: 14, method: "tools/call", params: { name: "delivery_knowledge_query",
|
|
154
|
-
arguments: { root: projectRoot, requirementId, targetPaths: ["artifact.txt"], contractPaths: ["AGENTS.md"],
|
|
155
|
-
recentErrorTerms: ["stale reader", "missing registration"], maxBytes: 8192 } } },
|
|
156
|
-
{ jsonrpc: "2.0", id: 15, method: "tools/call", params: { name: "record_delivery_premortem",
|
|
157
|
-
arguments: { root: projectRoot, requirementId, items: [
|
|
158
|
-
{ category: "baseline-environment", failure: "this delivery fails because the installed reader is stale", check: "Check the loaded reader version." },
|
|
159
|
-
{ category: "contract-tests", failure: "this delivery fails because required tools are missing", check: "List and call the required tools." },
|
|
160
|
-
{ category: "delivery-path", failure: "this delivery fails because configuration bytes changed", check: "Hash unmanaged configuration and sources." }
|
|
161
|
-
] } } }
|
|
162
|
-
];
|
|
163
|
-
const responses = await invokeLauncher(updated.launcherPath, projectRoot, {
|
|
164
|
-
AGENTSPINE_STATE_DIR: stateRoot, PLUGIN_ROOT: join(workspace, "wrong-plugin-root")
|
|
165
|
-
}, requests);
|
|
166
|
-
const toolNames = new Set((responses.get(11)?.result?.tools || []).map((tool) => tool.name));
|
|
167
|
-
const read = toolValue(responses.get(12));
|
|
168
|
-
const briefing = toolValue(responses.get(13));
|
|
169
|
-
const knowledge = toolValue(responses.get(14));
|
|
170
|
-
const premortem = toolValue(responses.get(15));
|
|
171
|
-
for (const name of ["session_briefing", "delivery_knowledge_query", "record_delivery_premortem"]) {
|
|
172
|
-
if (!toolNames.has(name)) throw new Error(`updated Codex reader is missing ${name}`);
|
|
173
|
-
}
|
|
174
|
-
if (responses.get(10)?.result?.serverInfo?.version !== VERSION || read?.content !== source
|
|
175
|
-
|| briefing?.deliveryUseReceipt?.blocked || knowledge?.deliveryUseReceipt?.blocked
|
|
176
|
-
|| premortem?.blocked || premortem?.status !== "recorded") {
|
|
177
|
-
throw new Error("updated Codex reader did not preserve the existing session and required calls");
|
|
178
|
-
}
|
|
179
|
-
const config = await readFile(configPath, "utf8");
|
|
180
|
-
const installedSkill = await readFile(updated.skill.skillPath);
|
|
181
|
-
const sourceSkill = await readFile(join(root, "skills", "agent-spine", "SKILL.md"));
|
|
182
|
-
if (stripManagedCodexBlock(config) !== foreignConfig
|
|
183
|
-
|| (config.match(/^\[mcp_servers\.agent-spine\]$/gm) || []).length !== 1
|
|
184
|
-
|| !installedSkill.equals(sourceSkill)
|
|
185
|
-
|| await readFile(sourcePath, "utf8") !== source || await readFile(unknownPath, "utf8") !== unknown) {
|
|
186
|
-
throw new Error("Codex installation changed foreign configuration, source bytes, or unknown state");
|
|
187
|
-
}
|
|
188
|
-
return {
|
|
189
|
-
ok: true,
|
|
190
|
-
version: VERSION,
|
|
191
|
-
oldVersion: "0.72.5",
|
|
192
|
-
configuredOnce: true,
|
|
193
|
-
foreignConfigDigest: sha256(foreignConfig),
|
|
194
|
-
unmanagedConfigDigest: updated.unmanagedAfterDigest,
|
|
195
|
-
sourceDigest: sha256(source),
|
|
196
|
-
unknownStateDigest: sha256(unknown),
|
|
197
|
-
tools: [...toolNames].filter((name) => REQUIRED_TOOL_NAMES.has(name)).sort(),
|
|
198
|
-
existingSessionReadable: true,
|
|
199
|
-
boundRequiredCalls: true,
|
|
200
|
-
nativeSkillInstalled: true,
|
|
201
|
-
wrongPluginRootIgnored: true,
|
|
202
|
-
authority: "installation-check-only"
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const REQUIRED_TOOL_NAMES = new Set([
|
|
207
|
-
"session_briefing", "delivery_knowledge_query", "record_delivery_premortem", "read_document"
|
|
208
|
-
]);
|
|
209
|
-
|
|
210
|
-
async function main() {
|
|
211
|
-
const root = resolve(process.argv[2] || process.cwd());
|
|
212
|
-
const workspace = resolve(process.argv[3] || join(root, ".synthetic-codex-install"));
|
|
213
|
-
await mkdir(workspace, { recursive: true });
|
|
214
|
-
try {
|
|
215
|
-
process.stdout.write(`${JSON.stringify(await checkCodexInstall(root, workspace), null, 2)}\n`);
|
|
216
|
-
} finally {
|
|
217
|
-
if (!process.argv[3]) await rm(workspace, { recursive: true, force: true });
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (process.argv[1] && resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url))) {
|
|
222
|
-
main().catch((error) => {
|
|
223
|
-
process.stderr.write(`AgentSpine Codex install check failed: ${error.message}\n`);
|
|
224
|
-
process.exitCode = 1;
|
|
225
|
-
});
|
|
226
|
-
}
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
|
-
import { readFile, stat } from "node:fs/promises";
|
|
4
|
-
import { isAbsolute, relative, resolve } from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { installedHostEnvironment } from "./check-install-hook.js";
|
|
7
|
-
|
|
8
|
-
const TIMELINE_PRE_TOOL_MATCHER = "^(?:Edit|Write|apply_patch|Bash|PowerShell|mcp__plugin_agent-spine_agent-spine__session_timeline_(?:index|search|capture))$";
|
|
9
|
-
const BLUN_TIMELINE_PRE_TOOL_MATCHER = "^(?:Edit|Write|apply_patch|Bash|PowerShell|exec_command|mcp__agent-spine__session_timeline_(?:index|search|capture))$";
|
|
10
|
-
|
|
11
|
-
function assert(condition, message) {
|
|
12
|
-
if (!condition) throw new Error(message);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async function json(root, path) {
|
|
16
|
-
return JSON.parse(await readFile(resolve(root, path), "utf8"));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function expand(value, variable, root) {
|
|
20
|
-
assert(typeof value === "string" && value.length > 0, "host command values must be non-empty strings");
|
|
21
|
-
return value.split(`\${${variable}}`).join(root);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async function validateEntrypoint(root, value) {
|
|
25
|
-
const target = resolve(value);
|
|
26
|
-
const within = relative(root, target);
|
|
27
|
-
assert(within && !within.startsWith("..") && !isAbsolute(within), "MCP entrypoint must remain inside the plugin");
|
|
28
|
-
const metadata = await stat(target);
|
|
29
|
-
assert(metadata.isFile(), "MCP entrypoint must be a regular file");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function validateHooks(root, hooks, { required, commandRoot, matcher = TIMELINE_PRE_TOOL_MATCHER }) {
|
|
33
|
-
assert(hooks && typeof hooks === "object" && !Array.isArray(hooks), "hook bundle is missing");
|
|
34
|
-
assert(Object.keys(hooks).every((key) => ["description", "hooks"].includes(key)), "hook bundle contains unsupported top-level metadata");
|
|
35
|
-
assert(hooks.description && typeof hooks.description === "string", "hook bundle description is missing");
|
|
36
|
-
for (const event of required) {
|
|
37
|
-
const registrations = hooks.hooks?.[event];
|
|
38
|
-
assert(Array.isArray(registrations) && registrations.length === 1, `${event} must have exactly one registration`);
|
|
39
|
-
assert(Array.isArray(registrations[0].hooks) && registrations[0].hooks.length === 1, `${event} must have exactly one hook command`);
|
|
40
|
-
const command = registrations[0].hooks[0];
|
|
41
|
-
assert(command.type === "command", `${event} must use a command hook`);
|
|
42
|
-
const expected = `node "\${${commandRoot}}/src/hook.js"${event === "PostToolUse"
|
|
43
|
-
? " --silent-oversize-post-tool-use" : ""}`;
|
|
44
|
-
assert(command.command === expected, `${event} must use the bundled lifecycle adapter`);
|
|
45
|
-
assert(Number.isInteger(command.timeout) && command.timeout > 0 && command.timeout <= 15, `${event} timeout is unsafe`);
|
|
46
|
-
if (event === "PreToolUse") assert(registrations[0].matcher === matcher,
|
|
47
|
-
"PreToolUse must route only exact mutations and timeline MCP calls through one guard");
|
|
48
|
-
}
|
|
49
|
-
const extras = Object.keys(hooks.hooks || {}).filter((event) => !required.includes(event));
|
|
50
|
-
assert(extras.length === 0, `unknown hook events: ${extras.join(", ")}`);
|
|
51
|
-
return { events: required, commands: required.length, entrypoint: relative(root, resolve(root, "src/hook.js")) };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function validateBlunHooks(root, hooks) {
|
|
55
|
-
const required = [
|
|
56
|
-
"SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse",
|
|
57
|
-
"PreCompact", "PostCompact", "Stop", "SubagentStop"
|
|
58
|
-
];
|
|
59
|
-
assert(Array.isArray(hooks), "BLUN hook bundle is missing");
|
|
60
|
-
assert(hooks.length === required.length, "BLUN must register exactly one command per lifecycle event");
|
|
61
|
-
assert(JSON.stringify(hooks.map(({ event }) => event)) === JSON.stringify(required),
|
|
62
|
-
"BLUN lifecycle events must remain complete and ordered");
|
|
63
|
-
for (const event of required) {
|
|
64
|
-
const registrations = hooks.filter((hook) => hook.event === event);
|
|
65
|
-
assert(registrations.length === 1, `${event} must have exactly one BLUN registration`);
|
|
66
|
-
const command = registrations[0];
|
|
67
|
-
const expected = `node "./src/hook.js"${event === "PostToolUse"
|
|
68
|
-
? " --silent-oversize-post-tool-use" : ""}`;
|
|
69
|
-
assert(command.command === expected, `${event} must use the bundled BLUN lifecycle adapter`);
|
|
70
|
-
assert(Number.isInteger(command.timeout) && command.timeout > 0 && command.timeout <= 15, `${event} BLUN timeout is unsafe`);
|
|
71
|
-
if (event === "PreToolUse") assert(command.matcher === BLUN_TIMELINE_PRE_TOOL_MATCHER,
|
|
72
|
-
"BLUN PreToolUse must route only exact mutations and timeline MCP calls through one guard");
|
|
73
|
-
}
|
|
74
|
-
return { events: required, commands: required.length, entrypoint: relative(root, resolve(root, "src/hook.js")) };
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async function initializeServer({ label, root, variable, server, version }) {
|
|
78
|
-
assert(server && typeof server === "object" && !Array.isArray(server), `${label} MCP registration is missing`);
|
|
79
|
-
assert(server.command === "node", `${label} MCP registration must use the Node.js runtime`);
|
|
80
|
-
assert(Array.isArray(server.args) && server.args.length === 1, `${label} MCP registration must name exactly one entrypoint`);
|
|
81
|
-
const command = process.execPath;
|
|
82
|
-
const args = server.args.map((value) => {
|
|
83
|
-
const expanded = expand(value, variable, root);
|
|
84
|
-
return isAbsolute(expanded) ? expanded : resolve(root, expanded);
|
|
85
|
-
});
|
|
86
|
-
assert(!args.some((value) => value.includes("${")), `${label} MCP registration contains an unresolved variable`);
|
|
87
|
-
await validateEntrypoint(root, args[0]);
|
|
88
|
-
|
|
89
|
-
return await new Promise((resolveResult, reject) => {
|
|
90
|
-
const child = spawn(command, args, {
|
|
91
|
-
cwd: root,
|
|
92
|
-
env: installedHostEnvironment(label, root),
|
|
93
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
94
|
-
});
|
|
95
|
-
let stdout = "";
|
|
96
|
-
let stderr = "";
|
|
97
|
-
let settled = false;
|
|
98
|
-
const finish = (error, value) => {
|
|
99
|
-
if (settled) return;
|
|
100
|
-
settled = true;
|
|
101
|
-
clearTimeout(timer);
|
|
102
|
-
const settle = () => {
|
|
103
|
-
if (error) reject(error);
|
|
104
|
-
else resolveResult(value);
|
|
105
|
-
};
|
|
106
|
-
if (child.exitCode !== null || child.signalCode !== null) return settle();
|
|
107
|
-
child.once("close", settle);
|
|
108
|
-
child.kill();
|
|
109
|
-
};
|
|
110
|
-
const timer = setTimeout(() => {
|
|
111
|
-
finish(new Error(`${label} MCP initialize timed out${stderr ? `: ${stderr.trim()}` : ""}`));
|
|
112
|
-
}, 3000);
|
|
113
|
-
child.stderr.setEncoding("utf8");
|
|
114
|
-
child.stderr.on("data", (chunk) => { stderr += chunk; });
|
|
115
|
-
child.stdout.setEncoding("utf8");
|
|
116
|
-
child.stdout.on("data", (chunk) => {
|
|
117
|
-
stdout += chunk;
|
|
118
|
-
const newline = stdout.indexOf("\n");
|
|
119
|
-
if (newline < 0) return;
|
|
120
|
-
try {
|
|
121
|
-
const message = JSON.parse(stdout.slice(0, newline));
|
|
122
|
-
assert(message.id === 1, `${label} MCP initialize returned the wrong request id`);
|
|
123
|
-
assert(message.result?.serverInfo?.name === "agent-spine", `${label} MCP initialize returned the wrong server identity`);
|
|
124
|
-
assert(message.result?.serverInfo?.version === version, `${label} MCP initialize returned a stale server version`);
|
|
125
|
-
finish(null, { label, server: message.result.serverInfo.name, entrypoint: relative(root, args[0]) });
|
|
126
|
-
} catch (error) {
|
|
127
|
-
finish(error);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
child.once("error", (error) => finish(error));
|
|
131
|
-
child.once("close", (code) => {
|
|
132
|
-
if (!settled) finish(new Error(`${label} MCP server exited with ${code}${stderr ? `: ${stderr.trim()}` : ""}`));
|
|
133
|
-
});
|
|
134
|
-
// A real MCP host keeps stdio open after initialization. Closing stdin
|
|
135
|
-
// here let macOS and Windows terminate the server before its queued reply.
|
|
136
|
-
child.stdin.write(`${JSON.stringify({
|
|
137
|
-
jsonrpc: "2.0", id: 1, method: "initialize", params: { protocolVersion: "2025-06-18" }
|
|
138
|
-
})}\n`);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export async function checkHosts(root = process.cwd()) {
|
|
143
|
-
root = resolve(root);
|
|
144
|
-
const [pkg, blunManifest, claudeManifest, claudeMcp, codexManifest, claudeHooks, codexHooks, hookVersion] = await Promise.all([
|
|
145
|
-
json(root, "package.json"),
|
|
146
|
-
json(root, "blun.plugin.json"),
|
|
147
|
-
json(root, ".claude-plugin/plugin.json"),
|
|
148
|
-
json(root, ".mcp.json"),
|
|
149
|
-
json(root, ".codex-plugin/plugin.json"),
|
|
150
|
-
json(root, "hooks/hooks.json"),
|
|
151
|
-
json(root, "hooks/codex.json"),
|
|
152
|
-
json(root, "hooks/version.json")
|
|
153
|
-
]);
|
|
154
|
-
assert(blunManifest.version === pkg.version && claudeManifest.version === pkg.version && codexManifest.version === pkg.version,
|
|
155
|
-
"host manifests must use the package cache version");
|
|
156
|
-
assert(hookVersion.schema === "agentspine.hook-bundle/v1" && hookVersion.version === pkg.version,
|
|
157
|
-
"hook bundle version must match the package cache version");
|
|
158
|
-
assert(hookVersion.contract === "agentspine.preflight/v2", "hook bundle preflight contract is missing");
|
|
159
|
-
assert(pkg.bin?.["agentspine-worker"] === "./src/worker.js", "package must register exactly one gateway worker entrypoint");
|
|
160
|
-
await validateEntrypoint(root, resolve(root, pkg.bin["agentspine-worker"]));
|
|
161
|
-
assert(claudeManifest.mcpServers === "./.mcp.json", "Claude manifest must explicitly reference ./.mcp.json");
|
|
162
|
-
assert(claudeManifest.hooks === undefined, "default hooks/hooks.json must not also be registered through a supplemental manifest path");
|
|
163
|
-
assert(codexManifest.hooks === "./hooks/codex.json", "Codex manifest must select its host-specific hook adapter");
|
|
164
|
-
assert(claudeMcp.mcpServers && Object.keys(claudeMcp.mcpServers).length === 1, "Claude MCP file must contain one mcpServers registration");
|
|
165
|
-
assert(codexManifest.mcpServers && Object.keys(codexManifest.mcpServers).length === 1, "Codex manifest must contain one MCP registration");
|
|
166
|
-
const commonEvents = ["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse", "PreCompact", "PostCompact", "Stop", "SubagentStop"];
|
|
167
|
-
const claudeHookInventory = validateHooks(root, claudeHooks, {
|
|
168
|
-
required: [...commonEvents, "InstructionsLoaded"], commandRoot: "CLAUDE_PLUGIN_ROOT"
|
|
169
|
-
});
|
|
170
|
-
const codexHookInventory = validateHooks(root, codexHooks, { required: commonEvents, commandRoot: "PLUGIN_ROOT",
|
|
171
|
-
matcher: "^(?:Edit|Write|apply_patch|Bash|PowerShell|mcp__(?:plugin_agent-spine_agent-spine|agent-spine)__session_timeline_(?:index|search|capture))$" });
|
|
172
|
-
const blunHookInventory = validateBlunHooks(root, blunManifest.hooks);
|
|
173
|
-
const registrations = await Promise.all([
|
|
174
|
-
initializeServer({ label: "blun", root, variable: "BLUN_PLUGIN_ROOT", server: blunManifest.mcpServers["agent-spine"], version: pkg.version }),
|
|
175
|
-
initializeServer({ label: "claude", root, variable: "CLAUDE_PLUGIN_ROOT", server: claudeMcp.mcpServers["agent-spine"], version: pkg.version }),
|
|
176
|
-
initializeServer({ label: "codex", root, variable: "PLUGIN_ROOT", server: codexManifest.mcpServers["agent-spine"], version: pkg.version })
|
|
177
|
-
]);
|
|
178
|
-
return {
|
|
179
|
-
ok: true, root, version: pkg.version, registrations,
|
|
180
|
-
hooks: { blun: blunHookInventory, claude: claudeHookInventory, codex: codexHookInventory },
|
|
181
|
-
hookDiscovery: {
|
|
182
|
-
blun: "plugin-manifest", claude: "default-hooks-directory", codex: "plugin-manifest",
|
|
183
|
-
trust: "host-user-required", liveTrustVerified: false
|
|
184
|
-
},
|
|
185
|
-
worker: { entrypoint: pkg.bin["agentspine-worker"], setsPerInstall: 1 },
|
|
186
|
-
exactlyOnce: { mcpServersPerHost: 1, hookSetsPerHost: 1, workerSetsPerInstall: 1 },
|
|
187
|
-
authority: "registration-check-only"
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
async function main() {
|
|
192
|
-
const args = process.argv.slice(2);
|
|
193
|
-
let root = process.cwd();
|
|
194
|
-
let pretty = false;
|
|
195
|
-
for (let index = 0; index < args.length; index += 1) {
|
|
196
|
-
if (args[index] === "--root") root = args[++index];
|
|
197
|
-
else if (args[index] === "--json") pretty = true;
|
|
198
|
-
else throw new Error(`unknown host-check argument: ${args[index]}`);
|
|
199
|
-
}
|
|
200
|
-
process.stdout.write(`${JSON.stringify(await checkHosts(root), null, pretty ? 2 : 0)}\n`);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (process.argv[1] && resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url))) {
|
|
204
|
-
main().catch((error) => {
|
|
205
|
-
process.stderr.write(`AgentSpine host check failed: ${error.message}\n`);
|
|
206
|
-
process.exitCode = 1;
|
|
207
|
-
});
|
|
208
|
-
}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { writeFile } from "node:fs/promises";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { pathToFileURL } from "node:url";
|
|
5
|
-
|
|
6
|
-
const HOST_ROOTS = {
|
|
7
|
-
blun: ["BLUN_PLUGIN_ROOT"],
|
|
8
|
-
claude: ["CLAUDE_PLUGIN_ROOT"],
|
|
9
|
-
codex: ["PLUGIN_ROOT", "CLAUDE_PLUGIN_ROOT"]
|
|
10
|
-
};
|
|
11
|
-
const HOST_ROOT_KEYS = ["BLUN_PLUGIN_ROOT", "CLAUDE_PLUGIN_ROOT", "PLUGIN_ROOT"];
|
|
12
|
-
|
|
13
|
-
export function installedHostEnvironment(host, pluginRoot, extraEnv = {}) {
|
|
14
|
-
const rootKeys = HOST_ROOTS[host];
|
|
15
|
-
if (!rootKeys) throw new Error(`unsupported installed host: ${host}`);
|
|
16
|
-
const env = { ...process.env, ...extraEnv };
|
|
17
|
-
for (const key of HOST_ROOT_KEYS) delete env[key];
|
|
18
|
-
for (const key of rootKeys) env[key] = pluginRoot;
|
|
19
|
-
return env;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function parseProtocol(stdout, host) {
|
|
23
|
-
try {
|
|
24
|
-
return JSON.parse(stdout.trim());
|
|
25
|
-
} catch (error) {
|
|
26
|
-
throw new Error(`${host} installed hook returned invalid protocol JSON: ${stdout.slice(0, 2048)}`, { cause: error });
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function parseContext(protocol, host, requireBriefing) {
|
|
31
|
-
const raw = protocol.hookSpecificOutput?.additionalContext;
|
|
32
|
-
if (typeof raw !== "string" || !raw) return null;
|
|
33
|
-
try {
|
|
34
|
-
return JSON.parse(raw);
|
|
35
|
-
} catch (error) {
|
|
36
|
-
if (!requireBriefing) return null;
|
|
37
|
-
throw new Error(`${host} installed hook returned invalid briefing context JSON`, { cause: error });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function protocolShape(protocol) {
|
|
42
|
-
const specific = protocol.hookSpecificOutput;
|
|
43
|
-
return {
|
|
44
|
-
protocolKeys: Object.keys(protocol).sort(),
|
|
45
|
-
hookSpecificKeys: specific && typeof specific === "object" ? Object.keys(specific).sort() : [],
|
|
46
|
-
permissionDecision: specific?.permissionDecision || null,
|
|
47
|
-
permissionDecisionReason: specific?.permissionDecisionReason || null
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export async function invokeInstalledHook(pluginRoot, projectRoot, stateRoot, host, payload = null,
|
|
52
|
-
{ requireBriefing = true, extraEnv = {} } = {}) {
|
|
53
|
-
return await new Promise((resolveResult, reject) => {
|
|
54
|
-
const child = spawn(process.execPath, [join(pluginRoot, "src/hook.js")], {
|
|
55
|
-
cwd: projectRoot,
|
|
56
|
-
env: installedHostEnvironment(host, pluginRoot, {
|
|
57
|
-
AGENTSPINE_HOST: host,
|
|
58
|
-
AGENTSPINE_STATE_DIR: stateRoot,
|
|
59
|
-
...extraEnv
|
|
60
|
-
}),
|
|
61
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
62
|
-
});
|
|
63
|
-
let stdout = "";
|
|
64
|
-
let stderr = "";
|
|
65
|
-
const timer = setTimeout(() => {
|
|
66
|
-
child.kill();
|
|
67
|
-
reject(new Error(`${host} installed hook timed out`));
|
|
68
|
-
}, 5000);
|
|
69
|
-
child.stdout.setEncoding("utf8");
|
|
70
|
-
child.stderr.setEncoding("utf8");
|
|
71
|
-
child.stdout.on("data", (chunk) => { stdout += chunk; });
|
|
72
|
-
child.stderr.on("data", (chunk) => { stderr += chunk; });
|
|
73
|
-
child.once("error", reject);
|
|
74
|
-
child.once("exit", (code) => {
|
|
75
|
-
clearTimeout(timer);
|
|
76
|
-
if (code !== 0) {
|
|
77
|
-
reject(new Error(`${host} installed hook exited with ${code}: ${stderr.slice(0, 2048)}`));
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
try {
|
|
81
|
-
const protocol = parseProtocol(stdout, host);
|
|
82
|
-
const context = parseContext(protocol, host, requireBriefing);
|
|
83
|
-
if (requireBriefing && (context?.briefing?.host !== host
|
|
84
|
-
|| !Array.isArray(context?.briefing?.sources?.documents))) {
|
|
85
|
-
throw new Error(`${host} installed hook did not inject a real session briefing: `
|
|
86
|
-
+ `${protocol.reason || context?.error || context?.sourceResolution?.reason || "missing context"}`);
|
|
87
|
-
}
|
|
88
|
-
resolveResult({
|
|
89
|
-
event: protocol.hookSpecificOutput?.hookEventName || payload?.hook_event_name || null, host,
|
|
90
|
-
sources: context?.briefing?.sources?.documents?.length ?? null,
|
|
91
|
-
sourceIds: context?.briefing?.sources?.documents?.map((item) => item.path) || [],
|
|
92
|
-
sourceContents: context?.briefing?.sources?.documents?.map((item) => item.content).filter(Boolean) || [],
|
|
93
|
-
sourceResolution: context?.sourceResolution || null,
|
|
94
|
-
learningClaims: context?.briefing?.learning?.map((item) => item.claim) || [],
|
|
95
|
-
attentionKinds: context?.briefing?.attention?.items?.map((item) => item.kind) || [],
|
|
96
|
-
capturedAttentionKind: context?.attentionEvent?.kind || null,
|
|
97
|
-
selfstarter: context?.selfstarter || null,
|
|
98
|
-
channelEvent: context?.channelEvent || null,
|
|
99
|
-
voiceBrief: context?.briefing?.voiceBrief || null,
|
|
100
|
-
preflight: context?.preflight || null,
|
|
101
|
-
decision: protocol.decision || null,
|
|
102
|
-
reason: protocol.reason || null,
|
|
103
|
-
message: protocol.hookSpecificOutput?.message || null,
|
|
104
|
-
additionalContext: protocol.hookSpecificOutput?.additionalContext || null,
|
|
105
|
-
...protocolShape(protocol)
|
|
106
|
-
});
|
|
107
|
-
} catch (error) {
|
|
108
|
-
reject(error);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
child.stdin.end(`${JSON.stringify(payload || {
|
|
112
|
-
hook_event_name: "SessionStart", cwd: projectRoot, host
|
|
113
|
-
})}\n`);
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export async function invokeInstalledBlunPostWriteDigest(pluginRoot, projectRoot, stateRoot) {
|
|
118
|
-
const sessionId = `session:installed-blun-post-${stateRoot.split(/[\\/]/).at(-1)}`;
|
|
119
|
-
const shared = {
|
|
120
|
-
hook_event_name: "UserPromptSubmit", cwd: projectRoot, host: "blun",
|
|
121
|
-
project_id: "project:installed-blun-protocol", session_id: sessionId,
|
|
122
|
-
event_id: `prompt:${sessionId}`, prompt: "Change the synthetic installed BLUN artifact safely."
|
|
123
|
-
};
|
|
124
|
-
const prompted = await invokeInstalledHook(pluginRoot, projectRoot, stateRoot, "blun", shared,
|
|
125
|
-
{ requireBriefing: false });
|
|
126
|
-
const requirementId = prompted.additionalContext?.match(
|
|
127
|
-
/Requirement: (premortem-requirement:[a-f0-9]{64}:[a-f0-9]{64})/
|
|
128
|
-
)?.[1];
|
|
129
|
-
if (!requirementId) throw new Error("installed BLUN prompt did not expose its premortem requirement");
|
|
130
|
-
const previousStateRoot = process.env.AGENTSPINE_STATE_DIR;
|
|
131
|
-
try {
|
|
132
|
-
process.env.AGENTSPINE_STATE_DIR = stateRoot;
|
|
133
|
-
const premortem = await import(pathToFileURL(join(pluginRoot, "src/lib/delivery-premortem.js")).href);
|
|
134
|
-
const usage = await import(pathToFileURL(join(pluginRoot, "src/lib/delivery-agent-usage.js")).href);
|
|
135
|
-
await usage.recordDeliveryBriefingUse({ root: projectRoot, requirementId,
|
|
136
|
-
input: { root: projectRoot }, result: { schema: "synthetic-installed-briefing" } });
|
|
137
|
-
await usage.recordDeliveryKnowledgeUse({ root: projectRoot, requirementId,
|
|
138
|
-
input: { targets: ["AGENTS.md"] }, result: { schema: "synthetic-installed-knowledge" } });
|
|
139
|
-
const recorded = await premortem.recordDeliveryPremortem({
|
|
140
|
-
root: projectRoot, requirementId, items: [
|
|
141
|
-
{ category: "baseline-environment", failure: "this delivery fails because the installed baseline is stale",
|
|
142
|
-
check: "Compare the installed synthetic snapshot digest." },
|
|
143
|
-
{ category: "contract-tests", failure: "this delivery fails because the installed contract regresses",
|
|
144
|
-
check: "Run the installed synthetic Node test." },
|
|
145
|
-
{ category: "delivery-path", failure: "this delivery fails because the installed artifact is misplaced",
|
|
146
|
-
check: "Verify the installed synthetic artifact path and digest." }
|
|
147
|
-
]
|
|
148
|
-
});
|
|
149
|
-
if (recorded.blocked) throw new Error(`installed BLUN premortem registration failed: ${recorded.reason}`);
|
|
150
|
-
} finally {
|
|
151
|
-
if (previousStateRoot === undefined) delete process.env.AGENTSPINE_STATE_DIR;
|
|
152
|
-
else process.env.AGENTSPINE_STATE_DIR = previousStateRoot;
|
|
153
|
-
}
|
|
154
|
-
const filePath = join(projectRoot, "installed-blun-post-write.txt");
|
|
155
|
-
const tool = { tool_name: "Write", tool_use_id: `write:${sessionId}`,
|
|
156
|
-
tool_input: { file_path: filePath, content: "synthetic installed BLUN write\n" } };
|
|
157
|
-
const pre = await invokeInstalledHook(pluginRoot, projectRoot, stateRoot, "blun", {
|
|
158
|
-
...shared, ...tool, hook_event_name: "PreToolUse"
|
|
159
|
-
}, { requireBriefing: false });
|
|
160
|
-
if (pre.decision === "block" || pre.permissionDecision === "deny") {
|
|
161
|
-
throw new Error(`installed BLUN PreToolUse denied its registered premortem: ${pre.reason}`);
|
|
162
|
-
}
|
|
163
|
-
await writeFile(filePath, tool.tool_input.content, "utf8");
|
|
164
|
-
const post = await invokeInstalledHook(pluginRoot, projectRoot, stateRoot, "blun", {
|
|
165
|
-
...shared, ...tool, hook_event_name: "PostToolUse", success: true, tool_response: { ok: true }
|
|
166
|
-
}, { requireBriefing: false });
|
|
167
|
-
const digest = post.additionalContext?.match(/Premortem latest write sha256 ([a-f0-9]{64})/)?.[1];
|
|
168
|
-
if (!digest || !exactKeys(post.protocolKeys, ["hookSpecificOutput"])
|
|
169
|
-
|| !exactKeys(post.hookSpecificKeys, ["additionalContext", "hookEventName"])) {
|
|
170
|
-
throw new Error("installed BLUN PostToolUse did not return its latest-write digest through model context");
|
|
171
|
-
}
|
|
172
|
-
return { contextField: "additionalContext", latestWriteDigest: digest };
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function exactKeys(value, expected) {
|
|
176
|
-
return JSON.stringify(value) === JSON.stringify([...expected].sort());
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export async function invokeInstalledBlockingProtocols(pluginRoot, projectRoot, stateRoot) {
|
|
180
|
-
const writePayload = (host) => ({
|
|
181
|
-
hook_event_name: "PreToolUse", cwd: projectRoot, host,
|
|
182
|
-
project_id: "project:installed-protocol",
|
|
183
|
-
session_id: `session:installed-${host}-protocol`, tool_name: "Write",
|
|
184
|
-
tool_use_id: `tool:installed-${host}-protocol`,
|
|
185
|
-
tool_input: { file_path: "AGENTS.md", content: "synthetic\n" }
|
|
186
|
-
});
|
|
187
|
-
const claudePreTool = await invokeInstalledHook(
|
|
188
|
-
pluginRoot, projectRoot, stateRoot, "claude", writePayload("claude"), { requireBriefing: false }
|
|
189
|
-
);
|
|
190
|
-
const claudeStop = await invokeInstalledHook(pluginRoot, projectRoot, stateRoot, "claude", {
|
|
191
|
-
hook_event_name: "Stop", cwd: projectRoot, host: "claude",
|
|
192
|
-
project_id: "project:installed-protocol",
|
|
193
|
-
session_id: "session:installed-claude-stop-protocol",
|
|
194
|
-
agent_spine_exchange_directory: projectRoot,
|
|
195
|
-
final_assistant_message: "missing-installed-artifact.txt sha256 0000000000000000"
|
|
196
|
-
}, { requireBriefing: false });
|
|
197
|
-
const codexPreTool = await invokeInstalledHook(
|
|
198
|
-
pluginRoot, projectRoot, stateRoot, "codex", writePayload("codex"), { requireBriefing: false }
|
|
199
|
-
);
|
|
200
|
-
if (claudePreTool.decision !== null || claudePreTool.permissionDecision !== "deny"
|
|
201
|
-
|| !claudePreTool.permissionDecisionReason?.includes("protected source")
|
|
202
|
-
|| !exactKeys(claudePreTool.protocolKeys, ["hookSpecificOutput"])
|
|
203
|
-
|| !exactKeys(claudePreTool.hookSpecificKeys,
|
|
204
|
-
["hookEventName", "permissionDecision", "permissionDecisionReason"])) {
|
|
205
|
-
throw new Error("installed Claude PreToolUse denial did not use its nested permissionDecision schema");
|
|
206
|
-
}
|
|
207
|
-
if (claudeStop.decision !== null || claudeStop.permissionDecision !== null) {
|
|
208
|
-
throw new Error("installed Claude Stop must not block replies for artifact evidence");
|
|
209
|
-
}
|
|
210
|
-
if (codexPreTool.decision !== "block" || !codexPreTool.reason?.includes("protected source")
|
|
211
|
-
|| codexPreTool.permissionDecision !== null
|
|
212
|
-
|| !exactKeys(codexPreTool.protocolKeys, ["decision", "reason"])) {
|
|
213
|
-
const observed = {
|
|
214
|
-
decision: codexPreTool.decision, reason: codexPreTool.reason,
|
|
215
|
-
protocolKeys: codexPreTool.protocolKeys, hookSpecificKeys: codexPreTool.hookSpecificKeys,
|
|
216
|
-
permissionDecision: codexPreTool.permissionDecision,
|
|
217
|
-
sourceResolution: codexPreTool.sourceResolution, preflight: codexPreTool.preflight,
|
|
218
|
-
selfstarter: codexPreTool.selfstarter
|
|
219
|
-
};
|
|
220
|
-
throw new Error("installed Codex denial did not preserve its strict top-level decision/reason schema: "
|
|
221
|
-
+ JSON.stringify(observed).slice(0, 8192));
|
|
222
|
-
}
|
|
223
|
-
return {
|
|
224
|
-
claude: { preTool: "nested-permission-deny", stop: "advisory" },
|
|
225
|
-
codex: { preTool: "top-level-block" }
|
|
226
|
-
};
|
|
227
|
-
}
|