blun-king-cli 9.1.642 → 9.1.644
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/LIESMICH.txt +18 -0
- package/README.md +20 -6
- 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 +78 -193
- package/bundled-agent-sources.json +1 -552
- package/package.json +4 -6
- package/tool-liveness642/index.cjs +7 -0
- package/tool-liveness642/queue-delivery.cjs +109 -0
- package/tool-liveness642/receipt.json +40 -0
- package/tool-liveness642/shell-yield.cjs +43 -0
- package/tool-liveness642/task-wait.cjs +45 -0
- package/versionierung/BELEG.json +43 -0
- package/versionierung/LIESMICH.md +5 -0
- package/versionierung/urspruenglicher-overlay-beleg.json +39 -0
- package/worker-host.mjs +48 -128
- 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,355 +0,0 @@
|
|
|
1
|
-
import { runAudit } from "./audit.js";
|
|
2
|
-
import {
|
|
3
|
-
attentionContext, configureAttention, deleteAttention,
|
|
4
|
-
recordActivity, resolveAttention, upsertAttention
|
|
5
|
-
} from "./attention.js";
|
|
6
|
-
import { sessionBriefing } from "./briefing.js";
|
|
7
|
-
import { deliveryKnowledgeQuery } from "./delivery-knowledge.js";
|
|
8
|
-
import { advisoryDeliveryUse } from "./hook-briefing-use.js";
|
|
9
|
-
import { recordDeliveryBriefingUse, recordDeliveryKnowledgeUse,
|
|
10
|
-
verifyDeliveryAgentUse } from "./delivery-agent-usage.js";
|
|
11
|
-
import { scanAndSave, verifyCatalog } from "./catalog.js";
|
|
12
|
-
import { checkDelegation, createTask, taskContext, updateTask } from "./coordination.js";
|
|
13
|
-
import { readDocument, resolveContext } from "./context.js";
|
|
14
|
-
import { recordDeliveryPremortem } from "./delivery-premortem.js";
|
|
15
|
-
import { recoverDeliveryPremortem } from "./delivery-premortem-correction.js";
|
|
16
|
-
import { completeDelivery } from "./mcp-delivery-completion.js";
|
|
17
|
-
import {
|
|
18
|
-
annotateDocument, linkDocuments, linkEntities,
|
|
19
|
-
relationshipContext, upsertEntity
|
|
20
|
-
} from "./graph.js";
|
|
21
|
-
import {
|
|
22
|
-
addLearningEvidence, configureLearning, deleteLearning, evaluateLearning,
|
|
23
|
-
learningContext, learningOutcomeStatus, proposeLearning, reviewLearning, rollbackLearning
|
|
24
|
-
} from "./learning.js";
|
|
25
|
-
import { sharedContext } from "./sharing.js";
|
|
26
|
-
import { recordWorldAssertion, worldContext } from "./world-model.js";
|
|
27
|
-
import { indexSessionTimeline, searchSessionTimeline } from "./session-timeline.js";
|
|
28
|
-
import { captureSessionTimelineEvidence } from "./timeline-world-capture.js";
|
|
29
|
-
import { gatewayEnvironmentContext } from "./hook-context.js";
|
|
30
|
-
import {
|
|
31
|
-
timelineInvocationInput, timelineInvocationRequest
|
|
32
|
-
} from "./mcp-timeline-tools.js";
|
|
33
|
-
import { sessionTimelineBinding } from "./session-timeline-contract.js";
|
|
34
|
-
import { timelineTransportDigest } from "./session-timeline-transport.js";
|
|
35
|
-
import { runtimeHostForTimeline, timelineHostHome } from "./session-timeline-provider.js";
|
|
36
|
-
import { boundBriefingArguments, rejectInternalSourceArguments, resolveMcpSources } from "./mcp-source-context.js";
|
|
37
|
-
import { evaluateAutonomyAction, projectPortfolioContext, recordProjectObservation } from "./autonomy.js";
|
|
38
|
-
|
|
39
|
-
function textResult(value, isError = false) {
|
|
40
|
-
return { content: [{ type: "text", text: JSON.stringify(value, null, 2) }], isError };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function timelineTransport(input, root, environment) {
|
|
44
|
-
const { scope } = input;
|
|
45
|
-
const host = input.request.host || "claude";
|
|
46
|
-
return { scope, host, transportDigest: timelineTransportDigest({ root,
|
|
47
|
-
binding: sessionTimelineBinding({ host, sessionId: input.request.sessionId, scope }), environment }) };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function absent(value) { return value === undefined || value === null || value === ""; }
|
|
51
|
-
|
|
52
|
-
function gatewayWorldRoute(environment) {
|
|
53
|
-
const gateway = gatewayEnvironmentContext(environment);
|
|
54
|
-
return gateway?.portalRef && gateway?.threadRef ? gateway : null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function exactGatewayValue(args, key, value) {
|
|
58
|
-
if (!absent(args[key]) && args[key] !== value) {
|
|
59
|
-
throw new Error(`${key} does not match the authenticated gateway binding`);
|
|
60
|
-
}
|
|
61
|
-
return value ?? null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function boundGatewayBriefing(args, gateway) {
|
|
65
|
-
if (!gateway) return args;
|
|
66
|
-
const result = { ...args, portalRef: gateway.portalRef, threadRef: gateway.threadRef };
|
|
67
|
-
for (const [key, gatewayKey] of [["host", "host"], ["entityId", "entityId"],
|
|
68
|
-
["projectId", "projectId"], ["groupId", "groupId"], ["currentTaskId", "taskId"]]) {
|
|
69
|
-
result[key] = exactGatewayValue(args, key, gateway[gatewayKey]);
|
|
70
|
-
}
|
|
71
|
-
if (result.groupId && result.includePrivate) {
|
|
72
|
-
throw new Error("private briefing context cannot be requested from an authenticated group route");
|
|
73
|
-
}
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function boundWorldWrite(args, environment) {
|
|
78
|
-
if (Object.hasOwn(args, "portalRef") || Object.hasOwn(args, "threadRef")) {
|
|
79
|
-
throw new Error("portal and thread references are supplied only by the authenticated gateway");
|
|
80
|
-
}
|
|
81
|
-
const gateway = gatewayWorldRoute(environment);
|
|
82
|
-
if (!gateway || !args.knowledgeKind || args.subjectId !== gateway.taskId) return args;
|
|
83
|
-
const projectId = exactGatewayValue(args, "projectId", gateway.projectId);
|
|
84
|
-
const groupId = exactGatewayValue(args, "groupId", gateway.groupId);
|
|
85
|
-
if (groupId && args.privacy !== "group") {
|
|
86
|
-
throw new Error("task knowledge from an authenticated group route requires group privacy");
|
|
87
|
-
}
|
|
88
|
-
if (!groupId && args.privacy === "group") {
|
|
89
|
-
throw new Error("group task knowledge requires an authenticated group route");
|
|
90
|
-
}
|
|
91
|
-
return { ...args, projectId, groupId, portalRef: gateway.portalRef, threadRef: gateway.threadRef };
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function boundWorldRead(args, environment) {
|
|
95
|
-
if (Object.hasOwn(args, "portalRef") || Object.hasOwn(args, "threadRef")) {
|
|
96
|
-
throw new Error("portal and thread references are supplied only by the authenticated gateway");
|
|
97
|
-
}
|
|
98
|
-
const gateway = gatewayWorldRoute(environment);
|
|
99
|
-
if (!gateway) return args;
|
|
100
|
-
if (args.continuationTaskId && gateway.taskId && args.continuationTaskId !== gateway.taskId) {
|
|
101
|
-
throw new Error("continuationTaskId does not match the authenticated gateway task");
|
|
102
|
-
}
|
|
103
|
-
const projectId = exactGatewayValue(args, "projectId", gateway.projectId);
|
|
104
|
-
const groupId = exactGatewayValue(args, "groupId", gateway.groupId);
|
|
105
|
-
if (groupId && args.includePrivate) {
|
|
106
|
-
throw new Error("private world context cannot be requested from an authenticated group route");
|
|
107
|
-
}
|
|
108
|
-
return { ...args, projectId, groupId, portalRef: gateway.portalRef, threadRef: gateway.threadRef,
|
|
109
|
-
continuationTaskId: args.continuationTaskId ?? gateway.taskId };
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// The MCP process can outlive a host turn. A group claim that appears after a
|
|
113
|
-
// private permit was issued must therefore suppress consumption here as well
|
|
114
|
-
// as in PreToolUse; tool arguments cannot clear an authenticated environment.
|
|
115
|
-
function runtimeTimelineGroup(environment, input) {
|
|
116
|
-
try {
|
|
117
|
-
const gateway = gatewayEnvironmentContext(environment);
|
|
118
|
-
return Boolean(input?.groupClaim) || !absent(environment?.AGENTSPINE_GROUP_ID) || !absent(gateway?.groupId);
|
|
119
|
-
} catch {
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function runtimeGatewayMatchesTimeline(environment, scope, host) {
|
|
125
|
-
let gateway;
|
|
126
|
-
try { gateway = gatewayEnvironmentContext(environment); }
|
|
127
|
-
catch { return false; }
|
|
128
|
-
if (!gateway) return true;
|
|
129
|
-
if (!absent(gateway.groupId)) return false;
|
|
130
|
-
const claims = [
|
|
131
|
-
[gateway.host, runtimeHostForTimeline(host)], [gateway.entityId, scope.entityId], [gateway.projectId, scope.projectId],
|
|
132
|
-
[gateway.taskId, scope.currentTaskId], [gateway.goalId, scope.goalId], [gateway.goalStepId, scope.goalStepId]
|
|
133
|
-
];
|
|
134
|
-
if (!claims.every(([actual, expected]) => actual === expected)) return false;
|
|
135
|
-
// Gateway context predates these two claims. In an authenticated gateway
|
|
136
|
-
// process, accepting an unverifiable user or tenant would let a stale private
|
|
137
|
-
// permit cross a newly selected identity, so their canonical env claims are
|
|
138
|
-
// deliberately mandatory until the gateway context carries them itself.
|
|
139
|
-
return environment?.AGENTSPINE_USER_ID === scope.userId
|
|
140
|
-
&& environment?.AGENTSPINE_TENANT_ID === scope.tenantId;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function unavailableTimelineInvocation(reason) {
|
|
144
|
-
return { status: "unavailable", reason, authority: "context-only" };
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async function callTool(name, args = {}, environment = process.env) {
|
|
148
|
-
const root = args.root || process.cwd();
|
|
149
|
-
if (name === "scan") return textResult(await scanAndSave(root));
|
|
150
|
-
if (name === "resolve_context") {
|
|
151
|
-
rejectInternalSourceArguments(args);
|
|
152
|
-
const sources = await resolveMcpSources({ root, cwd: args.cwd || root, host: args.host });
|
|
153
|
-
return textResult(await resolveContext({
|
|
154
|
-
root,
|
|
155
|
-
cwd: args.cwd || root,
|
|
156
|
-
host: sources.host,
|
|
157
|
-
maxBytes: args.maxBytes ?? 65536,
|
|
158
|
-
includeContent: args.includeContent ?? true,
|
|
159
|
-
catalog: sources.catalog
|
|
160
|
-
}));
|
|
161
|
-
}
|
|
162
|
-
if (name === "session_briefing") {
|
|
163
|
-
const gateway = gatewayWorldRoute(environment);
|
|
164
|
-
const scoped = boundGatewayBriefing(await boundBriefingArguments({ ...args, root }), gateway);
|
|
165
|
-
const sources = await resolveMcpSources({ ...scoped, required: Boolean(args.requirementId) });
|
|
166
|
-
const briefing = await sessionBriefing({ ...scoped, host: sources.host,
|
|
167
|
-
catalog: sources.catalog, userStateRoot: sources.userStateRoot, sourceDiagnostics: sources.diagnostics });
|
|
168
|
-
if (!args.requirementId) return textResult(briefing);
|
|
169
|
-
const receipt = await recordDeliveryBriefingUse({ root,
|
|
170
|
-
requirementId: args.requirementId, input: args, result: briefing });
|
|
171
|
-
return textResult({ ...briefing, deliveryUseReceipt: advisoryDeliveryUse(receipt) });
|
|
172
|
-
}
|
|
173
|
-
if (name === "delivery_knowledge_query") {
|
|
174
|
-
rejectInternalSourceArguments(args);
|
|
175
|
-
const knowledge = await deliveryKnowledgeQuery({ ...args, root });
|
|
176
|
-
if (knowledge.blocked) return textResult(knowledge, true);
|
|
177
|
-
const receipt = await recordDeliveryKnowledgeUse({ root,
|
|
178
|
-
requirementId: args.requirementId, input: args, result: knowledge });
|
|
179
|
-
return textResult({ ...knowledge, deliveryUseReceipt: advisoryDeliveryUse(receipt) });
|
|
180
|
-
}
|
|
181
|
-
if (name === "read_document") {
|
|
182
|
-
rejectInternalSourceArguments(args);
|
|
183
|
-
const sources = await resolveMcpSources({ root, host: args.host });
|
|
184
|
-
return textResult(await readDocument({
|
|
185
|
-
root, path: args.path, offset: args.offset ?? 0, length: args.length ?? 65536,
|
|
186
|
-
catalog: sources.catalog
|
|
187
|
-
}));
|
|
188
|
-
}
|
|
189
|
-
if (name === "verify") return textResult(await verifyCatalog(root));
|
|
190
|
-
if (name === "link_documents") return textResult(await linkDocuments({ ...args, root }));
|
|
191
|
-
if (name === "annotate_document") return textResult(await annotateDocument({ ...args, root }));
|
|
192
|
-
if (name === "upsert_entity") return textResult(await upsertEntity({ ...args, root }));
|
|
193
|
-
if (name === "link_entities") return textResult(await linkEntities({ ...args, root }));
|
|
194
|
-
if (name === "relationship_context") return textResult(await relationshipContext({ ...args, root }));
|
|
195
|
-
if (name === "upsert_attention") return textResult(await upsertAttention({ ...args, root }));
|
|
196
|
-
if (name === "record_activity") return textResult(await recordActivity({ ...args, root }));
|
|
197
|
-
if (name === "attention_context") return textResult(await attentionContext({ ...args, root }));
|
|
198
|
-
if (name === "resolve_attention") return textResult(await resolveAttention({ ...args, root }));
|
|
199
|
-
if (name === "configure_attention") return textResult(await configureAttention({ ...args, root }));
|
|
200
|
-
if (name === "delete_attention") return textResult(await deleteAttention({ ...args, root }));
|
|
201
|
-
if (name === "propose_learning") return textResult(await proposeLearning({ ...args, root }));
|
|
202
|
-
if (name === "add_learning_evidence") return textResult(await addLearningEvidence({ ...args, root }));
|
|
203
|
-
if (name === "review_learning") return textResult(await reviewLearning({ ...args, root }));
|
|
204
|
-
if (name === "learning_context") return textResult(await learningContext({ ...args, root }));
|
|
205
|
-
if (name === "learning_outcome_status") return textResult(await learningOutcomeStatus({ ...args, root }));
|
|
206
|
-
if (name === "evaluate_learning") return textResult(await evaluateLearning({ ...args, root }));
|
|
207
|
-
if (name === "rollback_learning") return textResult(await rollbackLearning({ ...args, root }));
|
|
208
|
-
if (name === "configure_learning") return textResult(await configureLearning({ ...args, root }));
|
|
209
|
-
if (name === "delete_learning") return textResult(await deleteLearning({ ...args, root }));
|
|
210
|
-
if (name === "check_delegation") return textResult(await checkDelegation({ ...args, root }));
|
|
211
|
-
if (name === "create_task") return textResult(await createTask({ ...args, root }));
|
|
212
|
-
if (name === "update_task") return textResult(await updateTask({ ...args, root }));
|
|
213
|
-
if (name === "task_context") return textResult(await taskContext({ ...args, root }));
|
|
214
|
-
if (name === "shared_context") return textResult(await sharedContext({ ...args, root }));
|
|
215
|
-
if (name === "record_world_assertion") {
|
|
216
|
-
return textResult(await recordWorldAssertion({ ...boundWorldWrite(args, environment), root }));
|
|
217
|
-
}
|
|
218
|
-
if (name === "world_context") {
|
|
219
|
-
return textResult(await worldContext({ ...boundWorldRead(args, environment), root }));
|
|
220
|
-
}
|
|
221
|
-
if (name === "project_portfolio") return textResult(await projectPortfolioContext({ ...args, root }));
|
|
222
|
-
if (name === "record_project_observation") return textResult(await recordProjectObservation({ ...args, root }));
|
|
223
|
-
if (name === "evaluate_autonomy_action") return textResult(await evaluateAutonomyAction({ ...args, root }));
|
|
224
|
-
if (name === "session_timeline_index") {
|
|
225
|
-
const input = timelineInvocationInput(args);
|
|
226
|
-
if (runtimeTimelineGroup(environment, input)) return textResult(unavailableTimelineInvocation("timeline-group-suppressed"));
|
|
227
|
-
if (!input.valid) return textResult(unavailableTimelineInvocation(input.reason || "timeline-scope-invalid"));
|
|
228
|
-
const timeline = timelineTransport(input, root, environment);
|
|
229
|
-
if (!runtimeGatewayMatchesTimeline(environment, timeline.scope, timeline.host)) {
|
|
230
|
-
return textResult(unavailableTimelineInvocation("timeline-gateway-binding-mismatch"));
|
|
231
|
-
}
|
|
232
|
-
const invocationRequest = timelineInvocationRequest("index", args, root);
|
|
233
|
-
if (!invocationRequest) return textResult(unavailableTimelineInvocation("timeline-invocation-unavailable"));
|
|
234
|
-
return textResult(await indexSessionTimeline({ root, host: timeline.host, sessionId: input.request.sessionId, scope: timeline.scope,
|
|
235
|
-
maxBytes: args.maxBytes, enrollmentDigest: input.request.enrollmentDigest,
|
|
236
|
-
hostHome: timelineHostHome(timeline.host, environment), transportDigest: timeline.transportDigest, invocationRequest }));
|
|
237
|
-
}
|
|
238
|
-
if (name === "session_timeline_search") {
|
|
239
|
-
const input = timelineInvocationInput(args);
|
|
240
|
-
if (runtimeTimelineGroup(environment, input)) return textResult(unavailableTimelineInvocation("timeline-group-suppressed"));
|
|
241
|
-
if (!input.valid) return textResult(unavailableTimelineInvocation(input.reason || "timeline-scope-invalid"));
|
|
242
|
-
const timeline = timelineTransport(input, root, environment);
|
|
243
|
-
if (!runtimeGatewayMatchesTimeline(environment, timeline.scope, timeline.host)) {
|
|
244
|
-
return textResult(unavailableTimelineInvocation("timeline-gateway-binding-mismatch"));
|
|
245
|
-
}
|
|
246
|
-
const invocationRequest = timelineInvocationRequest("search", args, root);
|
|
247
|
-
if (!invocationRequest) return textResult(unavailableTimelineInvocation("timeline-invocation-unavailable"));
|
|
248
|
-
return textResult(await searchSessionTimeline({ root, host: timeline.host, sessionId: input.request.sessionId, scope: timeline.scope,
|
|
249
|
-
at: args.at, query: args.query, windowSeconds: args.windowSeconds, includePriorSessions: args.includePriorSessions,
|
|
250
|
-
includePriorProviders: args.includePriorProviders, environment,
|
|
251
|
-
enrollmentDigest: input.request.enrollmentDigest,
|
|
252
|
-
hostHome: timelineHostHome(timeline.host, environment), transportDigest: timeline.transportDigest,
|
|
253
|
-
invocationRequest }));
|
|
254
|
-
}
|
|
255
|
-
if (name === "session_timeline_capture") {
|
|
256
|
-
const input = timelineInvocationInput(args);
|
|
257
|
-
if (runtimeTimelineGroup(environment, input)) return textResult(unavailableTimelineInvocation("timeline-group-suppressed"));
|
|
258
|
-
if (!input.valid) return textResult(unavailableTimelineInvocation(input.reason || "timeline-scope-invalid"));
|
|
259
|
-
const timeline = timelineTransport(input, root, environment);
|
|
260
|
-
if (!runtimeGatewayMatchesTimeline(environment, timeline.scope, timeline.host)) {
|
|
261
|
-
return textResult(unavailableTimelineInvocation("timeline-gateway-binding-mismatch"));
|
|
262
|
-
}
|
|
263
|
-
const invocationRequest = timelineInvocationRequest("capture", args, root);
|
|
264
|
-
if (!invocationRequest) return textResult(unavailableTimelineInvocation("timeline-invocation-unavailable"));
|
|
265
|
-
return textResult(await captureSessionTimelineEvidence({ root, host: timeline.host,
|
|
266
|
-
sessionId: input.request.sessionId, scope: timeline.scope, eventId: args.eventId,
|
|
267
|
-
at: args.at, query: args.query, windowSeconds: args.windowSeconds,
|
|
268
|
-
includePriorSessions: args.includePriorSessions, includePriorProviders: args.includePriorProviders,
|
|
269
|
-
interpretation: args.interpretation ?? null,
|
|
270
|
-
environment, enrollmentDigest: input.request.enrollmentDigest,
|
|
271
|
-
hostHome: timelineHostHome(timeline.host, environment), transportDigest: timeline.transportDigest,
|
|
272
|
-
invocationRequest }));
|
|
273
|
-
}
|
|
274
|
-
if (name === "audit") return textResult(await runAudit(root));
|
|
275
|
-
if (name === "complete_delivery") {
|
|
276
|
-
const completed = await completeDelivery(args);
|
|
277
|
-
return textResult(completed, completed.blocked || completed.status === "degraded");
|
|
278
|
-
}
|
|
279
|
-
if (name === "record_delivery_premortem") {
|
|
280
|
-
if (typeof args.root !== "string" || !args.root) {
|
|
281
|
-
throw new Error("record_delivery_premortem requires the exact project root");
|
|
282
|
-
}
|
|
283
|
-
const usage = await verifyDeliveryAgentUse({ root: args.root,
|
|
284
|
-
requirementId: args.requirementId });
|
|
285
|
-
if (usage.status === "mismatch") return textResult(usage, true);
|
|
286
|
-
if (usage.blocked || usage.status === "degraded") return textResult({ status: "unverified",
|
|
287
|
-
blocked: false, items: args.items, agentSpineUse: advisoryDeliveryUse(usage),
|
|
288
|
-
completionVerified: false, automaticRetry: false });
|
|
289
|
-
const premortem = await recordDeliveryPremortem({
|
|
290
|
-
root: args.root,
|
|
291
|
-
requirementId: args.requirementId,
|
|
292
|
-
items: args.items
|
|
293
|
-
});
|
|
294
|
-
return textResult({ ...premortem, agentSpineUse: usage }, premortem.blocked);
|
|
295
|
-
}
|
|
296
|
-
if (name === "recover_delivery_premortem") {
|
|
297
|
-
if (typeof args.root !== "string" || !args.root) {
|
|
298
|
-
throw new Error("recover_delivery_premortem requires the exact project root");
|
|
299
|
-
}
|
|
300
|
-
const recovery = await recoverDeliveryPremortem({ root: args.root,
|
|
301
|
-
predecessorRequirementId: args.predecessorRequirementId,
|
|
302
|
-
taskId: args.taskId || null });
|
|
303
|
-
return textResult(recovery, recovery.blocked);
|
|
304
|
-
}
|
|
305
|
-
throw new Error(`Unknown tool: ${name}`);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
async function dispatch(message, tools, version, environment) {
|
|
309
|
-
const { id, method, params = {} } = message;
|
|
310
|
-
if (method === "initialize") {
|
|
311
|
-
return {
|
|
312
|
-
jsonrpc: "2.0", id,
|
|
313
|
-
result: {
|
|
314
|
-
protocolVersion: params.protocolVersion || "2025-06-18",
|
|
315
|
-
capabilities: { tools: { listChanged: false } },
|
|
316
|
-
serverInfo: { name: "agent-spine", version }
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
if (method === "ping") return { jsonrpc: "2.0", id, result: {} };
|
|
321
|
-
if (method === "tools/list") return { jsonrpc: "2.0", id, result: { tools } };
|
|
322
|
-
if (method === "tools/call") {
|
|
323
|
-
try {
|
|
324
|
-
return { jsonrpc: "2.0", id, result: await callTool(params.name, params.arguments, environment) };
|
|
325
|
-
} catch (error) {
|
|
326
|
-
return { jsonrpc: "2.0", id, result: textResult({ error: error.message }, true) };
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
if (method?.startsWith("notifications/")) return null;
|
|
330
|
-
return { jsonrpc: "2.0", id, error: { code: -32601, message: `Method not found: ${method}` } };
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export function startMcpProtocol({ input, output, tools, version, environment = process.env }) {
|
|
334
|
-
input.setEncoding("utf8");
|
|
335
|
-
let buffer = "";
|
|
336
|
-
let queue = Promise.resolve();
|
|
337
|
-
input.on("data", (chunk) => {
|
|
338
|
-
buffer += chunk;
|
|
339
|
-
let newline;
|
|
340
|
-
while ((newline = buffer.indexOf("\n")) >= 0) {
|
|
341
|
-
const line = buffer.slice(0, newline).trim();
|
|
342
|
-
buffer = buffer.slice(newline + 1);
|
|
343
|
-
if (!line) continue;
|
|
344
|
-
queue = queue.then(async () => {
|
|
345
|
-
let response;
|
|
346
|
-
try {
|
|
347
|
-
response = await dispatch(JSON.parse(line), tools, version, environment);
|
|
348
|
-
} catch (error) {
|
|
349
|
-
response = { jsonrpc: "2.0", id: null, error: { code: -32700, message: error.message } };
|
|
350
|
-
}
|
|
351
|
-
if (response) output.write(`${JSON.stringify(response)}\n`);
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { canonicalPath, isInside } from "./paths.js";
|
|
2
|
-
import { resolveHostSourceCatalog } from "./source-roots.js";
|
|
3
|
-
import { inspectPremortemState } from "./delivery-premortem.js";
|
|
4
|
-
|
|
5
|
-
const INTERNAL = new Set(["catalog", "userStateRoot", "sourceDiagnostics", "sourceRegistry",
|
|
6
|
-
"env", "input", "memoryHooks", "resolvedSources", "portalRef", "threadRef"]);
|
|
7
|
-
|
|
8
|
-
export function rejectInternalSourceArguments(args) {
|
|
9
|
-
for (const key of INTERNAL) {
|
|
10
|
-
if (Object.hasOwn(args, key)) throw new Error(`unsupported internal source argument: ${key}`);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export async function boundBriefingArguments(args) {
|
|
15
|
-
rejectInternalSourceArguments(args);
|
|
16
|
-
if (!args.requirementId) return args;
|
|
17
|
-
const current = await inspectPremortemState({ root: args.root, requirementId: args.requirementId });
|
|
18
|
-
if (current.blocked || current.status === "degraded" || !current.binding) {
|
|
19
|
-
throw new Error("delivery source binding is unavailable; no briefing receipt issued");
|
|
20
|
-
}
|
|
21
|
-
const result = { ...args };
|
|
22
|
-
for (const [key, field] of [["host", "host"], ["entityId", "entityId"],
|
|
23
|
-
["projectId", "projectId"], ["groupId", "groupId"], ["currentTaskId", "taskId"]]) {
|
|
24
|
-
const expected = current.binding[field];
|
|
25
|
-
if (Object.hasOwn(args, key) && args[key] !== expected) {
|
|
26
|
-
throw new Error(`delivery source ${key} does not match its requirement`);
|
|
27
|
-
}
|
|
28
|
-
result[key] = expected;
|
|
29
|
-
}
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export async function resolveMcpSources({ root, cwd = root,
|
|
34
|
-
host, entityId = null,
|
|
35
|
-
groupId = null, projectId = null, currentTaskId = null, required = false }) {
|
|
36
|
-
const blunHost = Boolean(process.env.BLUN_HOME && process.env.BLUN_PLUGIN_ROOT);
|
|
37
|
-
const runtimeHost = blunHost && process.env.AGENTSPINE_HOST === "blun"
|
|
38
|
-
? "codex" : process.env.AGENTSPINE_HOST;
|
|
39
|
-
const selectedHost = host === undefined ? runtimeHost : host;
|
|
40
|
-
// King binds both values when loading this plugin; model arguments cannot
|
|
41
|
-
// switch that running host to another application's private profile.
|
|
42
|
-
if (blunHost && selectedHost !== undefined && selectedHost !== "codex") {
|
|
43
|
-
throw new Error("MCP source host does not match the running BLUN host");
|
|
44
|
-
}
|
|
45
|
-
host = blunHost ? "codex" : (host === undefined ? process.env.AGENTSPINE_HOST || "generic" : host);
|
|
46
|
-
const canonicalRoot = await canonicalPath(root);
|
|
47
|
-
const canonicalCwd = await canonicalPath(cwd);
|
|
48
|
-
if (!isInside(canonicalRoot, canonicalCwd)) throw new Error("MCP cwd must remain inside its root");
|
|
49
|
-
// Only the process environment and the locally read registry select sources.
|
|
50
|
-
// No MCP-provided catalog, registry, profile, or state location enters here.
|
|
51
|
-
const sources = await resolveHostSourceCatalog({ host, cwd: canonicalCwd,
|
|
52
|
-
input: { agent_spine_scope: { entity_id: entityId, group_id: groupId,
|
|
53
|
-
project_id: projectId, task_id: currentTaskId } } });
|
|
54
|
-
if (sources.projectRoot !== canonicalRoot) {
|
|
55
|
-
throw new Error("MCP root differs from the resolved host project root");
|
|
56
|
-
}
|
|
57
|
-
if (required && (sources.diagnostics.incomplete || sources.diagnostics.skipped.length)) {
|
|
58
|
-
throw new Error("MCP source discovery is incomplete; no delivery receipt issued");
|
|
59
|
-
}
|
|
60
|
-
return sources;
|
|
61
|
-
}
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { TIMELINE_HOSTS } from "./session-timeline-provider.js";
|
|
2
|
-
|
|
3
|
-
const stableId = {
|
|
4
|
-
type: "string",
|
|
5
|
-
pattern: "^[A-Za-z0-9][A-Za-z0-9:_.@/-]{0,127}$"
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const optionalId = { anyOf: [stableId, { type: "null" }] };
|
|
9
|
-
const assertionId = {
|
|
10
|
-
type: "string",
|
|
11
|
-
pattern: "^assertion:[A-Za-z0-9][A-Za-z0-9._/-]{0,190}$"
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const TIMELINE_INTERPRETATION_SCHEMA = "agentspine.timeline-user-feedback-interpretation-request/v1";
|
|
15
|
-
export const TIMELINE_CLARIFICATION_SCHEMA = "agentspine.timeline-user-feedback-clarification-request/v2";
|
|
16
|
-
const INTERPRETATION_KINDS = new Set([
|
|
17
|
-
"next-step-correction", "completion-claim", "not-current-instruction", "ambiguous"
|
|
18
|
-
]);
|
|
19
|
-
|
|
20
|
-
export function timelineInterpretationRequest(value) {
|
|
21
|
-
if (!value || typeof value !== "object" || Array.isArray(value)
|
|
22
|
-
|| Object.getPrototypeOf(value) !== Object.prototype) return null;
|
|
23
|
-
const clarificationKeys = ["schema", "feedbackAssertionIds", "targetAssertionId", "clarificationQuestion"];
|
|
24
|
-
if (Object.keys(value).sort().join("\0") === clarificationKeys.sort().join("\0")
|
|
25
|
-
&& value.schema === TIMELINE_CLARIFICATION_SCHEMA
|
|
26
|
-
&& Array.isArray(value.feedbackAssertionIds) && value.feedbackAssertionIds.length >= 2
|
|
27
|
-
&& value.feedbackAssertionIds.length <= 3
|
|
28
|
-
&& value.feedbackAssertionIds.every((id) => /^assertion:[A-Za-z0-9][A-Za-z0-9._/-]{0,190}$/.test(id))
|
|
29
|
-
&& new Set(value.feedbackAssertionIds).size === value.feedbackAssertionIds.length
|
|
30
|
-
&& [...value.feedbackAssertionIds].sort().every((id, index) => id === value.feedbackAssertionIds[index])
|
|
31
|
-
&& /^assertion:[A-Za-z0-9][A-Za-z0-9._/-]{0,190}$/.test(value.targetAssertionId || "")
|
|
32
|
-
&& typeof value.clarificationQuestion === "string" && Boolean(value.clarificationQuestion.trim())
|
|
33
|
-
&& value.clarificationQuestion.length <= 300 && !/[\r\n]/u.test(value.clarificationQuestion)) {
|
|
34
|
-
return structuredClone(value);
|
|
35
|
-
}
|
|
36
|
-
const keys = ["schema", "feedbackAssertionId", "targetAssertionId", "kind",
|
|
37
|
-
"proposedNextStepSummary", "clarificationQuestion"];
|
|
38
|
-
if (Object.keys(value).sort().join("\0") !== keys.sort().join("\0")
|
|
39
|
-
|| value.schema !== TIMELINE_INTERPRETATION_SCHEMA
|
|
40
|
-
|| !/^assertion:[A-Za-z0-9][A-Za-z0-9._/-]{0,190}$/.test(value.feedbackAssertionId || "")
|
|
41
|
-
|| !/^assertion:[A-Za-z0-9][A-Za-z0-9._/-]{0,190}$/.test(value.targetAssertionId || "")
|
|
42
|
-
|| !INTERPRETATION_KINDS.has(value.kind)) return null;
|
|
43
|
-
const next = value.proposedNextStepSummary;
|
|
44
|
-
const question = value.clarificationQuestion;
|
|
45
|
-
const validNext = typeof next === "string" && Boolean(next.trim())
|
|
46
|
-
&& next.length <= 500 && !/[\r\n]/u.test(next);
|
|
47
|
-
const validQuestion = typeof question === "string" && Boolean(question.trim())
|
|
48
|
-
&& question.length <= 300 && !/[\r\n]/u.test(question);
|
|
49
|
-
if ((value.kind === "next-step-correction" ? !validNext || question !== null
|
|
50
|
-
: next !== null || (value.kind === "ambiguous" ? !validQuestion : question !== null))) return null;
|
|
51
|
-
return structuredClone(value);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export const AGENTSPINE_TIMELINE_TOOL_PREFIX = "mcp__plugin_agent-spine_agent-spine__";
|
|
55
|
-
export const BLUN_TIMELINE_TOOL_PREFIX = "mcp__agent-spine__";
|
|
56
|
-
|
|
57
|
-
const TIMELINE_TOOL_PREFIXES = [
|
|
58
|
-
AGENTSPINE_TIMELINE_TOOL_PREFIX,
|
|
59
|
-
BLUN_TIMELINE_TOOL_PREFIX
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
const SCOPE_FIELDS = [
|
|
63
|
-
["entityId", ["entityId", "entity_id"]],
|
|
64
|
-
["userId", ["userId", "user_id"]],
|
|
65
|
-
["tenantId", ["tenantId", "tenant_id"]],
|
|
66
|
-
["projectId", ["projectId", "project_id"]],
|
|
67
|
-
["groupId", ["groupId", "group_id"]],
|
|
68
|
-
["currentTaskId", ["taskId", "task_id", "currentTaskId", "current_task_id"]],
|
|
69
|
-
["goalId", ["goalId", "goal_id"]],
|
|
70
|
-
["goalStepId", ["goalStepId", "goal_step_id"]],
|
|
71
|
-
["portalRef", ["portalRef", "portal_ref"]],
|
|
72
|
-
["threadRef", ["threadRef", "thread_ref"]],
|
|
73
|
-
["timelineVisibility", ["timelineVisibility", "timeline_visibility"]]
|
|
74
|
-
];
|
|
75
|
-
|
|
76
|
-
const REQUEST_FIELDS = [
|
|
77
|
-
["host", ["host"]],
|
|
78
|
-
["sessionId", ["sessionId", "session_id"]],
|
|
79
|
-
["enrollmentDigest", ["enrollmentDigest", "enrollment_digest"]]
|
|
80
|
-
];
|
|
81
|
-
|
|
82
|
-
function owns(value, key) {
|
|
83
|
-
return Boolean(value) && Object.prototype.hasOwnProperty.call(value, key);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function plainObject(value) {
|
|
87
|
-
return value && typeof value === "object" && !Array.isArray(value)
|
|
88
|
-
&& Object.getPrototypeOf(value) === Object.prototype;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function absent(value) { return value === undefined || value === null || value === ""; }
|
|
92
|
-
|
|
93
|
-
function containers(args) {
|
|
94
|
-
if (!plainObject(args)) return { valid: false, reason: "timeline-scope-invalid", values: [] };
|
|
95
|
-
if (!owns(args, "agent_spine_scope") || args.agent_spine_scope === null) {
|
|
96
|
-
return { valid: true, reason: null, values: [args] };
|
|
97
|
-
}
|
|
98
|
-
if (!plainObject(args.agent_spine_scope)) {
|
|
99
|
-
return { valid: false, reason: "timeline-scope-invalid", values: [args] };
|
|
100
|
-
}
|
|
101
|
-
return { valid: true, reason: null, values: [args, args.agent_spine_scope] };
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function claim(values, aliases) {
|
|
105
|
-
const supplied = values.flatMap((value) => aliases.filter((key) => owns(value, key)).map((key) => value[key]));
|
|
106
|
-
const present = supplied.filter((value) => !absent(value));
|
|
107
|
-
if (!present.length) return { valid: true, value: null, present: false };
|
|
108
|
-
if (present.some((value) => typeof value !== "string") || !present.every((value) => value === present[0])) {
|
|
109
|
-
return { valid: false, value: null, present: true };
|
|
110
|
-
}
|
|
111
|
-
return { valid: true, value: present[0], present: true };
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function validId(value) {
|
|
115
|
-
return value === null || (typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9:_.@/-]{0,127}$/.test(value));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function resolvedClaims(args) {
|
|
119
|
-
const nested = containers(args);
|
|
120
|
-
const values = nested.values;
|
|
121
|
-
const result = { valid: nested.valid, reason: nested.reason, groupClaim: false, scope: {}, request: {} };
|
|
122
|
-
for (const [field, aliases] of [...SCOPE_FIELDS, ...REQUEST_FIELDS]) {
|
|
123
|
-
const resolved = claim(values, aliases);
|
|
124
|
-
if (field === "groupId") result.groupClaim = resolved.present;
|
|
125
|
-
if (!resolved.valid || (field === "host" && resolved.value !== null && !TIMELINE_HOSTS.includes(resolved.value))
|
|
126
|
-
|| (field !== "timelineVisibility" && !validId(resolved.value))
|
|
127
|
-
|| (field === "timelineVisibility" && resolved.value !== null && resolved.value !== "private-verified")
|
|
128
|
-
|| (field === "enrollmentDigest" && resolved.value !== null && !/^[a-f0-9]{64}$/.test(resolved.value))) {
|
|
129
|
-
result.valid = false;
|
|
130
|
-
result.reason ||= "timeline-scope-conflict";
|
|
131
|
-
}
|
|
132
|
-
if (SCOPE_FIELDS.some(([name]) => name === field)) result.scope[field] = resolved.value;
|
|
133
|
-
else result.request[field] = resolved.value;
|
|
134
|
-
}
|
|
135
|
-
return result;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function timelineInvocationInput(args = {}) {
|
|
139
|
-
return resolvedClaims(args);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export function timelineScope(args = {}) {
|
|
143
|
-
return resolvedClaims(args).scope;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export function timelineToolKind(name) {
|
|
147
|
-
const qualified = String(name || "");
|
|
148
|
-
if (TIMELINE_TOOL_PREFIXES.some((prefix) => qualified === `${prefix}session_timeline_index`)) return "index";
|
|
149
|
-
if (TIMELINE_TOOL_PREFIXES.some((prefix) => qualified === `${prefix}session_timeline_search`)) return "search";
|
|
150
|
-
if (TIMELINE_TOOL_PREFIXES.some((prefix) => qualified === `${prefix}session_timeline_capture`)) return "capture";
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export function timelineInvocationRequest(tool, args, root) {
|
|
155
|
-
const input = resolvedClaims(args);
|
|
156
|
-
if (!input.valid || input.groupClaim || !input.request.sessionId) return null;
|
|
157
|
-
const scope = input.scope;
|
|
158
|
-
const request = { root, tool, sessionId: input.request.sessionId, entityId: scope.entityId, userId: scope.userId,
|
|
159
|
-
tenantId: scope.tenantId, projectId: scope.projectId, groupId: scope.groupId, taskId: scope.currentTaskId,
|
|
160
|
-
goalId: scope.goalId, goalStepId: scope.goalStepId, timelineVisibility: scope.timelineVisibility,
|
|
161
|
-
portalRef: scope.portalRef, threadRef: scope.threadRef,
|
|
162
|
-
enrollmentDigest: input.request.enrollmentDigest };
|
|
163
|
-
if (tool === "index") return { ...request, maxBytes: args.maxBytes ?? 4 * 1024 * 1024 };
|
|
164
|
-
return { ...request, ...(tool === "capture" ? { eventId: args.eventId ?? null,
|
|
165
|
-
interpretation: args.interpretation ?? null } : {}),
|
|
166
|
-
at: args.at ?? null, query: args.query ?? null,
|
|
167
|
-
windowSeconds: args.windowSeconds === undefined ? 0 : args.windowSeconds,
|
|
168
|
-
includePriorSessions: args.includePriorSessions === true,
|
|
169
|
-
includePriorProviders: args.includePriorProviders === true };
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const scopeProperties = {
|
|
173
|
-
host: { enum: TIMELINE_HOSTS },
|
|
174
|
-
entityId: stableId, userId: stableId, tenantId: stableId, projectId: stableId,
|
|
175
|
-
taskId: stableId, goalId: optionalId, goalStepId: optionalId,
|
|
176
|
-
portalRef: optionalId, threadRef: optionalId
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
export const sessionTimelineTools = [
|
|
180
|
-
{
|
|
181
|
-
name: "session_timeline_index",
|
|
182
|
-
description: "Index bounded evidence from one explicitly enrolled immutable provider transcript snapshot. Claude, Codex and King use separate format adapters; changed sources require a renewed host receipt and this tool never copies a transcript or grants authority.",
|
|
183
|
-
inputSchema: {
|
|
184
|
-
type: "object", additionalProperties: false,
|
|
185
|
-
required: [],
|
|
186
|
-
properties: { root: { type: "string", minLength: 1 }, sessionId: stableId, ...scopeProperties,
|
|
187
|
-
enrollmentDigest: { type: "string", pattern: "^[a-f0-9]{64}$" },
|
|
188
|
-
timelineVisibility: { const: "private-verified" }, groupId: { anyOf: [stableId, { type: "null" }] },
|
|
189
|
-
maxBytes: { type: "integer", minimum: 65536, maximum: 16777216 } }
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
name: "session_timeline_search",
|
|
194
|
-
description: "Search one enrolled immutable same-task source for objective evidence or strict user corrections. Query 'user message' explicitly selects bounded native user-message candidates without interpreting them; add exact UTC time to narrow. No source text is indexed. Cross-provider recall requires opt-in; one source is opened and no authority is granted.",
|
|
195
|
-
inputSchema: {
|
|
196
|
-
type: "object", additionalProperties: false,
|
|
197
|
-
required: [],
|
|
198
|
-
anyOf: [{ required: ["at"] }, { required: ["query"] }],
|
|
199
|
-
properties: { root: { type: "string", minLength: 1 }, sessionId: stableId, ...scopeProperties,
|
|
200
|
-
enrollmentDigest: { type: "string", pattern: "^[a-f0-9]{64}$" },
|
|
201
|
-
timelineVisibility: { const: "private-verified" }, groupId: { anyOf: [stableId, { type: "null" }] },
|
|
202
|
-
at: { type: "string", format: "date-time" }, query: { type: "string", minLength: 3, maxLength: 512 },
|
|
203
|
-
windowSeconds: { type: "integer", minimum: 0, maximum: 900 },
|
|
204
|
-
includePriorSessions: { type: "boolean" }, includePriorProviders: { type: "boolean" } }
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
name: "session_timeline_capture",
|
|
209
|
-
description: "Reopen one source-bound event. Objective fields become descriptive task state; strict prefixed corrections may replace the same-thread next step. Natural user messages remain uninterpreted beside their exact checkpoint. A second source-bound call may preserve one model interpretation as an unconfirmed proposal; it never changes continuation, proves completion or grants authority.",
|
|
210
|
-
inputSchema: {
|
|
211
|
-
type: "object", additionalProperties: false,
|
|
212
|
-
required: ["eventId"],
|
|
213
|
-
anyOf: [{ required: ["at"] }, { required: ["query"] }],
|
|
214
|
-
properties: { root: { type: "string", minLength: 1 }, sessionId: stableId, ...scopeProperties,
|
|
215
|
-
enrollmentDigest: { type: "string", pattern: "^[a-f0-9]{64}$" },
|
|
216
|
-
timelineVisibility: { const: "private-verified" }, groupId: { anyOf: [stableId, { type: "null" }] },
|
|
217
|
-
eventId: { type: "string", pattern: "^timeline-event:[a-f0-9]{32}$" },
|
|
218
|
-
interpretation: { oneOf: [{
|
|
219
|
-
type: "object", additionalProperties: false,
|
|
220
|
-
required: ["schema", "feedbackAssertionId", "targetAssertionId", "kind",
|
|
221
|
-
"proposedNextStepSummary", "clarificationQuestion"],
|
|
222
|
-
properties: { schema: { const: TIMELINE_INTERPRETATION_SCHEMA },
|
|
223
|
-
feedbackAssertionId: assertionId, targetAssertionId: assertionId,
|
|
224
|
-
kind: { enum: [...INTERPRETATION_KINDS] },
|
|
225
|
-
proposedNextStepSummary: { anyOf: [{ type: "string", minLength: 1, maxLength: 500 }, { type: "null" }] },
|
|
226
|
-
clarificationQuestion: { anyOf: [{ type: "string", minLength: 1, maxLength: 300 }, { type: "null" }] } }
|
|
227
|
-
}, {
|
|
228
|
-
type: "object", additionalProperties: false,
|
|
229
|
-
required: ["schema", "feedbackAssertionIds", "targetAssertionId", "clarificationQuestion"],
|
|
230
|
-
properties: { schema: { const: TIMELINE_CLARIFICATION_SCHEMA },
|
|
231
|
-
feedbackAssertionIds: { type: "array", minItems: 2, maxItems: 3, uniqueItems: true,
|
|
232
|
-
items: assertionId }, targetAssertionId: assertionId,
|
|
233
|
-
clarificationQuestion: { type: "string", minLength: 1, maxLength: 300 } }
|
|
234
|
-
}] },
|
|
235
|
-
at: { type: "string", format: "date-time" }, query: { type: "string", minLength: 3, maxLength: 512 },
|
|
236
|
-
windowSeconds: { type: "integer", minimum: 0, maximum: 900 },
|
|
237
|
-
includePriorSessions: { type: "boolean" }, includePriorProviders: { type: "boolean" } }
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
];
|