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,188 +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. Attributable rows and bodies are removed;
76
- * aggregate counters may remain advanced.
77
- */
78
- private persistedProjection;
79
- removeOwnedRouteAtomic(input: Readonly<{
80
- alias: string;
81
- binding: LogicalRouteBinding;
82
- activity?: Readonly<{
83
- operatorAction: boolean;
84
- action?: "route_retired";
85
- }>;
86
- }>): Promise<RemoveRouteAtomicResult>;
87
- replaceCodexRegistrationAtomic(input: ReplaceCodexRegistrationAtomicInput): Promise<ReplaceCodexRegistrationAtomicResult>;
88
- /**
89
- * Installs the route of a discovered Claude session on its first send, or
90
- * brings an existing route up to date with discovery. The (host, session
91
- * UUID) pair is the identity: a session already bound keeps its
92
- * registration (and its in-flight conversations) and is renamed if its
93
- * current name changed; a route whose alias now names a different session
94
- * is displaced, its work settled `cancelled/ENDPOINT_RETIRED`. Both
95
- * outcomes are journaled so `embassy status` can show them. Installation
96
- * never creates a permission: same-UID, same-host addressing already is
97
- * the permission, and the service's alias-collision fence has already run.
98
- */
99
- installClaudeRoute(replacement: RegisterRouteInput): Promise<InstallClaudeRouteResult>;
100
- /**
101
- * The refusal half of admission, without the write. A send to a Claude
102
- * session that has no route yet would otherwise install one — displacing
103
- * another session and settling its queued work — on its way to being
104
- * refused for its own reasons: too large, past the deadline window, rate
105
- * limited, or into a full queue. Callers that are about to materialize a
106
- * route run this first and materialize only if it returns.
107
- *
108
- * The refusal is still journaled, because a rejection is a fact about a real
109
- * attempt; nothing else is written, and the authoritative checks still run
110
- * inside `enqueueMessage` itself. `dedupeKey` is optional: a first send's key
111
- * is broker-generated and cannot collide, and omitting it keeps this from
112
- * inventing one to test against.
113
- */
114
- assertEnqueueAdmissible(input: Readonly<{
115
- sourceAlias: string;
116
- targetAlias: string;
117
- direction: MessageDirection;
118
- sourceRegistrationId: string;
119
- body: string;
120
- dedupeKey?: string;
121
- conversationIdSuffix?: string;
122
- deadlineAt?: string;
123
- steer?: true;
124
- }>): Promise<void>;
125
- enqueueMessage(input: EnqueueMessageInput): Promise<EnqueueMessageResult>;
126
- enqueueNativeIngress(input: EnqueueNativeIngressInput): Promise<EnqueueMessageResult>;
127
- inspectDispatchableTargets(): Promise<string[]>;
128
- nextDeadlineAt(): Promise<string | undefined>;
129
- deliveryStatus(token: string): Promise<GatewayMessageRecord | undefined>;
130
- reserveMessage(targetAlias?: string, mode?: "any" | "steer_only"): Promise<ReserveMessageResult>;
131
- authorizeMessage(input: AuthorizeMessageInput): Promise<AuthorizeMessageResult>;
132
- acceptMessage(input: AcceptMessageInput): Promise<AcceptMessageResult>;
133
- resolvePrewriteAttempt(input: ResolvePrewriteAttemptInput): Promise<ResolvePrewriteAttemptResult>;
134
- settleAttempt(input: SettleAttemptInput): Promise<SettleAttemptResult>;
135
- settleAttemptForShutdown(input: SettleAttemptForShutdownInput): Promise<SettleAttemptForShutdownResult>;
136
- settleQueuedMessageForShutdown(input: SettleQueuedMessageForShutdownInput): Promise<SettleQueuedMessageForShutdownResult>;
137
- expireDueMessages(now?: Date): Promise<TerminalMessageSettlement[]>;
138
- recordActivity(event: Omit<PublicGatewayActivityEvent, "sequence" | "timestamp">): Promise<PublicGatewayActivityEvent>;
139
- publicSnapshot(): Promise<GatewayPublicSnapshot>;
140
- private projectMessageEvent;
141
- private validateRouteInput;
142
- private requireRoute;
143
- private enqueueResolved;
144
- private allocateDeliveryToken;
145
- private consumeRate;
146
- private rejectEnqueue;
147
- private recordRejection;
148
- private finishMessage;
149
- private touchMessage;
150
- private appendRuntimeActivity;
151
- private terminalizeRegistration;
152
- private removeRegistrationMetadata;
153
- private renameRegistrationCoordinates;
154
- private recoverAfterRestart;
155
- private prune;
156
- private pruneRetainedBodies;
157
- private assertConfiguredBounds;
158
- private read;
159
- private mutate;
160
- private requireState;
161
- private prepareOwnedDirectory;
162
- /**
163
- * Boot-time litter sweep (emb-106): the static `gateway-dashboard*.html`
164
- * files 2.x published, any `.tmp` file its temp-file+rename publish could
165
- * have left behind mid-crash, and controller locks this store recovered as
166
- * stale more than seven days ago, are unlinked best-effort. Only a
167
- * regular file owned by this uid is removed (lstat, no symlink following);
168
- * nothing else in the state directory is touched, and a removal failure
169
- * never blocks startup. Runs only after the controller lock is held and
170
- * the state this boot will run on has passed both its schema check and
171
- * assertConfiguredBounds, so a refused boot leaves the directory exactly
172
- * as found.
173
- */
174
- private removeStateDirectoryLitter;
175
- private assertOwnedPrivate;
176
- private readPrivateFile;
177
- /**
178
- * Move a lock nobody owns aside instead of deleting it: a crash stays
179
- * diagnosable for a week (the boot sweep ages these out), and the caller
180
- * is told, because a silent recovery of another process's lock would be
181
- * the one event an operator most needs to see.
182
- */
183
- private recoverStaleLock;
184
- private acquireLock;
185
- releaseControllerLock(): Promise<void>;
186
- private loadStateFile;
187
- private persist;
188
- }