@autohq/cli 0.1.361 → 0.1.362

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.
@@ -23492,7 +23492,7 @@ Object.assign(lookup, {
23492
23492
  // package.json
23493
23493
  var package_default = {
23494
23494
  name: "@autohq/cli",
23495
- version: "0.1.361",
23495
+ version: "0.1.362",
23496
23496
  license: "SEE LICENSE IN README.md",
23497
23497
  publishConfig: {
23498
23498
  access: "public"
@@ -27879,6 +27879,12 @@ var SessionListItemSchema = external_exports.object({
27879
27879
  // Additive and optional so older live frames/list payloads that predate the
27880
27880
  // projection keep parsing; new projections include null when no reason exists.
27881
27881
  failureReason: external_exports.string().nullable().optional(),
27882
+ // Additive and optional so older live frames/list payloads that predate the
27883
+ // projection keep parsing; new projections include null when no selection
27884
+ // exists. Carried so a session-upsert after a selection change keeps the
27885
+ // open-session React Query record in sync without a full refetch.
27886
+ model: ResolvedAgentModelSelectionSchema.nullable().optional(),
27887
+ reasoningEffort: external_exports.string().trim().min(1).nullable().optional(),
27882
27888
  agent: SessionListItemAgentSchema,
27883
27889
  createdAt: external_exports.string().datetime(),
27884
27890
  updatedAt: external_exports.string().datetime(),
@@ -66926,7 +66932,7 @@ var ClaudeAgentBridgeSessionImpl = class {
66926
66932
  this.input.writeOutput?.(
66927
66933
  `agent_bridge_claude_startup_failed duration_ms=${Date.now() - startedAt} error=${error51 instanceof Error ? error51.message : String(error51)}`
66928
66934
  );
66929
- if (this.options.resume !== void 0 && this.state.kind !== "closed") {
66935
+ if (this.options.resume !== void 0 && this.input.allowResumeFallback !== false && this.state.kind !== "closed") {
66930
66936
  const { resume, ...optionsWithoutResume } = this.options;
66931
66937
  this.options = optionsWithoutResume;
66932
66938
  this.input.writeOutput?.(
@@ -67588,7 +67594,11 @@ var ClaudeCodeCommandHandler = class {
67588
67594
  context = null;
67589
67595
  agentSession = null;
67590
67596
  claudeConfig;
67597
+ // Selection-change restarts happen in-process, so prefer the live SDK id even
67598
+ // when the file resume store is stale or temporarily unreadable.
67599
+ lastObservedAgentId = null;
67591
67600
  persistedAgentId = null;
67601
+ requireResumeForNextAgentSession = false;
67592
67602
  injectedCommands = /* @__PURE__ */ new Set();
67593
67603
  // Message commands whose injection has started but not settled. A fresh SDK
67594
67604
  // warm inside sendMessage can outlast the bridge's command-ack window, so a
@@ -68012,14 +68022,19 @@ var ClaudeCodeCommandHandler = class {
68012
68022
  );
68013
68023
  }
68014
68024
  persistAgentId(activeContext, message) {
68015
- const store = this.input.sessionResume;
68016
- if (!store) {
68025
+ if (!("session_id" in message) || typeof message.session_id !== "string") {
68017
68026
  return;
68018
68027
  }
68019
- if (!("session_id" in message) || typeof message.session_id !== "string") {
68028
+ if (!message.session_id) {
68020
68029
  return;
68021
68030
  }
68022
- if (!message.session_id || message.session_id === this.persistedAgentId) {
68031
+ this.lastObservedAgentId = message.session_id;
68032
+ this.requireResumeForNextAgentSession = false;
68033
+ const store = this.input.sessionResume;
68034
+ if (!store) {
68035
+ return;
68036
+ }
68037
+ if (message.session_id === this.persistedAgentId) {
68023
68038
  return;
68024
68039
  }
68025
68040
  try {
@@ -68049,13 +68064,24 @@ var ClaudeCodeCommandHandler = class {
68049
68064
  return void 0;
68050
68065
  }
68051
68066
  }
68067
+ resumeAgentIdForNextSession() {
68068
+ return this.lastObservedAgentId ?? this.storedResumeAgentId();
68069
+ }
68052
68070
  ensureAgentSession() {
68053
68071
  if (this.agentSession) {
68054
68072
  return this.agentSession;
68055
68073
  }
68074
+ const resumeRequired = this.requireResumeForNextAgentSession;
68075
+ const resumeAgentId = this.resumeAgentIdForNextSession();
68076
+ if (resumeRequired && !resumeAgentId) {
68077
+ throw new Error(
68078
+ "Cannot restart Claude Code for a model/effort selection change without a session id to resume"
68079
+ );
68080
+ }
68056
68081
  const session = claudeAgentBridgeRuntime.start({
68057
68082
  claude: this.claudeConfig,
68058
- resumeAgentId: this.storedResumeAgentId(),
68083
+ resumeAgentId,
68084
+ ...resumeRequired ? { allowResumeFallback: false } : {},
68059
68085
  canUseTool: this.canUseTool,
68060
68086
  onMessage: (message, meta3) => this.handleAgentMessage(message, meta3),
68061
68087
  onError: (error51) => this.handleAgentError(error51),
@@ -68085,6 +68111,7 @@ var ClaudeCodeCommandHandler = class {
68085
68111
  return;
68086
68112
  }
68087
68113
  this.claudeConfig = next;
68114
+ this.requireResumeForNextAgentSession = this.lastObservedAgentId !== null;
68088
68115
  this.agentSession?.close();
68089
68116
  this.agentSession = null;
68090
68117
  this.settlePendingQuestions("The runtime restarted to change model");
package/dist/index.js CHANGED
@@ -19479,6 +19479,12 @@ var init_sessions = __esm({
19479
19479
  // Additive and optional so older live frames/list payloads that predate the
19480
19480
  // projection keep parsing; new projections include null when no reason exists.
19481
19481
  failureReason: external_exports.string().nullable().optional(),
19482
+ // Additive and optional so older live frames/list payloads that predate the
19483
+ // projection keep parsing; new projections include null when no selection
19484
+ // exists. Carried so a session-upsert after a selection change keeps the
19485
+ // open-session React Query record in sync without a full refetch.
19486
+ model: ResolvedAgentModelSelectionSchema.nullable().optional(),
19487
+ reasoningEffort: external_exports.string().trim().min(1).nullable().optional(),
19482
19488
  agent: SessionListItemAgentSchema,
19483
19489
  createdAt: external_exports.string().datetime(),
19484
19490
  updatedAt: external_exports.string().datetime(),
@@ -31549,7 +31555,7 @@ var init_package = __esm({
31549
31555
  "package.json"() {
31550
31556
  package_default = {
31551
31557
  name: "@autohq/cli",
31552
- version: "0.1.361",
31558
+ version: "0.1.362",
31553
31559
  license: "SEE LICENSE IN README.md",
31554
31560
  publishConfig: {
31555
31561
  access: "public"
@@ -44597,7 +44603,7 @@ var ClaudeAgentBridgeSessionImpl = class {
44597
44603
  this.input.writeOutput?.(
44598
44604
  `agent_bridge_claude_startup_failed duration_ms=${Date.now() - startedAt} error=${error51 instanceof Error ? error51.message : String(error51)}`
44599
44605
  );
44600
- if (this.options.resume !== void 0 && this.state.kind !== "closed") {
44606
+ if (this.options.resume !== void 0 && this.input.allowResumeFallback !== false && this.state.kind !== "closed") {
44601
44607
  const { resume, ...optionsWithoutResume } = this.options;
44602
44608
  this.options = optionsWithoutResume;
44603
44609
  this.input.writeOutput?.(
@@ -45259,7 +45265,11 @@ var ClaudeCodeCommandHandler = class {
45259
45265
  context = null;
45260
45266
  agentSession = null;
45261
45267
  claudeConfig;
45268
+ // Selection-change restarts happen in-process, so prefer the live SDK id even
45269
+ // when the file resume store is stale or temporarily unreadable.
45270
+ lastObservedAgentId = null;
45262
45271
  persistedAgentId = null;
45272
+ requireResumeForNextAgentSession = false;
45263
45273
  injectedCommands = /* @__PURE__ */ new Set();
45264
45274
  // Message commands whose injection has started but not settled. A fresh SDK
45265
45275
  // warm inside sendMessage can outlast the bridge's command-ack window, so a
@@ -45683,14 +45693,19 @@ var ClaudeCodeCommandHandler = class {
45683
45693
  );
45684
45694
  }
45685
45695
  persistAgentId(activeContext, message) {
45686
- const store = this.input.sessionResume;
45687
- if (!store) {
45696
+ if (!("session_id" in message) || typeof message.session_id !== "string") {
45688
45697
  return;
45689
45698
  }
45690
- if (!("session_id" in message) || typeof message.session_id !== "string") {
45699
+ if (!message.session_id) {
45691
45700
  return;
45692
45701
  }
45693
- if (!message.session_id || message.session_id === this.persistedAgentId) {
45702
+ this.lastObservedAgentId = message.session_id;
45703
+ this.requireResumeForNextAgentSession = false;
45704
+ const store = this.input.sessionResume;
45705
+ if (!store) {
45706
+ return;
45707
+ }
45708
+ if (message.session_id === this.persistedAgentId) {
45694
45709
  return;
45695
45710
  }
45696
45711
  try {
@@ -45720,13 +45735,24 @@ var ClaudeCodeCommandHandler = class {
45720
45735
  return void 0;
45721
45736
  }
45722
45737
  }
45738
+ resumeAgentIdForNextSession() {
45739
+ return this.lastObservedAgentId ?? this.storedResumeAgentId();
45740
+ }
45723
45741
  ensureAgentSession() {
45724
45742
  if (this.agentSession) {
45725
45743
  return this.agentSession;
45726
45744
  }
45745
+ const resumeRequired = this.requireResumeForNextAgentSession;
45746
+ const resumeAgentId = this.resumeAgentIdForNextSession();
45747
+ if (resumeRequired && !resumeAgentId) {
45748
+ throw new Error(
45749
+ "Cannot restart Claude Code for a model/effort selection change without a session id to resume"
45750
+ );
45751
+ }
45727
45752
  const session = claudeAgentBridgeRuntime.start({
45728
45753
  claude: this.claudeConfig,
45729
- resumeAgentId: this.storedResumeAgentId(),
45754
+ resumeAgentId,
45755
+ ...resumeRequired ? { allowResumeFallback: false } : {},
45730
45756
  canUseTool: this.canUseTool,
45731
45757
  onMessage: (message, meta3) => this.handleAgentMessage(message, meta3),
45732
45758
  onError: (error51) => this.handleAgentError(error51),
@@ -45756,6 +45782,7 @@ var ClaudeCodeCommandHandler = class {
45756
45782
  return;
45757
45783
  }
45758
45784
  this.claudeConfig = next;
45785
+ this.requireResumeForNextAgentSession = this.lastObservedAgentId !== null;
45759
45786
  this.agentSession?.close();
45760
45787
  this.agentSession = null;
45761
45788
  this.settlePendingQuestions("The runtime restarted to change model");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.361",
3
+ "version": "0.1.362",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"