@codexhost/cli-darwin-arm64 0.16.1 → 0.17.1

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.
@@ -19089,6 +19089,32 @@ function createAntigravityUsageStatistics(environment) {
19089
19089
  }
19090
19090
 
19091
19091
  // dist/antigravity-adapter.js
19092
+ function unstreamedReplyTail(streamed, reply) {
19093
+ const shown = streamed.replace(/\s+/gu, "");
19094
+ if (shown === "")
19095
+ return null;
19096
+ const replied = reply.replace(/\s+/gu, "");
19097
+ if (shown.endsWith(replied))
19098
+ return "";
19099
+ let at = 0;
19100
+ let matched = 0;
19101
+ while (matched < shown.length && at < reply.length) {
19102
+ const char = reply[at] ?? "";
19103
+ if (/\s/u.test(char)) {
19104
+ at += 1;
19105
+ continue;
19106
+ }
19107
+ if (char !== shown[matched])
19108
+ return null;
19109
+ at += 1;
19110
+ matched += 1;
19111
+ }
19112
+ if (matched < shown.length)
19113
+ return null;
19114
+ const tail = reply.slice(at);
19115
+ const shownTrailing = /\s*$/u.exec(streamed)?.[0] ?? "";
19116
+ return tail.startsWith(shownTrailing) ? tail.slice(shownTrailing.length) : tail;
19117
+ }
19092
19118
  var antigravityHarnessId = harnessIdSchema.parse("antigravity");
19093
19119
  var DEFAULT_INSPECT_TIMEOUT_MS = 2e4;
19094
19120
  var DEFAULT_PRINT_TIMEOUT = "30m";
@@ -19573,6 +19599,7 @@ var AntigravitySession = class {
19573
19599
  logPath,
19574
19600
  agentItem: null,
19575
19601
  agentText: "",
19602
+ turnAgentText: "",
19576
19603
  tools: /* @__PURE__ */ new Map(),
19577
19604
  completedItems: [],
19578
19605
  stderr: "",
@@ -19770,19 +19797,27 @@ ${line}`).slice(-8e3);
19770
19797
  const repliedThisTurn = Boolean(active.agentItem) || turnReply.trim() !== "";
19771
19798
  if (response)
19772
19799
  this.#lastResultResponse = response;
19773
- if (turnReply.trim() !== "")
19774
- this.#appendOrSyncAgentText(active, turnReply, false);
19800
+ if (turnReply.trim() !== "") {
19801
+ const unshown = unstreamedReplyTail(active.turnAgentText, turnReply);
19802
+ if (unshown === null)
19803
+ this.#appendOrSyncAgentText(active, turnReply, false);
19804
+ else if (unshown.trim() !== "")
19805
+ this.#appendAgentText(active, unshown);
19806
+ }
19807
+ if (!convId) {
19808
+ this.#completeIdentitylessTurn(active, event);
19809
+ return;
19810
+ }
19775
19811
  const safeTurnId = event.result.num_turns !== void 0 && event.result.num_turns !== null ? `turn:${event.result.num_turns}` : `turn:${this.#history.snapshot().length + 1}`;
19776
- const safeSessionId = convId || this.#nativeRef?.nativeSessionId || "unknown-session";
19777
19812
  const nativeTurnRef = nativeTurnRefSchema.parse({
19778
19813
  harnessId: this.harnessId,
19779
- nativeSessionId: safeSessionId,
19814
+ nativeSessionId: convId,
19780
19815
  nativeTurnKey: safeTurnId,
19781
19816
  formatVersion: 1
19782
19817
  });
19783
19818
  const checkpoint = nativeCheckpointRefSchema.parse({
19784
19819
  harnessId: this.harnessId,
19785
- nativeSessionId: safeSessionId,
19820
+ nativeSessionId: convId,
19786
19821
  checkpointId: safeTurnId,
19787
19822
  formatVersion: 1
19788
19823
  });
@@ -19799,16 +19834,33 @@ ${line}`).slice(-8e3);
19799
19834
  this.#completeTurn(active, { status: "succeeded", checkpoint }, nativeTurnRef);
19800
19835
  }
19801
19836
  } else {
19802
- const nativeError = event.result.error?.trim();
19803
- const errorDetail = nativeError || active.stderr;
19804
- const error51 = normalizedProcessError(errorDetail, `Antigravity Turn ended with status ${event.result.status}`, nativeError !== void 0);
19805
- if (repliedThisTurn && nativeError && this.#reportedEarlier(error51)) {
19837
+ const error51 = this.#resultError(active, event);
19838
+ if (repliedThisTurn && event.result.error?.trim() && this.#reportedEarlier(error51)) {
19806
19839
  this.#completeTurn(active, { status: "succeeded", checkpoint }, nativeTurnRef);
19807
19840
  } else {
19808
19841
  this.#completeTurn(active, { status: "failed", error: error51, checkpoint }, nativeTurnRef);
19809
19842
  }
19810
19843
  }
19811
19844
  }
19845
+ /** A Turn agy ended without a Conversation keeps its native outcome but no native identity. */
19846
+ #completeIdentitylessTurn(active, event) {
19847
+ if (active.cancellationRequested) {
19848
+ this.#completeTurn(active, { status: "cancelled", reason: "Cancelled by user" });
19849
+ return;
19850
+ }
19851
+ this.#completeTurn(active, {
19852
+ status: "failed",
19853
+ error: event.result.status === "SUCCESS" ? {
19854
+ code: "protocolError",
19855
+ message: "Antigravity finished the Turn without a Conversation identity",
19856
+ retryable: true
19857
+ } : this.#resultError(active, event)
19858
+ });
19859
+ }
19860
+ #resultError(active, event) {
19861
+ const nativeError = event.result.error?.trim();
19862
+ return normalizedProcessError(nativeError || active.stderr, `Antigravity Turn ended with status ${event.result.status}`, nativeError !== void 0);
19863
+ }
19812
19864
  #reportedEarlier(error51) {
19813
19865
  return this.#history.snapshot().some(({ outcome }) => outcome.status === "failed" && outcome.error.code === error51.code && outcome.error.message === error51.message);
19814
19866
  }
@@ -19955,6 +20007,7 @@ ${line}`).slice(-8e3);
19955
20007
  this.#appendAgentText(active, text);
19956
20008
  }
19957
20009
  #appendAgentText(active, text) {
20010
+ active.turnAgentText += text;
19958
20011
  if (!active.agentItem) {
19959
20012
  active.agentItem = { type: "agentMessage", itemId: this.#newItemId(), text };
19960
20013
  active.agentText = text;
@@ -55584,6 +55584,8 @@ function conversationMessages(values, sessionId) {
55584
55584
  type: value.type,
55585
55585
  uuid: value.uuid,
55586
55586
  message: value.message,
55587
+ // Failure metadata belongs to the outer SDK/transcript record, not its Message.
55588
+ failed: value.type === "assistant" && (typeof value.error === "string" || value.isApiErrorMessage === true),
55587
55589
  nested: typeof value.parent_tool_use_id === "string" && value.parent_tool_use_id.length > 0,
55588
55590
  interrupted,
55589
55591
  startsTurn: false,
@@ -55649,7 +55651,7 @@ function turnOutcome(messages) {
55649
55651
  if (messages.some(({ interrupted }) => interrupted))
55650
55652
  return { status: "cancelled", reason: "Cancelled by user" };
55651
55653
  const assistants = messages.filter(({ type }) => type === "assistant");
55652
- const failed = assistants.some(({ message }) => typeof message.error === "string");
55654
+ const failed = assistants.some(({ failed: failed2, nested }) => failed2 && !nested);
55653
55655
  if (failed) {
55654
55656
  return {
55655
55657
  status: "failed",
@@ -55735,6 +55737,7 @@ function mapClaudeSnapshot(values, sessionId) {
55735
55737
  }
55736
55738
  if (message.type !== "assistant")
55737
55739
  return [];
55740
+ const assistantOutcome = outcome.status === "failed" && (!message.failed || message.nested) ? { status: "succeeded" } : itemOutcome(outcome);
55738
55741
  const content = message.message.content;
55739
55742
  const text2 = textParts(content).join("");
55740
55743
  const reasoning = thinkingParts(content).join("");
@@ -55746,7 +55749,7 @@ function mapClaudeSnapshot(values, sessionId) {
55746
55749
  itemId: claudeTranscriptItemId(user.uuid, "agentMessage", agentMessageOrdinal += 1),
55747
55750
  text: text2
55748
55751
  },
55749
- outcome: itemOutcome(outcome)
55752
+ outcome: assistantOutcome
55750
55753
  }
55751
55754
  ] : [];
55752
55755
  }
@@ -55763,7 +55766,7 @@ function mapClaudeSnapshot(values, sessionId) {
55763
55766
  itemId: claudeTranscriptItemId(user.uuid, "reasoning", reasoningOrdinal += 1),
55764
55767
  text: reasoning
55765
55768
  },
55766
- outcome: itemOutcome(outcome)
55769
+ outcome: assistantOutcome
55767
55770
  });
55768
55771
  projectedReasoning = true;
55769
55772
  continue;
@@ -55775,7 +55778,7 @@ function mapClaudeSnapshot(values, sessionId) {
55775
55778
  itemId: claudeTranscriptItemId(user.uuid, "agentMessage", agentMessageOrdinal += 1),
55776
55779
  text: text2
55777
55780
  },
55778
- outcome: itemOutcome(outcome)
55781
+ outcome: assistantOutcome
55779
55782
  });
55780
55783
  projectedText = true;
55781
55784
  continue;
@@ -57551,7 +57554,8 @@ var ClaudeSdkTransport = class {
57551
57554
  const activeQuery = this.#query;
57552
57555
  if (!activeQuery)
57553
57556
  throw new Error("Claude SDK transport is not running");
57554
- this.#idleAccumulator?.requestCancel();
57557
+ const idle = this.#idleAccumulator ??= new ClaudeNativeTurnAccumulator(this.#provider ? { provider: this.#provider } : {});
57558
+ idle.requestCancel();
57555
57559
  try {
57556
57560
  await this.#stopRequest(activeQuery.interrupt(), INTERRUPT_TIMEOUT_MESSAGE);
57557
57561
  } catch (error52) {
@@ -59978,7 +59982,9 @@ var ClaudeHarnessSession = class {
59978
59982
  active.cancellationRequested = true;
59979
59983
  const transport = this.#transport;
59980
59984
  const taskIds = this.#backgroundTaskIds(active);
59981
- if (transport && (taskIds.length > 0 || active.held && (active.rootSegmentActive || this.#occupancy.awaitingContinuation || active.steersAwaitingNative.size > 0))) {
59985
+ if (transport && (taskIds.length > 0 || // A written steer survives the interrupt and runs as Claude's next native turn, so the
59986
+ // Turn stays open to interrupt that turn too instead of leaking it into the next one.
59987
+ active.steersAwaitingNative.size > 0 || active.held && (active.rootSegmentActive || this.#occupancy.awaitingContinuation))) {
59982
59988
  await this.#cancelBackgroundWork(active, transport, taskIds);
59983
59989
  return { ok: true, value: { cancellationRequested: true } };
59984
59990
  }
@@ -18350,6 +18350,16 @@ function snapshotFromHistory(contents, ref, cwd, profile = CODEBUDDY_RUNTIME_PRO
18350
18350
  continue;
18351
18351
  if (supportsNativeCommands && row.type === "message" && row.role === "user" && data.agent === "compact" && !manualCompactions.has(text(row.id)))
18352
18352
  continue;
18353
+ if (row.type === "message" && row.role === "user" && data.startsNewUserRequest === false && !localCommand && data.agent !== "compact" && !isNativeCompactionSummary(row)) {
18354
+ const contextOnly = body.trim().length > 0 && body.replace(/<system-reminder\b[^>]*\sdata-role=(["'])user-context\1[^>]*>[\s\S]*?<\/system-reminder>/gu, "").trim().length === 0;
18355
+ if (data.isMeta === true || contextOnly)
18356
+ continue;
18357
+ if (current) {
18358
+ if (body)
18359
+ current.input.push({ type: "text", text: body });
18360
+ continue;
18361
+ }
18362
+ }
18353
18363
  if (includeCompactionHistory && isNativeCompactionSummary(row)) {
18354
18364
  if (supportsNativeCommands && current) {
18355
18365
  const outcome = data.isCompacted === true ? { status: "succeeded" } : {
@@ -17042,6 +17042,16 @@ function cursorConfigDirectory(environment) {
17042
17042
  const home = environment.HOME ?? environment.USERPROFILE ?? os2.homedir();
17043
17043
  return environment.CURSOR_CONFIG_DIR?.trim() ? path6.resolve(environment.CURSOR_CONFIG_DIR) : environment.XDG_CONFIG_HOME?.trim() ? path6.resolve(environment.XDG_CONFIG_HOME, "cursor") : path6.join(home, ".cursor");
17044
17044
  }
17045
+ function cursorCliApprovalModeIsUnrestricted(environment, cwd = process.cwd()) {
17046
+ try {
17047
+ const home = (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) ?? os2.userInfo().homedir;
17048
+ const directory = environment.CURSOR_CONFIG_DIR?.trim() ? environment.CURSOR_CONFIG_DIR : environment.XDG_CONFIG_HOME?.trim() ? path6.join(environment.XDG_CONFIG_HOME, "cursor") : path6.join(home, ".cursor");
17049
+ const raw = JSON.parse(readFileSync(path6.resolve(cwd, directory, "cli-config.json"), "utf8"));
17050
+ return !!raw && typeof raw === "object" && !Array.isArray(raw) && raw.approvalMode === "unrestricted";
17051
+ } catch {
17052
+ return false;
17053
+ }
17054
+ }
17045
17055
  function cursorSessionDirectory(sessionId, environment) {
17046
17056
  if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(sessionId))
17047
17057
  throw new Error("Unsupported Cursor native session ID");
@@ -17138,7 +17148,8 @@ function readCursorNativeHistory(sessionId, cwd, environment, allowMissing = fal
17138
17148
  result.push({
17139
17149
  id,
17140
17150
  text: one(user, 1).toString("utf8"),
17141
- ...rewindRoot ? { rewindRoot } : {}
17151
+ ...rewindRoot ? { rewindRoot } : {},
17152
+ ...user.get(15)?.length ? { notification: true } : {}
17142
17153
  });
17143
17154
  }
17144
17155
  }
@@ -17412,12 +17423,17 @@ function cursorCatalog(info) {
17412
17423
  const native = cursorModels(info);
17413
17424
  const thinking = /* @__PURE__ */ new Map();
17414
17425
  const models = native.models.map((model2) => {
17415
- const config2 = model2.value === native.current ? info.configOptions : info.nativeModels?.find((entry) => entry.value === model2.value)?.configOptions;
17426
+ const live = model2.value === native.current;
17427
+ const config2 = live ? info.configOptions : info.nativeModels?.find((entry) => entry.value === model2.value)?.configOptions;
17416
17428
  const options = cursorThinking(config2);
17417
17429
  for (const { id, label } of options)
17418
17430
  thinking.set(id, { id, label });
17419
17431
  return {
17420
- ref: cursorConfiguredModelRef(model2.value, config2),
17432
+ // Only the live model's parameters reflect the user's Cursor settings. The parameterized
17433
+ // catalog reports Cursor's built-in defaults for every other model (for example
17434
+ // `fast=true`), so pinning them would override the user's remembered per-model parameters.
17435
+ // A bare Ref selects only the model and lets Cursor apply those parameters itself.
17436
+ ref: live ? cursorConfiguredModelRef(model2.value, config2) : cursorModelRef(model2.value),
17421
17437
  label: model2.name,
17422
17438
  supportedThinkingOptionIds: options.map(({ id }) => id)
17423
17439
  };
@@ -21716,7 +21732,8 @@ var CursorTransport = class {
21716
21732
  return this.#preparation ??= this.#prepare();
21717
21733
  }
21718
21734
  async #prepare() {
21719
- const invocation = cursorInvocation(this.options.environment, this.options.command, this.options.executionPolicy === "unattended-full-access" ? ["--force", "acp"] : ["acp"]);
21735
+ const useForce = this.options.executionPolicy === "unattended-full-access" || cursorCliApprovalModeIsUnrestricted(this.options.environment, this.options.cwd);
21736
+ const invocation = cursorInvocation(this.options.environment, this.options.command, useForce ? ["--force", "acp"] : ["acp"]);
21720
21737
  const child = spawn(invocation.command, invocation.arguments, {
21721
21738
  cwd: this.options.cwd,
21722
21739
  env: this.options.environment,
@@ -23803,19 +23820,22 @@ var CursorSession = class {
23803
23820
  const administrative = command.input.map((part) => part.text).join("\n").trim().toLowerCase() === "/copy-request-id";
23804
23821
  if (administrative && JSON.stringify(before) === JSON.stringify(after)) {
23805
23822
  } else {
23806
- if (added.length !== 1 || after.length !== before.length + 1 || before.some((turn, index) => after[index]?.id !== turn.id) || added[0]?.text !== command.input.map((part) => part.text).join("\n"))
23823
+ const prompted = added.filter((turn) => !turn.notification);
23824
+ const own = prompted[0];
23825
+ if (!own || prompted.length !== 1 || after.length !== before.length + added.length || before.some((turn, index) => after[index]?.id !== turn.id) || own.text !== command.input.map((part) => part.text).join("\n"))
23807
23826
  throw new Error("Cursor terminal has no unique, verified native turn identity");
23808
23827
  nativeTurnRef = nativeTurnRefSchema.parse({
23809
23828
  harnessId: "cursor-cli",
23810
23829
  nativeSessionId: this.transport.sessionId,
23811
- nativeTurnKey: added[0].id,
23830
+ nativeTurnKey: own.id,
23812
23831
  formatVersion: 1
23813
23832
  });
23814
23833
  this.#fresh = false;
23815
- if (outcome.status === "succeeded" && cursorForkAvailable())
23834
+ const ownIndex = after.findIndex((turn) => turn.id === own.id);
23835
+ if (outcome.status === "succeeded" && cursorForkAvailable() && (ownIndex === after.length - 1 || after[ownIndex + 1]?.rewindRoot))
23816
23836
  outcome = {
23817
23837
  ...outcome,
23818
- checkpoint: cursorCheckpoint(this.transport.sessionId, added[0].id)
23838
+ checkpoint: cursorCheckpoint(this.transport.sessionId, own.id)
23819
23839
  };
23820
23840
  }
23821
23841
  } catch (error51) {