agent-embassy 1.0.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 +68 -0
- package/CONTRIBUTING.md +25 -7
- package/README.md +66 -13
- package/README.zh-CN.md +41 -13
- package/SECURITY.md +80 -42
- package/assets/live-dashboard/app.css +14 -5
- package/dist/src/gateway/claude-helper-protocol.d.ts +3 -0
- package/dist/src/gateway/claude-helper-protocol.js +15 -1
- package/dist/src/gateway/claude-helper-protocol.js.map +1 -1
- package/dist/src/gateway/claude-helper-supervisor.d.ts +2 -0
- package/dist/src/gateway/claude-helper-supervisor.js +24 -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 +4 -1
- package/dist/src/gateway/cli-copy.en.js +6 -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 +4 -1
- package/dist/src/gateway/cli-copy.zh-CN.js +6 -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 +49 -73
- 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 +10 -53
- package/dist/src/gateway/codex-app-server.js.map +1 -1
- package/dist/src/gateway/codex-local-transport.d.ts +10 -3
- package/dist/src/gateway/codex-local-transport.js +25 -9
- 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 +4 -12
- package/dist/src/gateway/config.js.map +1 -1
- package/dist/src/gateway/control.d.ts +11 -20
- package/dist/src/gateway/control.js +50 -47
- 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 +12 -7
- package/dist/src/gateway/dashboard-copy.en.js +26 -21
- package/dist/src/gateway/dashboard-copy.en.js.map +1 -1
- package/dist/src/gateway/dashboard-copy.js +12 -7
- package/dist/src/gateway/dashboard-copy.js.map +1 -1
- package/dist/src/gateway/dashboard-copy.zh-CN.d.ts +12 -7
- package/dist/src/gateway/dashboard-copy.zh-CN.js +26 -21
- package/dist/src/gateway/dashboard-copy.zh-CN.js.map +1 -1
- package/dist/src/gateway/dashboard-model.d.ts +7 -9
- package/dist/src/gateway/dashboard-model.js +47 -16
- package/dist/src/gateway/dashboard-model.js.map +1 -1
- package/dist/src/gateway/dashboard.js +10 -10
- package/dist/src/gateway/dashboard.js.map +1 -1
- package/dist/src/gateway/live-dashboard-app/app.js +65 -55
- package/dist/src/gateway/live-dashboard-command.d.ts +5 -1
- package/dist/src/gateway/live-dashboard-command.js +18 -6
- package/dist/src/gateway/live-dashboard-command.js.map +1 -1
- package/dist/src/gateway/live-dashboard-http.d.ts +3 -4
- package/dist/src/gateway/live-dashboard-http.js +32 -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-stream.js +26 -25
- package/dist/src/gateway/live-dashboard-stream.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.d.ts +16 -0
- package/dist/src/gateway/provenance-envelope.js +80 -0
- package/dist/src/gateway/provenance-envelope.js.map +1 -0
- package/dist/src/gateway/providers.d.ts +40 -33
- package/dist/src/gateway/providers.js +683 -302
- package/dist/src/gateway/providers.js.map +1 -1
- package/dist/src/gateway/server.d.ts +2 -0
- package/dist/src/gateway/server.js +8 -5
- package/dist/src/gateway/server.js.map +1 -1
- package/dist/src/gateway/service.d.ts +103 -23
- package/dist/src/gateway/service.js +1346 -272
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/gateway/store.d.ts +39 -3
- package/dist/src/gateway/store.js +604 -44
- package/dist/src/gateway/store.js.map +1 -1
- package/dist/src/gateway/types.d.ts +90 -9
- package/dist/src/gateway/types.js +6 -0
- package/dist/src/gateway/types.js.map +1 -1
- package/docs/GATEWAY-ARCHITECTURE.md +155 -56
- package/package.json +3 -2
- package/skills/embassy-peer/SKILL.md +36 -7
- 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,5 +1,5 @@
|
|
|
1
1
|
import type { GatewayConfig } from "./config.js";
|
|
2
|
-
import { type CompatibilityAttestation, type
|
|
2
|
+
import { type CompatibilityAttestation, type CompatibilityProbeResult, type CompatibilitySurfaceObservation } from "./compatibility.js";
|
|
3
3
|
import { type GatewayControlHandlers, type GatewaySnapshotObservation } from "./control.js";
|
|
4
4
|
import { publishGatewayDashboard } from "./dashboard.js";
|
|
5
5
|
import { GatewayStore } from "./store.js";
|
|
@@ -32,6 +32,25 @@ export type GatewayAdapterDelivery = {
|
|
|
32
32
|
/** Transient, bounded by the adapter. Never copied into normalized state. */
|
|
33
33
|
replyText?: string;
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* One provider-wide Codex endpoint transition. Native thread and generation
|
|
37
|
+
* identifiers stay inside this controller boundary and are never projected.
|
|
38
|
+
*/
|
|
39
|
+
export type GatewayAdapterEndpointRefresh = Readonly<{
|
|
40
|
+
outcome: "compatible";
|
|
41
|
+
previous: PrivateEndpointIdentity;
|
|
42
|
+
current: PrivateEndpointIdentity;
|
|
43
|
+
attestation: CompatibilityAttestation;
|
|
44
|
+
routes: readonly Readonly<{
|
|
45
|
+
routeHandle: string;
|
|
46
|
+
state: GatewayAdapterRouteState;
|
|
47
|
+
}>[];
|
|
48
|
+
}> | Readonly<{
|
|
49
|
+
outcome: "incompatible";
|
|
50
|
+
previous: PrivateEndpointIdentity;
|
|
51
|
+
candidate: PrivateEndpointIdentity;
|
|
52
|
+
attestation: CompatibilityAttestation;
|
|
53
|
+
}>;
|
|
35
54
|
export type GatewayAdapterCallbacks = {
|
|
36
55
|
onDelivery: (event: GatewayAdapterDelivery) => void;
|
|
37
56
|
onRouteState: (event: {
|
|
@@ -61,6 +80,8 @@ export type GatewayAdapterCallbacks = {
|
|
|
61
80
|
onProtocolNotice?: (event: {
|
|
62
81
|
code: string;
|
|
63
82
|
}) => void;
|
|
83
|
+
/** Provider-wide, compatibility-gated Codex endpoint replacement. */
|
|
84
|
+
onEndpointRefresh?: (event: GatewayAdapterEndpointRefresh) => void;
|
|
64
85
|
};
|
|
65
86
|
export type GatewayAdapterStart = {
|
|
66
87
|
health: "healthy" | "degraded";
|
|
@@ -81,6 +102,23 @@ export type GatewayAdapterDispatchResult = {
|
|
|
81
102
|
safeErrorCode?: string;
|
|
82
103
|
replyText?: string;
|
|
83
104
|
};
|
|
105
|
+
/**
|
|
106
|
+
* One transient, service-authorized provider dispatch. Provenance fields are
|
|
107
|
+
* carried beside the raw body so the provider can frame it exactly once at
|
|
108
|
+
* its semantic write boundary. They must not be projected or persisted.
|
|
109
|
+
*/
|
|
110
|
+
export type GatewayAdapterDispatchInput = {
|
|
111
|
+
sourceAlias: string;
|
|
112
|
+
targetAlias: string;
|
|
113
|
+
conversationId: string;
|
|
114
|
+
binding: PrivateRouteBinding;
|
|
115
|
+
authorization: "selected_route" | "native_reply";
|
|
116
|
+
messageId: string;
|
|
117
|
+
text: string;
|
|
118
|
+
expectsReply: boolean;
|
|
119
|
+
deadlineAt: string;
|
|
120
|
+
steer?: true;
|
|
121
|
+
};
|
|
84
122
|
/**
|
|
85
123
|
* Narrow provider boundary. Production adapters wrap ClaudePeerAdapter or one
|
|
86
124
|
* exact CodexAppServerConnector; tests use in-memory fakes. Implementations
|
|
@@ -90,15 +128,10 @@ export interface GatewayProviderAdapter {
|
|
|
90
128
|
readonly identity: PrivateEndpointIdentity;
|
|
91
129
|
readonly protocol: string;
|
|
92
130
|
readonly protocolVersion: string;
|
|
93
|
-
/** Version identity is cheap; probes
|
|
131
|
+
/** Version identity is cheap; bounded probes run fresh on every startup. */
|
|
94
132
|
compatibilitySurface?(): CompatibilitySurfaceObservation;
|
|
95
133
|
runCompatibilityProbes?(): Promise<readonly CompatibilityProbeResult[]>;
|
|
96
134
|
acceptCompatibilityAttestation?(attestation: CompatibilityAttestation): void;
|
|
97
|
-
runCompatibilityCertification?(input: Readonly<{
|
|
98
|
-
controllerStateRoot: string;
|
|
99
|
-
routeHandle?: string;
|
|
100
|
-
withTurn: boolean;
|
|
101
|
-
}>): Promise<CompatibilityCertification>;
|
|
102
135
|
initialize(callbacks: GatewayAdapterCallbacks): Promise<GatewayAdapterStart>;
|
|
103
136
|
discoverClaudePeers?(): Promise<GatewayAdapterDiscoverySnapshot>;
|
|
104
137
|
selectRoute(input: {
|
|
@@ -107,6 +140,7 @@ export interface GatewayProviderAdapter {
|
|
|
107
140
|
}): Promise<{
|
|
108
141
|
routeHandle: string;
|
|
109
142
|
state: GatewayAdapterRouteState;
|
|
143
|
+
endpointRefresh?: GatewayAdapterEndpointRefresh;
|
|
110
144
|
}>;
|
|
111
145
|
/** Claude-only workspace guard. Codex registration has no workspace gate. */
|
|
112
146
|
assertWorkspaceDisjoint?(routeHandle: string, stateRoot: string): Promise<void>;
|
|
@@ -189,16 +223,7 @@ export interface GatewayProviderAdapter {
|
|
|
189
223
|
pendingCallbacks: number;
|
|
190
224
|
clean: boolean;
|
|
191
225
|
}>;
|
|
192
|
-
dispatch(input:
|
|
193
|
-
sourceAlias: string;
|
|
194
|
-
binding: PrivateRouteBinding;
|
|
195
|
-
authorization: "selected_route" | "native_reply";
|
|
196
|
-
messageId: string;
|
|
197
|
-
text: string;
|
|
198
|
-
expectsReply: boolean;
|
|
199
|
-
deadlineAt: string;
|
|
200
|
-
steer?: true;
|
|
201
|
-
}): Promise<GatewayAdapterDispatchResult>;
|
|
226
|
+
dispatch(input: GatewayAdapterDispatchInput): Promise<GatewayAdapterDispatchResult>;
|
|
202
227
|
releaseRoute?(routeHandle: string): Promise<void>;
|
|
203
228
|
close(): Promise<void>;
|
|
204
229
|
}
|
|
@@ -245,10 +270,34 @@ export declare class GatewayService {
|
|
|
245
270
|
private readonly deliveryTokens;
|
|
246
271
|
private readonly runtimeAlerts;
|
|
247
272
|
private readonly activityEvents;
|
|
273
|
+
private activeCodexIncompatibility;
|
|
248
274
|
private activitySequence;
|
|
249
275
|
private readonly detachedReceiptWrites;
|
|
250
276
|
private readonly nativeIngressByConversation;
|
|
251
277
|
private readonly callbackQueue;
|
|
278
|
+
/**
|
|
279
|
+
* Endpoint replacement is authority-bearing lifecycle evidence, not an
|
|
280
|
+
* ordinary refreshable observation. Keep one coalesced slot outside the
|
|
281
|
+
* bounded callback queue so delivery evidence can never displace it (or be
|
|
282
|
+
* displaced by it).
|
|
283
|
+
*/
|
|
284
|
+
private endpointRefreshCallback;
|
|
285
|
+
private activeEndpointRefreshCallback;
|
|
286
|
+
private endpointRefreshRetryRequested;
|
|
287
|
+
private endpointRefreshConflictBoundary;
|
|
288
|
+
private activeEndpointRefreshCallbackKey;
|
|
289
|
+
private endpointRefreshCallbackPoisoned;
|
|
290
|
+
private endpointRefreshConflictPending;
|
|
291
|
+
/** Last successfully activated transition per allowed Codex host. */
|
|
292
|
+
private readonly activatedEndpointRefreshes;
|
|
293
|
+
/** Durable reanchors awaiting their exact native-listener activation. */
|
|
294
|
+
private readonly durablyAppliedEndpointRefreshes;
|
|
295
|
+
/** Selector transitions staged until their exact registration owns a helper. */
|
|
296
|
+
private readonly pendingSelectorEndpointActivations;
|
|
297
|
+
/** Last incompatible transition already projected per allowed Codex host. */
|
|
298
|
+
private readonly handledIncompatibleEndpointRefreshes;
|
|
299
|
+
/** Process-local dedupe for automatic public activity rows across retries. */
|
|
300
|
+
private readonly endpointRefreshActivityKeys;
|
|
252
301
|
private callbackWorker;
|
|
253
302
|
private callbackScheduled;
|
|
254
303
|
private readonly callbackCapacity;
|
|
@@ -274,6 +323,12 @@ export declare class GatewayService {
|
|
|
274
323
|
/** Route-scoped fences; unrelated Codex registrations remain dispatchable. */
|
|
275
324
|
private readonly codexSuccessionDispatchFrozen;
|
|
276
325
|
private readonly codexSuccessionPoisoned;
|
|
326
|
+
/**
|
|
327
|
+
* Exact stale authority whose process-owned native advertisement was already
|
|
328
|
+
* removed, but whose durable orphan deletion did not commit. Keep dispatch
|
|
329
|
+
* frozen and permit only the same exact cleanup transaction to retry.
|
|
330
|
+
*/
|
|
331
|
+
private readonly codexOrphanCleanupPending;
|
|
277
332
|
private codexSuccessionState;
|
|
278
333
|
private pendingCodexSuccessionRecovery;
|
|
279
334
|
/**
|
|
@@ -287,18 +342,27 @@ export declare class GatewayService {
|
|
|
287
342
|
private closeOnce;
|
|
288
343
|
handlers(): GatewayControlHandlers;
|
|
289
344
|
snapshot(): Promise<GatewayPublicSnapshot>;
|
|
290
|
-
|
|
291
|
-
compatibilityCertify(params: Readonly<{
|
|
292
|
-
codexAlias?: string;
|
|
293
|
-
withTurn: boolean;
|
|
294
|
-
}>): Promise<CompatibilityCertificationReport>;
|
|
295
|
-
private compatibilityCheckLocked;
|
|
345
|
+
private runAutomaticCompatibilityProbesLocked;
|
|
296
346
|
observeSnapshot(): Promise<GatewaySnapshotObservation>;
|
|
297
347
|
private fingerprintSnapshot;
|
|
298
348
|
private callbacksFor;
|
|
299
349
|
private enqueueCallback;
|
|
350
|
+
private enqueueEndpointRefreshCallback;
|
|
351
|
+
private poisonEndpointRefreshCallbacks;
|
|
352
|
+
private hasPendingCallbackWork;
|
|
300
353
|
private enqueueCallbackWorkerOnly;
|
|
301
354
|
private drainCallbackQueueLocked;
|
|
355
|
+
/**
|
|
356
|
+
* A selector can synchronously admit callbacks while its promise is still
|
|
357
|
+
* running under the service mutex. Drain exactly the ordinary work that was
|
|
358
|
+
* retained before the selector returned before applying a returned endpoint
|
|
359
|
+
* transition. Delivery evidence wins within that fixed snapshot; callbacks
|
|
360
|
+
* admitted while it is reduced remain queued for the ordinary worker, and
|
|
361
|
+
* the dedicated endpoint-transition slot is never consumed recursively.
|
|
362
|
+
*/
|
|
363
|
+
private drainSelectorCallbackSnapshotLocked;
|
|
364
|
+
private failClosedEndpointRefreshConflict;
|
|
365
|
+
private requireEndpointRefreshUnconflicted;
|
|
302
366
|
private isTerminalAdapterDelivery;
|
|
303
367
|
/**
|
|
304
368
|
* Delivery evidence observed strictly before the deadline must reach the
|
|
@@ -318,6 +382,13 @@ export declare class GatewayService {
|
|
|
318
382
|
private assertClaudeWorkspaceDisjoint;
|
|
319
383
|
private contextTargetBinding;
|
|
320
384
|
private recoverCodexSuccessionAfterRestartLocked;
|
|
385
|
+
/**
|
|
386
|
+
* Rebuild process-owned route and listener authority for retained Codex
|
|
387
|
+
* registrations during staged startup. The provider's selectRoute performs
|
|
388
|
+
* the exact loaded/list + history-free resume proof; durable state advances
|
|
389
|
+
* only after the new native advertisement and status are live.
|
|
390
|
+
*/
|
|
391
|
+
private reactivateRetainedCodexRoutesAfterRestartLocked;
|
|
321
392
|
private completePendingCodexSuccessionRecoveryLocked;
|
|
322
393
|
private assertPendingCodexSuccessionRecoveryMatch;
|
|
323
394
|
private requireCurrentNativeCodexGeneration;
|
|
@@ -341,10 +412,16 @@ export declare class GatewayService {
|
|
|
341
412
|
private codexSuccessionPoisonBarrierCleanLocked;
|
|
342
413
|
private codexSuccessionBarrierCleanLocked;
|
|
343
414
|
private rescheduleIdleRoutesLocked;
|
|
415
|
+
private codexSuccessionIsStable;
|
|
416
|
+
private requireUnchangedStaleCodexOrphan;
|
|
417
|
+
private nativeCodexOrphanBarrierClean;
|
|
418
|
+
private endpointCallbacksQuiet;
|
|
344
419
|
private registerCodex;
|
|
345
420
|
private lockCodexRegistration;
|
|
346
421
|
private rollbackCodexRegistration;
|
|
347
422
|
private unregisterCodex;
|
|
423
|
+
private finalizeStaleCodexOrphanRemovalLocked;
|
|
424
|
+
private removeStaleCodexRegistration;
|
|
348
425
|
private discoveryPublicFingerprint;
|
|
349
426
|
private refreshClaudeDiscovery;
|
|
350
427
|
private renameClaudeRoute;
|
|
@@ -426,6 +503,7 @@ export declare class GatewayService {
|
|
|
426
503
|
private enqueueObservedClaudeReplyAfterRouteTeardownLocked;
|
|
427
504
|
private pruneTransient;
|
|
428
505
|
private awaitDispatchWithNativeHeldLocked;
|
|
506
|
+
private restoreQueuedMessageContextLocked;
|
|
429
507
|
private dispatchOne;
|
|
430
508
|
private scheduleDispatch;
|
|
431
509
|
private scheduleHeldRedispatch;
|
|
@@ -436,6 +514,8 @@ export declare class GatewayService {
|
|
|
436
514
|
private onClaudeReply;
|
|
437
515
|
private onClaudeMessage;
|
|
438
516
|
private releasePendingClaude;
|
|
517
|
+
private onCodexEndpointRefresh;
|
|
518
|
+
private applyCodexEndpointRefresh;
|
|
439
519
|
private onRouteState;
|
|
440
520
|
private setNativeCodexStatus;
|
|
441
521
|
private rejectDetachedNativeReceipt;
|