@conveno/cli 0.2.0-rc.9 → 0.2.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/README.md +3 -5
- package/dist/{acp-BVk6rmXR.js → acp-BUddItzP.js} +39 -7
- package/dist/{agy-relay-D8eZcLuc.js → agy-relay-BZ3d_-FS.js} +4 -2
- package/dist/{args-B3Cj2Ie4.js → args-CtyKPZuN.js} +29 -8
- package/dist/bin.js +16 -2
- package/dist/daemon.js +4 -3139
- package/dist/{daemonError-C05GqdhQ.js → daemonError-CDgEtvy7.js} +1 -1
- package/dist/dist-BNhTPp5p.js +4509 -0
- package/dist/{dist-BRjg9CLd.js → dist-BOwFdixw.js} +23 -50
- package/dist/{dist-DaIpdMke.js → dist-CFsDqevs.js} +51 -9
- package/dist/dist-CNdqmI3E.js +1065 -0
- package/dist/{dist-STNJjbNH.js → dist-CSSvrcKr.js} +1516 -599
- package/dist/{dist-BjdBeCHy.js → dist-D6Xoip5W.js} +63 -17
- package/dist/{dist-D_O_JLLq.js → dist-DAVtixeC.js} +19 -5
- package/dist/{dist-MK-cK1JY.js → dist-DTMnNySx.js} +39 -19
- package/dist/{hook-CDF1A8AY.js → hook-BA-tI6Oc.js} +101 -7
- package/dist/hook-entry-BwzBtAnd.js +1346 -0
- package/dist/hook-entry-Cgt5ZH1s.js +1 -0
- package/dist/{main-Kv31Qxro.js → main-kKnLA7Hj.js} +58 -21
- package/dist/{pick-DLp6w_-z.js → pick-BsMvXuDo.js} +1 -1
- package/dist/run-PQBzaHv1.js +8193 -0
- package/dist/{runtime-xjPzIGmp.js → runtime-0FMqklYn.js} +171 -119
- package/dist/{uninstall-8AHErPRN.js → uninstall-DcxkIDpk.js} +356 -56
- package/dist/{watch-D0KIPowJ.js → watch-BIepRTXJ.js} +29 -7
- package/package.json +14 -15
- package/dist/dist-CVdpCNJo.js +0 -793
- package/dist/dist-DzpERiRx.js +0 -624
- package/dist/hook-entry-BTJK7aO0.js +0 -2500
- package/dist/hook-entry-D6zup0QV.js +0 -1
- package/dist/run-BPtFUGtu.js +0 -5609
|
@@ -4,31 +4,35 @@ import { homedir } from "node:os";
|
|
|
4
4
|
import { delimiter, join, win32 } from "node:path";
|
|
5
5
|
import { createInterface } from "node:readline";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { t as
|
|
10
|
-
import { t as
|
|
11
|
-
import { t as createTheme } from "./dist-BRjg9CLd.js";
|
|
12
|
-
import { n as connect$1 } from "./dist-D_O_JLLq.js";
|
|
13
|
-
import { Dt as readCommandLine, Et as readAncestry, Gt as spawnSession, In as _enum, Ln as array, P as dataDir, R as detectRepo, Rn as boolean, S as baseName, T as claimSpawnRecord, Un as string, Vn as number, Y as formatInbox, an as CLI_KINDS, at as launcherText, f as SpawnError, fn as MessageId, gn as RpcErrorCode, ht as parsePs1ShimTarget, it as launcherPath, jt as realSpawnDeps, lt as needsQuoting, mt as parseCmdShimTarget, o as HEARTBEAT_INTERVAL_MS, pn as OWNER_SESSION_ID, r as ConvenoError, s as NOT_FROM_USER_NOTICE, tn as validateRename, u as SPAWN_CLIS, xt as planSpawn, y as attachAcpSession, yn as SessionId, zt as resolveWindowsCommand } from "./dist-STNJjbNH.js";
|
|
14
|
-
import "./dist-CVdpCNJo.js";
|
|
7
|
+
import { t as createTheme } from "./dist-BOwFdixw.js";
|
|
8
|
+
import { n as connect } from "./dist-DAVtixeC.js";
|
|
9
|
+
import { $t as readModelMenus, A as baseName, An as validateRename, At as needsQuoting, Bt as pendingTurn, Cr as number, D as attachAcpSession, Ft as parseCmdShimTarget, G as dataDir, Gt as planSpawn, It as parsePs1ShimTarget, K as dataPaths, Kn as MessageId, L as cliDescriptor, N as claimSpawnRecord, Tr as string, Vt as pidAlive, Xt as readAncestry, Y as detectRepo, Zn as RpcErrorCode, Zt as readCommandLine, a as ConvenoError, bn as spawnSession, br as boolean, bt as launcherPath, c as NOT_FROM_USER_NOTICE, dn as resolveWindowsCommand, f as SPAWN_CLIS, m as SpawnError, mt as isAntigravityApp, rn as realSpawnDeps, s as HEARTBEAT_INTERVAL_MS, st as formatInbox, tr as SessionId, vr as _enum, xt as launcherText, yr as array, zn as CLI_KINDS } from "./dist-CSSvrcKr.js";
|
|
10
|
+
import { t as defaultIsAlive } from "./dist-BNhTPp5p.js";
|
|
15
11
|
import { access } from "node:fs/promises";
|
|
16
12
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
17
13
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
import { a as adapterList, r as readAllStdin } from "./hook-entry-BwzBtAnd.js";
|
|
15
|
+
// ../mcp/dist/index.js
|
|
16
|
+
const SERVER_VERSION = "0.2.0";
|
|
17
|
+
const MENU_NAMES_MAX = 12;
|
|
18
|
+
/**
|
|
19
|
+
* One sentence for the spawn_session description: the models and efforts each CLI offered the
|
|
20
|
+
* last time a worker of it started. Empty when none are remembered.
|
|
21
|
+
*/
|
|
22
|
+
function modelMenuNote(menus) {
|
|
23
|
+
const parts = [];
|
|
24
|
+
const cap = (xs) => {
|
|
25
|
+
const names = xs.slice(0, MENU_NAMES_MAX).map((x) => x.value);
|
|
26
|
+
return xs.length > MENU_NAMES_MAX ? `${names.join(", ")}, ...` : names.join(", ");
|
|
27
|
+
};
|
|
28
|
+
for (const cli of CLI_KINDS) {
|
|
29
|
+
const m = menus[cli];
|
|
30
|
+
if (!m || m.models.length === 0 && m.efforts.length === 0) continue;
|
|
31
|
+
const efforts = m.efforts.length > 0 ? ` (effort: ${cap(m.efforts)})` : "";
|
|
32
|
+
parts.push(`${cli}: ${cap(m.models)}${efforts}`);
|
|
26
33
|
}
|
|
34
|
+
return parts.length > 0 ? ` Models offered last time: ${parts.join("; ")}.` : "";
|
|
27
35
|
}
|
|
28
|
-
`${OWNER_SESSION_ID}`;
|
|
29
|
-
SessionId.parse("0".repeat(26));
|
|
30
|
-
// ../mcp/dist/index.js
|
|
31
|
-
const SERVER_VERSION = "0.2.0-rc.9";
|
|
32
36
|
const ok = (text) => ({ content: [{
|
|
33
37
|
type: "text",
|
|
34
38
|
text
|
|
@@ -106,6 +110,8 @@ function whoamiText(s) {
|
|
|
106
110
|
}
|
|
107
111
|
/** The daemon no longer knows this session (restart, pruned, name taken). Recipient errors do not match. */
|
|
108
112
|
const isSessionGone = (err) => err instanceof ConvenoError && err.code === RpcErrorCode.NotFound && /No session with id|not registered|Register the session again/.test(err.message);
|
|
113
|
+
/** The daemon retired this session: it will not take heartbeats from it again. */
|
|
114
|
+
const isSessionEnded = (err) => err instanceof ConvenoError && err.code === RpcErrorCode.NotFound && err.message.includes("has ended and will not come back");
|
|
109
115
|
const SESSION_LOST_TEXT = "Conveno lost this session and could not restore it automatically. Tell the user that Conveno is not available in this session right now; restarting the CLI session reconnects it.";
|
|
110
116
|
/**
|
|
111
117
|
* Sent in the `instructions` field of the initialize result. MCP clients put it in the model's
|
|
@@ -134,31 +140,28 @@ function createServer(opts) {
|
|
|
134
140
|
version: SERVER_VERSION
|
|
135
141
|
}, { instructions: SERVER_INSTRUCTIONS });
|
|
136
142
|
const spawnDataDir = opts.dataDir ?? dataDir(process.platform, process.env, homedir());
|
|
143
|
+
const menuNote = modelMenuNote(readModelMenus(dataPaths(process.platform, spawnDataDir).workerModels));
|
|
137
144
|
let registering;
|
|
138
145
|
let timer;
|
|
139
146
|
let shutting;
|
|
140
147
|
/** This server acts as a session an ACP host registered, and leaves its lifecycle to the host. */
|
|
141
148
|
let attached = false;
|
|
142
149
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
150
|
+
* The id Conveno acts as. It starts as the session this process registered, and changes to the
|
|
151
|
+
* surviving session when `session.bind` merges this process's session into the one that already
|
|
152
|
+
* holds its conversation (Codex runs one MCP server per thread, so a thread the window already
|
|
153
|
+
* has may be registered a second time). Heartbeats, tool calls and unregister all use it.
|
|
146
154
|
*/
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
let
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
extraBeats.delete(id);
|
|
155
|
-
byOpencode.delete(ocId);
|
|
156
|
-
};
|
|
157
|
-
const register = async (extra = false, ocId) => {
|
|
155
|
+
let actingId;
|
|
156
|
+
/** The conversation this process last bound, so a tool call binds only when it changes. */
|
|
157
|
+
let boundConversation;
|
|
158
|
+
let binding = Promise.resolve();
|
|
159
|
+
const isAlive = opts.isAlive ?? pidAlive;
|
|
160
|
+
const parentGone = () => opts.parentPid !== void 0 && !isAlive(opts.parentPid);
|
|
161
|
+
const register = async () => {
|
|
158
162
|
const repo = await detectRepo(cwd, { exists: pathExists });
|
|
159
|
-
const
|
|
160
|
-
const
|
|
161
|
-
const record = extra ? void 0 : claimSpawnRecord(spawnDataDir, cli, hostPids);
|
|
163
|
+
const { hostPid, hostPids, variant } = await host;
|
|
164
|
+
const record = claimSpawnRecord(spawnDataDir, cli, hostPids);
|
|
162
165
|
if (record?.acp) {
|
|
163
166
|
attached = true;
|
|
164
167
|
return attachAcpSession(client, spawnDataDir, record);
|
|
@@ -170,36 +173,73 @@ function createServer(opts) {
|
|
|
170
173
|
pid: process.pid,
|
|
171
174
|
...hostPid !== void 0 ? { hostPid } : {},
|
|
172
175
|
...hostPids.length > 0 ? { hostPids: hostPids.slice(0, 8) } : {},
|
|
173
|
-
...
|
|
176
|
+
...variant ? { variant } : {},
|
|
174
177
|
...repo.root ? { repo: { root: repo.root } } : {},
|
|
175
178
|
...spawnedBy.success ? { spawnedBy: spawnedBy.data } : {},
|
|
176
179
|
...record ? { spawned: true } : {}
|
|
177
180
|
};
|
|
178
|
-
|
|
181
|
+
let session = (await (record ? client["session.register"]({
|
|
179
182
|
...params,
|
|
180
183
|
name: record.name
|
|
181
184
|
}).catch((err) => {
|
|
182
185
|
if (err instanceof ConvenoError && err.code === RpcErrorCode.Conflict) return client["session.register"](params);
|
|
183
186
|
throw err;
|
|
184
|
-
}) : client["session.register"](params));
|
|
185
|
-
|
|
187
|
+
}) : client["session.register"](params))).session;
|
|
188
|
+
actingId = session.id;
|
|
189
|
+
boundConversation = session.nativeId;
|
|
186
190
|
const claudeId = cli === "claude" ? process.env.CLAUDE_CODE_SESSION_ID?.trim() : void 0;
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
+
if (claudeId && session.nativeId === void 0) {
|
|
192
|
+
const bound = await bindTo(claudeId, session);
|
|
193
|
+
if (bound) session = bound;
|
|
194
|
+
if (await pendingTurn(spawnDataDir, "claude-pending-turn").take(claudeId)) await client["turn.start"]({ sessionId: session.id }).catch(() => {});
|
|
195
|
+
}
|
|
191
196
|
const beat = setInterval(() => {
|
|
192
|
-
|
|
193
|
-
|
|
197
|
+
if (!actingId) return;
|
|
198
|
+
if (parentGone()) {
|
|
199
|
+
shutdown().then(() => opts.onExit?.());
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
client["session.heartbeat"]({
|
|
203
|
+
sessionId: actingId,
|
|
204
|
+
pid: process.pid
|
|
205
|
+
}).catch((err) => {
|
|
206
|
+
if (isSessionEnded(err)) {
|
|
207
|
+
if (timer) clearInterval(timer);
|
|
208
|
+
timer = void 0;
|
|
209
|
+
opts.onExit?.();
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (!isSessionGone(err)) return;
|
|
213
|
+
forgetSession();
|
|
214
|
+
ensure().catch(() => {});
|
|
194
215
|
});
|
|
195
216
|
}, HEARTBEAT_INTERVAL_MS);
|
|
196
217
|
beat.unref();
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
218
|
+
if (timer) clearInterval(timer);
|
|
219
|
+
timer = beat;
|
|
220
|
+
return session;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Bind this process's session to a conversation. The daemon may answer with another session, the
|
|
224
|
+
* one that already holds it; this process acts as that one from then on. Best effort: without
|
|
225
|
+
* the answer the session stays as it is.
|
|
226
|
+
*/
|
|
227
|
+
const bindTo = async (conversation, me) => {
|
|
228
|
+
try {
|
|
229
|
+
const { session } = await client["session.bind"]({
|
|
230
|
+
cli,
|
|
231
|
+
nativeId: conversation,
|
|
232
|
+
sessionId: me.id,
|
|
233
|
+
pid: process.pid,
|
|
234
|
+
turnStart: true
|
|
235
|
+
});
|
|
236
|
+
if (!session) return void 0;
|
|
237
|
+
boundConversation = conversation;
|
|
238
|
+
actingId = session.id;
|
|
239
|
+
return session;
|
|
240
|
+
} catch {
|
|
241
|
+
return;
|
|
201
242
|
}
|
|
202
|
-
return res.session;
|
|
203
243
|
};
|
|
204
244
|
const ensure = () => {
|
|
205
245
|
if (!registering) {
|
|
@@ -211,20 +251,15 @@ function createServer(opts) {
|
|
|
211
251
|
}
|
|
212
252
|
return registering;
|
|
213
253
|
};
|
|
214
|
-
/** Forget a dead session so the next ensure() registers again. Only drops `dead`, not a newer one. */
|
|
215
|
-
const forget = (dead) => {
|
|
216
|
-
if (registering === dead) registering = void 0;
|
|
217
|
-
};
|
|
218
254
|
const shutdown = () => {
|
|
219
255
|
shutting ??= (async () => {
|
|
220
256
|
if (timer) clearInterval(timer);
|
|
221
257
|
timer = void 0;
|
|
222
258
|
const s = await registering?.catch(() => void 0);
|
|
223
|
-
if (s && !attached) await client["session.unregister"]({
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
for (const o of others) if (o && o.id !== s?.id) await client["session.unregister"]({ sessionId: o.id }).catch(() => void 0);
|
|
259
|
+
if (s && !attached) await client["session.unregister"]({
|
|
260
|
+
sessionId: actingId ?? s.id,
|
|
261
|
+
pid: process.pid
|
|
262
|
+
}).catch(() => void 0);
|
|
228
263
|
})();
|
|
229
264
|
return shutting;
|
|
230
265
|
};
|
|
@@ -239,44 +274,38 @@ function createServer(opts) {
|
|
|
239
274
|
await closeTransport();
|
|
240
275
|
await shutdown();
|
|
241
276
|
};
|
|
242
|
-
/**
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (byOpencode.get(ocId) === made) byOpencode.delete(ocId);
|
|
260
|
-
if (takeBase && baseOwner === ocId) baseOwner = void 0;
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
return p;
|
|
277
|
+
/**
|
|
278
|
+
* The session a tool call acts as. A call that names its conversation (`_meta`) is a turn start
|
|
279
|
+
* in it: when it differs from the one this process last bound, the window's session moves to it
|
|
280
|
+
* (and a session of another process that already holds it takes this one over).
|
|
281
|
+
*/
|
|
282
|
+
const sessionFor = async (conversation) => {
|
|
283
|
+
const me = await ensure();
|
|
284
|
+
if (!conversation || attached || conversation === boundConversation) return me;
|
|
285
|
+
const turn = binding.then(async () => {
|
|
286
|
+
const current = await ensure();
|
|
287
|
+
if (conversation === boundConversation) return current;
|
|
288
|
+
const bound = await bindTo(conversation, current);
|
|
289
|
+
if (bound) registering = Promise.resolve(bound);
|
|
290
|
+
return bound ?? current;
|
|
291
|
+
});
|
|
292
|
+
binding = turn.catch(() => void 0);
|
|
293
|
+
return turn;
|
|
264
294
|
};
|
|
265
295
|
/** Drop a dead session so the next call registers again. */
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
if (byOpencode.get(ocId) === dead) byOpencode.delete(ocId);
|
|
272
|
-
if (baseOwner === ocId) {
|
|
273
|
-
baseOwner = void 0;
|
|
274
|
-
registering = void 0;
|
|
275
|
-
}
|
|
296
|
+
const forgetSession = () => {
|
|
297
|
+
registering = void 0;
|
|
298
|
+
boundConversation = void 0;
|
|
299
|
+
actingId = void 0;
|
|
276
300
|
};
|
|
277
|
-
/**
|
|
278
|
-
|
|
279
|
-
|
|
301
|
+
/**
|
|
302
|
+
* The conversation a tool call comes from, in the request's `_meta` key the CLI's descriptor
|
|
303
|
+
* names (`conversationMetaKey`): Codex `threadId`, OpenCode `ai.opencode/sessionID`.
|
|
304
|
+
*/
|
|
305
|
+
const conversationOf = (extra) => {
|
|
306
|
+
const meta = extra?._meta;
|
|
307
|
+
const key = cliDescriptor(cli)?.conversationMetaKey;
|
|
308
|
+
const v = key === void 0 ? void 0 : meta?.[key];
|
|
280
309
|
return typeof v === "string" && v.length > 0 && v.length <= 256 ? v : void 0;
|
|
281
310
|
};
|
|
282
311
|
/**
|
|
@@ -287,16 +316,15 @@ function createServer(opts) {
|
|
|
287
316
|
const tool = (body) => async (...given) => {
|
|
288
317
|
const extra = given.length > 1 ? given[given.length - 1] : void 0;
|
|
289
318
|
const args = given.length > 1 ? given[0] : {};
|
|
290
|
-
const
|
|
291
|
-
const first = sessionFor(oc);
|
|
319
|
+
const conversation = conversationOf(extra ?? given[0]);
|
|
292
320
|
try {
|
|
293
|
-
return ok(await body(await
|
|
321
|
+
return ok(await body(await sessionFor(conversation), args));
|
|
294
322
|
} catch (err) {
|
|
295
323
|
if (!isSessionGone(err)) return fail(err);
|
|
296
|
-
|
|
324
|
+
forgetSession();
|
|
297
325
|
}
|
|
298
326
|
try {
|
|
299
|
-
return ok(await body(await sessionFor(
|
|
327
|
+
return ok(await body(await sessionFor(conversation), args));
|
|
300
328
|
} catch (err) {
|
|
301
329
|
return isSessionGone(err) ? fail(/* @__PURE__ */ new Error(SESSION_LOST_TEXT)) : fail(err);
|
|
302
330
|
}
|
|
@@ -366,6 +394,24 @@ function createServer(opts) {
|
|
|
366
394
|
const plural = (n, one, many) => n === 1 ? one : many;
|
|
367
395
|
return [`Acknowledged ${res.acked} ${plural(res.acked, "message", "messages")}.`, unknown > 0 ? `${unknown} ${plural(unknown, "id was", "ids were")} not found.` : ""].filter(Boolean).join(" ");
|
|
368
396
|
}));
|
|
397
|
+
mcp.registerTool("answer_permission", {
|
|
398
|
+
description: "Answer a worker's permission request (sent to you as a 'wants to run' notice).",
|
|
399
|
+
inputSchema: {
|
|
400
|
+
request: string().min(1).max(64).describe("The request id from the notice."),
|
|
401
|
+
answer: _enum([
|
|
402
|
+
"allow",
|
|
403
|
+
"always",
|
|
404
|
+
"deny"
|
|
405
|
+
]).describe("allow: this once. always: also for the same call later. deny.")
|
|
406
|
+
}
|
|
407
|
+
}, tool(async (me, a) => {
|
|
408
|
+
await client["permission.answer"]({
|
|
409
|
+
sessionId: me.id,
|
|
410
|
+
requestId: a.request,
|
|
411
|
+
answer: a.answer === "allow" ? "allow_once" : a.answer === "always" ? "allow_always" : "deny"
|
|
412
|
+
});
|
|
413
|
+
return `Answered request ${a.request}: ${a.answer}.`;
|
|
414
|
+
}));
|
|
369
415
|
mcp.registerTool("rename", {
|
|
370
416
|
description: "Change this session's name. Use it when the user wants a name others can remember, such as `api-worker`.",
|
|
371
417
|
inputSchema: { name: string().min(1).describe("New name: 1 to 64 characters of lowercase letters, digits, '.', '_', '@' or '-'.") }
|
|
@@ -392,7 +438,10 @@ function createServer(opts) {
|
|
|
392
438
|
return a.text === "" ? "Status cleared." : "Status set.";
|
|
393
439
|
}));
|
|
394
440
|
const becomeLead = tool(async (me) => {
|
|
395
|
-
const res = await client["orchestrator.claim"]({
|
|
441
|
+
const res = await client["orchestrator.claim"]({
|
|
442
|
+
sessionId: me.id,
|
|
443
|
+
via: "tool"
|
|
444
|
+
});
|
|
396
445
|
if (!res.previous) return "You are now the lead. There was no previous holder.";
|
|
397
446
|
const { sessions } = await client["session.list"]({ includeOffline: true });
|
|
398
447
|
return `You are now the lead. Previous holder: ${sessions.find((s) => s.id === res.previous)?.name ?? res.previous}.`;
|
|
@@ -426,14 +475,20 @@ function createServer(opts) {
|
|
|
426
475
|
return `Handed off to ${res.deliveredTo.name} (message id ${res.message.id}). ${DELIVERY_NOTE[res.delivery] ?? ""}`.trimEnd();
|
|
427
476
|
}));
|
|
428
477
|
mcp.registerTool("spawn_session", {
|
|
429
|
-
description: "Start a new worker session of a coding CLI with a first task, and return its name once it registers. It runs in the background and keeps running: each message you send becomes its next prompt, and it reports back the same way. Set window to open it in a visible terminal instead. The new session is yours to direct: message it by name with send. Only the listed CLIs can be started, and only inside the user's home folder.",
|
|
478
|
+
description: "Start a new worker session of a coding CLI with a first task, and return its name once it registers. It runs in the background and keeps running: each message you send becomes its next prompt, and it reports back the same way. Set window to open it in a visible terminal instead. The new session is yours to direct: message it by name with send. Only the listed CLIs can be started, and only inside the user's home folder." + menuNote,
|
|
430
479
|
inputSchema: {
|
|
431
480
|
cli: _enum(SPAWN_CLIS).describe("Which CLI to start."),
|
|
432
481
|
cwd: string().min(1).optional().describe("Folder to work in, inside the home folder. Default: this session's folder."),
|
|
433
482
|
name: string().min(1).optional().describe("Session name: lowercase letters, digits, '.', '_', '@' or '-'."),
|
|
434
483
|
task: string().min(1).optional().describe("The first task for the new session."),
|
|
435
484
|
window: boolean().optional().describe("Open it in a visible terminal window instead of the background."),
|
|
436
|
-
|
|
485
|
+
access: _enum([
|
|
486
|
+
"read",
|
|
487
|
+
"edit",
|
|
488
|
+
"full"
|
|
489
|
+
]).optional().describe("Optional. What the worker may do without asking: read (look only), edit (also change files) or full (everything; the default unless the user changed it). Not for window workers."),
|
|
490
|
+
model: string().max(200).optional().describe("Optional. The model, by the CLI's own name. Omit to use the user's default for that CLI, else the CLI's own default."),
|
|
491
|
+
effort: string().max(200).optional().describe("Optional. The effort or reasoning level, by the CLI's own name. Omit to use the user's default for that CLI, else the CLI's own default.")
|
|
437
492
|
}
|
|
438
493
|
}, tool(async (me, a) => {
|
|
439
494
|
const deps = opts.spawnDeps ?? realSpawnDeps({
|
|
@@ -452,7 +507,9 @@ function createServer(opts) {
|
|
|
452
507
|
name: a.name,
|
|
453
508
|
task: a.task,
|
|
454
509
|
window: a.window ?? false,
|
|
455
|
-
|
|
510
|
+
access: a.access,
|
|
511
|
+
model: a.model,
|
|
512
|
+
effort: a.effort,
|
|
456
513
|
requester: me,
|
|
457
514
|
confineToHome: true,
|
|
458
515
|
timeoutMs: 45e3
|
|
@@ -478,9 +535,10 @@ async function runStdio(opts) {
|
|
|
478
535
|
launcherPaths: process.argv[1] ? [process.argv[1]] : []
|
|
479
536
|
}).then((a) => ({
|
|
480
537
|
hostPid: a.hostPid,
|
|
481
|
-
hostPids: a.pids
|
|
538
|
+
hostPids: a.pids,
|
|
539
|
+
variant: opts.cli === "antigravity" && isAntigravityApp(a.entries) ? "app" : void 0
|
|
482
540
|
}));
|
|
483
|
-
const client = await connect
|
|
541
|
+
const client = await connect({
|
|
484
542
|
kind: "mcp",
|
|
485
543
|
autoStart: true,
|
|
486
544
|
...opts.daemonEntry ? { daemonEntry: opts.daemonEntry } : {}
|
|
@@ -489,7 +547,9 @@ async function runStdio(opts) {
|
|
|
489
547
|
cli: opts.cli,
|
|
490
548
|
client,
|
|
491
549
|
host,
|
|
492
|
-
cwd: process.cwd()
|
|
550
|
+
cwd: process.cwd(),
|
|
551
|
+
...process.ppid > 1 ? { parentPid: process.ppid } : {},
|
|
552
|
+
onExit: () => void stop().then(() => process.exit(0))
|
|
493
553
|
});
|
|
494
554
|
let stopping;
|
|
495
555
|
const stop = () => {
|
|
@@ -737,15 +797,7 @@ function createRuntimeCtx() {
|
|
|
737
797
|
bin: cliBinPath(),
|
|
738
798
|
launcher: convenoLauncher(env, platform, dir, void 0, void 0, void 0, home)
|
|
739
799
|
},
|
|
740
|
-
adapters:
|
|
741
|
-
claudeAdapter,
|
|
742
|
-
codexAdapter,
|
|
743
|
-
opencodeAdapter,
|
|
744
|
-
cursorAdapter,
|
|
745
|
-
copilotAdapter,
|
|
746
|
-
antigravityAdapter,
|
|
747
|
-
grokAdapter
|
|
748
|
-
],
|
|
800
|
+
adapters: adapterList(),
|
|
749
801
|
spawnRunner: [process.execPath, cliBinPath()],
|
|
750
802
|
exec,
|
|
751
803
|
theme,
|
|
@@ -756,7 +808,7 @@ function createRuntimeCtx() {
|
|
|
756
808
|
prompt: (q) => promptLine(theme, q),
|
|
757
809
|
now: () => /* @__PURE__ */ new Date(),
|
|
758
810
|
readStdin: readAllStdin,
|
|
759
|
-
connect
|
|
811
|
+
connect,
|
|
760
812
|
ancestry: (timeoutMs) => readAncestry({
|
|
761
813
|
timeoutMs,
|
|
762
814
|
launcherPaths: process.argv[1] ? [process.argv[1]] : []
|
|
@@ -769,4 +821,4 @@ function createRuntimeCtx() {
|
|
|
769
821
|
hookTimeoutMs: 2e3
|
|
770
822
|
};
|
|
771
823
|
}
|
|
772
|
-
export { ask,
|
|
824
|
+
export { ask, convenoCommand, convenoLauncher, createRuntimeCtx, resolveDaemonEntry, windowsShortPath };
|