@codexhost/cli-linux-arm64 0.18.0 → 0.19.0

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.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +59 -2
  4. package/app/console-web.js +76 -4
  5. package/app/desktop-controller.mjs +274 -11
  6. package/app/host-runtime.mjs +12322 -2469
  7. package/app/plugins/antigravity/plugin.mjs +654 -216
  8. package/app/plugins/claude-code/plugin.mjs +138 -11
  9. package/app/plugins/codebuddy/plugin.mjs +152 -20
  10. package/app/plugins/codex-usage/plugin.mjs +59 -2
  11. package/app/plugins/copilot/plugin.mjs +59 -2
  12. package/app/plugins/cursor-cli/plugin.mjs +134 -12
  13. package/app/plugins/deepseek-harness/manifest.json +2 -2
  14. package/app/plugins/deepseek-harness/plugin.mjs +86 -7
  15. package/app/plugins/devin/plugin.mjs +59 -2
  16. package/app/plugins/grok/plugin.mjs +392 -269
  17. package/app/plugins/hermes/plugin.mjs +138 -14
  18. package/app/plugins/kimi-code/plugin.mjs +59 -2
  19. package/app/plugins/kiro-cli/plugin.mjs +287 -18
  20. package/app/plugins/omp/plugin.mjs +788 -627
  21. package/app/plugins/opencode/plugin.mjs +59 -2
  22. package/app/plugins/pi/plugin.mjs +899 -773
  23. package/app/plugins/qoder/plugin.mjs +61 -6
  24. package/app/plugins/qoder-cn/plugin.mjs +61 -6
  25. package/app/plugins/qwen-code/plugin.mjs +168 -94
  26. package/app/plugins/workbuddy/plugin.mjs +152 -20
  27. package/app/plugins/zcode/plugin.mjs +132 -5
  28. package/app/renderer-extension.js +657 -270
  29. package/app/web/assets/index-BNQIOOHE.css +1 -0
  30. package/app/web/assets/index-Feo4BkqN.js +199 -0
  31. package/app/web/codexhost-settings.js +76 -4
  32. package/app/web/index.html +2 -2
  33. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  34. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
  35. package/app/web/plugins/deepseek-ai__dsh-client-file-upload/client.js +1 -1
  36. package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +3 -3
  37. package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +129 -8
  39. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +65 -63
  40. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +95 -93
  41. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  42. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  43. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.excel.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +16 -16
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
  50. package/app/web-modules/server.mjs +2339 -1514
  51. package/bin/codexhost +0 -0
  52. package/libexec/codexhost-shim +0 -0
  53. package/libexec/codexhost-updater +0 -0
  54. package/package.json +1 -1
  55. package/app/web/assets/index-C0aXz2jD.js +0 -199
  56. package/app/web/assets/index-C3lniEH1.css +0 -1
@@ -408,15 +408,6 @@ function createHarnessInstaller(environment, source) {
408
408
  };
409
409
  }
410
410
 
411
- // dist/antigravity-adapter.js
412
- import { spawn } from "node:child_process";
413
- import { randomUUID as randomUUID6 } from "node:crypto";
414
- import { access as access2, readFile as readFile2, unlink } from "node:fs/promises";
415
- import https3 from "node:https";
416
- import os6 from "node:os";
417
- import path11 from "node:path";
418
- import readline from "node:readline";
419
-
420
411
  // ../../../node_modules/zod/v4/classic/external.js
421
412
  var external_exports = {};
422
413
  __export(external_exports, {
@@ -15510,6 +15501,10 @@ var CLIENT_CHANNEL_VERSION = 1;
15510
15501
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
15511
15502
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
15512
15503
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
15504
+ var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
15505
+ var clientThreadTreeSchema = external_exports.object({
15506
+ parents: external_exports.record(external_exports.string().min(1), external_exports.string().min(1))
15507
+ }).strict();
15513
15508
  var clientProjectlessWorkspaceSchema = external_exports.object({
15514
15509
  prompt: external_exports.string().max(16384).optional()
15515
15510
  }).strict();
@@ -15526,6 +15521,11 @@ var clientChannelCursorSchema = external_exports.object({
15526
15521
  sequence: external_exports.number().int().nonnegative()
15527
15522
  });
15528
15523
  var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
15524
+ external_exports.object({
15525
+ type: external_exports.literal("skills-changed"),
15526
+ cursor: clientChannelCursorSchema,
15527
+ cwd: external_exports.string().optional()
15528
+ }),
15529
15529
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15530
15530
  external_exports.object({
15531
15531
  type: external_exports.literal("preferences-changed"),
@@ -15723,6 +15723,28 @@ var voiceTranscribeResultSchema = external_exports.discriminatedUnion("ok", [
15723
15723
  external_exports.object({ ok: external_exports.literal(false), error: external_exports.object({ code: voiceErrorCodeSchema }).strict() }).strict()
15724
15724
  ]);
15725
15725
 
15726
+ // ../../shared-contracts/dist/skills.js
15727
+ var skillsListParamsSchema = external_exports.object({
15728
+ threadId: hostThreadIdSchema.optional(),
15729
+ cwd: external_exports.string().min(1).optional()
15730
+ }).strict().refine((params) => !(params.threadId && params.cwd), {
15731
+ message: "Specify threadId or cwd, not both"
15732
+ });
15733
+ var librarySkillSchema = external_exports.object({
15734
+ name: external_exports.string().min(1).regex(/^[^\s[\]]+$/u),
15735
+ description: external_exports.string().optional(),
15736
+ path: external_exports.string().min(1),
15737
+ scope: external_exports.enum(["project", "global"]),
15738
+ source: external_exports.string().min(1)
15739
+ }).strict();
15740
+ var skillsListResultSchema = external_exports.object({
15741
+ revision: external_exports.number().int().nonnegative(),
15742
+ complete: external_exports.boolean(),
15743
+ skills: external_exports.array(librarySkillSchema),
15744
+ warnings: external_exports.array(external_exports.string()).optional()
15745
+ }).strict();
15746
+ var skillsChangedParamsSchema = external_exports.object({ cwd: external_exports.string().min(1).optional() }).strict();
15747
+
15726
15748
  // ../../shared-contracts/dist/web-access-tokens.js
15727
15749
  var webNetworkAccessUrlSchema = external_exports.object({
15728
15750
  /**
@@ -15828,8 +15850,8 @@ var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
15828
15850
  var delegationReadParamsSchema = external_exports.strictObject({
15829
15851
  threadId: external_exports.string().min(1).max(1024),
15830
15852
  view: external_exports.enum(["result", "messages"]),
15831
- cursor: external_exports.string().min(1).max(8192).optional(),
15832
- limit: external_exports.number().int().min(1).max(100).optional()
15853
+ from: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
15854
+ to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
15833
15855
  });
15834
15856
 
15835
15857
  // ../../shared-contracts/dist/credential-imports.js
@@ -16782,6 +16804,17 @@ var updateStatusResultSchema = external_exports.strictObject({
16782
16804
  status: updateStatusSchema.nullable()
16783
16805
  });
16784
16806
 
16807
+ // ../../shared-contracts/dist/thread-watch-notice.js
16808
+ var THREAD_WATCH_NOTICE_OUTCOMES = [
16809
+ "completed",
16810
+ "failed",
16811
+ "interrupted",
16812
+ "timedOut",
16813
+ "unreadable",
16814
+ "notFound"
16815
+ ];
16816
+ var ENTRY_PATTERN = new RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): ` + `(${THREAD_WATCH_NOTICE_OUTCOMES.join("|")})(?:. (.+))?$`, "u");
16817
+
16785
16818
  // ../../shared-contracts/dist/remote-runtime.js
16786
16819
  var remoteUpdatePhaseSchema = external_exports.enum([
16787
16820
  "idle",
@@ -16829,6 +16862,14 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
16829
16862
  archived: external_exports.boolean()
16830
16863
  }),
16831
16864
  external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
16865
+ external_exports.strictObject({
16866
+ kind: external_exports.literal("configure"),
16867
+ ...thread,
16868
+ epoch: identity,
16869
+ modelId: identity.optional(),
16870
+ thinkingOptionId: identity.optional(),
16871
+ permissionModeId: identity.optional()
16872
+ }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
16832
16873
  external_exports.strictObject({
16833
16874
  kind: external_exports.literal("prompt"),
16834
16875
  ...thread,
@@ -16901,6 +16942,13 @@ var remoteConnectionsReplySchema = external_exports.union([
16901
16942
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16902
16943
  ]);
16903
16944
 
16945
+ // ../../shared-contracts/dist/thread-title.js
16946
+ var threadTitleInputSchema = external_exports.strictObject({
16947
+ prompt: external_exports.string().trim().min(1).max(2e3),
16948
+ cwd: external_exports.string().max(4096).nullable()
16949
+ });
16950
+ var threadTitleResultSchema = external_exports.string().trim().min(1).max(60).nullable();
16951
+
16904
16952
  // ../../shared-contracts/dist/web-ui-extensions.js
16905
16953
  var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u);
16906
16954
  var localizedTextSchema2 = external_exports.union([
@@ -17104,6 +17152,69 @@ var requestFields = /* @__PURE__ */ new Set([
17104
17152
  "provider"
17105
17153
  ]);
17106
17154
 
17155
+ // ../../harness-adapter/dist/subagent-configuration.js
17156
+ function subagentConfiguration(value) {
17157
+ if (typeof value !== "object" || value === null || Array.isArray(value))
17158
+ return {};
17159
+ const row = value;
17160
+ const text = (value2) => typeof value2 === "string" && value2.trim() ? value2 : void 0;
17161
+ const model2 = row.model === "inherit" ? void 0 : text(row.model);
17162
+ const reasoningEffort = text(row.reasoningEffort) ?? text(row.reasoning_effort) ?? text(row.thinking);
17163
+ return { ...model2 ? { model: model2 } : {}, ...reasoningEffort ? { reasoningEffort } : {} };
17164
+ }
17165
+ function inheritSubagentConfiguration(child, parent) {
17166
+ const native = subagentConfiguration(child);
17167
+ const model2 = native.model ?? parent.model;
17168
+ const reasoningEffort = native.reasoningEffort ?? parent.reasoningEffort;
17169
+ const next = { ...child };
17170
+ delete next.model;
17171
+ delete next.reasoningEffort;
17172
+ return { ...next, ...model2 ? { model: model2 } : {}, ...reasoningEffort ? { reasoningEffort } : {} };
17173
+ }
17174
+ function configureSubagentEvent(event, parent) {
17175
+ const children = (states) => states.map((child) => inheritSubagentConfiguration(child, parent));
17176
+ if (event.type === "item.started" && event.item.type === "subagentDelegation")
17177
+ return { ...event, item: { ...event.item, subagents: children(event.item.subagents) } };
17178
+ if (event.type === "item.updated" && event.update.type === "subagents.replace")
17179
+ return { ...event, update: { ...event.update, subagents: children(event.update.subagents) } };
17180
+ if (event.type === "item.completed" && event.snapshot.item.type === "subagentDelegation")
17181
+ return {
17182
+ ...event,
17183
+ snapshot: {
17184
+ ...event.snapshot,
17185
+ item: {
17186
+ ...event.snapshot.item,
17187
+ subagents: children(event.snapshot.item.subagents)
17188
+ }
17189
+ }
17190
+ };
17191
+ return event;
17192
+ }
17193
+ function configureSubagentSnapshot(snapshot, parent) {
17194
+ return {
17195
+ ...snapshot,
17196
+ turns: snapshot.turns.map((turn) => ({
17197
+ ...turn,
17198
+ items: turn.items.map((entry) => entry.item.type === "subagentDelegation" ? {
17199
+ ...entry,
17200
+ item: {
17201
+ ...entry.item,
17202
+ subagents: entry.item.subagents.map((child) => inheritSubagentConfiguration(child, parent))
17203
+ }
17204
+ } : entry)
17205
+ }))
17206
+ };
17207
+ }
17208
+
17209
+ // dist/antigravity-adapter.js
17210
+ import { spawn } from "node:child_process";
17211
+ import { randomUUID as randomUUID6 } from "node:crypto";
17212
+ import { access as access2, readFile as readFile2, unlink } from "node:fs/promises";
17213
+ import https3 from "node:https";
17214
+ import os6 from "node:os";
17215
+ import path11 from "node:path";
17216
+ import readline from "node:readline";
17217
+
17107
17218
  // dist/command.js
17108
17219
  import path4 from "node:path";
17109
17220
  var antigravityDiscoverySpec = {
@@ -17130,7 +17241,8 @@ function resolveAntigravityExecutable(input = {}) {
17130
17241
 
17131
17242
  // dist/fork.js
17132
17243
  import { randomUUID as randomUUID2 } from "node:crypto";
17133
- import { access, copyFile, cp, mkdir as mkdir2 } from "node:fs/promises";
17244
+ import { constants } from "node:fs";
17245
+ import { access, copyFile, cp, mkdir as mkdir2, rm as rm3 } from "node:fs/promises";
17134
17246
  import os4 from "node:os";
17135
17247
  import path7 from "node:path";
17136
17248
 
@@ -17206,6 +17318,8 @@ var hostItemSchema = external_exports.discriminatedUnion("type", [
17206
17318
  nativeSubagentId: external_exports.string().optional(),
17207
17319
  description: external_exports.string(),
17208
17320
  role: external_exports.string().optional(),
17321
+ model: external_exports.string().optional(),
17322
+ reasoningEffort: external_exports.string().optional(),
17209
17323
  background: external_exports.boolean(),
17210
17324
  status: external_exports.enum(["pending", "running", "completed", "failed", "interrupted"]),
17211
17325
  resultSummary: external_exports.string().optional()
@@ -17457,6 +17571,113 @@ async function nativeTurnBoundaryError(dbPath, sidecarTurnCount) {
17457
17571
  return null;
17458
17572
  }
17459
17573
 
17574
+ // dist/native-trajectory-metadata.js
17575
+ var DEFAULT_CLI_PROJECT_ID = "default-cli-project";
17576
+ function encodeVarint(value) {
17577
+ const bytes = [];
17578
+ let remaining = value >>> 0;
17579
+ while (remaining >= 128) {
17580
+ bytes.push(remaining & 127 | 128);
17581
+ remaining >>>= 7;
17582
+ }
17583
+ bytes.push(remaining);
17584
+ return Buffer.from(bytes);
17585
+ }
17586
+ function decodeVarint(buffer, start) {
17587
+ let value = 0n;
17588
+ for (let index = 0; index < 10; index++) {
17589
+ const byte = buffer[start + index];
17590
+ if (byte === void 0 || index === 9 && byte > 1)
17591
+ return null;
17592
+ value |= BigInt(byte & 127) << BigInt(index * 7);
17593
+ if ((byte & 128) === 0)
17594
+ return [value, start + index + 1];
17595
+ }
17596
+ return null;
17597
+ }
17598
+ function encodeLengthDelimited(fieldNumber, payload) {
17599
+ return Buffer.concat([
17600
+ encodeVarint(fieldNumber << 3 | 2),
17601
+ encodeVarint(payload.length),
17602
+ Buffer.from(payload)
17603
+ ]);
17604
+ }
17605
+ function minimalTrajectoryMetadataBlob(cascadeId, projectId = DEFAULT_CLI_PROJECT_ID) {
17606
+ return Buffer.concat([
17607
+ encodeLengthDelimited(6, Buffer.from(cascadeId, "utf8")),
17608
+ encodeLengthDelimited(18, Buffer.from(projectId, "utf8"))
17609
+ ]);
17610
+ }
17611
+ function minimalRawSummaryBlob(trajectoryId, metadataBlob) {
17612
+ return Buffer.concat([
17613
+ encodeLengthDelimited(4, Buffer.from(trajectoryId, "utf8")),
17614
+ Buffer.from([40, 1]),
17615
+ encodeLengthDelimited(17, metadataBlob),
17616
+ Buffer.from([176, 1, 4])
17617
+ ]);
17618
+ }
17619
+ function rewriteTrajectoryMetadataCascadeId(blob, cascadeId) {
17620
+ const chunks = [];
17621
+ let offset = 0;
17622
+ let wroteCascadeId = false;
17623
+ let hasProjectId = false;
17624
+ while (offset < blob.length) {
17625
+ const fieldStart = offset;
17626
+ const tagParsed = decodeVarint(blob, offset);
17627
+ if (!tagParsed)
17628
+ return null;
17629
+ const [tag, afterTag] = tagParsed;
17630
+ if (tag < 8n || tag > 0xffffffffn)
17631
+ return null;
17632
+ const fieldNumber = Number(tag >> 3n);
17633
+ const wireType = Number(tag & 7n);
17634
+ if (fieldNumber === 6 && wireType !== 2)
17635
+ return null;
17636
+ offset = afterTag;
17637
+ if (wireType === 0) {
17638
+ const valParsed = decodeVarint(blob, offset);
17639
+ if (!valParsed)
17640
+ return null;
17641
+ offset = valParsed[1];
17642
+ } else if (wireType === 1) {
17643
+ if (offset + 8 > blob.length)
17644
+ return null;
17645
+ offset += 8;
17646
+ } else if (wireType === 2) {
17647
+ const lenParsed = decodeVarint(blob, offset);
17648
+ if (!lenParsed)
17649
+ return null;
17650
+ const [length, afterLen] = lenParsed;
17651
+ if (length > BigInt(blob.length - afterLen))
17652
+ return null;
17653
+ offset = afterLen + Number(length);
17654
+ if (fieldNumber === 6) {
17655
+ if (!wroteCascadeId) {
17656
+ chunks.push(encodeLengthDelimited(6, Buffer.from(cascadeId, "utf8")));
17657
+ wroteCascadeId = true;
17658
+ }
17659
+ continue;
17660
+ }
17661
+ if (fieldNumber === 18)
17662
+ hasProjectId = true;
17663
+ } else if (wireType === 5) {
17664
+ if (offset + 4 > blob.length)
17665
+ return null;
17666
+ offset += 4;
17667
+ } else {
17668
+ return null;
17669
+ }
17670
+ chunks.push(Buffer.from(blob.subarray(fieldStart, offset)));
17671
+ }
17672
+ if (!wroteCascadeId) {
17673
+ chunks.push(encodeLengthDelimited(6, Buffer.from(cascadeId, "utf8")));
17674
+ }
17675
+ if (!hasProjectId) {
17676
+ chunks.push(encodeLengthDelimited(18, Buffer.from(DEFAULT_CLI_PROJECT_ID, "utf8")));
17677
+ }
17678
+ return Buffer.concat(chunks);
17679
+ }
17680
+
17460
17681
  // dist/usage-statistics.js
17461
17682
  import { lstat, opendir } from "node:fs/promises";
17462
17683
  import os3 from "node:os";
@@ -17639,7 +17860,7 @@ function createAntigravityUsageStatistics(environment) {
17639
17860
  }
17640
17861
 
17641
17862
  // dist/fork.js
17642
- var DEFAULT_CLI_PROJECT_ID = "default-cli-project";
17863
+ var DEFAULT_CLI_PROJECT_ID2 = "default-cli-project";
17643
17864
  var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
17644
17865
  function nativeConversationDbPath(nativeSessionId, homedir2 = os4.homedir()) {
17645
17866
  return path7.join(homedir2, ".gemini", "antigravity-cli", "conversations", `${nativeSessionId}.db`);
@@ -17653,120 +17874,6 @@ function nativeBrainRoot(homedir2 = os4.homedir()) {
17653
17874
  function nativeBrainDirPath(nativeSessionId, homedir2 = os4.homedir()) {
17654
17875
  return path7.join(nativeBrainRoot(homedir2), nativeSessionId);
17655
17876
  }
17656
- function encodeVarint(value) {
17657
- const bytes = [];
17658
- let remaining = value >>> 0;
17659
- while (remaining >= 128) {
17660
- bytes.push(remaining & 127 | 128);
17661
- remaining >>>= 7;
17662
- }
17663
- bytes.push(remaining);
17664
- return Buffer.from(bytes);
17665
- }
17666
- function decodeVarint(buffer, startOffset) {
17667
- let value = 0;
17668
- let shift = 0;
17669
- let offset = startOffset;
17670
- while (offset < buffer.length) {
17671
- const byte = buffer[offset];
17672
- if (byte === void 0)
17673
- return null;
17674
- offset += 1;
17675
- value += (byte & 127) * 2 ** shift;
17676
- if ((byte & 128) === 0)
17677
- return [value, offset];
17678
- shift += 7;
17679
- if (shift > 53)
17680
- return null;
17681
- }
17682
- return null;
17683
- }
17684
- function encodeLengthDelimited(fieldNumber, payload) {
17685
- return Buffer.concat([
17686
- encodeVarint(fieldNumber << 3 | 2),
17687
- encodeVarint(payload.length),
17688
- Buffer.from(payload)
17689
- ]);
17690
- }
17691
- function minimalTrajectoryMetadataBlob(cascadeId, projectId = DEFAULT_CLI_PROJECT_ID) {
17692
- return Buffer.concat([
17693
- encodeLengthDelimited(6, Buffer.from(cascadeId, "utf8")),
17694
- encodeLengthDelimited(18, Buffer.from(projectId, "utf8"))
17695
- ]);
17696
- }
17697
- function minimalRawSummaryBlob(trajectoryId, metadataBlob) {
17698
- return Buffer.concat([
17699
- encodeLengthDelimited(4, Buffer.from(trajectoryId, "utf8")),
17700
- Buffer.from([40, 1]),
17701
- encodeLengthDelimited(17, metadataBlob),
17702
- Buffer.from([176, 1, 4])
17703
- ]);
17704
- }
17705
- function updateTrajectoryMetadataCascadeId(blob, cascadeId) {
17706
- if (!blob || blob.length === 0)
17707
- return minimalTrajectoryMetadataBlob(cascadeId);
17708
- return rewriteTrajectoryMetadataCascadeId(blob, cascadeId) ?? minimalTrajectoryMetadataBlob(cascadeId);
17709
- }
17710
- function rewriteTrajectoryMetadataCascadeId(blob, cascadeId) {
17711
- const chunks = [];
17712
- let offset = 0;
17713
- let wroteCascadeId = false;
17714
- let hasProjectId = false;
17715
- while (offset < blob.length) {
17716
- const fieldStart = offset;
17717
- const tagParsed = decodeVarint(blob, offset);
17718
- if (!tagParsed)
17719
- return null;
17720
- const [tag, afterTag] = tagParsed;
17721
- const fieldNumber = tag >>> 3;
17722
- const wireType = tag & 7;
17723
- offset = afterTag;
17724
- if (wireType === 0) {
17725
- const valParsed = decodeVarint(blob, offset);
17726
- if (!valParsed)
17727
- return null;
17728
- offset = valParsed[1];
17729
- chunks.push(Buffer.from(blob.subarray(fieldStart, offset)));
17730
- } else if (wireType === 1) {
17731
- if (offset + 8 > blob.length)
17732
- return null;
17733
- offset += 8;
17734
- chunks.push(Buffer.from(blob.subarray(fieldStart, offset)));
17735
- } else if (wireType === 2) {
17736
- const lenParsed = decodeVarint(blob, offset);
17737
- if (!lenParsed)
17738
- return null;
17739
- const [length, afterLen] = lenParsed;
17740
- if (afterLen + length > blob.length)
17741
- return null;
17742
- offset = afterLen + length;
17743
- if (fieldNumber === 6) {
17744
- if (!wroteCascadeId) {
17745
- chunks.push(encodeLengthDelimited(6, Buffer.from(cascadeId, "utf8")));
17746
- wroteCascadeId = true;
17747
- }
17748
- } else {
17749
- if (fieldNumber === 18)
17750
- hasProjectId = true;
17751
- chunks.push(Buffer.from(blob.subarray(fieldStart, offset)));
17752
- }
17753
- } else if (wireType === 5) {
17754
- if (offset + 4 > blob.length)
17755
- return null;
17756
- offset += 4;
17757
- chunks.push(Buffer.from(blob.subarray(fieldStart, offset)));
17758
- } else {
17759
- return null;
17760
- }
17761
- }
17762
- if (!wroteCascadeId) {
17763
- chunks.push(encodeLengthDelimited(6, Buffer.from(cascadeId, "utf8")));
17764
- }
17765
- if (!hasProjectId) {
17766
- chunks.push(encodeLengthDelimited(18, Buffer.from(DEFAULT_CLI_PROJECT_ID, "utf8")));
17767
- }
17768
- return Buffer.concat(chunks);
17769
- }
17770
17877
  async function pathExists(targetPath2) {
17771
17878
  return access(targetPath2).then(() => true, (error51) => {
17772
17879
  if (error51?.code === "ENOENT")
@@ -17839,7 +17946,7 @@ function upsertConversationSummaryRow(DatabaseSync, summariesDbPath, conversatio
17839
17946
  \`parent_conversation_id\`, \`nesting_depth\`, \`battle_id\`, \`winning_conversation_id\`,
17840
17947
  \`not_fully_idle\`, \`killed\`, \`last_user_input_time\`, \`last_user_input_step_index\`,
17841
17948
  \`app_data_dir\`, \`raw_summary\`, \`group_id\`
17842
- ) VALUES (?, '', '', ?, ?, '[]', 'CASCADE_RUN_STATUS_IDLE', '', ?, '', '', 0, '', '', 0, 0, ?, -1, '', ?, '')`).run(conversationId, stepCount, now, DEFAULT_CLI_PROJECT_ID, now, rawSummary);
17949
+ ) VALUES (?, '', '', ?, ?, '[]', 'CASCADE_RUN_STATUS_IDLE', '', ?, '', '', 0, '', '', 0, 0, ?, -1, '', ?, '')`).run(conversationId, stepCount, now, DEFAULT_CLI_PROJECT_ID2, now, rawSummary);
17843
17950
  }
17844
17951
  } finally {
17845
17952
  sumDb.close();
@@ -18020,28 +18127,24 @@ async function cloneNativeConversationDb(sourceSessionId, derivedSessionId, reta
18020
18127
  const sourceDb = nativeConversationDbPath(sourceSessionId, homedir2);
18021
18128
  const targetDb = nativeConversationDbPath(derivedSessionId, homedir2);
18022
18129
  const summariesDbPath = nativeConversationSummariesDbPath(homedir2);
18023
- let copiedFromDisk = false;
18024
- try {
18025
- await mkdir2(path7.dirname(targetDb), { recursive: true });
18026
- await copyFile(sourceDb, targetDb);
18027
- copiedFromDisk = true;
18028
- } catch {
18029
- copiedFromDisk = false;
18030
- }
18031
- let DatabaseSync;
18032
- try {
18033
- ({ DatabaseSync } = await import("node:sqlite"));
18034
- } catch {
18035
- return copiedFromDisk;
18036
- }
18037
- if (!copiedFromDisk) {
18130
+ const { DatabaseSync } = await import("node:sqlite");
18131
+ if (!await pathExists(sourceDb)) {
18038
18132
  const sourceSummary = await pathExists(summariesDbPath) ? readConversationSummaryRow(DatabaseSync, summariesDbPath, sourceSessionId) : void 0;
18039
18133
  const sourceBrainExists = await pathExists(nativeBrainDirPath(sourceSessionId, homedir2));
18040
18134
  if (!UUID_PATTERN.test(sourceSessionId) && !sourceSummary && !sourceBrainExists) {
18041
18135
  return false;
18042
18136
  }
18043
- return seedNativeConversationDb(derivedSessionId, homedir2, sourceSummary);
18137
+ if (await pathExists(targetDb)) {
18138
+ throw new Error("Antigravity derived native conversation database already exists");
18139
+ }
18140
+ if (!await seedNativeConversationDb(derivedSessionId, homedir2, sourceSummary)) {
18141
+ await rm3(targetDb, { force: true });
18142
+ throw new Error("Antigravity could not seed the derived native conversation database");
18143
+ }
18144
+ return true;
18044
18145
  }
18146
+ await mkdir2(path7.dirname(targetDb), { recursive: true });
18147
+ await copyFile(sourceDb, targetDb, constants.COPYFILE_EXCL);
18045
18148
  let trajectoryId = randomUUID2();
18046
18149
  let metadataBlob = minimalTrajectoryMetadataBlob(derivedSessionId);
18047
18150
  let remainingStepCount = 0;
@@ -18049,64 +18152,49 @@ async function cloneNativeConversationDb(sourceSessionId, derivedSessionId, reta
18049
18152
  const db = new DatabaseSync(targetDb);
18050
18153
  try {
18051
18154
  db.prepare("UPDATE trajectory_meta SET cascade_id = ?").run(derivedSessionId);
18052
- try {
18053
- const metaRow = db.prepare("SELECT trajectory_id FROM trajectory_meta LIMIT 1").get();
18054
- if (metaRow?.trajectory_id)
18055
- trajectoryId = metaRow.trajectory_id;
18056
- } catch {
18057
- }
18058
- try {
18059
- const blobRow = db.prepare("SELECT data FROM trajectory_metadata_blob WHERE id = 'main'").get();
18060
- metadataBlob = updateTrajectoryMetadataCascadeId(blobRow?.data, derivedSessionId);
18061
- db.prepare("INSERT OR REPLACE INTO trajectory_metadata_blob (id, data) VALUES ('main', ?)").run(metadataBlob);
18062
- } catch {
18063
- }
18155
+ const metaRow = db.prepare("SELECT trajectory_id FROM trajectory_meta LIMIT 1").get();
18156
+ if (metaRow?.trajectory_id)
18157
+ trajectoryId = metaRow.trajectory_id;
18158
+ const blobRow = db.prepare("SELECT data FROM trajectory_metadata_blob WHERE id = 'main'").get();
18159
+ const rewritten = blobRow?.data?.length ? rewriteTrajectoryMetadataCascadeId(blobRow.data, derivedSessionId) : minimalTrajectoryMetadataBlob(derivedSessionId);
18160
+ if (!rewritten)
18161
+ throw new Error("Antigravity could not parse source trajectory metadata");
18162
+ metadataBlob = rewritten;
18163
+ db.prepare("INSERT OR REPLACE INTO trajectory_metadata_blob (id, data) VALUES ('main', ?)").run(metadataBlob);
18064
18164
  if (retainedTurnsCount !== void 0) {
18065
- try {
18066
- if (retainedTurnsCount === 0) {
18067
- db.prepare("DELETE FROM steps").run();
18068
- } else {
18069
- const rows = db.prepare("SELECT idx FROM steps WHERE step_type = 14 ORDER BY idx ASC").all();
18070
- const cutoff = rows[retainedTurnsCount];
18071
- if (cutoff) {
18072
- db.prepare("DELETE FROM steps WHERE idx >= ?").run(cutoff.idx);
18073
- }
18074
- }
18075
- } catch {
18076
- }
18077
- try {
18078
- db.prepare("DELETE FROM gen_metadata WHERE idx >= ?").run(retainedTurnsCount);
18079
- } catch {
18080
- }
18081
- try {
18082
- db.prepare("DELETE FROM executor_metadata WHERE idx >= ?").run(retainedTurnsCount);
18083
- } catch {
18084
- }
18085
- try {
18086
- db.prepare("DELETE FROM parent_references WHERE idx >= ?").run(retainedTurnsCount);
18087
- } catch {
18165
+ if (retainedTurnsCount === 0) {
18166
+ db.prepare("DELETE FROM steps").run();
18167
+ } else {
18168
+ const rows = db.prepare("SELECT idx FROM steps WHERE step_type = 14 ORDER BY idx ASC").all();
18169
+ const cutoff = rows[retainedTurnsCount];
18170
+ if (cutoff)
18171
+ db.prepare("DELETE FROM steps WHERE idx >= ?").run(cutoff.idx);
18088
18172
  }
18089
- try {
18090
- db.prepare("DELETE FROM battle_mode_infos WHERE idx >= ?").run(retainedTurnsCount);
18091
- } catch {
18173
+ for (const table of [
18174
+ "gen_metadata",
18175
+ "executor_metadata",
18176
+ "parent_references",
18177
+ "battle_mode_infos"
18178
+ ]) {
18179
+ if (db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?").get(table)) {
18180
+ db.prepare(`DELETE FROM ${table} WHERE idx >= ?`).run(retainedTurnsCount);
18181
+ }
18092
18182
  }
18093
18183
  }
18094
- try {
18095
- const countRow = db.prepare("SELECT count(*) as c FROM steps").get();
18096
- if (countRow)
18097
- remainingStepCount = countRow.c;
18098
- } catch {
18099
- }
18184
+ const countRow = db.prepare("SELECT count(*) as c FROM steps").get();
18185
+ if (countRow)
18186
+ remainingStepCount = countRow.c;
18100
18187
  } finally {
18101
18188
  db.close();
18102
18189
  }
18103
- } catch {
18104
- return true;
18105
- }
18106
- if (await pathExists(summariesDbPath)) {
18107
- const sourceRow = readConversationSummaryRow(DatabaseSync, summariesDbPath, sourceSessionId);
18108
- const effectiveStepCount = retainedTurnsCount !== void 0 ? remainingStepCount : typeof sourceRow?.step_count === "number" ? sourceRow.step_count : remainingStepCount;
18109
- upsertConversationSummaryRow(DatabaseSync, summariesDbPath, derivedSessionId, trajectoryId, metadataBlob, effectiveStepCount, sourceRow);
18190
+ if (await pathExists(summariesDbPath)) {
18191
+ const sourceRow = readConversationSummaryRow(DatabaseSync, summariesDbPath, sourceSessionId);
18192
+ const effectiveStepCount = retainedTurnsCount !== void 0 ? remainingStepCount : typeof sourceRow?.step_count === "number" ? sourceRow.step_count : remainingStepCount;
18193
+ upsertConversationSummaryRow(DatabaseSync, summariesDbPath, derivedSessionId, trajectoryId, metadataBlob, effectiveStepCount, sourceRow);
18194
+ }
18195
+ } catch (error51) {
18196
+ await rm3(targetDb, { force: true });
18197
+ throw error51;
18110
18198
  }
18111
18199
  return true;
18112
18200
  }
@@ -18209,6 +18297,19 @@ async function forkAntigravitySession(options) {
18209
18297
  const model2 = sourceSession?.model ?? sourceHistory.model;
18210
18298
  const thinkingOptionId = sourceSession?.thinkingOptionId ?? sourceHistory.thinkingOptionId;
18211
18299
  const permissionMode = sourceSession?.permissionMode ?? "dangerously-skip-permissions";
18300
+ try {
18301
+ await copyNativeConversationDbIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, retainedTurns.length, homedir2);
18302
+ } catch (error51) {
18303
+ return {
18304
+ ok: false,
18305
+ error: {
18306
+ code: "nativeFailure",
18307
+ message: error51 instanceof Error ? error51.message : String(error51),
18308
+ retryable: false
18309
+ }
18310
+ };
18311
+ }
18312
+ await copyNativeBrainDirIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, homedir2);
18212
18313
  const forkedHistory = await AntigravityHistory.createDerived({
18213
18314
  environment: sessionEnvironment,
18214
18315
  nativeSessionId: derivedNativeSessionId,
@@ -18216,10 +18317,6 @@ async function forkAntigravitySession(options) {
18216
18317
  ...model2 ? { model: model2 } : {},
18217
18318
  ...thinkingOptionId ? { thinkingOptionId } : {}
18218
18319
  });
18219
- await Promise.all([
18220
- copyNativeConversationDbIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, retainedTurns.length, homedir2),
18221
- copyNativeBrainDirIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, homedir2)
18222
- ]);
18223
18320
  const derivedNativeRef = {
18224
18321
  harnessId,
18225
18322
  nativeSessionId: derivedNativeSessionId,
@@ -18359,6 +18456,109 @@ function decodeAntigravityPermissionModeId(value) {
18359
18456
  return "dangerously-skip-permissions";
18360
18457
  }
18361
18458
 
18459
+ // dist/recovered-native-error.js
18460
+ var USER_INPUT_STEP = 14;
18461
+ var PLANNER_RESPONSE_STEP = 15;
18462
+ var ERROR_MESSAGE_STEP = 17;
18463
+ var DONE_STATUS = 3;
18464
+ var UNSETTLED_STATUSES = /* @__PURE__ */ new Set([0, 1, 2, 8, 9, 11]);
18465
+ var RETRIED_REQUEST_ERROR = /^API error \(attempt \d+\):/;
18466
+ var SETTLE_ATTEMPTS = 3;
18467
+ var SETTLE_DELAY_MS = 150;
18468
+ async function nativeTurnRecoveredFromError(query) {
18469
+ const error51 = query.error.trim();
18470
+ if (!query.conversationId || !error51)
18471
+ return false;
18472
+ let DatabaseSync;
18473
+ try {
18474
+ ({ DatabaseSync } = await import("node:sqlite"));
18475
+ } catch {
18476
+ return false;
18477
+ }
18478
+ const dbPath = nativeConversationDbPath(query.conversationId, query.homedir);
18479
+ const errorBytes = Buffer.from(error51, "utf8");
18480
+ for (let attempt = 1; ; attempt += 1) {
18481
+ let verdict;
18482
+ try {
18483
+ verdict = readVerdict(DatabaseSync, dbPath, errorBytes);
18484
+ } catch {
18485
+ return false;
18486
+ }
18487
+ if (verdict !== "unsettled")
18488
+ return verdict === "recovered";
18489
+ if (attempt >= SETTLE_ATTEMPTS)
18490
+ return false;
18491
+ await new Promise((resolve) => setTimeout(resolve, SETTLE_DELAY_MS));
18492
+ }
18493
+ }
18494
+ function readVerdict(DatabaseSync, dbPath, errorBytes) {
18495
+ const db = new DatabaseSync(dbPath, { readOnly: true });
18496
+ try {
18497
+ const turnStart = db.prepare("SELECT MAX(idx) AS idx FROM steps WHERE step_type = ?").get(USER_INPUT_STEP);
18498
+ if (turnStart?.idx === null || turnStart?.idx === void 0)
18499
+ return "notRecovered";
18500
+ const steps = db.prepare(`SELECT idx, step_type, status,
18501
+ (instr(COALESCE(step_payload, X''), ?) > 0
18502
+ OR instr(COALESCE(error_details, X''), ?) > 0) AS has_error
18503
+ FROM steps WHERE idx > ? ORDER BY idx ASC`).all(errorBytes, errorBytes, turnStart.idx);
18504
+ if (steps.some((step) => step.has_error)) {
18505
+ return verdictForTurn(steps, RETRIED_REQUEST_ERROR.test(new TextDecoder().decode(errorBytes)));
18506
+ }
18507
+ const earlier = db.prepare(`SELECT 1 AS found FROM steps
18508
+ WHERE idx < ?
18509
+ AND (instr(COALESCE(step_payload, X''), ?) > 0
18510
+ OR instr(COALESCE(error_details, X''), ?) > 0)
18511
+ LIMIT 1`).get(turnStart.idx, errorBytes, errorBytes);
18512
+ if (!earlier)
18513
+ return "notRecovered";
18514
+ return verdictForFinishedTurn(steps);
18515
+ } finally {
18516
+ db.close();
18517
+ }
18518
+ }
18519
+ function verdictForTurn(steps, retriedRequest) {
18520
+ let errorAt = -1;
18521
+ for (let index = steps.length - 1; index >= 0; index -= 1) {
18522
+ if (steps[index]?.has_error) {
18523
+ errorAt = index;
18524
+ break;
18525
+ }
18526
+ }
18527
+ if (errorAt < 0)
18528
+ return "notRecovered";
18529
+ const after = steps.slice(errorAt + 1);
18530
+ const verdict = verdictForFinishedTurn(after);
18531
+ if (verdict !== "notRecovered" || !retriedRequest)
18532
+ return verdict;
18533
+ return retriedRequestRecovered(after) ? "recovered" : "notRecovered";
18534
+ }
18535
+ function settled(step) {
18536
+ return !UNSETTLED_STATUSES.has(step.status);
18537
+ }
18538
+ function completedPlannerResponse(step) {
18539
+ return step.step_type === PLANNER_RESPONSE_STEP && step.status === DONE_STATUS;
18540
+ }
18541
+ function verdictForFinishedTurn(steps) {
18542
+ const last = steps.at(-1);
18543
+ if (!last)
18544
+ return "notRecovered";
18545
+ if (!steps.every(settled))
18546
+ return "unsettled";
18547
+ return completedPlannerResponse(last) ? "recovered" : "notRecovered";
18548
+ }
18549
+ function retriedRequestRecovered(steps) {
18550
+ if (!steps.every(settled))
18551
+ return false;
18552
+ let lastReply = -1;
18553
+ steps.forEach((step, index) => {
18554
+ if (completedPlannerResponse(step))
18555
+ lastReply = index;
18556
+ });
18557
+ if (lastReply < 0)
18558
+ return false;
18559
+ return !steps.slice(lastReply + 1).some((step) => step.step_type === ERROR_MESSAGE_STEP || step.step_type === PLANNER_RESPONSE_STEP && step.status !== DONE_STATUS);
18560
+ }
18561
+
18362
18562
  // dist/rollback.js
18363
18563
  import { randomUUID as randomUUID3 } from "node:crypto";
18364
18564
  async function rollbackAntigravityLastTurn(options) {
@@ -18433,6 +18633,19 @@ async function rollbackAntigravityLastTurn(options) {
18433
18633
  const model2 = sourceSession?.model ?? sourceHistory.model;
18434
18634
  const thinkingOptionId = sourceSession?.thinkingOptionId ?? sourceHistory.thinkingOptionId;
18435
18635
  const permissionMode = sourceSession?.permissionMode ?? "dangerously-skip-permissions";
18636
+ try {
18637
+ await copyNativeConversationDbIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, mappedTurns.length, homedir2);
18638
+ } catch (error51) {
18639
+ return {
18640
+ ok: false,
18641
+ error: {
18642
+ code: "nativeFailure",
18643
+ message: error51 instanceof Error ? error51.message : String(error51),
18644
+ retryable: false
18645
+ }
18646
+ };
18647
+ }
18648
+ await copyNativeBrainDirIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, homedir2);
18436
18649
  const rolledBackHistory = await AntigravityHistory.createDerived({
18437
18650
  environment: sessionEnvironment,
18438
18651
  nativeSessionId: derivedNativeSessionId,
@@ -18440,10 +18653,6 @@ async function rollbackAntigravityLastTurn(options) {
18440
18653
  ...model2 ? { model: model2 } : {},
18441
18654
  ...thinkingOptionId ? { thinkingOptionId } : {}
18442
18655
  });
18443
- await Promise.all([
18444
- copyNativeConversationDbIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, mappedTurns.length, homedir2),
18445
- copyNativeBrainDirIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, homedir2)
18446
- ]);
18447
18656
  const derivedNativeRef = {
18448
18657
  harnessId,
18449
18658
  nativeSessionId: derivedNativeSessionId,
@@ -18811,6 +19020,7 @@ function completeAntigravityToolItem(item, step, toolOutputLimit, cwd) {
18811
19020
 
18812
19021
  // dist/code-action-diff.js
18813
19022
  var DIFF_CONTEXT_LINES = 3;
19023
+ var TRAJECTORY_PAGE_SIZE = 256;
18814
19024
  function isRecord2(value) {
18815
19025
  return typeof value === "object" && value !== null && !Array.isArray(value);
18816
19026
  }
@@ -18990,6 +19200,75 @@ function requestAntigravityTrajectorySteps(port, conversationId, timeoutMs) {
18990
19200
  request.end(JSON.stringify({ cascadeId: conversationId }));
18991
19201
  });
18992
19202
  }
19203
+ function plannerStepThinking(step) {
19204
+ if (!isRecord2(step) || step.type !== "CORTEX_STEP_TYPE_PLANNER_RESPONSE")
19205
+ return null;
19206
+ const plannerResponse = isRecord2(step.plannerResponse) ? step.plannerResponse : null;
19207
+ if (!plannerResponse)
19208
+ return null;
19209
+ for (const candidate of [
19210
+ plannerResponse.thinking,
19211
+ plannerResponse.rawThinking,
19212
+ plannerResponse.raw_thinking
19213
+ ]) {
19214
+ if (typeof candidate === "string" && candidate.trim().length > 0)
19215
+ return candidate;
19216
+ }
19217
+ return null;
19218
+ }
19219
+ function parseAntigravityStepThinking(value, stepIndex, stepOffset = 0) {
19220
+ if (!isRecord2(value) || !Array.isArray(value.steps))
19221
+ return null;
19222
+ const relativeIndex = stepIndex - stepOffset;
19223
+ if (relativeIndex >= 0 && relativeIndex < value.steps.length) {
19224
+ const direct = plannerStepThinking(value.steps[relativeIndex]);
19225
+ if (direct !== null)
19226
+ return direct;
19227
+ }
19228
+ for (const step of value.steps) {
19229
+ if (isRecord2(step) && step.stepIndex === stepIndex) {
19230
+ const matched = plannerStepThinking(step);
19231
+ if (matched !== null)
19232
+ return matched;
19233
+ }
19234
+ }
19235
+ return null;
19236
+ }
19237
+ function requestAntigravityStepThinking(port, conversationId, stepIndex, timeoutMs) {
19238
+ const stepOffset = stepIndex >= TRAJECTORY_PAGE_SIZE ? stepIndex : 0;
19239
+ return new Promise((resolve) => {
19240
+ const request = https.request({
19241
+ hostname: "127.0.0.1",
19242
+ port,
19243
+ path: "/exa.language_server_pb.LanguageServerService/GetCascadeTrajectorySteps",
19244
+ method: "POST",
19245
+ rejectUnauthorized: false,
19246
+ timeout: timeoutMs,
19247
+ headers: { "content-type": "application/json" }
19248
+ }, (response) => {
19249
+ let body = "";
19250
+ response.setEncoding("utf8");
19251
+ response.on("data", (chunk) => {
19252
+ body += chunk;
19253
+ });
19254
+ response.on("end", () => {
19255
+ if (response.statusCode !== 200)
19256
+ return resolve(null);
19257
+ try {
19258
+ resolve(parseAntigravityStepThinking(JSON.parse(body), stepIndex, stepOffset));
19259
+ } catch {
19260
+ resolve(null);
19261
+ }
19262
+ });
19263
+ });
19264
+ request.on("timeout", () => request.destroy());
19265
+ request.on("error", () => resolve(null));
19266
+ request.end(JSON.stringify({
19267
+ cascadeId: conversationId,
19268
+ ...stepOffset > 0 ? { stepOffset } : {}
19269
+ }));
19270
+ });
19271
+ }
18993
19272
 
18994
19273
  // dist/stream-events.js
18995
19274
  function isRecord3(value) {
@@ -19150,7 +19429,7 @@ async function fetchAntigravityQuota(run, now = /* @__PURE__ */ new Date()) {
19150
19429
 
19151
19430
  // dist/question-bridge.js
19152
19431
  import { randomBytes, randomUUID as randomUUID4, timingSafeEqual } from "node:crypto";
19153
- import { mkdir as mkdir3, mkdtemp as mkdtemp2, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
19432
+ import { mkdir as mkdir3, mkdtemp as mkdtemp2, rm as rm4, writeFile as writeFile3 } from "node:fs/promises";
19154
19433
  import { createServer } from "node:http";
19155
19434
  import os5 from "node:os";
19156
19435
  import path9 from "node:path";
@@ -19524,7 +19803,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
19524
19803
  this.#server.closeAllConnections();
19525
19804
  });
19526
19805
  if (this.#options.directory === void 0) {
19527
- await rm3(this.directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
19806
+ await rm4(this.directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
19528
19807
  }
19529
19808
  })();
19530
19809
  return this.#disposal;
@@ -19546,6 +19825,7 @@ var transcriptStepSchema = external_exports.object({
19546
19825
  type: external_exports.string(),
19547
19826
  status: external_exports.string(),
19548
19827
  content: external_exports.string().optional(),
19828
+ thinking: external_exports.string().optional(),
19549
19829
  tool_calls: external_exports.array(external_exports.object({ name: external_exports.string(), args: external_exports.unknown().optional() })).optional()
19550
19830
  });
19551
19831
  async function subagentRpc(port, conversationId, method) {
@@ -19665,6 +19945,16 @@ function parseSubagentTranscript(text, parentId, childId, status, cwd, outputLim
19665
19945
  }
19666
19946
  } : { status: "succeeded" };
19667
19947
  if (step.type === "PLANNER_RESPONSE") {
19948
+ if (step.thinking?.trim()) {
19949
+ current.items.push({
19950
+ item: {
19951
+ type: "reasoning",
19952
+ itemId: hostItemIdSchema.parse(`${itemId}-thinking`),
19953
+ text: step.thinking.slice(0, outputLimit)
19954
+ },
19955
+ outcome
19956
+ });
19957
+ }
19668
19958
  if (step.content) {
19669
19959
  current.items.push({
19670
19960
  item: { type: "agentMessage", itemId, text: step.content.slice(0, outputLimit) },
@@ -19739,6 +20029,40 @@ async function readSubagentTranscript(input) {
19739
20029
  };
19740
20030
  }
19741
20031
  }
20032
+ async function readTranscriptStepThinking(conversationId, stepIndex, outputLimit, home) {
20033
+ if (!conversationId || /[/\\]|^\.\.?$/u.test(conversationId))
20034
+ return null;
20035
+ const logsDir = path10.join(nativeBrainDirPath(conversationId, home), ".system_generated", "logs");
20036
+ for (const filename of ["transcript_full.jsonl", "transcript.jsonl"]) {
20037
+ try {
20038
+ const handle = await open(path10.join(logsDir, filename), "r");
20039
+ let text;
20040
+ try {
20041
+ const size = (await handle.stat()).size;
20042
+ if (size === 0 || size > MAX_TRANSCRIPT_BYTES)
20043
+ continue;
20044
+ const buffer = Buffer.alloc(size);
20045
+ const { bytesRead } = await handle.read(buffer, 0, size, 0);
20046
+ text = buffer.subarray(0, bytesRead).toString("utf8");
20047
+ } finally {
20048
+ await handle.close();
20049
+ }
20050
+ for (const line of text.split("\n")) {
20051
+ if (!line.trim())
20052
+ continue;
20053
+ try {
20054
+ const parsed = JSON.parse(line);
20055
+ if (isRecord3(parsed) && parsed.step_index === stepIndex && parsed.type === "PLANNER_RESPONSE" && typeof parsed.thinking === "string" && parsed.thinking.trim().length > 0) {
20056
+ return parsed.thinking.slice(0, outputLimit);
20057
+ }
20058
+ } catch {
20059
+ }
20060
+ }
20061
+ } catch {
20062
+ }
20063
+ }
20064
+ return null;
20065
+ }
19742
20066
 
19743
20067
  // dist/subagents.js
19744
20068
  var infoSchema = external_exports.object({
@@ -19746,6 +20070,10 @@ var infoSchema = external_exports.object({
19746
20070
  conversation_id: nativeSubagentIdSchema,
19747
20071
  type_name: external_exports.string().max(256).optional(),
19748
20072
  role: external_exports.string().max(2048).optional(),
20073
+ model: external_exports.string().max(512).optional().catch(void 0),
20074
+ reasoningEffort: external_exports.string().max(128).optional().catch(void 0),
20075
+ reasoning_effort: external_exports.string().max(128).optional().catch(void 0),
20076
+ thinking: external_exports.string().max(128).optional().catch(void 0),
19749
20077
  initial_prompt: external_exports.string().max(128e3).optional()
19750
20078
  })).max(32)
19751
20079
  });
@@ -19801,14 +20129,15 @@ var AntigravitySubagents = class {
19801
20129
  return true;
19802
20130
  }
19803
20131
  const subagents = parsed.data.subagents.map((child) => {
19804
- const state = {
20132
+ const state = inheritSubagentConfiguration({
19805
20133
  subagentId: child.conversation_id,
19806
20134
  nativeSubagentId: child.conversation_id,
19807
20135
  description: child.role || child.type_name || "Antigravity Subagent",
19808
20136
  ...child.type_name ? { role: child.type_name } : {},
20137
+ ...subagentConfiguration(child),
19809
20138
  background: true,
19810
20139
  status: "running"
19811
- };
20140
+ }, this.#options.parentConfiguration ?? {});
19812
20141
  this.#states.set(child.conversation_id, state);
19813
20142
  return state;
19814
20143
  });
@@ -20432,7 +20761,19 @@ var AntigravitySession = class {
20432
20761
  return historySubagentState(this.#history, id);
20433
20762
  }
20434
20763
  initialState;
20764
+ #subagentConfiguration() {
20765
+ const state = this.#state();
20766
+ const model2 = state.effectiveModel ? state.effectiveModel.id : void 0;
20767
+ return {
20768
+ ...model2 ? { model: model2 } : {},
20769
+ ...state.effectiveThinkingOptionId ? { reasoningEffort: state.effectiveThinkingOptionId } : {}
20770
+ };
20771
+ }
20435
20772
  async readSnapshot() {
20773
+ const result = await this.#readSnapshot();
20774
+ return result.ok ? { ok: true, value: configureSubagentSnapshot(result.value, this.#subagentConfiguration()) } : result;
20775
+ }
20776
+ async #readSnapshot() {
20436
20777
  if (this.#closed)
20437
20778
  return { ok: false, error: invalidState("Antigravity Session is closed") };
20438
20779
  return { ok: true, value: { turns: this.#history.snapshot(), state: this.#state() } };
@@ -20569,6 +20910,10 @@ var AntigravitySession = class {
20569
20910
  questions,
20570
20911
  subagents: new AntigravitySubagents({
20571
20912
  turnId: command.turnId,
20913
+ parentConfiguration: {
20914
+ ...this.#model ? { model: this.#model.id } : {},
20915
+ ...this.#thinkingOptionId ? { reasoningEffort: this.#thinkingOptionId } : {}
20916
+ },
20572
20917
  parentId: () => this.#nativeRef?.nativeSessionId,
20573
20918
  port: () => this.#languageServerPort(active),
20574
20919
  cwd: this.#cwd,
@@ -20604,6 +20949,9 @@ var AntigravitySession = class {
20604
20949
  codeActionCursor: 0,
20605
20950
  fileChanges: /* @__PURE__ */ new Map(),
20606
20951
  pendingSteps: /* @__PURE__ */ new Map(),
20952
+ thinkingSteps: /* @__PURE__ */ new Set(),
20953
+ checkedActiveThinkingSteps: /* @__PURE__ */ new Set(),
20954
+ pendingAgentText: /* @__PURE__ */ new Map(),
20607
20955
  httpsPort: null
20608
20956
  };
20609
20957
  this.#active = active;
@@ -20826,7 +21174,14 @@ ${line}`).slice(-8e3);
20826
21174
  if (!timedOut && finishedReason !== "interrupted" && repliedThisTurn && event.result.error?.trim() && this.#reportedEarlier(error51)) {
20827
21175
  this.#completeTurn(active, { status: "succeeded", checkpoint }, nativeTurnRef);
20828
21176
  } else {
20829
- this.#completeTurn(active, { status: "failed", error: error51, checkpoint }, nativeTurnRef);
21177
+ const recovered = !timedOut && finishedReason !== "interrupted" && repliedThisTurn && event.result.error?.trim() && await nativeTurnRecoveredFromError({
21178
+ conversationId: convId,
21179
+ error: event.result.error,
21180
+ homedir: antigravityHome(this.#environment)
21181
+ });
21182
+ if (this.#active !== active)
21183
+ return;
21184
+ this.#completeTurn(active, active.cancellationRequested ? { status: "cancelled", reason: "Cancelled by user", checkpoint } : recovered ? { status: "succeeded", checkpoint } : { status: "failed", error: error51, checkpoint }, nativeTurnRef);
20830
21185
  }
20831
21186
  }
20832
21187
  }
@@ -20894,14 +21249,13 @@ ${line}`).slice(-8e3);
20894
21249
  step = { ...step, step_type: "tool" };
20895
21250
  }
20896
21251
  if (step.step_type === "agent_response") {
20897
- if (typeof step.text_delta === "string" && step.text_delta.length > 0) {
20898
- this.#appendOrSyncAgentText(active, step.text_delta, true);
20899
- return;
20900
- }
20901
- const fullOrDelta = step.text ?? (typeof step.content === "string" ? step.content : void 0) ?? (typeof step.message === "string" ? step.message : void 0);
20902
- if (typeof fullOrDelta === "string" && fullOrDelta.length > 0) {
20903
- this.#appendOrSyncAgentText(active, fullOrDelta, false);
20904
- return;
21252
+ await this.#maybeProjectStepThinking(active, step);
21253
+ const isDelta = typeof step.text_delta === "string" && step.text_delta.length > 0;
21254
+ const text = isDelta ? step.text_delta : step.text ?? (typeof step.content === "string" ? step.content : void 0) ?? (typeof step.message === "string" ? step.message : void 0);
21255
+ if (typeof text === "string" && text.length > 0) {
21256
+ this.#emitOrBufferAgentResponseText(active, step.step_index, text, isDelta);
21257
+ } else if (active.thinkingSteps.has(step.step_index)) {
21258
+ this.#flushPendingAgentText(active, step.step_index);
20905
21259
  }
20906
21260
  return;
20907
21261
  }
@@ -20911,6 +21265,7 @@ ${line}`).slice(-8e3);
20911
21265
  }
20912
21266
  if (step.step_type !== "tool")
20913
21267
  return;
21268
+ this.#flushAllPendingAgentText(active);
20914
21269
  if (active.agentItem) {
20915
21270
  this.#completeItem(active, active.agentItem, { status: "succeeded" });
20916
21271
  active.agentItem = null;
@@ -21030,6 +21385,87 @@ ${line}`).slice(-8e3);
21030
21385
  active.httpsPort = port;
21031
21386
  return port;
21032
21387
  }
21388
+ /**
21389
+ * `agy --output-format stream-json` strips `<thought>` blocks from step text
21390
+ * and omits `thinking` from `step_update`, reporting only `usage.thinking_tokens`
21391
+ * when a planner step finishes. Resolve the step's thinking from inline fields,
21392
+ * the Language Server trajectory, or the native brain transcript before
21393
+ * projecting the step's visible response or subsequent tool calls. Reply text
21394
+ * for the same step is buffered until this returns with the step recorded in
21395
+ * `thinkingSteps`, so a late-fetched reasoning Item is not outranked by the
21396
+ * streamed answer.
21397
+ */
21398
+ async #maybeProjectStepThinking(active, step) {
21399
+ if (active.thinkingSteps.has(step.step_index))
21400
+ return;
21401
+ const isTerminal = step.state === "DONE" || step.state === "ERROR";
21402
+ if (!isTerminal && active.checkedActiveThinkingSteps.has(step.step_index))
21403
+ return;
21404
+ if (!isTerminal)
21405
+ active.checkedActiveThinkingSteps.add(step.step_index);
21406
+ const inlineThinking = typeof step.thinking_delta === "string" && step.thinking_delta.trim().length > 0 ? step.thinking_delta : typeof step.thinking === "string" && step.thinking.trim().length > 0 ? step.thinking : null;
21407
+ let thinking = inlineThinking;
21408
+ if (thinking === null) {
21409
+ const thinkingTokens = safeToken(step.usage?.thinking_tokens);
21410
+ if (!isTerminal || thinkingTokens === void 0 || thinkingTokens > 0) {
21411
+ const port = await this.#languageServerPort(active);
21412
+ if (port !== null) {
21413
+ thinking = await requestAntigravityStepThinking(port, step.conversation_id, step.step_index, TRAJECTORY_TIMEOUT_MS);
21414
+ }
21415
+ if (thinking === null) {
21416
+ const home = (process.platform === "win32" ? this.#environment.USERPROFILE : this.#environment.HOME) || void 0;
21417
+ thinking = await readTranscriptStepThinking(step.conversation_id, step.step_index, this.#toolOutputLimit, home);
21418
+ }
21419
+ }
21420
+ }
21421
+ if (isTerminal)
21422
+ active.thinkingSteps.add(step.step_index);
21423
+ if (thinking === null || thinking.trim().length === 0) {
21424
+ if (!isTerminal && !this.#thinkingOptionId)
21425
+ active.thinkingSteps.add(step.step_index);
21426
+ return;
21427
+ }
21428
+ active.thinkingSteps.add(step.step_index);
21429
+ if (active.agentItem) {
21430
+ this.#completeItem(active, active.agentItem, { status: "succeeded" });
21431
+ active.agentItem = null;
21432
+ active.agentText = "";
21433
+ }
21434
+ const item = {
21435
+ type: "reasoning",
21436
+ itemId: this.#newItemId(),
21437
+ text: thinking.slice(0, this.#toolOutputLimit)
21438
+ };
21439
+ this.#event({ type: "item.started", turnId: active.command.turnId, item });
21440
+ this.#completeItem(active, item, { status: "succeeded" });
21441
+ }
21442
+ /**
21443
+ * Emit agent_response text only after that step's thinking is resolved when
21444
+ * a late reasoning Item is still possible. Otherwise buffer so the streamed
21445
+ * answer cannot outrank thinking that only becomes available at DONE.
21446
+ */
21447
+ #emitOrBufferAgentResponseText(active, stepIndex, text, isDelta) {
21448
+ if (active.thinkingSteps.has(stepIndex) || !this.#thinkingOptionId) {
21449
+ this.#flushPendingAgentText(active, stepIndex);
21450
+ this.#appendOrSyncAgentText(active, text, isDelta);
21451
+ return;
21452
+ }
21453
+ const previous = active.pendingAgentText.get(stepIndex) ?? "";
21454
+ active.pendingAgentText.set(stepIndex, isDelta ? previous + text : text);
21455
+ }
21456
+ #flushPendingAgentText(active, stepIndex) {
21457
+ const pending = active.pendingAgentText.get(stepIndex);
21458
+ if (pending === void 0)
21459
+ return;
21460
+ active.pendingAgentText.delete(stepIndex);
21461
+ if (pending.length > 0)
21462
+ this.#appendOrSyncAgentText(active, pending, true);
21463
+ }
21464
+ #flushAllPendingAgentText(active) {
21465
+ for (const stepIndex of [...active.pendingAgentText.keys()].sort((a, b) => a - b)) {
21466
+ this.#flushPendingAgentText(active, stepIndex);
21467
+ }
21468
+ }
21033
21469
  #appendOrSyncAgentText(active, text, isExplicitDelta) {
21034
21470
  if (!text)
21035
21471
  return;
@@ -21084,6 +21520,7 @@ ${line}`).slice(-8e3);
21084
21520
  this.#active = null;
21085
21521
  const itemOutcome = outcome.status === "failed" ? { status: "failed", error: outcome.error } : outcome.status === "cancelled" ? { status: "cancelled", ...outcome.reason ? { reason: outcome.reason } : {} } : { status: "succeeded" };
21086
21522
  active.subagents.finish(itemOutcome);
21523
+ this.#flushAllPendingAgentText(active);
21087
21524
  if (active.compactionItem)
21088
21525
  this.#completeItem(active, active.compactionItem, itemOutcome);
21089
21526
  active.compactionItem = null;
@@ -21236,6 +21673,7 @@ ${line}`).slice(-8e3);
21236
21673
  };
21237
21674
  }
21238
21675
  #event(event) {
21676
+ event = configureSubagentEvent(event, this.#subagentConfiguration());
21239
21677
  this.#channel.emit({ kind: "event", event });
21240
21678
  }
21241
21679
  #newItemId() {