sessionpipe 0.6.0 → 0.6.1

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/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // sessionpipe 0.6.0 · Apache-2.0 · https://sessionpipe.org
2
+ // sessionpipe 0.6.1 · Apache-2.0 · https://sessionpipe.org
3
3
  var __defProp = Object.defineProperty;
4
4
  var __export = (target, all) => {
5
5
  for (var name in all)
@@ -381,20 +381,19 @@ function installedClaudeShaped(file, harness, events, cmd2, o) {
381
381
  // ../core/src/adapters/antigravity.ts
382
382
  var NAME = "antigravity";
383
383
  var HOOK_NAME = "sessionpipe";
384
- var AG_EVENTS = ["PreInvocation", "PostInvocation", "PreToolUse", "PostToolUse", "Stop"];
384
+ var AG_EVENTS = ["PreInvocation", "PostInvocation", "PostToolUse", "Stop"];
385
+ var AG_STALE_PRETOOL = '{"decision":"ask","reason":"sessionpipe: an outdated PreToolUse hook is still loaded. Restart this conversation (or run sessionpipe install) to drop it."}\n';
386
+ var antigravityAnswer = (event) => event === "PreToolUse" ? AG_STALE_PRETOOL : "{}\n";
385
387
  var gemini = (env) => env.GEMINI_CLI_HOME || path4.join(HOME, ".gemini");
386
388
  var hooksFile = (env) => path4.join(gemini(env), "config", "hooks.json");
387
389
  var projectsDir = (env) => path4.join(gemini(env), "config", "projects");
388
390
  var dataDirs = (env) => ["antigravity", "antigravity-cli", "antigravity-ide"].map((d) => path4.join(gemini(env), d));
389
391
  var ID_RE = /^[A-Za-z0-9_-]{1,128}$/;
390
392
  var validTool = (n) => typeof n === "string" && /^[A-Za-z0-9_.:-]{1,120}$/.test(n);
391
- function entry(cmd2, lean) {
393
+ function entry(cmd2) {
392
394
  const handler = (e) => ({ type: "command", command: cmd2([NAME, e]).command, timeout: 5 });
393
395
  const out2 = { enabled: true };
394
- for (const e of AG_EVENTS) {
395
- if (lean && e === "PreToolUse") continue;
396
- out2[e] = /Tool/.test(e) ? [{ matcher: "*", hooks: [handler(e)] }] : [handler(e)];
397
- }
396
+ for (const e of AG_EVENTS) out2[e] = /Tool/.test(e) ? [{ matcher: "*", hooks: [handler(e)] }] : [handler(e)];
398
397
  return out2;
399
398
  }
400
399
  var antigravity = {
@@ -402,12 +401,12 @@ var antigravity = {
402
401
  events: AG_EVENTS,
403
402
  detect: (env = process.env) => existsSync2(path4.join(gemini(env), "config")) || dataDirs(env).some((d) => existsSync2(d)),
404
403
  configFiles: (env = process.env) => [hooksFile(env)],
405
- install(cmd2, env = process.env, opts = {}) {
404
+ install(cmd2, env = process.env) {
406
405
  const file = hooksFile(env);
407
406
  const f = readJsonFile(file);
408
407
  if (!f.ok) return [{ file, changed: false, skipped: true, note: `${f.reason}; not touched` }];
409
408
  const hooks = f.value;
410
- const e = entry(cmd2, opts.lean);
409
+ const e = entry(cmd2);
411
410
  if (JSON.stringify(hooks[HOOK_NAME]) === JSON.stringify(e)) return [{ file, changed: false }];
412
411
  hooks[HOOK_NAME] = e;
413
412
  mkdirSync2(path4.dirname(file), { recursive: true });
@@ -436,14 +435,14 @@ var antigravity = {
436
435
  writeFileSync2(file, formatJson(hooks, f));
437
436
  return [{ file, changed: true }];
438
437
  },
439
- installed(cmd2, env = process.env, opts = {}) {
438
+ installed(cmd2, env = process.env) {
440
439
  const file = hooksFile(env);
441
440
  const f = readJsonFile(file);
442
441
  const have = f.ok ? f.value[HOOK_NAME] : void 0;
443
442
  return [
444
443
  {
445
444
  file,
446
- state: !have ? "missing" : JSON.stringify(have) === JSON.stringify(entry(cmd2, opts.lean)) ? "current" : "stale"
445
+ state: !have ? "missing" : JSON.stringify(have) === JSON.stringify(entry(cmd2)) ? "current" : "stale"
447
446
  }
448
447
  ];
449
448
  },
@@ -455,7 +454,8 @@ var antigravity = {
455
454
  } catch {
456
455
  }
457
456
  const id = s.conversationId ?? s.session_id ?? s.sessionId;
458
- if (!id) return { session: { id: "" }, events: [], stdout: "{}\n" };
457
+ const stdout = antigravityAnswer(event);
458
+ if (!id) return { session: { id: "" }, events: [], stdout };
459
459
  const workspaces = agWorkspaces(s.workspacePaths);
460
460
  const session = { id: String(id), cwd: workspaces[0] ?? input.cwd };
461
461
  if (typeof s.modelName === "string" && s.modelName !== "auto") session.model = s.modelName;
@@ -476,7 +476,8 @@ var antigravity = {
476
476
  if (tool) events.push(ev("tool.started", { tool, input: toolCall?.args }));
477
477
  break;
478
478
  case "PostToolUse":
479
- if (tool)
479
+ if (!tool) events.push(ev("session.heartbeat", {}));
480
+ else
480
481
  events.push(
481
482
  ev("tool.ended", {
482
483
  tool,
@@ -490,9 +491,9 @@ var antigravity = {
490
491
  events.push(ev("turn.ended", { reason: s.error ? "error" : "stop" }));
491
492
  break;
492
493
  default:
493
- return { session, events: [], stdout: "{}\n" };
494
+ return { session, events: [], stdout };
494
495
  }
495
- const r = { session, events, stdout: "{}\n", hints: { workspaces } };
496
+ const r = { session, events, stdout, hints: { workspaces } };
496
497
  if (typeof s.transcriptPath === "string") r.transcript = s.transcriptPath;
497
498
  return r;
498
499
  },
@@ -3229,7 +3230,7 @@ async function tellDaemon(state2, job, session, transcript) {
3229
3230
  300
3230
3231
  );
3231
3232
  }
3232
- var VERSION = true ? "0.6.0" : "0.0.0";
3233
+ var VERSION = true ? "0.6.1" : "0.0.0";
3233
3234
  function enqueueJob(state2, job) {
3234
3235
  const jobs = jobsDir(state2);
3235
3236
  mkdirSync7(jobs, { recursive: true, mode: 448 });
@@ -4696,7 +4697,7 @@ var {
4696
4697
  recentlyWritten: recentlyWritten2,
4697
4698
  sessionFolder: sessionFolder2
4698
4699
  } = claude_code_control_exports;
4699
- var VERSION2 = true ? "0.6.0" : "0.0.0";
4700
+ var VERSION2 = true ? "0.6.1" : "0.0.0";
4700
4701
  var MAX_REPLY = 2e4;
4701
4702
  var HELLO_EVERY_MS = 10 * 6e4;
4702
4703
  var TURN_FALLBACK_MS = 30 * 6e4;
@@ -5776,7 +5777,7 @@ import { randomBytes as randomBytes3 } from "node:crypto";
5776
5777
  import { existsSync as existsSync12, mkdirSync as mkdirSync10, unlinkSync as unlinkSync6, writeFileSync as writeFileSync8 } from "node:fs";
5777
5778
  import os6 from "node:os";
5778
5779
  import path20 from "node:path";
5779
- var VERSION3 = true ? "0.6.0" : "0.0.0";
5780
+ var VERSION3 = true ? "0.6.1" : "0.0.0";
5780
5781
  async function json(r) {
5781
5782
  try {
5782
5783
  return await r.json();
@@ -6423,7 +6424,7 @@ function launcherScript(node, hook, version) {
6423
6424
  # this; it runs hook.js beside it with the node sessionpipe was installed with, or with
6424
6425
  # any node on PATH once that one is gone (an nvm uninstall, a Homebrew upgrade).
6425
6426
  n=${sq(node)}
6426
- [ -x "$n" ] || n=$(command -v node) || { [ "$1" = antigravity ] && echo '{}'; exit 0; }
6427
+ [ -x "$n" ] || n=$(command -v node) || { [ "$1" = antigravity ] && if [ "$2" = PreToolUse ]; then echo ${sq(AG_STALE_PRETOOL.trim())}; else echo '{}'; fi; exit 0; }
6427
6428
  exec "$n" ${sq(hook)} "$@"
6428
6429
  `;
6429
6430
  }