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,185 +0,0 @@
1
- import type { GatewayConfig } from "./config.js";
2
- import { type PeerCatalogResult, type PeerHandoffParams } from "./peer-protocol.js";
3
- import type { AcceptMessageInput, AcceptMessageResult, AuthorizeMessageInput, AuthorizeMessageResult, EnqueueMessageInput, EnqueueMessageResult, EnqueueNativeIngressInput, GatewayMessageRecord, GatewayPersistedState, GatewayPrivateRouteInspection, GatewayPublicSnapshot, GatewayStoreDependencies, InstallClaudeRouteResult, LogicalRouteBinding, MessageDirection, PublicGatewayActivityEvent, RegisterRouteInput, RemoveRouteAtomicResult, ReplaceCodexRegistrationAtomicInput, ReplaceCodexRegistrationAtomicResult, ReserveMessageResult, ResolvePrewriteAttemptInput, ResolvePrewriteAttemptResult, SettleAttemptInput, SettleAttemptForShutdownInput, SettleAttemptForShutdownResult, SettleAttemptResult, SettleQueuedMessageForShutdownInput, SettleQueuedMessageForShutdownResult, TerminalMessageSettlement } from "./types.js";
4
- /** The controller lock's file name; the CLI reads the same file for a pid. */
5
- export declare const GATEWAY_CONTROLLER_LOCK_FILE = ".gateway-controller.lock";
6
- export declare const GATEWAY_MAX_STATE_FILE_BYTES: number;
7
- /**
8
- * `configuredHost` is the broker's own host identity, known at construction and
9
- * always supplied on the shipped path. Deriving the local host from the routes
10
- * alone is not sufficient: a federation node whose only routes are mirrors has
11
- * no local route to derive from, and a state file it just wrote would fail its
12
- * own validator on the next persist.
13
- */
14
- export declare function isGatewayPersistedStateV5(value: unknown, configuredHost?: string): value is GatewayPersistedState;
15
- export declare class GatewayStore {
16
- readonly config: GatewayConfig;
17
- rootDir: string;
18
- private readonly now;
19
- private readonly randomId;
20
- private readonly afterStateFileRename;
21
- private readonly renameStateFile;
22
- private readonly mutex;
23
- private state;
24
- private lockHandle;
25
- private lockToken;
26
- private readonly isProcessAlive;
27
- private readonly hostname;
28
- private persistenceDeferred;
29
- /**
30
- * Registration ids that must never reach the durable state document. They
31
- * are ordinary rows in the in-memory state — admission, dispatch, queueing
32
- * and settlement all see them — and are projected out at the one place that
33
- * serializes, together with every row that names one. When such a
34
- * registration is removed, the same rows leave the live state in the same
35
- * mutate, before the id leaves this set; a rolled-back mutate restores the
36
- * set with the state. Nothing here is written down, so a restart reclaims
37
- * them by construction.
38
- */
39
- private readonly ephemeralRegistrations;
40
- constructor(config: GatewayConfig, dependencies?: GatewayStoreDependencies);
41
- get stateFilePath(): string;
42
- initialize(options?: Readonly<{
43
- deferPersistence?: boolean;
44
- }>): Promise<void>;
45
- commitInitialization(): Promise<void>;
46
- close(): Promise<void>;
47
- inspectPrivateRoutes(): Promise<GatewayPrivateRouteInspection[]>;
48
- listLogicalRoutes(): Promise<GatewayPrivateRouteInspection[]>;
49
- inspectPrivateRoute(alias: string): Promise<GatewayPrivateRouteInspection | undefined>;
50
- reconcilePeerCatalog(peerHost: string, catalog: PeerCatalogResult): Promise<Readonly<{
51
- settlements: readonly TerminalMessageSettlement[];
52
- routes: readonly GatewayPrivateRouteInspection[];
53
- }>>;
54
- enqueuePeerHandoff(peerHost: string, handoff: PeerHandoffParams): Promise<EnqueueMessageResult>;
55
- registerRoute(input: RegisterRouteInput): Promise<void>;
56
- /** Whether this registration is memory-only; false for every durable route. */
57
- isEphemeralRegistration(registrationId: string): boolean;
58
- /**
59
- * Everything an ephemeral registration owns, taken out of `state`: the route
60
- * itself, every message that names it as source or target, the dedupe
61
- * fingerprints and rate bucket keyed by its alias, the journal rows —
62
- * message activity and runtime activity — that name the alias, and the
63
- * queued-bytes total those messages contributed. Pure: the caller decides
64
- * whether this becomes the written projection or the live state.
65
- */
66
- private ephemeralRowsRemoved;
67
- /**
68
- * The document actually written. While an ephemeral registration lives, its
69
- * rows are projected out here, so the written state stays internally
70
- * consistent under the strict loader — which refuses a state whose active
71
- * message points at a route it cannot find, or whose queued total disagrees
72
- * with its queued rows. Both refusals are exactly right, and neither must
73
- * ever be reachable by a document we wrote. When the registration is
74
- * removed, `removeRegistrationMetadata` takes the same rows out of the live
75
- * state in the same mutate, so nothing of it is written afterwards either.
76
- */
77
- private persistedProjection;
78
- removeOwnedRouteAtomic(input: Readonly<{
79
- alias: string;
80
- binding: LogicalRouteBinding;
81
- activity?: Readonly<{
82
- operatorAction: boolean;
83
- }>;
84
- }>): Promise<RemoveRouteAtomicResult>;
85
- replaceCodexRegistrationAtomic(input: ReplaceCodexRegistrationAtomicInput): Promise<ReplaceCodexRegistrationAtomicResult>;
86
- /**
87
- * Installs the route of a discovered Claude session on its first send, or
88
- * brings an existing route up to date with discovery. The (host, session
89
- * UUID) pair is the identity: a session already bound keeps its
90
- * registration (and its in-flight conversations) and is renamed if its
91
- * current name changed; a route whose alias now names a different session
92
- * is displaced, its work settled `cancelled/ENDPOINT_RETIRED`. Both
93
- * outcomes are journaled so `embassy status` can show them. Installation
94
- * never creates a permission: same-UID, same-host addressing already is
95
- * the permission, and the service's alias-collision fence has already run.
96
- */
97
- installClaudeRoute(replacement: RegisterRouteInput): Promise<InstallClaudeRouteResult>;
98
- /**
99
- * The refusal half of admission, without the write. A send to a Claude
100
- * session that has no route yet would otherwise install one — displacing
101
- * another session and settling its queued work — on its way to being
102
- * refused for its own reasons: too large, past the deadline window, rate
103
- * limited, or into a full queue. Callers that are about to materialize a
104
- * route run this first and materialize only if it returns.
105
- *
106
- * The refusal is still journaled, because a rejection is a fact about a real
107
- * attempt; nothing else is written, and the authoritative checks still run
108
- * inside `enqueueMessage` itself. `dedupeKey` is optional: a first send's key
109
- * is broker-generated and cannot collide, and omitting it keeps this from
110
- * inventing one to test against.
111
- */
112
- assertEnqueueAdmissible(input: Readonly<{
113
- sourceAlias: string;
114
- targetAlias: string;
115
- direction: MessageDirection;
116
- sourceRegistrationId: string;
117
- body: string;
118
- dedupeKey?: string;
119
- conversationIdSuffix?: string;
120
- deadlineAt?: string;
121
- steer?: true;
122
- }>): Promise<void>;
123
- enqueueMessage(input: EnqueueMessageInput): Promise<EnqueueMessageResult>;
124
- enqueueNativeIngress(input: EnqueueNativeIngressInput): Promise<EnqueueMessageResult>;
125
- inspectDispatchableTargets(): Promise<string[]>;
126
- nextDeadlineAt(): Promise<string | undefined>;
127
- deliveryStatus(token: string): Promise<GatewayMessageRecord | undefined>;
128
- reserveMessage(targetAlias?: string, mode?: "any" | "steer_only"): Promise<ReserveMessageResult>;
129
- authorizeMessage(input: AuthorizeMessageInput): Promise<AuthorizeMessageResult>;
130
- acceptMessage(input: AcceptMessageInput): Promise<AcceptMessageResult>;
131
- resolvePrewriteAttempt(input: ResolvePrewriteAttemptInput): Promise<ResolvePrewriteAttemptResult>;
132
- settleAttempt(input: SettleAttemptInput): Promise<SettleAttemptResult>;
133
- settleAttemptForShutdown(input: SettleAttemptForShutdownInput): Promise<SettleAttemptForShutdownResult>;
134
- settleQueuedMessageForShutdown(input: SettleQueuedMessageForShutdownInput): Promise<SettleQueuedMessageForShutdownResult>;
135
- expireDueMessages(now?: Date): Promise<TerminalMessageSettlement[]>;
136
- recordActivity(event: Omit<PublicGatewayActivityEvent, "sequence" | "timestamp">): Promise<PublicGatewayActivityEvent>;
137
- publicSnapshot(): Promise<GatewayPublicSnapshot>;
138
- private projectMessageEvent;
139
- private validateRouteInput;
140
- private requireRoute;
141
- private enqueueResolved;
142
- private allocateDeliveryToken;
143
- private consumeRate;
144
- private recordRejection;
145
- private finishMessage;
146
- private touchMessage;
147
- private appendRuntimeActivity;
148
- private terminalizeRegistration;
149
- private removeRegistrationMetadata;
150
- private renameRegistrationCoordinates;
151
- private recoverAfterRestart;
152
- private prune;
153
- private pruneRetainedBodies;
154
- private assertConfiguredBounds;
155
- private read;
156
- private mutate;
157
- private requireState;
158
- private prepareOwnedDirectory;
159
- /**
160
- * Boot-time litter sweep (emb-106): the static `gateway-dashboard*.html`
161
- * files 2.x published, any `.tmp` file its temp-file+rename publish could
162
- * have left behind mid-crash, and controller locks this store recovered as
163
- * stale more than seven days ago, are unlinked best-effort. Only a
164
- * regular file owned by this uid is removed (lstat, no symlink following);
165
- * nothing else in the state directory is touched, and a removal failure
166
- * never blocks startup. Runs only after the controller lock is held and
167
- * the state this boot will run on has passed both its schema check and
168
- * assertConfiguredBounds, so a refused boot leaves the directory exactly
169
- * as found.
170
- */
171
- private removeStateDirectoryLitter;
172
- private assertOwnedPrivate;
173
- private readPrivateFile;
174
- /**
175
- * Move a lock nobody owns aside instead of deleting it: a crash stays
176
- * diagnosable for a week (the boot sweep ages these out), and the caller
177
- * is told, because a silent recovery of another process's lock would be
178
- * the one event an operator most needs to see.
179
- */
180
- private recoverStaleLock;
181
- private acquireLock;
182
- releaseControllerLock(): Promise<void>;
183
- private loadStateFile;
184
- private persist;
185
- }