@conveno/cli 0.2.0-rc.11 → 0.2.0-rc.13
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 +1 -1
- package/dist/{acp-BOSDOzU7.js → acp-Bs6XS61j.js} +3 -3
- package/dist/{agy-relay-BUo9uRng.js → agy-relay-BJLRYbFp.js} +3 -2
- package/dist/{args-C1eX8Ixk.js → args-C4rVCVXx.js} +3 -1
- package/dist/bin.js +16 -2
- package/dist/daemon.js +339 -18
- package/dist/{daemonError-DraepwsB.js → daemonError-CjxG2yUl.js} +1 -1
- package/dist/{dist-Y0JDSJP_.js → dist-B14ldKRS.js} +50 -8
- package/dist/{dist-Rdj5ogAX.js → dist-BkhKEexU.js} +90 -21
- package/dist/{dist-DEjU_KXC.js → dist-C9Z1EMlM.js} +39 -19
- package/dist/{dist-n6XMTlyN.js → dist-Ca3P7aN-.js} +10 -1
- package/dist/{dist-Dg2IY9OA.js → dist-CoRBNycn.js} +1 -1
- package/dist/{dist-KWlFKO7H.js → dist-D4sb5RQD.js} +56 -13
- package/dist/{dist-qONHJRJk.js → dist-DnNuDzEA.js} +286 -36
- package/dist/{hook-CDF1A8AY.js → hook-C60hXJdg.js} +101 -7
- package/dist/{hook-entry-BYvXWDJv.js → hook-entry-WlJSM5aD.js} +101 -78
- package/dist/hook-entry-jOfjq-0A.js +1 -0
- package/dist/{main-EqfI0btx.js → main-I2RMN7XN.js} +54 -15
- package/dist/{pick-B-axJvgf.js → pick-Colav8Wm.js} +1 -1
- package/dist/{run-CtGfzzwB.js → run-BuDbmxx_.js} +223 -74
- package/dist/{runtime-BDNmkbsS.js → runtime-CPmrhPFJ.js} +118 -90
- package/dist/{uninstall-Blt-KHI5.js → uninstall-812XZDTG.js} +259 -43
- package/dist/{watch-CuZ7jPVd.js → watch-DXbOOc20.js} +29 -7
- package/package.json +13 -13
- package/dist/hook-entry-D2CAJsq-.js +0 -1
|
@@ -4,18 +4,18 @@ 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 { n as antigravityAdapter } from "./dist-
|
|
8
|
-
import { a as opencodeAdapter, o as claudeAdapter, r as readAllStdin } from "./hook-entry-
|
|
9
|
-
import { t as codexAdapter } from "./dist-
|
|
10
|
-
import { t as grokAdapter } from "./dist-
|
|
7
|
+
import { n as antigravityAdapter } from "./dist-D4sb5RQD.js";
|
|
8
|
+
import { a as opencodeAdapter, o as claudeAdapter, r as readAllStdin } from "./hook-entry-WlJSM5aD.js";
|
|
9
|
+
import { t as codexAdapter } from "./dist-C9Z1EMlM.js";
|
|
10
|
+
import { t as grokAdapter } from "./dist-B14ldKRS.js";
|
|
11
11
|
import { t as createTheme } from "./dist-BRjg9CLd.js";
|
|
12
|
-
import { n as connect$1 } from "./dist-
|
|
13
|
-
import {
|
|
14
|
-
import "./dist-
|
|
12
|
+
import { n as connect$1 } from "./dist-Ca3P7aN-.js";
|
|
13
|
+
import { $ as formatInbox, C as attachAcpSession, E as baseName, H as detectRepo, Mn as SessionId, Nt as planSpawn, On as RpcErrorCode, Ot as pendingTurn, R as dataDir, Rt as readAncestry, Tn as OWNER_SESSION_ID, Tt as parsePs1ShimTarget, Wt as realSpawnDeps, Xn as array, Yn as _enum, Zn as boolean, Zt as resolveWindowsCommand, _n as CLI_KINDS, a as ConvenoError, c as HEARTBEAT_INTERVAL_MS, er as number, f as SPAWN_CLIS, k as claimSpawnRecord, kt as pidAlive, l as NOT_FROM_USER_NOTICE, m as SpawnError, mt as launcherText, nr as string, pn as validateRename, pt as launcherPath, rn as spawnSession, st as isAntigravityApp, vt as needsQuoting, wn as MessageId, wt as parseCmdShimTarget, zt as readCommandLine } from "./dist-DnNuDzEA.js";
|
|
14
|
+
import "./dist-CoRBNycn.js";
|
|
15
15
|
import { access } from "node:fs/promises";
|
|
16
16
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
17
17
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
18
|
-
// ../daemon/dist/server-
|
|
18
|
+
// ../daemon/dist/server-D8Ib1txr.js
|
|
19
19
|
/** `kill(pid, 0)` liveness: EPERM means the process exists but belongs to someone else. */
|
|
20
20
|
function defaultIsAlive(pid) {
|
|
21
21
|
try {
|
|
@@ -28,7 +28,7 @@ function defaultIsAlive(pid) {
|
|
|
28
28
|
`${OWNER_SESSION_ID}`;
|
|
29
29
|
SessionId.parse("0".repeat(26));
|
|
30
30
|
// ../mcp/dist/index.js
|
|
31
|
-
const SERVER_VERSION = "0.2.0-rc.
|
|
31
|
+
const SERVER_VERSION = "0.2.0-rc.13";
|
|
32
32
|
const ok = (text) => ({ content: [{
|
|
33
33
|
type: "text",
|
|
34
34
|
text
|
|
@@ -106,6 +106,8 @@ function whoamiText(s) {
|
|
|
106
106
|
}
|
|
107
107
|
/** The daemon no longer knows this session (restart, pruned, name taken). Recipient errors do not match. */
|
|
108
108
|
const isSessionGone = (err) => err instanceof ConvenoError && err.code === RpcErrorCode.NotFound && /No session with id|not registered|Register the session again/.test(err.message);
|
|
109
|
+
/** The daemon retired this session: it will not take heartbeats from it again. */
|
|
110
|
+
const isSessionEnded = (err) => err instanceof ConvenoError && err.code === RpcErrorCode.NotFound && err.message.includes("has ended and will not come back");
|
|
109
111
|
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
112
|
/**
|
|
111
113
|
* Sent in the `instructions` field of the initialize result. MCP clients put it in the model's
|
|
@@ -140,25 +142,22 @@ function createServer(opts) {
|
|
|
140
142
|
/** This server acts as a session an ACP host registered, and leaves its lifecycle to the host. */
|
|
141
143
|
let attached = false;
|
|
142
144
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
145
|
+
* The id Conveno acts as. It starts as the session this process registered, and changes to the
|
|
146
|
+
* surviving session when `session.bind` merges this process's session into the one that already
|
|
147
|
+
* holds its conversation (Codex runs one MCP server per thread, so a thread the window already
|
|
148
|
+
* has may be registered a second time). Heartbeats, tool calls and unregister all use it.
|
|
146
149
|
*/
|
|
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) => {
|
|
150
|
+
let actingId;
|
|
151
|
+
/** The conversation this process last bound, so a tool call binds only when it changes. */
|
|
152
|
+
let boundConversation;
|
|
153
|
+
let binding = Promise.resolve();
|
|
154
|
+
const isAlive = opts.isAlive ?? pidAlive;
|
|
155
|
+
const parentGone = () => opts.parentPid !== void 0 && !isAlive(opts.parentPid);
|
|
156
|
+
const register = async () => {
|
|
158
157
|
const repo = await detectRepo(cwd, { exists: pathExists });
|
|
159
158
|
const cliVersion = process.env.CONVENO_CLI_VERSION?.trim().slice(0, 64);
|
|
160
|
-
const { hostPid, hostPids } = await host;
|
|
161
|
-
const record =
|
|
159
|
+
const { hostPid, hostPids, variant } = await host;
|
|
160
|
+
const record = claimSpawnRecord(spawnDataDir, cli, hostPids);
|
|
162
161
|
if (record?.acp) {
|
|
163
162
|
attached = true;
|
|
164
163
|
return attachAcpSession(client, spawnDataDir, record);
|
|
@@ -171,35 +170,73 @@ function createServer(opts) {
|
|
|
171
170
|
...hostPid !== void 0 ? { hostPid } : {},
|
|
172
171
|
...hostPids.length > 0 ? { hostPids: hostPids.slice(0, 8) } : {},
|
|
173
172
|
...cliVersion ? { cliVersion } : {},
|
|
173
|
+
...variant ? { variant } : {},
|
|
174
174
|
...repo.root ? { repo: { root: repo.root } } : {},
|
|
175
175
|
...spawnedBy.success ? { spawnedBy: spawnedBy.data } : {},
|
|
176
176
|
...record ? { spawned: true } : {}
|
|
177
177
|
};
|
|
178
|
-
|
|
178
|
+
let session = (await (record ? client["session.register"]({
|
|
179
179
|
...params,
|
|
180
180
|
name: record.name
|
|
181
181
|
}).catch((err) => {
|
|
182
182
|
if (err instanceof ConvenoError && err.code === RpcErrorCode.Conflict) return client["session.register"](params);
|
|
183
183
|
throw err;
|
|
184
|
-
}) : client["session.register"](params));
|
|
185
|
-
|
|
184
|
+
}) : client["session.register"](params))).session;
|
|
185
|
+
actingId = session.id;
|
|
186
|
+
boundConversation = session.nativeId;
|
|
186
187
|
const claudeId = cli === "claude" ? process.env.CLAUDE_CODE_SESSION_ID?.trim() : void 0;
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
if (claudeId && session.nativeId === void 0) {
|
|
189
|
+
const bound = await bindTo(claudeId, session);
|
|
190
|
+
if (bound) session = bound;
|
|
191
|
+
if (await pendingTurn(spawnDataDir, "claude-pending-turn").take(claudeId)) await client["turn.start"]({ sessionId: session.id }).catch(() => {});
|
|
192
|
+
}
|
|
191
193
|
const beat = setInterval(() => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
+
if (!actingId) return;
|
|
195
|
+
if (parentGone()) {
|
|
196
|
+
shutdown().then(() => opts.onExit?.());
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
client["session.heartbeat"]({
|
|
200
|
+
sessionId: actingId,
|
|
201
|
+
pid: process.pid
|
|
202
|
+
}).catch((err) => {
|
|
203
|
+
if (isSessionEnded(err)) {
|
|
204
|
+
if (timer) clearInterval(timer);
|
|
205
|
+
timer = void 0;
|
|
206
|
+
opts.onExit?.();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (!isSessionGone(err)) return;
|
|
210
|
+
forgetSession();
|
|
211
|
+
ensure().catch(() => {});
|
|
194
212
|
});
|
|
195
213
|
}, HEARTBEAT_INTERVAL_MS);
|
|
196
214
|
beat.unref();
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
215
|
+
if (timer) clearInterval(timer);
|
|
216
|
+
timer = beat;
|
|
217
|
+
return session;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Bind this process's session to a conversation. The daemon may answer with another session, the
|
|
221
|
+
* one that already holds it; this process acts as that one from then on. Best effort: without
|
|
222
|
+
* the answer the session stays as it is.
|
|
223
|
+
*/
|
|
224
|
+
const bindTo = async (conversation, me) => {
|
|
225
|
+
try {
|
|
226
|
+
const { session } = await client["session.bind"]({
|
|
227
|
+
cli,
|
|
228
|
+
nativeId: conversation,
|
|
229
|
+
sessionId: me.id,
|
|
230
|
+
pid: process.pid,
|
|
231
|
+
turnStart: true
|
|
232
|
+
});
|
|
233
|
+
if (!session) return void 0;
|
|
234
|
+
boundConversation = conversation;
|
|
235
|
+
actingId = session.id;
|
|
236
|
+
return session;
|
|
237
|
+
} catch {
|
|
238
|
+
return;
|
|
201
239
|
}
|
|
202
|
-
return res.session;
|
|
203
240
|
};
|
|
204
241
|
const ensure = () => {
|
|
205
242
|
if (!registering) {
|
|
@@ -211,20 +248,15 @@ function createServer(opts) {
|
|
|
211
248
|
}
|
|
212
249
|
return registering;
|
|
213
250
|
};
|
|
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
251
|
const shutdown = () => {
|
|
219
252
|
shutting ??= (async () => {
|
|
220
253
|
if (timer) clearInterval(timer);
|
|
221
254
|
timer = void 0;
|
|
222
255
|
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);
|
|
256
|
+
if (s && !attached) await client["session.unregister"]({
|
|
257
|
+
sessionId: actingId ?? s.id,
|
|
258
|
+
pid: process.pid
|
|
259
|
+
}).catch(() => void 0);
|
|
228
260
|
})();
|
|
229
261
|
return shutting;
|
|
230
262
|
};
|
|
@@ -239,44 +271,38 @@ function createServer(opts) {
|
|
|
239
271
|
await closeTransport();
|
|
240
272
|
await shutdown();
|
|
241
273
|
};
|
|
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;
|
|
274
|
+
/**
|
|
275
|
+
* The session a tool call acts as. A call that names its conversation (`_meta`) is a turn start
|
|
276
|
+
* in it: when it differs from the one this process last bound, the window's session moves to it
|
|
277
|
+
* (and a session of another process that already holds it takes this one over).
|
|
278
|
+
*/
|
|
279
|
+
const sessionFor = async (conversation) => {
|
|
280
|
+
const me = await ensure();
|
|
281
|
+
if (!conversation || attached || conversation === boundConversation) return me;
|
|
282
|
+
const turn = binding.then(async () => {
|
|
283
|
+
const current = await ensure();
|
|
284
|
+
if (conversation === boundConversation) return current;
|
|
285
|
+
const bound = await bindTo(conversation, current);
|
|
286
|
+
if (bound) registering = Promise.resolve(bound);
|
|
287
|
+
return bound ?? current;
|
|
288
|
+
});
|
|
289
|
+
binding = turn.catch(() => void 0);
|
|
290
|
+
return turn;
|
|
264
291
|
};
|
|
265
292
|
/** 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
|
-
}
|
|
293
|
+
const forgetSession = () => {
|
|
294
|
+
registering = void 0;
|
|
295
|
+
boundConversation = void 0;
|
|
296
|
+
actingId = void 0;
|
|
276
297
|
};
|
|
277
|
-
/**
|
|
278
|
-
|
|
279
|
-
|
|
298
|
+
/**
|
|
299
|
+
* The conversation a tool call comes from, in the request's `_meta`: Codex `threadId`, OpenCode
|
|
300
|
+
* `ai.opencode/sessionID`, Antigravity `antigravity.google/root_conversation_id`.
|
|
301
|
+
*/
|
|
302
|
+
const conversationOf = (extra) => {
|
|
303
|
+
const meta = extra?._meta;
|
|
304
|
+
const key = cli === "codex" ? "threadId" : cli === "opencode" ? "ai.opencode/sessionID" : cli === "antigravity" ? "antigravity.google/root_conversation_id" : void 0;
|
|
305
|
+
const v = key === void 0 ? void 0 : meta?.[key];
|
|
280
306
|
return typeof v === "string" && v.length > 0 && v.length <= 256 ? v : void 0;
|
|
281
307
|
};
|
|
282
308
|
/**
|
|
@@ -287,16 +313,15 @@ function createServer(opts) {
|
|
|
287
313
|
const tool = (body) => async (...given) => {
|
|
288
314
|
const extra = given.length > 1 ? given[given.length - 1] : void 0;
|
|
289
315
|
const args = given.length > 1 ? given[0] : {};
|
|
290
|
-
const
|
|
291
|
-
const first = sessionFor(oc);
|
|
316
|
+
const conversation = conversationOf(extra ?? given[0]);
|
|
292
317
|
try {
|
|
293
|
-
return ok(await body(await
|
|
318
|
+
return ok(await body(await sessionFor(conversation), args));
|
|
294
319
|
} catch (err) {
|
|
295
320
|
if (!isSessionGone(err)) return fail(err);
|
|
296
|
-
|
|
321
|
+
forgetSession();
|
|
297
322
|
}
|
|
298
323
|
try {
|
|
299
|
-
return ok(await body(await sessionFor(
|
|
324
|
+
return ok(await body(await sessionFor(conversation), args));
|
|
300
325
|
} catch (err) {
|
|
301
326
|
return isSessionGone(err) ? fail(/* @__PURE__ */ new Error(SESSION_LOST_TEXT)) : fail(err);
|
|
302
327
|
}
|
|
@@ -478,7 +503,8 @@ async function runStdio(opts) {
|
|
|
478
503
|
launcherPaths: process.argv[1] ? [process.argv[1]] : []
|
|
479
504
|
}).then((a) => ({
|
|
480
505
|
hostPid: a.hostPid,
|
|
481
|
-
hostPids: a.pids
|
|
506
|
+
hostPids: a.pids,
|
|
507
|
+
variant: opts.cli === "antigravity" && isAntigravityApp(a.entries) ? "app" : void 0
|
|
482
508
|
}));
|
|
483
509
|
const client = await connect$1({
|
|
484
510
|
kind: "mcp",
|
|
@@ -489,7 +515,9 @@ async function runStdio(opts) {
|
|
|
489
515
|
cli: opts.cli,
|
|
490
516
|
client,
|
|
491
517
|
host,
|
|
492
|
-
cwd: process.cwd()
|
|
518
|
+
cwd: process.cwd(),
|
|
519
|
+
...process.ppid > 1 ? { parentPid: process.ppid } : {},
|
|
520
|
+
onExit: () => void stop().then(() => process.exit(0))
|
|
493
521
|
});
|
|
494
522
|
let stopping;
|
|
495
523
|
const stop = () => {
|