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
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
export declare const SERVICE_AGENT_LABEL = "com.agent-embassy.broker";
|
|
2
|
+
export type LaunchAgentPlistOptions = Readonly<{
|
|
3
|
+
label: string;
|
|
4
|
+
programArguments: readonly string[];
|
|
5
|
+
logPath: string;
|
|
6
|
+
/** Already-captured, already-validated agent environment (see captureAgentEnvironment). */
|
|
7
|
+
environment: Readonly<Record<string, string>>;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Render the launchd agent plist.
|
|
11
|
+
*
|
|
12
|
+
* `KeepAlive` is `{ Crashed: true }`, never plain `true`. Per launchd.plist(5)
|
|
13
|
+
* `Crashed` relaunches the job only when it died from a signal typically
|
|
14
|
+
* associated with a crash — SIGSEGV, SIGBUS, SIGILL, SIGABRT. Nothing else
|
|
15
|
+
* brings it back: not a clean exit, not a non-zero exit, not a plain `kill`
|
|
16
|
+
* (SIGTERM), and not one of the broker's deliberate boot refusals (an
|
|
17
|
+
* unsupported state schema, another instance already holding the lease).
|
|
18
|
+
* Under plain `KeepAlive` every one of those refusals would relaunch forever,
|
|
19
|
+
* throttled to once every 5 seconds, into one log file that nothing rotates.
|
|
20
|
+
* A refusal now exits once and stays down, where `embassy service status` and
|
|
21
|
+
* the log can explain it. ThrottleInterval still bounds a genuine crash loop.
|
|
22
|
+
*
|
|
23
|
+
* EnvironmentVariables carries exactly the captured configuration keys and
|
|
24
|
+
* nothing else — see captureAgentEnvironment for the rule. PATH is not
|
|
25
|
+
* needed (every child process this broker spawns — the codex standalone
|
|
26
|
+
* binary, /bin/ps, /usr/bin/lockf, /bin/cat — is invoked by an absolute path
|
|
27
|
+
* already; see codex-local-transport.ts, claude-peer.ts, and
|
|
28
|
+
* instance-lease.ts).
|
|
29
|
+
*/
|
|
30
|
+
export declare function renderLaunchAgentPlist(options: LaunchAgentPlistOptions): string;
|
|
31
|
+
export type RunLaunchctlResult = Readonly<{
|
|
32
|
+
code: number;
|
|
33
|
+
stdout: string;
|
|
34
|
+
stderr: string;
|
|
35
|
+
}>;
|
|
36
|
+
export type RunLaunchctl = (args: readonly string[]) => RunLaunchctlResult | Promise<RunLaunchctlResult>;
|
|
37
|
+
export type ServiceAgentDependencies = Readonly<{
|
|
38
|
+
homeDir: string;
|
|
39
|
+
runLaunchctl: RunLaunchctl;
|
|
40
|
+
env: NodeJS.ProcessEnv;
|
|
41
|
+
execPath: string;
|
|
42
|
+
cliPath: string;
|
|
43
|
+
uid: number;
|
|
44
|
+
/** Bounded waits for launchd to finish unloading; injected by tests. */
|
|
45
|
+
delay?: (milliseconds: number) => Promise<void>;
|
|
46
|
+
now?: () => number;
|
|
47
|
+
/**
|
|
48
|
+
* The host-lease probe. The default spawns /usr/bin/lockf through
|
|
49
|
+
* instance-lease.ts and so only answers on macOS; tests inject a fake.
|
|
50
|
+
*/
|
|
51
|
+
probeHostLease?: ProbeHostLease;
|
|
52
|
+
}>;
|
|
53
|
+
export type ServiceAgentPaths = Readonly<{
|
|
54
|
+
launchAgentsDir: string;
|
|
55
|
+
logsDir: string;
|
|
56
|
+
plistPath: string;
|
|
57
|
+
logPath: string;
|
|
58
|
+
}>;
|
|
59
|
+
export declare function serviceAgentPaths(homeDir: string): ServiceAgentPaths;
|
|
60
|
+
/**
|
|
61
|
+
* stderr only, trimmed, and capped — never launchctl's stdout. Everything the
|
|
62
|
+
* service path puts on the CLI's stderr goes through this, including the
|
|
63
|
+
* errno text of a filesystem failure the CLI itself renders.
|
|
64
|
+
*/
|
|
65
|
+
export declare function boundedServiceDetail(text: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* The environment the installed agent runs with. launchd agents inherit
|
|
68
|
+
* almost nothing, so Embassy's own configuration has to be copied into the
|
|
69
|
+
* plist: every `EMBASSY_*` variable (EMBASSY_STATE_DIR included) plus
|
|
70
|
+
* XDG_STATE_HOME, which decides the state root when EMBASSY_STATE_DIR is
|
|
71
|
+
* unset. These are configuration, not secrets — but nothing else is copied,
|
|
72
|
+
* so an inherited API key or token cannot reach the plist.
|
|
73
|
+
*
|
|
74
|
+
* Both state roots must be absolute here, before capture: a relative value
|
|
75
|
+
* resolves against the installing shell's working directory, and the agent
|
|
76
|
+
* would silently resolve it somewhere else.
|
|
77
|
+
*/
|
|
78
|
+
export declare function captureAgentEnvironment(env: NodeJS.ProcessEnv): Readonly<Record<string, string>>;
|
|
79
|
+
/**
|
|
80
|
+
* Read the lease holder's pid under the same discipline instance-lease.ts
|
|
81
|
+
* applies in readPrivateFile: lstat first, regular file only, this user's
|
|
82
|
+
* own, size-bounded, opened O_NOFOLLOW and re-verified against the same
|
|
83
|
+
* inode. This value only decorates a refusal message, but it is read out of
|
|
84
|
+
* a file another process writes, so it gets the same care.
|
|
85
|
+
*/
|
|
86
|
+
/**
|
|
87
|
+
* Read a small private record this user owns, or nothing at all. Never
|
|
88
|
+
* throws, and never follows anything: the path is lstat'd, refused unless it
|
|
89
|
+
* is a regular file this uid owns within the byte bound, opened O_NOFOLLOW,
|
|
90
|
+
* and re-verified through the open handle by (dev, ino, uid, size) so the
|
|
91
|
+
* file that was checked is the file that was read. A uid of `undefined` — a
|
|
92
|
+
* platform with no `getuid` — skips only the ownership half.
|
|
93
|
+
*
|
|
94
|
+
* Both readers of a private record go through here: the host lease's pid
|
|
95
|
+
* below, and `readGatewayControllerPid` in cli.ts.
|
|
96
|
+
*/
|
|
97
|
+
export declare function readOwnedSmallFile(filePath: string, uid: number | undefined, maximumBytes: number): Promise<string | undefined>;
|
|
98
|
+
/** The pid recorded in a JSON record, or nothing when it names none. */
|
|
99
|
+
export declare function recordedPid(raw: string | undefined): number | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* What the host-wide lease says right now. `pid` is present only when a
|
|
102
|
+
* *live* holder was identified; `message` is the lease's own words for why it
|
|
103
|
+
* could not be taken.
|
|
104
|
+
*/
|
|
105
|
+
export type HostLeaseProbe = Readonly<{
|
|
106
|
+
held: false;
|
|
107
|
+
}> | Readonly<{
|
|
108
|
+
held: true;
|
|
109
|
+
pid?: number;
|
|
110
|
+
message: string;
|
|
111
|
+
}>;
|
|
112
|
+
export type ProbeHostLease = (homeDir: string, uid: number) => Promise<HostLeaseProbe>;
|
|
113
|
+
/**
|
|
114
|
+
* The production probe, and the reason this is an injected dependency at all.
|
|
115
|
+
* It reuses the exact detection the broker relies on for single-instance
|
|
116
|
+
* correctness — a non-blocking acquire of the host-wide advisory lease
|
|
117
|
+
* (acquireGatewayInstanceLease, unmodified), released immediately when nobody
|
|
118
|
+
* holds it. That helper spawns /usr/bin/lockf, which exists only on macOS, so
|
|
119
|
+
* on any other platform it reports contention that is really a missing
|
|
120
|
+
* binary. The product is macOS-only and that is correct in production, but it
|
|
121
|
+
* makes every install path untestable off darwin; tests inject a fake probe
|
|
122
|
+
* and one darwin-only test drives this default.
|
|
123
|
+
*
|
|
124
|
+
* `GATEWAY_INSTANCE_IN_USE` is not only contention: instance-lease.ts throws
|
|
125
|
+
* it for roughly ten conditions that have nothing to do with another broker
|
|
126
|
+
* (a symlinked path component, a non-empty unmarked lease root, a mode or
|
|
127
|
+
* owner drift). So its message is always carried out of here unchanged, and a
|
|
128
|
+
* pid is reported only when the recorded holder is genuinely alive — the lock
|
|
129
|
+
* record keeps the *last* holder, and a successful probe writes its own pid
|
|
130
|
+
* there, so an unchecked pid is routinely stale. Never tell someone to stop
|
|
131
|
+
* a dead process.
|
|
132
|
+
*/
|
|
133
|
+
export declare function defaultProbeHostLease(homeDir: string, uid: number): Promise<HostLeaseProbe>;
|
|
134
|
+
export type ServiceAgentInstallResult = Readonly<{
|
|
135
|
+
label: string;
|
|
136
|
+
plistPath: string;
|
|
137
|
+
logPath: string;
|
|
138
|
+
/** Names only: the configuration keys copied into the plist at install time. */
|
|
139
|
+
capturedEnv: readonly string[];
|
|
140
|
+
}>;
|
|
141
|
+
/**
|
|
142
|
+
* Register the broker as this user's launchd agent. Re-running it over a
|
|
143
|
+
* prior install — including one that is loaded and running right now — is
|
|
144
|
+
* the supported way to change what the agent runs with.
|
|
145
|
+
*/
|
|
146
|
+
export declare function installServiceAgent(deps: ServiceAgentDependencies): Promise<ServiceAgentInstallResult>;
|
|
147
|
+
export type ServiceAgentUninstallResult = Readonly<{
|
|
148
|
+
label: string;
|
|
149
|
+
plistPath: string;
|
|
150
|
+
logPath: string;
|
|
151
|
+
}>;
|
|
152
|
+
/**
|
|
153
|
+
* Boot the agent out, confirm that launchctl reports the label as *not
|
|
154
|
+
* found*, and only then unlink the plist. The confirmation must be that exact
|
|
155
|
+
* answer: treating any launchctl error (a missing binary, a gui domain that
|
|
156
|
+
* is not up, a timeout) as "gone" would unlink the plist while the agent is
|
|
157
|
+
* still loaded — invisible to `install`, unstoppable by `uninstall`. Logs are
|
|
158
|
+
* left in place.
|
|
159
|
+
*/
|
|
160
|
+
export declare function uninstallServiceAgent(deps: ServiceAgentDependencies): Promise<ServiceAgentUninstallResult>;
|
|
161
|
+
export type ServiceAgentStatusState = "loaded" | "not loaded" | "unknown";
|
|
162
|
+
export type ServiceAgentStatus = Readonly<{
|
|
163
|
+
label: string;
|
|
164
|
+
plistPath: string;
|
|
165
|
+
logPath: string;
|
|
166
|
+
plistExists: boolean;
|
|
167
|
+
state: ServiceAgentStatusState;
|
|
168
|
+
pid?: number;
|
|
169
|
+
launchdState?: string;
|
|
170
|
+
lastExitStatus?: number;
|
|
171
|
+
/** ProgramArguments[0]/[1] that are no longer on disk (a version manager moved node). */
|
|
172
|
+
programMissing?: readonly string[];
|
|
173
|
+
/** launchctl's stderr, trimmed and capped at 512 bytes; its stdout is never quoted. */
|
|
174
|
+
launchctlStderr?: string;
|
|
175
|
+
note: string;
|
|
176
|
+
}>;
|
|
177
|
+
/**
|
|
178
|
+
* Report what is actually knowable. A launchctl that cannot run, or output
|
|
179
|
+
* this version does not recognize, is `unknown` with the reason quoted — not
|
|
180
|
+
* "not loaded", and not "loaded" with blank fields. The plist's own
|
|
181
|
+
* ProgramArguments are checked against the filesystem too: a node binary
|
|
182
|
+
* under a version manager can be removed out from under an installed agent,
|
|
183
|
+
* which launchd otherwise reports only as a repeated spawn failure.
|
|
184
|
+
*/
|
|
185
|
+
export declare function serviceAgentStatus(deps: ServiceAgentDependencies): Promise<ServiceAgentStatus>;
|
|
186
|
+
/** The one production launchctl call site; every other reference to it in this module is through this runner. */
|
|
187
|
+
export declare function defaultRunLaunchctl(args: readonly string[]): Promise<RunLaunchctlResult>;
|