chat-recall 0.7.38 → 0.7.39

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
@@ -2034,7 +2034,7 @@ var require_thread_stream = __commonJS({
2034
2034
  var { version: version2 } = require_package();
2035
2035
  var { EventEmitter } = __require("events");
2036
2036
  var { Worker: Worker2 } = __require("worker_threads");
2037
- var { join: join71 } = __require("path");
2037
+ var { join: join72 } = __require("path");
2038
2038
  var { pathToFileURL } = __require("url");
2039
2039
  var { wait } = require_wait();
2040
2040
  var {
@@ -2077,7 +2077,7 @@ var require_thread_stream = __commonJS({
2077
2077
  function createWorker(stream, opts) {
2078
2078
  const { filename, workerData } = opts;
2079
2079
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
2080
- const toExecute = bundlerOverrides["thread-stream-worker"] || join71(__dirname, "lib", "worker.js");
2080
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join72(__dirname, "lib", "worker.js");
2081
2081
  const worker = new Worker2(toExecute, {
2082
2082
  ...opts.workerOpts,
2083
2083
  trackUnmanagedFds: false,
@@ -2480,7 +2480,7 @@ var require_transport = __commonJS({
2480
2480
  "use strict";
2481
2481
  var { createRequire: createRequire4 } = __require("module");
2482
2482
  var getCallers = require_caller();
2483
- var { join: join71, isAbsolute: isAbsolute5, sep: sep5 } = __require("node:path");
2483
+ var { join: join72, isAbsolute: isAbsolute5, sep: sep5 } = __require("node:path");
2484
2484
  var sleep2 = require_atomic_sleep();
2485
2485
  var onExit = require_on_exit_leak_free();
2486
2486
  var ThreadStream = require_thread_stream();
@@ -2543,7 +2543,7 @@ var require_transport = __commonJS({
2543
2543
  throw new Error("only one of target or targets can be specified");
2544
2544
  }
2545
2545
  if (targets) {
2546
- target = bundlerOverrides["pino-worker"] || join71(__dirname, "worker.js");
2546
+ target = bundlerOverrides["pino-worker"] || join72(__dirname, "worker.js");
2547
2547
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
2548
2548
  return {
2549
2549
  ...dest,
@@ -2561,7 +2561,7 @@ var require_transport = __commonJS({
2561
2561
  });
2562
2562
  });
2563
2563
  } else if (pipeline) {
2564
- target = bundlerOverrides["pino-worker"] || join71(__dirname, "worker.js");
2564
+ target = bundlerOverrides["pino-worker"] || join72(__dirname, "worker.js");
2565
2565
  options.pipelines = [pipeline.map((dest) => {
2566
2566
  return {
2567
2567
  ...dest,
@@ -2583,7 +2583,7 @@ var require_transport = __commonJS({
2583
2583
  return origin;
2584
2584
  }
2585
2585
  if (origin === "pino/file") {
2586
- return join71(__dirname, "..", "file.js");
2586
+ return join72(__dirname, "..", "file.js");
2587
2587
  }
2588
2588
  let fixTarget2;
2589
2589
  for (const filePath of callers) {
@@ -3572,7 +3572,7 @@ var require_safe_stable_stringify = __commonJS({
3572
3572
  return circularValue;
3573
3573
  }
3574
3574
  let res = "";
3575
- let join71 = ",";
3575
+ let join72 = ",";
3576
3576
  const originalIndentation = indentation;
3577
3577
  if (Array.isArray(value)) {
3578
3578
  if (value.length === 0) {
@@ -3586,7 +3586,7 @@ var require_safe_stable_stringify = __commonJS({
3586
3586
  indentation += spacer;
3587
3587
  res += `
3588
3588
  ${indentation}`;
3589
- join71 = `,
3589
+ join72 = `,
3590
3590
  ${indentation}`;
3591
3591
  }
3592
3592
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3594,13 +3594,13 @@ ${indentation}`;
3594
3594
  for (; i < maximumValuesToStringify - 1; i++) {
3595
3595
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3596
3596
  res += tmp2 !== void 0 ? tmp2 : "null";
3597
- res += join71;
3597
+ res += join72;
3598
3598
  }
3599
3599
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3600
3600
  res += tmp !== void 0 ? tmp : "null";
3601
3601
  if (value.length - 1 > maximumBreadth) {
3602
3602
  const removedKeys = value.length - maximumBreadth - 1;
3603
- res += `${join71}"... ${getItemCount(removedKeys)} not stringified"`;
3603
+ res += `${join72}"... ${getItemCount(removedKeys)} not stringified"`;
3604
3604
  }
3605
3605
  if (spacer !== "") {
3606
3606
  res += `
@@ -3621,7 +3621,7 @@ ${originalIndentation}`;
3621
3621
  let separator = "";
3622
3622
  if (spacer !== "") {
3623
3623
  indentation += spacer;
3624
- join71 = `,
3624
+ join72 = `,
3625
3625
  ${indentation}`;
3626
3626
  whitespace = " ";
3627
3627
  }
@@ -3635,13 +3635,13 @@ ${indentation}`;
3635
3635
  const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
3636
3636
  if (tmp !== void 0) {
3637
3637
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
3638
- separator = join71;
3638
+ separator = join72;
3639
3639
  }
3640
3640
  }
3641
3641
  if (keyLength > maximumBreadth) {
3642
3642
  const removedKeys = keyLength - maximumBreadth;
3643
3643
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
3644
- separator = join71;
3644
+ separator = join72;
3645
3645
  }
3646
3646
  if (spacer !== "" && separator.length > 1) {
3647
3647
  res = `
@@ -3682,7 +3682,7 @@ ${originalIndentation}`;
3682
3682
  }
3683
3683
  const originalIndentation = indentation;
3684
3684
  let res = "";
3685
- let join71 = ",";
3685
+ let join72 = ",";
3686
3686
  if (Array.isArray(value)) {
3687
3687
  if (value.length === 0) {
3688
3688
  return "[]";
@@ -3695,7 +3695,7 @@ ${originalIndentation}`;
3695
3695
  indentation += spacer;
3696
3696
  res += `
3697
3697
  ${indentation}`;
3698
- join71 = `,
3698
+ join72 = `,
3699
3699
  ${indentation}`;
3700
3700
  }
3701
3701
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3703,13 +3703,13 @@ ${indentation}`;
3703
3703
  for (; i < maximumValuesToStringify - 1; i++) {
3704
3704
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3705
3705
  res += tmp2 !== void 0 ? tmp2 : "null";
3706
- res += join71;
3706
+ res += join72;
3707
3707
  }
3708
3708
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3709
3709
  res += tmp !== void 0 ? tmp : "null";
3710
3710
  if (value.length - 1 > maximumBreadth) {
3711
3711
  const removedKeys = value.length - maximumBreadth - 1;
3712
- res += `${join71}"... ${getItemCount(removedKeys)} not stringified"`;
3712
+ res += `${join72}"... ${getItemCount(removedKeys)} not stringified"`;
3713
3713
  }
3714
3714
  if (spacer !== "") {
3715
3715
  res += `
@@ -3722,7 +3722,7 @@ ${originalIndentation}`;
3722
3722
  let whitespace = "";
3723
3723
  if (spacer !== "") {
3724
3724
  indentation += spacer;
3725
- join71 = `,
3725
+ join72 = `,
3726
3726
  ${indentation}`;
3727
3727
  whitespace = " ";
3728
3728
  }
@@ -3731,7 +3731,7 @@ ${indentation}`;
3731
3731
  const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
3732
3732
  if (tmp !== void 0) {
3733
3733
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
3734
- separator = join71;
3734
+ separator = join72;
3735
3735
  }
3736
3736
  }
3737
3737
  if (spacer !== "" && separator.length > 1) {
@@ -3789,20 +3789,20 @@ ${originalIndentation}`;
3789
3789
  indentation += spacer;
3790
3790
  let res2 = `
3791
3791
  ${indentation}`;
3792
- const join72 = `,
3792
+ const join73 = `,
3793
3793
  ${indentation}`;
3794
3794
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
3795
3795
  let i = 0;
3796
3796
  for (; i < maximumValuesToStringify - 1; i++) {
3797
3797
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3798
3798
  res2 += tmp2 !== void 0 ? tmp2 : "null";
3799
- res2 += join72;
3799
+ res2 += join73;
3800
3800
  }
3801
3801
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3802
3802
  res2 += tmp !== void 0 ? tmp : "null";
3803
3803
  if (value.length - 1 > maximumBreadth) {
3804
3804
  const removedKeys = value.length - maximumBreadth - 1;
3805
- res2 += `${join72}"... ${getItemCount(removedKeys)} not stringified"`;
3805
+ res2 += `${join73}"... ${getItemCount(removedKeys)} not stringified"`;
3806
3806
  }
3807
3807
  res2 += `
3808
3808
  ${originalIndentation}`;
@@ -3818,16 +3818,16 @@ ${originalIndentation}`;
3818
3818
  return '"[Object]"';
3819
3819
  }
3820
3820
  indentation += spacer;
3821
- const join71 = `,
3821
+ const join72 = `,
3822
3822
  ${indentation}`;
3823
3823
  let res = "";
3824
3824
  let separator = "";
3825
3825
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
3826
3826
  if (isTypedArrayWithEntries(value)) {
3827
- res += stringifyTypedArray(value, join71, maximumBreadth);
3827
+ res += stringifyTypedArray(value, join72, maximumBreadth);
3828
3828
  keys = keys.slice(value.length);
3829
3829
  maximumPropertiesToStringify -= value.length;
3830
- separator = join71;
3830
+ separator = join72;
3831
3831
  }
3832
3832
  if (deterministic) {
3833
3833
  keys = sort(keys, comparator);
@@ -3838,13 +3838,13 @@ ${indentation}`;
3838
3838
  const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
3839
3839
  if (tmp !== void 0) {
3840
3840
  res += `${separator}${strEscape(key3)}: ${tmp}`;
3841
- separator = join71;
3841
+ separator = join72;
3842
3842
  }
3843
3843
  }
3844
3844
  if (keyLength > maximumBreadth) {
3845
3845
  const removedKeys = keyLength - maximumBreadth;
3846
3846
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
3847
- separator = join71;
3847
+ separator = join72;
3848
3848
  }
3849
3849
  if (separator !== "") {
3850
3850
  res = `
@@ -9826,11 +9826,11 @@ async function archiveRawSession(store, sessionId) {
9826
9826
  return await store.putRawSession(sessionId, exp.tool, Math.floor(exp.mtime), gz, size);
9827
9827
  }
9828
9828
  function detectForkPredecessor(sessionPath) {
9829
- const { readFileSync: readFileSync57, readdirSync: readdirSync36 } = requireFs();
9830
- const { dirname: dirname31, join: join71, basename: basename30 } = requirePath();
9829
+ const { readFileSync: readFileSync58, readdirSync: readdirSync36 } = requireFs();
9830
+ const { dirname: dirname31, join: join72, basename: basename30 } = requirePath();
9831
9831
  let text;
9832
9832
  try {
9833
- text = readFileSync57(sessionPath, "utf-8");
9833
+ text = readFileSync58(sessionPath, "utf-8");
9834
9834
  } catch {
9835
9835
  return null;
9836
9836
  }
@@ -9864,7 +9864,7 @@ function detectForkPredecessor(sessionPath) {
9864
9864
  if (!f.endsWith(".jsonl") || f === self || f === "sessions-index.json")
9865
9865
  continue;
9866
9866
  try {
9867
- if (readFileSync57(join71(dir, f), "utf-8").includes(`"uuid":"${headParent}"`)) {
9867
+ if (readFileSync58(join72(dir, f), "utf-8").includes(`"uuid":"${headParent}"`)) {
9868
9868
  return basename30(f, ".jsonl");
9869
9869
  }
9870
9870
  } catch {
@@ -10598,15 +10598,18 @@ var init_opencode = __esm({
10598
10598
  FROM part p JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON p.message_id = m.id
10599
10599
  WHERE p.session_id = ?
10600
10600
  ORDER BY p.time_created ASC, p.id ASC
10601
- `).all(realId, realId);
10602
- const lines = [JSON.stringify({ kind: "session", row: session })];
10603
- for (const r of rows)
10604
- lines.push(JSON.stringify({ kind: "part", row: r }));
10601
+ `);
10602
+ const chunks = [Buffer.from(`${JSON.stringify({ kind: "session", row: session })}
10603
+ `, "utf-8")];
10604
+ for (const r of rows.iterate(realId, realId)) {
10605
+ chunks.push(Buffer.from(`${JSON.stringify({ kind: "part", row: r })}
10606
+ `, "utf-8"));
10607
+ }
10605
10608
  const mtime = session.time_updated || session.time_created || Date.now();
10606
10609
  return {
10607
10610
  tool: "opencode",
10608
10611
  mtime: Number(mtime),
10609
- files: [{ name: `${realId}.dump.jsonl`, bytes: Buffer.from(lines.join("\n") + "\n", "utf-8") }]
10612
+ files: [{ name: `${realId}.dump.jsonl`, bytes: Buffer.concat(chunks) }]
10610
10613
  };
10611
10614
  } catch {
10612
10615
  return null;
@@ -28341,7 +28344,7 @@ var init_http = __esm({
28341
28344
  CLI_VERSION = JSON.parse(readFileSync36(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION;
28342
28345
  } catch {
28343
28346
  try {
28344
- if (true) CLI_VERSION = "0.7.38";
28347
+ if (true) CLI_VERSION = "0.7.39";
28345
28348
  } catch {
28346
28349
  }
28347
28350
  }
@@ -28839,7 +28842,7 @@ var init_telemetry = __esm({
28839
28842
  init_sync_client();
28840
28843
  cliVersion2 = () => {
28841
28844
  try {
28842
- return true ? "0.7.38" : "dev";
28845
+ return true ? "0.7.39" : "dev";
28843
28846
  } catch {
28844
28847
  return "dev";
28845
28848
  }
@@ -29688,6 +29691,7 @@ __export(sync_client_exports, {
29688
29691
  classedError: () => classedError,
29689
29692
  classifyError: () => classifyError,
29690
29693
  countsForBreaker: () => countsForBreaker,
29694
+ exportByteLength: () => exportByteLength,
29691
29695
  isStandingFailure: () => isStandingFailure,
29692
29696
  isSyncSkip: () => isSyncSkip,
29693
29697
  lastSuccessfulWalkAt: () => lastSuccessfulWalkAt,
@@ -31009,6 +31013,10 @@ async function syncToTargetInScope(cred, opts = {}) {
31009
31013
  scanMs: Math.round(scanMs)
31010
31014
  };
31011
31015
  }
31016
+ function exportByteLength(exp) {
31017
+ if (!exp) return 0;
31018
+ return exp.files.reduce((n, f) => n + f.bytes.length, 0);
31019
+ }
31012
31020
  async function scanTranscriptFindingsChunked(ref, tenantRules) {
31013
31021
  const backend = getBackendForId(ref.prefixedId);
31014
31022
  const findings = [];
@@ -31079,7 +31087,20 @@ async function buildConversationSync(ref, mtime, opts = {}) {
31079
31087
  const backend = getBackendForId(ref.prefixedId) ?? getBackend("claude");
31080
31088
  const exp = backend.exportRawSession(ref.prefixedId);
31081
31089
  let built;
31082
- if (exp) {
31090
+ const exportBytes = exportByteLength(exp);
31091
+ const overCeiling = exportBytes > FULL_BUILD_MAX_BYTES;
31092
+ if (exp && overCeiling) {
31093
+ console.error(`[sync] ${ref.prefixedId} export is ${(exportBytes / 1048576).toFixed(0)}MB (over the ${(FULL_BUILD_MAX_BYTES / 1048576).toFixed(0)}MB ceiling) \u2014 parsing it in place, no container copy, no shadow merge, no raw archive`);
31094
+ record({
31095
+ kind: "oversized_session",
31096
+ mb: Math.round(exportBytes / 1048576),
31097
+ tool: ref.toolId,
31098
+ dedupeKey: stableMark(ref.prefixedId)
31099
+ });
31100
+ includeRaw = false;
31101
+ includeMeta = false;
31102
+ }
31103
+ if (exp && !overCeiling) {
31083
31104
  try {
31084
31105
  built = buildRawContainer(exp);
31085
31106
  srcHash = containerSrcHash(built);
@@ -31103,7 +31124,7 @@ async function buildConversationSync(ref, mtime, opts = {}) {
31103
31124
  includeMeta = false;
31104
31125
  }
31105
31126
  }
31106
- const shadow = updateShadow(ref.rawId, exp, built);
31127
+ const shadow = overCeiling ? { container: null, status: "skipped", recovered: 0 } : updateShadow(ref.rawId, exp, built);
31107
31128
  if (shadow.container) {
31108
31129
  fullestContainer = shadow.container;
31109
31130
  if (shadow.status === "rewrite-merged" && shadow.recovered > 0) {
@@ -31504,7 +31525,7 @@ var init_sync_client = __esm({
31504
31525
  ownVersion = JSON.parse(readFileSync41(join47(dir, "../package.json"), "utf-8")).version || ownVersion;
31505
31526
  } catch {
31506
31527
  try {
31507
- if (true) ownVersion = "0.7.38";
31528
+ if (true) ownVersion = "0.7.39";
31508
31529
  } catch {
31509
31530
  }
31510
31531
  }
@@ -32982,6 +33003,26 @@ function piAgentDir2(home) {
32982
33003
  const override = process.env.CHAT_RECALL_PI_HOME?.trim() || loadSourceSettings().piHome || process.env.PI_CODING_AGENT_DIR?.trim();
32983
33004
  return override ? expandTildePath(override) : join54(home, ".pi", "agent");
32984
33005
  }
33006
+ function launchCommand(spec) {
33007
+ if (!spec.command)
33008
+ throw new Error("an MCP entry needs a url or a command");
33009
+ return spec.command;
33010
+ }
33011
+ function remoteMcpServersEntry(id, spec) {
33012
+ const headers = spec.authorization ? { headers: { Authorization: spec.authorization } } : {};
33013
+ switch (id) {
33014
+ // Claude Code is the one that runs a command for the header at every start,
33015
+ // so the token stays out of the config file it writes.
33016
+ case "claude":
33017
+ return { type: "http", url: spec.url, ...spec.headersHelper ? { headersHelper: spec.headersHelper } : headers };
33018
+ case "agy":
33019
+ return { httpUrl: spec.url, ...headers };
33020
+ case "cursor":
33021
+ return { url: spec.url, ...headers };
33022
+ default:
33023
+ return { url: spec.url };
33024
+ }
33025
+ }
32985
33026
  function envHome(varName, fallback) {
32986
33027
  const v = process.env[varName];
32987
33028
  return v && v.trim() ? v.trim() : fallback;
@@ -33007,8 +33048,18 @@ function registerMcpServersJson(target, path, spec) {
33007
33048
  }
33008
33049
  const servers = cfg.mcpServers || {};
33009
33050
  const existing = servers[MCP_SERVER_NAME];
33051
+ if (spec.url) {
33052
+ const wanted = remoteMcpServersEntry(target.id, spec);
33053
+ const isCurrent2 = !!existing && !existing.disabled && Object.entries(wanted).every(([k, v]) => JSON.stringify(existing[k] ?? null) === JSON.stringify(v));
33054
+ if (isCurrent2)
33055
+ return { id: target.id, label: target.label, path, state: "current" };
33056
+ servers[MCP_SERVER_NAME] = wanted;
33057
+ cfg.mcpServers = servers;
33058
+ writeFileMkdir(path, JSON.stringify(cfg, null, 2) + "\n");
33059
+ return { id: target.id, label: target.label, path, state: existing ? "repaired" : "created" };
33060
+ }
33010
33061
  const entry = {
33011
- command: spec.command,
33062
+ command: launchCommand(spec),
33012
33063
  ...spec.args ? { args: spec.args } : {}
33013
33064
  };
33014
33065
  if (spec.alwaysAllow)
@@ -33038,7 +33089,17 @@ function registerOpencodeJson(path, spec) {
33038
33089
  cfg.$schema = "https://opencode.ai/config.json";
33039
33090
  const mcp = cfg.mcp || {};
33040
33091
  const existing = mcp[MCP_SERVER_NAME];
33041
- const argv = [spec.command, ...spec.args ?? []];
33092
+ if (spec.url) {
33093
+ const wanted = { type: "remote", url: spec.url, enabled: true };
33094
+ const isCurrent2 = !!existing && existing.type === "remote" && existing.enabled === true && existing.url === spec.url;
33095
+ if (isCurrent2)
33096
+ return { id, label, path, state: "current" };
33097
+ mcp[MCP_SERVER_NAME] = wanted;
33098
+ cfg.mcp = mcp;
33099
+ writeFileMkdir(path, JSON.stringify(cfg, null, 2) + "\n");
33100
+ return { id, label, path, state: existing ? "repaired" : "created" };
33101
+ }
33102
+ const argv = [launchCommand(spec), ...spec.args ?? []];
33042
33103
  const entry = { type: "local", command: argv, enabled: true };
33043
33104
  if (spec.env)
33044
33105
  entry.environment = { ...existing?.environment, ...spec.env };
@@ -33051,7 +33112,9 @@ function registerOpencodeJson(path, spec) {
33051
33112
  return { id, label, path, state: existing ? "repaired" : "created" };
33052
33113
  }
33053
33114
  function codexBlock(spec) {
33054
- const lines = [CODEX_HEADER, `command = ${JSON.stringify(spec.command)}`];
33115
+ if (spec.url)
33116
+ return [CODEX_HEADER, `url = ${JSON.stringify(spec.url)}`].join("\n") + "\n";
33117
+ const lines = [CODEX_HEADER, `command = ${JSON.stringify(launchCommand(spec))}`];
33055
33118
  if (spec.args?.length)
33056
33119
  lines.push(`args = [${spec.args.map((a) => JSON.stringify(a)).join(", ")}]`);
33057
33120
  const env = Object.entries(spec.env ?? {});
@@ -33454,7 +33517,7 @@ function relayCommand(bundleDir) {
33454
33517
  const bin = resolveOnPath("chat-recall-mcp");
33455
33518
  return bin ? [bin] : [process.execPath, join55(bundleDir, "mcp-relay.js")];
33456
33519
  }
33457
- function registerRelay(server, bundleDir, host, env = process.env) {
33520
+ function registerRelay(server, _bundleDir, host, env = process.env) {
33458
33521
  if (env.CHAT_RECALL_MCP_REGISTRATION?.trim().toLowerCase() === "own") return [];
33459
33522
  const kit = optionalKit(env);
33460
33523
  if (!kit) return [];
@@ -33463,8 +33526,7 @@ function registerRelay(server, bundleDir, host, env = process.env) {
33463
33526
  if (clients.length === 0) return [];
33464
33527
  return kit.addMcpServer(machine, clients, {
33465
33528
  name: MCP_NAME,
33466
- url: `${server.replace(/\/+$/, "")}/mcp`,
33467
- command: relayCommand(bundleDir)
33529
+ url: `${server.replace(/\/+$/, "")}/mcp`
33468
33530
  }).outcomes;
33469
33531
  }
33470
33532
  var OwnLoginError, LoginError, MCP_NAME, CLI_CLIENT_ID, RUN_TIMEOUT_MS, secretStoreOf;
@@ -37528,7 +37590,7 @@ var init_intent_drain = __esm({
37528
37590
  ownVersion2 = JSON.parse(readFileSync52(join65(dir, "../package.json"), "utf-8")).version || ownVersion2;
37529
37591
  } catch {
37530
37592
  try {
37531
- if (true) ownVersion2 = "0.7.38";
37593
+ if (true) ownVersion2 = "0.7.39";
37532
37594
  } catch {
37533
37595
  }
37534
37596
  }
@@ -38947,6 +39009,7 @@ var init_task_hook = __esm({
38947
39009
  var service_installer_exports = {};
38948
39010
  __export(service_installer_exports, {
38949
39011
  ServiceInstallError: () => ServiceInstallError,
39012
+ WATCH_HEAP_MB: () => WATCH_HEAP_MB,
38950
39013
  installService: () => installService,
38951
39014
  isServiceRunning: () => isServiceRunning,
38952
39015
  platformName: () => platformName,
@@ -39057,9 +39120,8 @@ function renderSystemdUnit(watchJs, node, logFile) {
39057
39120
  // Bounded heap: the daemon does bursty batch work (transcript parse,
39058
39121
  // base64 payloads); V8's default old-space on a big-RAM box is ~4GB and
39059
39122
  // GC only gets aggressive near the ceiling — observed as a multi-GB RSS
39060
- // sawtooth. 1536MB keeps GC honest (768 OOMed on the largest subagent-fanout session) with plenty of headroom for the
39061
- // largest transcripts.
39062
- `ExecStart=${node} --max-old-space-size=1536 ${watchJs}`,
39123
+ // sawtooth. The ceiling below is measured, not guessed: see WATCH_HEAP_MB.
39124
+ `ExecStart=${node} --max-old-space-size=${WATCH_HEAP_MB} ${watchJs}`,
39063
39125
  // ALWAYS: the collector never ends its own work, so any exit systemd did
39064
39126
  // not ask for is a fault. Under on-failure a clean exit left it dead: on
39065
39127
  // 2026-09-16 the unit went "inactive (dead) … status=0/SUCCESS" and stayed
@@ -39132,7 +39194,7 @@ function renderLaunchdPlist(watchJs, node, logFile, label = "com.chat-recall.wat
39132
39194
  '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
39133
39195
  '<plist version="1.0"><dict>',
39134
39196
  ` <key>Label</key><string>${label}</string>`,
39135
- ` <key>ProgramArguments</key><array><string>${node}</string><string>--max-old-space-size=1536</string><string>${watchJs}</string></array>`,
39197
+ ` <key>ProgramArguments</key><array><string>${node}</string><string>--max-old-space-size=${WATCH_HEAP_MB}</string><string>${watchJs}</string></array>`,
39136
39198
  " <key>RunAtLoad</key><true/>",
39137
39199
  " <key>KeepAlive</key><true/>",
39138
39200
  ` <key>StandardOutPath</key><string>${logFile}</string>`,
@@ -39143,7 +39205,7 @@ function renderLaunchdPlist(watchJs, node, logFile, label = "com.chat-recall.wat
39143
39205
  }
39144
39206
  function installWindowsTask(watchJs, node, logFile) {
39145
39207
  const taskName = "chat-recall-watch";
39146
- const tr = `cmd /c \\"\\"${node}\\" --max-old-space-size=1536 \\"${watchJs}\\" >> \\"${logFile}\\" 2>&1\\"`;
39208
+ const tr = `cmd /c \\"\\"${node}\\" --max-old-space-size=${WATCH_HEAP_MB} \\"${watchJs}\\" >> \\"${logFile}\\" 2>&1\\"`;
39147
39209
  try {
39148
39210
  execSync5(`schtasks /create /tn "${taskName}" /tr "${tr}" /sc onlogon /rl LIMITED /f`, { stdio: "inherit" });
39149
39211
  try {
@@ -39156,7 +39218,7 @@ function installWindowsTask(watchJs, node, logFile) {
39156
39218
  return { definitionPath: null, logFile };
39157
39219
  }
39158
39220
  function renderWindowsTaskCommand(watchJs, node, taskName = "chat-recall-watch", logFile) {
39159
- const tr = logFile ? `cmd /c \\"\\"${node}\\" --max-old-space-size=1536 \\"${watchJs}\\" >> \\"${logFile}\\" 2>&1\\"` : `\\"${node}\\" --max-old-space-size=1536 \\"${watchJs}\\"`;
39221
+ const tr = logFile ? `cmd /c \\"\\"${node}\\" --max-old-space-size=${WATCH_HEAP_MB} \\"${watchJs}\\" >> \\"${logFile}\\" 2>&1\\"` : `\\"${node}\\" --max-old-space-size=${WATCH_HEAP_MB} \\"${watchJs}\\"`;
39160
39222
  return `schtasks /create /tn "${taskName}" /tr "${tr}" /sc onlogon /rl LIMITED /f`;
39161
39223
  }
39162
39224
  function uninstallService() {
@@ -39207,10 +39269,11 @@ function platformName() {
39207
39269
  if (process.platform === "win32") return "Scheduled Task";
39208
39270
  return process.platform;
39209
39271
  }
39210
- var ServiceInstallError;
39272
+ var WATCH_HEAP_MB, ServiceInstallError;
39211
39273
  var init_service_installer = __esm({
39212
39274
  "src/service-installer.ts"() {
39213
39275
  "use strict";
39276
+ WATCH_HEAP_MB = 640;
39214
39277
  ServiceInstallError = class extends Error {
39215
39278
  hint;
39216
39279
  constructor(message, hint) {
@@ -39265,6 +39328,47 @@ var init_install_report = __esm({
39265
39328
  }
39266
39329
  });
39267
39330
 
39331
+ // ../engine/dist/core/remote-target.js
39332
+ var remote_target_exports = {};
39333
+ __export(remote_target_exports, {
39334
+ recallTarget: () => recallTarget
39335
+ });
39336
+ import { readFileSync as readFileSync56 } from "node:fs";
39337
+ import { join as join70 } from "node:path";
39338
+ function recallTarget() {
39339
+ const fromEnv = envCredentials();
39340
+ if (fromEnv)
39341
+ return { base: fromEnv.serverUrl, token: fromEnv.token };
39342
+ try {
39343
+ const raw = readFileSync56(join70(getDataDir(), "credentials.json"), "utf-8");
39344
+ const parsed = JSON.parse(raw);
39345
+ if (Array.isArray(parsed.targets) && parsed.targets.length) {
39346
+ const valid = parsed.targets.filter((t) => t?.serverUrl);
39347
+ if (!valid.length)
39348
+ return null;
39349
+ const norm = (u) => u.replace(/\/+$/, "");
39350
+ const isLocal = (u) => /\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)\b/.test(u);
39351
+ const byUrl = (u) => u ? valid.find((t) => norm(t.serverUrl) === norm(u)) : void 0;
39352
+ const remotes = valid.filter((t) => !isLocal(t.serverUrl));
39353
+ const pick = byUrl(process.env.CHAT_RECALL_SERVER) ?? byUrl(parsed.primary) ?? remotes[0] ?? valid[0];
39354
+ return pick?.serverUrl ? { base: norm(pick.serverUrl), token: targetToken(pick) } : null;
39355
+ }
39356
+ if (parsed.serverUrl)
39357
+ return { base: parsed.serverUrl.replace(/\/+$/, ""), token: parsed.token || "" };
39358
+ return null;
39359
+ } catch {
39360
+ return null;
39361
+ }
39362
+ }
39363
+ var init_remote_target = __esm({
39364
+ "../engine/dist/core/remote-target.js"() {
39365
+ "use strict";
39366
+ init_credentials_env();
39367
+ init_data_dir();
39368
+ init_stored_token();
39369
+ }
39370
+ });
39371
+
39268
39372
  // src/bulk-delete.ts
39269
39373
  var bulk_delete_exports = {};
39270
39374
  __export(bulk_delete_exports, {
@@ -39563,9 +39667,9 @@ init_project_resolver();
39563
39667
  import { config } from "dotenv";
39564
39668
  import { Command } from "commander";
39565
39669
  import chalk2 from "chalk";
39566
- import { existsSync as existsSync61, readFileSync as readFileSync56, writeFileSync as writeFileSync25 } from "fs";
39670
+ import { existsSync as existsSync61, readFileSync as readFileSync57, writeFileSync as writeFileSync25 } from "fs";
39567
39671
  import { homedir as homedir25 } from "os";
39568
- import { join as join70, resolve as resolve2, dirname as dirname30, basename as basename29 } from "path";
39672
+ import { join as join71, resolve as resolve2, dirname as dirname30, basename as basename29 } from "path";
39569
39673
 
39570
39674
  // ../engine/dist/core/score-tier.js
39571
39675
  var STRONG_RATIO = 0.85;
@@ -39809,13 +39913,13 @@ async function serverDelete(path, body2) {
39809
39913
  }
39810
39914
  var pkgEngines = (() => {
39811
39915
  try {
39812
- return JSON.parse(readFileSync56(new URL("../package.json", import.meta.url), "utf-8")).engines?.node ?? "";
39916
+ return JSON.parse(readFileSync57(new URL("../package.json", import.meta.url), "utf-8")).engines?.node ?? "";
39813
39917
  } catch {
39814
39918
  return "";
39815
39919
  }
39816
39920
  })();
39817
39921
  var pkgVersion = JSON.parse(
39818
- readFileSync56(new URL("../package.json", import.meta.url), "utf-8")
39922
+ readFileSync57(new URL("../package.json", import.meta.url), "utf-8")
39819
39923
  ).version;
39820
39924
  var DEFAULT_SERVER = (process.env.CHAT_RECALL_DEFAULT_SERVER || "https://chatrecall.dev").replace(/\/+$/, "");
39821
39925
  var DEFAULT_ALLOW = [
@@ -39995,10 +40099,10 @@ program.command("init").description("Set up chat-recall: connect to your server,
39995
40099
  } else if (target) {
39996
40100
  }
39997
40101
  if (!options.skipMcp) {
39998
- const projectRoot = join70(import.meta.dirname, "..");
40102
+ const projectRoot = join71(import.meta.dirname, "..");
39999
40103
  let mcpBinOnPath = false;
40000
40104
  mcpBinOnPath = isOnPath("chat-recall-mcp");
40001
- const launch = mcpBinOnPath ? { command: "chat-recall-mcp" } : { command: "node", args: [join70(projectRoot, "dist", "mcp-relay.js")] };
40105
+ const launch = mcpBinOnPath ? { command: "chat-recall-mcp" } : { command: "node", args: [join71(projectRoot, "dist", "mcp-relay.js")] };
40002
40106
  const MCP_ENV = { NODE_OPTIONS: "--max-old-space-size=1024" };
40003
40107
  const { registerMcpEverywhere: registerMcpEverywhere2 } = await Promise.resolve().then(() => (init_mcp_clients(), mcp_clients_exports));
40004
40108
  const MCP_CLIENT_FOR_BIN = {
@@ -40019,8 +40123,15 @@ program.command("init").description("Set up chat-recall: connect to your server,
40019
40123
  } catch (e) {
40020
40124
  rep.warn(chalk2.yellow(`could not register chat-recall-mcp with the kit: ${e instanceof Error ? e.message : e}`));
40021
40125
  }
40126
+ const hosted = options.server ?? target?.base;
40127
+ const hostedBase = hosted?.replace(/\/+$/, "");
40128
+ const stored = target && hostedBase && hostedBase === target.base.replace(/\/+$/, "") ? target : null;
40022
40129
  const results = registerMcpEverywhere2(
40023
- { ...launch, env: MCP_ENV, alwaysAllow: DEFAULT_ALLOW },
40130
+ hostedBase ? {
40131
+ url: `${hostedBase}/mcp`,
40132
+ authorization: stored?.token ? `Bearer ${stored.token}` : void 0,
40133
+ headersHelper: stored ? "chat-recall token --header" : void 0
40134
+ } : { ...launch, env: MCP_ENV, alwaysAllow: DEFAULT_ALLOW },
40024
40135
  { extraIds: detectedClients, skipIds: kitDone.has("claude") ? ["claude"] : [] }
40025
40136
  );
40026
40137
  const ok = results.filter((r) => r.state !== "unparseable");
@@ -40049,7 +40160,7 @@ program.command("init").description("Set up chat-recall: connect to your server,
40049
40160
  const detected = checkCodeindexStatus2();
40050
40161
  if (detected.installed && !forceInstall) {
40051
40162
  if (!options.skipMcp) {
40052
- const mcpJsonPath = join70(homedir25(), ".mcp.json");
40163
+ const mcpJsonPath = join71(homedir25(), ".mcp.json");
40053
40164
  const reg = registerCodeindexMcp2(mcpJsonPath, detected.path);
40054
40165
  }
40055
40166
  } else if (forceInstall) {
@@ -40058,7 +40169,7 @@ program.command("init").description("Set up chat-recall: connect to your server,
40058
40169
  if (result.installed) {
40059
40170
  const sizeMb = result.size ? `${(result.size / 1024 / 1024).toFixed(1)} MB` : "?";
40060
40171
  if (!options.skipMcp) {
40061
- const mcpJsonPath = join70(homedir25(), ".mcp.json");
40172
+ const mcpJsonPath = join71(homedir25(), ".mcp.json");
40062
40173
  const reg = registerCodeindexMcp2(mcpJsonPath, CODEINDEX_BIN_PATH2);
40063
40174
  }
40064
40175
  } else if (!result.prebuiltAvailable) {
@@ -40515,7 +40626,7 @@ memory.command("wake-up").description("Generate wake-up context (high-importance
40515
40626
  const identityFile = getIdentityFilePath();
40516
40627
  let identity = "AI coding assistant";
40517
40628
  if (existsSync61(identityFile)) {
40518
- identity = readFileSync56(identityFile, "utf-8").trim();
40629
+ identity = readFileSync57(identityFile, "utf-8").trim();
40519
40630
  }
40520
40631
  const lines = [
40521
40632
  chalk2.bold("# Wake-Up Context"),
@@ -40615,7 +40726,7 @@ program.command("feedback").argument("<message...>", "what you want to say \u201
40615
40726
  }
40616
40727
  });
40617
40728
  program.command("doctor").description("Quick health check across login, server, credentials, hooks, MCP server, and codeindex").option("--purge-local", "Remove the legacy local index (cache.db + vector/KG files) left by pre-thin-collector versions \u2014 storage is server-side now. Requires login; keeps credentials, sync ledger, identity, and the audit log.").action(async (opts) => {
40618
- const { existsSync: existsSync62, readFileSync: readFileSync57, statSync: statSync49 } = await import("fs");
40729
+ const { existsSync: existsSync62, readFileSync: readFileSync58, statSync: statSync49 } = await import("fs");
40619
40730
  const { execSync: execSync6 } = await import("child_process");
40620
40731
  const rows = [];
40621
40732
  const note = (ok, label, detail) => rows.push({ ok, label, detail });
@@ -40678,7 +40789,7 @@ program.command("doctor").description("Quick health check across login, server,
40678
40789
  }
40679
40790
  }
40680
40791
  }
40681
- const credFile = join70(getDataDir(), "credentials.json");
40792
+ const credFile = join71(getDataDir(), "credentials.json");
40682
40793
  if (!existsSync62(credFile)) {
40683
40794
  note(false, "Credentials file", `missing \u2014 run \`chat-recall login <server-url>\``);
40684
40795
  } else {
@@ -40698,14 +40809,14 @@ program.command("doctor").description("Quick health check across login, server,
40698
40809
  const label = `Claude hooks (${profile})`;
40699
40810
  let hooks;
40700
40811
  try {
40701
- hooks = existsSync62(settingsFile) ? JSON.parse(readFileSync57(settingsFile, "utf-8")).hooks || {} : {};
40812
+ hooks = existsSync62(settingsFile) ? JSON.parse(readFileSync58(settingsFile, "utf-8")).hooks || {} : {};
40702
40813
  } catch {
40703
40814
  note(false, label, `${settingsFile} is not valid JSON, so no hook in it runs`);
40704
40815
  continue;
40705
40816
  }
40706
- const legacy = join70(dirname30(settingsFile), "hooks.json");
40817
+ const legacy = join71(dirname30(settingsFile), "hooks.json");
40707
40818
  try {
40708
- const stranded = existsSync62(legacy) ? Object.values(JSON.parse(readFileSync57(legacy, "utf-8")).hooks || {}).flat().filter(isOurEntry2).length : 0;
40819
+ const stranded = existsSync62(legacy) ? Object.values(JSON.parse(readFileSync58(legacy, "utf-8")).hooks || {}).flat().filter(isOurEntry2).length : 0;
40709
40820
  if (stranded) note(false, `Old hook file (${profile})`, `${stranded} chat-recall entr${stranded === 1 ? "y" : "ies"} in ${legacy}, which Claude Code does not read \u2014 run \`chat-recall install-hooks\` to move them`);
40710
40821
  } catch {
40711
40822
  }
@@ -40740,7 +40851,7 @@ program.command("doctor").description("Quick health check across login, server,
40740
40851
  }
40741
40852
  let registered = false;
40742
40853
  try {
40743
- const cfg = JSON.parse(readFileSync57(target2.configPath, "utf-8"));
40854
+ const cfg = JSON.parse(readFileSync58(target2.configPath, "utf-8"));
40744
40855
  registered = JSON.stringify(cfg).includes("chat_recall_guard");
40745
40856
  } catch {
40746
40857
  }
@@ -40758,7 +40869,7 @@ program.command("doctor").description("Quick health check across login, server,
40758
40869
  let registered = existsSync62(target2.configPath);
40759
40870
  if (registered) {
40760
40871
  try {
40761
- const text = readFileSync57(target2.configPath, "utf-8");
40872
+ const text = readFileSync58(target2.configPath, "utf-8");
40762
40873
  registered = text.includes("chat_recall_messages_") || reg.isOurPluginSource(text);
40763
40874
  } catch {
40764
40875
  registered = false;
@@ -40773,7 +40884,7 @@ program.command("doctor").description("Quick health check across login, server,
40773
40884
  try {
40774
40885
  if (existsSync62(opencodeConfigDir())) {
40775
40886
  const path = tuiConfigPath();
40776
- const present = existsSync62(path) && hasTuiPluginEntry(readFileSync57(path, "utf-8"), tuiPluginEntry());
40887
+ const present = existsSync62(path) && hasTuiPluginEntry(readFileSync58(path, "utf-8"), tuiPluginEntry());
40777
40888
  note(
40778
40889
  present,
40779
40890
  "Messages \u2014 OpenCode TUI",
@@ -40788,7 +40899,7 @@ program.command("doctor").description("Quick health check across login, server,
40788
40899
  const want = bundledSkillNames2().length;
40789
40900
  for (const t of skillTargets2()) {
40790
40901
  if (!t.available) continue;
40791
- const have = want === 0 ? 0 : bundledSkillNames2().filter((n) => existsSync62(join70(t.dir, n, ".chat-recall-managed"))).length;
40902
+ const have = want === 0 ? 0 : bundledSkillNames2().filter((n) => existsSync62(join71(t.dir, n, ".chat-recall-managed"))).length;
40792
40903
  note(
40793
40904
  have === want,
40794
40905
  `Skills \u2014 ${t.label}`,
@@ -40863,12 +40974,12 @@ program.command("doctor").description("Quick health check across login, server,
40863
40974
  note(watchRunning, "Watch daemon", watchRunning ? "running" : "not running (run `chat-recall watch --install-service` to keep collection running)");
40864
40975
  const dataDir = getDataDir();
40865
40976
  const legacyPaths = [
40866
- join70(dataDir, "cache.db"),
40867
- join70(dataDir, "cache.db-wal"),
40868
- join70(dataDir, "cache.db-shm"),
40869
- join70(dataDir, "index", "lancedb"),
40870
- join70(dataDir, "index", "knowledge_graph.db"),
40871
- join70(dataDir, "index", "metadata.db")
40977
+ join71(dataDir, "cache.db"),
40978
+ join71(dataDir, "cache.db-wal"),
40979
+ join71(dataDir, "cache.db-shm"),
40980
+ join71(dataDir, "index", "lancedb"),
40981
+ join71(dataDir, "index", "knowledge_graph.db"),
40982
+ join71(dataDir, "index", "metadata.db")
40872
40983
  ];
40873
40984
  const legacyPresent = legacyPaths.filter((p) => existsSync62(p));
40874
40985
  if (opts.purgeLocal) {
@@ -40941,7 +41052,7 @@ companions.command("install").description("Install codeindex (downloads from mun
40941
41052
  if (result.installed) {
40942
41053
  const sizeMb = result.size ? `${(result.size / 1024 / 1024).toFixed(1)} MB` : "?";
40943
41054
  console.log(chalk2.green(`\u2713 codeindex installed (${sizeMb}) \u2192 ${result.path}`));
40944
- const mcpJsonPath = join70(homedir25(), ".mcp.json");
41055
+ const mcpJsonPath = join71(homedir25(), ".mcp.json");
40945
41056
  const reg = registerCodeindexMcp2(mcpJsonPath, CODEINDEX_BIN_PATH2);
40946
41057
  if (reg.added) console.log(chalk2.dim(` Registered as MCP server in ${mcpJsonPath}`));
40947
41058
  else console.log(chalk2.dim(` Already registered as MCP server`));
@@ -40963,7 +41074,7 @@ companions.command("uninstall").description("Remove the codeindex binary chat-re
40963
41074
  const r = uninstallCodeindex2();
40964
41075
  if (r.removed) console.log(chalk2.green(`\u2713 Removed ${r.path}`));
40965
41076
  else console.log(chalk2.dim(` Nothing to remove at ${r.path}`));
40966
- const mcpJsonPath = join70(homedir25(), ".mcp.json");
41077
+ const mcpJsonPath = join71(homedir25(), ".mcp.json");
40967
41078
  const u = unregisterCodeindexMcp2(mcpJsonPath);
40968
41079
  if (u.removed) console.log(chalk2.dim(` Unregistered MCP server from ${mcpJsonPath}`));
40969
41080
  });
@@ -41515,10 +41626,10 @@ tasks.command("pull [dir]").description("Write TEAM_TASKS.md for your tasks in t
41515
41626
  try {
41516
41627
  const { resolveProjectId: resolveProjectId2 } = await Promise.resolve().then(() => (init_project_resolver(), project_resolver_exports));
41517
41628
  const { renderTeamTasksMd: renderTeamTasksMd2, parseTeamTasksFile: parseTeamTasksFile2 } = await Promise.resolve().then(() => (init_project_tasks(), project_tasks_exports));
41518
- const { writeFileSync: writeFileSync26, readFileSync: readFileSync57, existsSync: existsSync62 } = await import("node:fs");
41519
- const { join: join71 } = await import("node:path");
41520
- const file = join71(cwd, "TEAM_TASKS.md");
41521
- if (!opts.force && existsSync62(file) && parseTeamTasksFile2(readFileSync57(file, "utf8")).length > 0) {
41629
+ const { writeFileSync: writeFileSync26, readFileSync: readFileSync58, existsSync: existsSync62 } = await import("node:fs");
41630
+ const { join: join72 } = await import("node:path");
41631
+ const file = join72(cwd, "TEAM_TASKS.md");
41632
+ if (!opts.force && existsSync62(file) && parseTeamTasksFile2(readFileSync58(file, "utf8")).length > 0) {
41522
41633
  console.error(chalk2.red("TEAM_TASKS.md has unpushed edits."), "Run", chalk2.bold("chat-recall tasks push"), "first, or", chalk2.bold("tasks pull --force"), "to discard.");
41523
41634
  process.exit(1);
41524
41635
  }
@@ -41537,14 +41648,14 @@ tasks.command("push [dir]").description("Push TEAM_TASKS.md status edits back to
41537
41648
  const cwd = dir || process.cwd();
41538
41649
  try {
41539
41650
  const { parseTeamTasksFile: parseTeamTasksFile2 } = await Promise.resolve().then(() => (init_project_tasks(), project_tasks_exports));
41540
- const { readFileSync: readFileSync57, existsSync: existsSync62 } = await import("node:fs");
41541
- const { join: join71 } = await import("node:path");
41542
- const file = join71(cwd, "TEAM_TASKS.md");
41651
+ const { readFileSync: readFileSync58, existsSync: existsSync62 } = await import("node:fs");
41652
+ const { join: join72 } = await import("node:path");
41653
+ const file = join72(cwd, "TEAM_TASKS.md");
41543
41654
  if (!existsSync62(file)) {
41544
41655
  console.error(chalk2.red("no TEAM_TASKS.md here \u2014"), "run", chalk2.bold("chat-recall tasks pull"), "first");
41545
41656
  process.exit(1);
41546
41657
  }
41547
- const edits = parseTeamTasksFile2(readFileSync57(file, "utf8"));
41658
+ const edits = parseTeamTasksFile2(readFileSync58(file, "utf8"));
41548
41659
  let n = 0;
41549
41660
  for (const e of edits) {
41550
41661
  await serverPatch(`/api/tasks/${encodeURIComponent(e.id)}`, { status: e.intent });
@@ -41650,8 +41761,8 @@ team.command("publish <type> <name> <file>").description("Publish a local file a
41650
41761
  console.error(chalk2.red(`Invalid tool: ${opts.tool}. Must be one of: ${validTools.join(", ")}`));
41651
41762
  process.exit(1);
41652
41763
  }
41653
- const { readFileSync: readFileSync57 } = await import("fs");
41654
- const body2 = readFileSync57(file);
41764
+ const { readFileSync: readFileSync58 } = await import("fs");
41765
+ const body2 = readFileSync58(file);
41655
41766
  const { teamPublish: teamPublish2 } = await Promise.resolve().then(() => (init_team_client(), team_client_exports));
41656
41767
  const a = await teamPublish2({
41657
41768
  type,
@@ -42562,6 +42673,15 @@ exclude.command("remove <value>").description("Remove an exclusion (tool name or
42562
42673
  console.log(chalk2.green(`\u2713 Removed ${value}`));
42563
42674
  });
42564
42675
  program.command("login [server-url]").description(`Log in (device flow), mint a sync device token, keep it in sealkeep, the OS keyring or a file only you can read, and register chat-recall-mcp in your AI tools. Defaults to ${DEFAULT_SERVER}.`).option("--token <token>", "Self-host: skip OIDC and save this device token directly").option("--check", "Report-only: exit 0 if a working credential for this server exists, 1 otherwise (never interactive)").option("--issuer <url>", "OIDC issuer URL (default: learned from the server via /api/capabilities)").option("--client-id <id>", "OIDC client id (default: chat-recall-web)").option("--team <slug>", "Team to mint the device token for (default: your only team)").option("--device-id <id>", "Device id for this machine (default: hostname)").option("--prompt-json", "Print the device prompt as one JSON line on stdout, then wait for approval", false).option("--skip-mcp", "Do not register chat-recall-mcp in the AI tools of this machine").action((serverUrl, opts) => runLogin(serverUrl || DEFAULT_SERVER, opts));
42676
+ program.command("token").description("Print the credential of this machine, for a client that runs a header helper instead of a sign-in").option("--header", "Print the whole Authorization header value").action(async (opts) => {
42677
+ const { recallTarget: recallTarget2 } = await Promise.resolve().then(() => (init_remote_target(), remote_target_exports));
42678
+ const target = recallTarget2();
42679
+ if (!target?.token) {
42680
+ console.error(chalk2.red("No stored credential.") + chalk2.dim(" Run `chat-recall login` first."));
42681
+ process.exit(1);
42682
+ }
42683
+ console.log(opts.header ? `Bearer ${target.token}` : target.token);
42684
+ });
42565
42685
  program.command("logout <server-url>").description("Remove one sync target (other targets keep syncing)").action(async (serverUrl) => {
42566
42686
  const { removeCredentials: removeCredentials2, loadAllCredentials: loadAllCredentials2 } = await Promise.resolve().then(() => (init_sync_client(), sync_client_exports));
42567
42687
  if (removeCredentials2(serverUrl)) {