@hydra-acp/cli 0.1.9 → 0.1.11

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
@@ -306,7 +306,7 @@ var init_config = __esm({
306
306
  })
307
307
  });
308
308
  HydraConfigReadOnly = HydraConfig.extend({
309
- daemon: DaemonConfig.omit({ authToken: true })
309
+ daemon: DaemonConfig.omit({ authToken: true }).default({})
310
310
  });
311
311
  }
312
312
  });
@@ -563,6 +563,15 @@ var init_connection = __esm({
563
563
  }
564
564
  }
565
565
  }
566
+ // Discard any notifications buffered for the given method without firing
567
+ // handlers. Used by the resurrect path to drop the agent's session/load
568
+ // replay: that replay is the agent re-emitting our own history back at
569
+ // us, and if we flushed it through wireAgent's session/update handler
570
+ // every entry would be re-appended to history.jsonl, doubling the log
571
+ // each time the session was woken up.
572
+ drainBuffered(method) {
573
+ this.bufferedNotifications.delete(method);
574
+ }
566
575
  onClose(handler) {
567
576
  this.closeHandlers.push(handler);
568
577
  }
@@ -8227,7 +8236,7 @@ async function runSession(term, config, opts, exitHint) {
8227
8236
  const frozenBodyStyle = stoppedReason !== null ? "tool-status-fail" : "dim";
8228
8237
  const lines = [
8229
8238
  {
8230
- prefix: "\u2692 ",
8239
+ prefix: "\u2699 ",
8231
8240
  prefixStyle: pureThinking ? "tool-status-running" : frozenStyle,
8232
8241
  body: summary,
8233
8242
  bodyStyle: pureThinking ? "tool-status-running" : frozenBodyStyle
@@ -8642,6 +8651,17 @@ import { fileURLToPath as fileURLToPath2 } from "url";
8642
8651
  import { dirname as dirname6, resolve as resolve4 } from "path";
8643
8652
 
8644
8653
  // src/cli/parse-args.ts
8654
+ var KNOWN_BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
8655
+ "all",
8656
+ "foreground",
8657
+ "help",
8658
+ "info",
8659
+ "new",
8660
+ "reattach",
8661
+ "replace",
8662
+ "rotate-token",
8663
+ "version"
8664
+ ]);
8645
8665
  function parseArgs(argv) {
8646
8666
  const positional = [];
8647
8667
  const flags = {};
@@ -8660,6 +8680,11 @@ function parseArgs(argv) {
8660
8680
  continue;
8661
8681
  }
8662
8682
  const key = token.slice(2);
8683
+ if (KNOWN_BOOLEAN_FLAGS.has(key)) {
8684
+ flags[key] = true;
8685
+ i += 1;
8686
+ continue;
8687
+ }
8663
8688
  const next = argv[i + 1];
8664
8689
  if (next !== void 0 && !next.startsWith("--")) {
8665
8690
  flags[key] = next;
@@ -9741,6 +9766,7 @@ var SessionManager = class {
9741
9766
  await agent.kill().catch(() => void 0);
9742
9767
  return this.doResurrectFromImport(params);
9743
9768
  }
9769
+ agent.connection.drainBuffered("session/update");
9744
9770
  const session = new Session({
9745
9771
  sessionId: params.hydraSessionId,
9746
9772
  cwd: params.cwd,
@@ -12880,6 +12906,17 @@ async function main() {
12880
12906
  const positionalAgentId = afterLaunch[0];
12881
12907
  const agentArgs = afterLaunch.slice(1);
12882
12908
  const { flags: flags2 } = parseArgs(beforeLaunch);
12909
+ if (flags2.resume === true) {
12910
+ bareResumeError();
12911
+ return;
12912
+ }
12913
+ if (flags2.reattach === true) {
12914
+ process.stderr.write(
12915
+ "hydra-acp launch: --reattach is not valid here. Pass --resume <id> to attach to a specific session.\n"
12916
+ );
12917
+ process.exit(2);
12918
+ return;
12919
+ }
12883
12920
  const agentId = positionalAgentId ?? resolveOption(flags2, "agent");
12884
12921
  if (!agentId) {
12885
12922
  process.stderr.write(
@@ -12888,8 +12925,7 @@ async function main() {
12888
12925
  process.exit(2);
12889
12926
  return;
12890
12927
  }
12891
- const launchResume = flags2.resume;
12892
- const sessionId2 = typeof launchResume === "string" ? launchResume : resolveOption(flags2, "session-id");
12928
+ const sessionId2 = typeof flags2.resume === "string" ? flags2.resume : resolveOption(flags2, "session-id");
12893
12929
  const name2 = resolveOption(flags2, "name");
12894
12930
  const model2 = resolveOption(flags2, "model");
12895
12931
  await runShim({ sessionId: sessionId2, agentId, agentArgs, name: name2, model: model2 });
@@ -12906,8 +12942,11 @@ async function main() {
12906
12942
  return;
12907
12943
  }
12908
12944
  const subcommand = positional[0];
12909
- const resumeFlag = flags.resume;
12910
- const sessionId = typeof resumeFlag === "string" ? resumeFlag : resolveOption(flags, "session-id");
12945
+ if (flags.resume === true) {
12946
+ bareResumeError();
12947
+ return;
12948
+ }
12949
+ const sessionId = typeof flags.resume === "string" ? flags.resume : resolveOption(flags, "session-id");
12911
12950
  const name = resolveOption(flags, "name");
12912
12951
  const agentIdFromFlag = resolveOption(flags, "agent");
12913
12952
  const model = resolveOption(flags, "model");
@@ -13064,7 +13103,7 @@ async function main() {
13064
13103
  }
13065
13104
  async function dispatchTui(flags, base) {
13066
13105
  const cwd = resolveOption(flags, "cwd");
13067
- const resume = flags.resume === true;
13106
+ const resume = flags.reattach === true;
13068
13107
  const forceNew = flags.new === true;
13069
13108
  const { runTui } = await Promise.resolve().then(() => (init_tui(), tui_exports));
13070
13109
  const tuiOpts = { resume, forceNew };
@@ -13085,6 +13124,12 @@ async function dispatchTui(flags, base) {
13085
13124
  }
13086
13125
  await runTui(tuiOpts);
13087
13126
  }
13127
+ function bareResumeError() {
13128
+ process.stderr.write(
13129
+ "hydra-acp: --resume requires a session id. Use --resume <id> to attach to a specific session, or --reattach to pick the most recent one in cwd.\n"
13130
+ );
13131
+ process.exit(2);
13132
+ }
13088
13133
  function readVersion() {
13089
13134
  try {
13090
13135
  const here = dirname6(fileURLToPath2(import.meta.url));
@@ -13110,6 +13155,7 @@ function printHelp() {
13110
13155
  " from the registry. Args after <agent>",
13111
13156
  " are forwarded to the agent's command.",
13112
13157
  " hydra-acp --resume <id> Attach to an existing session (TUI when in a terminal, shim otherwise)",
13158
+ " hydra-acp --reattach Attach to the most-recent session for the current cwd (TUI/shim auto-pick)",
13113
13159
  " hydra-acp init [--rotate-token] Initialize ~/.hydra-acp/config.json",
13114
13160
  " hydra-acp daemon start [--foreground] Start daemon (detached by default; --foreground to attach)",
13115
13161
  " hydra-acp daemon stop|restart|status",
@@ -13128,9 +13174,9 @@ function printHelp() {
13128
13174
  " hydra-acp extensions logs <name> [-f] [-n N]Tail or follow an extension's log",
13129
13175
  " hydra-acp agents [list] List agents in the cached registry",
13130
13176
  " hydra-acp agents refresh Force a registry re-fetch",
13131
- " hydra-acp tui flags: [--resume [<id>]] [--new] [--agent <id>] [--model <id>] [--cwd <path>] [--name <label>]",
13132
- " --resume <id> attaches to a specific session; bare --resume picks the most-recent",
13133
- " in cwd. Smart default (no flags): picks if any live sessions exist, else new.",
13177
+ " hydra-acp tui flags: [--resume <id>] [--reattach] [--new] [--agent <id>] [--model <id>] [--cwd <path>] [--name <label>]",
13178
+ " --resume <id> attaches to a specific session; --reattach picks the most-recent in cwd.",
13179
+ " Smart default (no flags): shows a picker when sessions exist, else new.",
13134
13180
  " hydra-acp --version Print version",
13135
13181
  " hydra-acp --help Show this help",
13136
13182
  "",
package/dist/index.d.ts CHANGED
@@ -1532,6 +1532,7 @@ declare class JsonRpcConnection {
1532
1532
  onRequest(method: string, handler: RequestHandler): void;
1533
1533
  setDefaultHandler(handler: RequestHandler): void;
1534
1534
  onNotification(method: string, handler: NotificationHandler): void;
1535
+ drainBuffered(method: string): void;
1535
1536
  onClose(handler: (err?: Error) => void): void;
1536
1537
  request<T = unknown>(method: string, params?: unknown): Promise<T>;
1537
1538
  requestWithId<T = unknown>(method: string, params?: unknown): {
package/dist/index.js CHANGED
@@ -162,7 +162,7 @@ var HydraConfig = z.object({
162
162
  })
163
163
  });
164
164
  var HydraConfigReadOnly = HydraConfig.extend({
165
- daemon: DaemonConfig.omit({ authToken: true })
165
+ daemon: DaemonConfig.omit({ authToken: true }).default({})
166
166
  });
167
167
  function extensionList(config) {
168
168
  return Object.entries(config.extensions).map(([name, body]) => ({
@@ -1162,6 +1162,15 @@ var JsonRpcConnection = class _JsonRpcConnection {
1162
1162
  }
1163
1163
  }
1164
1164
  }
1165
+ // Discard any notifications buffered for the given method without firing
1166
+ // handlers. Used by the resurrect path to drop the agent's session/load
1167
+ // replay: that replay is the agent re-emitting our own history back at
1168
+ // us, and if we flushed it through wireAgent's session/update handler
1169
+ // every entry would be re-appended to history.jsonl, doubling the log
1170
+ // each time the session was woken up.
1171
+ drainBuffered(method) {
1172
+ this.bufferedNotifications.delete(method);
1173
+ }
1165
1174
  onClose(handler) {
1166
1175
  this.closeHandlers.push(handler);
1167
1176
  }
@@ -3218,6 +3227,7 @@ var SessionManager = class {
3218
3227
  await agent.kill().catch(() => void 0);
3219
3228
  return this.doResurrectFromImport(params);
3220
3229
  }
3230
+ agent.connection.drainBuffered("session/update");
3221
3231
  const session = new Session({
3222
3232
  sessionId: params.hydraSessionId,
3223
3233
  cwd: params.cwd,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hydra-acp/cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Multi-client ACP session daemon: spawn agents, attach over WSS, multiplex sessions across editors.",
5
5
  "license": "MIT",
6
6
  "type": "module",