@conveno/cli 0.2.0-rc.13 → 0.2.0-rc.15
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-Bs6XS61j.js → acp-DZf0zyNC.js} +3 -3
- package/dist/{agy-relay-BJLRYbFp.js → agy-relay-DSRJtMz3.js} +3 -2
- package/dist/{args-C4rVCVXx.js → args-CpAvszNY.js} +13 -6
- package/dist/bin.js +2 -2
- package/dist/daemon.js +120 -12
- package/dist/{daemonError-CjxG2yUl.js → daemonError-Bj22X-4V.js} +1 -1
- package/dist/{dist-D4sb5RQD.js → dist-Bv1bmmme.js} +1 -1
- package/dist/{dist-CoRBNycn.js → dist-Bx22a5AV.js} +1 -1
- package/dist/{dist-B14ldKRS.js → dist-C4KljaIP.js} +1 -1
- package/dist/{dist-Ca3P7aN-.js → dist-C59LTq60.js} +9 -5
- package/dist/{dist-C9Z1EMlM.js → dist-DDzIkwf9.js} +1 -1
- package/dist/{dist-DnNuDzEA.js → dist-ZL7d4_97.js} +187 -75
- package/dist/{dist-BkhKEexU.js → dist-fI_XSoCQ.js} +192 -24
- package/dist/{hook-C60hXJdg.js → hook-BFZTvd7M.js} +1 -1
- package/dist/hook-entry-CmuvppGf.js +1 -0
- package/dist/{hook-entry-WlJSM5aD.js → hook-entry-CvzyjOo4.js} +6 -6
- package/dist/{main-I2RMN7XN.js → main-1QSm5UjR.js} +34 -60
- package/dist/{pick-Colav8Wm.js → pick-DaCRjuyz.js} +1 -1
- package/dist/{run-BuDbmxx_.js → run-CKiYjNqx.js} +276 -19
- package/dist/{runtime-CPmrhPFJ.js → runtime-CeFKWoIL.js} +37 -12
- package/dist/{uninstall-812XZDTG.js → uninstall-DK25hyWX.js} +80 -8
- package/dist/{watch-DXbOOc20.js → watch-De3wbdQL.js} +4 -4
- package/package.json +13 -13
- package/dist/hook-entry-jOfjq-0A.js +0 -1
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ Or run `conveno` with no arguments. It opens a full-screen app (Sessions, New, D
|
|
|
39
39
|
| `conveno send <to> <text...> [--urgent]` | Send a message as you to a session name or id, `lead`, or `device:name`. `-` reads the text from standard input. |
|
|
40
40
|
| `conveno rename <session> <new-name>` | Rename an online session. |
|
|
41
41
|
| `conveno lead <session>` | Make a session the lead. `conveno lead --clear` leaves no lead. |
|
|
42
|
-
| `conveno spawn <cli> [--cwd <dir>] [--name <name>] [--task <text> \| --task-file <path>] [--window] [--
|
|
42
|
+
| `conveno spawn <cli> [--cwd <dir>] [--name <name>] [--task <text> \| --task-file <path>] [--window] [--access <read\|edit\|full>] [--yes]` | Start a worker session of `claude`, `codex`, `opencode`, `antigravity` or `grok`, and print its name once it registers. The CLI must be installed. By default the worker runs in the background through the CLI's Agent Client Protocol server, with `conveno acp-host` driving it. It keeps running: each message sent to it becomes its next prompt at once when it is idle, or when its current turn ends. `--window` opens the real CLI in a new terminal instead, so you can watch it and take over: Windows Terminal (`wt -w 0 new-tab`, else a new console window) on Windows, Terminal.app (iTerm2 when it is your terminal) on macOS, and on Linux a new tmux window when you are inside tmux, else the first of `x-terminal-emulator`, `gnome-terminal`, `konsole`, `kitty`, `wezterm`, `alacritty` and `xterm`. The ACP commands are `claude-agent-acp` (install `@agentclientprotocol/claude-agent-acp`), `codex-acp` (install `@agentclientprotocol/codex-acp`), `opencode acp`, `agy acp` and `grok agent stdio`; a missing one is an error that says what to install. For Claude Code and Codex, `conveno init` can allow running the adapter with `npx -y <package>@<pinned version>`, and `CONVENO_ACP_CODEX_CMD` / `CONVENO_ACP_CLAUDE_CMD` replace the command. In the background a tool call the `--access` preset (`read`, `edit` or `full`; default `full`) does not cover is asked of the session that spawned the worker. The first task is optional. `--name` sets the session name (a taken or reserved one is refused); otherwise the usual `<cli>@<repo>-<n>` name is used. `--cwd` defaults to the current folder, which must be inside your home folder; an explicit `--cwd` can be anywhere. It asks first and `--yes` skips the question; without a terminal it exits 2 unless `--yes` is given. At most 8 spawned sessions run at once (`CONVENO_SPAWN_MAX` changes that), and a spawned session cannot spawn more than 3 levels deep. A task is at most 16000 characters. See `packages/protocol/PROTOCOL.md`. |
|
|
43
43
|
| `conveno stop <worker>` | Stop a background worker. It cancels a running turn, ends its CLI and the processes it started, tells the spawning session why, and goes offline. A worker in a window is yours to close. |
|
|
44
44
|
| `conveno doctor [--cli <list>]` | Check each CLI and the daemon, and say how to fix what is wrong. `--cli claude,codex` checks only those CLIs, so problems in the others do not count. |
|
|
45
45
|
| `conveno devices [pair\|join\|revoke\|rename\|accept\|reset]` | Pro. List your devices, or pair a new machine: `pair` on one device and `join` on the new one at the same time, then type the 8-digit code each screen shows. `revoke` removes a device for good. Needs a Pro login on both. |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { writeFileSync } from "node:fs";
|
|
2
|
-
import { n as runAcpHostFromFile, r as stopRequestPath, t as killProcessTree } from "./dist-
|
|
3
|
-
import {
|
|
4
|
-
import { a as parseFlags, n as COMMANDS } from "./args-
|
|
2
|
+
import { n as runAcpHostFromFile, r as stopRequestPath, t as killProcessTree } from "./dist-fI_XSoCQ.js";
|
|
3
|
+
import { Kt as readSpawnRecord, an as spawnRecordPath } from "./dist-ZL7d4_97.js";
|
|
4
|
+
import { a as parseFlags, n as COMMANDS } from "./args-CpAvszNY.js";
|
|
5
5
|
import { a as fail, n as cmd } from "./fmt-C2SsP5Y0.js";
|
|
6
6
|
// src/acp.ts
|
|
7
7
|
/** How long `conveno stop` waits for a worker to end by itself before it ends the process tree. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
|
-
import { t as RELAY_SUBCOMMAND } from "./dist-
|
|
3
|
-
import {
|
|
2
|
+
import { t as RELAY_SUBCOMMAND } from "./dist-Bv1bmmme.js";
|
|
3
|
+
import { nn as runWaker } from "./dist-ZL7d4_97.js";
|
|
4
4
|
import { n as connectOpts } from "./ctx-tYftvhz_.js";
|
|
5
5
|
// src/agy-relay.ts
|
|
6
6
|
/**
|
|
@@ -64,6 +64,7 @@ async function runAgyRelay(ctx, argv, deps = {}) {
|
|
|
64
64
|
ctx.out(`[conveno] ${RELAY_SUBCOMMAND} ended: ${why}\n`);
|
|
65
65
|
return code;
|
|
66
66
|
};
|
|
67
|
+
if (ctx.env.CONVENO_ACP_WORKER === "1") return 0;
|
|
67
68
|
if (argv.length > 0) return end("it takes no arguments.", 2);
|
|
68
69
|
const conversationId = ctx.env.ANTIGRAVITY_CONVERSATION_ID;
|
|
69
70
|
const exe = ctx.env.ANTIGRAVITY_AGENTAPI_EXE;
|
|
@@ -33,7 +33,7 @@ const SETUP_FLAGS = {
|
|
|
33
33
|
const COMMANDS = [
|
|
34
34
|
{
|
|
35
35
|
name: "setup",
|
|
36
|
-
usage: "conveno setup [--yes] [--dry-run] [--cli <list>] [--lead <cli>]",
|
|
36
|
+
usage: "conveno setup [--yes] [--dry-run] [--cli <list>] [--lead <cli>] [--worker-access <level>]",
|
|
37
37
|
summary: "Connect Conveno to your AI tools",
|
|
38
38
|
flags: {
|
|
39
39
|
...SETUP_FLAGS,
|
|
@@ -41,6 +41,11 @@ const COMMANDS = [
|
|
|
41
41
|
type: "string",
|
|
42
42
|
value: "<cli>",
|
|
43
43
|
help: "The AI tool that should lead when it starts, such as claude"
|
|
44
|
+
},
|
|
45
|
+
"worker-access": {
|
|
46
|
+
type: "string",
|
|
47
|
+
value: "<read|edit|full>",
|
|
48
|
+
help: "What background workers may do: read, edit or full (the default)"
|
|
44
49
|
}
|
|
45
50
|
},
|
|
46
51
|
notes: [
|
|
@@ -153,10 +158,10 @@ const COMMANDS = [
|
|
|
153
158
|
type: "boolean",
|
|
154
159
|
help: "Open the CLI in a terminal window you can watch, instead of the background"
|
|
155
160
|
},
|
|
156
|
-
|
|
161
|
+
access: {
|
|
157
162
|
type: "string",
|
|
158
|
-
value: "<
|
|
159
|
-
help: "Background:
|
|
163
|
+
value: "<read|edit|full>",
|
|
164
|
+
help: "Background: what the worker may do without asking (default: your setting, full unless changed)"
|
|
160
165
|
},
|
|
161
166
|
yes: {
|
|
162
167
|
type: "boolean",
|
|
@@ -165,11 +170,13 @@ const COMMANDS = [
|
|
|
165
170
|
}
|
|
166
171
|
},
|
|
167
172
|
notes: [
|
|
173
|
+
"--access sets what a background worker may do without asking: read (look only), edit (also",
|
|
174
|
+
"change files and fetch pages) or full (everything). Without it, your setting applies; full unless changed.",
|
|
168
175
|
"By default the worker runs in the background over ACP and stays alive. Each message sent to",
|
|
169
176
|
"it becomes its next prompt: right away when it is idle, else when its turn ends.",
|
|
170
177
|
"--window opens the real CLI in a new terminal instead, so you can watch it and take over.",
|
|
171
|
-
"In the background, tool calls
|
|
172
|
-
"
|
|
178
|
+
"In the background, tool calls the preset does not cover are asked of the session that spawned the worker,",
|
|
179
|
+
"and denied if nobody answers in time or there is nobody to ask.",
|
|
173
180
|
"Conveno's own tools, such as send, are always allowed.",
|
|
174
181
|
"claude and codex need an ACP adapter installed. End a worker with conveno stop.",
|
|
175
182
|
"Waits until the session registers, then prints its name.",
|
package/dist/bin.js
CHANGED
|
@@ -40,9 +40,9 @@ for (const stream of [process.stdout, process.stderr]) stream.on("error", (err)
|
|
|
40
40
|
});
|
|
41
41
|
try {
|
|
42
42
|
let code;
|
|
43
|
-
if (isHook) code = await (await import("./hook-entry-
|
|
43
|
+
if (isHook) code = await (await import("./hook-entry-CmuvppGf.js")).runHookEntry(argv.slice(1));
|
|
44
44
|
else {
|
|
45
|
-
const [{ main }, { createRuntimeCtx }] = await Promise.all([import("./main-
|
|
45
|
+
const [{ main }, { createRuntimeCtx }] = await Promise.all([import("./main-1QSm5UjR.js"), import("./runtime-CeFKWoIL.js")]);
|
|
46
46
|
code = await main(argv, createRuntimeCtx());
|
|
47
47
|
}
|
|
48
48
|
if (isHook) process.exit(code);
|
package/dist/daemon.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { homedir, hostname, userInfo } from "node:os";
|
|
3
|
-
import { t as codexAdapter } from "./dist-
|
|
4
|
-
import {
|
|
3
|
+
import { t as codexAdapter } from "./dist-DDzIkwf9.js";
|
|
4
|
+
import { $ as formatContinuation, $n as sanitizeLine, $t as resolveRecipient, A as claimOrchestrator, B as dataDir, Bn as defaultSocketPath, Bt as readAccountTokens, Ct as oneWindowPerHost, D as autoLimitsFromEnv, E as autoCandidates, En as EVENT_NAMES, Gn as makeEventNotification, Gt as readSettings, H as decideAutoContinue, In as SESSION_ENDED_TEXT, It as planSpawn, Jn as newMessageId, Kn as makeResult, L as createWmiWalker, M as clearOrchestrator, Mn as PROTOCOL_VERSION, N as clientProof, Nn as RelayPayload, O as baseName, Pn as RpcErrorCode, Qn as safeParse, R as currentAccessToken, Rn as SessionId, Rt as proofsMatch, S as appendHookLog, St as newAuthNonce, Tn as DeviceId, U as defaultProcessIo, Un as isSocketPathTooLong, Ut as readInbox, V as dataPaths, Vn as encodeFrame, Vt as readAncestry, W as detectRepo, Wn as makeError, Xn as parseIpcRequest, Xt as requeueEntries, Y as evaluateLiveness, Yn as newSessionId, Zn as parseRelayFrame, _ as ackEntries, _t as leadLogPath, bt as markDelivered, cn as statusAfterLiveness, dn as takeWithinChars, dt as isOnline, er as socketPathTooLongMessage, et as formatHookContext, fn as tooManyUnreadMessage, ft as jwtClaim, gn as validateRename, gt as leadLogLine, i as ConvenoError, jn as OWNER_SESSION_ID, k as bindAccountDevice, kn as Message, kt as pendingForInjection, l as RESPONSE_BUDGET_BYTES, n as AccountError, nt as generateSessionName, pn as turnHops, q as effectiveHolder, qn as newDeviceId, rt as holderAfterDeparture, un as takeWithinBytes, z as daemonProof, zn as createLineDecoder } from "./dist-ZL7d4_97.js";
|
|
5
5
|
import { randomBytes } from "node:crypto";
|
|
6
6
|
import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { connect, createServer } from "node:net";
|
|
8
8
|
import { dirname, join, posix, win32 } from "node:path";
|
|
9
|
-
import { _ as sasMatches, a as JoinerPairing, b as signRelayHello, c as decodePairMessage, d as forkPoint, f as generateIdentity, g as publicRecord, h as parseIdentity, i as InviterPairing, l as deviceFingerprint, m as openEnvelope, n as ENVELOPE_MAX_AGE_MS, o as appendRevoke, p as headMatches, r as ENVELOPE_MAX_FUTURE_MS, s as chainHead, t as CryptoError, u as encodePairMessage, v as sealEnvelope, x as verifyChain, y as serializeIdentity } from "./dist-
|
|
9
|
+
import { _ as sasMatches, a as JoinerPairing, b as signRelayHello, c as decodePairMessage, d as forkPoint, f as generateIdentity, g as publicRecord, h as parseIdentity, i as InviterPairing, l as deviceFingerprint, m as openEnvelope, n as ENVELOPE_MAX_AGE_MS, o as appendRevoke, p as headMatches, r as ENVELOPE_MAX_FUTURE_MS, s as chainHead, t as CryptoError, u as encodePairMessage, v as sealEnvelope, x as verifyChain, y as serializeIdentity } from "./dist-Bx22a5AV.js";
|
|
10
10
|
import { execFileSync } from "node:child_process";
|
|
11
11
|
import { DatabaseSync } from "node:sqlite";
|
|
12
12
|
// ../daemon/src/lifecycle.ts
|
|
@@ -1970,7 +1970,7 @@ var Store = class {
|
|
|
1970
1970
|
}
|
|
1971
1971
|
};
|
|
1972
1972
|
// ../daemon/src/server.ts
|
|
1973
|
-
const DAEMON_VERSION = "0.2.0-rc.
|
|
1973
|
+
const DAEMON_VERSION = "0.2.0-rc.15";
|
|
1974
1974
|
/** A connection that has not finished the handshake by then is closed. */
|
|
1975
1975
|
const AUTH_TIMEOUT_MS = 5e3;
|
|
1976
1976
|
/** Unread messages one session may hold. */
|
|
@@ -1991,6 +1991,8 @@ const WAKE_RETRY_MS = 15e3;
|
|
|
1991
1991
|
const WOKEN_STALL_MS = 3e4;
|
|
1992
1992
|
const WAKE_RETRY_MAX_MS = 3e5;
|
|
1993
1993
|
/** Sender id on `system` messages made by the daemon itself (no session sent them). */
|
|
1994
|
+
/** Permission requests one worker may have waiting at once. */
|
|
1995
|
+
const MAX_ASKS_PER_WORKER = 5;
|
|
1994
1996
|
const DAEMON_SENDER_ID = SessionId.parse("0".repeat(26));
|
|
1995
1997
|
const CLI_TIER = {
|
|
1996
1998
|
claude: "next_turn",
|
|
@@ -2012,6 +2014,7 @@ var Daemon = class {
|
|
|
2012
2014
|
platform;
|
|
2013
2015
|
wakers;
|
|
2014
2016
|
settingsPath;
|
|
2017
|
+
leadLog;
|
|
2015
2018
|
conns = /* @__PURE__ */ new Set();
|
|
2016
2019
|
/** Reaches the owner's other devices; set by startDaemon unless disabled. */
|
|
2017
2020
|
relay;
|
|
@@ -2042,6 +2045,10 @@ var Daemon = class {
|
|
|
2042
2045
|
wokenAt = /* @__PURE__ */ new Map();
|
|
2043
2046
|
idleSince;
|
|
2044
2047
|
startedMs;
|
|
2048
|
+
/** Permission requests of workers that wait for their spawner, by request id. In memory only. */
|
|
2049
|
+
/** When each session last sent a message (since this daemon started). */
|
|
2050
|
+
lastSent = /* @__PURE__ */ new Map();
|
|
2051
|
+
asks = /* @__PURE__ */ new Map();
|
|
2045
2052
|
/** When each session went offline, for the removal grace. In memory only. */
|
|
2046
2053
|
offlineSince = /* @__PURE__ */ new Map();
|
|
2047
2054
|
/**
|
|
@@ -2057,7 +2064,7 @@ var Daemon = class {
|
|
|
2057
2064
|
* Their heartbeats are refused, so a leftover MCP process cannot bring them back online.
|
|
2058
2065
|
*/
|
|
2059
2066
|
retired = /* @__PURE__ */ new Set();
|
|
2060
|
-
constructor(store, token, now, isAlive, idleExitMs, requestIdleExit, requestShutdown, log, authTimeoutMs = AUTH_TIMEOUT_MS, autoLimits = autoLimitsFromEnv({}), processIo = defaultProcessIo, platform = process.platform, wakers = {}, settingsPath) {
|
|
2067
|
+
constructor(store, token, now, isAlive, idleExitMs, requestIdleExit, requestShutdown, log, authTimeoutMs = AUTH_TIMEOUT_MS, autoLimits = autoLimitsFromEnv({}), processIo = defaultProcessIo, platform = process.platform, wakers = {}, settingsPath, leadLog) {
|
|
2061
2068
|
this.store = store;
|
|
2062
2069
|
this.token = token;
|
|
2063
2070
|
this.now = now;
|
|
@@ -2072,6 +2079,7 @@ var Daemon = class {
|
|
|
2072
2079
|
this.platform = platform;
|
|
2073
2080
|
this.wakers = wakers;
|
|
2074
2081
|
this.settingsPath = settingsPath;
|
|
2082
|
+
this.leadLog = leadLog;
|
|
2075
2083
|
this.deviceId = store.deviceId();
|
|
2076
2084
|
this.startedMs = now().getTime();
|
|
2077
2085
|
this.idleSince = this.startedMs;
|
|
@@ -2131,6 +2139,10 @@ var Daemon = class {
|
|
|
2131
2139
|
this.send(conn, makeError(req.id, RpcErrorCode.Unauthorized, unauthorizedMessage));
|
|
2132
2140
|
return;
|
|
2133
2141
|
}
|
|
2142
|
+
if (req.method === "permission.ask") {
|
|
2143
|
+
(async () => this.dispatch(conn, req))().then((result) => this.send(conn, makeResult(req.id, result)), (e) => this.sendError(conn, req.id, req.method, e));
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2134
2146
|
try {
|
|
2135
2147
|
const result = await this.dispatch(conn, req);
|
|
2136
2148
|
const flushed = req.method === "daemon.shutdown" ? this.requestShutdown : void 0;
|
|
@@ -2167,8 +2179,10 @@ var Daemon = class {
|
|
|
2167
2179
|
case "turn.end": return this.turnEnd(req.params);
|
|
2168
2180
|
case "turn.wake": return this.turnWake(conn, req.params);
|
|
2169
2181
|
case "daemon.shutdown": return { ok: true };
|
|
2170
|
-
case "orchestrator.claim": return this.claim(req.params.sessionId);
|
|
2182
|
+
case "orchestrator.claim": return this.claim(req.params.sessionId, req.params.via ?? "unknown");
|
|
2171
2183
|
case "orchestrator.clear": return this.clearLead(conn);
|
|
2184
|
+
case "permission.ask": return this.permissionAsk(req.params);
|
|
2185
|
+
case "permission.answer": return this.permissionAnswer(req.params);
|
|
2172
2186
|
case "message.send": return this.sendMessage(req.params);
|
|
2173
2187
|
case "owner.send": return this.ownerSend(conn, req.params);
|
|
2174
2188
|
case "message.inbox": return this.inbox(req.params);
|
|
@@ -2233,7 +2247,8 @@ var Daemon = class {
|
|
|
2233
2247
|
...row,
|
|
2234
2248
|
deliveryTier: tier
|
|
2235
2249
|
}, holder?.id === row.id, this.store.unreadCount(row.id) + this.stalledWoken(row.id)),
|
|
2236
|
-
wakeable: tier === "live" || tier === "acp"
|
|
2250
|
+
wakeable: tier === "live" || tier === "acp",
|
|
2251
|
+
...this.lastSent.has(row.id) ? { lastSentAt: this.lastSent.get(row.id) } : {}
|
|
2237
2252
|
};
|
|
2238
2253
|
}
|
|
2239
2254
|
/** The orchestrator as routing sees it: the holder, if it is online. */
|
|
@@ -2351,7 +2366,7 @@ var Daemon = class {
|
|
|
2351
2366
|
if (settings.leadCli !== row.cli) return;
|
|
2352
2367
|
if (settings.tools && !settings.tools.includes(row.cli)) return;
|
|
2353
2368
|
if (this.orchestratorNow() !== null) return;
|
|
2354
|
-
this.claim(row.id);
|
|
2369
|
+
this.claim(row.id, "preferred");
|
|
2355
2370
|
}
|
|
2356
2371
|
async registerAsync(p) {
|
|
2357
2372
|
return this.register(p, await this.detect(p));
|
|
@@ -2379,14 +2394,17 @@ var Daemon = class {
|
|
|
2379
2394
|
depart(sessionId, change) {
|
|
2380
2395
|
const before = this.store.holder();
|
|
2381
2396
|
const after = holderAfterDeparture(before, sessionId);
|
|
2397
|
+
const prevName = this.leadName(before);
|
|
2382
2398
|
this.store.tx(() => {
|
|
2383
2399
|
this.store.updateSession(sessionId, { status: "offline" });
|
|
2384
2400
|
if (after !== before) this.store.setHolder(after);
|
|
2385
2401
|
});
|
|
2402
|
+
this.logLead(prevName, before, after, "departed");
|
|
2386
2403
|
this.listeners.delete(sessionId);
|
|
2387
2404
|
this.woken.delete(sessionId);
|
|
2388
2405
|
this.attached.delete(sessionId);
|
|
2389
2406
|
this.hookAt.delete(sessionId);
|
|
2407
|
+
this.settleAsksOf(sessionId);
|
|
2390
2408
|
this.offlineSince.set(sessionId, this.now().getTime());
|
|
2391
2409
|
this.emitSession(sessionId, change);
|
|
2392
2410
|
if (after !== before) this.emit({
|
|
@@ -2428,10 +2446,12 @@ var Daemon = class {
|
|
|
2428
2446
|
};
|
|
2429
2447
|
const before = this.store.holder();
|
|
2430
2448
|
const after = holderAfterDeparture(before, sessionId);
|
|
2449
|
+
const prevName = this.leadName(before);
|
|
2431
2450
|
this.store.tx(() => {
|
|
2432
2451
|
if (after !== before) this.store.setHolder(after);
|
|
2433
2452
|
this.store.deleteSession(sessionId);
|
|
2434
2453
|
});
|
|
2454
|
+
this.logLead(prevName, before, after, "removed");
|
|
2435
2455
|
this.listeners.delete(sessionId);
|
|
2436
2456
|
this.woken.delete(sessionId);
|
|
2437
2457
|
this.wokenAt.delete(sessionId);
|
|
@@ -2439,6 +2459,7 @@ var Daemon = class {
|
|
|
2439
2459
|
this.offlineSince.delete(sessionId);
|
|
2440
2460
|
this.attached.delete(sessionId);
|
|
2441
2461
|
this.hookAt.delete(sessionId);
|
|
2462
|
+
this.settleAsksOf(sessionId);
|
|
2442
2463
|
this.emit({
|
|
2443
2464
|
event: "session.updated",
|
|
2444
2465
|
data: {
|
|
@@ -2694,13 +2715,16 @@ var Daemon = class {
|
|
|
2694
2715
|
const pids = this.attachedOf(into);
|
|
2695
2716
|
for (const q of this.attachedOf(from)) pids.add(q);
|
|
2696
2717
|
if (pid !== void 0) pids.add(pid);
|
|
2697
|
-
const
|
|
2718
|
+
const before = this.store.holder();
|
|
2719
|
+
const lead = before === from.id;
|
|
2720
|
+
const prevName = this.leadName(before);
|
|
2698
2721
|
this.store.tx(() => {
|
|
2699
2722
|
this.store.moveMailbox(from.id, into.id);
|
|
2700
2723
|
if (lead) this.store.setHolder(into.id);
|
|
2701
2724
|
this.store.updateSession(into.id, { lastSeenAt: this.iso() });
|
|
2702
2725
|
this.store.deleteSession(from.id);
|
|
2703
2726
|
});
|
|
2727
|
+
if (lead) this.logLead(prevName, before, into.id, "merged");
|
|
2704
2728
|
this.listeners.delete(from.id);
|
|
2705
2729
|
this.woken.delete(from.id);
|
|
2706
2730
|
this.attached.delete(from.id);
|
|
@@ -2740,11 +2764,27 @@ var Daemon = class {
|
|
|
2740
2764
|
this.hookAt.delete(r.id);
|
|
2741
2765
|
}
|
|
2742
2766
|
}
|
|
2743
|
-
|
|
2767
|
+
leadName(id) {
|
|
2768
|
+
return id ? this.store.getSession(id)?.name ?? null : null;
|
|
2769
|
+
}
|
|
2770
|
+
/** One line in `<dataDir>/logs/lead.log` when the holder changed. Never throws. */
|
|
2771
|
+
logLead(previous, before, after, via) {
|
|
2772
|
+
if (before === after || !this.leadLog) return;
|
|
2773
|
+
try {
|
|
2774
|
+
appendHookLog(this.leadLog, leadLogLine({
|
|
2775
|
+
at: this.now(),
|
|
2776
|
+
lead: this.leadName(after),
|
|
2777
|
+
previous,
|
|
2778
|
+
via
|
|
2779
|
+
}));
|
|
2780
|
+
} catch {}
|
|
2781
|
+
}
|
|
2782
|
+
claim(sessionId, via) {
|
|
2744
2783
|
this.requireSession(sessionId);
|
|
2745
2784
|
const rows = this.store.allSessions();
|
|
2746
2785
|
const holder = this.store.holder();
|
|
2747
2786
|
const res = claimOrchestrator(holder, sessionId, this.named(rows));
|
|
2787
|
+
const prevName = this.leadName(holder);
|
|
2748
2788
|
const at = this.iso();
|
|
2749
2789
|
const sent = [];
|
|
2750
2790
|
this.store.tx(() => {
|
|
@@ -2766,6 +2806,7 @@ var Daemon = class {
|
|
|
2766
2806
|
sent.push(m);
|
|
2767
2807
|
}
|
|
2768
2808
|
});
|
|
2809
|
+
this.logLead(prevName, holder, res.orchestrator, via);
|
|
2769
2810
|
if (res.notices.length > 0) {
|
|
2770
2811
|
this.emit({
|
|
2771
2812
|
event: "orchestrator.changed",
|
|
@@ -2783,10 +2824,74 @@ var Daemon = class {
|
|
|
2783
2824
|
previous: res.previous
|
|
2784
2825
|
};
|
|
2785
2826
|
}
|
|
2827
|
+
/**
|
|
2828
|
+
* A worker asks its spawner to allow a tool call. Resolves when the spawner answers, when
|
|
2829
|
+
* `timeoutMs` passes, or when the worker goes away. The request lives in memory only.
|
|
2830
|
+
*/
|
|
2831
|
+
permissionAsk(p) {
|
|
2832
|
+
const worker = this.requireOnline(p.sessionId);
|
|
2833
|
+
const spawner = worker.spawnedBy ? this.store.getSession(worker.spawnedBy) : void 0;
|
|
2834
|
+
if (!spawner || spawner.status === "offline") return Promise.resolve({ answer: "no_spawner" });
|
|
2835
|
+
let mine = 0;
|
|
2836
|
+
for (const a of this.asks.values()) if (a.worker === worker.id) mine++;
|
|
2837
|
+
if (mine >= MAX_ASKS_PER_WORKER) throw new ConvenoError(RpcErrorCode.LimitExceeded, `Session "${worker.name}" already has ${mine} permission requests waiting. Wait for an answer.`);
|
|
2838
|
+
let id = randomBytes(4).toString("base64url").slice(0, 6);
|
|
2839
|
+
while (this.asks.has(id)) id = randomBytes(4).toString("base64url").slice(0, 6);
|
|
2840
|
+
const what = `${p.title ?? "a tool call"} (${p.kind ?? "other"})`;
|
|
2841
|
+
const fallback = p.unanswered === "allow" ? "allow" : "deny";
|
|
2842
|
+
const at = this.iso();
|
|
2843
|
+
const m = {
|
|
2844
|
+
id: newMessageId(),
|
|
2845
|
+
from: DAEMON_SENDER_ID,
|
|
2846
|
+
to: spawner.id,
|
|
2847
|
+
kind: "system",
|
|
2848
|
+
body: {
|
|
2849
|
+
event: "permission.asked",
|
|
2850
|
+
detail: `${worker.name} wants to run: ${what}. Answer with the answer_permission tool: request ${id}, answer allow, always or deny. No answer in ${p.timeoutMs >= 6e4 && p.timeoutMs % 6e4 === 0 ? `${p.timeoutMs / 6e4} min` : `${Math.round(p.timeoutMs / 1e3)} s`}: ${fallback}.`
|
|
2851
|
+
},
|
|
2852
|
+
urgent: false,
|
|
2853
|
+
createdAt: at
|
|
2854
|
+
};
|
|
2855
|
+
this.store.insertMessage(m, spawner.id, at);
|
|
2856
|
+
this.emitMessage(m, spawner.id);
|
|
2857
|
+
return new Promise((resolve) => {
|
|
2858
|
+
const timer = setTimeout(() => this.settleAsk(id, { answer: "unanswered" }), p.timeoutMs);
|
|
2859
|
+
timer.unref();
|
|
2860
|
+
this.asks.set(id, {
|
|
2861
|
+
worker: worker.id,
|
|
2862
|
+
spawner: spawner.id,
|
|
2863
|
+
resolve,
|
|
2864
|
+
timer
|
|
2865
|
+
});
|
|
2866
|
+
});
|
|
2867
|
+
}
|
|
2868
|
+
permissionAnswer(p) {
|
|
2869
|
+
this.requireOnline(p.sessionId);
|
|
2870
|
+
const ask = this.asks.get(p.requestId);
|
|
2871
|
+
if (!ask) throw new ConvenoError(RpcErrorCode.NotFound, `No permission request "${p.requestId}". It was already answered, or it expired.`);
|
|
2872
|
+
if (ask.spawner !== p.sessionId) throw new ConvenoError(RpcErrorCode.PermissionRequired, `Only the session that spawned the worker can answer request "${p.requestId}".`);
|
|
2873
|
+
this.settleAsk(p.requestId, {
|
|
2874
|
+
answer: p.answer,
|
|
2875
|
+
by: p.sessionId
|
|
2876
|
+
});
|
|
2877
|
+
return { ok: true };
|
|
2878
|
+
}
|
|
2879
|
+
settleAsk(id, result) {
|
|
2880
|
+
const ask = this.asks.get(id);
|
|
2881
|
+
if (!ask) return;
|
|
2882
|
+
this.asks.delete(id);
|
|
2883
|
+
clearTimeout(ask.timer);
|
|
2884
|
+
ask.resolve(result);
|
|
2885
|
+
}
|
|
2886
|
+
/** The worker left: its waiting requests end as `worker_offline`. */
|
|
2887
|
+
settleAsksOf(worker) {
|
|
2888
|
+
for (const [id, a] of this.asks) if (a.worker === worker) this.settleAsk(id, { answer: "worker_offline" });
|
|
2889
|
+
}
|
|
2786
2890
|
clearLead(conn) {
|
|
2787
2891
|
this.requireCli(conn, "clear the lead");
|
|
2788
2892
|
const holder = this.store.holder();
|
|
2789
2893
|
const res = clearOrchestrator(holder, this.named(this.store.allSessions()));
|
|
2894
|
+
const prevName = this.leadName(holder);
|
|
2790
2895
|
const at = this.iso();
|
|
2791
2896
|
const sent = [];
|
|
2792
2897
|
this.store.tx(() => {
|
|
@@ -2808,6 +2913,7 @@ var Daemon = class {
|
|
|
2808
2913
|
sent.push(m);
|
|
2809
2914
|
}
|
|
2810
2915
|
});
|
|
2916
|
+
this.logLead(prevName, holder, null, "clear");
|
|
2811
2917
|
if (holder !== null) {
|
|
2812
2918
|
this.emit({
|
|
2813
2919
|
event: "orchestrator.changed",
|
|
@@ -2825,12 +2931,14 @@ var Daemon = class {
|
|
|
2825
2931
|
const sender = this.requireSession(p.sessionId);
|
|
2826
2932
|
if (sender.status === "offline") throw new ConvenoError(RpcErrorCode.NotFound, `Session "${sender.name}" is offline. Register the session again before sending.`);
|
|
2827
2933
|
if (p.kind === "system") throw new ConvenoError(RpcErrorCode.InvalidParams, "Messages of kind \"system\" are made by the Conveno daemon only. Send kind \"text\" instead.");
|
|
2828
|
-
|
|
2934
|
+
const sent = this.deliverFrom({
|
|
2829
2935
|
id: sender.id,
|
|
2830
2936
|
name: sender.name,
|
|
2831
2937
|
cli: sender.cli,
|
|
2832
2938
|
hops: sender.status === "busy" ? sender.turnHops : 0
|
|
2833
2939
|
}, p);
|
|
2940
|
+
this.lastSent.set(sender.id, this.iso());
|
|
2941
|
+
return sent;
|
|
2834
2942
|
}
|
|
2835
2943
|
/** The recipient names the owner: `you`, or the id of a message the owner sent. */
|
|
2836
2944
|
isOwnerRecipient(to) {
|
|
@@ -3379,7 +3487,7 @@ async function startDaemon(opts) {
|
|
|
3379
3487
|
close().then(() => opts.onIdleExit?.());
|
|
3380
3488
|
}, () => {
|
|
3381
3489
|
close().then(() => opts.onShutdown?.());
|
|
3382
|
-
}, daemonLog, opts.authTimeoutMs ?? 5e3, opts.autoLimits ?? autoLimitsFromEnv(process.env), processIo, opts.platform, opts.wakers ?? {}, paths.settings);
|
|
3490
|
+
}, daemonLog, opts.authTimeoutMs ?? 5e3, opts.autoLimits ?? autoLimitsFromEnv(process.env), processIo, opts.platform, opts.wakers ?? {}, paths.settings, leadLogPath(opts.dataDir));
|
|
3383
3491
|
daemon.removeAllOffline();
|
|
3384
3492
|
const srv = createServer((socket) => daemon.attach(socket));
|
|
3385
3493
|
server = srv;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile, readdir } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { At as pendingHookContext, B as dataDir, G as dropFromList, J as endTurnContinuation, K as editJson, P as compareVersions, Pt as planLauncher, Tt as parseCliVersion, X as existedBefore, mn as uninstallLauncher, pt as late, rn as sameJson, ut as isObject, vt as loadJson, w as askedMarker, wt as ownSession, x as agentCommand, xt as needsQuoting } from "./dist-ZL7d4_97.js";
|
|
4
4
|
// ../adapters/antigravity/dist/index.js
|
|
5
5
|
const SERVER_NAME = "conveno";
|
|
6
6
|
/** The name of our entry in hooks.json. Antigravity keys hooks by an arbitrary name. */
|
|
@@ -2,7 +2,7 @@ import { randomBytes as randomBytes$1 } from "@noble/ciphers/utils.js";
|
|
|
2
2
|
import { equalBytes } from "@noble/curves/utils.js";
|
|
3
3
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
4
4
|
import { bytesToHex, concatBytes, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
5
|
-
import {
|
|
5
|
+
import { Tn as DeviceId, ar as literal, cr as string, ir as discriminatedUnion, nr as array, or as number, sr as object, tr as _enum } from "./dist-ZL7d4_97.js";
|
|
6
6
|
import { ed25519, x25519 } from "@noble/curves/ed25519.js";
|
|
7
7
|
import { chacha20poly1305 } from "@noble/ciphers/chacha.js";
|
|
8
8
|
import { expand, extract } from "@noble/hashes/hkdf.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { At as pendingHookContext, C as askedKey, G as dropFromList, Ht as readCommandLine, J as endTurnContinuation, K as editJson, Pt as planLauncher, Tt as parseCliVersion, U as defaultProcessIo, X as existedBefore, a as FROM_USER_NOTICE, c as ORCHESTRATOR_TASK_NOTICE, mn as uninstallLauncher, pt as late, rn as sameJson, s as NOT_FROM_USER_NOTICE, st as hostPidOf, ut as isObject, vt as loadJson, w as askedMarker, wt as ownSession, x as agentCommand, xt as needsQuoting, zt as putInList } from "./dist-ZL7d4_97.js";
|
|
4
4
|
import { n as cs, t as Za } from "./toml-patch-DGzVRdd1.js";
|
|
5
5
|
// ../adapters/grok/dist/index.js
|
|
6
6
|
const SERVER_NAME = "conveno";
|
|
@@ -3,7 +3,7 @@ import { mkdir, open, readFile, rm, stat } from "node:fs/promises";
|
|
|
3
3
|
import { createConnection } from "node:net";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
|
-
import {
|
|
6
|
+
import { B as dataDir, Bn as defaultSocketPath, Fn as RpcResponse, Hn as ipcMethods, Mn as PROTOCOL_VERSION, N as clientProof, On as EventPayload, Pn as RpcErrorCode, Rt as proofsMatch, St as newAuthNonce, Un as isSocketPathTooLong, V as dataPaths, Vn as encodeFrame, er as socketPathTooLongMessage, i as ConvenoError, z as daemonProof, zn as createLineDecoder } from "./dist-ZL7d4_97.js";
|
|
7
7
|
// ../client/dist/index.js
|
|
8
8
|
const DEFAULT_REQUEST_TIMEOUT_MS = 5e3;
|
|
9
9
|
const DEFAULT_START_TIMEOUT_MS = 1e4;
|
|
@@ -26,6 +26,8 @@ const CLIENT_METHODS = [
|
|
|
26
26
|
"session.list",
|
|
27
27
|
"orchestrator.claim",
|
|
28
28
|
"orchestrator.clear",
|
|
29
|
+
"permission.ask",
|
|
30
|
+
"permission.answer",
|
|
29
31
|
"message.send",
|
|
30
32
|
"message.inbox",
|
|
31
33
|
"message.deliver",
|
|
@@ -54,6 +56,7 @@ const NOT_REPLAYABLE = /* @__PURE__ */ new Set([
|
|
|
54
56
|
"daemon.shutdown",
|
|
55
57
|
"turn.end",
|
|
56
58
|
"turn.wake",
|
|
59
|
+
"permission.ask",
|
|
57
60
|
"devices.pair",
|
|
58
61
|
"devices.pairConfirm",
|
|
59
62
|
"devices.revoke",
|
|
@@ -186,14 +189,14 @@ var Connection = class {
|
|
|
186
189
|
p.reject(e);
|
|
187
190
|
}
|
|
188
191
|
}
|
|
189
|
-
call(method, params) {
|
|
192
|
+
call(method, params, timeoutMs = this.timeoutMs) {
|
|
190
193
|
if (this.closed) return Promise.reject(new ConnectionLost("Connection to the Conveno daemon is closed.", false));
|
|
191
194
|
const id = this.nextId++;
|
|
192
195
|
return new Promise((resolve, reject) => {
|
|
193
196
|
const timer = setTimeout(() => {
|
|
194
197
|
this.pending.delete(id);
|
|
195
|
-
reject(new ClientError(`Request ${method} timed out after ${
|
|
196
|
-
},
|
|
198
|
+
reject(new ClientError(`Request ${method} timed out after ${timeoutMs} ms. Check that the daemon is running with "conveno daemon status".`, { kind: "connection" }));
|
|
199
|
+
}, timeoutMs);
|
|
197
200
|
this.pending.set(id, {
|
|
198
201
|
resolve,
|
|
199
202
|
reject,
|
|
@@ -397,8 +400,9 @@ var Link = class {
|
|
|
397
400
|
if (this.closed) throw new ClientError("The Conveno client is closed.");
|
|
398
401
|
const used = this.conn;
|
|
399
402
|
let result;
|
|
403
|
+
const wait = method === "permission.ask" ? wire.timeoutMs + 1e4 : void 0;
|
|
400
404
|
try {
|
|
401
|
-
result = await used.call(method, wire);
|
|
405
|
+
result = await used.call(method, wire, wait);
|
|
402
406
|
} catch (e) {
|
|
403
407
|
if (!(e instanceof ConnectionLost) || this.closed) throw plainError(e, this.socketPath);
|
|
404
408
|
if (e.sent && NOT_REPLAYABLE.has(method)) {
|
|
@@ -2,7 +2,7 @@ import { execFile, spawn } from "node:child_process";
|
|
|
2
2
|
import { readFileSync, statSync } from "node:fs";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
-
import {
|
|
5
|
+
import { At as pendingHookContext, Ft as planProgram, It as planSpawn, J as endTurnContinuation, Q as findOnPath, Tt as parseCliVersion, sn as startTurnContext, wt as ownSession } from "./dist-ZL7d4_97.js";
|
|
6
6
|
import { n as cs, t as Za } from "./toml-patch-DGzVRdd1.js";
|
|
7
7
|
// ../adapters/codex/dist/index.js
|
|
8
8
|
const SERVER_NAME = "conveno";
|