agent-embassy 1.7.1 → 1.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.
Files changed (121) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/CONTRIBUTING.md +51 -47
  3. package/README.md +26 -9
  4. package/README.zh-CN.md +22 -9
  5. package/SECURITY.md +48 -35
  6. package/dist/src/gateway/acp-client.d.ts +12 -19
  7. package/dist/src/gateway/acp-client.js +90 -65
  8. package/dist/src/gateway/acp-client.js.map +1 -1
  9. package/dist/src/gateway/acp-provider.d.ts +11 -10
  10. package/dist/src/gateway/acp-provider.js +165 -53
  11. package/dist/src/gateway/acp-provider.js.map +1 -1
  12. package/dist/src/gateway/claude-helper-client.d.ts +2 -43
  13. package/dist/src/gateway/claude-helper-client.js +1 -211
  14. package/dist/src/gateway/claude-helper-client.js.map +1 -1
  15. package/dist/src/gateway/claude-helper-protocol.d.ts +16 -74
  16. package/dist/src/gateway/claude-helper-protocol.js +99 -378
  17. package/dist/src/gateway/claude-helper-protocol.js.map +1 -1
  18. package/dist/src/gateway/claude-helper-supervisor.d.ts +56 -44
  19. package/dist/src/gateway/claude-helper-supervisor.js +265 -456
  20. package/dist/src/gateway/claude-helper-supervisor.js.map +1 -1
  21. package/dist/src/gateway/claude-helper.js +184 -210
  22. package/dist/src/gateway/claude-helper.js.map +1 -1
  23. package/dist/src/gateway/claude-peer.d.ts +20 -87
  24. package/dist/src/gateway/claude-peer.js +310 -1009
  25. package/dist/src/gateway/claude-peer.js.map +1 -1
  26. package/dist/src/gateway/claude-runtime.d.ts +13 -15
  27. package/dist/src/gateway/claude-runtime.js +14 -168
  28. package/dist/src/gateway/claude-runtime.js.map +1 -1
  29. package/dist/src/gateway/cli-copy.d.ts +1 -1
  30. package/dist/src/gateway/cli-copy.en.d.ts +2 -4
  31. package/dist/src/gateway/cli-copy.en.js +3 -4
  32. package/dist/src/gateway/cli-copy.en.js.map +1 -1
  33. package/dist/src/gateway/cli-copy.js +0 -2
  34. package/dist/src/gateway/cli-copy.js.map +1 -1
  35. package/dist/src/gateway/cli-copy.zh-CN.d.ts +2 -4
  36. package/dist/src/gateway/cli-copy.zh-CN.js +3 -4
  37. package/dist/src/gateway/cli-copy.zh-CN.js.map +1 -1
  38. package/dist/src/gateway/cli.d.ts +7 -2
  39. package/dist/src/gateway/cli.js +273 -617
  40. package/dist/src/gateway/cli.js.map +1 -1
  41. package/dist/src/gateway/codex-app-server.d.ts +5 -227
  42. package/dist/src/gateway/codex-app-server.js +18 -1463
  43. package/dist/src/gateway/codex-app-server.js.map +1 -1
  44. package/dist/src/gateway/codex-doctor.d.ts +6 -3
  45. package/dist/src/gateway/codex-doctor.js +77 -98
  46. package/dist/src/gateway/codex-doctor.js.map +1 -1
  47. package/dist/src/gateway/codex-local-transport.d.ts +1 -6
  48. package/dist/src/gateway/codex-local-transport.js +8 -10
  49. package/dist/src/gateway/codex-local-transport.js.map +1 -1
  50. package/dist/src/gateway/codex-stateless-transport.d.ts +114 -0
  51. package/dist/src/gateway/codex-stateless-transport.js +1108 -0
  52. package/dist/src/gateway/codex-stateless-transport.js.map +1 -0
  53. package/dist/src/gateway/config.d.ts +2 -9
  54. package/dist/src/gateway/config.js +62 -100
  55. package/dist/src/gateway/config.js.map +1 -1
  56. package/dist/src/gateway/control.d.ts +36 -90
  57. package/dist/src/gateway/control.js +464 -1159
  58. package/dist/src/gateway/control.js.map +1 -1
  59. package/dist/src/gateway/dashboard-copy.d.ts +1 -1
  60. package/dist/src/gateway/dashboard-copy.en.d.ts +3 -26
  61. package/dist/src/gateway/dashboard-copy.en.js +14 -37
  62. package/dist/src/gateway/dashboard-copy.en.js.map +1 -1
  63. package/dist/src/gateway/dashboard-copy.js +3 -26
  64. package/dist/src/gateway/dashboard-copy.js.map +1 -1
  65. package/dist/src/gateway/dashboard-copy.zh-CN.d.ts +3 -26
  66. package/dist/src/gateway/dashboard-copy.zh-CN.js +14 -37
  67. package/dist/src/gateway/dashboard-copy.zh-CN.js.map +1 -1
  68. package/dist/src/gateway/dashboard-model.d.ts +6 -23
  69. package/dist/src/gateway/dashboard-model.js +37 -131
  70. package/dist/src/gateway/dashboard-model.js.map +1 -1
  71. package/dist/src/gateway/dashboard.d.ts +0 -6
  72. package/dist/src/gateway/dashboard.js +0 -6
  73. package/dist/src/gateway/dashboard.js.map +1 -1
  74. package/dist/src/gateway/live-dashboard-app/app.js +9 -32
  75. package/dist/src/gateway/live-dashboard-command.js +2 -2
  76. package/dist/src/gateway/live-dashboard-command.js.map +1 -1
  77. package/dist/src/gateway/live-dashboard-http.d.ts +1 -1
  78. package/dist/src/gateway/live-dashboard-http.js +2 -2
  79. package/dist/src/gateway/live-dashboard-http.js.map +1 -1
  80. package/dist/src/gateway/progress-watch-machine.d.ts +1 -37
  81. package/dist/src/gateway/progress-watch-machine.js +4 -15
  82. package/dist/src/gateway/progress-watch-machine.js.map +1 -1
  83. package/dist/src/gateway/providers.d.ts +55 -195
  84. package/dist/src/gateway/providers.js +608 -2465
  85. package/dist/src/gateway/providers.js.map +1 -1
  86. package/dist/src/gateway/server.d.ts +16 -25
  87. package/dist/src/gateway/server.js +164 -251
  88. package/dist/src/gateway/server.js.map +1 -1
  89. package/dist/src/gateway/service.d.ts +146 -448
  90. package/dist/src/gateway/service.js +1670 -6142
  91. package/dist/src/gateway/service.js.map +1 -1
  92. package/dist/src/gateway/state-v2-to-v3.d.ts +23 -0
  93. package/dist/src/gateway/state-v2-to-v3.js +994 -0
  94. package/dist/src/gateway/state-v2-to-v3.js.map +1 -0
  95. package/dist/src/gateway/store.d.ts +54 -309
  96. package/dist/src/gateway/store.js +1560 -3524
  97. package/dist/src/gateway/store.js.map +1 -1
  98. package/dist/src/gateway/types.d.ts +175 -228
  99. package/dist/src/gateway/types.js +114 -252
  100. package/dist/src/gateway/types.js.map +1 -1
  101. package/docs/CONFIGURATION.md +22 -9
  102. package/docs/CONFIGURATION.zh-CN.md +21 -9
  103. package/docs/DASHBOARD.md +10 -10
  104. package/docs/DASHBOARD.zh-CN.md +3 -3
  105. package/docs/DELIVERY.md +4 -4
  106. package/docs/DELIVERY.zh-CN.md +4 -4
  107. package/docs/GATEWAY-ARCHITECTURE.md +158 -187
  108. package/package.json +1 -1
  109. package/skills/embassy-peer/SKILL.md +28 -22
  110. package/dist/src/gateway/codex-registration-generation.d.ts +0 -5
  111. package/dist/src/gateway/codex-registration-generation.js +0 -19
  112. package/dist/src/gateway/codex-registration-generation.js.map +0 -1
  113. package/dist/src/gateway/codex-registration-succession.d.ts +0 -209
  114. package/dist/src/gateway/codex-registration-succession.js +0 -588
  115. package/dist/src/gateway/codex-registration-succession.js.map +0 -1
  116. package/dist/src/gateway/compatibility.d.ts +0 -22
  117. package/dist/src/gateway/compatibility.js +0 -23
  118. package/dist/src/gateway/compatibility.js.map +0 -1
  119. package/dist/src/gateway/delivery-machine.d.ts +0 -235
  120. package/dist/src/gateway/delivery-machine.js +0 -540
  121. package/dist/src/gateway/delivery-machine.js.map +0 -1
@@ -1,13 +1,5 @@
1
- import type { ProgressWatch, ProgressWatchJournalEvent } from "./progress-watch-machine.js";
2
1
  export declare const gatewayProviders: readonly ["claude", "codex", "deepseek", "grok"];
3
2
  export type GatewayProvider = (typeof gatewayProviders)[number];
4
- export declare const gatewayProviderDisplayNames: Readonly<{
5
- claude: string;
6
- codex: string;
7
- deepseek: string;
8
- grok: string;
9
- }>;
10
- /** Registration syntax only; route bindings, never prefixes, prove providers. */
11
3
  export declare const gatewayRegistrationIngressPrefixes: Readonly<{
12
4
  claude: undefined;
13
5
  codex: string;
@@ -36,11 +28,10 @@ export declare function parseDirection(value: unknown): ParsedMessageDirection |
36
28
  export declare const isMessageDirection: (value: unknown) => value is MessageDirection;
37
29
  export declare const deliveryStates: readonly ["queued", "duplicate", "dispatching", "transport_written", "held", "delivered", "unconfirmed", "failed", "ambiguous", "expired", "cancelled", "abandoned", "rejected"];
38
30
  export type DeliveryState = (typeof deliveryStates)[number];
39
- export declare const terminalDeliveryStates: Set<"delivered" | "failed" | "cancelled" | "queued" | "duplicate" | "dispatching" | "transport_written" | "held" | "unconfirmed" | "ambiguous" | "expired" | "abandoned" | "rejected">;
31
+ export type TerminalDeliveryOutcome = Extract<DeliveryState, "delivered" | "unconfirmed" | "failed" | "ambiguous" | "expired" | "cancelled" | "abandoned">;
40
32
  export declare const alertSeverities: readonly ["info", "warning", "error"];
41
33
  export type AlertSeverity = (typeof alertSeverities)[number];
42
34
  export type BusyPolicy = "queue";
43
- /** Canonical closed-array bounds shared by store projections and control/UI. */
44
35
  export declare const gatewayPublicSnapshotLimits: Readonly<{
45
36
  readonly connectors: 64;
46
37
  readonly registryRejectionCodes: 32;
@@ -53,25 +44,16 @@ export declare const gatewayPublicSnapshotLimits: Readonly<{
53
44
  readonly messages: 1024;
54
45
  readonly alerts: 256;
55
46
  }>;
56
- /** Leaves headroom for the private control protocol response envelope. */
57
47
  export declare const GATEWAY_PUBLIC_SNAPSHOT_BYTE_BUDGET: number;
58
48
  /**
59
- * Private connector identity. Values in this structure are permitted only in
60
- * controller-owned state and connector calls. They must never be copied into
61
- * public snapshots, normalized events, logs, or error messages.
49
+ * Durable logical registration. Provider endpoint generations are deliberately
50
+ * absent: they are operation-local evidence and never routing authority.
62
51
  */
63
- export type PrivateEndpointIdentity = {
52
+ export type LogicalRouteBinding = {
64
53
  provider: GatewayProvider;
65
54
  hostId: string;
66
- endpointGeneration: string;
67
- };
68
- /**
69
- * Private, immutable target binding. routeHandle may be a native provider
70
- * thread/session identifier; ownerLease proves which registration owns it.
71
- */
72
- export type PrivateRouteBinding = PrivateEndpointIdentity & {
73
55
  routeHandle: string;
74
- ownerLease: string;
56
+ registrationId: string;
75
57
  };
76
58
  export type RouteCounters = {
77
59
  accepted: number;
@@ -87,30 +69,25 @@ export type RouteCounters = {
87
69
  };
88
70
  export type GatewayRouteRecord = {
89
71
  alias: string;
90
- binding: PrivateRouteBinding;
72
+ binding: LogicalRouteBinding;
91
73
  registrationMode: RouteRegistrationMode;
92
74
  enabled: boolean;
93
- state: RouteState;
94
75
  busyPolicy: BusyPolicy;
95
76
  registeredAt: string;
96
77
  updatedAt: string;
97
- lastSeenAt?: string;
98
- queueDepth: number;
99
78
  counters: RouteCounters;
100
- safeErrorCode?: string;
101
79
  };
102
80
  /**
103
81
  * Durable bidirectional consent between two exact route owners. Aliases are
104
- * display coordinates; the private leases prevent an alias from silently
82
+ * display coordinates; the private registration identities prevent an alias from silently
105
83
  * retargeting an existing permission edge.
106
84
  */
107
85
  export type GatewayConsentEndpoint = Readonly<{
108
86
  alias: string;
109
87
  provider: GatewayProvider;
110
- ownerLease: string;
88
+ registrationId: string;
111
89
  }>;
112
90
  export type GatewayConsentEdgeRecord = {
113
- /** Canonical order: provider order first, then alias. */
114
91
  endpoints: readonly [GatewayConsentEndpoint, GatewayConsentEndpoint];
115
92
  createdAt: string;
116
93
  updatedAt: string;
@@ -122,28 +99,13 @@ export type GatewayConsentEdgeRecord = {
122
99
  */
123
100
  export type GatewayPrivateRouteInspection = {
124
101
  alias: string;
125
- binding: PrivateRouteBinding;
102
+ binding: LogicalRouteBinding;
126
103
  registrationMode: RouteRegistrationMode;
127
104
  enabled: boolean;
128
- state: RouteState;
129
- safeErrorCode?: string;
130
105
  };
131
- export type ConnectorRecord = {
132
- provider: GatewayProvider;
133
- hostId: string;
134
- endpointGeneration: string;
135
- health: ConnectorHealth;
136
- protocol: string;
137
- protocolVersion: string;
138
- updatedAt: string;
139
- lastSeenAt?: string;
140
- safeErrorCode?: string;
141
- };
142
- /** Metadata persisted for a queued message. Legacy rows may be bodyless. */
143
106
  export type QueuedMessageMetadata = {
144
107
  messageId: string;
145
108
  messageIdSuffix: string;
146
- /** Bounded public correlation only; the full conversation capability stays private. */
147
109
  conversationIdSuffix?: string;
148
110
  direction: MessageDirection;
149
111
  sourceAlias: string;
@@ -151,22 +113,11 @@ export type QueuedMessageMetadata = {
151
113
  enqueuedAt: string;
152
114
  deadlineAt: string;
153
115
  bytes: number;
154
- /** Bounded same-user durable payload; absent only on pre-v1.2 rows. */
155
116
  body?: string;
156
- /** This message was admitted by the exact durable consent edge. */
157
117
  pair?: true;
158
- /** Target authority was transient and must never be reconstructed after restart. */
159
118
  transientTarget?: true;
160
- /** Exact Claude-to-Codex `STEER:` classification; absence means ordinary. */
161
119
  steer?: true;
162
120
  };
163
- /** A dispatch value with the exact persisted body promoted to required. */
164
- export type TransientQueuedMessage = QueuedMessageMetadata & {
165
- body: string;
166
- };
167
- export type InFlightMessageMetadata = QueuedMessageMetadata & {
168
- dispatchedAt: string;
169
- };
170
121
  export type DedupeRecord = {
171
122
  fingerprint: string;
172
123
  messageIdSuffix: string;
@@ -193,7 +144,6 @@ export type NormalizedMessageEvent = {
193
144
  targetAlias: string;
194
145
  state: DeliveryState;
195
146
  bytes: number;
196
- /** Retained payload; oldest values are evicted without removing metadata. */
197
147
  body?: string;
198
148
  steer?: true;
199
149
  latencyMs?: number;
@@ -213,61 +163,75 @@ export type GatewayAccounting = {
213
163
  bytesAccepted: number;
214
164
  queuedBytes: number;
215
165
  };
216
- /**
217
- * Private proof that one exact Codex task was re-anchored after its App Server
218
- * endpoint generation changed. Native task and endpoint identifiers in this
219
- * journal must never enter a public snapshot, event, error, or log.
220
- */
221
- export type CodexEndpointRefreshJournalEvent = {
222
- sequence: number;
223
- timestamp: string;
224
- alias: string;
225
- hostId: string;
226
- threadId: string;
227
- oldEndpointGeneration: string;
228
- newEndpointGeneration: string;
229
- /** Broker-start proof; absent for a live endpoint-generation refresh. */
230
- reason?: "boot_reactivation";
166
+ export type GatewayPreparedWriteEvidence = {
167
+ kind: "claude_mailbox" | "codex_turn_start" | "codex_turn_steer" | "acp_prompt";
168
+ bodyBytes: number;
169
+ bodySha256: string;
170
+ frameBytes: number;
171
+ sha256: string;
172
+ };
173
+ export type GatewayMessageAttemptAuthority = {
174
+ attemptId: string;
175
+ attemptCount: number;
176
+ targetRegistrationId: string;
177
+ sourceRegistrationId: string | null;
178
+ consentEdge: readonly [GatewayConsentEndpoint, GatewayConsentEndpoint] | null;
179
+ };
180
+ export type GatewayMessageState = {
181
+ phase: "queued";
182
+ attemptCount: number;
183
+ } | (GatewayMessageAttemptAuthority & {
184
+ phase: "reserved";
185
+ reservedAt: string;
186
+ }) | (GatewayMessageAttemptAuthority & {
187
+ phase: "armed";
188
+ armedAt: string;
189
+ prepared: GatewayPreparedWriteEvidence;
190
+ }) | (GatewayMessageAttemptAuthority & {
191
+ phase: "accepted";
192
+ acceptedAt: string;
193
+ prepared: GatewayPreparedWriteEvidence;
194
+ lossOutcome: "unconfirmed" | "ambiguous";
195
+ }) | {
196
+ phase: "terminal";
197
+ outcome: TerminalDeliveryOutcome;
198
+ terminalAt: string;
199
+ safeErrorCode?: string;
200
+ latencyMs: number;
231
201
  };
232
- export declare const CODEX_ENDPOINT_REFRESH_JOURNAL_CAPACITY = 256;
233
- /**
234
- * Private durable evidence that an operator removed one safely proven stale
235
- * Codex registration. No native task or endpoint identifiers are retained.
236
- */
237
- export type CodexOrphanRemovalJournalEvent = {
202
+ export type GatewayMessageRecord = QueuedMessageMetadata & {
238
203
  sequence: number;
239
- timestamp: string;
240
- alias: string;
241
- hostId: string;
204
+ deliveryToken?: string;
205
+ sourceRegistrationId: string | null;
206
+ targetRegistrationId: string | null;
207
+ consentEdge: readonly [GatewayConsentEndpoint, GatewayConsentEndpoint] | null;
208
+ state: GatewayMessageState;
209
+ };
210
+ export type GatewayLegacyMessageActivity = {
211
+ type: "legacy_message";
212
+ event: NormalizedMessageEvent;
242
213
  };
243
- export declare const CODEX_ORPHAN_REMOVAL_JOURNAL_CAPACITY = 256;
214
+ export type GatewayRuntimeActivity = {
215
+ type: "activity";
216
+ event: PublicGatewayActivityEvent;
217
+ };
218
+ export type GatewayStateActivity = GatewayLegacyMessageActivity | GatewayRuntimeActivity;
244
219
  export type GatewayPersistedState = {
245
- schemaVersion: 2;
220
+ schemaVersion: 3;
221
+ commit: {
222
+ sequence: number;
223
+ id: string;
224
+ };
246
225
  createdAt: string;
247
226
  updatedAt: string;
248
227
  eventSequence: number;
249
228
  routes: GatewayRouteRecord[];
250
229
  consentEdges: GatewayConsentEdgeRecord[];
251
- connectors: ConnectorRecord[];
252
- queue: QueuedMessageMetadata[];
253
- inFlight: InFlightMessageMetadata[];
254
- events: NormalizedMessageEvent[];
230
+ messages: GatewayMessageRecord[];
255
231
  dedupe: DedupeRecord[];
256
232
  rateBuckets: RateBucket[];
233
+ activity: GatewayStateActivity[];
257
234
  accounting: GatewayAccounting;
258
- watchSequence: number;
259
- progressWatches: ProgressWatch[];
260
- progressWatchEvents: ProgressWatchJournalEvent[];
261
- /** Monotonic sequence for the bounded private endpoint-refresh journal. */
262
- codexEndpointRefreshSequence: number;
263
- /** Strictly private route-lifecycle evidence; never publicly projected. */
264
- codexEndpointRefreshEvents: CodexEndpointRefreshJournalEvent[];
265
- /** Monotonic sequence for bounded private operator-recovery evidence. */
266
- codexOrphanRemovalSequence: number;
267
- /** Strictly private orphan-removal evidence; never publicly projected. */
268
- codexOrphanRemovalEvents: CodexOrphanRemovalJournalEvent[];
269
- /** Strictly validated internal restart journal; never publicly projected. */
270
- codexSuccession?: unknown;
271
235
  };
272
236
  export type PublicRouteSnapshot = {
273
237
  alias: string;
@@ -278,18 +242,15 @@ export type PublicRouteSnapshot = {
278
242
  busyPolicy: BusyPolicy;
279
243
  lastSeenAt?: string;
280
244
  queueDepth: number;
281
- /** Earliest enqueue time for this route's current queue, if non-empty. */
282
245
  oldestQueuedAt?: string;
283
246
  counters: RouteCounters;
284
247
  safeErrorCode?: string;
285
248
  };
286
- /** Metadata-only public consent edge. Private route authority is omitted. */
287
249
  export type PublicConsentEndpointSnapshot = Readonly<{
288
250
  alias: string;
289
251
  provider: GatewayProvider;
290
252
  }>;
291
253
  export type PublicConsentEdgeSnapshot = {
292
- /** Canonical order matching the private consent edge. */
293
254
  endpoints: readonly [PublicConsentEndpointSnapshot, PublicConsentEndpointSnapshot];
294
255
  host: string;
295
256
  counters: RouteCounters;
@@ -301,17 +262,15 @@ export type PublicConnectorSnapshot = {
301
262
  protocol: string;
302
263
  protocolVersion: string;
303
264
  lastSeenAt?: string;
304
- /** Age of the latest positive connector observation at snapshot generation. */
305
265
  observationAgeMs?: number;
306
266
  codexDoctor?: PublicCodexDoctorSnapshot;
307
267
  safeErrorCode?: string;
308
268
  registry?: PublicRegistryObservationSnapshot;
309
269
  };
310
- export type PublicCodexDoctorCondition = "split_brain" | "orphaned" | "attached" | "observation_stale" | "unknown";
270
+ export type PublicCodexDoctorCondition = "split_brain" | "orphaned" | "attached" | "observation_stale" | "managed_layout_missing" | "unknown";
311
271
  export type PublicCodexDoctorSnapshot = Readonly<{
312
272
  conditions: readonly PublicCodexDoctorCondition[];
313
273
  }>;
314
- /** A healthy connector must have positive observation evidence within this age. */
315
274
  export declare const CONNECTOR_OBSERVATION_STALE_AFTER_MS = 35000;
316
275
  /**
317
276
  * Bounded, native-ID-free evidence attached to one Claude connector. Counts
@@ -342,17 +301,15 @@ export type PublicAvailablePeerSnapshot = {
342
301
  provider: GatewayProvider;
343
302
  host: string;
344
303
  state: PublicAvailablePeerState;
345
- /** True only when this row passed the provider's strict selectable-peer checks. */
346
304
  validated: boolean;
347
305
  selected: boolean;
348
306
  lastSeenAt?: string;
349
307
  safeErrorCode?: string;
350
308
  };
351
- export declare const gatewayActivityKinds: readonly ["discovery", "selection", "registration", "pairing", "watch", "endpoint", "recovery"];
309
+ export declare const gatewayActivityKinds: readonly ["discovery", "selection", "registration", "pairing", "watch"];
352
310
  export type GatewayActivityKind = (typeof gatewayActivityKinds)[number];
353
- export declare const gatewayActivityActions: readonly ["discovery_refreshed", "claude_selected", "claude_unselected", "codex_registered", "codex_succeeded", "codex_unregistered", "routes_paired", "routes_unpaired", "watch_ended", "endpoint_refreshed", "codex_orphan_removed"];
311
+ export declare const gatewayActivityActions: readonly ["discovery_refreshed", "claude_selected", "claude_unselected", "codex_registered", "codex_succeeded", "codex_unregistered", "routes_paired", "routes_unpaired", "watch_ended"];
354
312
  export type GatewayActivityAction = (typeof gatewayActivityActions)[number];
355
- /** Bounded, body-free operator activity retained for this broker process. */
356
313
  export type PublicGatewayActivityEvent = {
357
314
  sequence: number;
358
315
  timestamp: string;
@@ -370,7 +327,6 @@ export type DeadlinePressureBucket = {
370
327
  settled: number;
371
328
  expired: number;
372
329
  };
373
- /** Counts are computed only from the bounded retained delivery ledger. */
374
330
  export type DeadlinePressureSnapshot = {
375
331
  configuredDeadlineMs: number;
376
332
  retainedSince?: string;
@@ -378,7 +334,6 @@ export type DeadlinePressureSnapshot = {
378
334
  expiredEvents: number;
379
335
  buckets: DeadlinePressureBucket[];
380
336
  };
381
- /** Strict closed-schema guard for runtime-supplied transient inventory rows. */
382
337
  export declare function isPublicAvailablePeerSnapshot(value: unknown): value is PublicAvailablePeerSnapshot;
383
338
  export declare function arePublicAvailablePeerSnapshots(value: unknown, maximumRows?: number): value is PublicAvailablePeerSnapshot[];
384
339
  export declare function isPublicRegistryObservationSnapshot(value: unknown): value is PublicRegistryObservationSnapshot;
@@ -411,7 +366,6 @@ export type PublicProgressWatchEventSnapshot = {
411
366
  export type GatewayPublicSnapshot = {
412
367
  schemaVersion: 2;
413
368
  generatedAt: string;
414
- /** Launch-time Claude-to-Codex consent policy; paired is the safe default. */
415
369
  inboundMode: GatewayInboundMode;
416
370
  health: ConnectorHealth;
417
371
  connectors: PublicConnectorSnapshot[];
@@ -447,100 +401,114 @@ export type GatewaySnapshotTruncation = {
447
401
  export declare function projectGatewayPublicSnapshot(snapshot: GatewayPublicSnapshot, maximumBytes?: number): GatewayPublicSnapshot;
448
402
  export type RegisterRouteInput = {
449
403
  alias: string;
450
- binding: PrivateRouteBinding;
404
+ binding: LogicalRouteBinding;
451
405
  registrationMode: RouteRegistrationMode;
452
- state?: "idle" | "busy" | "awaiting_approval";
453
406
  };
454
- export type ObserveConnectorInput = {
455
- identity: PrivateEndpointIdentity;
456
- health: Exclude<ConnectorHealth, "offline">;
457
- protocol: string;
458
- protocolVersion: string;
407
+ export type GatewayReservedAttempt = Readonly<{
408
+ messageId: string;
409
+ attemptId: string;
410
+ attemptCount: number;
411
+ body: string;
412
+ deadlineAt: string;
413
+ direction: MessageDirection;
414
+ sourceAlias: string;
415
+ targetAlias: string;
416
+ conversationIdSuffix?: string;
417
+ sourceRegistrationId: string | null;
418
+ targetRegistrationId: string;
419
+ consentEdge: readonly [GatewayConsentEndpoint, GatewayConsentEndpoint] | null;
420
+ bytes: number;
421
+ steer?: true;
422
+ }>;
423
+ export type ReserveMessageResult = Readonly<{
424
+ status: "empty";
425
+ }> | Readonly<{
426
+ status: "terminal";
427
+ settlement: TerminalMessageSettlement;
428
+ }> | Readonly<{
429
+ status: "reserved";
430
+ attempt: GatewayReservedAttempt;
431
+ }>;
432
+ type AttemptInput = Readonly<{
433
+ messageId: string;
434
+ attemptId: string;
435
+ }>;
436
+ type StaleAttemptResult = Readonly<{
437
+ status: "stale";
438
+ }>;
439
+ type SettledAttemptResult = Readonly<{
440
+ status: "settled";
441
+ settlement: TerminalMessageSettlement;
442
+ }>;
443
+ export type AuthorizeMessageInput = AttemptInput & Readonly<{
444
+ sourceRegistrationId: string | null;
445
+ targetRegistrationId: string;
446
+ prepared: GatewayPreparedWriteEvidence;
447
+ }>;
448
+ export type AuthorizeMessageResult = Readonly<{
449
+ status: "authorized";
450
+ }> | Readonly<{
451
+ status: "stale";
452
+ reason: "not_reserved" | "attempt_mismatch" | "registration_changed" | "consent_removed";
453
+ }> | Readonly<{
454
+ status: "terminal";
455
+ reason: "expired" | "fenced";
456
+ settlement: TerminalMessageSettlement;
457
+ }>;
458
+ export type AcceptMessageInput = AttemptInput & Readonly<{
459
+ lossOutcome: "unconfirmed" | "ambiguous";
460
+ }>;
461
+ export type AcceptMessageResult = Readonly<{
462
+ status: "accepted";
463
+ }> | StaleAttemptResult;
464
+ export type ResolvePrewriteAttemptInput = AttemptInput & Readonly<{
465
+ outcome: "requeue" | "failed";
459
466
  safeErrorCode?: string;
460
- };
461
- export type ObserveRouteInput = {
462
- binding: PrivateRouteBinding;
463
- state: "idle" | "busy" | "awaiting_approval";
467
+ }>;
468
+ export type ResolvePrewriteAttemptResult = Readonly<{
469
+ status: "requeued";
470
+ }> | SettledAttemptResult | StaleAttemptResult;
471
+ export type SettleAttemptInput = AttemptInput & Readonly<{
472
+ state: Exclude<TerminalDeliveryOutcome, "abandoned">;
464
473
  safeErrorCode?: string;
465
- } | {
466
- binding: PrivateRouteBinding;
467
- state: "stale";
468
- safeErrorCode: string;
469
- };
470
- export type RebindStaleRouteInput = {
471
- /** The currently persisted alias. */
472
- alias: string;
473
- /** The provider's latest live display name for the same logical route. */
474
- newAlias?: string;
475
- currentOwnerLease: string;
476
- newBinding: PrivateRouteBinding;
477
- reason: "endpoint_reobserved" | "peer_explicitly_reselected" | "peer_identity_reobserved";
478
- /** Append exact private boot-recovery evidence in the refresh journal. */
479
- journalReason?: "boot_reactivation";
480
- state?: "idle" | "busy" | "awaiting_approval";
481
- };
482
- export type ReanchorCodexRouteInput = {
483
- alias: string;
484
- /** Exact private App Server thread identifier proved present by loaded/list. */
485
- threadId: string;
486
- /** Existing registration authority; a refresh never rotates this lease. */
487
- ownerLease: string;
488
- state?: "idle" | "busy" | "awaiting_approval";
489
- };
490
- export type ReanchorCodexRoutesInput = {
491
- oldEndpoint: PrivateEndpointIdentity;
492
- newEndpoint: PrivateEndpointIdentity;
493
- /** Only the exact loaded/list-present subset is named here. */
494
- routes: readonly ReanchorCodexRouteInput[];
495
- };
496
- export type ReanchorCodexRoutesResult = {
497
- reboundAliases: string[];
498
- };
499
- export type RemoveStaleCodexOrphanInput = {
500
- /** Dashboard-confirmed exact public alias; no native identifier is accepted. */
501
- alias: string;
502
- };
503
- export type StaleCodexOrphanRemovalAuthority = {
504
- binding: PrivateRouteBinding;
505
- previousSequence: number;
506
- };
507
- export type StaleCodexOrphanRemovalCommitProofInput = {
508
- alias: string;
509
- binding: PrivateRouteBinding;
510
- previousSequence: number;
511
- };
512
- export type RemoveStaleCodexOrphanResult = {
513
- alias: string;
514
- /** Private result used only to reconcile in-process service bindings. */
515
- binding: PrivateRouteBinding;
516
- removedEdges: Array<{
517
- aliases: readonly [string, string];
518
- }>;
519
- };
474
+ }>;
475
+ export type SettleAttemptResult = SettledAttemptResult | StaleAttemptResult;
476
+ export type SettleAttemptForShutdownInput = AttemptInput;
477
+ export type SettleAttemptForShutdownResult = Readonly<{
478
+ status: "requeued";
479
+ }> | SettledAttemptResult | StaleAttemptResult;
480
+ export type SettleQueuedMessageForShutdownInput = Readonly<{
481
+ messageId: string;
482
+ }>;
483
+ export type SettleQueuedMessageForShutdownResult = SettledAttemptResult | StaleAttemptResult;
484
+ export type RemoveRouteAtomicResult = Readonly<{
485
+ removed: boolean;
486
+ settlements: readonly TerminalMessageSettlement[];
487
+ }>;
488
+ export type GatewayAtomicActivityInput = Readonly<{
489
+ operatorAction: boolean;
490
+ }>;
491
+ export type ReplaceCodexRegistrationAtomicInput = Readonly<{
492
+ oldAlias: string;
493
+ expectedOldRegistrationId: string;
494
+ replacement: RegisterRouteInput;
495
+ activity: GatewayAtomicActivityInput;
496
+ }>;
497
+ export type ReplaceCodexRegistrationAtomicResult = Readonly<{
498
+ replaced: boolean;
499
+ idempotent: boolean;
500
+ settlements: readonly TerminalMessageSettlement[];
501
+ }>;
520
502
  export type EnqueueMessageInput = {
521
503
  sourceAlias: string;
522
504
  targetAlias: string;
505
+ expectedSourceRegistrationId?: string;
506
+ expectedTargetRegistrationId?: string;
523
507
  body: string;
524
508
  dedupeKey: string;
525
- /** Last eight opaque characters of the controller-owned conversation ID. */
526
509
  conversationIdSuffix?: string;
527
510
  deadlineAt?: string;
528
511
  steer?: true;
529
- /**
530
- * Controller-derived watch intent committed in the same mutation as the
531
- * accepted message. Bodies and command flags are never persisted here.
532
- */
533
- progressWatch?: {
534
- conversationId: string;
535
- actorAlias: string;
536
- openIdleMs?: number;
537
- completionSignal?: true;
538
- };
539
- /** Controller-authored nudge committed atomically with its queued body. */
540
- progressWatchNudge?: {
541
- conversationId: string;
542
- nudgeNumber: 1 | 2;
543
- };
544
512
  };
545
513
  /**
546
514
  * Controller-internal proof of one currently observed native Claude peer.
@@ -549,36 +517,30 @@ export type EnqueueMessageInput = {
549
517
  */
550
518
  export type TransientNativeClaudePeer = {
551
519
  alias: string;
552
- binding: PrivateRouteBinding;
520
+ binding: LogicalRouteBinding;
553
521
  };
554
- export type EnqueueNativeIngressInput = Omit<EnqueueMessageInput, "sourceAlias" | "targetAlias"> & {
522
+ export type EnqueueNativeIngressInput = Omit<EnqueueMessageInput, "sourceAlias" | "targetAlias" | "expectedSourceRegistrationId" | "expectedTargetRegistrationId"> & {
555
523
  source: TransientNativeClaudePeer;
556
524
  targetAlias: string;
557
- /** Pre-deadline reply evidence retained across exact pair teardown. */
525
+ expectedTargetRegistrationId: string;
558
526
  authorizedPairTeardownReply?: true;
559
527
  };
560
- export type EnqueueNativeReplyInput = Omit<EnqueueMessageInput, "sourceAlias" | "targetAlias"> & {
528
+ export type EnqueueNativeReplyInput = Omit<EnqueueMessageInput, "sourceAlias" | "targetAlias" | "expectedSourceRegistrationId" | "expectedTargetRegistrationId"> & {
561
529
  sourceAlias: string;
530
+ expectedSourceRegistrationId: string;
562
531
  target: TransientNativeClaudePeer;
563
- /** Retain the original paired admission authority, when one existed. */
564
532
  pair?: true;
533
+ exposeDeliveryToken?: true;
565
534
  };
566
535
  export type EnqueueMessageResult = {
567
536
  accepted: boolean;
568
537
  duplicate: boolean;
569
538
  messageId?: string;
570
539
  messageIdSuffix: string;
571
- /** The accepted message is owned by one exact consent edge. */
540
+ deliveryToken?: string;
572
541
  pair?: true;
573
- /** Exact older queued steer displaced by the per-edge cap, if any. */
574
542
  supersededSettlement?: TerminalMessageSettlement;
575
543
  };
576
- export type InFlightMessageProgressState = Extract<DeliveryState, "transport_written" | "held">;
577
- export type SettleMessageInput = {
578
- messageId: string;
579
- state: Extract<DeliveryState, "delivered" | "unconfirmed" | "failed" | "ambiguous" | "expired" | "cancelled">;
580
- safeErrorCode?: string;
581
- };
582
544
  /**
583
545
  * Controller-internal proof that one message won its terminal-state race.
584
546
  * Full message IDs are required only for in-memory service correlation; this
@@ -586,27 +548,12 @@ export type SettleMessageInput = {
586
548
  */
587
549
  export type TerminalMessageSettlement = {
588
550
  messageId: string;
589
- state: Extract<DeliveryState, "delivered" | "unconfirmed" | "failed" | "ambiguous" | "expired" | "cancelled" | "abandoned">;
551
+ state: TerminalDeliveryOutcome;
590
552
  safeErrorCode?: string;
591
553
  };
592
- export type SettleMessageResult = {
593
- status: "settled";
594
- settlement: TerminalMessageSettlement;
595
- } | {
596
- status: "not_in_flight";
597
- };
598
- export type RequeueInFlightMessageResult = {
599
- status: "requeued";
600
- } | {
601
- status: "settled";
602
- settlement: TerminalMessageSettlement;
603
- } | {
604
- status: "not_in_flight";
605
- };
606
554
  export type GatewayStoreLimits = {
607
555
  maxRoutes: number;
608
556
  maxConsentEdges: number;
609
- /** Omitted injected-test configs use the production default of 32. */
610
557
  maxWatches?: number;
611
558
  eventCapacity: number;
612
559
  eventTtlMs: number;
@@ -617,7 +564,6 @@ export type GatewayStoreLimits = {
617
564
  maxInFlightMessages: number;
618
565
  maxQueueBytes: number;
619
566
  maxMessageBytes: number;
620
- /** Bounded historical event-body bytes; omitted configs use 1 MiB. */
621
567
  maxRetainedBodyBytes?: number;
622
568
  messageDeadlineMs: number;
623
569
  rateLimitPerRoute: number;
@@ -626,6 +572,7 @@ export type GatewayStoreLimits = {
626
572
  export type GatewayStoreDependencies = {
627
573
  now?: () => Date;
628
574
  randomId?: () => string;
629
- /** Deterministic durability-fault seam; production callers leave this unset. */
575
+ renameStateFile?: (source: string, target: string) => Promise<void>;
630
576
  afterStateFileRename?: () => void | Promise<void>;
631
577
  };
578
+ export {};