agent-embassy 3.0.0 → 4.0.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 (115) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/CONTRIBUTING.md +92 -200
  3. package/README.md +159 -138
  4. package/SECURITY.md +191 -335
  5. package/dist/src/gateway/broker-check.d.ts +26 -0
  6. package/dist/src/gateway/broker-check.js +89 -0
  7. package/dist/src/gateway/broker-check.js.map +1 -0
  8. package/dist/src/gateway/broker-control.d.ts +72 -0
  9. package/dist/src/gateway/broker-control.js +164 -0
  10. package/dist/src/gateway/broker-control.js.map +1 -0
  11. package/dist/src/gateway/broker.d.ts +117 -0
  12. package/dist/src/gateway/broker.js +186 -0
  13. package/dist/src/gateway/broker.js.map +1 -0
  14. package/dist/src/gateway/claude-peer.d.ts +1 -124
  15. package/dist/src/gateway/claude-peer.js +62 -1053
  16. package/dist/src/gateway/claude-peer.js.map +1 -1
  17. package/dist/src/gateway/codex-stateless-transport.d.ts +0 -12
  18. package/dist/src/gateway/codex-stateless-transport.js +8 -142
  19. package/dist/src/gateway/codex-stateless-transport.js.map +1 -1
  20. package/dist/src/gateway/config.d.ts +2 -6
  21. package/dist/src/gateway/config.js +17 -27
  22. package/dist/src/gateway/config.js.map +1 -1
  23. package/dist/src/gateway/coordinator.d.ts +57 -0
  24. package/dist/src/gateway/coordinator.js +217 -0
  25. package/dist/src/gateway/coordinator.js.map +1 -0
  26. package/dist/src/gateway/core-cli.d.ts +15 -0
  27. package/dist/src/gateway/core-cli.js +282 -0
  28. package/dist/src/gateway/core-cli.js.map +1 -0
  29. package/dist/src/gateway/core-service-command.d.ts +16 -0
  30. package/dist/src/gateway/core-service-command.js +71 -0
  31. package/dist/src/gateway/core-service-command.js.map +1 -0
  32. package/dist/src/gateway/endpoint-directory.d.ts +33 -0
  33. package/dist/src/gateway/endpoint-directory.js +223 -0
  34. package/dist/src/gateway/endpoint-directory.js.map +1 -0
  35. package/dist/src/gateway/federation.d.ts +89 -0
  36. package/dist/src/gateway/federation.js +632 -0
  37. package/dist/src/gateway/federation.js.map +1 -0
  38. package/dist/src/gateway/ledger-codec.d.ts +3 -0
  39. package/dist/src/gateway/ledger-codec.js +159 -0
  40. package/dist/src/gateway/ledger-codec.js.map +1 -0
  41. package/dist/src/gateway/ledger.d.ts +138 -0
  42. package/dist/src/gateway/ledger.js +319 -0
  43. package/dist/src/gateway/ledger.js.map +1 -0
  44. package/dist/src/gateway/local-control.d.ts +23 -0
  45. package/dist/src/gateway/local-control.js +489 -0
  46. package/dist/src/gateway/local-control.js.map +1 -0
  47. package/dist/src/gateway/native-destinations.d.ts +34 -0
  48. package/dist/src/gateway/native-destinations.js +272 -0
  49. package/dist/src/gateway/native-destinations.js.map +1 -0
  50. package/dist/src/gateway/owned-state.d.ts +57 -0
  51. package/dist/src/gateway/owned-state.js +398 -0
  52. package/dist/src/gateway/owned-state.js.map +1 -0
  53. package/dist/src/gateway/provenance-envelope.d.ts +3 -3
  54. package/dist/src/gateway/provenance-envelope.js +3 -23
  55. package/dist/src/gateway/provenance-envelope.js.map +1 -1
  56. package/dist/src/gateway/runtime.d.ts +41 -0
  57. package/dist/src/gateway/runtime.js +175 -0
  58. package/dist/src/gateway/runtime.js.map +1 -0
  59. package/docs/CONFIGURATION.md +178 -266
  60. package/docs/DELIVERY.md +133 -82
  61. package/docs/GATEWAY-ARCHITECTURE.md +276 -943
  62. package/package.json +5 -5
  63. package/skills/embassy-peer/SKILL.md +38 -194
  64. package/skills/embassy-peer/agents/openai.yaml +2 -2
  65. package/dist/src/gateway/claude-helper-client.d.ts +0 -2
  66. package/dist/src/gateway/claude-helper-client.js +0 -2
  67. package/dist/src/gateway/claude-helper-client.js.map +0 -1
  68. package/dist/src/gateway/claude-helper-protocol.d.ts +0 -117
  69. package/dist/src/gateway/claude-helper-protocol.js +0 -122
  70. package/dist/src/gateway/claude-helper-protocol.js.map +0 -1
  71. package/dist/src/gateway/claude-helper-supervisor.d.ts +0 -87
  72. package/dist/src/gateway/claude-helper-supervisor.js +0 -347
  73. package/dist/src/gateway/claude-helper-supervisor.js.map +0 -1
  74. package/dist/src/gateway/claude-helper.d.ts +0 -1
  75. package/dist/src/gateway/claude-helper.js +0 -252
  76. package/dist/src/gateway/claude-helper.js.map +0 -1
  77. package/dist/src/gateway/cli.d.ts +0 -57
  78. package/dist/src/gateway/cli.js +0 -1503
  79. package/dist/src/gateway/cli.js.map +0 -1
  80. package/dist/src/gateway/codex-socket-holder.d.ts +0 -26
  81. package/dist/src/gateway/codex-socket-holder.js +0 -76
  82. package/dist/src/gateway/codex-socket-holder.js.map +0 -1
  83. package/dist/src/gateway/control.d.ts +0 -261
  84. package/dist/src/gateway/control.js +0 -903
  85. package/dist/src/gateway/control.js.map +0 -1
  86. package/dist/src/gateway/peer-client.d.ts +0 -58
  87. package/dist/src/gateway/peer-client.js +0 -217
  88. package/dist/src/gateway/peer-client.js.map +0 -1
  89. package/dist/src/gateway/peer-mailbox.d.ts +0 -78
  90. package/dist/src/gateway/peer-mailbox.js +0 -168
  91. package/dist/src/gateway/peer-mailbox.js.map +0 -1
  92. package/dist/src/gateway/peer-protocol.d.ts +0 -105
  93. package/dist/src/gateway/peer-protocol.js +0 -70
  94. package/dist/src/gateway/peer-protocol.js.map +0 -1
  95. package/dist/src/gateway/peer-stdio.d.ts +0 -23
  96. package/dist/src/gateway/peer-stdio.js +0 -100
  97. package/dist/src/gateway/peer-stdio.js.map +0 -1
  98. package/dist/src/gateway/providers.d.ts +0 -163
  99. package/dist/src/gateway/providers.js +0 -972
  100. package/dist/src/gateway/providers.js.map +0 -1
  101. package/dist/src/gateway/server.d.ts +0 -47
  102. package/dist/src/gateway/server.js +0 -219
  103. package/dist/src/gateway/server.js.map +0 -1
  104. package/dist/src/gateway/service.d.ts +0 -373
  105. package/dist/src/gateway/service.js +0 -2274
  106. package/dist/src/gateway/service.js.map +0 -1
  107. package/dist/src/gateway/status-view.d.ts +0 -167
  108. package/dist/src/gateway/status-view.js +0 -488
  109. package/dist/src/gateway/status-view.js.map +0 -1
  110. package/dist/src/gateway/store.d.ts +0 -185
  111. package/dist/src/gateway/store.js +0 -2359
  112. package/dist/src/gateway/store.js.map +0 -1
  113. package/dist/src/gateway/types.d.ts +0 -528
  114. package/dist/src/gateway/types.js +0 -341
  115. package/dist/src/gateway/types.js.map +0 -1
@@ -1,528 +0,0 @@
1
- export declare const gatewayProviders: readonly ["claude", "codex", "peer"];
2
- export type GatewayProvider = (typeof gatewayProviders)[number];
3
- export declare const gatewayRegistrationIngressPrefixes: Readonly<{
4
- claude: undefined;
5
- codex: string;
6
- peer: string;
7
- }>;
8
- export declare const connectorHealthStates: readonly ["offline", "connecting", "healthy", "degraded"];
9
- export type ConnectorHealth = (typeof connectorHealthStates)[number];
10
- export declare const routeStates: readonly ["stale", "idle", "busy", "awaiting_approval", "offline", "disabled"];
11
- export type RouteState = (typeof routeStates)[number];
12
- export declare const routeRegistrationModes: readonly ["explicit_opt_in", "selected_live_peer", "federated_peer"];
13
- export type RouteRegistrationMode = (typeof routeRegistrationModes)[number];
14
- export type MessageDirection = `${GatewayProvider}_to_${GatewayProvider}`;
15
- export type ParsedMessageDirection = Readonly<{
16
- sourceProvider: GatewayProvider;
17
- targetProvider: GatewayProvider;
18
- }>;
19
- export declare const isGatewayProvider: (value: unknown) => value is GatewayProvider;
20
- export declare function directionId(sourceProvider: GatewayProvider, targetProvider: GatewayProvider): MessageDirection;
21
- export declare const messageDirections: readonly MessageDirection[];
22
- export declare function parseDirection(value: unknown): ParsedMessageDirection | undefined;
23
- export declare const isMessageDirection: (value: unknown) => value is MessageDirection;
24
- export declare const deliveryStates: readonly ["queued", "duplicate", "dispatching", "transport_written", "held", "delivered", "unconfirmed", "failed", "ambiguous", "expired", "cancelled", "abandoned", "rejected"];
25
- export type DeliveryState = (typeof deliveryStates)[number];
26
- export type TerminalDeliveryOutcome = Extract<DeliveryState, "delivered" | "unconfirmed" | "failed" | "ambiguous" | "expired" | "cancelled" | "abandoned">;
27
- export declare const alertSeverities: readonly ["info", "warning", "error"];
28
- export type AlertSeverity = (typeof alertSeverities)[number];
29
- export type BusyPolicy = "queue";
30
- export declare const gatewayPublicSnapshotLimits: Readonly<{
31
- readonly connectors: 64;
32
- readonly registryRejectionCodes: 32;
33
- readonly availablePeers: 256;
34
- readonly routes: 256;
35
- readonly activityEvents: 256;
36
- readonly messages: 1024;
37
- readonly alerts: 256;
38
- }>;
39
- export declare const GATEWAY_PUBLIC_SNAPSHOT_BYTE_BUDGET: number;
40
- /**
41
- * Durable logical registration. Provider endpoint generations are deliberately
42
- * absent: they are operation-local evidence and never routing authority.
43
- */
44
- export type LogicalRouteBinding = {
45
- provider: GatewayProvider;
46
- hostId: string;
47
- routeHandle: string;
48
- registrationId: string;
49
- };
50
- export type RouteCounters = {
51
- accepted: number;
52
- delivered: number;
53
- unconfirmed: number;
54
- failed: number;
55
- ambiguous: number;
56
- expired: number;
57
- cancelled: number;
58
- abandoned: number;
59
- rejected: number;
60
- bytesAccepted: number;
61
- };
62
- export type GatewayRouteRecord = {
63
- alias: string;
64
- binding: LogicalRouteBinding;
65
- registrationMode: RouteRegistrationMode;
66
- enabled: boolean;
67
- busyPolicy: BusyPolicy;
68
- registeredAt: string;
69
- updatedAt: string;
70
- counters: RouteCounters;
71
- };
72
- /**
73
- * Controller-internal route view used to prove ownership across a restart.
74
- * This type must never cross the control protocol or enter a public snapshot.
75
- */
76
- export type GatewayPrivateRouteInspection = {
77
- alias: string;
78
- binding: LogicalRouteBinding;
79
- registrationMode: RouteRegistrationMode;
80
- enabled: boolean;
81
- };
82
- export type QueuedMessageMetadata = {
83
- messageId: string;
84
- messageIdSuffix: string;
85
- conversationIdSuffix?: string;
86
- direction: MessageDirection;
87
- sourceAlias: string;
88
- targetAlias: string;
89
- enqueuedAt: string;
90
- deadlineAt: string;
91
- bytes: number;
92
- body?: string;
93
- steer?: true;
94
- };
95
- export type DedupeRecord = {
96
- fingerprint: string;
97
- messageIdSuffix: string;
98
- conversationIdSuffix?: string;
99
- sourceAlias: string;
100
- targetAlias: string;
101
- direction: MessageDirection;
102
- firstSeenAt: string;
103
- expiresAt: string;
104
- };
105
- export type RateBucket = {
106
- sourceAlias: string;
107
- windowStartedAt: string;
108
- count: number;
109
- };
110
- export type NormalizedMessageEvent = {
111
- sequence: number;
112
- timestamp: string;
113
- messageIdSuffix: string;
114
- conversationIdSuffix?: string;
115
- direction: MessageDirection;
116
- sourceAlias: string;
117
- targetAlias: string;
118
- state: DeliveryState;
119
- bytes: number;
120
- body?: string;
121
- steer?: true;
122
- latencyMs?: number;
123
- safeErrorCode?: string;
124
- };
125
- export type GatewayAccounting = {
126
- accepted: number;
127
- duplicates: number;
128
- delivered: number;
129
- unconfirmed: number;
130
- failed: number;
131
- ambiguous: number;
132
- expired: number;
133
- cancelled: number;
134
- abandoned: number;
135
- rejected: number;
136
- bytesAccepted: number;
137
- queuedBytes: number;
138
- };
139
- export type GatewayPreparedWriteEvidence = {
140
- kind: "claude_mailbox" | "codex_turn_start" | "codex_turn_steer" | "peer_mailbox" | "peer_handoff";
141
- bodyBytes: number;
142
- bodySha256: string;
143
- frameBytes: number;
144
- sha256: string;
145
- };
146
- export type GatewayMessageAttemptAuthority = {
147
- attemptId: string;
148
- attemptCount: number;
149
- targetRegistrationId: string;
150
- sourceRegistrationId: string;
151
- };
152
- export type GatewayMessageState = {
153
- phase: "queued";
154
- attemptCount: number;
155
- } | (GatewayMessageAttemptAuthority & {
156
- phase: "reserved";
157
- reservedAt: string;
158
- }) | (GatewayMessageAttemptAuthority & {
159
- phase: "armed";
160
- armedAt: string;
161
- prepared: GatewayPreparedWriteEvidence;
162
- }) | (GatewayMessageAttemptAuthority & {
163
- phase: "accepted";
164
- acceptedAt: string;
165
- prepared: GatewayPreparedWriteEvidence;
166
- lossOutcome: "unconfirmed" | "ambiguous";
167
- }) | {
168
- phase: "terminal";
169
- outcome: TerminalDeliveryOutcome;
170
- terminalAt: string;
171
- safeErrorCode?: string;
172
- latencyMs: number;
173
- };
174
- export type GatewayMessageRecord = QueuedMessageMetadata & {
175
- sequence: number;
176
- deliveryToken?: string;
177
- sourceRegistrationId: string;
178
- targetRegistrationId: string | null;
179
- state: GatewayMessageState;
180
- };
181
- export type GatewayMessageActivity = {
182
- type: "message_activity";
183
- event: NormalizedMessageEvent;
184
- };
185
- export type GatewayRuntimeActivity = {
186
- type: "activity";
187
- event: PublicGatewayActivityEvent;
188
- };
189
- export type GatewayStateActivity = GatewayMessageActivity | GatewayRuntimeActivity;
190
- export type GatewayPersistedState = {
191
- schemaVersion: 5;
192
- commit: {
193
- sequence: number;
194
- id: string;
195
- };
196
- createdAt: string;
197
- updatedAt: string;
198
- eventSequence: number;
199
- routes: GatewayRouteRecord[];
200
- messages: GatewayMessageRecord[];
201
- dedupe: DedupeRecord[];
202
- rateBuckets: RateBucket[];
203
- activity: GatewayStateActivity[];
204
- accounting: GatewayAccounting;
205
- };
206
- export type PublicRouteSnapshot = {
207
- alias: string;
208
- provider: GatewayProvider;
209
- host: string;
210
- enabled: boolean;
211
- state: RouteState;
212
- busyPolicy: BusyPolicy;
213
- lastSeenAt?: string;
214
- queueDepth: number;
215
- oldestQueuedAt?: string;
216
- counters: RouteCounters;
217
- safeErrorCode?: string;
218
- mutable?: boolean;
219
- };
220
- export type PublicConnectorSnapshot = {
221
- provider: GatewayProvider;
222
- host: string;
223
- health: ConnectorHealth;
224
- protocol: string;
225
- protocolVersion: string;
226
- lastSeenAt?: string;
227
- observationAgeMs?: number;
228
- safeErrorCode?: string;
229
- registry?: PublicRegistryObservationSnapshot;
230
- };
231
- export declare const CONNECTOR_OBSERVATION_STALE_AFTER_MS = 35000;
232
- /**
233
- * Bounded, native-ID-free evidence attached to one Claude connector. Counts
234
- * describe only the latest pass; the monotonic flag distinguishes an ordinary
235
- * empty registry from one that has never yielded parseable required fields
236
- * this boot.
237
- */
238
- export type PublicRegistryObservationSnapshot = {
239
- entriesScanned: number;
240
- parseableRecords: number;
241
- parseableRecordSeenSinceBoot: boolean;
242
- rejected: {
243
- safeErrorCode: string;
244
- count: number;
245
- }[];
246
- rejectedCodesOmitted: number;
247
- };
248
- export declare const publicAvailablePeerStates: readonly ["idle", "busy", "awaiting_approval", "offline"];
249
- export type PublicAvailablePeerState = (typeof publicAvailablePeerStates)[number];
250
- /**
251
- * A transient, metadata-only discovery row. Native provider IDs, process
252
- * identifiers, registry/socket paths, and generations are deliberately absent.
253
- * Version 1 uses this for genuine Claude peers; Codex inventory remains the
254
- * explicit PublicRouteSnapshot list. `routed` means the session currently has
255
- * an installed logical route — it is a fact about the route table, never a
256
- * permission: any discovered session is addressable, and its route installs on
257
- * first use.
258
- */
259
- export type PublicAvailablePeerSnapshot = {
260
- alias: string;
261
- provider: GatewayProvider;
262
- host: string;
263
- state: PublicAvailablePeerState;
264
- validated: boolean;
265
- routed: boolean;
266
- lastSeenAt?: string;
267
- safeErrorCode?: string;
268
- };
269
- export declare const gatewayActivityKinds: readonly ["discovery", "registration"];
270
- export type GatewayActivityKind = (typeof gatewayActivityKinds)[number];
271
- /**
272
- * `claude_route_installed` and `claude_route_retired` are journaled by the
273
- * store when a send installs, renames, or displaces a discovered Claude
274
- * session's route; there is no explicit Claude registration command.
275
- */
276
- export declare const gatewayActivityActions: readonly ["discovery_refreshed", "codex_registered", "codex_succeeded", "codex_unregistered", "claude_route_installed", "claude_route_retired"];
277
- export type GatewayActivityAction = (typeof gatewayActivityActions)[number];
278
- export type PublicGatewayActivityEvent = {
279
- sequence: number;
280
- timestamp: string;
281
- kind: GatewayActivityKind;
282
- action: GatewayActivityAction;
283
- outcome: "accepted" | "rejected";
284
- aliases: string[];
285
- operatorAction: boolean;
286
- safeErrorCode?: string;
287
- };
288
- export declare const deadlinePressureBucketNames: readonly ["under_1m", "1m_to_5m", "5m_to_15m", "15m_to_60m", "over_60m"];
289
- export type DeadlinePressureBucketName = (typeof deadlinePressureBucketNames)[number];
290
- export type DeadlinePressureBucket = {
291
- bucket: DeadlinePressureBucketName;
292
- settled: number;
293
- expired: number;
294
- };
295
- export type DeadlinePressureSnapshot = {
296
- configuredDeadlineMs: number;
297
- retainedSince?: string;
298
- terminalEvents: number;
299
- expiredEvents: number;
300
- buckets: DeadlinePressureBucket[];
301
- };
302
- export declare function isPublicAvailablePeerSnapshot(value: unknown): value is PublicAvailablePeerSnapshot;
303
- export declare function arePublicAvailablePeerSnapshots(value: unknown, maximumRows?: number): value is PublicAvailablePeerSnapshot[];
304
- export declare function isPublicRegistryObservationSnapshot(value: unknown): value is PublicRegistryObservationSnapshot;
305
- export type SafeGatewayAlert = {
306
- code: string;
307
- severity: AlertSeverity;
308
- timestamp: string;
309
- provider?: GatewayProvider;
310
- host?: string;
311
- alias?: string;
312
- };
313
- export type GatewayPublicSnapshot = {
314
- schemaVersion: 2;
315
- generatedAt: string;
316
- health: ConnectorHealth;
317
- connectors: PublicConnectorSnapshot[];
318
- availablePeers: PublicAvailablePeerSnapshot[];
319
- routes: PublicRouteSnapshot[];
320
- activityEvents?: PublicGatewayActivityEvent[];
321
- deadlinePressure?: DeadlinePressureSnapshot;
322
- messages: NormalizedMessageEvent[];
323
- accounting: GatewayAccounting;
324
- alerts: SafeGatewayAlert[];
325
- truncation: GatewaySnapshotTruncation;
326
- };
327
- export type GatewaySnapshotTruncation = {
328
- connectors: number;
329
- availablePeers: number;
330
- routes: number;
331
- activityEvents?: number;
332
- messages: number;
333
- alerts: number;
334
- };
335
- /**
336
- * Deterministically projects a canonical snapshot under the local control
337
- * byte budget. Content is never shortened: complete metadata rows are either
338
- * retained or counted as omitted. Registry rejection-code detail is shed
339
- * before routes; connector inventory remains last.
340
- */
341
- export declare function projectGatewayPublicSnapshot(snapshot: GatewayPublicSnapshot, maximumBytes?: number): GatewayPublicSnapshot;
342
- export type RegisterRouteInput = {
343
- alias: string;
344
- binding: LogicalRouteBinding;
345
- registrationMode: RouteRegistrationMode;
346
- /**
347
- * An ephemeral registration is real in memory — it routes, queues, and
348
- * settles exactly like any other — but it is projected out of the durable
349
- * state document along with every row that names it, so it cannot survive
350
- * a restart and cannot be published to a federation peer; and when it is
351
- * removed, by `unregister-peer` or by its own expiry, those rows leave the
352
- * live state with it, so nothing of it is written afterwards either.
353
- * `embassy check` uses one so a self-test leaves nothing behind.
354
- */
355
- ephemeral?: true;
356
- };
357
- export type GatewayReservedAttempt = Readonly<{
358
- messageId: string;
359
- attemptId: string;
360
- attemptCount: number;
361
- body: string;
362
- deadlineAt: string;
363
- direction: MessageDirection;
364
- sourceAlias: string;
365
- targetAlias: string;
366
- conversationIdSuffix?: string;
367
- sourceRegistrationId: string;
368
- targetRegistrationId: string;
369
- bytes: number;
370
- steer?: true;
371
- }>;
372
- export type ReserveMessageResult = Readonly<{
373
- status: "empty";
374
- }> | Readonly<{
375
- status: "terminal";
376
- settlement: TerminalMessageSettlement;
377
- }> | Readonly<{
378
- status: "reserved";
379
- attempt: GatewayReservedAttempt;
380
- }>;
381
- type AttemptInput = Readonly<{
382
- messageId: string;
383
- attemptId: string;
384
- }>;
385
- type StaleAttemptResult = Readonly<{
386
- status: "stale";
387
- }>;
388
- type SettledAttemptResult = Readonly<{
389
- status: "settled";
390
- settlement: TerminalMessageSettlement;
391
- }>;
392
- export type AuthorizeMessageInput = AttemptInput & Readonly<{
393
- sourceRegistrationId: string;
394
- targetRegistrationId: string;
395
- prepared: GatewayPreparedWriteEvidence;
396
- }>;
397
- export type AuthorizeMessageResult = Readonly<{
398
- status: "authorized";
399
- }> | Readonly<{
400
- status: "stale";
401
- reason: "not_reserved" | "attempt_mismatch" | "registration_changed";
402
- }> | Readonly<{
403
- status: "terminal";
404
- reason: "expired" | "fenced";
405
- settlement: TerminalMessageSettlement;
406
- }>;
407
- export type AcceptMessageInput = AttemptInput & Readonly<{
408
- lossOutcome: "unconfirmed" | "ambiguous";
409
- }>;
410
- export type AcceptMessageResult = Readonly<{
411
- status: "accepted";
412
- }> | StaleAttemptResult;
413
- export type ResolvePrewriteAttemptInput = AttemptInput & Readonly<{
414
- outcome: "requeue" | "failed";
415
- safeErrorCode?: string;
416
- }>;
417
- export type ResolvePrewriteAttemptResult = Readonly<{
418
- status: "requeued";
419
- }> | SettledAttemptResult | StaleAttemptResult;
420
- export type SettleAttemptInput = AttemptInput & Readonly<{
421
- state: Exclude<TerminalDeliveryOutcome, "abandoned">;
422
- safeErrorCode?: string;
423
- }>;
424
- export type SettleAttemptResult = SettledAttemptResult | StaleAttemptResult;
425
- export type SettleAttemptForShutdownInput = AttemptInput;
426
- export type SettleAttemptForShutdownResult = Readonly<{
427
- status: "requeued";
428
- }> | SettledAttemptResult | StaleAttemptResult;
429
- export type SettleQueuedMessageForShutdownInput = Readonly<{
430
- messageId: string;
431
- }>;
432
- export type SettleQueuedMessageForShutdownResult = SettledAttemptResult | StaleAttemptResult;
433
- export type RemoveRouteAtomicResult = Readonly<{
434
- removed: boolean;
435
- settlements: readonly TerminalMessageSettlement[];
436
- }>;
437
- export type GatewayAtomicActivityInput = Readonly<{
438
- operatorAction: boolean;
439
- }>;
440
- export type ReplaceCodexRegistrationAtomicInput = Readonly<{
441
- oldAlias: string;
442
- expectedOldRegistrationId: string;
443
- replacement: RegisterRouteInput;
444
- activity: GatewayAtomicActivityInput;
445
- }>;
446
- export type ReplaceCodexRegistrationAtomicResult = Readonly<{
447
- replaced: boolean;
448
- idempotent: boolean;
449
- settlements: readonly TerminalMessageSettlement[];
450
- }>;
451
- /**
452
- * Result of installing a discovered Claude session's route on first send.
453
- * `settlements` carries the work of any route the install displaced.
454
- */
455
- export type InstallClaudeRouteResult = Readonly<{
456
- installed: boolean;
457
- settlements: readonly TerminalMessageSettlement[];
458
- }>;
459
- export type EnqueueMessageInput = {
460
- sourceAlias: string;
461
- targetAlias: string;
462
- expectedSourceRegistrationId?: string;
463
- expectedTargetRegistrationId?: string;
464
- body: string;
465
- dedupeKey: string;
466
- conversationIdSuffix?: string;
467
- deadlineAt?: string;
468
- steer?: true;
469
- };
470
- /**
471
- * The native Claude sender of one inbound message: its installed route's
472
- * alias and exact binding. The binding carries a native session identifier
473
- * and must remain an in-memory call argument.
474
- */
475
- export type NativeClaudeSender = {
476
- alias: string;
477
- binding: LogicalRouteBinding;
478
- };
479
- export type EnqueueNativeIngressInput = Omit<EnqueueMessageInput, "sourceAlias" | "targetAlias" | "expectedSourceRegistrationId" | "expectedTargetRegistrationId"> & {
480
- source: NativeClaudeSender;
481
- targetAlias: string;
482
- expectedTargetRegistrationId: string;
483
- };
484
- export type EnqueueMessageResult = {
485
- accepted: boolean;
486
- duplicate: boolean;
487
- messageId?: string;
488
- messageIdSuffix: string;
489
- deliveryToken?: string;
490
- supersededSettlement?: TerminalMessageSettlement;
491
- };
492
- /**
493
- * Controller-internal proof that one message won its terminal-state race.
494
- * Full message IDs are required only for in-memory service correlation; this
495
- * structure must never enter a public snapshot or persisted event.
496
- */
497
- export type TerminalMessageSettlement = {
498
- messageId: string;
499
- state: TerminalDeliveryOutcome;
500
- safeErrorCode?: string;
501
- };
502
- export type GatewayStoreLimits = {
503
- maxRoutes: number;
504
- eventCapacity: number;
505
- eventTtlMs: number;
506
- dedupeCapacity: number;
507
- dedupeTtlMs: number;
508
- maxQueueMessages: number;
509
- maxQueueMessagesPerRoute: number;
510
- maxInFlightMessages: number;
511
- maxQueueBytes: number;
512
- maxMessageBytes: number;
513
- maxRetainedBodyBytes?: number;
514
- messageDeadlineMs: number;
515
- rateLimitPerRoute: number;
516
- rateWindowMs: number;
517
- };
518
- export type GatewayStoreDependencies = {
519
- now?: () => Date;
520
- randomId?: () => string;
521
- renameStateFile?: (source: string, target: string) => Promise<void>;
522
- afterStateFileRename?: () => void | Promise<void>;
523
- /** Controller-lock liveness probe; the default is `process.kill(pid, 0)`. */
524
- isProcessAlive?: (pid: number) => boolean;
525
- /** This machine's name as the controller lock records it; the default is `os.hostname()`. */
526
- hostname?: () => string;
527
- };
528
- export {};