@conveno/cli 0.2.0-rc.6 → 0.2.0-rc.7
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/dist/{acp-3xehqLdo.js → acp-9pRRszwU.js} +3 -3
- package/dist/agy-relay-C-nqvieJ.js +137 -0
- package/dist/{args-D9T-6TDw.js → args-C7Agak9f.js} +9 -3
- package/dist/bin.js +2 -2
- package/dist/daemon.js +65 -20
- package/dist/{daemonError-CdLataBW.js → daemonError-DNAKEyRT.js} +1 -1
- package/dist/{dist-BTLBO1Rp.js → dist-D2hMvcZu.js} +291 -139
- package/dist/dist-D9Gu-mQm.js +547 -0
- package/dist/dist-DOGlDbRb.js +504 -0
- package/dist/{dist-BAlMjYqQ.js → dist-DOKVrSIw.js} +3 -3
- package/dist/dist-Dd31Fg0h.js +671 -0
- package/dist/{dist-BYVibI3a.js → dist-ftx5RNCp.js} +1 -1
- package/dist/{dist-DIAtMDWW.js → dist-iFaY42Bs.js} +1 -1
- package/dist/{doctor-DjwXJvKw.js → doctor-BYa-MApu.js} +91 -16
- package/dist/{hook-BGJc4PHG.js → hook-CQeSn-w4.js} +5 -1
- package/dist/{hook-entry-BWWJS7n3.js → hook-entry-BXmSN--S.js} +611 -743
- package/dist/hook-entry-CgiSN-Oj.js +1 -0
- package/dist/{main-CRw-fISR.js → main-seh-HPZO.js} +12 -12
- package/dist/{pick-B-18E4Mx.js → pick-DoyocW55.js} +1 -1
- package/dist/{run-Yi48fiJN.js → run-B-WfNtCX.js} +271 -229
- package/dist/{runtime-DyknkzAS.js → runtime-Bnjh9BQ8.js} +18 -9
- package/dist/{dist-CNyzLyZh.js → toml-patch-DGzVRdd1.js} +20 -497
- package/dist/watch-Dr2RdyGo.js +185 -0
- package/package.json +15 -15
- package/dist/dist-LkcRvVjE.js +0 -449
- package/dist/hook-entry-rDISaMgP.js +0 -1
- package/dist/sidecar-CTKxOMie.js +0 -98
- package/dist/watch-CfYanJvt.js +0 -109
package/dist/sidecar-CTKxOMie.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { n as conversationOf } from "./dist-LkcRvVjE.js";
|
|
2
|
-
import { jt as runWaker } from "./dist-BTLBO1Rp.js";
|
|
3
|
-
import { n as connectOpts } from "./ctx-tYftvhz_.js";
|
|
4
|
-
// src/sidecar.ts
|
|
5
|
-
/**
|
|
6
|
-
* Send text into an Antigravity conversation as the user: the same as typing it, and it starts a
|
|
7
|
-
* turn even when the conversation is idle. `--as-user` is only allowed for sidecars. Antigravity
|
|
8
|
-
* hands a sidecar `ANTIGRAVITY_LS_ADDRESS` and `ANTIGRAVITY_CSRF_TOKEN` (the child inherits them)
|
|
9
|
-
* and puts `agentapi` on its PATH; on Windows `ANTIGRAVITY_AGENTAPI_EXE` must name the real exe, since
|
|
10
|
-
* the `.bat` shim would re-parse the text (command injection); without one nothing is sent.
|
|
11
|
-
*/
|
|
12
|
-
async function sendToConversation(ctx, conversationId, text) {
|
|
13
|
-
const tail = [
|
|
14
|
-
"send-message",
|
|
15
|
-
"--as-user",
|
|
16
|
-
conversationId,
|
|
17
|
-
text
|
|
18
|
-
];
|
|
19
|
-
const exe = ctx.env.ANTIGRAVITY_AGENTAPI_EXE;
|
|
20
|
-
if ((ctx.platform ?? process.platform) === "win32" && !(exe && /\.exe$/i.test(exe))) return false;
|
|
21
|
-
const attempts = exe ? [[exe, tail]] : [["agentapi", tail], ["agy", ["agentapi", ...tail]]];
|
|
22
|
-
for (const [cmd, args] of attempts) try {
|
|
23
|
-
return (await ctx.exec(cmd, args)).code === 0;
|
|
24
|
-
} catch (e) {
|
|
25
|
-
if (e?.code !== "ENOENT") return false;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* `conveno sidecar antigravity` (hidden): started by Antigravity itself from the sidecar manifest
|
|
31
|
-
* Conveno installs. Runs the shared waker for every online Antigravity session whose conversation
|
|
32
|
-
* the hooks have recorded, and sends each batch into that conversation. Exits when `signal` aborts.
|
|
33
|
-
*/
|
|
34
|
-
async function runSidecar(ctx, argv, deps = {}) {
|
|
35
|
-
if (argv[0] !== "antigravity") {
|
|
36
|
-
ctx.err("conveno sidecar: the only sidecar is antigravity.\n");
|
|
37
|
-
return 2;
|
|
38
|
-
}
|
|
39
|
-
const runWaker$1 = deps.runWaker ?? runWaker;
|
|
40
|
-
const pollMs = deps.pollMs ?? 3e3;
|
|
41
|
-
const signal = deps.signal ?? new AbortController().signal;
|
|
42
|
-
const running = /* @__PURE__ */ new Map();
|
|
43
|
-
let client;
|
|
44
|
-
const stop = async (id) => {
|
|
45
|
-
const r = running.get(id);
|
|
46
|
-
if (!r) return;
|
|
47
|
-
running.delete(id);
|
|
48
|
-
r.abort.abort();
|
|
49
|
-
await r.done.catch(() => void 0);
|
|
50
|
-
};
|
|
51
|
-
const sleep = (ms) => new Promise((resolve) => {
|
|
52
|
-
const t = setTimeout(resolve, ms);
|
|
53
|
-
signal.addEventListener("abort", () => {
|
|
54
|
-
clearTimeout(t);
|
|
55
|
-
resolve();
|
|
56
|
-
}, { once: true });
|
|
57
|
-
});
|
|
58
|
-
while (!signal.aborted) {
|
|
59
|
-
try {
|
|
60
|
-
client ??= await ctx.connect(connectOpts(ctx, false));
|
|
61
|
-
const { sessions } = await client["session.list"]({ cli: "antigravity" });
|
|
62
|
-
const live = /* @__PURE__ */ new Set();
|
|
63
|
-
for (const s of sessions) {
|
|
64
|
-
if (s.status === "offline") continue;
|
|
65
|
-
const conversationId = await conversationOf(s.id, deps.conversationsBase);
|
|
66
|
-
if (!conversationId) continue;
|
|
67
|
-
live.add(s.id);
|
|
68
|
-
if (running.get(s.id)?.conversationId === conversationId) continue;
|
|
69
|
-
await stop(s.id);
|
|
70
|
-
const abort = new AbortController();
|
|
71
|
-
const done = runWaker$1({
|
|
72
|
-
client: await ctx.connect(connectOpts(ctx, false)),
|
|
73
|
-
sessionId: s.id,
|
|
74
|
-
signal: abort.signal,
|
|
75
|
-
inject: (text) => sendToConversation(ctx, conversationId, text)
|
|
76
|
-
}).then(() => void 0, () => void 0);
|
|
77
|
-
done.then(() => {
|
|
78
|
-
if (running.get(s.id)?.abort === abort) running.delete(s.id);
|
|
79
|
-
});
|
|
80
|
-
running.set(s.id, {
|
|
81
|
-
conversationId,
|
|
82
|
-
abort,
|
|
83
|
-
done
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
for (const id of [...running.keys()]) if (!live.has(id)) await stop(id);
|
|
87
|
-
} catch {
|
|
88
|
-
await client?.close().catch(() => void 0);
|
|
89
|
-
client = void 0;
|
|
90
|
-
for (const id of [...running.keys()]) await stop(id);
|
|
91
|
-
}
|
|
92
|
-
await sleep(pollMs);
|
|
93
|
-
}
|
|
94
|
-
for (const id of [...running.keys()]) await stop(id);
|
|
95
|
-
await client?.close().catch(() => void 0);
|
|
96
|
-
return 0;
|
|
97
|
-
}
|
|
98
|
-
export { runSidecar };
|
package/dist/watch-CfYanJvt.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { Ct as renderBody, Nt as senderOf, Y as isFromOwner, jt as runWaker } from "./dist-BTLBO1Rp.js";
|
|
2
|
-
import { n as connectOpts } from "./ctx-tYftvhz_.js";
|
|
3
|
-
import { t as daemonProblem } from "./daemonError-CdLataBW.js";
|
|
4
|
-
import { t as findSession } from "./pick-B-18E4Mx.js";
|
|
5
|
-
const NAME_CHARS = 40;
|
|
6
|
-
/**
|
|
7
|
-
* Control, bidi and zero-width characters. Newlines and their lookalikes are in here: a peer's text
|
|
8
|
-
* must never start a line of its own, because every line of the monitor is taken as Conveno's.
|
|
9
|
-
*/
|
|
10
|
-
const INVISIBLE = /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u180e\u200b-\u200f\u2028-\u202e\u2060-\u206f\ufeff\ufff9-\ufffb]+/g;
|
|
11
|
-
/**
|
|
12
|
-
* Text from another session as one safe piece of a line: no line breaks or invisible characters, no
|
|
13
|
-
* angle brackets (Grok wraps events in a `<monitor-event>` tag, monitor/event.rs:105) and no double
|
|
14
|
-
* quotes (they close the quoted body). Cut at `max` characters; the flag says it was cut.
|
|
15
|
-
*/
|
|
16
|
-
function oneLine(text, max) {
|
|
17
|
-
const flat = text.replace(INVISIBLE, " ").replace(/\s+/g, " ").replace(/</g, "‹").replace(/>/g, "›").replace(/"/g, "'").trim();
|
|
18
|
-
const chars = Array.from(flat);
|
|
19
|
-
if (chars.length <= max) return {
|
|
20
|
-
text: flat,
|
|
21
|
-
cut: false
|
|
22
|
-
};
|
|
23
|
-
return {
|
|
24
|
-
text: `${chars.slice(0, max - 3).join("")}...`,
|
|
25
|
-
cut: true
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
const READ_FULL = "full text: inbox tool, unread_only false";
|
|
29
|
-
function lineOf(m, orchestrator) {
|
|
30
|
-
const body = oneLine(renderBody(m), 260);
|
|
31
|
-
const tail = body.cut || m.kind !== "text" ? ` (${READ_FULL})` : "";
|
|
32
|
-
if (isFromOwner(m)) return `[conveno] The user sent a message through Conveno: "${body.text}"${tail}`;
|
|
33
|
-
const sender = senderOf(m);
|
|
34
|
-
const who = `${oneLine(sender.name, NAME_CHARS).text} (${sender.cli})`;
|
|
35
|
-
return orchestrator !== null && m.from === orchestrator && m.kind !== "system" ? `[conveno] Task from the lead ${who}: "${body.text}"${tail}` : `[conveno] ${who} sent a message (not from the user): "${body.text}"${tail}`;
|
|
36
|
-
}
|
|
37
|
-
/** The lines one batch of messages prints: one per message, then a pointer for the rest. */
|
|
38
|
-
function watchLines(messages, orchestrator) {
|
|
39
|
-
const lines = messages.slice(0, 5).map((m) => lineOf(m, orchestrator));
|
|
40
|
-
const more = messages.length - lines.length;
|
|
41
|
-
if (more > 0) lines.push(`[conveno] ${more} more message${more === 1 ? "" : "s"} (${READ_FULL}).`);
|
|
42
|
-
return lines;
|
|
43
|
-
}
|
|
44
|
-
const USAGE = "[conveno] watch needs a session name. The conveno whoami tool gives it.";
|
|
45
|
-
/** Reasons the waker stops that are not a failure of the watcher. */
|
|
46
|
-
const CLEAN_STOPS = /* @__PURE__ */ new Set([
|
|
47
|
-
"aborted",
|
|
48
|
-
"superseded",
|
|
49
|
-
"offline",
|
|
50
|
-
"host_exited",
|
|
51
|
-
"timeout"
|
|
52
|
-
]);
|
|
53
|
-
const STOP_TEXT = {
|
|
54
|
-
superseded: "another watcher for this session started",
|
|
55
|
-
offline: "the session went offline",
|
|
56
|
-
host_exited: "the session's CLI exited",
|
|
57
|
-
timeout: "the time limit passed",
|
|
58
|
-
disconnected: "the connection to Conveno's background service broke"
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Runs until the session goes away, another watcher takes over, or the process is stopped. Prints
|
|
62
|
-
* nothing but `[conveno]` lines, on stdout, because Grok reads the monitor's stdout.
|
|
63
|
-
*/
|
|
64
|
-
async function runWatch(ctx, argv, deps = {}) {
|
|
65
|
-
const [name, ...extra] = argv;
|
|
66
|
-
if (!name || extra.length > 0) {
|
|
67
|
-
ctx.out(`${USAGE}\n`);
|
|
68
|
-
return 2;
|
|
69
|
-
}
|
|
70
|
-
const end = (why, code) => {
|
|
71
|
-
ctx.out(`[conveno] watch ended: ${why}.\n`);
|
|
72
|
-
return code;
|
|
73
|
-
};
|
|
74
|
-
let client;
|
|
75
|
-
try {
|
|
76
|
-
client = await ctx.connect(connectOpts(ctx, false));
|
|
77
|
-
} catch (e) {
|
|
78
|
-
return end(daemonProblem(ctx.theme, e).notRunning ? "Conveno's background service is not running" : "Conveno's background service cannot be reached", 1);
|
|
79
|
-
}
|
|
80
|
-
const controller = new AbortController();
|
|
81
|
-
const stop = () => controller.abort();
|
|
82
|
-
deps.signal?.addEventListener("abort", stop, { once: true });
|
|
83
|
-
if (deps.signal?.aborted) stop();
|
|
84
|
-
const signals = deps.signal ? [] : ["SIGINT", "SIGTERM"];
|
|
85
|
-
for (const s of signals) process.once(s, stop);
|
|
86
|
-
try {
|
|
87
|
-
const session = await findSession(client, name);
|
|
88
|
-
if (!session) return end(`no session named "${oneLine(name, NAME_CHARS).text}"`, 1);
|
|
89
|
-
if (session.status === "offline") return end("the session is offline", 1);
|
|
90
|
-
const reason = await (deps.runWaker ?? runWaker)({
|
|
91
|
-
client,
|
|
92
|
-
sessionId: session.id,
|
|
93
|
-
signal: controller.signal,
|
|
94
|
-
inject: async (_text, messages, batch) => {
|
|
95
|
-
const lines = watchLines(messages, batch?.orchestrator ?? null);
|
|
96
|
-
if (lines.length === 0) return true;
|
|
97
|
-
ctx.out(`${lines.join("\n")}\n`);
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
if (reason === "aborted") return 0;
|
|
102
|
-
return end(STOP_TEXT[reason] ?? reason, CLEAN_STOPS.has(reason) ? 0 : 1);
|
|
103
|
-
} finally {
|
|
104
|
-
deps.signal?.removeEventListener("abort", stop);
|
|
105
|
-
for (const s of signals) process.off(s, stop);
|
|
106
|
-
await client.close().catch(() => void 0);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
export { runWatch };
|