agent-embassy 1.0.0 → 1.2.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +50 -5
  3. package/README.zh-CN.md +32 -5
  4. package/SECURITY.md +26 -2
  5. package/assets/live-dashboard/app.css +14 -5
  6. package/dist/src/gateway/claude-helper-protocol.d.ts +3 -0
  7. package/dist/src/gateway/claude-helper-protocol.js +15 -1
  8. package/dist/src/gateway/claude-helper-protocol.js.map +1 -1
  9. package/dist/src/gateway/claude-helper-supervisor.d.ts +2 -0
  10. package/dist/src/gateway/claude-helper-supervisor.js +25 -1
  11. package/dist/src/gateway/claude-helper-supervisor.js.map +1 -1
  12. package/dist/src/gateway/cli-copy.en.d.ts +1 -0
  13. package/dist/src/gateway/cli-copy.en.js +1 -0
  14. package/dist/src/gateway/cli-copy.en.js.map +1 -1
  15. package/dist/src/gateway/cli-copy.zh-CN.d.ts +1 -0
  16. package/dist/src/gateway/cli-copy.zh-CN.js +1 -0
  17. package/dist/src/gateway/cli-copy.zh-CN.js.map +1 -1
  18. package/dist/src/gateway/cli.d.ts +1 -1
  19. package/dist/src/gateway/cli.js +20 -7
  20. package/dist/src/gateway/cli.js.map +1 -1
  21. package/dist/src/gateway/codex-app-server.js +6 -2
  22. package/dist/src/gateway/codex-app-server.js.map +1 -1
  23. package/dist/src/gateway/codex-local-transport.d.ts +13 -0
  24. package/dist/src/gateway/codex-local-transport.js +21 -2
  25. package/dist/src/gateway/codex-local-transport.js.map +1 -1
  26. package/dist/src/gateway/config.js +5 -3
  27. package/dist/src/gateway/config.js.map +1 -1
  28. package/dist/src/gateway/control.d.ts +11 -1
  29. package/dist/src/gateway/control.js +48 -14
  30. package/dist/src/gateway/control.js.map +1 -1
  31. package/dist/src/gateway/dashboard-copy.d.ts +1 -1
  32. package/dist/src/gateway/dashboard-copy.en.d.ts +6 -0
  33. package/dist/src/gateway/dashboard-copy.en.js +11 -5
  34. package/dist/src/gateway/dashboard-copy.en.js.map +1 -1
  35. package/dist/src/gateway/dashboard-copy.js +6 -0
  36. package/dist/src/gateway/dashboard-copy.js.map +1 -1
  37. package/dist/src/gateway/dashboard-copy.zh-CN.d.ts +6 -0
  38. package/dist/src/gateway/dashboard-copy.zh-CN.js +11 -5
  39. package/dist/src/gateway/dashboard-copy.zh-CN.js.map +1 -1
  40. package/dist/src/gateway/dashboard-model.d.ts +4 -2
  41. package/dist/src/gateway/dashboard-model.js +6 -0
  42. package/dist/src/gateway/dashboard-model.js.map +1 -1
  43. package/dist/src/gateway/dashboard.js +5 -3
  44. package/dist/src/gateway/dashboard.js.map +1 -1
  45. package/dist/src/gateway/live-dashboard-app/app.js +48 -10
  46. package/dist/src/gateway/live-dashboard-command.js +10 -0
  47. package/dist/src/gateway/live-dashboard-command.js.map +1 -1
  48. package/dist/src/gateway/live-dashboard-http.d.ts +3 -0
  49. package/dist/src/gateway/live-dashboard-http.js +13 -0
  50. package/dist/src/gateway/live-dashboard-http.js.map +1 -1
  51. package/dist/src/gateway/live-dashboard-stream.js +26 -25
  52. package/dist/src/gateway/live-dashboard-stream.js.map +1 -1
  53. package/dist/src/gateway/provenance-envelope.d.ts +16 -0
  54. package/dist/src/gateway/provenance-envelope.js +80 -0
  55. package/dist/src/gateway/provenance-envelope.js.map +1 -0
  56. package/dist/src/gateway/providers.d.ts +43 -16
  57. package/dist/src/gateway/providers.js +688 -61
  58. package/dist/src/gateway/providers.js.map +1 -1
  59. package/dist/src/gateway/server.d.ts +2 -0
  60. package/dist/src/gateway/server.js +9 -3
  61. package/dist/src/gateway/server.js.map +1 -1
  62. package/dist/src/gateway/service.d.ts +102 -10
  63. package/dist/src/gateway/service.js +1309 -54
  64. package/dist/src/gateway/service.js.map +1 -1
  65. package/dist/src/gateway/store.d.ts +39 -3
  66. package/dist/src/gateway/store.js +528 -26
  67. package/dist/src/gateway/store.js.map +1 -1
  68. package/dist/src/gateway/types.d.ts +90 -5
  69. package/dist/src/gateway/types.js +6 -0
  70. package/dist/src/gateway/types.js.map +1 -1
  71. package/docs/GATEWAY-ARCHITECTURE.md +98 -11
  72. package/package.json +3 -2
  73. package/skills/embassy-peer/SKILL.md +15 -1
@@ -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
@@ -107,6 +145,7 @@ export interface GatewayProviderAdapter {
107
145
  }): Promise<{
108
146
  routeHandle: string;
109
147
  state: GatewayAdapterRouteState;
148
+ endpointRefresh?: GatewayAdapterEndpointRefresh;
110
149
  }>;
111
150
  /** Claude-only workspace guard. Codex registration has no workspace gate. */
112
151
  assertWorkspaceDisjoint?(routeHandle: string, stateRoot: string): Promise<void>;
@@ -189,16 +228,7 @@ export interface GatewayProviderAdapter {
189
228
  pendingCallbacks: number;
190
229
  clean: boolean;
191
230
  }>;
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>;
231
+ dispatch(input: GatewayAdapterDispatchInput): Promise<GatewayAdapterDispatchResult>;
202
232
  releaseRoute?(routeHandle: string): Promise<void>;
203
233
  close(): Promise<void>;
204
234
  }
@@ -239,16 +269,42 @@ export declare class GatewayService {
239
269
  private readonly activeDispatchByTarget;
240
270
  private readonly scheduledDispatchTargets;
241
271
  private readonly dispatchRunnerTargets;
272
+ /** Claude sends that proved no write wait for exact provider-idle evidence. */
273
+ private readonly claudePrewriteIdleWaitTargets;
242
274
  private readonly heldRedispatchTimers;
243
275
  private readonly pendingClaudeReplies;
244
276
  private readonly deliveryTrackers;
245
277
  private readonly deliveryTokens;
246
278
  private readonly runtimeAlerts;
247
279
  private readonly activityEvents;
280
+ private activeCodexIncompatibility;
248
281
  private activitySequence;
249
282
  private readonly detachedReceiptWrites;
250
283
  private readonly nativeIngressByConversation;
251
284
  private readonly callbackQueue;
285
+ /**
286
+ * Endpoint replacement is authority-bearing lifecycle evidence, not an
287
+ * ordinary refreshable observation. Keep one coalesced slot outside the
288
+ * bounded callback queue so delivery evidence can never displace it (or be
289
+ * displaced by it).
290
+ */
291
+ private endpointRefreshCallback;
292
+ private activeEndpointRefreshCallback;
293
+ private endpointRefreshRetryRequested;
294
+ private endpointRefreshConflictBoundary;
295
+ private activeEndpointRefreshCallbackKey;
296
+ private endpointRefreshCallbackPoisoned;
297
+ private endpointRefreshConflictPending;
298
+ /** Last successfully activated transition per allowed Codex host. */
299
+ private readonly activatedEndpointRefreshes;
300
+ /** Durable reanchors awaiting their exact native-listener activation. */
301
+ private readonly durablyAppliedEndpointRefreshes;
302
+ /** Selector transitions staged until their exact registration owns a helper. */
303
+ private readonly pendingSelectorEndpointActivations;
304
+ /** Last incompatible transition already projected per allowed Codex host. */
305
+ private readonly handledIncompatibleEndpointRefreshes;
306
+ /** Process-local dedupe for automatic public activity rows across retries. */
307
+ private readonly endpointRefreshActivityKeys;
252
308
  private callbackWorker;
253
309
  private callbackScheduled;
254
310
  private readonly callbackCapacity;
@@ -274,6 +330,12 @@ export declare class GatewayService {
274
330
  /** Route-scoped fences; unrelated Codex registrations remain dispatchable. */
275
331
  private readonly codexSuccessionDispatchFrozen;
276
332
  private readonly codexSuccessionPoisoned;
333
+ /**
334
+ * Exact stale authority whose process-owned native advertisement was already
335
+ * removed, but whose durable orphan deletion did not commit. Keep dispatch
336
+ * frozen and permit only the same exact cleanup transaction to retry.
337
+ */
338
+ private readonly codexOrphanCleanupPending;
277
339
  private codexSuccessionState;
278
340
  private pendingCodexSuccessionRecovery;
279
341
  /**
@@ -297,8 +359,22 @@ export declare class GatewayService {
297
359
  private fingerprintSnapshot;
298
360
  private callbacksFor;
299
361
  private enqueueCallback;
362
+ private enqueueEndpointRefreshCallback;
363
+ private poisonEndpointRefreshCallbacks;
364
+ private hasPendingCallbackWork;
300
365
  private enqueueCallbackWorkerOnly;
301
366
  private drainCallbackQueueLocked;
367
+ /**
368
+ * A selector can synchronously admit callbacks while its promise is still
369
+ * running under the service mutex. Drain exactly the ordinary work that was
370
+ * retained before the selector returned before applying a returned endpoint
371
+ * transition. Delivery evidence wins within that fixed snapshot; callbacks
372
+ * admitted while it is reduced remain queued for the ordinary worker, and
373
+ * the dedicated endpoint-transition slot is never consumed recursively.
374
+ */
375
+ private drainSelectorCallbackSnapshotLocked;
376
+ private failClosedEndpointRefreshConflict;
377
+ private requireEndpointRefreshUnconflicted;
302
378
  private isTerminalAdapterDelivery;
303
379
  /**
304
380
  * Delivery evidence observed strictly before the deadline must reach the
@@ -318,6 +394,13 @@ export declare class GatewayService {
318
394
  private assertClaudeWorkspaceDisjoint;
319
395
  private contextTargetBinding;
320
396
  private recoverCodexSuccessionAfterRestartLocked;
397
+ /**
398
+ * Rebuild process-owned route and listener authority for retained Codex
399
+ * registrations during staged startup. The provider's selectRoute performs
400
+ * the exact loaded/list + history-free resume proof; durable state advances
401
+ * only after the new native advertisement and status are live.
402
+ */
403
+ private reactivateRetainedCodexRoutesAfterRestartLocked;
321
404
  private completePendingCodexSuccessionRecoveryLocked;
322
405
  private assertPendingCodexSuccessionRecoveryMatch;
323
406
  private requireCurrentNativeCodexGeneration;
@@ -341,10 +424,16 @@ export declare class GatewayService {
341
424
  private codexSuccessionPoisonBarrierCleanLocked;
342
425
  private codexSuccessionBarrierCleanLocked;
343
426
  private rescheduleIdleRoutesLocked;
427
+ private codexSuccessionIsStable;
428
+ private requireUnchangedStaleCodexOrphan;
429
+ private nativeCodexOrphanBarrierClean;
430
+ private endpointCallbacksQuiet;
344
431
  private registerCodex;
345
432
  private lockCodexRegistration;
346
433
  private rollbackCodexRegistration;
347
434
  private unregisterCodex;
435
+ private finalizeStaleCodexOrphanRemovalLocked;
436
+ private removeStaleCodexRegistration;
348
437
  private discoveryPublicFingerprint;
349
438
  private refreshClaudeDiscovery;
350
439
  private renameClaudeRoute;
@@ -426,6 +515,7 @@ export declare class GatewayService {
426
515
  private enqueueObservedClaudeReplyAfterRouteTeardownLocked;
427
516
  private pruneTransient;
428
517
  private awaitDispatchWithNativeHeldLocked;
518
+ private restoreQueuedMessageContextLocked;
429
519
  private dispatchOne;
430
520
  private scheduleDispatch;
431
521
  private scheduleHeldRedispatch;
@@ -436,6 +526,8 @@ export declare class GatewayService {
436
526
  private onClaudeReply;
437
527
  private onClaudeMessage;
438
528
  private releasePendingClaude;
529
+ private onCodexEndpointRefresh;
530
+ private applyCodexEndpointRefresh;
439
531
  private onRouteState;
440
532
  private setNativeCodexStatus;
441
533
  private rejectDetachedNativeReceipt;