@conveno/cli 0.2.0-rc.8 → 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.
Files changed (32) hide show
  1. package/README.md +3 -5
  2. package/dist/{acp-YHhVx0Ya.js → acp-BUddItzP.js} +39 -7
  3. package/dist/{agy-relay-BS2NeFlh.js → agy-relay-BZ3d_-FS.js} +4 -2
  4. package/dist/{args-CGL-AmNd.js → args-CtyKPZuN.js} +29 -8
  5. package/dist/bin.js +16 -2
  6. package/dist/daemon.js +4 -3139
  7. package/dist/{daemonError-DJ-P55nH.js → daemonError-CDgEtvy7.js} +1 -1
  8. package/dist/dist-BNhTPp5p.js +4509 -0
  9. package/dist/{dist-BRjg9CLd.js → dist-BOwFdixw.js} +23 -50
  10. package/dist/{dist-CcoTmwrf.js → dist-CFsDqevs.js} +94 -56
  11. package/dist/dist-CNdqmI3E.js +1065 -0
  12. package/dist/{dist-BBdba94T.js → dist-CSSvrcKr.js} +1752 -708
  13. package/dist/{dist-B6Sm0MRT.js → dist-D6Xoip5W.js} +203 -62
  14. package/dist/{dist-WTkKRM39.js → dist-DAVtixeC.js} +19 -5
  15. package/dist/dist-DTMnNySx.js +989 -0
  16. package/dist/hook-BA-tI6Oc.js +208 -0
  17. package/dist/hook-entry-BwzBtAnd.js +1346 -0
  18. package/dist/hook-entry-Cgt5ZH1s.js +1 -0
  19. package/dist/{main-DrzHsV5y.js → main-kKnLA7Hj.js} +58 -21
  20. package/dist/{pick-Bi1yJDh6.js → pick-BsMvXuDo.js} +1 -1
  21. package/dist/run-PQBzaHv1.js +8193 -0
  22. package/dist/{runtime-Db_YT5Xg.js → runtime-0FMqklYn.js} +233 -122
  23. package/dist/{uninstall-D9rW_j7H.js → uninstall-DcxkIDpk.js} +556 -82
  24. package/dist/{watch-BrTWYf3Y.js → watch-BIepRTXJ.js} +29 -7
  25. package/package.json +14 -15
  26. package/dist/dist-B1EVHdIM.js +0 -504
  27. package/dist/dist-BlWWt5gx.js +0 -624
  28. package/dist/dist-C6cMQ00I.js +0 -793
  29. package/dist/hook-DxjJDCjz.js +0 -94
  30. package/dist/hook-entry-CrpZz5QW.js +0 -1
  31. package/dist/hook-entry-pHJioNgN.js +0 -2494
  32. package/dist/run-C32oP2c_.js +0 -5550
@@ -1,94 +0,0 @@
1
- import { n as connectOpts } from "./ctx-tYftvhz_.js";
2
- // src/hook.ts
3
- /**
4
- * Time allowed for the hook's own process-table query. Only the fallback runs it: the usual way to
5
- * find the host CLI is to ask the daemon (`session.hostOf`). When the query fails or runs out, the
6
- * hook falls back to its direct parent as the host.
7
- */
8
- const HOOK_ANCESTRY_TIMEOUT_MS = 1200;
9
- const NOTHING = {
10
- stdout: "",
11
- exitCode: 0
12
- };
13
- /**
14
- * The pid of the CLI that runs this hook, or undefined when there is nothing to deliver to.
15
- * The daemon walks the process chain (it keeps a warm query helper on Windows) and answers at once
16
- * when no session of this CLI is online, so the hook reads no process table in either case. When
17
- * the daemon cannot answer (an older daemon, a table it may not read), the hook reads the table
18
- * itself, as it always did, and `complete: false` keeps the direct-parent fallback.
19
- */
20
- async function findHostPid(ctx, client, cli, local) {
21
- if (ctx.hostLookup) {
22
- const { ppid, launcherPaths } = ctx.hostLookup;
23
- const r = await client["session.hostOf"]({
24
- cli,
25
- ppid,
26
- launcherPaths
27
- }).catch(() => void 0);
28
- if (r && !r.online) return void 0;
29
- if (r?.complete) return r.hostPid;
30
- }
31
- return (await local()).hostPid;
32
- }
33
- /**
34
- * `conveno hook <cli> <event>`: reads the CLI's hook JSON on stdin and prints what the adapter
35
- * returns. Never starts a daemon. A hook that fails or stalls must not hold the CLI up, so an
36
- * ordinary hook gives up after the context's timeout (2 s), never writes to stderr and exits 0.
37
- *
38
- * Listener events (the adapter's `listenEvents`) are the exception: they run in the background,
39
- * wait without the 2 s budget until a message arrives or their CLI goes away, and may exit 2 with
40
- * the message on stderr (Claude Code's `asyncRewake`). They stop on their own when the host CLI
41
- * exits, the session goes offline, or a newer listener replaces them.
42
- */
43
- /** After a timeout, the hook gets this many more timeouts' worth of time to finish recording. */
44
- const FINISH_GRACE_FACTOR = 2;
45
- /** How long before the hook's timeout its messages count as too late to print. */
46
- const DEADLINE_MARGIN_MS = 300;
47
- async function runHook(ctx, argv) {
48
- const [cli, event] = argv;
49
- const adapter = ctx.adapters.find((a) => a.cli === cli);
50
- if (!adapter || !event) return 0;
51
- const listener = adapter.listenEvents?.includes(event) === true;
52
- const deadline = listener ? void 0 : Date.now() + ctx.hookTimeoutMs - DEADLINE_MARGIN_MS;
53
- let client;
54
- let timer;
55
- const early = ctx.hostLookup ? void 0 : ctx.ancestry(HOOK_ANCESTRY_TIMEOUT_MS);
56
- const work = (async () => {
57
- const readInput = async () => {
58
- try {
59
- const raw = await ctx.readStdin();
60
- return raw.trim() === "" ? {} : JSON.parse(raw);
61
- } catch {
62
- return {};
63
- }
64
- };
65
- const [input, connected] = await Promise.all([readInput(), ctx.connect(connectOpts(ctx, false))]);
66
- client = connected;
67
- const hostPid = await findHostPid(ctx, connected, adapter.cli, () => early ?? ctx.ancestry(1200));
68
- if (hostPid === void 0) return NOTHING;
69
- return adapter.hook(event, input, {
70
- client,
71
- hostPid,
72
- cli: adapter.cli,
73
- isAlive: ctx.isAlive,
74
- ...deadline === void 0 ? {} : { deadline }
75
- });
76
- })();
77
- const timeout = listener ? new Promise(() => void 0) : new Promise((resolve) => {
78
- timer = setTimeout(() => resolve(NOTHING), ctx.hookTimeoutMs);
79
- });
80
- let code = 0;
81
- try {
82
- const out = await Promise.race([work, timeout]);
83
- if (out === NOTHING && !listener) await Promise.race([work.catch(() => void 0), new Promise((r) => setTimeout(r, ctx.hookTimeoutMs * FINISH_GRACE_FACTOR))]);
84
- if (out.stdout) ctx.out(out.stdout.endsWith("\n") ? out.stdout : `${out.stdout}\n`);
85
- if (listener && out.stderr) ctx.err(out.stderr.endsWith("\n") ? out.stderr : `${out.stderr}\n`);
86
- if (listener) code = out.exitCode;
87
- } catch {} finally {
88
- if (timer) clearTimeout(timer);
89
- work.catch(() => void 0);
90
- await Promise.race([client?.close().catch(() => void 0), new Promise((r) => setTimeout(r, 100))]);
91
- }
92
- return code;
93
- }
94
- export { runHook as t };
@@ -1 +0,0 @@
1
- export { i as runHookEntry } from "./hook-entry-pHJioNgN.js";