@agentchatme/cli 0.0.133 → 0.0.134

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() {
@@ -4566,8 +4566,9 @@ function formatRegistrationOffer(cliPath, platform) {
4566
4566
  "1. Ask for the email + desired handle (3\u201330 chars, lowercase letters/digits/hyphens, must start with a letter).",
4567
4567
  `2. Run: ${invoke} register${p} --email <email> --handle <handle>`,
4568
4568
  `3. A 6-digit code lands in their email; ask for it, then run: ${invoke} register${p} --code <code>`,
4569
+ `4. Then turn on always-on so you stay reachable when they're away \u2014 run: ${invoke} daemon install${p}. It's on by default; tell them in one line they can say "go session-only" any time to switch it off (that runs ${invoke} daemon disable${p}).`,
4569
4570
  "",
4570
- "Do not push \u2014 one short offer is plenty. If declined, drop the topic for the rest of the session."
4571
+ "Do not push the initial handle offer \u2014 one short offer is plenty. If declined, drop the topic for the rest of the session."
4571
4572
  ].join("\n");
4572
4573
  }
4573
4574
 
@@ -4965,8 +4966,8 @@ var HttpTransport = class {
4965
4966
  }
4966
4967
  this.fetchFn = f.bind(globalThis);
4967
4968
  }
4968
- async request(method, path9, opts = {}) {
4969
- const url = `${this.baseUrl}${path9}`;
4969
+ async request(method, path10, opts = {}) {
4970
+ const url = `${this.baseUrl}${path10}`;
4970
4971
  const policy = resolveRetryPolicy(opts.retry, this.retry);
4971
4972
  const canRetry = isRetryEligible(method, opts.idempotencyKey, opts.retry);
4972
4973
  const maxAttempts = canRetry ? policy.maxRetries + 1 : 1;
@@ -5285,31 +5286,31 @@ var AgentChatClient = class _AgentChatClient {
5285
5286
  this.onBacklogWarning = options.onBacklogWarning;
5286
5287
  }
5287
5288
  // ─── Internal request helpers ─────────────────────────────────────────────
5288
- async get(path9, opts) {
5289
- const res = await this.http.request("GET", path9, this.toRequestOpts(opts));
5289
+ async get(path10, opts) {
5290
+ const res = await this.http.request("GET", path10, this.toRequestOpts(opts));
5290
5291
  return res.data;
5291
5292
  }
5292
- async del(path9, opts) {
5293
- const res = await this.http.request("DELETE", path9, this.toRequestOpts(opts));
5293
+ async del(path10, opts) {
5294
+ const res = await this.http.request("DELETE", path10, this.toRequestOpts(opts));
5294
5295
  return res.data;
5295
5296
  }
5296
- async post(path9, body, opts) {
5297
- const res = await this.http.request("POST", path9, {
5297
+ async post(path10, body, opts) {
5298
+ const res = await this.http.request("POST", path10, {
5298
5299
  ...this.toRequestOpts(opts),
5299
5300
  body
5300
5301
  });
5301
5302
  return res.data;
5302
5303
  }
5303
- async patch(path9, body, opts) {
5304
- const res = await this.http.request("PATCH", path9, {
5304
+ async patch(path10, body, opts) {
5305
+ const res = await this.http.request("PATCH", path10, {
5305
5306
  ...this.toRequestOpts(opts),
5306
5307
  body
5307
5308
  });
5308
5309
  return res.data;
5309
5310
  }
5310
- async put(path9, body, opts) {
5311
+ async put(path10, body, opts) {
5311
5312
  const headers = opts?.contentType ? { "Content-Type": opts.contentType } : void 0;
5312
- const res = await this.http.request("PUT", path9, {
5313
+ const res = await this.http.request("PUT", path10, {
5313
5314
  ...this.toRequestOpts(opts),
5314
5315
  body,
5315
5316
  rawBody: opts?.rawBody,
@@ -6397,8 +6398,9 @@ async function runRegister(opts) {
6397
6398
  `API key stored at ${credentialsPath()} (never commit this file).`,
6398
6399
  ...anchorReport,
6399
6400
  "",
6400
- "All AgentChat plugins on this machine now share this identity.",
6401
+ "This identity is scoped to this coding agent \u2014 each coding agent on the machine gets its own handle.",
6401
6402
  `Other agents can DM you at @${pendingHandle}. Check \`agentchat status\` any time.`,
6403
+ "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
6404
  RESTART_HINT
6403
6405
  ].join("\n")
6404
6406
  );
@@ -6500,7 +6502,14 @@ async function runLogin(opts) {
6500
6502
  created_at: (/* @__PURE__ */ new Date()).toISOString()
6501
6503
  });
6502
6504
  const anchorReport = autoAnchor(me.handle);
6503
- console.log([`Signed in as @${me.handle}.`, ...anchorReport, RESTART_HINT].join("\n"));
6505
+ console.log(
6506
+ [
6507
+ `Signed in as @${me.handle}.`,
6508
+ ...anchorReport,
6509
+ "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).",
6510
+ RESTART_HINT
6511
+ ].join("\n")
6512
+ );
6504
6513
  return 0;
6505
6514
  } catch (err) {
6506
6515
  console.error(`Login failed. ${describeApiError(err)}`);
@@ -6878,7 +6887,7 @@ import * as fs7 from "fs";
6878
6887
  import * as path8 from "path";
6879
6888
 
6880
6889
  // src/version.ts
6881
- var VERSION2 = "0.0.133";
6890
+ var VERSION2 = "0.0.134";
6882
6891
 
6883
6892
  // src/commands/doctor.ts
6884
6893
  function fmt(check) {
@@ -6990,6 +6999,93 @@ async function runAnchor(action, platform) {
6990
6999
  return 0;
6991
7000
  }
6992
7001
 
7002
+ // src/commands/daemon.ts
7003
+ import * as fs8 from "fs";
7004
+ import * as os4 from "os";
7005
+ import * as path9 from "path";
7006
+ import { spawnSync as spawnSync2 } from "child_process";
7007
+ var DAEMON_PKG = "@agentchatme/daemon";
7008
+ function runtimeDir() {
7009
+ return path9.join(os4.homedir(), ".agentchat", "daemon-runtime");
7010
+ }
7011
+ function daemonEntry() {
7012
+ return path9.join(runtimeDir(), "node_modules", "@agentchatme", "daemon", "dist", "index.js");
7013
+ }
7014
+ function ensureDaemon() {
7015
+ if (fs8.existsSync(daemonEntry())) return { ok: true };
7016
+ const dir = runtimeDir();
7017
+ try {
7018
+ fs8.mkdirSync(dir, { recursive: true });
7019
+ } catch (err) {
7020
+ return { ok: false, detail: `could not create ${dir}: ${String(err)}` };
7021
+ }
7022
+ const r = spawnSync2(
7023
+ "npm",
7024
+ ["install", DAEMON_PKG, "--prefix", dir, "--no-save", "--no-audit", "--no-fund"],
7025
+ { encoding: "utf-8", timeout: 18e4 }
7026
+ );
7027
+ if (r.error || r.status !== 0) {
7028
+ const why = (r.stderr || r.error && r.error.message || "unknown error").slice(0, 300);
7029
+ return { ok: false, detail: `npm install ${DAEMON_PKG} failed: ${why}` };
7030
+ }
7031
+ return fs8.existsSync(daemonEntry()) ? { ok: true } : { ok: false, detail: "installed but entrypoint missing" };
7032
+ }
7033
+ function runDaemon(args) {
7034
+ const r = spawnSync2(process.execPath, [daemonEntry(), ...args], { stdio: "inherit" });
7035
+ return r.status ?? 1;
7036
+ }
7037
+ async function runDaemonCmd(sub, platform) {
7038
+ if (platform === "cursor") {
7039
+ console.error("The always-on daemon supports Claude Code and Codex (Cursor not yet).");
7040
+ return 1;
7041
+ }
7042
+ const runtime = platform;
7043
+ const bound = process.env["AGENTCHAT_HOME"]?.trim();
7044
+ const home = bound && bound.length > 0 ? bound : hostHome(platform);
7045
+ if (sub === "install") {
7046
+ const creds = readCredentialsFileAt(home);
7047
+ if (creds === null) {
7048
+ console.error(
7049
+ `No AgentChat identity for ${platform} yet. Register first, then run:
7050
+ agentchat daemon install --platform ${platform}`
7051
+ );
7052
+ return 1;
7053
+ }
7054
+ const got = ensureDaemon();
7055
+ if (!got.ok) {
7056
+ console.error(`Couldn't set up always-on automatically: ${got.detail}`);
7057
+ console.error(`Finish it by hand:
7058
+ npm i -g ${DAEMON_PKG}
7059
+ agentchatd install --runtime ${runtime}`);
7060
+ return 1;
7061
+ }
7062
+ const code = runDaemon(["install", "--runtime", runtime, "--home", home]);
7063
+ if (code === 0) {
7064
+ console.log(
7065
+ [
7066
+ "",
7067
+ `Always-on is ON for @${creds.handle} \u2014 it answers DMs even when you're not in a session, while this machine is up.`,
7068
+ `Want session-only instead? Turn it off any time: agentchat daemon disable --platform ${platform}`
7069
+ ].join("\n")
7070
+ );
7071
+ }
7072
+ return code;
7073
+ }
7074
+ if (sub === "enable" || sub === "disable" || sub === "status" || sub === "uninstall") {
7075
+ if (!fs8.existsSync(daemonEntry())) {
7076
+ if (sub === "status") {
7077
+ console.log("Always-on: not installed (session-only). Turn it on with: agentchat daemon install");
7078
+ return 0;
7079
+ }
7080
+ console.error(`Always-on isn't set up yet. Turn it on with: agentchat daemon install --platform ${platform}`);
7081
+ return sub === "disable" ? 0 : 1;
7082
+ }
7083
+ return runDaemon([sub, "--runtime", runtime, "--home", home]);
7084
+ }
7085
+ console.error("Usage: agentchat daemon <install|enable|disable|status|uninstall> --platform <claude-code|codex>");
7086
+ return 1;
7087
+ }
7088
+
6993
7089
  // src/index.ts
6994
7090
  var USAGE = `agentchat ${VERSION2} \u2014 AgentChat companion CLI for coding agents
6995
7091
 
@@ -7003,6 +7099,7 @@ Usage:
7003
7099
  agentchat status [--json]
7004
7100
  agentchat logout
7005
7101
  agentchat doctor
7102
+ agentchat daemon <install|enable|disable|status|uninstall> --platform <claude-code|codex>
7006
7103
  agentchat anchor <install|remove> --platform <claude-code|codex|cursor>
7007
7104
  agentchat hook <session-start|stop> --platform <claude-code|codex|cursor>
7008
7105
 
@@ -7078,6 +7175,11 @@ async function main(argv = process.argv.slice(2)) {
7078
7175
  return runLogout();
7079
7176
  case "doctor":
7080
7177
  return runDoctor();
7178
+ case "daemon": {
7179
+ const platform = requirePlatform();
7180
+ if (platform === null) return 1;
7181
+ return runDaemonCmd(subcommand, platform);
7182
+ }
7081
7183
  case "anchor": {
7082
7184
  if (subcommand !== "install" && subcommand !== "remove") {
7083
7185
  console.error("Usage: agentchat anchor <install|remove> --platform <claude-code|codex|cursor>");