@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,102 @@
|
|
|
1
|
+
export declare const EXTERNAL_OUTCOME_SCHEMA_VERSION: "external-outcome/1";
|
|
2
|
+
export declare const EXTERNAL_OUTCOME_RESULT_SCHEMA_VERSION: "external-outcome-result/1";
|
|
3
|
+
export declare const EXTERNAL_OUTCOME_LIMITS: Readonly<{
|
|
4
|
+
maxActions: 100;
|
|
5
|
+
maxAssertionsPerAction: 50;
|
|
6
|
+
maxContractBytes: number;
|
|
7
|
+
maxResponseBytes: number;
|
|
8
|
+
maxDeadlineMs: 30000;
|
|
9
|
+
maxConcurrency: 4;
|
|
10
|
+
}>;
|
|
11
|
+
export type ExternalOutcomeJsonScalar = string | number | boolean | null;
|
|
12
|
+
export type ExternalOutcomeStatus = "passed" | "failed" | "unknown";
|
|
13
|
+
export type ExternalOutcomeReasonCode = "passed" | "record_missing" | "value_mismatch" | "wrong_identity" | "duplicate_record" | "stale_record" | "source_unavailable" | "auth_denied" | "invalid_response" | "response_too_large" | "redirect_blocked" | "deadline_exceeded" | "cancelled";
|
|
14
|
+
export interface ExternalOutcomeExpectation {
|
|
15
|
+
pointer: string;
|
|
16
|
+
equals: ExternalOutcomeJsonScalar;
|
|
17
|
+
}
|
|
18
|
+
export interface ExternalOutcomeFreshness {
|
|
19
|
+
pointer: string;
|
|
20
|
+
notEquals?: ExternalOutcomeJsonScalar;
|
|
21
|
+
notBefore?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ExternalOutcomeActionContract {
|
|
24
|
+
actionId: string;
|
|
25
|
+
claimedDone: boolean;
|
|
26
|
+
source: {
|
|
27
|
+
url: string;
|
|
28
|
+
authEnv?: string;
|
|
29
|
+
};
|
|
30
|
+
recordPointer: string;
|
|
31
|
+
identity: ExternalOutcomeExpectation;
|
|
32
|
+
expectedCount: number;
|
|
33
|
+
assertions: ExternalOutcomeExpectation[];
|
|
34
|
+
freshness?: ExternalOutcomeFreshness;
|
|
35
|
+
}
|
|
36
|
+
export interface ExternalOutcomeContract {
|
|
37
|
+
schemaVersion: typeof EXTERNAL_OUTCOME_SCHEMA_VERSION;
|
|
38
|
+
contractId: string;
|
|
39
|
+
allowedOrigins: string[];
|
|
40
|
+
deadlineMs: number;
|
|
41
|
+
pollIntervalMs: number;
|
|
42
|
+
requestTimeoutMs: number;
|
|
43
|
+
actions: ExternalOutcomeActionContract[];
|
|
44
|
+
}
|
|
45
|
+
export interface ExternalOutcomeAssertionResult {
|
|
46
|
+
pointer: string;
|
|
47
|
+
passed: boolean;
|
|
48
|
+
reasonCode: "passed" | "missing_pointer" | "value_mismatch" | "stale_record";
|
|
49
|
+
}
|
|
50
|
+
export interface ExternalOutcomeActionResult {
|
|
51
|
+
actionId: string;
|
|
52
|
+
claimedDone: boolean;
|
|
53
|
+
status: ExternalOutcomeStatus;
|
|
54
|
+
reasonCode: ExternalOutcomeReasonCode;
|
|
55
|
+
observationCount: number;
|
|
56
|
+
firstObservedAt?: string;
|
|
57
|
+
lastObservedAt?: string;
|
|
58
|
+
elapsedMs: number;
|
|
59
|
+
source: {
|
|
60
|
+
origin: string;
|
|
61
|
+
};
|
|
62
|
+
assertions: ExternalOutcomeAssertionResult[];
|
|
63
|
+
}
|
|
64
|
+
export interface ExternalOutcomeEvidenceReference {
|
|
65
|
+
kind: "external_outcome";
|
|
66
|
+
contractId: string;
|
|
67
|
+
sha256: string;
|
|
68
|
+
path: string;
|
|
69
|
+
}
|
|
70
|
+
export interface ExternalOutcomeResult {
|
|
71
|
+
schemaVersion: typeof EXTERNAL_OUTCOME_RESULT_SCHEMA_VERSION;
|
|
72
|
+
contractId: string;
|
|
73
|
+
contractSha256: string;
|
|
74
|
+
startedAt: string;
|
|
75
|
+
completedAt: string;
|
|
76
|
+
binding?: {
|
|
77
|
+
runId?: string;
|
|
78
|
+
attemptId?: string;
|
|
79
|
+
workspaceId?: string;
|
|
80
|
+
};
|
|
81
|
+
aggregate: {
|
|
82
|
+
claimedDone: number;
|
|
83
|
+
checked: number;
|
|
84
|
+
passed: number;
|
|
85
|
+
failed: number;
|
|
86
|
+
unknown: number;
|
|
87
|
+
rejectedClaimRate: number;
|
|
88
|
+
unknownClaimRate: number;
|
|
89
|
+
coverage: number;
|
|
90
|
+
};
|
|
91
|
+
actions: ExternalOutcomeActionResult[];
|
|
92
|
+
}
|
|
93
|
+
export interface ExternalOutcomeValidationError {
|
|
94
|
+
path: string;
|
|
95
|
+
message: string;
|
|
96
|
+
}
|
|
97
|
+
export declare function validateExternalOutcomeContract(value: unknown): ExternalOutcomeValidationError[];
|
|
98
|
+
export declare function resolveExternalOutcomeJsonPointer(value: unknown, pointer: string): {
|
|
99
|
+
found: boolean;
|
|
100
|
+
value?: unknown;
|
|
101
|
+
};
|
|
102
|
+
export declare function externalOutcomeValuesEqual(left: unknown, right: ExternalOutcomeJsonScalar): boolean;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
export const EXTERNAL_OUTCOME_SCHEMA_VERSION = "external-outcome/1";
|
|
2
|
+
export const EXTERNAL_OUTCOME_RESULT_SCHEMA_VERSION = "external-outcome-result/1";
|
|
3
|
+
export const EXTERNAL_OUTCOME_LIMITS = Object.freeze({
|
|
4
|
+
maxActions: 100,
|
|
5
|
+
maxAssertionsPerAction: 50,
|
|
6
|
+
maxContractBytes: 256 * 1024,
|
|
7
|
+
maxResponseBytes: 1024 * 1024,
|
|
8
|
+
maxDeadlineMs: 30_000,
|
|
9
|
+
maxConcurrency: 4,
|
|
10
|
+
});
|
|
11
|
+
const SAFE_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
|
|
12
|
+
const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/u;
|
|
13
|
+
export function validateExternalOutcomeContract(value) {
|
|
14
|
+
const errors = [];
|
|
15
|
+
if (!isRecord(value))
|
|
16
|
+
return [{ path: "", message: "contract must be an object" }];
|
|
17
|
+
let encodedBytes = Number.POSITIVE_INFINITY;
|
|
18
|
+
try {
|
|
19
|
+
encodedBytes = new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
errors.push({ path: "", message: "contract must be JSON-serializable" });
|
|
23
|
+
}
|
|
24
|
+
if (encodedBytes > EXTERNAL_OUTCOME_LIMITS.maxContractBytes) {
|
|
25
|
+
errors.push({ path: "", message: `contract exceeds ${EXTERNAL_OUTCOME_LIMITS.maxContractBytes} bytes` });
|
|
26
|
+
}
|
|
27
|
+
if (value.schemaVersion !== EXTERNAL_OUTCOME_SCHEMA_VERSION) {
|
|
28
|
+
errors.push({ path: "schemaVersion", message: `must equal ${EXTERNAL_OUTCOME_SCHEMA_VERSION}` });
|
|
29
|
+
}
|
|
30
|
+
validateId(value.contractId, "contractId", errors);
|
|
31
|
+
if (!Array.isArray(value.allowedOrigins) || value.allowedOrigins.length === 0) {
|
|
32
|
+
errors.push({ path: "allowedOrigins", message: "at least one allowed origin is required" });
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const seen = new Set();
|
|
36
|
+
value.allowedOrigins.forEach((origin, index) => {
|
|
37
|
+
if (typeof origin !== "string") {
|
|
38
|
+
errors.push({ path: `allowedOrigins[${index}]`, message: "must be a URL origin string" });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const parsed = new URL(origin);
|
|
43
|
+
if ((parsed.protocol !== "https:" && parsed.protocol !== "http:")
|
|
44
|
+
|| parsed.username || parsed.password || parsed.pathname !== "/" || parsed.search || parsed.hash
|
|
45
|
+
|| parsed.origin !== origin.replace(/\/$/u, "")) {
|
|
46
|
+
errors.push({ path: `allowedOrigins[${index}]`, message: "must be a canonical http(s) origin without path, query, fragment, or credentials" });
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (seen.has(parsed.origin))
|
|
50
|
+
errors.push({ path: `allowedOrigins[${index}]`, message: "duplicate origin" });
|
|
51
|
+
seen.add(parsed.origin);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
errors.push({ path: `allowedOrigins[${index}]`, message: "must be a valid URL origin" });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
validateInteger(value.deadlineMs, "deadlineMs", 1, EXTERNAL_OUTCOME_LIMITS.maxDeadlineMs, errors);
|
|
59
|
+
validateInteger(value.pollIntervalMs, "pollIntervalMs", 25, EXTERNAL_OUTCOME_LIMITS.maxDeadlineMs, errors);
|
|
60
|
+
validateInteger(value.requestTimeoutMs, "requestTimeoutMs", 25, EXTERNAL_OUTCOME_LIMITS.maxDeadlineMs, errors);
|
|
61
|
+
if (typeof value.deadlineMs === "number" && typeof value.pollIntervalMs === "number" && value.pollIntervalMs > value.deadlineMs) {
|
|
62
|
+
errors.push({ path: "pollIntervalMs", message: "must not exceed deadlineMs" });
|
|
63
|
+
}
|
|
64
|
+
if (typeof value.deadlineMs === "number" && typeof value.requestTimeoutMs === "number" && value.requestTimeoutMs > value.deadlineMs) {
|
|
65
|
+
errors.push({ path: "requestTimeoutMs", message: "must not exceed deadlineMs" });
|
|
66
|
+
}
|
|
67
|
+
if (!Array.isArray(value.actions) || value.actions.length === 0) {
|
|
68
|
+
errors.push({ path: "actions", message: "at least one action is required" });
|
|
69
|
+
return errors;
|
|
70
|
+
}
|
|
71
|
+
if (value.actions.length > EXTERNAL_OUTCOME_LIMITS.maxActions) {
|
|
72
|
+
errors.push({ path: "actions", message: `must contain at most ${EXTERNAL_OUTCOME_LIMITS.maxActions} actions` });
|
|
73
|
+
}
|
|
74
|
+
const actionIds = new Set();
|
|
75
|
+
if (!value.actions.some((candidate) => isRecord(candidate) && candidate.claimedDone === true)) {
|
|
76
|
+
errors.push({ path: "actions", message: "at least one action must have claimedDone=true" });
|
|
77
|
+
}
|
|
78
|
+
value.actions.forEach((candidate, index) => {
|
|
79
|
+
const base = `actions[${index}]`;
|
|
80
|
+
if (!isRecord(candidate)) {
|
|
81
|
+
errors.push({ path: base, message: "must be an object" });
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
validateId(candidate.actionId, `${base}.actionId`, errors);
|
|
85
|
+
if (typeof candidate.actionId === "string") {
|
|
86
|
+
if (actionIds.has(candidate.actionId))
|
|
87
|
+
errors.push({ path: `${base}.actionId`, message: "must be unique" });
|
|
88
|
+
actionIds.add(candidate.actionId);
|
|
89
|
+
}
|
|
90
|
+
if (typeof candidate.claimedDone !== "boolean")
|
|
91
|
+
errors.push({ path: `${base}.claimedDone`, message: "must be boolean" });
|
|
92
|
+
if (!isRecord(candidate.source)) {
|
|
93
|
+
errors.push({ path: `${base}.source`, message: "must be an object" });
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (typeof candidate.source.url !== "string") {
|
|
97
|
+
errors.push({ path: `${base}.source.url`, message: "must be a URL string" });
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
try {
|
|
101
|
+
const parsed = new URL(candidate.source.url);
|
|
102
|
+
if (!["https:", "http:"].includes(parsed.protocol))
|
|
103
|
+
errors.push({ path: `${base}.source.url`, message: "only http(s) read-back URLs are supported" });
|
|
104
|
+
if (parsed.username || parsed.password)
|
|
105
|
+
errors.push({ path: `${base}.source.url`, message: "URL credentials are forbidden" });
|
|
106
|
+
if (parsed.search)
|
|
107
|
+
errors.push({ path: `${base}.source.url`, message: "query strings are forbidden; use path identity and authEnv instead" });
|
|
108
|
+
if (parsed.hash)
|
|
109
|
+
errors.push({ path: `${base}.source.url`, message: "URL fragments are forbidden" });
|
|
110
|
+
if (Array.isArray(value.allowedOrigins) && !value.allowedOrigins.map((item) => {
|
|
111
|
+
try {
|
|
112
|
+
return new URL(String(item)).origin;
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return "";
|
|
116
|
+
}
|
|
117
|
+
}).includes(parsed.origin)) {
|
|
118
|
+
errors.push({ path: `${base}.source.url`, message: "origin is not present in allowedOrigins" });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
errors.push({ path: `${base}.source.url`, message: "must be a valid URL" });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (candidate.source.authEnv !== undefined && (typeof candidate.source.authEnv !== "string" || !ENV_NAME.test(candidate.source.authEnv))) {
|
|
126
|
+
errors.push({ path: `${base}.source.authEnv`, message: "must be a valid environment variable name" });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
validatePointer(candidate.recordPointer, `${base}.recordPointer`, errors);
|
|
130
|
+
validateExpectation(candidate.identity, `${base}.identity`, errors);
|
|
131
|
+
validateInteger(candidate.expectedCount, `${base}.expectedCount`, 1, EXTERNAL_OUTCOME_LIMITS.maxActions, errors);
|
|
132
|
+
if (!Array.isArray(candidate.assertions)) {
|
|
133
|
+
errors.push({ path: `${base}.assertions`, message: "must be an array" });
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
if (candidate.assertions.length > EXTERNAL_OUTCOME_LIMITS.maxAssertionsPerAction) {
|
|
137
|
+
errors.push({ path: `${base}.assertions`, message: `must contain at most ${EXTERNAL_OUTCOME_LIMITS.maxAssertionsPerAction} assertions` });
|
|
138
|
+
}
|
|
139
|
+
candidate.assertions.forEach((assertion, assertionIndex) => validateExpectation(assertion, `${base}.assertions[${assertionIndex}]`, errors));
|
|
140
|
+
}
|
|
141
|
+
if (candidate.freshness !== undefined) {
|
|
142
|
+
if (!isRecord(candidate.freshness)) {
|
|
143
|
+
errors.push({ path: `${base}.freshness`, message: "must be an object" });
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
validatePointer(candidate.freshness.pointer, `${base}.freshness.pointer`, errors);
|
|
147
|
+
const hasNotEquals = Object.prototype.hasOwnProperty.call(candidate.freshness, "notEquals");
|
|
148
|
+
const hasNotBefore = candidate.freshness.notBefore !== undefined;
|
|
149
|
+
if (!hasNotEquals && !hasNotBefore)
|
|
150
|
+
errors.push({ path: `${base}.freshness`, message: "must define notEquals or notBefore" });
|
|
151
|
+
if (hasNotEquals && !isScalar(candidate.freshness.notEquals))
|
|
152
|
+
errors.push({ path: `${base}.freshness.notEquals`, message: "must be a JSON scalar" });
|
|
153
|
+
if (hasNotBefore && (typeof candidate.freshness.notBefore !== "string" || !isCanonicalIso(candidate.freshness.notBefore))) {
|
|
154
|
+
errors.push({ path: `${base}.freshness.notBefore`, message: "must be a canonical ISO timestamp" });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
return errors;
|
|
160
|
+
}
|
|
161
|
+
export function resolveExternalOutcomeJsonPointer(value, pointer) {
|
|
162
|
+
if (!isValidPointer(pointer))
|
|
163
|
+
return { found: false };
|
|
164
|
+
if (pointer === "")
|
|
165
|
+
return { found: true, value };
|
|
166
|
+
let current = value;
|
|
167
|
+
for (const raw of pointer.slice(1).split("/")) {
|
|
168
|
+
const segment = raw.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
169
|
+
if (Array.isArray(current)) {
|
|
170
|
+
if (!/^(?:0|[1-9]\d*)$/u.test(segment))
|
|
171
|
+
return { found: false };
|
|
172
|
+
const index = Number(segment);
|
|
173
|
+
if (index >= current.length)
|
|
174
|
+
return { found: false };
|
|
175
|
+
current = current[index];
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (!isRecord(current) || !Object.prototype.hasOwnProperty.call(current, segment))
|
|
179
|
+
return { found: false };
|
|
180
|
+
current = current[segment];
|
|
181
|
+
}
|
|
182
|
+
return { found: true, value: current };
|
|
183
|
+
}
|
|
184
|
+
export function externalOutcomeValuesEqual(left, right) {
|
|
185
|
+
return isScalar(left) && typeof left === typeof right && Object.is(left, right);
|
|
186
|
+
}
|
|
187
|
+
function validateExpectation(value, path, errors) {
|
|
188
|
+
if (!isRecord(value)) {
|
|
189
|
+
errors.push({ path, message: "must be an object" });
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
validatePointer(value.pointer, `${path}.pointer`, errors);
|
|
193
|
+
if (!Object.prototype.hasOwnProperty.call(value, "equals") || !isScalar(value.equals)) {
|
|
194
|
+
errors.push({ path: `${path}.equals`, message: "must be a JSON scalar" });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function validatePointer(value, path, errors) {
|
|
198
|
+
if (typeof value !== "string" || !isValidPointer(value))
|
|
199
|
+
errors.push({ path, message: "must be an RFC 6901 JSON Pointer" });
|
|
200
|
+
}
|
|
201
|
+
function isValidPointer(value) {
|
|
202
|
+
if (value === "")
|
|
203
|
+
return true;
|
|
204
|
+
if (!value.startsWith("/"))
|
|
205
|
+
return false;
|
|
206
|
+
return !/(?:~(?![01]))/u.test(value);
|
|
207
|
+
}
|
|
208
|
+
function validateId(value, path, errors) {
|
|
209
|
+
if (typeof value !== "string" || !SAFE_ID.test(value))
|
|
210
|
+
errors.push({ path, message: "must be a stable 1-128 character identifier" });
|
|
211
|
+
}
|
|
212
|
+
function validateInteger(value, path, min, max, errors) {
|
|
213
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < min || value > max) {
|
|
214
|
+
errors.push({ path, message: `must be an integer between ${min} and ${max}` });
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function isCanonicalIso(value) {
|
|
218
|
+
const time = Date.parse(value);
|
|
219
|
+
return Number.isFinite(time) && new Date(time).toISOString() === value;
|
|
220
|
+
}
|
|
221
|
+
function isScalar(value) {
|
|
222
|
+
return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
223
|
+
}
|
|
224
|
+
function isRecord(value) {
|
|
225
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
226
|
+
}
|
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { TerminationEnvelopeV1 } from "./exits.js";
|
|
11
11
|
import type { AgentExecutionIntent } from "./agent-execution.js";
|
|
12
|
+
import type { SwarmChildReceiptLink } from "./swarm.js";
|
|
12
13
|
export { DEFAULT_AGENT_EXECUTION_INTENT, DEFAULT_PROVIDER_EXECUTION_TIMEOUT_MS, GOVERNED_AUTONOMOUS_BOUNDARY, normalizeProviderExecutionTimeoutMs } from "./agent-execution.js";
|
|
13
14
|
export type { AgentExecutionIntent } from "./agent-execution.js";
|
|
15
|
+
export { EXTERNAL_OUTCOME_LIMITS, EXTERNAL_OUTCOME_RESULT_SCHEMA_VERSION, EXTERNAL_OUTCOME_SCHEMA_VERSION, externalOutcomeValuesEqual, resolveExternalOutcomeJsonPointer, validateExternalOutcomeContract, } from "./external-outcome.js";
|
|
16
|
+
export type { ExternalOutcomeActionContract, ExternalOutcomeActionResult, ExternalOutcomeAssertionResult, ExternalOutcomeContract, ExternalOutcomeEvidenceReference, ExternalOutcomeFreshness, ExternalOutcomeJsonScalar, ExternalOutcomeReasonCode, ExternalOutcomeResult, ExternalOutcomeStatus, ExternalOutcomeValidationError, } from "./external-outcome.js";
|
|
14
17
|
export type LoopStatus = "queued" | "running" | "verifying" | "completed" | "failed" | "exited";
|
|
15
18
|
export type LoopLifecycleState = "created" | "running" | "verifying" | "completed" | "budget_exit" | "diminishing_returns" | "stuck_exit" | "human_escalation" | "wall_clock" | "error_threshold" | "external_event";
|
|
16
19
|
export declare const FAILURE_CLASSES: readonly ["logic_error", "hallucination", "syntax_error", "type_error", "test_regression", "scope_creep", "no_progress", "repo_grounding_failure", "verification_failure", "environment_mismatch", "budget_pressure", "safety_leash_blocked", "sandbox_write_blocked"];
|
|
@@ -42,7 +45,7 @@ export interface LoopTask {
|
|
|
42
45
|
acceptanceCriteria?: string[];
|
|
43
46
|
}
|
|
44
47
|
export type ExecutionProfile = "strict_local" | "ci_safe" | "staging_controlled" | "research_untrusted";
|
|
45
|
-
export type MutationMode = "edit";
|
|
48
|
+
export type MutationMode = "edit" | "read_only";
|
|
46
49
|
export interface ApprovalPolicy {
|
|
47
50
|
dependencyAdds?: boolean;
|
|
48
51
|
migrations?: boolean;
|
|
@@ -114,6 +117,8 @@ export interface ReceiptScope {
|
|
|
114
117
|
providerExecutionTimeoutMs?: number;
|
|
115
118
|
/** Enforced demo changes (DEMO.md-only enforcement output). */
|
|
116
119
|
demoChangedFiles?: string[];
|
|
120
|
+
/** Optional lineage for a child launched by a governed swarm. */
|
|
121
|
+
swarmChild?: SwarmChildReceiptLink;
|
|
117
122
|
}
|
|
118
123
|
export type ReceiptIntegrityState = "verified" | "unsigned" | "tamper_detected" | "relocated" | "material_missing" | "selector_noncanonical";
|
|
119
124
|
export interface ReceiptIntegritySummary {
|
|
@@ -468,3 +473,5 @@ export { HANDOFF_SCHEMA_VERSION } from "./context-handoff.js";
|
|
|
468
473
|
export type { ChainIntegrityState, ContextCircuitBreakResult, ContextExclusionDecision, ContextHandoffArtifact, ContextHandoffClaim, ContextHandoffReceipt, ContextHandoffVerification, HandoffClaimState } from "./context-handoff.js";
|
|
469
474
|
export { MISSION_SCHEMA_VERSION, MISSION_STATUSES, ALLOWED_MISSION_TRANSITIONS, createMissionRecord, isMissionTransitionAllowed } from './mission.js';
|
|
470
475
|
export type { MissionStatus, MissionDecision, MissionBudget, MissionCost, MissionRunLink, MissionRunRole, MissionApproval, MissionOutcome, MissionEvent, MissionEventKind, MissionRecord, MissionDraft } from './mission.js';
|
|
476
|
+
export { SWARM_LIVE_ENGINES, SWARM_ORCHESTRATION_STRATEGIES, SWARM_EVENT_TYPES, SWARM_PARENT_RECEIPT_SCHEMA_VERSION, SWARM_SCHEMA_VERSION, computeSwarmLivePlanHash, createSwarmLivePlan, createSwarmRunRecord, normalizeSwarmPathPattern, swarmConcretePathMatchesPattern, swarmPathPatternContains, swarmPathPatternsOverlap, validateSwarmConcretePath, validateSwarmChildReceiptLink, validateSwarmDeterministicDemoReceiptEvidence, validateSwarmChildContract, validateSwarmLiveEvent, validateSwarmLivePlan, validateSwarmLiveRevision, validateSwarmParentContract, validateSwarmRunRecord } from "./swarm.js";
|
|
477
|
+
export type { SwarmAgentRecord, SwarmAgentStatus, SwarmBudgetLedger, SwarmBudgetLease, SwarmBudgetUsage, SwarmCandidate, SwarmChildContract, SwarmChildReceiptLink, SwarmChildWorkspaceRecord, SwarmCleanupRecord, SwarmCleanupState, SwarmConcretePathResult, SwarmConflictRecord, SwarmDependencyWaiver, SwarmDemoReferentialBindingState, SwarmDeterministicDemoReceiptEvidence, SwarmEvent, SwarmEventType, SwarmGlobalVerification, SwarmGlobalVerificationCommandState, SwarmIntegrationWorkspaceRecord, SwarmIntegrationStrategy, SwarmLeaseStatus, SwarmLiveEngine, SwarmLiveEngineProfile, SwarmLiveEvent, SwarmLivePlan, SwarmLivePlanDraft, SwarmLiveRevision, SwarmOrchestrationStrategy, SwarmOutcome, SwarmOutcomeState, SwarmParentContract, SwarmParentReceipt, SwarmPatchAdmission, SwarmPatchAdmissionReasonCode, SwarmPatchAdmissionState, SwarmPathPatternResult, SwarmPermissions, SwarmProcessCloseState, SwarmRecoveryPolicy, SwarmReceiptBlockedAction, SwarmReceiptReassignment, SwarmRunDraft, SwarmRunRecord, SwarmScope, SwarmStopDisposition, SwarmStopPolicy, SwarmTaskNode, SwarmTaskStatus, SwarmValidationError, SwarmValidationResult, SwarmVerifierMutationState, SwarmVerifierSubprocessResult, SwarmVerificationRecord, SwarmVerifierAuthority, SwarmVerifierWorkspaceRecord, SwarmWorkspaceKind, SwarmWorkspaceRecord, SwarmWorkspaceRemovalState, SwarmWorkspaceState } from "./swarm.js";
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* portfolio snapshots and routing economics.
|
|
9
9
|
*/
|
|
10
10
|
export { DEFAULT_AGENT_EXECUTION_INTENT, DEFAULT_PROVIDER_EXECUTION_TIMEOUT_MS, GOVERNED_AUTONOMOUS_BOUNDARY, normalizeProviderExecutionTimeoutMs } from "./agent-execution.js";
|
|
11
|
+
export { EXTERNAL_OUTCOME_LIMITS, EXTERNAL_OUTCOME_RESULT_SCHEMA_VERSION, EXTERNAL_OUTCOME_SCHEMA_VERSION, externalOutcomeValuesEqual, resolveExternalOutcomeJsonPointer, validateExternalOutcomeContract, } from "./external-outcome.js";
|
|
11
12
|
export const FAILURE_CLASSES = [
|
|
12
13
|
"logic_error",
|
|
13
14
|
"hallucination",
|
|
@@ -247,3 +248,4 @@ export { EVIDENCE_STATUSES, EXECUTION_MODES, TEST_INTEGRITY_STATUSES, TEST_INTEG
|
|
|
247
248
|
// ─── Context Handoff — A-CTX-2 ───────────────────────────────────────────────
|
|
248
249
|
export { HANDOFF_SCHEMA_VERSION } from "./context-handoff.js";
|
|
249
250
|
export { MISSION_SCHEMA_VERSION, MISSION_STATUSES, ALLOWED_MISSION_TRANSITIONS, createMissionRecord, isMissionTransitionAllowed } from './mission.js';
|
|
251
|
+
export { SWARM_LIVE_ENGINES, SWARM_ORCHESTRATION_STRATEGIES, SWARM_EVENT_TYPES, SWARM_PARENT_RECEIPT_SCHEMA_VERSION, SWARM_SCHEMA_VERSION, computeSwarmLivePlanHash, createSwarmLivePlan, createSwarmRunRecord, normalizeSwarmPathPattern, swarmConcretePathMatchesPattern, swarmPathPatternContains, swarmPathPatternsOverlap, validateSwarmConcretePath, validateSwarmChildReceiptLink, validateSwarmDeterministicDemoReceiptEvidence, validateSwarmChildContract, validateSwarmLiveEvent, validateSwarmLivePlan, validateSwarmLiveRevision, validateSwarmParentContract, validateSwarmRunRecord } from "./swarm.js";
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { type FailureClass, type ReceiptIntegrityState } from "./index.js";
|
|
2
|
+
import { SWARM_PARENT_RECEIPT_SCHEMA_VERSION, SWARM_SCHEMA_VERSION, type SwarmAgentStatus, type SwarmEventType, type SwarmOutcomeState, type SwarmTaskStatus, type SwarmValidationResult } from "./swarm.js";
|
|
3
|
+
export declare const SWARM_HOSTED_SCHEMA_VERSION: "martin.swarm-hosted.v1";
|
|
4
|
+
export declare const SWARM_EVIDENCE_INDEX_SCHEMA_VERSION: "martin.swarm-evidence-index.v1";
|
|
5
|
+
export type SwarmHostedTaskVerificationState = "passed" | "failed" | "unknown";
|
|
6
|
+
export type SwarmHostedGlobalVerificationState = "passed" | "failed" | "unknown";
|
|
7
|
+
export type SwarmTraceDerivationKind = "observed" | "deterministic_graph_derivation";
|
|
8
|
+
export type SwarmTraceFactKind = "blocking_dependency" | "failure" | "reassignment" | "recovery" | "verification_boundary";
|
|
9
|
+
export interface SwarmHostedEvidenceReference {
|
|
10
|
+
eventId: string;
|
|
11
|
+
sequence: number;
|
|
12
|
+
}
|
|
13
|
+
export interface SwarmHostedTask {
|
|
14
|
+
taskId: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
dependsOn: string[];
|
|
17
|
+
plannedAgentId?: string;
|
|
18
|
+
effectiveAgentId?: string;
|
|
19
|
+
status: SwarmTaskStatus;
|
|
20
|
+
}
|
|
21
|
+
export interface SwarmHostedAgent {
|
|
22
|
+
agentId: string;
|
|
23
|
+
role: string;
|
|
24
|
+
status: SwarmAgentStatus;
|
|
25
|
+
taskIds: string[];
|
|
26
|
+
childRunId?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface SwarmHostedChild {
|
|
29
|
+
childRunId: string;
|
|
30
|
+
agentId: string;
|
|
31
|
+
attemptId: string;
|
|
32
|
+
taskIds: string[];
|
|
33
|
+
status: SwarmAgentStatus;
|
|
34
|
+
receiptIntegrityState: ReceiptIntegrityState;
|
|
35
|
+
evidence: SwarmHostedEvidenceReference[];
|
|
36
|
+
}
|
|
37
|
+
export interface SwarmHostedEvent {
|
|
38
|
+
eventId: string;
|
|
39
|
+
/** Exact persisted Phase 4 event idempotencyKey, retained to make the hosted rename checkable. */
|
|
40
|
+
sourceIdempotencyKey: string;
|
|
41
|
+
sequence: number;
|
|
42
|
+
type: SwarmEventType;
|
|
43
|
+
timestamp: string;
|
|
44
|
+
taskId?: string;
|
|
45
|
+
agentId?: string;
|
|
46
|
+
childRunId?: string;
|
|
47
|
+
attemptId?: string;
|
|
48
|
+
relatedAttemptId?: string;
|
|
49
|
+
toAgentId?: string;
|
|
50
|
+
candidateId?: string;
|
|
51
|
+
verificationId?: string;
|
|
52
|
+
failureClass?: FailureClass;
|
|
53
|
+
}
|
|
54
|
+
export interface SwarmHostedBlockedAction {
|
|
55
|
+
action: string;
|
|
56
|
+
reasonCode: string;
|
|
57
|
+
taskId: string;
|
|
58
|
+
agentId: string;
|
|
59
|
+
attemptId: string;
|
|
60
|
+
evidence: SwarmHostedEvidenceReference[];
|
|
61
|
+
}
|
|
62
|
+
export interface SwarmHostedReassignment {
|
|
63
|
+
taskId: string;
|
|
64
|
+
fromAgentId: string;
|
|
65
|
+
toAgentId: string;
|
|
66
|
+
fromAttemptId: string;
|
|
67
|
+
toAttemptId: string;
|
|
68
|
+
reasonCode: string;
|
|
69
|
+
evidence: SwarmHostedEvidenceReference[];
|
|
70
|
+
}
|
|
71
|
+
export interface SwarmHostedIntegrationDecision {
|
|
72
|
+
candidateId: string;
|
|
73
|
+
taskId: string;
|
|
74
|
+
agentId: string;
|
|
75
|
+
childRunId: string;
|
|
76
|
+
state: "admitted" | "rejected";
|
|
77
|
+
evidence: SwarmHostedEvidenceReference[];
|
|
78
|
+
}
|
|
79
|
+
export interface SwarmHostedConflict {
|
|
80
|
+
conflictId: string;
|
|
81
|
+
taskIds: string[];
|
|
82
|
+
state: "detected" | "resolved" | "blocking";
|
|
83
|
+
evidence: SwarmHostedEvidenceReference[];
|
|
84
|
+
}
|
|
85
|
+
export interface SwarmHostedEnvelope {
|
|
86
|
+
schemaVersion: typeof SWARM_HOSTED_SCHEMA_VERSION;
|
|
87
|
+
envelopeId: string;
|
|
88
|
+
sourceSchemas: {
|
|
89
|
+
swarm: typeof SWARM_SCHEMA_VERSION;
|
|
90
|
+
receipt: typeof SWARM_PARENT_RECEIPT_SCHEMA_VERSION;
|
|
91
|
+
evidenceIndex: typeof SWARM_EVIDENCE_INDEX_SCHEMA_VERSION;
|
|
92
|
+
};
|
|
93
|
+
sourceIdentities: {
|
|
94
|
+
receiptId: string;
|
|
95
|
+
receiptSha256: string;
|
|
96
|
+
evidenceIndexSha256: string;
|
|
97
|
+
eventChainSha256: string;
|
|
98
|
+
};
|
|
99
|
+
runtimeVersion: string;
|
|
100
|
+
createdAt: string;
|
|
101
|
+
swarm: {
|
|
102
|
+
swarmId: string;
|
|
103
|
+
workspaceId: string;
|
|
104
|
+
projectId: string;
|
|
105
|
+
planHash: string;
|
|
106
|
+
baselineCommit: string;
|
|
107
|
+
};
|
|
108
|
+
topology: {
|
|
109
|
+
tasks: SwarmHostedTask[];
|
|
110
|
+
agents: SwarmHostedAgent[];
|
|
111
|
+
children: SwarmHostedChild[];
|
|
112
|
+
};
|
|
113
|
+
budget: {
|
|
114
|
+
capUsd: number;
|
|
115
|
+
capTokens?: number;
|
|
116
|
+
settledUsd: number;
|
|
117
|
+
settledTokens: number;
|
|
118
|
+
};
|
|
119
|
+
interventions: {
|
|
120
|
+
blockedActions: SwarmHostedBlockedAction[];
|
|
121
|
+
reassignments: SwarmHostedReassignment[];
|
|
122
|
+
};
|
|
123
|
+
integration: {
|
|
124
|
+
admissions: SwarmHostedIntegrationDecision[];
|
|
125
|
+
rejections: SwarmHostedIntegrationDecision[];
|
|
126
|
+
conflicts: SwarmHostedConflict[];
|
|
127
|
+
integratedTreeHash?: string;
|
|
128
|
+
};
|
|
129
|
+
events: SwarmHostedEvent[];
|
|
130
|
+
globalVerification: {
|
|
131
|
+
state: SwarmHostedGlobalVerificationState;
|
|
132
|
+
verificationId?: string;
|
|
133
|
+
integratedTreeHash?: string;
|
|
134
|
+
evidence: SwarmHostedEvidenceReference[];
|
|
135
|
+
};
|
|
136
|
+
parentOutcome: {
|
|
137
|
+
state: Exclude<SwarmOutcomeState, "running">;
|
|
138
|
+
source: "sealed_parent_receipt";
|
|
139
|
+
evidence: SwarmHostedEvidenceReference[];
|
|
140
|
+
};
|
|
141
|
+
taskVerificationState: SwarmHostedTaskVerificationState;
|
|
142
|
+
receiptIntegrityState: ReceiptIntegrityState;
|
|
143
|
+
transportSignature: {
|
|
144
|
+
algorithm: "hmac-sha256";
|
|
145
|
+
keyId: string;
|
|
146
|
+
keyLocatorHash: string;
|
|
147
|
+
signatureHmacSha256: string;
|
|
148
|
+
};
|
|
149
|
+
extensions?: Record<string, unknown>;
|
|
150
|
+
}
|
|
151
|
+
export interface SwarmAtlasView {
|
|
152
|
+
schemaVersion: "martin.swarm-atlas-view.v1";
|
|
153
|
+
envelopeId: string;
|
|
154
|
+
sourceIdentities: SwarmHostedEnvelope["sourceIdentities"];
|
|
155
|
+
swarm: SwarmHostedEnvelope["swarm"];
|
|
156
|
+
tasks: SwarmHostedTask[];
|
|
157
|
+
dependencyEdges: Array<{
|
|
158
|
+
fromTaskId: string;
|
|
159
|
+
toTaskId: string;
|
|
160
|
+
}>;
|
|
161
|
+
agents: SwarmHostedAgent[];
|
|
162
|
+
children: SwarmHostedChild[];
|
|
163
|
+
budget: SwarmHostedEnvelope["budget"];
|
|
164
|
+
interventions: SwarmHostedEnvelope["interventions"];
|
|
165
|
+
integration: SwarmHostedEnvelope["integration"];
|
|
166
|
+
globalVerification: SwarmHostedEnvelope["globalVerification"];
|
|
167
|
+
parentOutcome: SwarmHostedEnvelope["parentOutcome"];
|
|
168
|
+
taskVerificationState: SwarmHostedTaskVerificationState;
|
|
169
|
+
receiptIntegrityState: ReceiptIntegrityState;
|
|
170
|
+
}
|
|
171
|
+
export interface SwarmTraceFact {
|
|
172
|
+
factId: string;
|
|
173
|
+
kind: SwarmTraceFactKind;
|
|
174
|
+
derivationKind: SwarmTraceDerivationKind;
|
|
175
|
+
taskIds: string[];
|
|
176
|
+
agentIds: string[];
|
|
177
|
+
childRunIds: string[];
|
|
178
|
+
attemptIds: string[];
|
|
179
|
+
verificationIds: string[];
|
|
180
|
+
evidence: SwarmHostedEvidenceReference[];
|
|
181
|
+
}
|
|
182
|
+
export interface SwarmSansaView {
|
|
183
|
+
schemaVersion: "martin.swarm-sansa-view.v1";
|
|
184
|
+
envelopeId: string;
|
|
185
|
+
sourceIdentities: SwarmHostedEnvelope["sourceIdentities"];
|
|
186
|
+
facts: SwarmTraceFact[];
|
|
187
|
+
parentOutcome: SwarmHostedEnvelope["parentOutcome"];
|
|
188
|
+
globalVerification: SwarmHostedEnvelope["globalVerification"];
|
|
189
|
+
}
|
|
190
|
+
export interface SwarmDashboardView {
|
|
191
|
+
schemaVersion: "martin.swarm-dashboard-view.v1";
|
|
192
|
+
envelopeId: string;
|
|
193
|
+
sourceIdentities: SwarmHostedEnvelope["sourceIdentities"];
|
|
194
|
+
swarmId: string;
|
|
195
|
+
children: SwarmHostedChild[];
|
|
196
|
+
parentOutcome: SwarmHostedEnvelope["parentOutcome"];
|
|
197
|
+
globalVerification: SwarmHostedEnvelope["globalVerification"];
|
|
198
|
+
taskVerificationState: SwarmHostedTaskVerificationState;
|
|
199
|
+
receiptIntegrityState: ReceiptIntegrityState;
|
|
200
|
+
budget: SwarmHostedEnvelope["budget"];
|
|
201
|
+
}
|
|
202
|
+
export declare function canonicalSwarmHostedTransportBytes(envelope: SwarmHostedEnvelope): string;
|
|
203
|
+
export declare function computeSwarmHostedEnvelopeIdentity(envelope: SwarmHostedEnvelope): string;
|
|
204
|
+
export declare function validateSwarmHostedEnvelope(value: unknown): SwarmValidationResult;
|