agent-embassy 2.0.1 → 3.1.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.
- package/CHANGELOG.md +77 -0
- package/CONTRIBUTING.md +23 -36
- package/README.md +123 -222
- package/SECURITY.md +72 -93
- package/dist/src/errors.d.ts +10 -1
- package/dist/src/errors.js +3 -1
- package/dist/src/errors.js.map +1 -1
- package/dist/src/gateway/claude-helper-protocol.d.ts +8 -11
- package/dist/src/gateway/claude-helper-protocol.js +12 -11
- package/dist/src/gateway/claude-helper-protocol.js.map +1 -1
- package/dist/src/gateway/claude-helper-supervisor.d.ts +1 -5
- package/dist/src/gateway/claude-helper-supervisor.js +45 -17
- package/dist/src/gateway/claude-helper-supervisor.js.map +1 -1
- package/dist/src/gateway/claude-helper.js +6 -6
- package/dist/src/gateway/claude-helper.js.map +1 -1
- package/dist/src/gateway/claude-peer.d.ts +0 -3
- package/dist/src/gateway/claude-peer.js +7 -19
- package/dist/src/gateway/claude-peer.js.map +1 -1
- package/dist/src/gateway/cli.d.ts +17 -7
- package/dist/src/gateway/cli.js +945 -265
- package/dist/src/gateway/cli.js.map +1 -1
- package/dist/src/gateway/codex-socket-holder.d.ts +26 -0
- package/dist/src/gateway/codex-socket-holder.js +76 -0
- package/dist/src/gateway/codex-socket-holder.js.map +1 -0
- package/dist/src/gateway/codex-stateless-transport.js +1 -1
- package/dist/src/gateway/codex-stateless-transport.js.map +1 -1
- package/dist/src/gateway/config.d.ts +1 -10
- package/dist/src/gateway/config.js +4 -10
- package/dist/src/gateway/config.js.map +1 -1
- package/dist/src/gateway/control.d.ts +66 -80
- package/dist/src/gateway/control.js +92 -147
- package/dist/src/gateway/control.js.map +1 -1
- package/dist/src/gateway/federation-nodes.d.ts +29 -2
- package/dist/src/gateway/federation-nodes.js +177 -7
- package/dist/src/gateway/federation-nodes.js.map +1 -1
- package/dist/src/gateway/peer-client.d.ts +4 -3
- package/dist/src/gateway/peer-client.js +22 -13
- package/dist/src/gateway/peer-client.js.map +1 -1
- package/dist/src/gateway/peer-protocol.d.ts +13 -11
- package/dist/src/gateway/peer-protocol.js +14 -12
- package/dist/src/gateway/peer-protocol.js.map +1 -1
- package/dist/src/gateway/provenance-envelope.d.ts +0 -1
- package/dist/src/gateway/provenance-envelope.js +4 -19
- package/dist/src/gateway/provenance-envelope.js.map +1 -1
- package/dist/src/gateway/providers.d.ts +11 -7
- package/dist/src/gateway/providers.js +49 -50
- package/dist/src/gateway/providers.js.map +1 -1
- package/dist/src/gateway/server.d.ts +4 -14
- package/dist/src/gateway/server.js +32 -54
- package/dist/src/gateway/server.js.map +1 -1
- package/dist/src/gateway/service-agent.d.ts +187 -0
- package/dist/src/gateway/service-agent.js +758 -0
- package/dist/src/gateway/service-agent.js.map +1 -0
- package/dist/src/gateway/service.d.ts +119 -38
- package/dist/src/gateway/service.js +754 -798
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/gateway/status-view.d.ts +119 -0
- package/dist/src/gateway/status-view.js +484 -0
- package/dist/src/gateway/status-view.js.map +1 -0
- package/dist/src/gateway/store.d.ts +106 -21
- package/dist/src/gateway/store.js +463 -537
- package/dist/src/gateway/store.js.map +1 -1
- package/dist/src/gateway/types.d.ts +64 -102
- package/dist/src/gateway/types.js +40 -86
- package/dist/src/gateway/types.js.map +1 -1
- package/docs/CONFIGURATION.md +174 -45
- package/docs/DELIVERY.md +11 -11
- package/docs/GATEWAY-ARCHITECTURE.md +292 -384
- package/package.json +4 -12
- package/skills/embassy-peer/SKILL.md +69 -92
- package/skills/embassy-peer/agents/openai.yaml +1 -1
- package/README.zh-CN.md +0 -275
- package/assets/live-dashboard/app.css +0 -1619
- package/assets/vendor/react/LICENSE +0 -21
- package/assets/vendor/react/react-dom.production.min.js +0 -267
- package/assets/vendor/react/react.production.min.js +0 -31
- package/dist/src/gateway/acp-client.d.ts +0 -110
- package/dist/src/gateway/acp-client.js +0 -407
- package/dist/src/gateway/acp-client.js.map +0 -1
- package/dist/src/gateway/acp-provider.d.ts +0 -66
- package/dist/src/gateway/acp-provider.js +0 -275
- package/dist/src/gateway/acp-provider.js.map +0 -1
- package/dist/src/gateway/claude-helper-client.d.ts +0 -2
- package/dist/src/gateway/claude-helper-client.js +0 -2
- package/dist/src/gateway/claude-helper-client.js.map +0 -1
- package/dist/src/gateway/cli-copy.d.ts +0 -8
- package/dist/src/gateway/cli-copy.en.d.ts +0 -22
- package/dist/src/gateway/cli-copy.en.js +0 -62
- package/dist/src/gateway/cli-copy.en.js.map +0 -1
- package/dist/src/gateway/cli-copy.js +0 -27
- package/dist/src/gateway/cli-copy.js.map +0 -1
- package/dist/src/gateway/cli-copy.zh-CN.d.ts +0 -22
- package/dist/src/gateway/cli-copy.zh-CN.js +0 -62
- package/dist/src/gateway/cli-copy.zh-CN.js.map +0 -1
- package/dist/src/gateway/codex-doctor.d.ts +0 -36
- package/dist/src/gateway/codex-doctor.js +0 -127
- package/dist/src/gateway/codex-doctor.js.map +0 -1
- package/dist/src/gateway/dashboard-copy.d.ts +0 -7
- package/dist/src/gateway/dashboard-copy.en.d.ts +0 -504
- package/dist/src/gateway/dashboard-copy.en.js +0 -505
- package/dist/src/gateway/dashboard-copy.en.js.map +0 -1
- package/dist/src/gateway/dashboard-copy.js +0 -514
- package/dist/src/gateway/dashboard-copy.js.map +0 -1
- package/dist/src/gateway/dashboard-copy.zh-CN.d.ts +0 -504
- package/dist/src/gateway/dashboard-copy.zh-CN.js +0 -505
- package/dist/src/gateway/dashboard-copy.zh-CN.js.map +0 -1
- package/dist/src/gateway/dashboard-model.d.ts +0 -343
- package/dist/src/gateway/dashboard-model.js +0 -1061
- package/dist/src/gateway/dashboard-model.js.map +0 -1
- package/dist/src/gateway/dashboard.d.ts +0 -20
- package/dist/src/gateway/dashboard.js +0 -874
- package/dist/src/gateway/dashboard.js.map +0 -1
- package/dist/src/gateway/deepseek-detect.d.ts +0 -14
- package/dist/src/gateway/deepseek-detect.js +0 -41
- package/dist/src/gateway/deepseek-detect.js.map +0 -1
- package/dist/src/gateway/live-dashboard-app/app.js +0 -2385
- package/dist/src/gateway/live-dashboard-assets.d.ts +0 -10
- package/dist/src/gateway/live-dashboard-assets.js +0 -74
- package/dist/src/gateway/live-dashboard-assets.js.map +0 -1
- package/dist/src/gateway/live-dashboard-command.d.ts +0 -60
- package/dist/src/gateway/live-dashboard-command.js +0 -334
- package/dist/src/gateway/live-dashboard-command.js.map +0 -1
- package/dist/src/gateway/live-dashboard-http.d.ts +0 -39
- package/dist/src/gateway/live-dashboard-http.js +0 -383
- package/dist/src/gateway/live-dashboard-http.js.map +0 -1
- package/dist/src/gateway/live-dashboard-protocol.d.ts +0 -34
- package/dist/src/gateway/live-dashboard-protocol.js +0 -114
- package/dist/src/gateway/live-dashboard-protocol.js.map +0 -1
- package/dist/src/gateway/live-dashboard-server.d.ts +0 -33
- package/dist/src/gateway/live-dashboard-server.js +0 -144
- package/dist/src/gateway/live-dashboard-server.js.map +0 -1
- package/dist/src/gateway/live-dashboard-stream.d.ts +0 -46
- package/dist/src/gateway/live-dashboard-stream.js +0 -234
- package/dist/src/gateway/live-dashboard-stream.js.map +0 -1
- package/dist/src/gateway/live-dashboard.d.ts +0 -28
- package/dist/src/gateway/live-dashboard.js +0 -154
- package/dist/src/gateway/live-dashboard.js.map +0 -1
- package/dist/src/gateway/locale.d.ts +0 -4
- package/dist/src/gateway/locale.js +0 -10
- package/dist/src/gateway/locale.js.map +0 -1
- package/dist/src/gateway/progress-watch-machine.d.ts +0 -45
- package/dist/src/gateway/progress-watch-machine.js +0 -70
- package/dist/src/gateway/progress-watch-machine.js.map +0 -1
- package/docs/CONFIGURATION.zh-CN.md +0 -97
- package/docs/DASHBOARD.md +0 -98
- package/docs/DASHBOARD.zh-CN.md +0 -49
- package/docs/DELIVERY.zh-CN.md +0 -55
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { GatewayConfig } from "./config.js";
|
|
2
2
|
import { type PeerCatalogResult, type PeerHandoffParams } from "./peer-protocol.js";
|
|
3
|
-
import type { AcceptMessageInput, AcceptMessageResult, AuthorizeMessageInput, AuthorizeMessageResult, EnqueueMessageInput, EnqueueMessageResult, EnqueueNativeIngressInput,
|
|
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";
|
|
4
6
|
export declare const GATEWAY_MAX_STATE_FILE_BYTES: number;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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;
|
|
10
15
|
export declare class GatewayStore {
|
|
11
16
|
readonly config: GatewayConfig;
|
|
12
17
|
rootDir: string;
|
|
@@ -18,7 +23,20 @@ export declare class GatewayStore {
|
|
|
18
23
|
private state;
|
|
19
24
|
private lockHandle;
|
|
20
25
|
private lockToken;
|
|
26
|
+
private readonly isProcessAlive;
|
|
27
|
+
private readonly hostname;
|
|
21
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;
|
|
22
40
|
constructor(config: GatewayConfig, dependencies?: GatewayStoreDependencies);
|
|
23
41
|
get stateFilePath(): string;
|
|
24
42
|
initialize(options?: Readonly<{
|
|
@@ -28,7 +46,6 @@ export declare class GatewayStore {
|
|
|
28
46
|
close(): Promise<void>;
|
|
29
47
|
inspectPrivateRoutes(): Promise<GatewayPrivateRouteInspection[]>;
|
|
30
48
|
listLogicalRoutes(): Promise<GatewayPrivateRouteInspection[]>;
|
|
31
|
-
inspectPrivateConsentEdges(): Promise<GatewayConsentEdgeRecord[]>;
|
|
32
49
|
inspectPrivateRoute(alias: string): Promise<GatewayPrivateRouteInspection | undefined>;
|
|
33
50
|
reconcilePeerCatalog(peerHost: string, catalog: PeerCatalogResult): Promise<Readonly<{
|
|
34
51
|
settlements: readonly TerminalMessageSettlement[];
|
|
@@ -36,26 +53,77 @@ export declare class GatewayStore {
|
|
|
36
53
|
}>>;
|
|
37
54
|
enqueuePeerHandoff(peerHost: string, handoff: PeerHandoffParams): Promise<EnqueueMessageResult>;
|
|
38
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;
|
|
39
79
|
removeOwnedRouteAtomic(input: Readonly<{
|
|
40
80
|
alias: string;
|
|
41
81
|
binding: LogicalRouteBinding;
|
|
42
82
|
activity?: Readonly<{
|
|
43
83
|
operatorAction: boolean;
|
|
84
|
+
action?: "route_retired";
|
|
44
85
|
}>;
|
|
45
86
|
}>): Promise<RemoveRouteAtomicResult>;
|
|
46
87
|
replaceCodexRegistrationAtomic(input: ReplaceCodexRegistrationAtomicInput): Promise<ReplaceCodexRegistrationAtomicResult>;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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>;
|
|
56
125
|
enqueueMessage(input: EnqueueMessageInput): Promise<EnqueueMessageResult>;
|
|
57
126
|
enqueueNativeIngress(input: EnqueueNativeIngressInput): Promise<EnqueueMessageResult>;
|
|
58
|
-
enqueueNativeReply(input: EnqueueNativeReplyInput): Promise<EnqueueMessageResult>;
|
|
59
127
|
inspectDispatchableTargets(): Promise<string[]>;
|
|
60
128
|
nextDeadlineAt(): Promise<string | undefined>;
|
|
61
129
|
deliveryStatus(token: string): Promise<GatewayMessageRecord | undefined>;
|
|
@@ -72,12 +140,10 @@ export declare class GatewayStore {
|
|
|
72
140
|
private projectMessageEvent;
|
|
73
141
|
private validateRouteInput;
|
|
74
142
|
private requireRoute;
|
|
75
|
-
private resolvePair;
|
|
76
|
-
private requireConsent;
|
|
77
143
|
private enqueueResolved;
|
|
78
|
-
private terminalizeConsentEdge;
|
|
79
144
|
private allocateDeliveryToken;
|
|
80
145
|
private consumeRate;
|
|
146
|
+
private rejectEnqueue;
|
|
81
147
|
private recordRejection;
|
|
82
148
|
private finishMessage;
|
|
83
149
|
private touchMessage;
|
|
@@ -93,11 +159,30 @@ export declare class GatewayStore {
|
|
|
93
159
|
private mutate;
|
|
94
160
|
private requireState;
|
|
95
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;
|
|
96
175
|
private assertOwnedPrivate;
|
|
97
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;
|
|
98
184
|
private acquireLock;
|
|
99
185
|
releaseControllerLock(): Promise<void>;
|
|
100
186
|
private loadStateFile;
|
|
101
187
|
private persist;
|
|
102
188
|
}
|
|
103
|
-
export {};
|