sessionpipe-core 0.4.1 → 0.5.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.
package/dist/control.js CHANGED
@@ -1,4 +1,4 @@
1
- // sessionpipe-core 0.4.1 · Apache-2.0 · https://sessionpipe.org
1
+ // sessionpipe-core 0.5.0 · Apache-2.0 · https://sessionpipe.org
2
2
 
3
3
  // src/control/verify.ts
4
4
  var GRANT_MAX_MS = 24 * 36e5;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // sessionpipe-core 0.4.1 · Apache-2.0 · https://sessionpipe.org
1
+ // sessionpipe-core 0.5.0 · Apache-2.0 · https://sessionpipe.org
2
2
  var __defProp = Object.defineProperty;
3
3
  var __export = (target, all) => {
4
4
  for (var name in all)
@@ -244,7 +244,7 @@ function readAntigravity(lines, from) {
244
244
  // src/adapters/claude-shaped.ts
245
245
  import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
246
246
  import path3 from "node:path";
247
- var OURS = /sessionpipe[^"\n]*[\\/]hook\.js"?\s+[a-z][a-z-]*\s+[A-Za-z]+\s*$/;
247
+ var OURS = /(?:sessionpipe[^"\n]*[\\/]hook\.js|[\\/]sessionpipe-hook)"?\s+[a-z][a-z-]*\s+[A-Za-z]+\s*$/;
248
248
  var isOurs = (h) => Array.isArray(h?.hooks) && h.hooks.some((x) => typeof x.command === "string" && OURS.test(x.command));
249
249
  function readJsonFile(file) {
250
250
  let raw;
@@ -1211,7 +1211,7 @@ import path6 from "node:path";
1211
1211
  // src/adapters/codex-config.ts
1212
1212
  var NOTIFY_LINE = /^[ \t]*notify[ \t]*=[ \t]*(\[.*\])[ \t]*(?:#.*)?$/m;
1213
1213
  var NOTIFY_KEY = /^[ \t]*notify[ \t]*=/m;
1214
- var OURS2 = /hook\.js",\s*"codex",\s*"notify"/;
1214
+ var OURS2 = /(?:hook\.js|sessionpipe-hook)",\s*"codex",\s*"notify"/;
1215
1215
  function scan(line, st) {
1216
1216
  let i = 0;
1217
1217
  while (i < line.length) {
@@ -1859,19 +1859,23 @@ var claude_code_control_exports = {};
1859
1859
  __export(claude_code_control_exports, {
1860
1860
  JOB_TIMEOUT_MS: () => JOB_TIMEOUT_MS,
1861
1861
  claudeEnv: () => claudeEnv,
1862
+ claudeLogin: () => claudeLogin,
1862
1863
  detectCaps: () => detectCaps,
1863
1864
  findClaude: () => findClaude,
1864
1865
  findTranscript: () => findTranscript,
1865
1866
  isUuid: () => isUuid,
1866
1867
  liveProcess: () => liveProcess,
1868
+ loginCommand: () => loginCommand,
1869
+ loginHint: () => loginHint,
1867
1870
  modeFlags: () => modeFlags,
1871
+ parseAuthStatus: () => parseAuthStatus,
1868
1872
  parseCaps: () => parseCaps,
1869
1873
  parseResult: () => parseResult,
1870
1874
  recentlyWritten: () => recentlyWritten,
1871
1875
  runClaude: () => runClaude,
1872
1876
  sessionFolder: () => sessionFolder
1873
1877
  });
1874
- import { execFileSync as execFileSync4, spawn } from "node:child_process";
1878
+ import { execFile, execFileSync as execFileSync4, spawn } from "node:child_process";
1875
1879
  import { accessSync, closeSync as closeSync2, constants, openSync as openSync2, readdirSync as readdirSync5, readFileSync as readFileSync6, readSync as readSync2, statSync as statSync4 } from "node:fs";
1876
1880
  import os2 from "node:os";
1877
1881
  import path8 from "node:path";
@@ -1976,6 +1980,45 @@ function claudeEnv(configDir, env = process.env) {
1976
1980
  }
1977
1981
  return e;
1978
1982
  }
1983
+ function parseAuthStatus(stdout) {
1984
+ const text = String(stdout || "").trim();
1985
+ const start = text.indexOf("{");
1986
+ if (start < 0) return { loggedIn: null };
1987
+ try {
1988
+ const j = JSON.parse(text.slice(start));
1989
+ if (typeof j.loggedIn !== "boolean") return { loggedIn: null };
1990
+ return {
1991
+ loggedIn: j.loggedIn,
1992
+ ...typeof j.authMethod === "string" ? { method: j.authMethod } : {},
1993
+ ...typeof j.subscriptionType === "string" ? { subscription: j.subscriptionType } : {}
1994
+ };
1995
+ } catch {
1996
+ return { loggedIn: null };
1997
+ }
1998
+ }
1999
+ function claudeLogin(bin, configDir, env = process.env) {
2000
+ return new Promise((resolve) => {
2001
+ execFile(
2002
+ bin,
2003
+ ["auth", "status", "--json"],
2004
+ { encoding: "utf8", timeout: 2e4, env: claudeEnv(configDir, env), maxBuffer: 256 * 1024 },
2005
+ // `auth status` may exit non-zero when signed out; its JSON still says so.
2006
+ (_err, stdout) => resolve(parseAuthStatus(stdout))
2007
+ );
2008
+ });
2009
+ }
2010
+ function loginCommand(configDir) {
2011
+ const home = os2.homedir();
2012
+ const isDefault = !configDir || path8.resolve(configDir) === path8.resolve(home, ".claude");
2013
+ return isDefault ? "`claude auth login`" : `\`CLAUDE_CONFIG_DIR=${configDir.replace(home, "~")} claude auth login\``;
2014
+ }
2015
+ function loginHint(configDir, platform = process.platform) {
2016
+ const shown = configDir ? configDir.replace(os2.homedir(), "~") : "~/.claude";
2017
+ const login = loginCommand(configDir);
2018
+ if (platform === "darwin")
2019
+ return `Claude Code (${shown}) isn't signed in as this machine's background service sees it. On a Mac its login lives in the login keychain, which a background service can read only while someone is logged in at the screen: log in at the Mac, or run ${login} there.`;
2020
+ return `Claude Code (${shown}) isn't signed in on this machine: run ${login} there.`;
2021
+ }
1979
2022
  function detectCaps(bin) {
1980
2023
  let help = "";
1981
2024
  try {