agent-embassy 1.2.0 → 1.3.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/CHANGELOG.md +24 -0
- package/CONTRIBUTING.md +25 -7
- package/README.md +20 -12
- package/README.zh-CN.md +14 -13
- package/SECURITY.md +55 -41
- package/dist/src/gateway/claude-helper-supervisor.js +0 -1
- package/dist/src/gateway/claude-helper-supervisor.js.map +1 -1
- package/dist/src/gateway/claude-runtime.d.ts +0 -2
- package/dist/src/gateway/claude-runtime.js +6 -17
- package/dist/src/gateway/claude-runtime.js.map +1 -1
- package/dist/src/gateway/cli-copy.d.ts +1 -1
- package/dist/src/gateway/cli-copy.en.d.ts +3 -1
- package/dist/src/gateway/cli-copy.en.js +5 -3
- package/dist/src/gateway/cli-copy.en.js.map +1 -1
- package/dist/src/gateway/cli-copy.js +2 -0
- package/dist/src/gateway/cli-copy.js.map +1 -1
- package/dist/src/gateway/cli-copy.zh-CN.d.ts +3 -1
- package/dist/src/gateway/cli-copy.zh-CN.js +5 -3
- package/dist/src/gateway/cli-copy.zh-CN.js.map +1 -1
- package/dist/src/gateway/cli.d.ts +2 -5
- package/dist/src/gateway/cli.js +30 -67
- package/dist/src/gateway/cli.js.map +1 -1
- package/dist/src/gateway/codex-app-server.d.ts +1 -7
- package/dist/src/gateway/codex-app-server.js +5 -52
- package/dist/src/gateway/codex-app-server.js.map +1 -1
- package/dist/src/gateway/codex-local-transport.d.ts +4 -10
- package/dist/src/gateway/codex-local-transport.js +13 -16
- package/dist/src/gateway/codex-local-transport.js.map +1 -1
- package/dist/src/gateway/compatibility.d.ts +0 -27
- package/dist/src/gateway/compatibility.js +1 -101
- package/dist/src/gateway/compatibility.js.map +1 -1
- package/dist/src/gateway/config.d.ts +0 -3
- package/dist/src/gateway/config.js +0 -10
- package/dist/src/gateway/config.js.map +1 -1
- package/dist/src/gateway/control.d.ts +1 -20
- package/dist/src/gateway/control.js +2 -33
- package/dist/src/gateway/control.js.map +1 -1
- package/dist/src/gateway/dashboard-copy.d.ts +1 -1
- package/dist/src/gateway/dashboard-copy.en.d.ts +6 -7
- package/dist/src/gateway/dashboard-copy.en.js +15 -16
- package/dist/src/gateway/dashboard-copy.en.js.map +1 -1
- package/dist/src/gateway/dashboard-copy.js +6 -7
- package/dist/src/gateway/dashboard-copy.js.map +1 -1
- package/dist/src/gateway/dashboard-copy.zh-CN.d.ts +6 -7
- package/dist/src/gateway/dashboard-copy.zh-CN.js +15 -16
- package/dist/src/gateway/dashboard-copy.zh-CN.js.map +1 -1
- package/dist/src/gateway/dashboard-model.d.ts +3 -7
- package/dist/src/gateway/dashboard-model.js +41 -16
- package/dist/src/gateway/dashboard-model.js.map +1 -1
- package/dist/src/gateway/dashboard.js +5 -7
- package/dist/src/gateway/dashboard.js.map +1 -1
- package/dist/src/gateway/live-dashboard-app/app.js +17 -45
- package/dist/src/gateway/live-dashboard-command.d.ts +5 -1
- package/dist/src/gateway/live-dashboard-command.js +8 -6
- package/dist/src/gateway/live-dashboard-command.js.map +1 -1
- package/dist/src/gateway/live-dashboard-http.d.ts +0 -4
- package/dist/src/gateway/live-dashboard-http.js +19 -93
- package/dist/src/gateway/live-dashboard-http.js.map +1 -1
- package/dist/src/gateway/live-dashboard-protocol.d.ts +1 -5
- package/dist/src/gateway/live-dashboard-protocol.js +0 -42
- package/dist/src/gateway/live-dashboard-protocol.js.map +1 -1
- package/dist/src/gateway/live-dashboard-server.d.ts +2 -2
- package/dist/src/gateway/live-dashboard-server.js +18 -4
- package/dist/src/gateway/live-dashboard-server.js.map +1 -1
- package/dist/src/gateway/live-dashboard.d.ts +3 -6
- package/dist/src/gateway/live-dashboard.js +6 -42
- package/dist/src/gateway/live-dashboard.js.map +1 -1
- package/dist/src/gateway/provenance-envelope.js +1 -1
- package/dist/src/gateway/provenance-envelope.js.map +1 -1
- package/dist/src/gateway/providers.d.ts +1 -21
- package/dist/src/gateway/providers.js +15 -261
- package/dist/src/gateway/providers.js.map +1 -1
- package/dist/src/gateway/server.js +0 -3
- package/dist/src/gateway/server.js.map +1 -1
- package/dist/src/gateway/service.d.ts +3 -15
- package/dist/src/gateway/service.js +76 -257
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/gateway/store.js +76 -18
- package/dist/src/gateway/store.js.map +1 -1
- package/dist/src/gateway/types.d.ts +0 -4
- package/dist/src/gateway/types.js.map +1 -1
- package/docs/GATEWAY-ARCHITECTURE.md +75 -63
- package/package.json +1 -1
- package/skills/embassy-peer/SKILL.md +25 -10
- package/dist/src/gateway/claude-compatibility-scratch.d.ts +0 -18
- package/dist/src/gateway/claude-compatibility-scratch.js +0 -158
- package/dist/src/gateway/claude-compatibility-scratch.js.map +0 -1
- package/dist/src/gateway/live-dashboard-bootstrap.d.ts +0 -36
- package/dist/src/gateway/live-dashboard-bootstrap.js +0 -176
- package/dist/src/gateway/live-dashboard-bootstrap.js.map +0 -1
- package/docs/DESIGN.md +0 -134
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-dashboard.js","sourceRoot":"","sources":["../../../src/gateway/live-dashboard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"live-dashboard.js","sourceRoot":"","sources":["../../../src/gateway/live-dashboard.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EACL,iCAAiC,GAElC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EACL,uBAAuB,EACvB,+BAA+B,GAGhC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,4BAA4B,GAG7B,MAAM,4BAA4B,CAAC;AAuBpC,MAAM,OAAO,kCAAmC,SAAQ,KAAK;IAClD,IAAI,GAAG,gCAAyC,CAAC;IAE1D;QACE,KAAK,CAAC,uCAAuC,CA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C,KAAK,EAAE,CAAC;YACtB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,UAAU,GAAG,KAAK,CAAC;YACrB,CAAC;YACD,IAAI,UAAU,KAAK,SAAS;gBAAE,MAAM,UAAU,CAAC;QACjD,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,aAAa,CAAC;IACvB,CAAC,CAAC;IAEF,MAAM,iBAAiB,GAAG,GAAS,EAAE;QACnC,KAAK,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC,CAAC;IACF,OAAO,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7E,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;QACrC,MAAM,KAAK,EAAE,CAAC;QACd,MAAM,IAAI,kCAAkC,EAAE,CAAC;IACjD,CAAC;IAED,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,GAAG;QACH,KAAK;KACN,CAAC;AACJ,CAAC"}
|
|
@@ -68,7 +68,7 @@ export function composeProvenanceEnvelope(input) {
|
|
|
68
68
|
const hint = `<embassy-reply-hint conversation="${input.conversationId}"` +
|
|
69
69
|
` reply-as="${input.targetAlias}"${exactSourceAttribute}>` +
|
|
70
70
|
`Reply by running \`${replyCommand}\` with the reply body on stdin. ` +
|
|
71
|
-
"
|
|
71
|
+
"Caller, conversation, and route policy are rechecked.</embassy-reply-hint>";
|
|
72
72
|
const body = neutralizeReservedTags(input.body);
|
|
73
73
|
const envelope = `<cross-session-message from-name="${fromName}"${conversationAttribute}>\n` +
|
|
74
74
|
`${hint}\n${body}\n</cross-session-message>`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provenance-envelope.js","sourceRoot":"","sources":["../../../src/gateway/provenance-envelope.ts"],"names":[],"mappings":"AAAA,OA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AC,GAAG,6BAA6B,EACnE,CAAC;QACD,gBAAgB,EAAE,CAAC;IACrB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ClaudePeerAdapter, type ClaudePeerInboundProgress, type ClaudePeerRegistryPublicationOutcome } from "./claude-peer.js";
|
|
2
2
|
import type { AttestedClaudePeerRuntime } from "./claude-runtime.js";
|
|
3
|
-
import { type
|
|
4
|
-
import { type CompatibilityAttestation, type CompatibilityCertification, type CompatibilityPolicy, type CompatibilityProbeResult, type CompatibilitySurfaceObservation } from "./compatibility.js";
|
|
3
|
+
import { type CompatibilityAttestation, type CompatibilityProbeResult, type CompatibilitySurfaceObservation } from "./compatibility.js";
|
|
5
4
|
import { type CodexConnectorObservation } from "./codex-app-server.js";
|
|
6
5
|
import type { LocalCodexTransportFactory } from "./codex-local-transport.js";
|
|
7
6
|
import type { GatewayDeliveryNoticeMode } from "./config.js";
|
|
@@ -28,8 +27,6 @@ export type LocalClaudeGatewayProviderOptions = {
|
|
|
28
27
|
}>;
|
|
29
28
|
/** Deterministic test seam. Production callers must omit this. */
|
|
30
29
|
peerFactory?: ClaudePeerFactory;
|
|
31
|
-
/** Deterministic test seam. Production starts one bounded local scratch. */
|
|
32
|
-
compatibilityScratchFactory?: ClaudeCompatibilityScratchFactory;
|
|
33
30
|
};
|
|
34
31
|
export type ClaudeNativeCodexSuccessionBarrier = Readonly<{
|
|
35
32
|
generation: string;
|
|
@@ -66,7 +63,6 @@ export declare class LocalClaudeGatewayProvider implements GatewayProviderAdapte
|
|
|
66
63
|
private readonly now;
|
|
67
64
|
private readonly selectedStateRoots;
|
|
68
65
|
private readonly nativeHelpers;
|
|
69
|
-
private readonly compatibilityScratchFactory;
|
|
70
66
|
private readonly discovered;
|
|
71
67
|
private readonly selected;
|
|
72
68
|
/** Exact live same-UID sessions observed through native inbound frames. */
|
|
@@ -99,17 +95,11 @@ export declare class LocalClaudeGatewayProvider implements GatewayProviderAdapte
|
|
|
99
95
|
private retiredNativeCodexListener;
|
|
100
96
|
/** Fences discovery callbacks and monitor restarts across listener rotation. */
|
|
101
97
|
private nativeCodexSuccessionFreeze;
|
|
102
|
-
private compatibilityCertificationInFlight;
|
|
103
98
|
private initialized;
|
|
104
99
|
private closed;
|
|
105
100
|
constructor(options: LocalClaudeGatewayProviderOptions);
|
|
106
101
|
compatibilitySurface(): CompatibilitySurfaceObservation;
|
|
107
102
|
runCompatibilityProbes(): Promise<readonly CompatibilityProbeResult[]>;
|
|
108
|
-
runCompatibilityCertification(input: Readonly<{
|
|
109
|
-
controllerStateRoot: string;
|
|
110
|
-
routeHandle?: string;
|
|
111
|
-
withTurn: boolean;
|
|
112
|
-
}>): Promise<CompatibilityCertification>;
|
|
113
103
|
initialize(callbacks: GatewayAdapterCallbacks): Promise<GatewayAdapterStart>;
|
|
114
104
|
discoverClaudePeers(): Promise<GatewayAdapterDiscoverySnapshot>;
|
|
115
105
|
assertWorkspaceDisjoint(routeHandle: string, stateRoot: string): Promise<void>;
|
|
@@ -203,8 +193,6 @@ export type LocalCodexGatewayProviderOptions = {
|
|
|
203
193
|
factory: LocalCodexTransportFactory;
|
|
204
194
|
/** Re-resolves the exact pinned managed install after its generation moves. */
|
|
205
195
|
refreshFactory?: () => Promise<LocalCodexTransportFactory>;
|
|
206
|
-
/** Controller policy retained across every endpoint generation. */
|
|
207
|
-
compatibilityPolicy?: CompatibilityPolicy;
|
|
208
196
|
cleanupPollMs?: number;
|
|
209
197
|
cleanupTimeoutMs?: number;
|
|
210
198
|
recoveryInitialMs?: number;
|
|
@@ -217,7 +205,6 @@ export type LocalCodexGatewayProviderOptions = {
|
|
|
217
205
|
export declare class LocalCodexGatewayProvider implements GatewayProviderAdapter {
|
|
218
206
|
private factory;
|
|
219
207
|
private readonly refreshFactory;
|
|
220
|
-
private readonly compatibilityPolicy;
|
|
221
208
|
private readonly maxCallbacks;
|
|
222
209
|
private readonly maxRoutes;
|
|
223
210
|
private readonly maxReplyBytes;
|
|
@@ -238,8 +225,6 @@ export declare class LocalCodexGatewayProvider implements GatewayProviderAdapter
|
|
|
238
225
|
private readonly trackedRoutes;
|
|
239
226
|
private retiredEndpointGeneration;
|
|
240
227
|
private readonly expectsReply;
|
|
241
|
-
private readonly compatibilityCertifyingRoutes;
|
|
242
|
-
private readonly compatibilityTurns;
|
|
243
228
|
private readonly callbackQueue;
|
|
244
229
|
private callbackScheduled;
|
|
245
230
|
private callbacks;
|
|
@@ -263,11 +248,6 @@ export declare class LocalCodexGatewayProvider implements GatewayProviderAdapter
|
|
|
263
248
|
acceptCompatibilityAttestation(attestation: CompatibilityAttestation): void;
|
|
264
249
|
runCompatibilityProbes(): Promise<readonly CompatibilityProbeResult[]>;
|
|
265
250
|
private runCompatibilityProbesFor;
|
|
266
|
-
runCompatibilityCertification(input: Readonly<{
|
|
267
|
-
controllerStateRoot: string;
|
|
268
|
-
routeHandle?: string;
|
|
269
|
-
withTurn: boolean;
|
|
270
|
-
}>): Promise<CompatibilityCertification>;
|
|
271
251
|
initialize(callbacks: GatewayAdapterCallbacks): Promise<GatewayAdapterStart>;
|
|
272
252
|
selectRoute(input: {
|
|
273
253
|
alias: string;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { createHash
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { BridgeError } from "../errors.js";
|
|
4
4
|
import { CLAUDE_PEER_COMPATIBILITY, ClaudePeerAdapter, } from "./claude-peer.js";
|
|
5
|
-
import { startClaudeCompatibilityScratch, } from "./claude-compatibility-scratch.js";
|
|
6
5
|
import { certifiedCompatibilityVersions, compatibilityProbeNames, evaluateCompatibilityAttestation, sharesCompatibilityMajor, } from "./compatibility.js";
|
|
7
6
|
import { CODEX_APP_SERVER_WRITABLE_VERSIONS, CodexAppServerConnector, CodexConnectorError, } from "./codex-app-server.js";
|
|
8
7
|
import { LocalCodexTransportError } from "./codex-local-transport.js";
|
|
@@ -25,9 +24,6 @@ const DEFAULT_CODEX_RECOVERY_INITIAL_MS = 250;
|
|
|
25
24
|
const DEFAULT_CODEX_RECOVERY_MAX_MS = 5_000;
|
|
26
25
|
const MAX_CODEX_ENDPOINT_REFRESH_CANDIDATES = 3;
|
|
27
26
|
const COMPATIBILITY_PROBE_THREAD_ID = "00000000-0000-7000-8000-000000000000";
|
|
28
|
-
const COMPATIBILITY_TURN_TIMEOUT_MS = 60_000;
|
|
29
|
-
const CLAUDE_CERTIFICATION_TIMEOUT_MS = 10_000;
|
|
30
|
-
const CLAUDE_CERTIFICATION_DISCOVERY_POLL_MS = 100;
|
|
31
27
|
const CLAUDE_CLEAN_PREWRITE_RETRY_CODES = new Set([
|
|
32
28
|
"CLAUDE_PEER_TARGET_UNKNOWN",
|
|
33
29
|
"CLAUDE_PEER_TARGET_STALE",
|
|
@@ -109,7 +105,8 @@ function invokeCallback(operation) {
|
|
|
109
105
|
}
|
|
110
106
|
}
|
|
111
107
|
function validateAttestedClaudeRuntime(runtime) {
|
|
112
|
-
if (
|
|
108
|
+
if (runtime.claudeCodeVersion !==
|
|
109
|
+
CLAUDE_PEER_COMPATIBILITY.claudeCodeVersion ||
|
|
113
110
|
[
|
|
114
111
|
runtime.claudeExecutable,
|
|
115
112
|
runtime.sessionsDir,
|
|
@@ -146,7 +143,6 @@ export class LocalClaudeGatewayProvider {
|
|
|
146
143
|
now;
|
|
147
144
|
selectedStateRoots = new Map();
|
|
148
145
|
nativeHelpers;
|
|
149
|
-
compatibilityScratchFactory;
|
|
150
146
|
discovered = new Map();
|
|
151
147
|
selected = new Map();
|
|
152
148
|
/** Exact live same-UID sessions observed through native inbound frames. */
|
|
@@ -179,7 +175,6 @@ export class LocalClaudeGatewayProvider {
|
|
|
179
175
|
retiredNativeCodexListener;
|
|
180
176
|
/** Fences discovery callbacks and monitor restarts across listener rotation. */
|
|
181
177
|
nativeCodexSuccessionFreeze;
|
|
182
|
-
compatibilityCertificationInFlight = false;
|
|
183
178
|
initialized = false;
|
|
184
179
|
closed = false;
|
|
185
180
|
constructor(options) {
|
|
@@ -205,9 +200,6 @@ export class LocalClaudeGatewayProvider {
|
|
|
205
200
|
locale,
|
|
206
201
|
deliveryNotices,
|
|
207
202
|
})))(options.runtime, options.locale ?? "en", options.deliveryNotices ?? "merged");
|
|
208
|
-
this.compatibilityScratchFactory =
|
|
209
|
-
options.compatibilityScratchFactory ??
|
|
210
|
-
(() => startClaudeCompatibilityScratch(options.runtime));
|
|
211
203
|
this.nativeHelpers =
|
|
212
204
|
options.nativeHelpers === undefined
|
|
213
205
|
? undefined
|
|
@@ -258,90 +250,6 @@ export class LocalClaudeGatewayProvider {
|
|
|
258
250
|
];
|
|
259
251
|
}
|
|
260
252
|
}
|
|
261
|
-
async runCompatibilityCertification(input) {
|
|
262
|
-
void input.routeHandle;
|
|
263
|
-
void input.withTurn;
|
|
264
|
-
const depth = "wire";
|
|
265
|
-
let scratch;
|
|
266
|
-
let listener;
|
|
267
|
-
if (this.compatibilityCertificationInFlight) {
|
|
268
|
-
return {
|
|
269
|
-
depth,
|
|
270
|
-
outcome: "fail",
|
|
271
|
-
certifiedAt: new Date(this.now()).toISOString(),
|
|
272
|
-
safeErrorCode: "CLAUDE_CERTIFICATION_BUSY",
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
this.compatibilityCertificationInFlight = true;
|
|
276
|
-
try {
|
|
277
|
-
this.assertReady();
|
|
278
|
-
scratch = await this.compatibilityScratchFactory();
|
|
279
|
-
const deadlineAt = this.now() + CLAUDE_CERTIFICATION_TIMEOUT_MS;
|
|
280
|
-
let targetId;
|
|
281
|
-
while (this.now() < deadlineAt) {
|
|
282
|
-
scratch.assertRunning();
|
|
283
|
-
const discovery = await this.peer.discover();
|
|
284
|
-
if (discovery.truncated) {
|
|
285
|
-
throw new BridgeError("CLAUDE_CERTIFICATION_DISCOVERY_INCOMPLETE", "The scratch session could not be proven from a complete registry scan.", true);
|
|
286
|
-
}
|
|
287
|
-
const matches = discovery.peers.filter((peer) => peer.alias === scratch?.name && peer.targetId === scratch?.sessionId);
|
|
288
|
-
if (matches.length > 1) {
|
|
289
|
-
throw new BridgeError("CLAUDE_CERTIFICATION_TARGET_COLLISION", "The scratch session identity was not unique.");
|
|
290
|
-
}
|
|
291
|
-
if (matches.length === 1) {
|
|
292
|
-
targetId = matches[0]?.targetId;
|
|
293
|
-
break;
|
|
294
|
-
}
|
|
295
|
-
await new Promise((resolve) => {
|
|
296
|
-
const timer = setTimeout(resolve, CLAUDE_CERTIFICATION_DISCOVERY_POLL_MS);
|
|
297
|
-
timer.unref();
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
if (targetId === undefined) {
|
|
301
|
-
throw new BridgeError("CLAUDE_CERTIFICATION_TARGET_UNAVAILABLE", "The bounded scratch session did not publish a discoverable peer record.", true);
|
|
302
|
-
}
|
|
303
|
-
await this.peer.assertTargetWorkspaceDisjoint(targetId, input.controllerStateRoot);
|
|
304
|
-
listener = await this.peer.listen({
|
|
305
|
-
onMessage: () => undefined,
|
|
306
|
-
onReceipt: () => undefined,
|
|
307
|
-
});
|
|
308
|
-
const sent = await this.peer.send(targetId, "[embassy compat-certify] ignore", {
|
|
309
|
-
listener,
|
|
310
|
-
receiptDeadlineAt: deadlineAt,
|
|
311
|
-
});
|
|
312
|
-
if (sent.transportStatus !== "transport_written" ||
|
|
313
|
-
sent.receiptStatus !== "pending") {
|
|
314
|
-
throw new BridgeError("CLAUDE_CERTIFICATION_WRITE_UNCONFIRMED", "The scratch diagnostic frame was not accepted for receipt tracking.", true);
|
|
315
|
-
}
|
|
316
|
-
// A direct `crossSessionInbound: accept` write emits no native
|
|
317
|
-
// peer_message_status frame. That status family describes the optional
|
|
318
|
-
// approval lifecycle, not universal delivery acknowledgement. For this
|
|
319
|
-
// wire-depth certification, the strongest portable evidence is the
|
|
320
|
-
// confirmed write to the exact, uniquely discovered scratch session.
|
|
321
|
-
return {
|
|
322
|
-
depth,
|
|
323
|
-
outcome: "pass",
|
|
324
|
-
certifiedAt: new Date(this.now()).toISOString(),
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
catch (error) {
|
|
328
|
-
const observedCode = error instanceof BridgeError && /^[A-Z][A-Z0-9_]{0,63}$/.test(error.code)
|
|
329
|
-
? error.code
|
|
330
|
-
: "CLAUDE_CERTIFICATION_FAILED";
|
|
331
|
-
return {
|
|
332
|
-
depth,
|
|
333
|
-
outcome: "fail",
|
|
334
|
-
certifiedAt: new Date(this.now()).toISOString(),
|
|
335
|
-
safeErrorCode: observedCode,
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
finally {
|
|
339
|
-
await listener?.close().catch(() => undefined);
|
|
340
|
-
await scratch?.close().catch(() => undefined);
|
|
341
|
-
await this.peer.discover().catch(() => undefined);
|
|
342
|
-
this.compatibilityCertificationInFlight = false;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
253
|
async initialize(callbacks) {
|
|
346
254
|
if (this.closed) {
|
|
347
255
|
throw new BridgeError("CLAUDE_PROVIDER_CLOSED", "The local Claude provider is closed.");
|
|
@@ -871,9 +779,7 @@ export class LocalClaudeGatewayProvider {
|
|
|
871
779
|
const selectedAlias = this.selected.get(input.binding.routeHandle);
|
|
872
780
|
const stateRoot = this.selectedStateRoots.get(input.binding.routeHandle);
|
|
873
781
|
if (input.authorization === "selected_route" &&
|
|
874
|
-
(selectedAlias === undefined ||
|
|
875
|
-
selectedAlias !== input.targetAlias ||
|
|
876
|
-
stateRoot === undefined)) {
|
|
782
|
+
(selectedAlias === undefined || stateRoot === undefined)) {
|
|
877
783
|
return { state: "failed", safeErrorCode: "CLAUDE_ROUTE_UNAVAILABLE" };
|
|
878
784
|
}
|
|
879
785
|
if (input.authorization === "selected_route") {
|
|
@@ -919,29 +825,17 @@ export class LocalClaudeGatewayProvider {
|
|
|
919
825
|
return { state: "failed", safeErrorCode: "CLAUDE_ROUTE_UNAVAILABLE" };
|
|
920
826
|
}
|
|
921
827
|
if (input.authorization === "native_reply") {
|
|
922
|
-
try {
|
|
923
|
-
await this.refreshClaudeDiscovery();
|
|
924
|
-
}
|
|
925
|
-
catch {
|
|
926
|
-
return { state: "failed", safeErrorCode: "CLAUDE_ROUTE_UNAVAILABLE" };
|
|
927
|
-
}
|
|
928
828
|
const observedRoute = this.nativeInbound.get(input.binding.routeHandle);
|
|
929
|
-
const current = this.discovered.get(input.binding.routeHandle);
|
|
930
829
|
if (observedRoute === undefined ||
|
|
931
|
-
observedRoute.listenerGeneration !== activeListener.generation
|
|
932
|
-
current?.alias !== observedRoute.alias) {
|
|
830
|
+
observedRoute.listenerGeneration !== activeListener.generation) {
|
|
933
831
|
this.nativeInbound.delete(input.binding.routeHandle);
|
|
934
832
|
return { state: "failed", safeErrorCode: "CLAUDE_NATIVE_REPLY_STALE" };
|
|
935
833
|
}
|
|
936
|
-
if (observedRoute.alias !== input.targetAlias) {
|
|
937
|
-
return { state: "failed", safeErrorCode: "CLAUDE_ROUTE_UNAVAILABLE" };
|
|
938
|
-
}
|
|
939
834
|
}
|
|
940
835
|
else {
|
|
941
836
|
const selectedAlias = this.selected.get(input.binding.routeHandle);
|
|
942
837
|
const stateRoot = this.selectedStateRoots.get(input.binding.routeHandle);
|
|
943
838
|
if (selectedAlias === undefined ||
|
|
944
|
-
selectedAlias !== input.targetAlias ||
|
|
945
839
|
stateRoot === undefined) {
|
|
946
840
|
return { state: "failed", safeErrorCode: "CLAUDE_ROUTE_UNAVAILABLE" };
|
|
947
841
|
}
|
|
@@ -987,8 +881,8 @@ export class LocalClaudeGatewayProvider {
|
|
|
987
881
|
}
|
|
988
882
|
this.selectedDispatchEpoch.set(input.binding.routeHandle, (this.selectedDispatchEpoch.get(input.binding.routeHandle) ?? 0) + 1);
|
|
989
883
|
// The exact workspace attestation is refreshed before every send. A
|
|
990
|
-
// clean failure
|
|
991
|
-
//
|
|
884
|
+
// clean prewrite failure remains retryable within the message deadline;
|
|
885
|
+
// retry timing does not depend on the model turn's observed state.
|
|
992
886
|
this.selectedObservationDirty.add(input.binding.routeHandle);
|
|
993
887
|
this.emitClaudeRouteObservation(input.binding.routeHandle, "busy");
|
|
994
888
|
try {
|
|
@@ -1558,29 +1452,16 @@ export class LocalClaudeGatewayProvider {
|
|
|
1558
1452
|
this.discovered.set(peer.targetId, row);
|
|
1559
1453
|
rows.push(row);
|
|
1560
1454
|
}
|
|
1561
|
-
for (const [routeHandle, route] of this.nativeInbound) {
|
|
1562
|
-
const current = this.discovered.get(routeHandle);
|
|
1563
|
-
if (current !== undefined) {
|
|
1564
|
-
// The stable session UUID owns native reply authority. A rename only
|
|
1565
|
-
// updates its current public coordinate.
|
|
1566
|
-
this.nativeInbound.set(routeHandle, {
|
|
1567
|
-
alias: current.alias,
|
|
1568
|
-
listenerGeneration: route.listenerGeneration,
|
|
1569
|
-
});
|
|
1570
|
-
}
|
|
1571
|
-
else if (!discovery.truncated) {
|
|
1572
|
-
this.nativeInbound.delete(routeHandle);
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
1455
|
for (const [routeHandle, selectedAlias] of this.selected) {
|
|
1576
1456
|
const row = this.discovered.get(routeHandle);
|
|
1577
1457
|
if (row === undefined) {
|
|
1578
1458
|
this.emitClaudeRouteObservation(routeHandle, "busy", "CLAUDE_PEER_NOT_OBSERVED", true);
|
|
1579
1459
|
}
|
|
1580
1460
|
else {
|
|
1581
|
-
if (row.alias !== selectedAlias) {
|
|
1461
|
+
if (!discovery.truncated && row.alias !== selectedAlias) {
|
|
1582
1462
|
// A Claude rename changes only the live name index. The native
|
|
1583
|
-
// session UUID remains the selected logical route.
|
|
1463
|
+
// session UUID remains the selected logical route. An incomplete
|
|
1464
|
+
// scan is display evidence only and cannot rename dispatch authority.
|
|
1584
1465
|
this.selected.set(routeHandle, row.alias);
|
|
1585
1466
|
}
|
|
1586
1467
|
if (row.state === "idle" &&
|
|
@@ -1665,7 +1546,8 @@ function validateCodexFactory(factory) {
|
|
|
1665
1546
|
if (factory.hostId !== LOCAL_HOST ||
|
|
1666
1547
|
factory.protocol !== "codex-app-server" ||
|
|
1667
1548
|
factory.protocolVersion !== factory.appServerVersion ||
|
|
1668
|
-
(!certified &&
|
|
1549
|
+
(!certified &&
|
|
1550
|
+
(!schemaCandidate || write !== null || factory.writableReady)) ||
|
|
1669
1551
|
schema.appServerVersion !== factory.appServerVersion ||
|
|
1670
1552
|
schema.endpointGeneration !== factory.endpointGeneration ||
|
|
1671
1553
|
schema.protocol !== "app-server-v2-stable" ||
|
|
@@ -1714,7 +1596,6 @@ function codexRouteSafeCode(observation) {
|
|
|
1714
1596
|
export class LocalCodexGatewayProvider {
|
|
1715
1597
|
factory;
|
|
1716
1598
|
refreshFactory;
|
|
1717
|
-
compatibilityPolicy;
|
|
1718
1599
|
maxCallbacks;
|
|
1719
1600
|
maxRoutes;
|
|
1720
1601
|
maxReplyBytes;
|
|
@@ -1735,8 +1616,6 @@ export class LocalCodexGatewayProvider {
|
|
|
1735
1616
|
trackedRoutes = new Set();
|
|
1736
1617
|
retiredEndpointGeneration;
|
|
1737
1618
|
expectsReply = new Map();
|
|
1738
|
-
compatibilityCertifyingRoutes = new Set();
|
|
1739
|
-
compatibilityTurns = new Map();
|
|
1740
1619
|
callbackQueue = [];
|
|
1741
1620
|
callbackScheduled = false;
|
|
1742
1621
|
callbacks;
|
|
@@ -1756,8 +1635,6 @@ export class LocalCodexGatewayProvider {
|
|
|
1756
1635
|
validateCodexFactory(options.factory);
|
|
1757
1636
|
this.factory = options.factory;
|
|
1758
1637
|
this.refreshFactory = options.refreshFactory;
|
|
1759
|
-
this.compatibilityPolicy =
|
|
1760
|
-
options.compatibilityPolicy ?? options.factory.compatibilityPolicy;
|
|
1761
1638
|
exactLocalHost(options.factory.hostId);
|
|
1762
1639
|
this.compatibilityAttested = CODEX_APP_SERVER_WRITABLE_VERSIONS.includes(options.factory.appServerVersion);
|
|
1763
1640
|
this.maxCallbacks = positiveBounded(options.maxCallbackEvents, MAX_CODEX_CALLBACKS, 4_096);
|
|
@@ -1795,7 +1672,8 @@ export class LocalCodexGatewayProvider {
|
|
|
1795
1672
|
const pending = this.pendingEndpointAttestation;
|
|
1796
1673
|
if (attestation.surface !== "codex" ||
|
|
1797
1674
|
attestation.version !== this.factory.appServerVersion ||
|
|
1798
|
-
attestation.tier
|
|
1675
|
+
attestation.tier !== "certified" ||
|
|
1676
|
+
!CODEX_APP_SERVER_WRITABLE_VERSIONS.includes(attestation.version) ||
|
|
1799
1677
|
(this.endpointUnavailable && pending === undefined) ||
|
|
1800
1678
|
(pending !== undefined &&
|
|
1801
1679
|
(attestation.checkedAt !== pending.checkedAt ||
|
|
@@ -1885,107 +1763,6 @@ export class LocalCodexGatewayProvider {
|
|
|
1885
1763
|
}
|
|
1886
1764
|
}
|
|
1887
1765
|
}
|
|
1888
|
-
async runCompatibilityCertification(input) {
|
|
1889
|
-
void input.controllerStateRoot;
|
|
1890
|
-
const certifiedAt = this.now().toISOString();
|
|
1891
|
-
const depth = input.withTurn ? "turn" : "thread_ops";
|
|
1892
|
-
const routeHandle = input.routeHandle;
|
|
1893
|
-
if (routeHandle === undefined || this.compatibilityCertifyingRoutes.has(routeHandle)) {
|
|
1894
|
-
return {
|
|
1895
|
-
depth,
|
|
1896
|
-
outcome: "fail",
|
|
1897
|
-
certifiedAt,
|
|
1898
|
-
safeErrorCode: "CODEX_CERTIFICATION_ROUTE_REQUIRED",
|
|
1899
|
-
};
|
|
1900
|
-
}
|
|
1901
|
-
this.assertReady();
|
|
1902
|
-
const route = this.routes.get(routeHandle);
|
|
1903
|
-
if (route === undefined || !this.observeRouteSuccessionBarrier(routeHandle).clean) {
|
|
1904
|
-
return {
|
|
1905
|
-
depth,
|
|
1906
|
-
outcome: "fail",
|
|
1907
|
-
certifiedAt,
|
|
1908
|
-
safeErrorCode: "CODEX_CERTIFICATION_ROUTE_BUSY",
|
|
1909
|
-
};
|
|
1910
|
-
}
|
|
1911
|
-
this.compatibilityCertifyingRoutes.add(routeHandle);
|
|
1912
|
-
try {
|
|
1913
|
-
const loaded = await route.connector.observeLoadedThread(route.connector.guard());
|
|
1914
|
-
if (!loaded.selectedThreadLoaded) {
|
|
1915
|
-
return {
|
|
1916
|
-
depth,
|
|
1917
|
-
outcome: "fail",
|
|
1918
|
-
certifiedAt: this.now().toISOString(),
|
|
1919
|
-
safeErrorCode: "CODEX_CERTIFICATION_THREAD_UNAVAILABLE",
|
|
1920
|
-
};
|
|
1921
|
-
}
|
|
1922
|
-
await route.connector.certifyThreadOperations(route.connector.guard());
|
|
1923
|
-
if (!input.withTurn) {
|
|
1924
|
-
return {
|
|
1925
|
-
depth,
|
|
1926
|
-
outcome: "pass",
|
|
1927
|
-
certifiedAt: this.now().toISOString(),
|
|
1928
|
-
};
|
|
1929
|
-
}
|
|
1930
|
-
const messageId = `compat_${randomBytes(12).toString("hex")}`;
|
|
1931
|
-
const result = new Promise((resolve) => {
|
|
1932
|
-
const timer = setTimeout(() => {
|
|
1933
|
-
this.compatibilityTurns.delete(messageId);
|
|
1934
|
-
resolve({
|
|
1935
|
-
messageId,
|
|
1936
|
-
outcome: "expired",
|
|
1937
|
-
replyCode: "REPLY_UNAVAILABLE",
|
|
1938
|
-
text: null,
|
|
1939
|
-
});
|
|
1940
|
-
}, COMPATIBILITY_TURN_TIMEOUT_MS);
|
|
1941
|
-
timer.unref();
|
|
1942
|
-
this.compatibilityTurns.set(messageId, { resolve, timer });
|
|
1943
|
-
});
|
|
1944
|
-
try {
|
|
1945
|
-
const disposition = await route.connector.submitMessage(route.connector.guard(), {
|
|
1946
|
-
deadlineAt: new Date(this.now().getTime() + COMPATIBILITY_TURN_TIMEOUT_MS).toISOString(),
|
|
1947
|
-
messageId,
|
|
1948
|
-
text: "reply OK",
|
|
1949
|
-
});
|
|
1950
|
-
if (disposition.disposition !== "started") {
|
|
1951
|
-
throw new BridgeError("CODEX_CERTIFICATION_TURN_NOT_STARTED", "The bounded certification turn did not start on the exact idle route.");
|
|
1952
|
-
}
|
|
1953
|
-
const settled = await result;
|
|
1954
|
-
if (settled.outcome !== "completed" ||
|
|
1955
|
-
settled.text?.trim() !== "OK") {
|
|
1956
|
-
return {
|
|
1957
|
-
depth,
|
|
1958
|
-
outcome: "fail",
|
|
1959
|
-
certifiedAt: this.now().toISOString(),
|
|
1960
|
-
safeErrorCode: "CODEX_CERTIFICATION_TURN_FAILED",
|
|
1961
|
-
};
|
|
1962
|
-
}
|
|
1963
|
-
return {
|
|
1964
|
-
depth,
|
|
1965
|
-
outcome: "pass",
|
|
1966
|
-
certifiedAt: this.now().toISOString(),
|
|
1967
|
-
};
|
|
1968
|
-
}
|
|
1969
|
-
finally {
|
|
1970
|
-
const pending = this.compatibilityTurns.get(messageId);
|
|
1971
|
-
if (pending !== undefined) {
|
|
1972
|
-
clearTimeout(pending.timer);
|
|
1973
|
-
this.compatibilityTurns.delete(messageId);
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
1976
|
-
}
|
|
1977
|
-
catch {
|
|
1978
|
-
return {
|
|
1979
|
-
depth,
|
|
1980
|
-
outcome: "fail",
|
|
1981
|
-
certifiedAt: this.now().toISOString(),
|
|
1982
|
-
safeErrorCode: "CODEX_CERTIFICATION_FAILED",
|
|
1983
|
-
};
|
|
1984
|
-
}
|
|
1985
|
-
finally {
|
|
1986
|
-
this.compatibilityCertifyingRoutes.delete(routeHandle);
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
1766
|
async initialize(callbacks) {
|
|
1990
1767
|
if (this.closed || this.initialized) {
|
|
1991
1768
|
throw new BridgeError("CODEX_PROVIDER_INITIALIZATION_REJECTED", "The local Codex provider cannot be initialized in this state.");
|
|
@@ -2172,9 +1949,6 @@ export class LocalCodexGatewayProvider {
|
|
|
2172
1949
|
route.endpointGeneration !== this.factory.endpointGeneration) {
|
|
2173
1950
|
return { state: "failed", safeErrorCode: "CODEX_ROUTE_UNAVAILABLE" };
|
|
2174
1951
|
}
|
|
2175
|
-
if (this.compatibilityCertifyingRoutes.has(input.binding.routeHandle)) {
|
|
2176
|
-
return { state: "deferred", safeErrorCode: "CODEX_ROUTE_HELD" };
|
|
2177
|
-
}
|
|
2178
1952
|
if (!this.factory.writableReady ||
|
|
2179
1953
|
this.factory.writeCompatibility === null) {
|
|
2180
1954
|
return { state: "failed", safeErrorCode: "CODEX_WRITES_DISABLED" };
|
|
@@ -2321,17 +2095,6 @@ export class LocalCodexGatewayProvider {
|
|
|
2321
2095
|
this.closed = true;
|
|
2322
2096
|
this.closing = false;
|
|
2323
2097
|
this.callbackQueue.length = 0;
|
|
2324
|
-
for (const [messageId, pending] of this.compatibilityTurns) {
|
|
2325
|
-
clearTimeout(pending.timer);
|
|
2326
|
-
pending.resolve({
|
|
2327
|
-
messageId,
|
|
2328
|
-
outcome: "abandoned",
|
|
2329
|
-
replyCode: "REPLY_UNAVAILABLE",
|
|
2330
|
-
text: null,
|
|
2331
|
-
});
|
|
2332
|
-
}
|
|
2333
|
-
this.compatibilityTurns.clear();
|
|
2334
|
-
this.compatibilityCertifyingRoutes.clear();
|
|
2335
2098
|
this.pendingEndpointAttestation = undefined;
|
|
2336
2099
|
this.pendingEndpointRefreshEvent = undefined;
|
|
2337
2100
|
this.trackedRoutes.clear();
|
|
@@ -2723,8 +2486,7 @@ export class LocalCodexGatewayProvider {
|
|
|
2723
2486
|
candidate = await refreshFactory();
|
|
2724
2487
|
validateCodexFactory(candidate);
|
|
2725
2488
|
if (candidate.hostId !== previous.hostId ||
|
|
2726
|
-
candidate.protocol !== previousFactory.protocol
|
|
2727
|
-
candidate.compatibilityPolicy !== this.compatibilityPolicy) {
|
|
2489
|
+
candidate.protocol !== previousFactory.protocol) {
|
|
2728
2490
|
throw new BridgeError("CODEX_FACTORY_ATTESTATION_INVALID", "The replacement Codex factory moved outside its pinned boundary.");
|
|
2729
2491
|
}
|
|
2730
2492
|
if (candidate === previousFactory ||
|
|
@@ -2744,7 +2506,6 @@ export class LocalCodexGatewayProvider {
|
|
|
2744
2506
|
surface: "codex",
|
|
2745
2507
|
version: candidate.appServerVersion,
|
|
2746
2508
|
checkedAt: this.now().toISOString(),
|
|
2747
|
-
policy: this.compatibilityPolicy,
|
|
2748
2509
|
certifiedVersions: certifiedCompatibilityVersions.codex,
|
|
2749
2510
|
probes,
|
|
2750
2511
|
});
|
|
@@ -2881,13 +2642,6 @@ export class LocalCodexGatewayProvider {
|
|
|
2881
2642
|
invokeCallback(() => callbacks.onEndpointRefresh?.(event));
|
|
2882
2643
|
}
|
|
2883
2644
|
onTurnResult(endpointGeneration, result) {
|
|
2884
|
-
const certification = this.compatibilityTurns.get(result.messageId);
|
|
2885
|
-
if (certification !== undefined) {
|
|
2886
|
-
clearTimeout(certification.timer);
|
|
2887
|
-
this.compatibilityTurns.delete(result.messageId);
|
|
2888
|
-
certification.resolve(result);
|
|
2889
|
-
return;
|
|
2890
|
-
}
|
|
2891
2645
|
const wantsReply = this.expectsReply.get(result.messageId) === true;
|
|
2892
2646
|
this.expectsReply.delete(result.messageId);
|
|
2893
2647
|
let replyText;
|