@martinloop/mcp 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/vendor/adapters/claude-cli.d.ts +11 -1
- package/dist/vendor/adapters/claude-cli.js +285 -71
- package/dist/vendor/adapters/cli-bridge.d.ts +12 -3
- package/dist/vendor/adapters/cli-bridge.js +129 -149
- package/dist/vendor/adapters/codex-cli.d.ts +3 -3
- package/dist/vendor/adapters/codex-cli.js +10 -24
- package/dist/vendor/adapters/codex-host.js +127 -132
- package/dist/vendor/adapters/index.d.ts +2 -1
- package/dist/vendor/adapters/index.js +2 -1
- package/dist/vendor/adapters/openai-compatible.js +88 -6
- package/dist/vendor/adapters/process-supervisor.d.ts +60 -0
- package/dist/vendor/adapters/process-supervisor.js +541 -0
- package/dist/vendor/adapters/verifier-only.d.ts +10 -1
- package/dist/vendor/adapters/verifier-only.js +43 -1
- package/dist/vendor/contracts/external-outcome.d.ts +102 -0
- package/dist/vendor/contracts/external-outcome.js +226 -0
- package/dist/vendor/contracts/index.d.ts +8 -1
- package/dist/vendor/contracts/index.js +2 -0
- package/dist/vendor/contracts/swarm-hosted.d.ts +204 -0
- package/dist/vendor/contracts/swarm-hosted.js +629 -0
- package/dist/vendor/contracts/swarm.d.ts +449 -0
- package/dist/vendor/contracts/swarm.js +550 -0
- package/dist/vendor/core/external-outcome.d.ts +34 -0
- package/dist/vendor/core/external-outcome.js +515 -0
- package/dist/vendor/core/grounding.js +1 -1
- package/dist/vendor/core/index.d.ts +47 -1
- package/dist/vendor/core/index.js +53 -3
- package/dist/vendor/core/leash.d.ts +1 -0
- package/dist/vendor/core/leash.js +13 -0
- package/dist/vendor/core/persistence/integrity.d.ts +4 -0
- package/dist/vendor/core/persistence/integrity.js +19 -6
- package/dist/vendor/core/persistence/swarm-integrity.d.ts +63 -0
- package/dist/vendor/core/persistence/swarm-integrity.js +309 -0
- package/dist/vendor/core/swarm/candidates.d.ts +78 -0
- package/dist/vendor/core/swarm/candidates.js +810 -0
- package/dist/vendor/core/swarm/evidence-projection.d.ts +87 -0
- package/dist/vendor/core/swarm/evidence-projection.js +128 -0
- package/dist/vendor/core/swarm/evidence.d.ts +40 -0
- package/dist/vendor/core/swarm/evidence.js +575 -0
- package/dist/vendor/core/swarm/hosted-export.d.ts +48 -0
- package/dist/vendor/core/swarm/hosted-export.js +362 -0
- package/dist/vendor/core/swarm/hosted-projection.d.ts +5 -0
- package/dist/vendor/core/swarm/hosted-projection.js +258 -0
- package/dist/vendor/core/swarm/index.d.ts +110 -0
- package/dist/vendor/core/swarm/index.js +1060 -0
- package/dist/vendor/core/swarm/integration.d.ts +76 -0
- package/dist/vendor/core/swarm/integration.js +615 -0
- package/dist/vendor/core/swarm/lifecycle.d.ts +72 -0
- package/dist/vendor/core/swarm/lifecycle.js +252 -0
- package/dist/vendor/core/swarm/live-runtime.d.ts +78 -0
- package/dist/vendor/core/swarm/live-runtime.js +1482 -0
- package/dist/vendor/core/swarm/live-store.d.ts +99 -0
- package/dist/vendor/core/swarm/live-store.js +860 -0
- package/dist/vendor/core/swarm/operational-reader.d.ts +17 -0
- package/dist/vendor/core/swarm/operational-reader.js +96 -0
- package/dist/vendor/core/swarm/operations.d.ts +29 -0
- package/dist/vendor/core/swarm/operations.js +128 -0
- package/dist/vendor/core/swarm/parent-receipt.d.ts +13 -0
- package/dist/vendor/core/swarm/parent-receipt.js +489 -0
- package/dist/vendor/core/swarm/receipt-projection.d.ts +26 -0
- package/dist/vendor/core/swarm/receipt-projection.js +120 -0
- package/dist/vendor/core/swarm/scheduler.d.ts +92 -0
- package/dist/vendor/core/swarm/scheduler.js +555 -0
- package/dist/vendor/core/swarm/verification.d.ts +70 -0
- package/dist/vendor/core/swarm/verification.js +295 -0
- package/dist/vendor/core/swarm/workspaces.d.ts +77 -0
- package/dist/vendor/core/swarm/workspaces.js +488 -0
- package/dist/vendor/core/verified-handoff.d.ts +4 -0
- package/dist/vendor/core/verified-handoff.js +4 -0
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { SwarmLiveEngineProfile, SwarmParentReceipt } from "../../contracts/index.js";
|
|
2
|
+
import { type SwarmReceiptProjection } from "./receipt-projection.js";
|
|
3
|
+
import { type SwarmOperationalSelector, type SwarmOperationalState } from "./operational-reader.js";
|
|
4
|
+
export type SwarmEvidenceSelector = SwarmOperationalSelector;
|
|
5
|
+
export interface SwarmDossierProjection {
|
|
6
|
+
schemaVersion: "martin.swarm-dossier.v1";
|
|
7
|
+
swarmId: string;
|
|
8
|
+
planHash: string;
|
|
9
|
+
receiptId: string;
|
|
10
|
+
receiptSha256: string;
|
|
11
|
+
objective: string;
|
|
12
|
+
engine: SwarmLiveEngineProfile;
|
|
13
|
+
baselineCommit: string;
|
|
14
|
+
parentOutcome: SwarmParentReceipt["parentOutcome"];
|
|
15
|
+
integrityState: "verified" | "material_missing" | "tamper_detected";
|
|
16
|
+
taskVerificationState: "passed" | "failed" | "unknown";
|
|
17
|
+
sealedAt: string;
|
|
18
|
+
taskCounts: SwarmStatusCounts;
|
|
19
|
+
agentCounts: SwarmStatusCounts;
|
|
20
|
+
budget: {
|
|
21
|
+
capUsd: number;
|
|
22
|
+
capTokens?: number;
|
|
23
|
+
settledUsd: number;
|
|
24
|
+
settledTokens: number;
|
|
25
|
+
};
|
|
26
|
+
evidence: {
|
|
27
|
+
files: number;
|
|
28
|
+
childReceipts: number;
|
|
29
|
+
events: number;
|
|
30
|
+
blockedActions: number;
|
|
31
|
+
reassignments: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface SwarmEvidenceVerification {
|
|
35
|
+
schemaVersion: "martin.swarm-verification.v1";
|
|
36
|
+
swarmId: string;
|
|
37
|
+
planHash: string;
|
|
38
|
+
receiptId: string;
|
|
39
|
+
receiptSha256: string;
|
|
40
|
+
integrityState: SwarmDossierProjection["integrityState"];
|
|
41
|
+
taskVerificationState: SwarmDossierProjection["taskVerificationState"];
|
|
42
|
+
parentOutcomeState: SwarmParentReceipt["parentOutcome"]["state"];
|
|
43
|
+
verified: boolean;
|
|
44
|
+
verifiedAt: string;
|
|
45
|
+
}
|
|
46
|
+
/** Sanitized, deterministic input for the three-file local share bundle. */
|
|
47
|
+
export interface SwarmShareProjection {
|
|
48
|
+
schemaVersion: "martin.swarm-share.v1";
|
|
49
|
+
generatedAt: string;
|
|
50
|
+
swarmId: string;
|
|
51
|
+
planHash: string;
|
|
52
|
+
receiptId: string;
|
|
53
|
+
receiptSha256: string;
|
|
54
|
+
baselineCommit: string;
|
|
55
|
+
parentOutcomeState: "verified";
|
|
56
|
+
integrityState: "verified";
|
|
57
|
+
taskVerificationState: "passed";
|
|
58
|
+
engine: SwarmLiveEngineProfile;
|
|
59
|
+
taskCounts: SwarmStatusCounts;
|
|
60
|
+
agentCounts: SwarmStatusCounts;
|
|
61
|
+
budget: SwarmDossierProjection["budget"];
|
|
62
|
+
evidence: SwarmDossierProjection["evidence"];
|
|
63
|
+
}
|
|
64
|
+
export interface SwarmStatusCounts {
|
|
65
|
+
total: number;
|
|
66
|
+
accepted?: number;
|
|
67
|
+
verified?: number;
|
|
68
|
+
stopped: number;
|
|
69
|
+
needsReview: number;
|
|
70
|
+
other: number;
|
|
71
|
+
}
|
|
72
|
+
export interface SwarmEvidenceProjectionDependencies {
|
|
73
|
+
readOperationalState(input: SwarmOperationalSelector): Promise<SwarmOperationalState>;
|
|
74
|
+
readReceiptProjection(input: {
|
|
75
|
+
runsRoot: string;
|
|
76
|
+
swarmId: string;
|
|
77
|
+
}): Promise<SwarmReceiptProjection>;
|
|
78
|
+
}
|
|
79
|
+
export declare function readSwarmDossier(input: SwarmEvidenceSelector): Promise<SwarmDossierProjection>;
|
|
80
|
+
export declare function verifySwarmEvidence(input: SwarmEvidenceSelector): Promise<SwarmEvidenceVerification>;
|
|
81
|
+
export declare function buildSwarmShareProjection(input: SwarmEvidenceSelector): Promise<SwarmShareProjection>;
|
|
82
|
+
/** Internal test seam; intentionally not re-exported from the Core package root. */
|
|
83
|
+
export declare function readSwarmDossierWithDependencies(input: SwarmEvidenceSelector, dependencies: SwarmEvidenceProjectionDependencies): Promise<SwarmDossierProjection>;
|
|
84
|
+
/** Internal test seam; intentionally not re-exported from the Core package root. */
|
|
85
|
+
export declare function verifySwarmEvidenceWithDependencies(input: SwarmEvidenceSelector, dependencies: SwarmEvidenceProjectionDependencies): Promise<SwarmEvidenceVerification>;
|
|
86
|
+
/** Internal test seam; intentionally not re-exported from the Core package root. */
|
|
87
|
+
export declare function buildSwarmShareProjectionWithDependencies(input: SwarmEvidenceSelector, dependencies: SwarmEvidenceProjectionDependencies): Promise<SwarmShareProjection>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { redactSecretsFromText } from "../leash.js";
|
|
2
|
+
import { readSwarmReceiptProjection } from "./receipt-projection.js";
|
|
3
|
+
import { readSwarmOperationalState, } from "./operational-reader.js";
|
|
4
|
+
const productionDependencies = {
|
|
5
|
+
readOperationalState: readSwarmOperationalState,
|
|
6
|
+
readReceiptProjection: readSwarmReceiptProjection,
|
|
7
|
+
};
|
|
8
|
+
export function readSwarmDossier(input) {
|
|
9
|
+
return readSwarmDossierWithDependencies(input, productionDependencies);
|
|
10
|
+
}
|
|
11
|
+
export function verifySwarmEvidence(input) {
|
|
12
|
+
return verifySwarmEvidenceWithDependencies(input, productionDependencies);
|
|
13
|
+
}
|
|
14
|
+
export function buildSwarmShareProjection(input) {
|
|
15
|
+
return buildSwarmShareProjectionWithDependencies(input, productionDependencies);
|
|
16
|
+
}
|
|
17
|
+
/** Internal test seam; intentionally not re-exported from the Core package root. */
|
|
18
|
+
export async function readSwarmDossierWithDependencies(input, dependencies) {
|
|
19
|
+
const state = await dependencies.readOperationalState(input);
|
|
20
|
+
const swarmId = state.snapshot.swarmId;
|
|
21
|
+
const projection = await dependencies.readReceiptProjection({ runsRoot: input.runsRoot, swarmId });
|
|
22
|
+
return projectDossier(projection.receipt, projection.integrity.state);
|
|
23
|
+
}
|
|
24
|
+
/** Internal test seam; intentionally not re-exported from the Core package root. */
|
|
25
|
+
export async function verifySwarmEvidenceWithDependencies(input, dependencies) {
|
|
26
|
+
const dossier = await readSwarmDossierWithDependencies(input, dependencies);
|
|
27
|
+
return {
|
|
28
|
+
schemaVersion: "martin.swarm-verification.v1",
|
|
29
|
+
swarmId: dossier.swarmId,
|
|
30
|
+
planHash: dossier.planHash,
|
|
31
|
+
receiptId: dossier.receiptId,
|
|
32
|
+
receiptSha256: dossier.receiptSha256,
|
|
33
|
+
integrityState: dossier.integrityState,
|
|
34
|
+
taskVerificationState: dossier.taskVerificationState,
|
|
35
|
+
parentOutcomeState: dossier.parentOutcome.state,
|
|
36
|
+
verified: dossier.integrityState === "verified"
|
|
37
|
+
&& dossier.taskVerificationState === "passed"
|
|
38
|
+
&& dossier.parentOutcome.state === "verified",
|
|
39
|
+
verifiedAt: dossier.sealedAt,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Internal test seam; intentionally not re-exported from the Core package root. */
|
|
43
|
+
export async function buildSwarmShareProjectionWithDependencies(input, dependencies) {
|
|
44
|
+
const dossier = await readSwarmDossierWithDependencies(input, dependencies);
|
|
45
|
+
if (dossier.integrityState !== "verified"
|
|
46
|
+
|| dossier.taskVerificationState !== "passed"
|
|
47
|
+
|| dossier.parentOutcome.state !== "verified") {
|
|
48
|
+
throw codedEvidenceError("SWARM_SHARE_NOT_VERIFIED", "Swarm evidence is not fully verified and cannot be shared.");
|
|
49
|
+
}
|
|
50
|
+
const share = {
|
|
51
|
+
schemaVersion: "martin.swarm-share.v1",
|
|
52
|
+
generatedAt: dossier.sealedAt,
|
|
53
|
+
swarmId: dossier.swarmId,
|
|
54
|
+
planHash: dossier.planHash,
|
|
55
|
+
receiptId: dossier.receiptId,
|
|
56
|
+
receiptSha256: dossier.receiptSha256,
|
|
57
|
+
baselineCommit: dossier.baselineCommit,
|
|
58
|
+
parentOutcomeState: "verified",
|
|
59
|
+
integrityState: "verified",
|
|
60
|
+
taskVerificationState: "passed",
|
|
61
|
+
engine: structuredClone(dossier.engine),
|
|
62
|
+
taskCounts: structuredClone(dossier.taskCounts),
|
|
63
|
+
agentCounts: structuredClone(dossier.agentCounts),
|
|
64
|
+
budget: structuredClone(dossier.budget),
|
|
65
|
+
evidence: structuredClone(dossier.evidence),
|
|
66
|
+
};
|
|
67
|
+
return JSON.parse(redactSecretsFromText(JSON.stringify(share)));
|
|
68
|
+
}
|
|
69
|
+
function projectDossier(receipt, integrityState) {
|
|
70
|
+
const taskCounts = countStatuses(receipt.tasks.map((task) => task.status), "accepted");
|
|
71
|
+
const agentCounts = countStatuses(receipt.agents.map((agent) => agent.status), "verified");
|
|
72
|
+
return {
|
|
73
|
+
schemaVersion: "martin.swarm-dossier.v1",
|
|
74
|
+
swarmId: receipt.swarmId,
|
|
75
|
+
planHash: receipt.planHash,
|
|
76
|
+
receiptId: receipt.receiptId,
|
|
77
|
+
receiptSha256: receipt.receiptSha256,
|
|
78
|
+
objective: receipt.objective,
|
|
79
|
+
engine: structuredClone(receipt.engine),
|
|
80
|
+
baselineCommit: receipt.baselineCommit,
|
|
81
|
+
parentOutcome: structuredClone(receipt.parentOutcome),
|
|
82
|
+
integrityState,
|
|
83
|
+
taskVerificationState: receipt.taskVerificationState,
|
|
84
|
+
sealedAt: receipt.sealedAt,
|
|
85
|
+
taskCounts,
|
|
86
|
+
agentCounts,
|
|
87
|
+
budget: {
|
|
88
|
+
capUsd: receipt.budgetLedger.capUsd,
|
|
89
|
+
...(receipt.budgetLedger.capTokens === undefined ? {} : { capTokens: receipt.budgetLedger.capTokens }),
|
|
90
|
+
settledUsd: receipt.budgetLedger.settledUsd,
|
|
91
|
+
settledTokens: receipt.budgetLedger.settledTokens,
|
|
92
|
+
},
|
|
93
|
+
evidence: {
|
|
94
|
+
files: receipt.evidenceFiles.length,
|
|
95
|
+
childReceipts: receipt.childReceipts.length,
|
|
96
|
+
events: receipt.events.length,
|
|
97
|
+
blockedActions: receipt.blockedActions.length,
|
|
98
|
+
reassignments: receipt.reassignments.length,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function countStatuses(values, successStatus) {
|
|
103
|
+
const counts = {
|
|
104
|
+
total: values.length,
|
|
105
|
+
...(successStatus === "accepted" ? { accepted: 0 } : { verified: 0 }),
|
|
106
|
+
stopped: 0,
|
|
107
|
+
needsReview: 0,
|
|
108
|
+
other: 0,
|
|
109
|
+
};
|
|
110
|
+
for (const status of values) {
|
|
111
|
+
if (status === successStatus) {
|
|
112
|
+
if (successStatus === "accepted")
|
|
113
|
+
counts.accepted = (counts.accepted ?? 0) + 1;
|
|
114
|
+
else
|
|
115
|
+
counts.verified = (counts.verified ?? 0) + 1;
|
|
116
|
+
}
|
|
117
|
+
else if (status === "stopped")
|
|
118
|
+
counts.stopped += 1;
|
|
119
|
+
else if (status === "needs_review")
|
|
120
|
+
counts.needsReview += 1;
|
|
121
|
+
else
|
|
122
|
+
counts.other += 1;
|
|
123
|
+
}
|
|
124
|
+
return counts;
|
|
125
|
+
}
|
|
126
|
+
function codedEvidenceError(code, message) {
|
|
127
|
+
return Object.assign(new Error(message), { code });
|
|
128
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SwarmLiveEvent, SwarmLivePlan, SwarmOutcome } from "../../contracts/index.js";
|
|
2
|
+
import { type SwarmLiveSnapshot } from "./live-store.js";
|
|
3
|
+
export declare const SWARM_EVIDENCE_INDEX_SCHEMA_VERSION: "martin.swarm-evidence-index.v1";
|
|
4
|
+
export interface SwarmEvidenceIndexFile {
|
|
5
|
+
kind: "operational" | "artifact";
|
|
6
|
+
path: string;
|
|
7
|
+
sha256: string;
|
|
8
|
+
bytes: number;
|
|
9
|
+
}
|
|
10
|
+
export interface SwarmEvidenceIndex {
|
|
11
|
+
schemaVersion: typeof SWARM_EVIDENCE_INDEX_SCHEMA_VERSION;
|
|
12
|
+
swarmId: string;
|
|
13
|
+
planHash: string;
|
|
14
|
+
revision: number;
|
|
15
|
+
outcome: SwarmOutcome;
|
|
16
|
+
sealedAt: string;
|
|
17
|
+
files: SwarmEvidenceIndexFile[];
|
|
18
|
+
}
|
|
19
|
+
export interface ReadAndSealSwarmEvidenceResult {
|
|
20
|
+
index: SwarmEvidenceIndex;
|
|
21
|
+
indexPath: string;
|
|
22
|
+
indexBytes: string;
|
|
23
|
+
model: SealedSwarmEvidenceModel;
|
|
24
|
+
}
|
|
25
|
+
export interface SealedSwarmEvidenceArtifact {
|
|
26
|
+
path: string;
|
|
27
|
+
value: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
export interface SealedSwarmEvidenceModel {
|
|
30
|
+
plan: SwarmLivePlan;
|
|
31
|
+
events: SwarmLiveEvent[];
|
|
32
|
+
snapshot: SwarmLiveSnapshot;
|
|
33
|
+
artifacts: SealedSwarmEvidenceArtifact[];
|
|
34
|
+
}
|
|
35
|
+
export declare function readAndSealSwarmEvidence(input: {
|
|
36
|
+
rootDir: string;
|
|
37
|
+
swarmId: string;
|
|
38
|
+
/** Internal deterministic race-test seam; not exported from the Core package root. */
|
|
39
|
+
beforePublish?: () => Promise<void>;
|
|
40
|
+
}): Promise<ReadAndSealSwarmEvidenceResult>;
|