@relaymessenger/cli 0.4.4 → 0.5.0-staging.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 (91) hide show
  1. package/README.md +108 -118
  2. package/dist/cli.js +2 -172
  3. package/dist/cli.js.map +1 -1
  4. package/dist/client.d.ts +8 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/client.js +13 -0
  7. package/dist/client.js.map +1 -0
  8. package/dist/config.d.ts +39 -0
  9. package/dist/config.d.ts.map +1 -0
  10. package/dist/config.js +206 -0
  11. package/dist/config.js.map +1 -0
  12. package/dist/doctor.d.ts +20 -1
  13. package/dist/doctor.d.ts.map +1 -1
  14. package/dist/doctor.js +73 -112
  15. package/dist/doctor.js.map +1 -1
  16. package/dist/event-listen.d.ts +11 -0
  17. package/dist/event-listen.d.ts.map +1 -0
  18. package/dist/event-listen.js +37 -0
  19. package/dist/event-listen.js.map +1 -0
  20. package/dist/output.d.ts +4 -0
  21. package/dist/output.d.ts.map +1 -0
  22. package/dist/output.js +26 -0
  23. package/dist/output.js.map +1 -0
  24. package/dist/program.d.ts +14 -0
  25. package/dist/program.d.ts.map +1 -0
  26. package/dist/program.js +655 -0
  27. package/dist/program.js.map +1 -0
  28. package/package.json +31 -37
  29. package/claude-plugin/marketplace/.claude-plugin/marketplace.json +0 -14
  30. package/claude-plugin/marketplace/plugins/relay/.claude-plugin/plugin.json +0 -27
  31. package/claude-plugin/marketplace/plugins/relay/LICENSE +0 -21
  32. package/claude-plugin/marketplace/plugins/relay/README.md +0 -173
  33. package/claude-plugin/marketplace/plugins/relay/commands/configure.md +0 -71
  34. package/claude-plugin/marketplace/plugins/relay/runtime/server.mjs +0 -26197
  35. package/dist/api.d.ts +0 -114
  36. package/dist/api.d.ts.map +0 -1
  37. package/dist/api.js +0 -162
  38. package/dist/api.js.map +0 -1
  39. package/dist/claude-settings.d.ts +0 -14
  40. package/dist/claude-settings.d.ts.map +0 -1
  41. package/dist/claude-settings.js +0 -47
  42. package/dist/claude-settings.js.map +0 -1
  43. package/dist/codex.d.ts +0 -25
  44. package/dist/codex.d.ts.map +0 -1
  45. package/dist/codex.js +0 -237
  46. package/dist/codex.js.map +0 -1
  47. package/dist/engine/acp.d.ts +0 -74
  48. package/dist/engine/acp.d.ts.map +0 -1
  49. package/dist/engine/acp.js +0 -413
  50. package/dist/engine/acp.js.map +0 -1
  51. package/dist/engine/catalog.d.ts +0 -26
  52. package/dist/engine/catalog.d.ts.map +0 -1
  53. package/dist/engine/catalog.js +0 -41
  54. package/dist/engine/catalog.js.map +0 -1
  55. package/dist/engine/process.d.ts +0 -12
  56. package/dist/engine/process.d.ts.map +0 -1
  57. package/dist/engine/process.js +0 -54
  58. package/dist/engine/process.js.map +0 -1
  59. package/dist/engine/types.d.ts +0 -57
  60. package/dist/engine/types.d.ts.map +0 -1
  61. package/dist/engine/types.js +0 -8
  62. package/dist/engine/types.js.map +0 -1
  63. package/dist/flags.d.ts +0 -9
  64. package/dist/flags.d.ts.map +0 -1
  65. package/dist/flags.js +0 -34
  66. package/dist/flags.js.map +0 -1
  67. package/dist/install.d.ts +0 -69
  68. package/dist/install.d.ts.map +0 -1
  69. package/dist/install.js +0 -513
  70. package/dist/install.js.map +0 -1
  71. package/dist/mcp.d.ts +0 -16
  72. package/dist/mcp.d.ts.map +0 -1
  73. package/dist/mcp.js +0 -127
  74. package/dist/mcp.js.map +0 -1
  75. package/dist/pair.d.ts +0 -20
  76. package/dist/pair.d.ts.map +0 -1
  77. package/dist/pair.js +0 -135
  78. package/dist/pair.js.map +0 -1
  79. package/dist/permissions.d.ts +0 -90
  80. package/dist/permissions.d.ts.map +0 -1
  81. package/dist/permissions.js +0 -361
  82. package/dist/permissions.js.map +0 -1
  83. package/dist/receive.d.ts +0 -113
  84. package/dist/receive.d.ts.map +0 -1
  85. package/dist/receive.js +0 -596
  86. package/dist/receive.js.map +0 -1
  87. package/dist/store.d.ts +0 -301
  88. package/dist/store.d.ts.map +0 -1
  89. package/dist/store.js +0 -551
  90. package/dist/store.js.map +0 -1
  91. package/openclaw-plugin/relaymessenger-openclaw-plugin-0.3.3.tgz +0 -0
@@ -1,74 +0,0 @@
1
- import { type RequestPermissionRequest, type ToolCallUpdate } from "@agentclientprotocol/sdk";
2
- import type { EngineAdapter, SessionRef, TurnCallbacks, TurnResult } from "./types.js";
3
- import type { SessionStore } from "../store.js";
4
- import { type EngineName } from "./catalog.js";
5
- export declare const ADAPTER_PACKAGES: Record<string, string>;
6
- /**
7
- * Adapter versions are read from the manifest rather than restated here, so a
8
- * dependency bump cannot leave the runtime reporting a version it is not
9
- * running. The pins must stay exact; a range would let npm resolve an adapter
10
- * the lockfile never vetted.
11
- */
12
- export declare const ADAPTER_VERSIONS: Record<string, string>;
13
- /** Resolve the installed, lockfile-pinned executable without invoking npm. */
14
- export declare function adapterEntrypoint(engine: "claude" | "codex"): string;
15
- export interface EngineProcessSpec {
16
- command: string;
17
- args: string[];
18
- display: string;
19
- }
20
- /** Shell-free, deterministic process descriptor for one ACP runtime. */
21
- export declare function engineProcessSpec(engine: EngineName): EngineProcessSpec;
22
- export declare function engineEnv(parent?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
23
- /**
24
- * Accumulates one turn's streamed assistant text. Chunks stream into the
25
- * current message segment; a tool-call boundary ends the segment, so the next
26
- * chunk starts a distinct message. Distinct segments join with a blank line —
27
- * a plain "" join would fuse back-to-back messages into one word
28
- * ("…the file." + "Created…" → "file.Created").
29
- */
30
- export declare class AgentTextBuffer {
31
- private readonly segments;
32
- private open;
33
- append(chunk: string): void;
34
- /** Mark a message boundary: the next appended chunk starts a new segment. */
35
- endSegment(): void;
36
- /** Segments trimmed (no doubled blank lines), empty segments dropped. */
37
- toString(): string;
38
- }
39
- /** Merge a sparse ACP tool-call update without erasing previously known fields. */
40
- export declare function mergeToolCall(previous: ToolCallUpdate | undefined, incoming: ToolCallUpdate): ToolCallUpdate;
41
- /**
42
- * Flatten the security-relevant parts of an ACP tool call — raw input,
43
- * affected locations, content — into one preview string for the approval
44
- * card. Length is clamped downstream (head + tail) by the card builder.
45
- */
46
- export declare function permissionDetail(toolCall: RequestPermissionRequest["toolCall"]): string | undefined;
47
- /** True only when the phone can display the full operation being approved. */
48
- export declare function permissionInputComplete(toolCall: RequestPermissionRequest["toolCall"]): boolean;
49
- export declare class AcpEngine implements EngineAdapter {
50
- readonly engine: EngineName;
51
- private readonly sessions;
52
- private readonly log;
53
- private child;
54
- private connection;
55
- private ctx;
56
- private initialization;
57
- private loadSessionSupported;
58
- /** Live turn state keyed by ACP session id. */
59
- private readonly turns;
60
- /** conversation_id → ACP session + repository for the live process. */
61
- private readonly liveSessions;
62
- private permissionSeq;
63
- constructor(engine: EngineName, sessions: SessionStore, log?: (line: string) => void);
64
- private ensureConnected;
65
- private connect;
66
- private resetConnection;
67
- private handleUpdate;
68
- private handlePermission;
69
- private openSession;
70
- startTurn(ref: SessionRef, promptText: string, callbacks: TurnCallbacks): Promise<TurnResult>;
71
- abort(ref: SessionRef): Promise<void>;
72
- dispose(): Promise<void>;
73
- }
74
- //# sourceMappingURL=acp.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acp.d.ts","sourceRoot":"","sources":["../../src/engine/acp.ts"],"names":[],"mappings":"AAiBA,OAAO,EAML,KAAK,wBAAwB,EAG7B,KAAK,cAAc,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,aAAa,EAEb,UAAU,EACV,aAAa,EACb,UAAU,EACX,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGnD,CAAC;AAOF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAanD,CAAC;A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;IACvC,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,oBAAoB,CAAS;IACrC,+CAA+C;IAC/C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgC;IACtD,uEAAuE;IACvE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAyD;IACtF,OAAO,CAAC,aAAa,CAAK;IAE1B,YACW,MAAM,EAAE,UAAU,EACV,QAAQ,EAAE,YAAY,EACtB,GAAG,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAe,EACrD;YAEU,eAAe;YAcf,OAAO;IAkDrB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,YAAY;YAsBN,gBAAgB;YAmChB,WAAW;IAmCnB,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CAgBlG;IAEK,KAAK,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAI1C;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAK7B;CACF"}
@@ -1,413 +0,0 @@
1
- import { createRequire } from "node:module";
2
- import { Readable, Writable } from "node:stream";
3
- import crossSpawn from "cross-spawn";
4
- import { client, ndJsonStream, PROTOCOL_VERSION, } from "@agentclientprotocol/sdk";
5
- import { terminateProcessTree } from "./process.js";
6
- import { EXTERNAL_ENGINE_SPECS, engineDisplayName, } from "./catalog.js";
7
- export const ADAPTER_PACKAGES = {
8
- claude: "@agentclientprotocol/claude-agent-acp",
9
- codex: "@agentclientprotocol/codex-acp",
10
- };
11
- const require = createRequire(import.meta.url);
12
- /** An exact pin: a bare semver with no range operator. */
13
- const EXACT_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
14
- /**
15
- * Adapter versions are read from the manifest rather than restated here, so a
16
- * dependency bump cannot leave the runtime reporting a version it is not
17
- * running. The pins must stay exact; a range would let npm resolve an adapter
18
- * the lockfile never vetted.
19
- */
20
- export const ADAPTER_VERSIONS = Object.fromEntries(Object.entries(ADAPTER_PACKAGES).map(([engine, adapterPackage]) => {
21
- const manifest = require("../../package.json");
22
- const pinned = manifest.dependencies[adapterPackage];
23
- if (!pinned || !EXACT_VERSION.test(pinned)) {
24
- throw new Error(`${adapterPackage} must be pinned to an exact version, found ${pinned ?? "no dependency"}`);
25
- }
26
- return [engine, pinned];
27
- }));
28
- /** Resolve the installed, lockfile-pinned executable without invoking npm. */
29
- export function adapterEntrypoint(engine) {
30
- if (engine === "claude") {
31
- return require.resolve("@agentclientprotocol/claude-agent-acp/dist/index.js");
32
- }
33
- return require.resolve("@agentclientprotocol/codex-acp");
34
- }
35
- /** Shell-free, deterministic process descriptor for one ACP runtime. */
36
- export function engineProcessSpec(engine) {
37
- if (engine === "claude" || engine === "codex") {
38
- return {
39
- command: process.execPath,
40
- args: [adapterEntrypoint(engine)],
41
- display: `${ADAPTER_PACKAGES[engine]}@${ADAPTER_VERSIONS[engine]}`,
42
- };
43
- }
44
- const spec = EXTERNAL_ENGINE_SPECS[engine];
45
- return {
46
- command: spec.command,
47
- args: [...spec.args],
48
- display: `${spec.displayName} (${spec.command} ${spec.args.join(" ")})`,
49
- };
50
- }
51
- /**
52
- * Minimized environment for the adapter subprocess. The full parent env can
53
- * carry unrelated cloud/deploy/CI secrets; the adapter (and the agent it
54
- * execs) only needs the platform basics plus its own provider credentials.
55
- * Extend with RELAYMESSENGER_ENGINE_ENV="VAR1,VAR2,MYPREFIX_*". Deliberately no
56
- * "inherit" escape hatch exists: unrelated deploy and cloud credentials must
57
- * never be handed wholesale to a coding-agent subprocess.
58
- */
59
- const ENGINE_ENV_EXACT = new Set([
60
- "PATH",
61
- "HOME",
62
- "USER",
63
- "LOGNAME",
64
- "SHELL",
65
- "TMPDIR",
66
- "TMP",
67
- "TEMP",
68
- "LANG",
69
- "TZ",
70
- "TERM",
71
- "COLORTERM",
72
- "HTTP_PROXY",
73
- "HTTPS_PROXY",
74
- "NO_PROXY",
75
- "http_proxy",
76
- "https_proxy",
77
- "no_proxy",
78
- // Windows process basics.
79
- "SYSTEMROOT",
80
- "SYSTEMDRIVE",
81
- "COMSPEC",
82
- "PATHEXT",
83
- "APPDATA",
84
- "LOCALAPPDATA",
85
- "USERPROFILE",
86
- "HOMEDRIVE",
87
- "HOMEPATH",
88
- "USERNAME",
89
- "PROGRAMFILES",
90
- "PROGRAMDATA",
91
- "OS",
92
- "WINDIR",
93
- ]);
94
- const ENGINE_ENV_PREFIXES = [
95
- "LC_",
96
- "XDG_",
97
- // Engine/provider credentials and settings for supported local runtimes.
98
- "ANTHROPIC_",
99
- "CLAUDE_",
100
- "OPENAI_",
101
- "CODEX_",
102
- "HERMES_",
103
- ];
104
- export function engineEnv(parent = process.env) {
105
- const extra = (parent.RELAYMESSENGER_ENGINE_ENV ?? "").trim();
106
- const extraExact = new Set();
107
- const extraPrefixes = [];
108
- for (const raw of extra.split(",")) {
109
- const entry = raw.trim();
110
- if (entry.length === 0)
111
- continue;
112
- if (entry.endsWith("*"))
113
- extraPrefixes.push(entry.slice(0, -1));
114
- else
115
- extraExact.add(entry);
116
- }
117
- const allowed = (key) => {
118
- if (ENGINE_ENV_EXACT.has(key) || ENGINE_ENV_EXACT.has(key.toUpperCase()))
119
- return true;
120
- if (extraExact.has(key))
121
- return true;
122
- return [...ENGINE_ENV_PREFIXES, ...extraPrefixes].some((prefix) => key.startsWith(prefix));
123
- };
124
- const env = {};
125
- for (const [key, value] of Object.entries(parent)) {
126
- if (value !== undefined && allowed(key))
127
- env[key] = value;
128
- }
129
- return env;
130
- }
131
- /**
132
- * Accumulates one turn's streamed assistant text. Chunks stream into the
133
- * current message segment; a tool-call boundary ends the segment, so the next
134
- * chunk starts a distinct message. Distinct segments join with a blank line —
135
- * a plain "" join would fuse back-to-back messages into one word
136
- * ("…the file." + "Created…" → "file.Created").
137
- */
138
- export class AgentTextBuffer {
139
- segments = [];
140
- open = false;
141
- append(chunk) {
142
- if (!this.open) {
143
- this.segments.push("");
144
- this.open = true;
145
- }
146
- this.segments[this.segments.length - 1] += chunk;
147
- }
148
- /** Mark a message boundary: the next appended chunk starts a new segment. */
149
- endSegment() {
150
- this.open = false;
151
- }
152
- /** Segments trimmed (no doubled blank lines), empty segments dropped. */
153
- toString() {
154
- return this.segments
155
- .map((segment) => segment.trim())
156
- .filter((segment) => segment.length > 0)
157
- .join("\n\n");
158
- }
159
- }
160
- /** Merge a sparse ACP tool-call update without erasing previously known fields. */
161
- export function mergeToolCall(previous, incoming) {
162
- const merged = { ...(previous ?? {}) };
163
- for (const [key, value] of Object.entries(incoming)) {
164
- if (value !== undefined)
165
- merged[key] = value;
166
- }
167
- merged.toolCallId = incoming.toolCallId;
168
- return merged;
169
- }
170
- /**
171
- * Flatten the security-relevant parts of an ACP tool call — raw input,
172
- * affected locations, content — into one preview string for the approval
173
- * card. Length is clamped downstream (head + tail) by the card builder.
174
- */
175
- export function permissionDetail(toolCall) {
176
- const parts = [];
177
- if (toolCall.rawInput !== undefined && toolCall.rawInput !== null) {
178
- try {
179
- parts.push(JSON.stringify(toolCall.rawInput));
180
- }
181
- catch {
182
- parts.push(String(toolCall.rawInput));
183
- }
184
- }
185
- if (Array.isArray(toolCall.locations) && toolCall.locations.length > 0) {
186
- parts.push(`paths: ${toolCall.locations.map((location) => location.path).join(", ")}`);
187
- }
188
- for (const content of toolCall.content ?? []) {
189
- if (content.type === "content" && content.content.type === "text") {
190
- parts.push(content.content.text);
191
- }
192
- else if (content.type === "diff") {
193
- parts.push([
194
- `diff ${content.path}`,
195
- "--- before",
196
- content.oldText ?? "(new file)",
197
- "+++ after",
198
- content.newText,
199
- ].join("\n"));
200
- }
201
- else if (content.type === "terminal") {
202
- parts.push(`terminal ${content.terminalId}`);
203
- }
204
- }
205
- const joined = parts.filter((part) => part && part.length > 0).join("\n");
206
- return joined.length > 0 ? joined : undefined;
207
- }
208
- /** True only when the phone can display the full operation being approved. */
209
- export function permissionInputComplete(toolCall) {
210
- if (toolCall.rawInput !== undefined && toolCall.rawInput !== null)
211
- return true;
212
- return (toolCall.content ?? []).some((content) => content.type === "diff" &&
213
- typeof content.path === "string" &&
214
- typeof content.newText === "string");
215
- }
216
- export class AcpEngine {
217
- engine;
218
- sessions;
219
- log;
220
- child;
221
- connection;
222
- ctx;
223
- initialization;
224
- loadSessionSupported = false;
225
- /** Live turn state keyed by ACP session id. */
226
- turns = new Map();
227
- /** conversation_id → ACP session + repository for the live process. */
228
- liveSessions = new Map();
229
- permissionSeq = 0;
230
- constructor(engine, sessions, log = () => { }) {
231
- this.engine = engine;
232
- this.sessions = sessions;
233
- this.log = log;
234
- }
235
- async ensureConnected() {
236
- if (this.ctx && this.child && this.child.exitCode === null)
237
- return this.ctx;
238
- if (!this.initialization) {
239
- this.initialization = this.connect();
240
- // A failed connect must not poison future attempts: clear the cached
241
- // promise on rejection so the next turn re-spawns.
242
- this.initialization.catch(() => {
243
- this.initialization = undefined;
244
- });
245
- }
246
- await this.initialization;
247
- return this.ctx;
248
- }
249
- async connect() {
250
- const processSpec = engineProcessSpec(this.engine);
251
- this.log(`spawning ${processSpec.display}`);
252
- const child = crossSpawn(processSpec.command, processSpec.args, {
253
- stdio: ["pipe", "pipe", "inherit"],
254
- env: engineEnv(),
255
- // POSIX: own process group so dispose() reaches adapter descendants.
256
- detached: process.platform !== "win32",
257
- windowsHide: true,
258
- });
259
- this.child = child;
260
- child.on("error", (error) => {
261
- this.log(`${processSpec.display} spawn error: ${error.message}`);
262
- this.resetConnection();
263
- });
264
- child.on("exit", (code) => {
265
- this.log(`${processSpec.display} exited with code ${code}`);
266
- this.resetConnection();
267
- });
268
- const stream = ndJsonStream(Writable.toWeb(child.stdin), Readable.toWeb(child.stdout));
269
- const app = client({ name: "relaymessenger" })
270
- .onRequest("session/request_permission", async (c) => this.handlePermission(c.params))
271
- .onNotification("session/update", (c) => {
272
- this.handleUpdate(c.params);
273
- });
274
- const connection = app.connect(stream);
275
- this.connection = connection;
276
- this.ctx = connection.agent;
277
- const init = await this.ctx.request("initialize", {
278
- protocolVersion: PROTOCOL_VERSION,
279
- clientInfo: { name: "relaymessenger", version: "0.2.0" },
280
- clientCapabilities: {},
281
- });
282
- if (init.protocolVersion !== PROTOCOL_VERSION) {
283
- throw new Error(`${engineDisplayName(this.engine)} returned unsupported ACP protocol ` +
284
- `${init.protocolVersion}; relaymessenger requires ${PROTOCOL_VERSION}`);
285
- }
286
- this.loadSessionSupported = init.agentCapabilities?.loadSession === true;
287
- this.log(`initialized ${processSpec.display} (protocol v${init.protocolVersion})`);
288
- }
289
- resetConnection() {
290
- this.connection?.close();
291
- this.connection = undefined;
292
- this.ctx = undefined;
293
- this.initialization = undefined;
294
- this.liveSessions.clear();
295
- this.turns.clear();
296
- }
297
- handleUpdate(notification) {
298
- const turn = this.turns.get(notification.sessionId);
299
- if (!turn)
300
- return;
301
- const update = notification.update;
302
- if (update.sessionUpdate === "agent_message_chunk" && update.content.type === "text") {
303
- turn.text.append(update.content.text);
304
- turn.callbacks.onDelta?.(update.content.text);
305
- }
306
- else if (update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") {
307
- // A tool call between text chunks means the next text is a new message.
308
- turn.text.endSegment();
309
- const { sessionUpdate: _sessionUpdate, ...incoming } = update;
310
- turn.toolCalls.set(incoming.toolCallId, mergeToolCall(turn.toolCalls.get(incoming.toolCallId), incoming));
311
- turn.callbacks.onToolEvent?.({
312
- kind: update.sessionUpdate,
313
- title: "title" in update ? (update.title ?? undefined) : undefined,
314
- });
315
- }
316
- }
317
- async handlePermission(params) {
318
- const turn = this.turns.get(params.sessionId);
319
- if (!turn) {
320
- // No live turn owns this session (e.g. restart race) — safest is refusal.
321
- return { outcome: { outcome: "cancelled" } };
322
- }
323
- this.permissionSeq += 1;
324
- const toolCall = mergeToolCall(turn.toolCalls.get(params.toolCall.toolCallId), params.toolCall);
325
- turn.toolCalls.set(toolCall.toolCallId, toolCall);
326
- const ask = {
327
- requestId: `perm_${Date.now().toString(36)}_${this.permissionSeq}`,
328
- toolName: toolCall.title ?? toolCall.toolCallId,
329
- title: toolCall.title ?? undefined,
330
- // The card must show WHAT is being approved, not just a tool title: a
331
- // generic "Bash" with the command hidden turns Allow into a blind grant.
332
- inputPreview: permissionDetail(toolCall),
333
- inputComplete: permissionInputComplete(toolCall),
334
- options: params.options.map((option) => ({
335
- optionId: option.optionId,
336
- label: option.name,
337
- kind: option.kind,
338
- })),
339
- };
340
- const decision = await turn.callbacks.onPermissionAsk(ask);
341
- if (decision.behavior === "selected") {
342
- return { outcome: { outcome: "selected", optionId: decision.optionId } };
343
- }
344
- return { outcome: { outcome: "cancelled" } };
345
- }
346
- async openSession(ctx, ref) {
347
- const live = this.liveSessions.get(ref.conversationId);
348
- if (live?.cwd === ref.cwd)
349
- return live.sessionId;
350
- if (live)
351
- this.liveSessions.delete(ref.conversationId);
352
- const stored = this.sessions.get(ref.conversationId);
353
- // Reuse only bindings from the same engine AND the same working
354
- // directory: reloading another repository's session would leak its
355
- // history/instructions into this tree and act against the wrong files.
356
- if (stored && stored.engine === this.engine && stored.cwd === ref.cwd && this.loadSessionSupported) {
357
- try {
358
- await ctx.request("session/load", {
359
- sessionId: stored.session_id,
360
- cwd: ref.cwd,
361
- mcpServers: [],
362
- });
363
- this.liveSessions.set(ref.conversationId, { sessionId: stored.session_id, cwd: ref.cwd });
364
- return stored.session_id;
365
- }
366
- catch (error) {
367
- this.log(`session/load failed for ${ref.conversationId}, creating fresh: ${error}`);
368
- this.sessions.delete(ref.conversationId);
369
- }
370
- }
371
- const created = await ctx.request("session/new", { cwd: ref.cwd, mcpServers: [] });
372
- this.liveSessions.set(ref.conversationId, { sessionId: created.sessionId, cwd: ref.cwd });
373
- this.sessions.set(ref.conversationId, {
374
- engine: this.engine,
375
- session_id: created.sessionId,
376
- cwd: ref.cwd,
377
- created_at: new Date().toISOString(),
378
- });
379
- return created.sessionId;
380
- }
381
- async startTurn(ref, promptText, callbacks) {
382
- const ctx = await this.ensureConnected();
383
- const sessionId = await this.openSession(ctx, ref);
384
- const turn = { callbacks, text: new AgentTextBuffer(), toolCalls: new Map() };
385
- this.turns.set(sessionId, turn);
386
- try {
387
- // No request timeout: a coding-agent turn can legitimately run for a
388
- // long time, and the JSON-RPC layer settles when the peer responds.
389
- const response = await ctx.request("session/prompt", {
390
- sessionId,
391
- prompt: [{ type: "text", text: promptText }],
392
- });
393
- return { text: turn.text.toString(), stopReason: response.stopReason };
394
- }
395
- finally {
396
- this.turns.delete(sessionId);
397
- }
398
- }
399
- async abort(ref) {
400
- const live = this.liveSessions.get(ref.conversationId);
401
- if (!live || live.cwd !== ref.cwd || !this.ctx)
402
- return;
403
- await this.ctx.notify("session/cancel", { sessionId: live.sessionId });
404
- }
405
- async dispose() {
406
- const child = this.child;
407
- this.resetConnection();
408
- this.child = undefined;
409
- if (child)
410
- await terminateProcessTree(child);
411
- }
412
- }
413
- //# sourceMappingURL=acp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acp.js","sourceRoot":"","sources":["../../src/engine/acp.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,MAAM,EACN,YAAY,EACZ,gBAAgB,GAOjB,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAElB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,gBAAgB,GAA2B;IACtD,MAAM,EAAE,uCAAuC;IAC/C,KAAK,EAAE,gCAAgC;CACxC,CAAC;AAEF,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,0DAA0D;AAC1D,MAAM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,SAAS,CAAC;QACvB,IAAI,KAAK;YAAE,MAAM,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;CACF"}
@@ -1,26 +0,0 @@
1
- /**
2
- * ACP runtime presets supported by relaymessenger.
3
- *
4
- * Bundled adapters are exact npm dependencies resolved by acp.ts. External
5
- * runtimes are always user-installed binaries: relaymessenger never downloads a
6
- * mutable CLI at startup and never passes a command through a shell.
7
- */
8
- export declare const ENGINE_NAMES: readonly ["claude", "codex", "hermes"];
9
- export type EngineName = (typeof ENGINE_NAMES)[number];
10
- export interface ExternalEngineSpec {
11
- displayName: string;
12
- command: string;
13
- args: string[];
14
- versionArgs: string[];
15
- docsUrl: string;
16
- /** Runtime-specific readiness check that does not reveal credentials. */
17
- checkArgs?: string[];
18
- /** Some ACP servers impose a shorter requestPermission deadline. */
19
- permissionTimeoutMs?: number;
20
- }
21
- export declare const EXTERNAL_ENGINE_SPECS: Record<Exclude<EngineName, "claude" | "codex">, ExternalEngineSpec>;
22
- export declare function isEngineName(value: unknown): value is EngineName;
23
- export declare function engineDisplayName(engine: EngineName | string): string;
24
- export declare function enginePermissionTimeoutMs(engine: EngineName): number | undefined;
25
- export declare const ENGINE_HELP: string;
26
- //# sourceMappingURL=catalog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/engine/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,YAAY,YACvB,QAAQ,EACR,OAAO,EACP,QAAQ,CACA,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,oEAAoE;IACpE,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,GAAG,OAAO,CAAC,EAAE,kBAAkB,CAWrG,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAIrE;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAGhF;AAED,eAAO,MAAM,WAAW,QAAyB,CAAC"}
@@ -1,41 +0,0 @@
1
- /**
2
- * ACP runtime presets supported by relaymessenger.
3
- *
4
- * Bundled adapters are exact npm dependencies resolved by acp.ts. External
5
- * runtimes are always user-installed binaries: relaymessenger never downloads a
6
- * mutable CLI at startup and never passes a command through a shell.
7
- */
8
- export const ENGINE_NAMES = [
9
- "claude",
10
- "codex",
11
- "hermes",
12
- ];
13
- export const EXTERNAL_ENGINE_SPECS = {
14
- hermes: {
15
- displayName: "Hermes Agent",
16
- command: "hermes",
17
- args: ["acp"],
18
- versionArgs: ["--version"],
19
- checkArgs: ["acp", "--check"],
20
- docsUrl: "https://hermes-agent.nousresearch.com/docs/user-guide/features/acp",
21
- // Hermes currently waits 60 seconds for an ACP permission decision.
22
- permissionTimeoutMs: 55_000,
23
- },
24
- };
25
- export function isEngineName(value) {
26
- return typeof value === "string" && ENGINE_NAMES.includes(value);
27
- }
28
- export function engineDisplayName(engine) {
29
- if (engine === "claude")
30
- return "Claude Code";
31
- if (engine === "codex")
32
- return "Codex";
33
- return EXTERNAL_ENGINE_SPECS[engine]?.displayName ?? engine;
34
- }
35
- export function enginePermissionTimeoutMs(engine) {
36
- if (engine === "claude" || engine === "codex")
37
- return undefined;
38
- return EXTERNAL_ENGINE_SPECS[engine].permissionTimeoutMs;
39
- }
40
- export const ENGINE_HELP = ENGINE_NAMES.join("|");
41
- //# sourceMappingURL=catalog.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/engine/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ;IACR,OAAO;IACP,QAAQ;CACA,CAAC;AAgBX,MAAM,CAAC,MAAM,qBAAqB,GAAwE;IACxG,MAAM,EAAE;QACN,WAAW,EAAE,cAAc;QAC3B,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,CAAC,KAAK,CAAC;QACb,WAAW,EAAE,CAAC,WAAW,CAAC;QAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC;QAC7B,OAAO,EAAE,oEAAoE;QAC7E,oEAAoE;QACpE,mBAAmB,EAAE,MAAM;KAC5B;CACF,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,YAAkC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1F,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAA2B;IAC3D,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,aAAa,CAAC;IAC9C,IAAI,MAAM,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IACvC,OAAO,qBAAqB,CAAC,MAA4C,CAAC,EAAE,WAAW,IAAI,MAAM,CAAC;AACpG,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,MAAkB;IAC1D,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC;IAChE,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC,mBAAmB,CAAC;AAC3D,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- import { type ChildProcess } from "node:child_process";
2
- /**
3
- * Terminates the complete subprocess tree owned by an engine adapter.
4
- *
5
- * POSIX children are spawned as process-group leaders, so a negative PID
6
- * reaches the adapter and every agent process below it. Windows has no
7
- * equivalent signalable process group; taskkill /T /F is the supported tree
8
- * termination path there. The bounded wait prevents shutdown from hanging on
9
- * a child that ignores SIGTERM.
10
- */
11
- export declare function terminateProcessTree(child: ChildProcess, graceMs?: number): Promise<void>;
12
- //# sourceMappingURL=process.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/engine/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMlE;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,SAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAsC9F"}