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