@agentchatme/cli 0.0.133 → 0.0.135

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/index.js CHANGED
@@ -582,8 +582,8 @@ function getErrorMap() {
582
582
 
583
583
  // ../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
584
584
  var makeIssue = (params) => {
585
- const { data, path: path9, errorMaps, issueData } = params;
586
- const fullPath = [...path9, ...issueData.path || []];
585
+ const { data, path: path10, errorMaps, issueData } = params;
586
+ const fullPath = [...path10, ...issueData.path || []];
587
587
  const fullIssue = {
588
588
  ...issueData,
589
589
  path: fullPath
@@ -699,11 +699,11 @@ var errorUtil;
699
699
 
700
700
  // ../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
701
701
  var ParseInputLazyPath = class {
702
- constructor(parent, value, path9, key) {
702
+ constructor(parent, value, path10, key) {
703
703
  this._cachedPath = [];
704
704
  this.parent = parent;
705
705
  this.data = value;
706
- this._path = path9;
706
+ this._path = path10;
707
707
  this._key = key;
708
708
  }
709
709
  get path() {
@@ -4561,13 +4561,21 @@ function formatRegistrationOffer(cliPath, platform) {
4561
4561
  return [
4562
4562
  "The AgentChat plugin is installed but this agent has no AgentChat identity yet.",
4563
4563
  "",
4564
- "AgentChat gives you (the agent) a handle other agents can DM, like a phone number. If the user would like that, offer to set it up conversationally:",
4564
+ "AgentChat gives you (the agent) a handle other agents can DM. If the user would like that, offer to set it up \u2014 and FIRST ask whether they already have an AgentChat account (e.g. from another machine, or a Hermes / OpenClaw agent), so you sign them in instead of creating a duplicate:",
4565
4565
  ...hostNote ? [hostNote] : [],
4566
- "1. Ask for the email + desired handle (3\u201330 chars, lowercase letters/digits/hyphens, must start with a letter).",
4567
- `2. Run: ${invoke} register${p} --email <email> --handle <handle>`,
4568
- `3. A 6-digit code lands in their email; ask for it, then run: ${invoke} register${p} --code <code>`,
4569
4566
  "",
4570
- "Do not push \u2014 one short offer is plenty. If declined, drop the topic for the rest of the session."
4567
+ "NEW to AgentChat (most people):",
4568
+ " 1. Ask for their email + a desired handle (3\u201330 chars, lowercase letters/digits/hyphens, must start with a letter).",
4569
+ ` 2. Run: ${invoke} register${p} --email <email> --handle <handle>`,
4570
+ ` 3. A 6-digit code lands in their email; ask for it, then run: ${invoke} register${p} --code <code>`,
4571
+ "",
4572
+ "ALREADY have an AgentChat agent \u2014 sign in, do NOT register a second one:",
4573
+ ` \u2022 They have its API key (ac_\u2026): ${invoke} login${p} --api-key <ac_\u2026>`,
4574
+ ` \u2022 They lost the key: ${invoke} recover${p} --email <email>, then relay the emailed 6-digit code: ${invoke} recover${p} --code <code>`,
4575
+ "",
4576
+ `Then, either way, turn on always-on so you stay reachable when they're away: ${invoke} daemon install${p} (on by default; they can say "go session-only" any time \u2192 ${invoke} daemon disable${p}).`,
4577
+ "",
4578
+ "Do not push the offer \u2014 one short ask is plenty. If declined, drop the topic for the rest of the session."
4571
4579
  ].join("\n");
4572
4580
  }
4573
4581
 
@@ -4965,8 +4973,8 @@ var HttpTransport = class {
4965
4973
  }
4966
4974
  this.fetchFn = f.bind(globalThis);
4967
4975
  }
4968
- async request(method, path9, opts = {}) {
4969
- const url = `${this.baseUrl}${path9}`;
4976
+ async request(method, path10, opts = {}) {
4977
+ const url = `${this.baseUrl}${path10}`;
4970
4978
  const policy = resolveRetryPolicy(opts.retry, this.retry);
4971
4979
  const canRetry = isRetryEligible(method, opts.idempotencyKey, opts.retry);
4972
4980
  const maxAttempts = canRetry ? policy.maxRetries + 1 : 1;
@@ -5285,31 +5293,31 @@ var AgentChatClient = class _AgentChatClient {
5285
5293
  this.onBacklogWarning = options.onBacklogWarning;
5286
5294
  }
5287
5295
  // ─── Internal request helpers ─────────────────────────────────────────────
5288
- async get(path9, opts) {
5289
- const res = await this.http.request("GET", path9, this.toRequestOpts(opts));
5296
+ async get(path10, opts) {
5297
+ const res = await this.http.request("GET", path10, this.toRequestOpts(opts));
5290
5298
  return res.data;
5291
5299
  }
5292
- async del(path9, opts) {
5293
- const res = await this.http.request("DELETE", path9, this.toRequestOpts(opts));
5300
+ async del(path10, opts) {
5301
+ const res = await this.http.request("DELETE", path10, this.toRequestOpts(opts));
5294
5302
  return res.data;
5295
5303
  }
5296
- async post(path9, body, opts) {
5297
- const res = await this.http.request("POST", path9, {
5304
+ async post(path10, body, opts) {
5305
+ const res = await this.http.request("POST", path10, {
5298
5306
  ...this.toRequestOpts(opts),
5299
5307
  body
5300
5308
  });
5301
5309
  return res.data;
5302
5310
  }
5303
- async patch(path9, body, opts) {
5304
- const res = await this.http.request("PATCH", path9, {
5311
+ async patch(path10, body, opts) {
5312
+ const res = await this.http.request("PATCH", path10, {
5305
5313
  ...this.toRequestOpts(opts),
5306
5314
  body
5307
5315
  });
5308
5316
  return res.data;
5309
5317
  }
5310
- async put(path9, body, opts) {
5318
+ async put(path10, body, opts) {
5311
5319
  const headers = opts?.contentType ? { "Content-Type": opts.contentType } : void 0;
5312
- const res = await this.http.request("PUT", path9, {
5320
+ const res = await this.http.request("PUT", path10, {
5313
5321
  ...this.toRequestOpts(opts),
5314
5322
  body,
5315
5323
  rawBody: opts?.rawBody,
@@ -6332,7 +6340,7 @@ async function prompt(question) {
6332
6340
  rl.close();
6333
6341
  }
6334
6342
  }
6335
- var RESTART_HINT = "Restart your agent session (Claude Code: start a new session, or /mcp \u2192 reconnect) so the messaging tools pick up this identity.";
6343
+ var RESTART_HINT = "Your messaging tools pick this up immediately \u2014 no restart needed. (If a send still says NOT_REGISTERED, you're on an older MCP; start a fresh session once to refresh it.)";
6336
6344
  function autoAnchor(handle) {
6337
6345
  const lines = [];
6338
6346
  const ccFile = anchorFilePath("claude-code");
@@ -6397,8 +6405,9 @@ async function runRegister(opts) {
6397
6405
  `API key stored at ${credentialsPath()} (never commit this file).`,
6398
6406
  ...anchorReport,
6399
6407
  "",
6400
- "All AgentChat plugins on this machine now share this identity.",
6408
+ "This identity is scoped to this coding agent \u2014 each coding agent on the machine gets its own handle.",
6401
6409
  `Other agents can DM you at @${pendingHandle}. Check \`agentchat status\` any time.`,
6410
+ "Next, turn on always-on so you're reachable when the user is away: `agentchat daemon install` (on by default \u2014 `agentchat daemon disable` switches to session-only).",
6402
6411
  RESTART_HINT
6403
6412
  ].join("\n")
6404
6413
  );
@@ -6500,7 +6509,14 @@ async function runLogin(opts) {
6500
6509
  created_at: (/* @__PURE__ */ new Date()).toISOString()
6501
6510
  });
6502
6511
  const anchorReport = autoAnchor(me.handle);
6503
- console.log([`Signed in as @${me.handle}.`, ...anchorReport, RESTART_HINT].join("\n"));
6512
+ console.log(
6513
+ [
6514
+ `Signed in as @${me.handle}.`,
6515
+ ...anchorReport,
6516
+ "Next, turn on always-on so you're reachable when the user is away: `agentchat daemon install` (on by default \u2014 `agentchat daemon disable` for session-only).",
6517
+ RESTART_HINT
6518
+ ].join("\n")
6519
+ );
6504
6520
  return 0;
6505
6521
  } catch (err) {
6506
6522
  console.error(`Login failed. ${describeApiError(err)}`);
@@ -6878,7 +6894,7 @@ import * as fs7 from "fs";
6878
6894
  import * as path8 from "path";
6879
6895
 
6880
6896
  // src/version.ts
6881
- var VERSION2 = "0.0.133";
6897
+ var VERSION2 = "0.0.135";
6882
6898
 
6883
6899
  // src/commands/doctor.ts
6884
6900
  function fmt(check) {
@@ -6990,6 +7006,93 @@ async function runAnchor(action, platform) {
6990
7006
  return 0;
6991
7007
  }
6992
7008
 
7009
+ // src/commands/daemon.ts
7010
+ import * as fs8 from "fs";
7011
+ import * as os4 from "os";
7012
+ import * as path9 from "path";
7013
+ import { spawnSync as spawnSync2 } from "child_process";
7014
+ var DAEMON_PKG = "@agentchatme/daemon";
7015
+ function runtimeDir() {
7016
+ return path9.join(os4.homedir(), ".agentchat", "daemon-runtime");
7017
+ }
7018
+ function daemonEntry() {
7019
+ return path9.join(runtimeDir(), "node_modules", "@agentchatme", "daemon", "dist", "index.js");
7020
+ }
7021
+ function ensureDaemon() {
7022
+ if (fs8.existsSync(daemonEntry())) return { ok: true };
7023
+ const dir = runtimeDir();
7024
+ try {
7025
+ fs8.mkdirSync(dir, { recursive: true });
7026
+ } catch (err) {
7027
+ return { ok: false, detail: `could not create ${dir}: ${String(err)}` };
7028
+ }
7029
+ const r = spawnSync2(
7030
+ "npm",
7031
+ ["install", DAEMON_PKG, "--prefix", dir, "--no-save", "--no-audit", "--no-fund"],
7032
+ { encoding: "utf-8", timeout: 18e4 }
7033
+ );
7034
+ if (r.error || r.status !== 0) {
7035
+ const why = (r.stderr || r.error && r.error.message || "unknown error").slice(0, 300);
7036
+ return { ok: false, detail: `npm install ${DAEMON_PKG} failed: ${why}` };
7037
+ }
7038
+ return fs8.existsSync(daemonEntry()) ? { ok: true } : { ok: false, detail: "installed but entrypoint missing" };
7039
+ }
7040
+ function runDaemon(args) {
7041
+ const r = spawnSync2(process.execPath, [daemonEntry(), ...args], { stdio: "inherit" });
7042
+ return r.status ?? 1;
7043
+ }
7044
+ async function runDaemonCmd(sub, platform) {
7045
+ if (platform === "cursor") {
7046
+ console.error("The always-on daemon supports Claude Code and Codex (Cursor not yet).");
7047
+ return 1;
7048
+ }
7049
+ const runtime = platform;
7050
+ const bound = process.env["AGENTCHAT_HOME"]?.trim();
7051
+ const home = bound && bound.length > 0 ? bound : hostHome(platform);
7052
+ if (sub === "install") {
7053
+ const creds = readCredentialsFileAt(home);
7054
+ if (creds === null) {
7055
+ console.error(
7056
+ `No AgentChat identity for ${platform} yet. Register first, then run:
7057
+ agentchat daemon install --platform ${platform}`
7058
+ );
7059
+ return 1;
7060
+ }
7061
+ const got = ensureDaemon();
7062
+ if (!got.ok) {
7063
+ console.error(`Couldn't set up always-on automatically: ${got.detail}`);
7064
+ console.error(`Finish it by hand:
7065
+ npm i -g ${DAEMON_PKG}
7066
+ agentchatd install --runtime ${runtime}`);
7067
+ return 1;
7068
+ }
7069
+ const code = runDaemon(["install", "--runtime", runtime, "--home", home]);
7070
+ if (code === 0) {
7071
+ console.log(
7072
+ [
7073
+ "",
7074
+ `Always-on is ON for @${creds.handle} \u2014 it answers DMs even when you're not in a session, while this machine is up.`,
7075
+ `Want session-only instead? Turn it off any time: agentchat daemon disable --platform ${platform}`
7076
+ ].join("\n")
7077
+ );
7078
+ }
7079
+ return code;
7080
+ }
7081
+ if (sub === "enable" || sub === "disable" || sub === "status" || sub === "uninstall") {
7082
+ if (!fs8.existsSync(daemonEntry())) {
7083
+ if (sub === "status") {
7084
+ console.log("Always-on: not installed (session-only). Turn it on with: agentchat daemon install");
7085
+ return 0;
7086
+ }
7087
+ console.error(`Always-on isn't set up yet. Turn it on with: agentchat daemon install --platform ${platform}`);
7088
+ return sub === "disable" ? 0 : 1;
7089
+ }
7090
+ return runDaemon([sub, "--runtime", runtime, "--home", home]);
7091
+ }
7092
+ console.error("Usage: agentchat daemon <install|enable|disable|status|uninstall> --platform <claude-code|codex>");
7093
+ return 1;
7094
+ }
7095
+
6993
7096
  // src/index.ts
6994
7097
  var USAGE = `agentchat ${VERSION2} \u2014 AgentChat companion CLI for coding agents
6995
7098
 
@@ -7003,6 +7106,7 @@ Usage:
7003
7106
  agentchat status [--json]
7004
7107
  agentchat logout
7005
7108
  agentchat doctor
7109
+ agentchat daemon <install|enable|disable|status|uninstall> --platform <claude-code|codex>
7006
7110
  agentchat anchor <install|remove> --platform <claude-code|codex|cursor>
7007
7111
  agentchat hook <session-start|stop> --platform <claude-code|codex|cursor>
7008
7112
 
@@ -7078,6 +7182,11 @@ async function main(argv = process.argv.slice(2)) {
7078
7182
  return runLogout();
7079
7183
  case "doctor":
7080
7184
  return runDoctor();
7185
+ case "daemon": {
7186
+ const platform = requirePlatform();
7187
+ if (platform === null) return 1;
7188
+ return runDaemonCmd(subcommand, platform);
7189
+ }
7081
7190
  case "anchor": {
7082
7191
  if (subcommand !== "install" && subcommand !== "remove") {
7083
7192
  console.error("Usage: agentchat anchor <install|remove> --platform <claude-code|codex|cursor>");