@dotobokuri/fleet-console 1.71.1 → 1.72.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 (65) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +13 -0
  3. package/dist/cli.mjs +396 -339
  4. package/dist/client/assets/{_baseUniq-Bhd1wyKE.js → _baseUniq-D_AjNlwO.js} +1 -1
  5. package/dist/client/assets/{arc-Cu9FOmUr.js → arc-DiscagS3.js} +1 -1
  6. package/dist/client/assets/{architectureDiagram-Q4EWVU46-Dq9FA5I3.js → architectureDiagram-Q4EWVU46-PGPwULb9.js} +1 -1
  7. package/dist/client/assets/{blockDiagram-DXYQGD6D-BDZkCLI1.js → blockDiagram-DXYQGD6D-DLexJaxZ.js} +1 -1
  8. package/dist/client/assets/{c4Diagram-AHTNJAMY-XBPYwanu.js → c4Diagram-AHTNJAMY-D9Ye73ny.js} +1 -1
  9. package/dist/client/assets/channel-CR5OWwKU.js +1 -0
  10. package/dist/client/assets/{chunk-4BX2VUAB-BbTQSLs0.js → chunk-4BX2VUAB-B7YgJYL4.js} +1 -1
  11. package/dist/client/assets/{chunk-4TB4RGXK-DukpmkUz.js → chunk-4TB4RGXK-CEEQcTWi.js} +1 -1
  12. package/dist/client/assets/{chunk-55IACEB6-BFyIa1Ge.js → chunk-55IACEB6-B8AcnGT7.js} +1 -1
  13. package/dist/client/assets/{chunk-EDXVE4YY-D7RHsfQm.js → chunk-EDXVE4YY-DjZ88S2h.js} +1 -1
  14. package/dist/client/assets/{chunk-FMBD7UC4-Co64dt-k.js → chunk-FMBD7UC4-io3C2TDz.js} +1 -1
  15. package/dist/client/assets/{chunk-OYMX7WX6-CdycD6Yh.js → chunk-OYMX7WX6-s0DPD-0B.js} +1 -1
  16. package/dist/client/assets/{chunk-QZHKN3VN-CNvTB1xu.js → chunk-QZHKN3VN-DGcrSXIn.js} +1 -1
  17. package/dist/client/assets/{chunk-YZCP3GAM-CY1_pTO2.js → chunk-YZCP3GAM-Dp1DewA_.js} +1 -1
  18. package/dist/client/assets/classDiagram-6PBFFD2Q-BxfrF-vv.js +1 -0
  19. package/dist/client/assets/classDiagram-v2-HSJHXN6E-BxfrF-vv.js +1 -0
  20. package/dist/client/assets/clone-BH8tX1wM.js +1 -0
  21. package/dist/client/assets/{cose-bilkent-S5V4N54A-PLhfHDPQ.js → cose-bilkent-S5V4N54A-D9PZkL8M.js} +1 -1
  22. package/dist/client/assets/{dagre-KV5264BT-gJnGByq0.js → dagre-KV5264BT-M-8Bl0QN.js} +1 -1
  23. package/dist/client/assets/{diagram-5BDNPKRD-y48OdlFp.js → diagram-5BDNPKRD-CbFVI18N.js} +1 -1
  24. package/dist/client/assets/{diagram-G4DWMVQ6-DSLYc2V1.js → diagram-G4DWMVQ6-Bofydoge.js} +1 -1
  25. package/dist/client/assets/{diagram-MMDJMWI5-DWgtcwcn.js → diagram-MMDJMWI5-BZQV1jqh.js} +1 -1
  26. package/dist/client/assets/{diagram-TYMM5635-CLd83m-G.js → diagram-TYMM5635-v_pX67fP.js} +1 -1
  27. package/dist/client/assets/{erDiagram-SMLLAGMA-CGP2g7Ug.js → erDiagram-SMLLAGMA-DA8k24I7.js} +1 -1
  28. package/dist/client/assets/{flowDiagram-DWJPFMVM-BhKzXbma.js → flowDiagram-DWJPFMVM-CA3Jm5mj.js} +1 -1
  29. package/dist/client/assets/{ganttDiagram-T4ZO3ILL-BdpBmhZF.js → ganttDiagram-T4ZO3ILL-B6YPlixu.js} +1 -1
  30. package/dist/client/assets/{gitGraphDiagram-UUTBAWPF-IylczS5r.js → gitGraphDiagram-UUTBAWPF-3BjoRhTq.js} +1 -1
  31. package/dist/client/assets/{graph-xlKIIKKy.js → graph-CjQR1bpo.js} +1 -1
  32. package/dist/client/assets/{index-DH7xHFza.js → index-B21kBRWF.js} +70 -70
  33. package/dist/client/assets/{infoDiagram-42DDH7IO-Dm9-Iqxb.js → infoDiagram-42DDH7IO-Cz8NXcwy.js} +1 -1
  34. package/dist/client/assets/{ishikawaDiagram-UXIWVN3A-0tPrKKU3.js → ishikawaDiagram-UXIWVN3A-dJiEc4oW.js} +1 -1
  35. package/dist/client/assets/{journeyDiagram-VCZTEJTY-3wTioYxO.js → journeyDiagram-VCZTEJTY-D0e9gSNl.js} +1 -1
  36. package/dist/client/assets/{kanban-definition-6JOO6SKY-DjVcpuse.js → kanban-definition-6JOO6SKY-DJ-tyN1D.js} +1 -1
  37. package/dist/client/assets/{layout-BZ0nnXEn.js → layout-By8oq65c.js} +1 -1
  38. package/dist/client/assets/{linear-DNdW4gLV.js → linear-Bgvt1y1F.js} +1 -1
  39. package/dist/client/assets/{mermaid.core-DpO6yFcA.js → mermaid.core-BzUsxrJd.js} +4 -4
  40. package/dist/client/assets/{min-xMtTJxkM.js → min-C5LKMAsm.js} +1 -1
  41. package/dist/client/assets/{mindmap-definition-QFDTVHPH-8tcRIKM5.js → mindmap-definition-QFDTVHPH-BVEgUjPO.js} +1 -1
  42. package/dist/client/assets/{pieDiagram-DEJITSTG-DOuWZGrv.js → pieDiagram-DEJITSTG-H6ERErU1.js} +1 -1
  43. package/dist/client/assets/{quadrantDiagram-34T5L4WZ-BWPtgVdA.js → quadrantDiagram-34T5L4WZ-B3Y2XYCJ.js} +1 -1
  44. package/dist/client/assets/{requirementDiagram-MS252O5E-CkNpSYqR.js → requirementDiagram-MS252O5E-NgcHrVQM.js} +1 -1
  45. package/dist/client/assets/{sankeyDiagram-XADWPNL6-DUPS39lN.js → sankeyDiagram-XADWPNL6-DtmwsCxU.js} +1 -1
  46. package/dist/client/assets/{sequenceDiagram-FGHM5R23-B4n7l5jw.js → sequenceDiagram-FGHM5R23-Rd0S2w1n.js} +1 -1
  47. package/dist/client/assets/{stateDiagram-FHFEXIEX-DBHsG7yj.js → stateDiagram-FHFEXIEX-Cpag_fk7.js} +1 -1
  48. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-Cbjujcp-.js +1 -0
  49. package/dist/client/assets/{timeline-definition-GMOUNBTQ-BLxUyg3R.js → timeline-definition-GMOUNBTQ-C8yS2XLP.js} +1 -1
  50. package/dist/client/assets/{vennDiagram-DHZGUBPP-27NkxCen.js → vennDiagram-DHZGUBPP-Bj7SvZFm.js} +1 -1
  51. package/dist/client/assets/{wardley-RL74JXVD-VNgEaZlH.js → wardley-RL74JXVD-DZhhw2v9.js} +1 -1
  52. package/dist/client/assets/{wardleyDiagram-NUSXRM2D-byIhDvPD.js → wardleyDiagram-NUSXRM2D-DgpBbIN3.js} +1 -1
  53. package/dist/client/assets/{xychartDiagram-5P7HB3ND-D0amCilL.js → xychartDiagram-5P7HB3ND-CUq82Sal.js} +1 -1
  54. package/dist/client/index.html +1 -1
  55. package/dist/fleet-plugins/ledger/routes.mjs +62 -5
  56. package/dist/fleet-plugins/quota/routes.mjs +621 -137
  57. package/dist/fleet-plugins/scuttlebutt/routes.mjs +62 -5
  58. package/dist/fleet-plugins/terminal/routes.mjs +1521 -502
  59. package/dist/fleet.mjs +2885 -633
  60. package/package.json +1 -1
  61. package/dist/client/assets/channel-BTX-SvBb.js +0 -1
  62. package/dist/client/assets/classDiagram-6PBFFD2Q-CixB9uB6.js +0 -1
  63. package/dist/client/assets/classDiagram-v2-HSJHXN6E-CixB9uB6.js +0 -1
  64. package/dist/client/assets/clone-DuMuKBBB.js +0 -1
  65. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2--18aeGq2.js +0 -1
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import * as path18 from 'node:path';
3
- import path18__default, { posix } from 'node:path';
2
+ import * as path19 from 'node:path';
3
+ import path19__default, { posix } from 'node:path';
4
4
  import * as fs9 from 'node:fs';
5
5
  import fs9__default, { existsSync, readFileSync, lstatSync, rmSync, mkdirSync, mkdtempSync, writeFileSync, chmodSync, promises, renameSync as renameSync$1, readdirSync, closeSync, fstatSync, accessSync, constants as constants$1, realpathSync, openSync } from 'node:fs';
6
6
  import * as os3 from 'node:os';
@@ -8,9 +8,9 @@ import os3__default, { tmpdir, homedir } from 'node:os';
8
8
  import { randomUUID, createHash } from 'crypto';
9
9
  import * as fs42 from 'fs';
10
10
  import { constants, mkdirSync as mkdirSync$1, rmSync as rmSync$1, renameSync, appendFileSync, statSync } from 'fs';
11
- import * as path32 from 'path';
12
- import path32__default, { dirname } from 'path';
13
- import { execFile } from 'child_process';
11
+ import * as path42 from 'path';
12
+ import path42__default, { dirname } from 'path';
13
+ import { execFile, spawn } from 'child_process';
14
14
  import fs22, { appendFile, chmod, mkdir, stat, unlink, rename as rename$1 } from 'fs/promises';
15
15
  import os5 from 'os';
16
16
  import { promisify } from 'util';
@@ -61,8 +61,8 @@ var FLEET_DATA_DIR_NAME = ".fleet";
61
61
  var FLEET_DATA_DIR_ENV = "FLEET_DATA_DIR";
62
62
  function getFleetDataDir(env = process.env) {
63
63
  const override = env[FLEET_DATA_DIR_ENV];
64
- if (override === void 0 || override.trim().length === 0) return path18.join(os3.homedir(), FLEET_DATA_DIR_NAME);
65
- if (!path18.isAbsolute(override)) throw new Error(`${FLEET_DATA_DIR_ENV} must be an absolute path, received: ${override}`);
64
+ if (override === void 0 || override.trim().length === 0) return path19.join(os3.homedir(), FLEET_DATA_DIR_NAME);
65
+ if (!path19.isAbsolute(override)) throw new Error(`${FLEET_DATA_DIR_ENV} must be an absolute path, received: ${override}`);
66
66
  return override;
67
67
  }
68
68
  var SECURE_DIR_MODE = 448;
@@ -95,9 +95,9 @@ function ensureSafeDirectory(dirPath) {
95
95
  fs9.chmodSync(dirPath, SECURE_DIR_MODE);
96
96
  }
97
97
  function assertWithinRoot(root, candidatePath) {
98
- const resolvedRoot = path18.resolve(root);
99
- const resolvedCandidate = path18.resolve(candidatePath);
100
- if (!resolvedCandidate.startsWith(`${resolvedRoot}${path18.sep}`) && resolvedCandidate !== resolvedRoot) {
98
+ const resolvedRoot = path19.resolve(root);
99
+ const resolvedCandidate = path19.resolve(candidatePath);
100
+ if (!resolvedCandidate.startsWith(`${resolvedRoot}${path19.sep}`) && resolvedCandidate !== resolvedRoot) {
101
101
  throw new Error(`Path escapes root: ${candidatePath}`);
102
102
  }
103
103
  }
@@ -158,7 +158,7 @@ function cleanupTempFiles(dir, prefix, minAgeMs, now) {
158
158
  if (!entry.startsWith(prefix)) {
159
159
  continue;
160
160
  }
161
- const tempPath = path18.join(dir, entry);
161
+ const tempPath = path19.join(dir, entry);
162
162
  try {
163
163
  const stat4 = fs9.lstatSync(tempPath);
164
164
  if (stat4?.isFile() && !stat4.isSymbolicLink() && now - stat4.mtimeMs >= minAgeMs) {
@@ -264,7 +264,7 @@ function writeLockOwner(lockDir, ownerFileName, startedAt) {
264
264
  hostname: os3.hostname(),
265
265
  startedAt
266
266
  };
267
- const ownerPath = path18.join(lockDir, ownerFileName);
267
+ const ownerPath = path19.join(lockDir, ownerFileName);
268
268
  try {
269
269
  fs9.writeFileSync(ownerPath, JSON.stringify(owner), { encoding: "utf-8", mode: 384 });
270
270
  } catch (error51) {
@@ -273,7 +273,7 @@ function writeLockOwner(lockDir, ownerFileName, startedAt) {
273
273
  }
274
274
  }
275
275
  function readLockOwner(lockDir, ownerFileName) {
276
- const ownerPath = path18.join(lockDir, ownerFileName);
276
+ const ownerPath = path19.join(lockDir, ownerFileName);
277
277
  try {
278
278
  return sanitizeLockOwner(JSON.parse(fs9.readFileSync(ownerPath, "utf-8")));
279
279
  } catch (error51) {
@@ -331,7 +331,7 @@ function sleepSync(ms) {
331
331
  }
332
332
 
333
333
  // ../../packages/core-infra/src/auth/auth-storage.ts
334
- var DEFAULT_AUTH_PATH = path18.join(getFleetDataDir(), "auth.json");
334
+ var DEFAULT_AUTH_PATH = path19.join(getFleetDataDir(), "auth.json");
335
335
  var AUTH_LOCK_OWNER_FILE_NAME = "owner.json";
336
336
  var AUTH_LOCK_TIMEOUT_MS = 5e3;
337
337
  function readAuthStoreFile(filePath) {
@@ -406,7 +406,7 @@ function createAuthService(deps = {}) {
406
406
  }
407
407
  },
408
408
  async setApiKey(providerId, key) {
409
- const dir = path18.dirname(authPath);
409
+ const dir = path19.dirname(authPath);
410
410
  ensureSafeDirectory(dir);
411
411
  withAuthLock(authPath, lockDir, () => {
412
412
  const data = fs9.existsSync(authPath) ? readAuthStoreFile(authPath) : {};
@@ -442,7 +442,7 @@ function createDurableJsonStore(deps) {
442
442
  const sensitivity = deps.sensitivity;
443
443
  const mode = sensitivity === "sensitive" ? SECURE_FILE_MODE : 420;
444
444
  const minAgeMs = deps.tempCleanupMinAgeMs ?? DEFAULT_TEMP_FILE_MIN_AGE_MS;
445
- const dir = path18.dirname(deps.filePath);
445
+ const dir = path19.dirname(deps.filePath);
446
446
  return {
447
447
  path: deps.filePath,
448
448
  load() {
@@ -542,8 +542,8 @@ function updateGlobalOptions(store, mutate) {
542
542
  }
543
543
  function createGlobalOptionsStore(deps = {}) {
544
544
  const dataDir = deps.dataDir ?? getFleetDataDir();
545
- const optionsPath = path18.join(dataDir, GLOBAL_OPTIONS_FILE_NAME);
546
- const lockDir = path18.join(dataDir, LOCK_DIR_NAME);
545
+ const optionsPath = path19.join(dataDir, GLOBAL_OPTIONS_FILE_NAME);
546
+ const lockDir = path19.join(dataDir, LOCK_DIR_NAME);
547
547
  const store = createDurableJsonStore({
548
548
  filePath: optionsPath,
549
549
  lockDir,
@@ -684,7 +684,7 @@ function getWorkspaceDirectoryRoot(dataDir) {
684
684
  if (!dataDir.trim()) {
685
685
  throw new Error("Fleet data directory is required");
686
686
  }
687
- return path18.join(path18.resolve(dataDir), WORKSPACES_DIRECTORY_NAME);
687
+ return path19.join(path19.resolve(dataDir), WORKSPACES_DIRECTORY_NAME);
688
688
  }
689
689
  function resolveWorkspaceDirectory(dataDir, cwd) {
690
690
  const canonicalCwd = canonicalizeWorkspaceCwd(cwd);
@@ -692,7 +692,7 @@ function resolveWorkspaceDirectory(dataDir, cwd) {
692
692
  }
693
693
  function ensureWorkspaceDirectory(dataDir, cwd) {
694
694
  const workspace = resolveWorkspaceDirectory(dataDir, cwd);
695
- const resolvedDataDir = path18.resolve(dataDir);
695
+ const resolvedDataDir = path19.resolve(dataDir);
696
696
  ensureSafeDirectory(resolvedDataDir);
697
697
  ensureSafeDirectory(workspace.root);
698
698
  assertWithinRoot(workspace.root, workspace.path);
@@ -717,11 +717,11 @@ function ensureWorkspaceDirectory(dataDir, cwd) {
717
717
  function buildWorkspaceDirectory(dataDir, name, cwd) {
718
718
  assertWorkspaceDirectoryName(name);
719
719
  const root = getWorkspaceDirectoryRoot(dataDir);
720
- const workspacePath = path18.join(root, name);
720
+ const workspacePath = path19.join(root, name);
721
721
  assertWithinRoot(root, workspacePath);
722
722
  return {
723
723
  cwd,
724
- identityPath: path18.join(workspacePath, WORKSPACE_IDENTITY_FILE_NAME),
724
+ identityPath: path19.join(workspacePath, WORKSPACE_IDENTITY_FILE_NAME),
725
725
  name,
726
726
  path: workspacePath,
727
727
  root
@@ -731,7 +731,7 @@ function canonicalizeWorkspaceCwd(cwd) {
731
731
  if (!cwd.trim()) {
732
732
  throw new Error("Workspace cwd is required");
733
733
  }
734
- return fs9.realpathSync.native(path18.resolve(cwd));
734
+ return fs9.realpathSync.native(path19.resolve(cwd));
735
735
  }
736
736
  function assertWorkspaceDirectoryName(name) {
737
737
  if (!name || !WORKSPACE_NAME_PATTERN.test(name)) {
@@ -893,12 +893,12 @@ function writeLaunchPromptPointer(body, onCleanup, cmdWrapped) {
893
893
  return written.instruction;
894
894
  }
895
895
  function writeLaunchPromptFile(body, onCleanup) {
896
- const tempRoot = path18__default.resolve(os3__default.tmpdir());
896
+ const tempRoot = path19__default.resolve(os3__default.tmpdir());
897
897
  mkdirSync(tempRoot, { recursive: true });
898
- const tempDir = mkdtempSync(path18__default.join(tempRoot, LAUNCH_PROMPT_TEMP_DIR_PREFIX));
898
+ const tempDir = mkdtempSync(path19__default.join(tempRoot, LAUNCH_PROMPT_TEMP_DIR_PREFIX));
899
899
  const cleanup = () => rmBestEffort(tempDir);
900
900
  try {
901
- const filePath = path18__default.join(tempDir, LAUNCH_PROMPT_FILE_NAME);
901
+ const filePath = path19__default.join(tempDir, LAUNCH_PROMPT_FILE_NAME);
902
902
  writeFileSync(filePath, body, { encoding: "utf8", flag: "wx", mode: LAUNCH_PROMPT_FILE_MODE });
903
903
  chmodBestEffort(filePath, LAUNCH_PROMPT_FILE_MODE);
904
904
  onCleanup(cleanup);
@@ -20464,6 +20464,27 @@ function isClaudeUsageLimitDirective(text2) {
20464
20464
  function omitClaudeWebSearchTools(request) {
20465
20465
  return omitClaudeClientTools(request, CLAUDE_WEB_SEARCH_TOOL_IDENTIFIERS);
20466
20466
  }
20467
+ var CLAUDE_BILLING_HEADER_BLOCK = /^\s*x-anthropic-billing-header:[^\n]*[ \t]*$/;
20468
+ var CLAUDE_CLIENT_IDENTITY_SENTENCES = [
20469
+ "You are Claude Code, Anthropic's official CLI for Claude.",
20470
+ "You are a Claude agent, built on Anthropic's Claude Agent SDK."
20471
+ ];
20472
+ var CLAUDE_IDENTITY_MAX_BLOCK_LENGTH = Math.max(...CLAUDE_CLIENT_IDENTITY_SENTENCES.map((sentence) => sentence.length)) + 16;
20473
+ function stripClaudeClientIdentity(system) {
20474
+ if (system === void 0) return { system, changed: false, removed: 0 };
20475
+ const kept = system.filter((block) => !isClaudeClientIdentityBlock(block));
20476
+ const removed = system.length - kept.length;
20477
+ if (removed === 0) return { system, changed: false, removed: 0 };
20478
+ return { system: kept.length > 0 ? kept : void 0, changed: true, removed };
20479
+ }
20480
+ function isClaudeClientIdentityBlock(block) {
20481
+ const text2 = block.text;
20482
+ if (typeof text2 !== "string") return false;
20483
+ if (CLAUDE_BILLING_HEADER_BLOCK.test(text2)) return true;
20484
+ if (text2.length > CLAUDE_IDENTITY_MAX_BLOCK_LENGTH) return false;
20485
+ const trimmed = text2.trim();
20486
+ return CLAUDE_CLIENT_IDENTITY_SENTENCES.includes(trimmed);
20487
+ }
20467
20488
  var benchmarks_default = {
20468
20489
  version: 2,
20469
20490
  sources: {
@@ -20683,6 +20704,46 @@ var models_default = {
20683
20704
  version: 1,
20684
20705
  updatedAt: "2026-08-22T00:00:00Z",
20685
20706
  providers: {
20707
+ antigravity: {
20708
+ name: "Antigravity",
20709
+ defaultModel: "gemini-3.7-flash",
20710
+ source: "live POST https://daily-cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels read with the credential the Antigravity CLI (agy 1.1.18) owns, 2026-08-22; the same read reported defaultAgentModelId gemini-3.7-flash-high and a deprecatedModelIds entry mapping gemini-3.1-pro-high to gemini-pro-agent, and a live streamGenerateContent probe on that date confirmed gemini-3.1-pro-high is refused with INVALID_ARGUMENT while gemini-pro-agent answers. Effort spelling was measured per model on one fixed prompt: gemini-3.7-flash-tiered honours generationConfig.thinkingConfig.thinkingLevel (343 / 407 / 434 reasoning tokens at low / medium / high) so its ladder is a request field, while Gemini 3.1 Pro encodes the rung in the wire id. thinkingLevel accepts low, medium, and high only: minimal and max are both refused. Claude and GPT-OSS models are served by the same subscription but are deliberately not exposed here",
20711
+ models: [
20712
+ {
20713
+ modelId: "gemini-3.7-flash",
20714
+ name: "Gemini-3.7-Flash",
20715
+ capabilityClass: "light",
20716
+ providerModelId: "gemini-3.7-flash-tiered",
20717
+ contextWindow: 1048576,
20718
+ effort: {
20719
+ supported: true,
20720
+ levels: [
20721
+ "low",
20722
+ "medium",
20723
+ "high"
20724
+ ]
20725
+ }
20726
+ },
20727
+ {
20728
+ modelId: "gemini-3.1-pro",
20729
+ name: "Gemini-3.1-Pro",
20730
+ capabilityClass: "flagship",
20731
+ providerModelId: "gemini-3.1-pro-low",
20732
+ contextWindow: 1048576,
20733
+ effort: {
20734
+ supported: true,
20735
+ levels: [
20736
+ "low",
20737
+ "high"
20738
+ ],
20739
+ upstreamModelIds: {
20740
+ low: "gemini-3.1-pro-low",
20741
+ high: "gemini-pro-agent"
20742
+ }
20743
+ }
20744
+ }
20745
+ ]
20746
+ },
20686
20747
  codex: {
20687
20748
  name: "Codex",
20688
20749
  defaultModel: "gpt-5.6-sol",
@@ -21681,7 +21742,7 @@ var models_default = {
21681
21742
  var KIMI_AUTH_PROVIDER_ID = "Claude Code with Moonshot Kimi";
21682
21743
  var KIMI_CODE_API_BASE_URL = "https://api.kimi.com/coding";
21683
21744
  var KIMI_CODE_MODEL = "k3";
21684
- var GATEWAY_PROVIDERS = ["codex", "xai", "cursor", "opencode", "kimi"];
21745
+ var GATEWAY_PROVIDERS = ["codex", "xai", "cursor", "opencode", "antigravity", "kimi"];
21685
21746
  var GATEWAY_MODEL_WIRES = ["anthropic", "responses", "chat-completions"];
21686
21747
  var GATEWAY_REASONING_EFFORTS = [
21687
21748
  "low",
@@ -21789,7 +21850,8 @@ var GatewayModelsRegistrySchema = external_exports.object({
21789
21850
  cursor: GatewayProviderSchema,
21790
21851
  kimi: GatewayProviderSchema,
21791
21852
  opencode: GatewayProviderSchema,
21792
- xai: GatewayProviderSchema
21853
+ xai: GatewayProviderSchema,
21854
+ antigravity: GatewayProviderSchema
21793
21855
  }).strict(),
21794
21856
  pricing: GatewayPricingRegistrySchema
21795
21857
  }).strict();
@@ -21815,7 +21877,6 @@ var registry2 = (() => {
21815
21877
  return parsed;
21816
21878
  })();
21817
21879
  var GATEWAY_MODELS_UPDATED_AT = registry2.updatedAt;
21818
- registry2.pricing.observedAt;
21819
21880
  Object.freeze(
21820
21881
  Object.fromEntries(
21821
21882
  Object.entries(registry2.pricing.models).map(([modelId, pricing]) => [
@@ -22101,8 +22162,8 @@ function validateRegistry(value) {
22101
22162
  }
22102
22163
  }
22103
22164
  if (exactModelIds) {
22104
- if (provider !== "cursor") {
22105
- throw new Error(`Gateway effort model id overrides are only supported by Cursor: ${provider}/${model.modelId}`);
22165
+ if (provider !== "cursor" && provider !== "antigravity") {
22166
+ throw new Error(`Gateway effort model id overrides are only supported by Cursor and Antigravity: ${provider}/${model.modelId}`);
22106
22167
  }
22107
22168
  for (const effort of Object.keys(exactModelIds)) {
22108
22169
  if (!model.effort.levels.includes(effort)) {
@@ -24528,6 +24589,967 @@ function anthropicNativeHeaders(requestHeaders) {
24528
24589
  }
24529
24590
  return headers;
24530
24591
  }
24592
+ var execFileAsync = promisify(execFile);
24593
+ var MAX_CREDENTIAL_BYTES = 65536;
24594
+ var CREDENTIAL_OPEN_FLAGS = process.platform === "win32" ? constants.O_RDONLY : constants.O_RDONLY | constants.O_NONBLOCK;
24595
+ async function readBoundedFile(filePath, maxBytes) {
24596
+ const handle = await fs22.open(filePath, CREDENTIAL_OPEN_FLAGS);
24597
+ try {
24598
+ const stat22 = await handle.stat();
24599
+ if (!stat22.isFile() || stat22.size > maxBytes) return null;
24600
+ const buffer = Buffer.allocUnsafe(maxBytes + 1);
24601
+ let totalBytes = 0;
24602
+ while (totalBytes < buffer.byteLength) {
24603
+ const { bytesRead } = await handle.read(
24604
+ buffer,
24605
+ totalBytes,
24606
+ buffer.byteLength - totalBytes,
24607
+ totalBytes
24608
+ );
24609
+ if (bytesRead === 0) break;
24610
+ totalBytes += bytesRead;
24611
+ }
24612
+ return totalBytes > maxBytes ? null : buffer.subarray(0, totalBytes).toString("utf8");
24613
+ } finally {
24614
+ await handle.close();
24615
+ }
24616
+ }
24617
+ var defaultCredentialDeps = {
24618
+ platform: process.platform,
24619
+ homedir: os5.homedir,
24620
+ env: process.env,
24621
+ readBounded: readBoundedFile,
24622
+ execFile: async (file2, args, options) => {
24623
+ const result = await execFileAsync(file2, [...args], options);
24624
+ return result.stdout;
24625
+ }
24626
+ };
24627
+ function credentialRecord(value) {
24628
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
24629
+ }
24630
+ function optionalTrimmedString(value) {
24631
+ if (typeof value !== "string") return void 0;
24632
+ const trimmed = value.trim();
24633
+ return trimmed.length > 0 ? trimmed : void 0;
24634
+ }
24635
+ var ANTIGRAVITY_KEYCHAIN_SERVICE = "gemini";
24636
+ var ANTIGRAVITY_KEYCHAIN_ACCOUNT = "antigravity";
24637
+ var GO_KEYRING_BASE64_PREFIX = "go-keyring-base64:";
24638
+ var ANTIGRAVITY_CLI_BINARY = "agy";
24639
+ var ANTIGRAVITY_CLI_REFRESH_ARGS = ["models"];
24640
+ var ANTIGRAVITY_DAILY_API = "https://daily-cloudcode-pa.googleapis.com";
24641
+ var ANTIGRAVITY_PROD_API = "https://cloudcode-pa.googleapis.com";
24642
+ var ANTIGRAVITY_IDE_VERSION = "2.5.5";
24643
+ var ARCH_LABELS = Object.freeze({
24644
+ x64: "amd64",
24645
+ arm64: "arm64",
24646
+ ia32: "386"
24647
+ });
24648
+ function antigravityUserAgent(platform = process.platform, arch = process.arch) {
24649
+ const osType = platform === "win32" ? "windows" : platform;
24650
+ const archLabel = ARCH_LABELS[arch] ?? arch;
24651
+ return `antigravity/ide/${ANTIGRAVITY_IDE_VERSION} (os_type=${osType}; arch=${archLabel}; aidev_client; auth_method=oauth)`;
24652
+ }
24653
+ var ANTIGRAVITY_REFRESH_BUFFER_MS = 6e4;
24654
+ var VENDOR_REFRESH_TIMEOUT_MS = 2e4;
24655
+ var KEYCHAIN_TIMEOUT_MS = 5e3;
24656
+ var WINDOWS_CREDENTIAL_TIMEOUT_MS = 15e3;
24657
+ var vendorRefreshInFlight = /* @__PURE__ */ new Map();
24658
+ function expiry(value) {
24659
+ if (typeof value === "number" && Number.isFinite(value)) {
24660
+ return value < 1e12 ? Math.round(value * 1e3) : Math.round(value);
24661
+ }
24662
+ if (typeof value !== "string") return void 0;
24663
+ const parsed = Date.parse(value);
24664
+ return Number.isFinite(parsed) ? parsed : void 0;
24665
+ }
24666
+ function firstString(source, keys) {
24667
+ for (const key of keys) {
24668
+ const value = optionalTrimmedString(source[key]);
24669
+ if (value !== void 0) return value;
24670
+ }
24671
+ return void 0;
24672
+ }
24673
+ function parseAntigravityKeychainValue(raw) {
24674
+ let body = raw.trim();
24675
+ if (body.length === 0) return null;
24676
+ if (body.startsWith(GO_KEYRING_BASE64_PREFIX)) {
24677
+ try {
24678
+ body = Buffer.from(body.slice(GO_KEYRING_BASE64_PREFIX.length), "base64").toString("utf8");
24679
+ } catch {
24680
+ return null;
24681
+ }
24682
+ }
24683
+ if (/^bearer /i.test(body)) body = body.slice(7).trim();
24684
+ if (!body.startsWith("{")) {
24685
+ return body.length > 0 ? { accessToken: body } : null;
24686
+ }
24687
+ let parsed;
24688
+ try {
24689
+ parsed = JSON.parse(body);
24690
+ } catch {
24691
+ return null;
24692
+ }
24693
+ const root = credentialRecord(parsed);
24694
+ if (!root) return null;
24695
+ const source = credentialRecord(root.token) ?? credentialRecord(root.tokens) ?? credentialRecord(root.oauth) ?? credentialRecord(root.oauth2) ?? credentialRecord(root.credentials) ?? credentialRecord(root.auth) ?? root;
24696
+ const accessToken = firstString(source, [
24697
+ "access_token",
24698
+ "accessToken",
24699
+ "token",
24700
+ "id_token",
24701
+ "idToken",
24702
+ "bearerToken",
24703
+ "auth_token",
24704
+ "authToken"
24705
+ ]);
24706
+ const refreshToken2 = firstString(source, ["refresh_token", "refreshToken"]);
24707
+ const expiresAt = expiry(source.expiry) ?? expiry(source.expires_at) ?? expiry(source.expiresAt);
24708
+ if (!accessToken && !refreshToken2) return null;
24709
+ return {
24710
+ ...accessToken === void 0 ? {} : { accessToken },
24711
+ ...refreshToken2 === void 0 ? {} : { refreshToken: refreshToken2 },
24712
+ ...expiresAt === void 0 ? {} : { expiresAt }
24713
+ };
24714
+ }
24715
+ var WINDOWS_CREDENTIAL_TARGET = `${ANTIGRAVITY_KEYCHAIN_SERVICE}:${ANTIGRAVITY_KEYCHAIN_ACCOUNT}`;
24716
+ var WINDOWS_CREDENTIAL_READER = `$ErrorActionPreference = 'Stop'
24717
+ Add-Type -TypeDefinition @'
24718
+ using System;
24719
+ using System.Runtime.InteropServices;
24720
+ public static class FleetAntigravityCredential {
24721
+ [DllImport("advapi32.dll", SetLastError=true, CharSet=CharSet.Unicode, EntryPoint="CredReadW")]
24722
+ private static extern bool CredRead(string target, uint type, uint flags, out IntPtr credential);
24723
+ [DllImport("advapi32.dll")]
24724
+ private static extern void CredFree(IntPtr credential);
24725
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
24726
+ private struct CREDENTIAL {
24727
+ public uint Flags; public uint Type; public IntPtr TargetName; public IntPtr Comment;
24728
+ public long LastWritten; public uint CredentialBlobSize; public IntPtr CredentialBlob;
24729
+ public uint Persist; public uint AttributeCount; public IntPtr Attributes;
24730
+ public IntPtr TargetAlias; public IntPtr UserName;
24731
+ }
24732
+ public static string Read(string target) {
24733
+ IntPtr handle;
24734
+ if (!CredRead(target, 1, 0, out handle)) return "";
24735
+ try {
24736
+ CREDENTIAL cred = (CREDENTIAL)Marshal.PtrToStructure(handle, typeof(CREDENTIAL));
24737
+ byte[] blob = new byte[cred.CredentialBlobSize];
24738
+ Marshal.Copy(cred.CredentialBlob, blob, 0, (int)cred.CredentialBlobSize);
24739
+ return Convert.ToBase64String(blob);
24740
+ } finally { CredFree(handle); }
24741
+ }
24742
+ }
24743
+ '@
24744
+ [Console]::Out.Write([FleetAntigravityCredential]::Read('${WINDOWS_CREDENTIAL_TARGET}'))
24745
+ `;
24746
+ function windowsPowerShell(deps) {
24747
+ const systemRoot = optionalTrimmedString(deps.env.SystemRoot);
24748
+ return systemRoot === void 0 ? "powershell.exe" : path42__default.win32.join(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
24749
+ }
24750
+ async function readKeychainValue(deps) {
24751
+ if (deps.platform === "darwin") {
24752
+ const raw = await deps.execFile(
24753
+ "security",
24754
+ [
24755
+ "find-generic-password",
24756
+ "-s",
24757
+ ANTIGRAVITY_KEYCHAIN_SERVICE,
24758
+ "-a",
24759
+ ANTIGRAVITY_KEYCHAIN_ACCOUNT,
24760
+ "-w"
24761
+ ],
24762
+ { timeout: KEYCHAIN_TIMEOUT_MS }
24763
+ );
24764
+ return raw.length > MAX_CREDENTIAL_BYTES ? null : raw;
24765
+ }
24766
+ if (deps.platform === "linux") {
24767
+ const raw = await deps.execFile(
24768
+ "secret-tool",
24769
+ [
24770
+ "lookup",
24771
+ "service",
24772
+ ANTIGRAVITY_KEYCHAIN_SERVICE,
24773
+ "username",
24774
+ ANTIGRAVITY_KEYCHAIN_ACCOUNT
24775
+ ],
24776
+ { timeout: KEYCHAIN_TIMEOUT_MS }
24777
+ );
24778
+ return raw.length > MAX_CREDENTIAL_BYTES ? null : raw;
24779
+ }
24780
+ if (deps.platform === "win32") {
24781
+ const encoded = await deps.execFile(
24782
+ windowsPowerShell(deps),
24783
+ [
24784
+ "-NoProfile",
24785
+ "-NonInteractive",
24786
+ "-EncodedCommand",
24787
+ // `-EncodedCommand` takes UTF-16LE base64, which is what keeps a script
24788
+ // full of quotes and `$` out of Windows command-line quoting entirely.
24789
+ Buffer.from(WINDOWS_CREDENTIAL_READER, "utf16le").toString("base64")
24790
+ ],
24791
+ { timeout: WINDOWS_CREDENTIAL_TIMEOUT_MS }
24792
+ );
24793
+ const blob = encoded.trim();
24794
+ if (blob.length === 0) return null;
24795
+ const raw = Buffer.from(blob, "base64").toString("utf8");
24796
+ return raw.length > MAX_CREDENTIAL_BYTES ? null : raw;
24797
+ }
24798
+ return null;
24799
+ }
24800
+ function spawnVendorRefresh(deps) {
24801
+ const binary = optionalTrimmedString(deps.env.FLEET_ANTIGRAVITY_CLI) ?? ANTIGRAVITY_CLI_BINARY;
24802
+ return new Promise((resolve3) => {
24803
+ let child;
24804
+ try {
24805
+ child = spawn(binary, [...ANTIGRAVITY_CLI_REFRESH_ARGS], { stdio: "ignore" });
24806
+ } catch {
24807
+ resolve3();
24808
+ return;
24809
+ }
24810
+ let settled = false;
24811
+ const finish = () => {
24812
+ if (settled) return;
24813
+ settled = true;
24814
+ clearTimeout(timer);
24815
+ resolve3();
24816
+ };
24817
+ const timer = setTimeout(() => {
24818
+ child.kill("SIGKILL");
24819
+ finish();
24820
+ }, VENDOR_REFRESH_TIMEOUT_MS);
24821
+ child.once("error", finish);
24822
+ child.once("close", finish);
24823
+ });
24824
+ }
24825
+ async function runVendorRefresh(deps, refresh) {
24826
+ const binary = optionalTrimmedString(deps.env.FLEET_ANTIGRAVITY_CLI) ?? ANTIGRAVITY_CLI_BINARY;
24827
+ const key = `${binary}\0${deps.homedir()}`;
24828
+ const existing = vendorRefreshInFlight.get(key);
24829
+ if (existing) return existing;
24830
+ const task = refresh(deps).catch(() => void 0).finally(() => {
24831
+ vendorRefreshInFlight.delete(key);
24832
+ });
24833
+ vendorRefreshInFlight.set(key, task);
24834
+ return task;
24835
+ }
24836
+ async function resolveAntigravityAuth(deps, options = {}) {
24837
+ const now = options.now ?? Date.now;
24838
+ const read = async () => {
24839
+ let raw;
24840
+ try {
24841
+ raw = await readKeychainValue(deps);
24842
+ } catch {
24843
+ return null;
24844
+ }
24845
+ return raw === null ? null : parseAntigravityKeychainValue(raw);
24846
+ };
24847
+ const usable = (token) => {
24848
+ if (!token.accessToken) return null;
24849
+ if (token.expiresAt !== void 0 && token.expiresAt <= now()) return null;
24850
+ return {
24851
+ status: "ok",
24852
+ credentials: {
24853
+ accessToken: token.accessToken,
24854
+ method: "keychain",
24855
+ ...token.expiresAt === void 0 ? {} : { expiresAt: token.expiresAt }
24856
+ }
24857
+ };
24858
+ };
24859
+ const stored = await read();
24860
+ if (!stored) return { status: "signed_out" };
24861
+ const stale = stored.expiresAt !== void 0 && stored.expiresAt - now() <= ANTIGRAVITY_REFRESH_BUFFER_MS;
24862
+ if (options.forceRefresh !== true && !stale) {
24863
+ const ready2 = usable(stored);
24864
+ if (ready2) return ready2;
24865
+ }
24866
+ if (!stored.refreshToken) {
24867
+ return usable(stored) ?? { status: stored.accessToken ? "expired" : "signed_out" };
24868
+ }
24869
+ await runVendorRefresh(deps, options.refreshVendorCredential ?? spawnVendorRefresh);
24870
+ const renewed = await read();
24871
+ const ready = renewed ? usable(renewed) : null;
24872
+ if (ready) return ready;
24873
+ return { status: "expired" };
24874
+ }
24875
+ async function resolveAntigravityCredentials(deps, options = {}) {
24876
+ const result = await resolveAntigravityAuth(deps, options);
24877
+ return result.status === "ok" ? result.credentials : null;
24878
+ }
24879
+ var ANTIGRAVITY_LOAD_CODE_ASSIST_URL = `${ANTIGRAVITY_PROD_API}/v1internal:loadCodeAssist`;
24880
+ var REQUEST_TIMEOUT_MS = 1e4;
24881
+ var ANTIGRAVITY_CODE_ASSIST_TTL_MS = 36e5;
24882
+ var MAX_PROJECT_ID_LENGTH = 128;
24883
+ var TIER_LABELS = Object.freeze({
24884
+ "free-tier": "Free",
24885
+ "legacy-tier": "Legacy",
24886
+ "standard-tier": "Standard",
24887
+ "g1-pro-tier": "Pro",
24888
+ "g1-ultra-tier": "Ultra"
24889
+ });
24890
+ function antigravityPlanLabel(tierId) {
24891
+ const id = optionalTrimmedString(tierId)?.toLowerCase();
24892
+ if (!id) return void 0;
24893
+ const known = TIER_LABELS[id];
24894
+ if (known) return known;
24895
+ const bare = id.replace(/-tier$/, "").replace(/[-_]+/g, " ").trim();
24896
+ if (bare.length === 0 || bare.length > 24 || !/^[a-z0-9][a-z0-9 .+-]*$/.test(bare)) return void 0;
24897
+ return bare.replace(/(^|\s)([a-z0-9])/g, (_, lead, char) => `${lead}${char.toUpperCase()}`);
24898
+ }
24899
+ function projectId(value) {
24900
+ const id = optionalTrimmedString(value);
24901
+ if (!id || id.length > MAX_PROJECT_ID_LENGTH) return void 0;
24902
+ return /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(id) ? id : void 0;
24903
+ }
24904
+ async function loadAntigravityCodeAssist(fetchImpl, accessToken, signal) {
24905
+ const controller = new AbortController();
24906
+ const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
24907
+ const onAbort = () => controller.abort();
24908
+ signal?.addEventListener("abort", onAbort, { once: true });
24909
+ try {
24910
+ const response = await fetchImpl(ANTIGRAVITY_LOAD_CODE_ASSIST_URL, {
24911
+ method: "POST",
24912
+ headers: {
24913
+ Accept: "application/json",
24914
+ "Content-Type": "application/json",
24915
+ Authorization: `Bearer ${accessToken}`,
24916
+ "User-Agent": antigravityUserAgent()
24917
+ },
24918
+ body: JSON.stringify({ metadata: { ideType: "ANTIGRAVITY" } }),
24919
+ signal: controller.signal
24920
+ });
24921
+ if (!response.ok) {
24922
+ await response.body?.cancel().catch(() => void 0);
24923
+ return {};
24924
+ }
24925
+ const payload = credentialRecord(await response.json());
24926
+ if (!payload) return {};
24927
+ const project = projectId(payload.cloudaicompanionProject);
24928
+ const plan = antigravityPlanLabel(credentialRecord(payload.currentTier)?.id);
24929
+ return {
24930
+ ...project === void 0 ? {} : { projectId: project },
24931
+ ...plan === void 0 ? {} : { plan }
24932
+ };
24933
+ } catch {
24934
+ return {};
24935
+ } finally {
24936
+ clearTimeout(timer);
24937
+ signal?.removeEventListener("abort", onAbort);
24938
+ }
24939
+ }
24940
+ function createAntigravityCodeAssistCache(now = Date.now, ttlMs = ANTIGRAVITY_CODE_ASSIST_TTL_MS) {
24941
+ let entry;
24942
+ let inFlight;
24943
+ return {
24944
+ async read(fetchImpl, accessToken, signal) {
24945
+ if (entry && entry.token === accessToken && entry.expiresAt > now()) return entry.value;
24946
+ if (inFlight && inFlight.token === accessToken) return inFlight.task;
24947
+ const task = loadAntigravityCodeAssist(fetchImpl, accessToken, signal).then((value) => {
24948
+ if (value.projectId !== void 0 || value.plan !== void 0) {
24949
+ entry = { token: accessToken, value, expiresAt: now() + ttlMs };
24950
+ }
24951
+ return value;
24952
+ }).finally(() => {
24953
+ if (inFlight?.token === accessToken) inFlight = void 0;
24954
+ });
24955
+ inFlight = { token: accessToken, task };
24956
+ return task;
24957
+ },
24958
+ clear() {
24959
+ entry = void 0;
24960
+ inFlight = void 0;
24961
+ }
24962
+ };
24963
+ }
24964
+ function thinkingLevel(effort) {
24965
+ if (effort === "low" || effort === "minimal") return "low";
24966
+ if (effort === "medium") return "medium";
24967
+ return "high";
24968
+ }
24969
+ function resolveAntigravityModelSelection(modelId, requestedEffort, catalog = GATEWAY_MODELS) {
24970
+ const model = findGatewayModel(modelId, catalog) ?? catalog.find((candidate) => candidate.provider === "antigravity" && upstreamModelId(candidate) === modelId);
24971
+ if (!model || model.provider !== "antigravity") return { wireModelId: modelId };
24972
+ const baseId = upstreamModelId(model);
24973
+ if (!model.effort.supported) return { wireModelId: baseId };
24974
+ const effort = clampReasoningEffort(
24975
+ requestedEffort ?? "high",
24976
+ model.effort.levels,
24977
+ baseId
24978
+ );
24979
+ const exactModelId = model.effort.upstreamModelIds?.[effort] ?? model.effort.upstreamModelIdTemplate?.replace("{effort}", effort);
24980
+ if (exactModelId) return { wireModelId: exactModelId };
24981
+ return { wireModelId: baseId, thinkingLevel: thinkingLevel(effort) };
24982
+ }
24983
+ var GEMINI_TOOL_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_.-]{0,63}$/;
24984
+ var MAX_TOOL_NAME_LENGTH = 64;
24985
+ function createToolNameCodec() {
24986
+ const toWireMap = /* @__PURE__ */ new Map();
24987
+ const fromWireMap = /* @__PURE__ */ new Map();
24988
+ return {
24989
+ toWire(name) {
24990
+ const cached22 = toWireMap.get(name);
24991
+ if (cached22 !== void 0) return cached22;
24992
+ let wire = name;
24993
+ if (!GEMINI_TOOL_NAME_PATTERN.test(name)) {
24994
+ const suffix = createHash("sha256").update(name, "utf8").digest("hex").slice(0, 8);
24995
+ const cleaned = name.replace(/[^A-Za-z0-9_.-]/g, "_").replace(/^[^A-Za-z_]/, "_");
24996
+ wire = `${cleaned.slice(0, MAX_TOOL_NAME_LENGTH - suffix.length - 1)}_${suffix}`;
24997
+ }
24998
+ toWireMap.set(name, wire);
24999
+ if (!fromWireMap.has(wire)) fromWireMap.set(wire, name);
25000
+ return wire;
25001
+ },
25002
+ fromWire(name) {
25003
+ return fromWireMap.get(name) ?? name;
25004
+ }
25005
+ };
25006
+ }
25007
+ var GEMINI_SCHEMA_KEYS = /* @__PURE__ */ new Set([
25008
+ "type",
25009
+ "format",
25010
+ "description",
25011
+ "nullable",
25012
+ "enum",
25013
+ "items",
25014
+ "properties",
25015
+ "required",
25016
+ "minItems",
25017
+ "maxItems",
25018
+ "minimum",
25019
+ "maximum",
25020
+ "anyOf"
25021
+ ]);
25022
+ var GEMINI_STRING_FORMATS = /* @__PURE__ */ new Set(["enum", "date-time"]);
25023
+ var GEMINI_NUMBER_FORMATS = /* @__PURE__ */ new Set(["float", "double", "int32", "int64"]);
25024
+ function isRecord5(value) {
25025
+ return typeof value === "object" && value !== null && !Array.isArray(value);
25026
+ }
25027
+ function sanitizeGeminiSchema(value) {
25028
+ if (!isRecord5(value)) return { type: "object", properties: {} };
25029
+ const out = {};
25030
+ for (const [key, raw] of Object.entries(value)) {
25031
+ if (!GEMINI_SCHEMA_KEYS.has(key)) continue;
25032
+ switch (key) {
25033
+ case "properties": {
25034
+ if (!isRecord5(raw)) break;
25035
+ const properties = {};
25036
+ for (const [name, schema] of Object.entries(raw)) {
25037
+ properties[name] = sanitizeGeminiSchema(schema);
25038
+ }
25039
+ out.properties = properties;
25040
+ break;
25041
+ }
25042
+ case "items":
25043
+ out.items = sanitizeGeminiSchema(raw);
25044
+ break;
25045
+ case "anyOf":
25046
+ if (Array.isArray(raw)) out.anyOf = raw.map((entry) => sanitizeGeminiSchema(entry));
25047
+ break;
25048
+ case "format": {
25049
+ const type = typeof value.type === "string" ? value.type : "";
25050
+ const format = typeof raw === "string" ? raw : "";
25051
+ const allowed = type === "string" ? GEMINI_STRING_FORMATS : GEMINI_NUMBER_FORMATS;
25052
+ if (allowed.has(format)) out.format = format;
25053
+ break;
25054
+ }
25055
+ case "required":
25056
+ if (Array.isArray(raw)) out.required = raw.filter((entry) => typeof entry === "string");
25057
+ break;
25058
+ default:
25059
+ out[key] = raw;
25060
+ }
25061
+ }
25062
+ if (out.type === void 0 && out.properties !== void 0) out.type = "object";
25063
+ return out;
25064
+ }
25065
+ function geminiFunctionDeclarations(tools, codec2) {
25066
+ return tools.map((tool) => ({
25067
+ name: codec2.toWire(tool.name),
25068
+ ...tool.description === void 0 ? {} : { description: tool.description },
25069
+ parameters: sanitizeGeminiSchema(tool.parameters)
25070
+ }));
25071
+ }
25072
+ function geminiToolConfig(choice, codec2) {
25073
+ if (choice === void 0 || choice === "auto") return void 0;
25074
+ if (choice === "none") return { functionCallingConfig: { mode: "NONE" } };
25075
+ if (choice === "required") return { functionCallingConfig: { mode: "ANY" } };
25076
+ return {
25077
+ functionCallingConfig: { mode: "ANY", allowedFunctionNames: [codec2.toWire(choice.name)] }
25078
+ };
25079
+ }
25080
+ var DATA_URL = /^data:([^;,]+);base64,(.*)$/s;
25081
+ function imagePart(imageUrl) {
25082
+ const match = DATA_URL.exec(imageUrl);
25083
+ if (!match) return void 0;
25084
+ const [, mimeType, data] = match;
25085
+ if (!mimeType || !data) return void 0;
25086
+ return { inline_data: { mime_type: mimeType, data } };
25087
+ }
25088
+ function createAntigravitySignatureLedger(maxEntries = 512) {
25089
+ const entries = /* @__PURE__ */ new Map();
25090
+ return {
25091
+ record(callId, signature) {
25092
+ if (callId.length === 0 || signature.length === 0) return;
25093
+ entries.delete(callId);
25094
+ entries.set(callId, signature);
25095
+ while (entries.size > maxEntries) {
25096
+ const oldest = entries.keys().next();
25097
+ if (oldest.done) break;
25098
+ entries.delete(oldest.value);
25099
+ }
25100
+ },
25101
+ recall(callId) {
25102
+ return entries.get(callId);
25103
+ }
25104
+ };
25105
+ }
25106
+ function isAntigravitySignature(value) {
25107
+ return typeof value === "string" && value.length >= 16 && !/^(fc|ctc|tsc|call|msg|rs|resp|reasoning|item|ws|toolu|tool|func|function)[-_]/i.test(value) && /^[A-Za-z0-9+/_=-]+$/.test(value);
25108
+ }
25109
+ function parsedArguments(raw) {
25110
+ if (raw.trim().length === 0) return {};
25111
+ try {
25112
+ const parsed = JSON.parse(raw);
25113
+ return isRecord5(parsed) ? parsed : {};
25114
+ } catch {
25115
+ return {};
25116
+ }
25117
+ }
25118
+ function signatureFor(item, callId, ledger) {
25119
+ if (isAntigravitySignature(item.reasoning_encrypted)) return item.reasoning_encrypted;
25120
+ const recalled = ledger.recall(callId);
25121
+ return isAntigravitySignature(recalled) ? recalled : void 0;
25122
+ }
25123
+ function geminiContents(input, codec2, ledger) {
25124
+ const contents = [];
25125
+ const push = (role, parts) => {
25126
+ if (parts.length === 0) return;
25127
+ const tail = contents.at(-1);
25128
+ if (tail && tail.role === role) tail.parts.push(...parts);
25129
+ else contents.push({ role, parts });
25130
+ };
25131
+ for (const item of input) {
25132
+ if (item.type === "function_call") {
25133
+ const signature = signatureFor(item, item.call_id, ledger);
25134
+ push("model", [{
25135
+ ...signature === void 0 ? {} : { thoughtSignature: signature },
25136
+ functionCall: {
25137
+ name: codec2.toWire(item.name),
25138
+ args: parsedArguments(item.arguments),
25139
+ id: item.call_id
25140
+ }
25141
+ }]);
25142
+ continue;
25143
+ }
25144
+ if (item.type === "function_call_output") {
25145
+ push("user", [{
25146
+ functionResponse: {
25147
+ name: codec2.toWire(item.call_id),
25148
+ response: { result: item.output },
25149
+ id: item.call_id
25150
+ }
25151
+ }]);
25152
+ continue;
25153
+ }
25154
+ const role = item.role === "assistant" ? "model" : "user";
25155
+ const parts = [];
25156
+ const text2 = canonicalMessageText(item.content);
25157
+ if (text2.length > 0) {
25158
+ const signature = role === "model" && isAntigravitySignature(item.reasoning_encrypted) ? item.reasoning_encrypted : void 0;
25159
+ parts.push({ text: text2, ...signature === void 0 ? {} : { thoughtSignature: signature } });
25160
+ }
25161
+ for (const image of canonicalMessageImages(item.content)) {
25162
+ const part = imagePart(image.image_url);
25163
+ if (part) parts.push(part);
25164
+ }
25165
+ push(role, parts);
25166
+ }
25167
+ return contents;
25168
+ }
25169
+ function linkFunctionResponseNames(contents) {
25170
+ const namesByCallId = /* @__PURE__ */ new Map();
25171
+ for (const content of contents) {
25172
+ for (const part of content.parts) {
25173
+ if (part.functionCall?.id) namesByCallId.set(part.functionCall.id, part.functionCall.name);
25174
+ }
25175
+ }
25176
+ for (const content of contents) {
25177
+ for (const part of content.parts) {
25178
+ const response = part.functionResponse;
25179
+ if (!response?.id) continue;
25180
+ const name = namesByCallId.get(response.id);
25181
+ if (name) response.name = name;
25182
+ }
25183
+ }
25184
+ return contents;
25185
+ }
25186
+ function antigravitySessionId(input) {
25187
+ const anchor = input.find(
25188
+ (item) => item.type === "message" && item.role === "user"
25189
+ );
25190
+ const text2 = anchor ? canonicalMessageText(anchor.content) : "";
25191
+ const digest = createHash("sha256").update(text2, "utf8").digest();
25192
+ const masked = digest.readBigUInt64BE(0) & 0x7fffffffffffffffn;
25193
+ return `-${masked.toString()}`;
25194
+ }
25195
+ function buildAntigravityEnvelope(request, options) {
25196
+ const selection = resolveAntigravityModelSelection(request.model, request.reasoning?.effort);
25197
+ const contents = linkFunctionResponseNames(
25198
+ geminiContents(request.input, options.codec, options.ledger)
25199
+ );
25200
+ const declarations = geminiFunctionDeclarations(request.tools ?? [], options.codec);
25201
+ const toolConfig = geminiToolConfig(request.tool_choice, options.codec);
25202
+ return {
25203
+ model: selection.wireModelId,
25204
+ userAgent: "antigravity",
25205
+ requestType: "agent",
25206
+ ...options.project === void 0 ? {} : { project: options.project },
25207
+ requestId: options.requestId,
25208
+ request: {
25209
+ contents,
25210
+ ...request.instructions === void 0 || request.instructions.length === 0 ? {} : { systemInstruction: { role: "user", parts: [{ text: request.instructions }] } },
25211
+ ...declarations.length > 0 ? { tools: [{ functionDeclarations: declarations }] } : {},
25212
+ ...toolConfig === void 0 ? {} : { toolConfig },
25213
+ generationConfig: {
25214
+ ...request.max_output_tokens === void 0 ? {} : { maxOutputTokens: request.max_output_tokens },
25215
+ ...selection.thinkingLevel === void 0 ? {} : { thinkingConfig: { thinkingLevel: selection.thinkingLevel } }
25216
+ },
25217
+ sessionId: antigravitySessionId(request.input)
25218
+ }
25219
+ };
25220
+ }
25221
+ function isRecord6(value) {
25222
+ return typeof value === "object" && value !== null && !Array.isArray(value);
25223
+ }
25224
+ function positiveNumber(value) {
25225
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
25226
+ }
25227
+ function antigravityUsage(value) {
25228
+ if (!isRecord6(value)) return null;
25229
+ const inputTokens = positiveNumber(value.promptTokenCount) ?? 0;
25230
+ const visibleOutput = positiveNumber(value.candidatesTokenCount) ?? 0;
25231
+ const reasoning = positiveNumber(value.thoughtsTokenCount);
25232
+ const cached22 = positiveNumber(value.cachedContentTokenCount);
25233
+ const total = positiveNumber(value.totalTokenCount);
25234
+ return {
25235
+ input_tokens: inputTokens,
25236
+ output_tokens: visibleOutput + (reasoning ?? 0),
25237
+ ...cached22 === void 0 ? {} : { cached_input_tokens: cached22 },
25238
+ ...reasoning === void 0 ? {} : { reasoning_output_tokens: reasoning },
25239
+ ...total === void 0 ? {} : { total_tokens: total }
25240
+ };
25241
+ }
25242
+ function antigravityError(value) {
25243
+ const error51 = isRecord6(value) ? value.error : void 0;
25244
+ if (!isRecord6(error51)) return void 0;
25245
+ const message = typeof error51.message === "string" && error51.message.length > 0 ? error51.message : "Antigravity request failed";
25246
+ const status = typeof error51.status === "string" ? error51.status : void 0;
25247
+ const code = typeof error51.code === "number" ? error51.code : void 0;
25248
+ return { type: canonicalErrorType(status, code), message };
25249
+ }
25250
+ function canonicalErrorType(status, code) {
25251
+ switch (status) {
25252
+ case "UNAUTHENTICATED":
25253
+ return "authentication_error";
25254
+ case "PERMISSION_DENIED":
25255
+ return "permission_error";
25256
+ case "RESOURCE_EXHAUSTED":
25257
+ return "rate_limit_error";
25258
+ case "INVALID_ARGUMENT":
25259
+ case "NOT_FOUND":
25260
+ return "invalid_request_error";
25261
+ case "UNAVAILABLE":
25262
+ return "overloaded_error";
25263
+ }
25264
+ if (code === 401) return "authentication_error";
25265
+ if (code === 403) return "permission_error";
25266
+ if (code === 429) return "rate_limit_error";
25267
+ if (code === 400 || code === 404) return "invalid_request_error";
25268
+ if (code === 503) return "overloaded_error";
25269
+ return "api_error";
25270
+ }
25271
+ function parseAntigravityFrame(data) {
25272
+ const trimmed = data.trim();
25273
+ if (trimmed.length === 0) return void 0;
25274
+ let parsed;
25275
+ try {
25276
+ parsed = JSON.parse(trimmed);
25277
+ } catch {
25278
+ throw new UpstreamProtocolError("Antigravity stream frame was not valid JSON");
25279
+ }
25280
+ if (!isRecord6(parsed)) return void 0;
25281
+ logRawWireEvent("antigravity.wire.event", void 0, parsed);
25282
+ if (isRecord6(parsed.error)) return { error: parsed };
25283
+ const response = isRecord6(parsed.response) ? parsed.response : void 0;
25284
+ return response === void 0 ? void 0 : { response };
25285
+ }
25286
+ function partSignature(part) {
25287
+ const direct = part.thoughtSignature ?? part.thought_signature;
25288
+ return isAntigravitySignature(direct) ? direct : void 0;
25289
+ }
25290
+ async function* translateAntigravityStream(frames, options) {
25291
+ let started = false;
25292
+ let responseId = "";
25293
+ let model = options.model;
25294
+ let usage4 = null;
25295
+ let outputIndex = 0;
25296
+ let sequence = 0;
25297
+ const callIdPrefix = options.callIdPrefix && options.callIdPrefix.length > 0 ? options.callIdPrefix : randomUUID();
25298
+ let textItemId;
25299
+ let reasoningItemId;
25300
+ let failed;
25301
+ const snapshot = () => ({ id: responseId, model, usage: usage4 });
25302
+ function* closeText() {
25303
+ if (textItemId === void 0) return;
25304
+ yield { type: "response.output_text.done", item_id: textItemId, output_index: outputIndex, content_index: 0, text: "" };
25305
+ outputIndex += 1;
25306
+ textItemId = void 0;
25307
+ }
25308
+ function* closeReasoning(signature) {
25309
+ if (reasoningItemId === void 0 && signature === void 0) return;
25310
+ const id = reasoningItemId ?? `agr_${sequence++}`;
25311
+ yield {
25312
+ type: "response.output_item.done",
25313
+ output_index: outputIndex,
25314
+ item: {
25315
+ id,
25316
+ type: "reasoning",
25317
+ ...signature === void 0 ? {} : { encrypted_content: signature }
25318
+ }
25319
+ };
25320
+ outputIndex += 1;
25321
+ reasoningItemId = void 0;
25322
+ }
25323
+ for await (const frame of frames) {
25324
+ if (frame.error !== void 0) {
25325
+ failed = antigravityError(frame.error) ?? { type: "api_error", message: "Antigravity request failed" };
25326
+ break;
25327
+ }
25328
+ const response = frame.response;
25329
+ if (!response) continue;
25330
+ if (typeof response.responseId === "string" && responseId.length === 0) responseId = response.responseId;
25331
+ if (typeof response.modelVersion === "string" && response.modelVersion.length > 0) {
25332
+ model = response.modelVersion;
25333
+ }
25334
+ const frameUsage = antigravityUsage(response.usageMetadata);
25335
+ if (frameUsage) usage4 = frameUsage;
25336
+ if (!started) {
25337
+ started = true;
25338
+ yield { type: "response.created", response: { id: responseId, model, usage: null } };
25339
+ }
25340
+ const candidates = Array.isArray(response.candidates) ? response.candidates : [];
25341
+ const candidate = isRecord6(candidates[0]) ? candidates[0] : void 0;
25342
+ const content = isRecord6(candidate?.content) ? candidate.content : void 0;
25343
+ const parts = Array.isArray(content?.parts) ? content.parts.filter(isRecord6) : [];
25344
+ for (const part of parts) {
25345
+ const call = isRecord6(part.functionCall) ? part.functionCall : void 0;
25346
+ if (call) {
25347
+ yield* closeText();
25348
+ const signature2 = partSignature(part);
25349
+ yield* closeReasoning(signature2);
25350
+ const wireName = typeof call.name === "string" ? call.name : "";
25351
+ const callId = typeof call.id === "string" && call.id.length > 0 ? call.id : `agc_${callIdPrefix}_${sequence++}`;
25352
+ if (signature2 !== void 0) options.ledger.record(callId, signature2);
25353
+ const args = JSON.stringify(isRecord6(call.args) ? call.args : {});
25354
+ const itemId = `agf_${sequence++}`;
25355
+ yield {
25356
+ type: "response.output_item.added",
25357
+ output_index: outputIndex,
25358
+ item: {
25359
+ id: itemId,
25360
+ type: "function_call",
25361
+ call_id: callId,
25362
+ name: options.codec.fromWire(wireName),
25363
+ arguments: ""
25364
+ }
25365
+ };
25366
+ yield { type: "response.function_call_arguments.delta", item_id: itemId, output_index: outputIndex, delta: args };
25367
+ yield { type: "response.function_call_arguments.done", item_id: itemId, output_index: outputIndex, arguments: args };
25368
+ yield {
25369
+ type: "response.output_item.done",
25370
+ output_index: outputIndex,
25371
+ item: {
25372
+ id: itemId,
25373
+ type: "function_call",
25374
+ call_id: callId,
25375
+ name: options.codec.fromWire(wireName),
25376
+ arguments: args
25377
+ }
25378
+ };
25379
+ outputIndex += 1;
25380
+ continue;
25381
+ }
25382
+ const text2 = typeof part.text === "string" ? part.text : "";
25383
+ const signature = partSignature(part);
25384
+ if (part.thought === true) {
25385
+ if (text2.length > 0) {
25386
+ if (reasoningItemId === void 0) {
25387
+ yield* closeText();
25388
+ reasoningItemId = `agr_${sequence++}`;
25389
+ }
25390
+ yield { type: "response.reasoning_summary_text.delta", item_id: reasoningItemId, output_index: outputIndex, delta: text2 };
25391
+ }
25392
+ if (signature !== void 0) yield* closeReasoning(signature);
25393
+ continue;
25394
+ }
25395
+ if (text2.length > 0) {
25396
+ yield* closeReasoning(void 0);
25397
+ if (textItemId === void 0) {
25398
+ textItemId = `agm_${sequence++}`;
25399
+ yield {
25400
+ type: "response.content_part.added",
25401
+ item_id: textItemId,
25402
+ output_index: outputIndex,
25403
+ content_index: 0,
25404
+ part: { type: "output_text", text: "" }
25405
+ };
25406
+ }
25407
+ yield { type: "response.output_text.delta", item_id: textItemId, output_index: outputIndex, content_index: 0, delta: text2 };
25408
+ }
25409
+ if (signature !== void 0) yield* closeReasoning(signature);
25410
+ }
25411
+ }
25412
+ yield* closeText();
25413
+ yield* closeReasoning(void 0);
25414
+ if (failed) {
25415
+ yield { type: "response.failed", response: { ...snapshot(), error: failed } };
25416
+ return;
25417
+ }
25418
+ if (!started) {
25419
+ throw new UpstreamProtocolError("Antigravity stream produced no response frames");
25420
+ }
25421
+ yield { type: "response.completed", response: snapshot() };
25422
+ }
25423
+ var ANTIGRAVITY_STREAM_URL = `${ANTIGRAVITY_DAILY_API}/v1internal:streamGenerateContent?alt=sse`;
25424
+ var DEFAULT_ANTIGRAVITY_MAX_UPSTREAM_BODY_BYTES = 64 * 1024 * 1024;
25425
+ var AUTH_REJECTION_STATUS = /* @__PURE__ */ new Set([401, 403]);
25426
+ async function discardResponseBody(response) {
25427
+ await response.body?.cancel().catch(() => void 0);
25428
+ }
25429
+ var DEFAULT_ANTIGRAVITY_UPSTREAM_IDLE_TIMEOUT_MS = 3e5;
25430
+ var AntigravityGenerateContentAdapter = class {
25431
+ capabilities = {};
25432
+ fetchImpl;
25433
+ maxBodyBytes;
25434
+ idleTimeoutMs;
25435
+ project;
25436
+ codeAssist;
25437
+ ledger;
25438
+ renewCredential;
25439
+ constructor(options = {}) {
25440
+ this.fetchImpl = options.fetch ?? ((input, init) => fetch(input, init));
25441
+ this.maxBodyBytes = options.maxBodyBytes === void 0 ? DEFAULT_ANTIGRAVITY_MAX_UPSTREAM_BODY_BYTES : positiveInteger(options.maxBodyBytes, "maxBodyBytes");
25442
+ this.idleTimeoutMs = options.idleTimeoutMs === void 0 ? DEFAULT_ANTIGRAVITY_UPSTREAM_IDLE_TIMEOUT_MS : positiveInteger(options.idleTimeoutMs, "idleTimeoutMs");
25443
+ this.project = options.project;
25444
+ this.codeAssist = options.codeAssist ?? createAntigravityCodeAssistCache();
25445
+ this.ledger = options.signatureLedger ?? createAntigravitySignatureLedger();
25446
+ this.renewCredential = options.renewCredential;
25447
+ }
25448
+ async stream(request, options) {
25449
+ const controller = new AbortController();
25450
+ const unlink2 = linkAbortSignal(options.signal, controller);
25451
+ const codec2 = createToolNameCodec();
25452
+ const project = this.project ?? (await this.codeAssist.read(this.fetchImpl, options.apiKey, controller.signal)).projectId;
25453
+ const envelope = buildAntigravityEnvelope(request, {
25454
+ ...project === void 0 ? {} : { project },
25455
+ requestId: `agent-${randomUUID()}`,
25456
+ codec: codec2,
25457
+ ledger: this.ledger
25458
+ });
25459
+ const replayable = envelope.request.contents.flatMap((content) => content.role === "model" ? content.parts.filter((part) => part.functionCall !== void 0) : []);
25460
+ wireLog("antigravity.wire.request", {
25461
+ url: ANTIGRAVITY_STREAM_URL,
25462
+ model: envelope.model,
25463
+ hasProject: project !== void 0,
25464
+ contents: envelope.request.contents.length,
25465
+ replayableCalls: replayable.length,
25466
+ replayedSignatures: replayable.filter((part) => part.thoughtSignature !== void 0).length,
25467
+ tools: envelope.request.tools?.[0].functionDeclarations.length ?? 0,
25468
+ toolConfig: envelope.request.toolConfig,
25469
+ generationConfig: envelope.request.generationConfig
25470
+ });
25471
+ const body = JSON.stringify(envelope);
25472
+ const send = (token) => this.fetchImpl(ANTIGRAVITY_STREAM_URL, {
25473
+ method: "POST",
25474
+ headers: {
25475
+ "Content-Type": "application/json",
25476
+ Accept: "text/event-stream",
25477
+ Authorization: `Bearer ${token}`,
25478
+ "User-Agent": antigravityUserAgent()
25479
+ },
25480
+ body,
25481
+ signal: controller.signal
25482
+ });
25483
+ let response;
25484
+ try {
25485
+ response = await send(options.apiKey);
25486
+ if (AUTH_REJECTION_STATUS.has(response.status) && this.renewCredential) {
25487
+ const renewed = await this.renewCredential().catch(() => null);
25488
+ if (renewed && renewed !== options.apiKey) {
25489
+ wireLog("antigravity.wire.auth_retry", { status: response.status });
25490
+ await discardResponseBody(response);
25491
+ response = await send(renewed);
25492
+ }
25493
+ }
25494
+ } catch (error51) {
25495
+ unlink2();
25496
+ throw error51;
25497
+ }
25498
+ const readOptions = {
25499
+ controller,
25500
+ idleTimeoutMs: this.idleTimeoutMs,
25501
+ maxBodyBytes: this.maxBodyBytes
25502
+ };
25503
+ if (!response.ok) {
25504
+ try {
25505
+ return {
25506
+ ok: false,
25507
+ status: response.status,
25508
+ headers: response.headers,
25509
+ body: await readBoundedBody(response.body, readOptions)
25510
+ };
25511
+ } finally {
25512
+ unlink2();
25513
+ }
25514
+ }
25515
+ const frames = parseUpstreamSseStream(response.body, {
25516
+ ...readOptions,
25517
+ onClose: unlink2,
25518
+ missingBodyMessage: "Antigravity response had no body"
25519
+ }, (frame) => parseAntigravityFrame(parseSseFrameFields(frame).data));
25520
+ return {
25521
+ ok: true,
25522
+ status: response.status,
25523
+ headers: response.headers,
25524
+ events: translateAntigravityStream(frames, {
25525
+ codec: codec2,
25526
+ ledger: this.ledger,
25527
+ model: request.model,
25528
+ // The envelope's own request id is already unique per request.
25529
+ callIdPrefix: envelope.requestId
25530
+ })
25531
+ };
25532
+ }
25533
+ /**
25534
+ * Every declared tool is serialized: this wire has no deferred-loading contract
25535
+ * to honour, so the pre-flight estimate measures exactly what is sent.
25536
+ */
25537
+ wireTools(request) {
25538
+ return request.tools ?? [];
25539
+ }
25540
+ };
25541
+ var HOUR_MS = 36e5;
25542
+ var WEEK_MS = 7 * 24 * HOUR_MS;
25543
+ var SESSION_MS = 5 * HOUR_MS;
25544
+ var BUCKETS = Object.freeze({
25545
+ "gemini-5h": { id: "session", label: "Gemini", durationMs: SESSION_MS, reported: true },
25546
+ "gemini-weekly": { id: "weekly", label: "Gemini", durationMs: WEEK_MS, reported: true },
25547
+ "3p-5h": { id: "session", label: "Claude & GPT", durationMs: SESSION_MS, reported: false },
25548
+ "3p-weekly": { id: "weekly", label: "Claude & GPT", durationMs: WEEK_MS, reported: false }
25549
+ });
25550
+ Object.freeze(
25551
+ Object.keys(BUCKETS).filter((bucketId) => BUCKETS[bucketId]?.reported === true)
25552
+ );
24531
25553
  var MS_PER_HOUR = 36e5;
24532
25554
  var CADENCE_SESSION_MAX_MS = 20 * MS_PER_HOUR;
24533
25555
  var CADENCE_DAILY_MAX_MS = 3 * 24 * MS_PER_HOUR;
@@ -24584,54 +25606,11 @@ function deriveQuotaWindowRisk(window, at) {
24584
25606
  pressure: windowPressure(window.usedPercent, paceRatio)
24585
25607
  };
24586
25608
  }
24587
- var execFileAsync = promisify(execFile);
24588
- var MAX_CREDENTIAL_BYTES = 65536;
24589
- var CREDENTIAL_OPEN_FLAGS = process.platform === "win32" ? constants.O_RDONLY : constants.O_RDONLY | constants.O_NONBLOCK;
24590
- async function readBoundedFile(filePath, maxBytes) {
24591
- const handle = await fs22.open(filePath, CREDENTIAL_OPEN_FLAGS);
24592
- try {
24593
- const stat22 = await handle.stat();
24594
- if (!stat22.isFile() || stat22.size > maxBytes) return null;
24595
- const buffer = Buffer.allocUnsafe(maxBytes + 1);
24596
- let totalBytes = 0;
24597
- while (totalBytes < buffer.byteLength) {
24598
- const { bytesRead } = await handle.read(
24599
- buffer,
24600
- totalBytes,
24601
- buffer.byteLength - totalBytes,
24602
- totalBytes
24603
- );
24604
- if (bytesRead === 0) break;
24605
- totalBytes += bytesRead;
24606
- }
24607
- return totalBytes > maxBytes ? null : buffer.subarray(0, totalBytes).toString("utf8");
24608
- } finally {
24609
- await handle.close();
24610
- }
24611
- }
24612
- var defaultCredentialDeps = {
24613
- platform: process.platform,
24614
- homedir: os5.homedir,
24615
- env: process.env,
24616
- readBounded: readBoundedFile,
24617
- execFile: async (file2, args, options) => {
24618
- const result = await execFileAsync(file2, [...args], options);
24619
- return result.stdout;
24620
- }
24621
- };
24622
- function credentialRecord(value) {
24623
- return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
24624
- }
24625
- function optionalTrimmedString(value) {
24626
- if (typeof value !== "string") return void 0;
24627
- const trimmed = value.trim();
24628
- return trimmed.length > 0 ? trimmed : void 0;
24629
- }
24630
25609
  function optionalNonEmptyString(value) {
24631
25610
  return typeof value === "string" && value.length > 0 ? value : void 0;
24632
25611
  }
24633
25612
  function codexAuthFilePath(deps) {
24634
- return path32__default.join(deps.env.CODEX_HOME || path32__default.join(deps.homedir(), ".codex"), "auth.json");
25613
+ return path42__default.join(deps.env.CODEX_HOME || path42__default.join(deps.homedir(), ".codex"), "auth.json");
24635
25614
  }
24636
25615
  async function resolveCodexCredentials(deps) {
24637
25616
  try {
@@ -24670,12 +25649,12 @@ function parseCursorCredentialJson(raw, method) {
24670
25649
  function cursorAuthFilePath(deps) {
24671
25650
  const home = deps.homedir();
24672
25651
  if (deps.platform === "win32") {
24673
- return path32__default.join(deps.env.APPDATA || path32__default.join(home, "AppData", "Roaming"), "Cursor", "auth.json");
25652
+ return path42__default.join(deps.env.APPDATA || path42__default.join(home, "AppData", "Roaming"), "Cursor", "auth.json");
24674
25653
  }
24675
25654
  if (deps.platform === "darwin") {
24676
- return path32__default.join(home, ".cursor", "auth.json");
25655
+ return path42__default.join(home, ".cursor", "auth.json");
24677
25656
  }
24678
- return path32__default.join(deps.env.XDG_CONFIG_HOME || path32__default.join(home, ".config"), "cursor", "auth.json");
25657
+ return path42__default.join(deps.env.XDG_CONFIG_HOME || path42__default.join(home, ".config"), "cursor", "auth.json");
24679
25658
  }
24680
25659
  async function resolveCursorCredentials(deps) {
24681
25660
  if (deps.platform === "darwin") {
@@ -24968,16 +25947,16 @@ function pruneUndeclaredArguments(raw, schema) {
24968
25947
  return pruned === parsed ? raw : JSON.stringify(pruned);
24969
25948
  }
24970
25949
  function pruneUndeclaredValue(value, schema) {
24971
- if (!isRecord5(schema)) return value;
25950
+ if (!isRecord7(schema)) return value;
24972
25951
  if (typeof schema.$ref === "string") return value;
24973
25952
  if (Array.isArray(schema.anyOf) || Array.isArray(schema.oneOf) || Array.isArray(schema.allOf)) {
24974
25953
  return value;
24975
25954
  }
24976
- if (isRecord5(schema.patternProperties) || isRecord5(schema.dependentSchemas) || schema.if !== void 0 || schema.unevaluatedProperties !== void 0) {
25955
+ if (isRecord7(schema.patternProperties) || isRecord7(schema.dependentSchemas) || schema.if !== void 0 || schema.unevaluatedProperties !== void 0) {
24977
25956
  return value;
24978
25957
  }
24979
25958
  if (Array.isArray(value)) {
24980
- if (!isRecord5(schema.items)) return value;
25959
+ if (!isRecord7(schema.items)) return value;
24981
25960
  let changed2 = false;
24982
25961
  const next2 = value.map((entry) => {
24983
25962
  const pruned = pruneUndeclaredValue(entry, schema.items);
@@ -24986,8 +25965,8 @@ function pruneUndeclaredValue(value, schema) {
24986
25965
  });
24987
25966
  return changed2 ? next2 : value;
24988
25967
  }
24989
- if (!isRecord5(value)) return value;
24990
- const properties = isRecord5(schema.properties) ? schema.properties : void 0;
25968
+ if (!isRecord7(value)) return value;
25969
+ const properties = isRecord7(schema.properties) ? schema.properties : void 0;
24991
25970
  if (properties === void 0) return value;
24992
25971
  const closed = schema.additionalProperties === false;
24993
25972
  let changed = false;
@@ -25026,10 +26005,10 @@ async function* translateChatCompletionsStream(body, options, toolSchemas) {
25026
26005
  const toolCalls = /* @__PURE__ */ new Map();
25027
26006
  const MESSAGE_ITEM_ID = "chat_message_0";
25028
26007
  function* consumeChunk(value) {
25029
- if (!isRecord5(value)) {
26008
+ if (!isRecord7(value)) {
25030
26009
  throw new UpstreamProtocolError("Chat Completions SSE event was not an object");
25031
26010
  }
25032
- if (isRecord5(value.error)) {
26011
+ if (isRecord7(value.error)) {
25033
26012
  failed = true;
25034
26013
  yield { type: "error", error: chatCanonicalError(value.error) };
25035
26014
  return;
@@ -25051,13 +26030,13 @@ async function* translateChatCompletionsStream(body, options, toolSchemas) {
25051
26030
  }
25052
26031
  };
25053
26032
  }
25054
- if (isRecord5(value.usage)) {
26033
+ if (isRecord7(value.usage)) {
25055
26034
  usage4 = chatUsage(value.usage);
25056
26035
  }
25057
26036
  const choices = Array.isArray(value.choices) ? value.choices : [];
25058
26037
  for (const choice of choices) {
25059
- if (!isRecord5(choice)) continue;
25060
- const delta = isRecord5(choice.delta) ? choice.delta : {};
26038
+ if (!isRecord7(choice)) continue;
26039
+ const delta = isRecord7(choice.delta) ? choice.delta : {};
25061
26040
  if (typeof delta.reasoning_content === "string" && delta.reasoning_content.length > 0) {
25062
26041
  yield {
25063
26042
  type: "response.reasoning_summary_text.delta",
@@ -25079,13 +26058,13 @@ async function* translateChatCompletionsStream(body, options, toolSchemas) {
25079
26058
  }
25080
26059
  const wireToolCalls = Array.isArray(delta.tool_calls) ? delta.tool_calls : [];
25081
26060
  for (const call of wireToolCalls) {
25082
- if (!isRecord5(call)) continue;
26061
+ if (!isRecord7(call)) continue;
25083
26062
  const index = typeof call.index === "number" ? call.index : 0;
25084
26063
  const pending = toolCalls.get(index) ?? { arguments: "" };
25085
26064
  if (typeof call.id === "string" && call.id.length > 0) {
25086
26065
  pending.id ??= call.id;
25087
26066
  }
25088
- const fn = isRecord5(call.function) ? call.function : {};
26067
+ const fn = isRecord7(call.function) ? call.function : {};
25089
26068
  if (typeof fn.name === "string" && fn.name.length > 0) {
25090
26069
  pending.name ??= fn.name;
25091
26070
  }
@@ -25207,8 +26186,8 @@ function chatFrameData(frame) {
25207
26186
  function chatUsage(value) {
25208
26187
  const inputTokens = nonNegativeOrZero(value.prompt_tokens);
25209
26188
  const outputTokens = nonNegativeOrZero(value.completion_tokens);
25210
- const promptDetails = isRecord5(value.prompt_tokens_details) ? value.prompt_tokens_details : void 0;
25211
- const completionDetails = isRecord5(value.completion_tokens_details) ? value.completion_tokens_details : void 0;
26189
+ const promptDetails = isRecord7(value.prompt_tokens_details) ? value.prompt_tokens_details : void 0;
26190
+ const completionDetails = isRecord7(value.completion_tokens_details) ? value.completion_tokens_details : void 0;
25212
26191
  const cachedInputTokens = promptDetails === void 0 ? void 0 : optionalNonNegative(promptDetails.cached_tokens);
25213
26192
  const reasoningOutputTokens = completionDetails === void 0 ? void 0 : optionalNonNegative(completionDetails.reasoning_tokens);
25214
26193
  const totalTokens = optionalNonNegative(value.total_tokens);
@@ -25231,7 +26210,7 @@ function nonNegativeOrZero(value) {
25231
26210
  function optionalNonNegative(value) {
25232
26211
  return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
25233
26212
  }
25234
- function isRecord5(value) {
26213
+ function isRecord7(value) {
25235
26214
  return typeof value === "object" && value !== null && !Array.isArray(value);
25236
26215
  }
25237
26216
  var OPENCODE_GO_RESPONSES_URL = "https://opencode.ai/zen/go/v1/responses";
@@ -25396,13 +26375,13 @@ function parseEventFrame2(frame) {
25396
26375
  );
25397
26376
  }
25398
26377
  logRawWireEvent("opencode-go-responses.wire.event", eventName, parsed);
25399
- if (isRecord6(parsed) && typeof parsed.type !== "string" && eventName !== void 0) {
26378
+ if (isRecord8(parsed) && typeof parsed.type !== "string" && eventName !== void 0) {
25400
26379
  parsed = { ...parsed, type: eventName };
25401
26380
  }
25402
26381
  return canonicalEvent2(parsed);
25403
26382
  }
25404
26383
  function canonicalEvent2(value) {
25405
- if (!isRecord6(value) || typeof value.type !== "string") {
26384
+ if (!isRecord8(value) || typeof value.type !== "string") {
25406
26385
  throw new UpstreamProtocolError("OpenCode Go SSE event was not an object with a type");
25407
26386
  }
25408
26387
  switch (value.type) {
@@ -25546,26 +26525,26 @@ var STRICT_ALLOWED_KEYWORDS2 = /* @__PURE__ */ new Set([
25546
26525
  "format"
25547
26526
  ]);
25548
26527
  function strictCompatible2(schema) {
25549
- if (!isRecord6(schema)) return true;
26528
+ if (!isRecord8(schema)) return true;
25550
26529
  for (const key of Object.keys(schema)) {
25551
26530
  if (!STRICT_ALLOWED_KEYWORDS2.has(key)) return false;
25552
26531
  }
25553
26532
  if (!("type" in schema) && !Array.isArray(schema.anyOf) && typeof schema.$ref !== "string") {
25554
26533
  return false;
25555
26534
  }
25556
- if (schema.type === "object" && !isRecord6(schema.properties)) return false;
25557
- if (schema.type === "array" && !isRecord6(schema.items)) return false;
25558
- if (isRecord6(schema.properties)) {
26535
+ if (schema.type === "object" && !isRecord8(schema.properties)) return false;
26536
+ if (schema.type === "array" && !isRecord8(schema.items)) return false;
26537
+ if (isRecord8(schema.properties)) {
25559
26538
  for (const value of Object.values(schema.properties)) {
25560
26539
  if (!strictCompatible2(value)) return false;
25561
26540
  }
25562
26541
  }
25563
- if (isRecord6(schema.$defs)) {
26542
+ if (isRecord8(schema.$defs)) {
25564
26543
  for (const value of Object.values(schema.$defs)) {
25565
26544
  if (!strictCompatible2(value)) return false;
25566
26545
  }
25567
26546
  }
25568
- if (isRecord6(schema.items) && !strictCompatible2(schema.items)) return false;
26547
+ if (isRecord8(schema.items) && !strictCompatible2(schema.items)) return false;
25569
26548
  if (Array.isArray(schema.anyOf)) {
25570
26549
  for (const branch of schema.anyOf) {
25571
26550
  if (!strictCompatible2(branch)) return false;
@@ -25575,10 +26554,10 @@ function strictCompatible2(schema) {
25575
26554
  }
25576
26555
  function strictParameters2(schema) {
25577
26556
  const converted = strictSchema2(schema);
25578
- return isRecord6(converted) ? converted : schema;
26557
+ return isRecord8(converted) ? converted : schema;
25579
26558
  }
25580
26559
  function strictSchema2(schema) {
25581
- if (!isRecord6(schema)) return schema;
26560
+ if (!isRecord8(schema)) return schema;
25582
26561
  const next = { ...schema };
25583
26562
  delete next.$schema;
25584
26563
  delete next.default;
@@ -25587,8 +26566,8 @@ function strictSchema2(schema) {
25587
26566
  const branches = next[key];
25588
26567
  if (Array.isArray(branches)) next[key] = branches.map(strictSchema2);
25589
26568
  }
25590
- if (isRecord6(next.items)) next.items = strictSchema2(next.items);
25591
- if (isRecord6(next.$defs)) {
26569
+ if (isRecord8(next.items)) next.items = strictSchema2(next.items);
26570
+ if (isRecord8(next.$defs)) {
25592
26571
  const rewrittenDefs = {};
25593
26572
  for (const [name, value] of Object.entries(next.$defs)) {
25594
26573
  rewrittenDefs[name] = strictSchema2(value);
@@ -25596,7 +26575,7 @@ function strictSchema2(schema) {
25596
26575
  next.$defs = rewrittenDefs;
25597
26576
  }
25598
26577
  const properties = next.properties;
25599
- if (isRecord6(properties)) {
26578
+ if (isRecord8(properties)) {
25600
26579
  const required2 = new Set(
25601
26580
  Array.isArray(next.required) ? next.required.filter((name) => typeof name === "string") : []
25602
26581
  );
@@ -25612,7 +26591,7 @@ function strictSchema2(schema) {
25612
26591
  return next;
25613
26592
  }
25614
26593
  function nullableSchema2(schema) {
25615
- if (!isRecord6(schema)) return schema;
26594
+ if (!isRecord8(schema)) return schema;
25616
26595
  const next = { ...schema };
25617
26596
  if (Array.isArray(next.enum) && !next.enum.includes(null)) {
25618
26597
  next.enum = [...next.enum, null];
@@ -25637,7 +26616,7 @@ function stripNullArguments2(raw) {
25637
26616
  } catch {
25638
26617
  return raw;
25639
26618
  }
25640
- if (!isRecord6(parsed)) return raw;
26619
+ if (!isRecord8(parsed)) return raw;
25641
26620
  return JSON.stringify(withoutNulls2(parsed));
25642
26621
  }
25643
26622
  function withoutNulls2(value) {
@@ -25649,7 +26628,7 @@ function withoutNulls2(value) {
25649
26628
  return out;
25650
26629
  }
25651
26630
  function withoutNullMembers2(entry) {
25652
- if (isRecord6(entry)) return withoutNulls2(entry);
26631
+ if (isRecord8(entry)) return withoutNulls2(entry);
25653
26632
  if (Array.isArray(entry)) return entry.map(withoutNullMembers2);
25654
26633
  return entry;
25655
26634
  }
@@ -25689,7 +26668,7 @@ function outputItem2(value) {
25689
26668
  return void 0;
25690
26669
  }
25691
26670
  function webSearchAction2(value) {
25692
- if (!isRecord6(value) || typeof value.type !== "string") {
26671
+ if (!isRecord8(value) || typeof value.type !== "string") {
25693
26672
  return void 0;
25694
26673
  }
25695
26674
  const action = { type: value.type };
@@ -25720,7 +26699,7 @@ function webSearchSources2(value) {
25720
26699
  }
25721
26700
  const sources = [];
25722
26701
  for (const entry of value) {
25723
- if (!isRecord6(entry) || typeof entry.url !== "string" || entry.url.length === 0) {
26702
+ if (!isRecord8(entry) || typeof entry.url !== "string" || entry.url.length === 0) {
25724
26703
  continue;
25725
26704
  }
25726
26705
  const source = {
@@ -25740,11 +26719,11 @@ function canonicalError2(value) {
25740
26719
  const type = typeof error51.type === "string" && error51.type !== "error" ? error51.type : typeof error51.code === "string" ? error51.code : "api_error";
25741
26720
  return { type, message };
25742
26721
  }
25743
- function isRecord6(value) {
26722
+ function isRecord8(value) {
25744
26723
  return typeof value === "object" && value !== null && !Array.isArray(value);
25745
26724
  }
25746
26725
  function record22(value, name) {
25747
- if (!isRecord6(value)) {
26726
+ if (!isRecord8(value)) {
25748
26727
  throw new UpstreamProtocolError(`${name} must be an object`);
25749
26728
  }
25750
26729
  return value;
@@ -25819,9 +26798,9 @@ var XAI_CLI_REFRESH_BUFFER_MS = 5 * 60 * 1e3;
25819
26798
  var REFRESH_TIMEOUT_MS = 15e3;
25820
26799
  var FALLBACK_ACCESS_TOKEN_TTL_MS = 36e5;
25821
26800
  function xaiCliAuthFilePath(deps) {
25822
- return path32__default.join(deps.env.GROK_HOME || path32__default.join(deps.homedir(), ".grok"), "auth.json");
26801
+ return path42__default.join(deps.env.GROK_HOME || path42__default.join(deps.homedir(), ".grok"), "auth.json");
25823
26802
  }
25824
- function expiry(value) {
26803
+ function expiry2(value) {
25825
26804
  if (typeof value !== "string" && typeof value !== "number") return void 0;
25826
26805
  const parsed = typeof value === "number" ? value : Date.parse(value);
25827
26806
  if (!Number.isFinite(parsed)) return void 0;
@@ -25841,7 +26820,7 @@ function jwtExpiry(token) {
25841
26820
  }
25842
26821
  }
25843
26822
  function effectiveExpiry(entry, accessToken) {
25844
- const fromEntry = expiry(entry.expires_at) ?? expiry(entry.expires);
26823
+ const fromEntry = expiry2(entry.expires_at) ?? expiry2(entry.expires);
25845
26824
  const fromJwt = jwtExpiry(accessToken);
25846
26825
  if (fromEntry !== void 0 && fromJwt !== void 0) return Math.min(fromEntry, fromJwt);
25847
26826
  return fromEntry ?? fromJwt;
@@ -25995,7 +26974,7 @@ var VERSION_PATTERN = /\b(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)\b/;
25995
26974
  var VERSION_EXEC_TIMEOUT_MS = 2e3;
25996
26975
  var MAX_VERSION_FILE_BYTES = 256;
25997
26976
  function grokHomeDir(deps) {
25998
- return optionalTrimmedString(deps.env.GROK_HOME) ?? path32__default.join(deps.homedir(), ".grok");
26977
+ return optionalTrimmedString(deps.env.GROK_HOME) ?? path42__default.join(deps.homedir(), ".grok");
25999
26978
  }
26000
26979
  function versionFrom(value) {
26001
26980
  if (typeof value !== "string") return void 0;
@@ -26003,20 +26982,20 @@ function versionFrom(value) {
26003
26982
  }
26004
26983
  async function fromInstallerSymlink(home, readLink) {
26005
26984
  try {
26006
- return versionFrom(path32__default.basename(await readLink(path32__default.join(home, "bin", "grok"))));
26985
+ return versionFrom(path42__default.basename(await readLink(path42__default.join(home, "bin", "grok"))));
26007
26986
  } catch {
26008
26987
  return void 0;
26009
26988
  }
26010
26989
  }
26011
26990
  async function fromMetadataMarker(home, deps) {
26012
26991
  try {
26013
- return versionFrom(await deps.readBounded(path32__default.join(home, ".metadata_version"), MAX_VERSION_FILE_BYTES));
26992
+ return versionFrom(await deps.readBounded(path42__default.join(home, ".metadata_version"), MAX_VERSION_FILE_BYTES));
26014
26993
  } catch {
26015
26994
  return void 0;
26016
26995
  }
26017
26996
  }
26018
26997
  function grokExecutablePath(home, deps) {
26019
- return path32__default.join(home, "bin", deps.platform === "win32" ? "grok.exe" : "grok");
26998
+ return path42__default.join(home, "bin", deps.platform === "win32" ? "grok.exe" : "grok");
26020
26999
  }
26021
27000
  async function fromCommand(deps, file2) {
26022
27001
  try {
@@ -26044,8 +27023,8 @@ function sanitizeXaiEndpoint(value) {
26044
27023
  return typeof value === "string" && XAI_ENDPOINT_PREFERENCES.includes(value) ? value : void 0;
26045
27024
  }
26046
27025
  function normalizeAiGatewaySettings(value) {
26047
- if (!isRecord7(value) || value.version !== 1) return { version: 1 };
26048
- const models = Array.isArray(value.models) ? value.models.filter((entry) => isRecord7(entry) && typeof entry.id === "string" && entry.id.length > 0).flatMap((entry) => {
27026
+ if (!isRecord9(value) || value.version !== 1) return { version: 1 };
27027
+ const models = Array.isArray(value.models) ? value.models.filter((entry) => isRecord9(entry) && typeof entry.id === "string" && entry.id.length > 0).flatMap((entry) => {
26049
27028
  const model = findGatewayModel(entry.id);
26050
27029
  if (!model) return [];
26051
27030
  const efforts = Array.isArray(entry.efforts) ? entry.efforts.filter((level) => typeof level === "string" && level.length > 0) : [];
@@ -26083,7 +27062,7 @@ function sanitizeProviderPriority(value) {
26083
27062
  }
26084
27063
  return cleaned.length > 0 ? cleaned : void 0;
26085
27064
  }
26086
- function isRecord7(value) {
27065
+ function isRecord9(value) {
26087
27066
  return typeof value === "object" && value !== null && !Array.isArray(value);
26088
27067
  }
26089
27068
  function resolveAiGatewaySelection(settings2) {
@@ -26866,7 +27845,7 @@ function parseEventFrame3(frame) {
26866
27845
  );
26867
27846
  }
26868
27847
  logRawWireEvent("xai-responses.wire.event", eventName, parsed);
26869
- if (isRecord8(parsed) && typeof parsed.type !== "string" && eventName !== void 0) {
27848
+ if (isRecord10(parsed) && typeof parsed.type !== "string" && eventName !== void 0) {
26870
27849
  parsed = { ...parsed, type: eventName };
26871
27850
  }
26872
27851
  return canonicalEvent3(parsed);
@@ -26876,7 +27855,7 @@ function withoutXaiSentinel(text2) {
26876
27855
  return text2.includes(XAI_EOS_SENTINEL) ? text2.split(XAI_EOS_SENTINEL).join("") : text2;
26877
27856
  }
26878
27857
  function canonicalEvent3(value) {
26879
- if (!isRecord8(value) || typeof value.type !== "string") {
27858
+ if (!isRecord10(value) || typeof value.type !== "string") {
26880
27859
  throw new UpstreamProtocolError("Grok CLI SSE event was not an object with a type");
26881
27860
  }
26882
27861
  switch (value.type) {
@@ -27044,11 +28023,11 @@ function xaiErrorType(error51, message) {
27044
28023
  if (typeof error51.code === "string") return error51.code;
27045
28024
  return XAI_CAPACITY_MESSAGE.test(message) ? XAI_OVERLOADED_ERROR_TYPE : "api_error";
27046
28025
  }
27047
- function isRecord8(value) {
28026
+ function isRecord10(value) {
27048
28027
  return typeof value === "object" && value !== null && !Array.isArray(value);
27049
28028
  }
27050
28029
  function record3(value, name) {
27051
- if (!isRecord8(value)) {
28030
+ if (!isRecord10(value)) {
27052
28031
  throw new UpstreamProtocolError(`${name} must be an object`);
27053
28032
  }
27054
28033
  return value;
@@ -27120,38 +28099,38 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
27120
28099
  "shell_command",
27121
28100
  "exec_command"
27122
28101
  ]);
27123
- if (isRecord9(exec2.readArgs)) {
28102
+ if (isRecord11(exec2.readArgs)) {
27124
28103
  return [execReply(exec2, "readResult", {
27125
28104
  error: { path: stringValue(exec2.readArgs.path), error: readMessage3 }
27126
28105
  })];
27127
28106
  }
27128
- if (isRecord9(exec2.writeArgs)) {
28107
+ if (isRecord11(exec2.writeArgs)) {
27129
28108
  return [execReply(exec2, "writeResult", {
27130
28109
  rejected: { path: stringValue(exec2.writeArgs.path), reason: mutationMessage }
27131
28110
  })];
27132
28111
  }
27133
- if (isRecord9(exec2.deleteArgs)) {
28112
+ if (isRecord11(exec2.deleteArgs)) {
27134
28113
  return [execReply(exec2, "deleteResult", {
27135
28114
  rejected: { path: stringValue(exec2.deleteArgs.path), reason: mutationMessage }
27136
28115
  })];
27137
28116
  }
27138
- if (isRecord9(exec2.lsArgs)) {
28117
+ if (isRecord11(exec2.lsArgs)) {
27139
28118
  return [execReply(exec2, "lsResult", {
27140
28119
  error: { path: stringValue(exec2.lsArgs.path), error: listMessage }
27141
28120
  })];
27142
28121
  }
27143
- if (isRecord9(exec2.grepArgs)) {
28122
+ if (isRecord11(exec2.grepArgs)) {
27144
28123
  return [execReply(exec2, "grepResult", { error: { error: grepMessage } })];
27145
28124
  }
27146
- if (isRecord9(exec2.shellArgs)) {
28125
+ if (isRecord11(exec2.shellArgs)) {
27147
28126
  return [execReply(exec2, "shellResult", shellFailure(exec2.shellArgs, shellMessage))];
27148
28127
  }
27149
- if (isRecord9(exec2.shellStreamArgs)) {
28128
+ if (isRecord11(exec2.shellStreamArgs)) {
27150
28129
  const args = exec2.shellStreamArgs;
27151
28130
  const cwd = stringValue(args.workingDirectory);
27152
28131
  return [
27153
28132
  execReply(exec2, "shellStream", {
27154
- start: isRecord9(args.requestedSandboxPolicy) ? { sandboxPolicy: args.requestedSandboxPolicy } : {}
28133
+ start: isRecord11(args.requestedSandboxPolicy) ? { sandboxPolicy: args.requestedSandboxPolicy } : {}
27155
28134
  }),
27156
28135
  execReply(exec2, "shellStream", { stderr: { data: shellMessage } }),
27157
28136
  execReply(exec2, "shellStream", { exit: { code: 1, cwd, aborted: true } }),
@@ -27159,7 +28138,7 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
27159
28138
  { execClientControlMessage: { streamClose: { id: numberValue(exec2.id) } } }
27160
28139
  ];
27161
28140
  }
27162
- if (isRecord9(exec2.backgroundShellSpawnArgs)) {
28141
+ if (isRecord11(exec2.backgroundShellSpawnArgs)) {
27163
28142
  const args = exec2.backgroundShellSpawnArgs;
27164
28143
  return [execReply(exec2, "backgroundShellSpawnResult", {
27165
28144
  error: {
@@ -27169,15 +28148,15 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
27169
28148
  }
27170
28149
  })];
27171
28150
  }
27172
- if (isRecord9(exec2.writeShellStdinArgs)) {
28151
+ if (isRecord11(exec2.writeShellStdinArgs)) {
27173
28152
  return [execReply(exec2, "writeShellStdinResult", { error: { error: shellMessage } })];
27174
28153
  }
27175
- if (isRecord9(exec2.fetchArgs)) {
28154
+ if (isRecord11(exec2.fetchArgs)) {
27176
28155
  return [execReply(exec2, "fetchResult", {
27177
28156
  error: { url: stringValue(exec2.fetchArgs.url), error: networkMessage }
27178
28157
  })];
27179
28158
  }
27180
- if (isRecord9(exec2.diagnosticsArgs)) {
28159
+ if (isRecord11(exec2.diagnosticsArgs)) {
27181
28160
  return [execReply(exec2, "diagnosticsResult", {
27182
28161
  error: {
27183
28162
  path: stringValue(exec2.diagnosticsArgs.path),
@@ -27185,12 +28164,12 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
27185
28164
  }
27186
28165
  })];
27187
28166
  }
27188
- if (isRecord9(exec2.listMcpResourcesExecArgs)) {
28167
+ if (isRecord11(exec2.listMcpResourcesExecArgs)) {
27189
28168
  return [execReply(exec2, "listMcpResourcesExecResult", {
27190
28169
  error: { error: retryMessage(clientTools, ["ListMcpResources", "list_mcp_resources"]) }
27191
28170
  })];
27192
28171
  }
27193
- if (isRecord9(exec2.readMcpResourceExecArgs)) {
28172
+ if (isRecord11(exec2.readMcpResourceExecArgs)) {
27194
28173
  return [execReply(exec2, "readMcpResourceExecResult", {
27195
28174
  error: {
27196
28175
  uri: stringValue(exec2.readMcpResourceExecArgs.uri),
@@ -27198,12 +28177,12 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
27198
28177
  }
27199
28178
  })];
27200
28179
  }
27201
- if (isRecord9(exec2.recordScreenArgs)) {
28180
+ if (isRecord11(exec2.recordScreenArgs)) {
27202
28181
  return [execReply(exec2, "recordScreenResult", {
27203
28182
  failure: { error: retryMessage(clientTools, ["record_screen", "computer_use"]) }
27204
28183
  })];
27205
28184
  }
27206
- if (isRecord9(exec2.computerUseArgs)) {
28185
+ if (isRecord11(exec2.computerUseArgs)) {
27207
28186
  return [execReply(exec2, "computerUseResult", {
27208
28187
  error: {
27209
28188
  error: retryMessage(clientTools, ["computer_use"]),
@@ -27213,7 +28192,7 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
27213
28192
  }
27214
28193
  })];
27215
28194
  }
27216
- if (isRecord9(exec2.mcpArgs)) {
28195
+ if (isRecord11(exec2.mcpArgs)) {
27217
28196
  return [execReply(exec2, "mcpResult", {
27218
28197
  error: { error: retryMessage(clientTools, []) }
27219
28198
  })];
@@ -27285,7 +28264,7 @@ function numberValue(value) {
27285
28264
  function stringValue(value) {
27286
28265
  return typeof value === "string" ? value : "";
27287
28266
  }
27288
- function isRecord9(value) {
28267
+ function isRecord11(value) {
27289
28268
  return typeof value === "object" && value !== null && !Array.isArray(value);
27290
28269
  }
27291
28270
  var EXECUTE_HOOK_FIELD_NUMBER = 27;
@@ -27441,14 +28420,14 @@ function isCursorWithheldToolName(name) {
27441
28420
  function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
27442
28421
  const messageId = numberValue2(exec2.id ?? 0);
27443
28422
  const execId = stringValue2(exec2.execId) || `redirect-${messageId}`;
27444
- if (isRecord10(exec2.readArgs)) {
27445
- const path82 = stringValue2(exec2.readArgs.path);
27446
- if (!path82) return null;
28423
+ if (isRecord12(exec2.readArgs)) {
28424
+ const path92 = stringValue2(exec2.readArgs.path);
28425
+ if (!path92) return null;
27447
28426
  if ([exec2.readArgs.offset, exec2.readArgs.limit].some((value) => typeof value === "number" && value < 0)) return null;
27448
- const offset = positiveNumber(exec2.readArgs.offset);
27449
- const limit = positiveNumber(exec2.readArgs.limit);
28427
+ const offset = positiveNumber2(exec2.readArgs.offset);
28428
+ const limit = positiveNumber2(exec2.readArgs.limit);
27450
28429
  if (offset !== void 0 || limit !== void 0) return null;
27451
- const mapped = tools.filter((tool) => matchesLeaf(tool, READ_CANDIDATES)).map((tool) => ({ tool, args: readArguments(tool.inputSchemaValue, path82) })).find((candidate) => candidate.args !== null);
28430
+ const mapped = tools.filter((tool) => matchesLeaf(tool, READ_CANDIDATES)).map((tool) => ({ tool, args: readArguments(tool.inputSchemaValue, path92) })).find((candidate) => candidate.args !== null);
27452
28431
  if (!mapped?.args) return null;
27453
28432
  return redirect(
27454
28433
  exec2,
@@ -27460,14 +28439,14 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
27460
28439
  "readResult",
27461
28440
  "read-direct",
27462
28441
  mapped.args,
27463
- { path: path82 }
28442
+ { path: path92 }
27464
28443
  );
27465
28444
  }
27466
- if (isRecord10(exec2.grepArgs)) {
28445
+ if (isRecord12(exec2.grepArgs)) {
27467
28446
  const grepArgs = exec2.grepArgs;
27468
28447
  const pattern = stringValue2(grepArgs.pattern);
27469
28448
  if (!pattern.trim()) return null;
27470
- const path82 = stringValue2(grepArgs.path) || ".";
28449
+ const path92 = stringValue2(grepArgs.path) || ".";
27471
28450
  const glob = stringValue2(grepArgs.glob);
27472
28451
  const outputMode = normalizedGrepOutputMode(stringValue2(grepArgs.outputMode));
27473
28452
  if (!outputMode) return null;
@@ -27483,27 +28462,27 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
27483
28462
  if (numericOptions.some((value) => typeof value === "number" && value < 0)) return null;
27484
28463
  const mappingInput = {
27485
28464
  pattern,
27486
- path: path82,
28465
+ path: path92,
27487
28466
  glob,
27488
28467
  outputMode,
27489
28468
  caseInsensitive: grepArgs.caseInsensitive === true,
27490
- contextBefore: positiveNumber(grepArgs.contextBefore),
27491
- contextAfter: positiveNumber(grepArgs.contextAfter),
27492
- context: positiveNumber(grepArgs.context),
28469
+ contextBefore: positiveNumber2(grepArgs.contextBefore),
28470
+ contextAfter: positiveNumber2(grepArgs.contextAfter),
28471
+ context: positiveNumber2(grepArgs.context),
27493
28472
  type: stringValue2(grepArgs.type) || void 0,
27494
- headLimit: positiveNumber(grepArgs.headLimit),
28473
+ headLimit: positiveNumber2(grepArgs.headLimit),
27495
28474
  multiline: grepArgs.multiline === true,
27496
28475
  sort,
27497
28476
  sortAscending: Object.prototype.hasOwnProperty.call(grepArgs, "sortAscending") ? grepArgs.sortAscending === true : void 0,
27498
- offset: positiveNumber(grepArgs.offset)
28477
+ offset: positiveNumber2(grepArgs.offset)
27499
28478
  };
27500
28479
  const mapped = tools.filter((tool) => matchesLeaf(tool, GREP_CANDIDATES)).map((tool) => ({ tool, args: grepArguments(tool, mappingInput) })).find((candidate) => candidate.args !== null);
27501
28480
  const nativeArgs = {
27502
28481
  pattern,
27503
- path: path82,
28482
+ path: path92,
27504
28483
  outputMode,
27505
28484
  ...glob ? { glob } : {},
27506
- ...positiveNumber(grepArgs.offset) === void 0 ? {} : { offset: String(positiveNumber(grepArgs.offset)) }
28485
+ ...positiveNumber2(grepArgs.offset) === void 0 ? {} : { offset: String(positiveNumber2(grepArgs.offset)) }
27507
28486
  };
27508
28487
  if (mapped?.args) {
27509
28488
  return redirect(
@@ -27537,15 +28516,15 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
27537
28516
  nativeArgs
27538
28517
  );
27539
28518
  }
27540
- if (isRecord10(exec2.shellArgs) || isRecord10(exec2.shellStreamArgs)) {
27541
- const argsRecord = isRecord10(exec2.shellArgs) ? exec2.shellArgs : exec2.shellStreamArgs;
28519
+ if (isRecord12(exec2.shellArgs) || isRecord12(exec2.shellStreamArgs)) {
28520
+ const argsRecord = isRecord12(exec2.shellArgs) ? exec2.shellArgs : exec2.shellStreamArgs;
27542
28521
  const command = stringValue2(argsRecord.command);
27543
28522
  if (!command) return null;
27544
28523
  const cwd = stringValue2(argsRecord.workingDirectory);
27545
- const timeout = positiveNumber(argsRecord.timeout) ?? positiveNumber(argsRecord.hardTimeout);
28524
+ const timeout = positiveNumber2(argsRecord.timeout) ?? positiveNumber2(argsRecord.hardTimeout);
27546
28525
  const mapped = tools.filter((tool) => matchesLeaf(tool, SHELL_CANDIDATES)).map((tool) => ({ tool, args: shellArguments(tool.inputSchemaValue, command, cwd || void 0, timeout) })).find((candidate) => candidate.args !== null);
27547
28526
  if (!mapped?.args) return null;
27548
- const stream = isRecord10(exec2.shellStreamArgs);
28527
+ const stream = isRecord12(exec2.shellStreamArgs);
27549
28528
  return redirect(
27550
28529
  exec2,
27551
28530
  mapped.tool,
@@ -27635,9 +28614,9 @@ function cursorNativeRedirectErrorReplies(correlation, error51) {
27635
28614
  }
27636
28615
  }
27637
28616
  }
27638
- function readArguments(schema, path82) {
28617
+ function readArguments(schema, path92) {
27639
28618
  const pathKey = firstSchemaProperty(schema, ["file_path", "path"]);
27640
- return pathKey ? { [pathKey]: path82 } : null;
28619
+ return pathKey ? { [pathKey]: path92 } : null;
27641
28620
  }
27642
28621
  function grepArguments(tool, input) {
27643
28622
  const leaf = normalizedLeaf(tool.clientName);
@@ -27804,7 +28783,7 @@ function parseGrepShellReceipt(output, expectedOutputMode) {
27804
28783
  const decoded = JSON.parse(inflateRawSync(compressed, {
27805
28784
  maxOutputLength: CURSOR_GREP_RECEIPT_MAX_BYTES
27806
28785
  }).toString("utf8"));
27807
- if (!isRecord10(decoded)) throw new Error("receipt is not an object");
28786
+ if (!isRecord12(decoded)) throw new Error("receipt is not an object");
27808
28787
  if (decoded.ok === false && typeof decoded.error === "string") {
27809
28788
  return { ok: false, error: decoded.error };
27810
28789
  }
@@ -27817,7 +28796,7 @@ function parseGrepShellReceipt(output, expectedOutputMode) {
27817
28796
  if (!Array.isArray(decoded.counts) || !decoded.counts.every((entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && typeof entry[1] === "number" && Number.isSafeInteger(entry[1]) && entry[1] >= 0)) {
27818
28797
  throw new Error("receipt counts are invalid");
27819
28798
  }
27820
- if (!Array.isArray(decoded.matches) || !decoded.matches.every((entry) => isRecord10(entry) && typeof entry.file === "string" && typeof entry.lineNumber === "number" && Number.isSafeInteger(entry.lineNumber) && entry.lineNumber > 0 && typeof entry.content === "string" && typeof entry.contentTruncated === "boolean" && typeof entry.isContextLine === "boolean")) {
28799
+ if (!Array.isArray(decoded.matches) || !decoded.matches.every((entry) => isRecord12(entry) && typeof entry.file === "string" && typeof entry.lineNumber === "number" && Number.isSafeInteger(entry.lineNumber) && entry.lineNumber > 0 && typeof entry.content === "string" && typeof entry.contentTruncated === "boolean" && typeof entry.isContextLine === "boolean")) {
27821
28800
  throw new Error("receipt matches are invalid");
27822
28801
  }
27823
28802
  for (const key of ["totalFiles", "totalLines", "totalMatchedLines"]) {
@@ -27835,7 +28814,7 @@ function parseGrepShellReceipt(output, expectedOutputMode) {
27835
28814
  }
27836
28815
  }
27837
28816
  function buildGrepReceiptSuccess(args, receipt) {
27838
- const path82 = args.path || ".";
28817
+ const path92 = args.path || ".";
27839
28818
  let result;
27840
28819
  if (receipt.outputMode === "files_with_matches") {
27841
28820
  result = {
@@ -27881,15 +28860,15 @@ function buildGrepReceiptSuccess(args, receipt) {
27881
28860
  }
27882
28861
  return {
27883
28862
  pattern: args.pattern ?? "",
27884
- path: path82,
28863
+ path: path92,
27885
28864
  outputMode: receipt.outputMode,
27886
- workspaceResults: { [path82]: result }
28865
+ workspaceResults: { [path92]: result }
27887
28866
  };
27888
28867
  }
27889
28868
  function buildGrepSuccess(args, output) {
27890
28869
  const outputMode = normalizedGrepOutputMode(args.outputMode) ?? "content";
27891
28870
  const lines = output.split(/\r?\n/).map((line) => line.trimEnd()).filter((line) => line.length > 0 && !line.startsWith("[") && !/^no matches/i.test(line));
27892
- const path82 = args.path || ".";
28871
+ const path92 = args.path || ".";
27893
28872
  let result;
27894
28873
  if (outputMode === "files_with_matches") {
27895
28874
  result = {
@@ -27952,9 +28931,9 @@ function buildGrepSuccess(args, output) {
27952
28931
  }
27953
28932
  return {
27954
28933
  pattern: args.pattern ?? "",
27955
- path: path82,
28934
+ path: path92,
27956
28935
  outputMode,
27957
- workspaceResults: { [path82]: result }
28936
+ workspaceResults: { [path92]: result }
27958
28937
  };
27959
28938
  }
27960
28939
  function parseCallerShellOutput(output, isError) {
@@ -28016,7 +28995,7 @@ function redirect(exec2, tool, providerIdentifier, messageId, execId, execCase,
28016
28995
  }
28017
28996
  function execArgsToolCallId(exec2) {
28018
28997
  for (const value of Object.values(exec2)) {
28019
- if (!isRecord10(value)) continue;
28998
+ if (!isRecord12(value)) continue;
28020
28999
  const toolCallId = stringValue2(value.toolCallId);
28021
29000
  if (toolCallId) return toolCallId;
28022
29001
  }
@@ -28037,7 +29016,7 @@ function firstSchemaProperty(schema, candidates) {
28037
29016
  return candidates.find((candidate) => schemaHasProperty(schema, candidate));
28038
29017
  }
28039
29018
  function schemaHasProperty(schema, name) {
28040
- return isRecord10(schema.properties) && Object.prototype.hasOwnProperty.call(schema.properties, name);
29019
+ return isRecord12(schema.properties) && Object.prototype.hasOwnProperty.call(schema.properties, name);
28041
29020
  }
28042
29021
  function execReply2(exec2, resultName, result) {
28043
29022
  return {
@@ -28057,14 +29036,14 @@ function numberValue2(value) {
28057
29036
  function numberOrUndefined(value) {
28058
29037
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
28059
29038
  }
28060
- function positiveNumber(value) {
29039
+ function positiveNumber2(value) {
28061
29040
  const number42 = numberOrUndefined(value);
28062
29041
  return number42 !== void 0 && number42 > 0 ? number42 : void 0;
28063
29042
  }
28064
29043
  function stringValue2(value) {
28065
29044
  return typeof value === "string" ? value : "";
28066
29045
  }
28067
- function isRecord10(value) {
29046
+ function isRecord12(value) {
28068
29047
  return typeof value === "object" && value !== null && !Array.isArray(value);
28069
29048
  }
28070
29049
  var cursorAgentDescriptor = [
@@ -28895,18 +29874,18 @@ function decodeCursorServerMessage(payload) {
28895
29874
  const message = fromBinary(AgentServerMessageSchema, payload);
28896
29875
  const unknownExecFields = extractCursorUnknownExecFields(message);
28897
29876
  const json2 = toJson(AgentServerMessageSchema, message);
28898
- if (!isRecord11(json2)) throw new TypeError("Cursor server frame was not a message object");
29877
+ if (!isRecord13(json2)) throw new TypeError("Cursor server frame was not a message object");
28899
29878
  if (unknownExecFields.length > 0) {
28900
29879
  Object.defineProperty(json2, CURSOR_UNKNOWN_EXEC_FIELDS, { value: unknownExecFields });
28901
29880
  }
28902
29881
  return json2;
28903
29882
  }
28904
29883
  function extractCursorUnknownExecFields(message) {
28905
- if (!isRecord11(message) || !isRecord11(message.message)) return [];
28906
- if (message.message.case !== "execServerMessage" || !isRecord11(message.message.value)) return [];
29884
+ if (!isRecord13(message) || !isRecord13(message.message)) return [];
29885
+ if (message.message.case !== "execServerMessage" || !isRecord13(message.message.value)) return [];
28907
29886
  const fields = message.message.value.$unknown;
28908
29887
  if (!Array.isArray(fields)) return [];
28909
- return fields.filter((field) => isRecord11(field) && typeof field.no === "number" && typeof field.wireType === "number" && field.data instanceof Uint8Array);
29888
+ return fields.filter((field) => isRecord13(field) && typeof field.no === "number" && typeof field.wireType === "number" && field.data instanceof Uint8Array);
28910
29889
  }
28911
29890
  function parseConnectEndStreamError(payload) {
28912
29891
  try {
@@ -29228,7 +30207,7 @@ function cursorToolArgumentBytes(argumentsText) {
29228
30207
  } catch {
29229
30208
  return {};
29230
30209
  }
29231
- if (!isRecord11(parsed)) return {};
30210
+ if (!isRecord13(parsed)) return {};
29232
30211
  return Object.fromEntries(Object.entries(parsed).map(([name, value]) => [
29233
30212
  name,
29234
30213
  Buffer.from(toBinary(ValueSchema, fromJson(ValueSchema, value))).toString("base64")
@@ -30513,7 +31492,7 @@ ${argumentsText}`;
30513
31492
  const handleFrame = (frame, replayed = false) => {
30514
31493
  const unknownExecFields = frame[CURSOR_UNKNOWN_EXEC_FIELDS] ?? [];
30515
31494
  lastFrame = describeCursorServerFrame(frame, unknownExecFields);
30516
- const tokenDetails = isRecord11(frame.conversationCheckpointUpdate) && isRecord11(frame.conversationCheckpointUpdate.tokenDetails) ? frame.conversationCheckpointUpdate.tokenDetails : void 0;
31495
+ const tokenDetails = isRecord13(frame.conversationCheckpointUpdate) && isRecord13(frame.conversationCheckpointUpdate.tokenDetails) ? frame.conversationCheckpointUpdate.tokenDetails : void 0;
30517
31496
  const checkpointContextTokens = positiveTokenCount(tokenDetails?.usedTokens);
30518
31497
  const checkpointContextWindow = positiveTokenCount(tokenDetails?.maxTokens);
30519
31498
  if (!replayed) {
@@ -30526,7 +31505,7 @@ ${argumentsText}`;
30526
31505
  ...checkpointContextWindow === void 0 ? {} : { contextWindow: checkpointContextWindow }
30527
31506
  });
30528
31507
  }
30529
- if (isRecord11(frame.conversationCheckpointUpdate)) {
31508
+ if (isRecord13(frame.conversationCheckpointUpdate)) {
30530
31509
  if (checkpointContextTokens !== void 0) {
30531
31510
  wireLog("cursor.wire.checkpoint", {
30532
31511
  model: diagnosticModel,
@@ -30549,7 +31528,7 @@ ${argumentsText}`;
30549
31528
  }
30550
31529
  return;
30551
31530
  }
30552
- if (isRecord11(frame.kvServerMessage)) {
31531
+ if (isRecord13(frame.kvServerMessage)) {
30553
31532
  const kv = kvReply(frame.kvServerMessage, blobs);
30554
31533
  stream.write(encodeCursorClientMessage(kv.message));
30555
31534
  if (kv.fetch) {
@@ -30570,7 +31549,7 @@ ${argumentsText}`;
30570
31549
  });
30571
31550
  return;
30572
31551
  }
30573
- if (isRecord11(frame.interactionQuery)) {
31552
+ if (isRecord13(frame.interactionQuery)) {
30574
31553
  const reply = cursorInteractionQueryReply(frame.interactionQuery);
30575
31554
  stream.write(encodeCursorClientMessage(reply.message));
30576
31555
  report("client.reply", { model: diagnosticModel, reply: reply.replyKind });
@@ -30586,7 +31565,7 @@ ${argumentsText}`;
30586
31565
  }
30587
31566
  return;
30588
31567
  }
30589
- if (isRecord11(frame.error)) {
31568
+ if (isRecord13(frame.error)) {
30590
31569
  if (state === "attached") {
30591
31570
  emit({ type: "error", error: cursorError(frame.error) });
30592
31571
  completeRun("server_error");
@@ -30615,8 +31594,8 @@ ${argumentsText}`;
30615
31594
  return;
30616
31595
  }
30617
31596
  if (state !== "attached") return;
30618
- if (isRecord11(frame.execServerMessage)) {
30619
- if (isRecord11(frame.execServerMessage.requestContextArgs)) {
31597
+ if (isRecord13(frame.execServerMessage)) {
31598
+ if (isRecord13(frame.execServerMessage.requestContextArgs)) {
30620
31599
  stream.write(encodeCursorClientMessage(cursorRequestContextReply(frame.execServerMessage, tools)));
30621
31600
  report("client.reply", { model: diagnosticModel, reply: "exec.requestContext" });
30622
31601
  return;
@@ -30705,10 +31684,10 @@ ${argumentsText}`;
30705
31684
  }
30706
31685
  return;
30707
31686
  }
30708
- const update = isRecord11(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
31687
+ const update = isRecord13(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
30709
31688
  if (update === void 0) return;
30710
31689
  if (isSettledToolUpdate(update)) return;
30711
- if (isRecord11(update.textDelta) && typeof update.textDelta.text === "string") {
31690
+ if (isRecord13(update.textDelta) && typeof update.textDelta.text === "string") {
30712
31691
  activeSegment.outputText += update.textDelta.text;
30713
31692
  emit({
30714
31693
  type: "response.output_text.delta",
@@ -30719,7 +31698,7 @@ ${argumentsText}`;
30719
31698
  });
30720
31699
  return;
30721
31700
  }
30722
- if (isRecord11(update.thinkingDelta) && typeof update.thinkingDelta.text === "string") {
31701
+ if (isRecord13(update.thinkingDelta) && typeof update.thinkingDelta.text === "string") {
30723
31702
  activeSegment.outputText += update.thinkingDelta.text;
30724
31703
  emit({
30725
31704
  type: "response.reasoning_summary_text.delta",
@@ -30729,12 +31708,12 @@ ${argumentsText}`;
30729
31708
  });
30730
31709
  return;
30731
31710
  }
30732
- if (isRecord11(update.tokenDelta)) {
31711
+ if (isRecord13(update.tokenDelta)) {
30733
31712
  const tokens = positiveTokenCount(update.tokenDelta.tokens);
30734
31713
  if (tokens !== void 0) activeSegment.contextOutputTokens += tokens;
30735
31714
  return;
30736
31715
  }
30737
- if (isRecord11(update.toolCallStarted)) {
31716
+ if (isRecord13(update.toolCallStarted)) {
30738
31717
  const wireCall = mcpCallFromToolUpdate(update.toolCallStarted);
30739
31718
  const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
30740
31719
  if (call) {
@@ -30744,7 +31723,7 @@ ${argumentsText}`;
30744
31723
  }
30745
31724
  return;
30746
31725
  }
30747
- if (isRecord11(update.partialToolCall)) {
31726
+ if (isRecord13(update.partialToolCall)) {
30748
31727
  const wireCall = mcpCallFromToolUpdate(update.partialToolCall);
30749
31728
  const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
30750
31729
  if (!call) return;
@@ -30755,7 +31734,7 @@ ${argumentsText}`;
30755
31734
  rescheduleToolTurnFinish();
30756
31735
  return;
30757
31736
  }
30758
- if (isRecord11(update.toolCallCompleted)) {
31737
+ if (isRecord13(update.toolCallCompleted)) {
30759
31738
  const wireCall = mcpCallFromToolUpdate(update.toolCallCompleted);
30760
31739
  const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
30761
31740
  if (!call) return;
@@ -30768,7 +31747,7 @@ ${argumentsText}`;
30768
31747
  rescheduleToolTurnFinish();
30769
31748
  return;
30770
31749
  }
30771
- if (isRecord11(update.turnEnded)) completeRun("turn_ended");
31750
+ if (isRecord13(update.turnEnded)) completeRun("turn_ended");
30772
31751
  };
30773
31752
  const eventsFor = (segment) => (async function* () {
30774
31753
  try {
@@ -30979,34 +31958,34 @@ var CURSOR_INTERACTION_QUERY_CASES = [
30979
31958
  ];
30980
31959
  var CURSOR_KV_CASES = ["getBlobArgs", "setBlobArgs"];
30981
31960
  function describeCursorServerFrame(frame, unknownExecFields = []) {
30982
- if (isRecord11(frame.interactionUpdate)) {
31961
+ if (isRecord13(frame.interactionUpdate)) {
30983
31962
  return `interactionUpdate.${cursorNestedRecordCase(
30984
31963
  frame.interactionUpdate,
30985
31964
  CURSOR_INTERACTION_UPDATE_CASES
30986
31965
  )}`;
30987
31966
  }
30988
- if (isRecord11(frame.execServerMessage)) {
31967
+ if (isRecord13(frame.execServerMessage)) {
30989
31968
  const knownCase = cursorNestedRecordCase(frame.execServerMessage, CURSOR_EXEC_CASES);
30990
31969
  return `execServerMessage.${knownCase === "unknown" ? cursorUnknownExecCaseName(unknownExecFields) : knownCase}`;
30991
31970
  }
30992
- if (isRecord11(frame.interactionQuery)) {
31971
+ if (isRecord13(frame.interactionQuery)) {
30993
31972
  return `interactionQuery.${cursorNestedRecordCase(
30994
31973
  frame.interactionQuery,
30995
31974
  CURSOR_INTERACTION_QUERY_CASES
30996
31975
  )}`;
30997
31976
  }
30998
- if (isRecord11(frame.kvServerMessage)) {
31977
+ if (isRecord13(frame.kvServerMessage)) {
30999
31978
  return `kvServerMessage.${cursorNestedRecordCase(frame.kvServerMessage, CURSOR_KV_CASES)}`;
31000
31979
  }
31001
- if (isRecord11(frame.conversationCheckpointUpdate)) return "conversationCheckpointUpdate";
31002
- if (isRecord11(frame.error)) return "error";
31980
+ if (isRecord13(frame.conversationCheckpointUpdate)) return "conversationCheckpointUpdate";
31981
+ if (isRecord13(frame.error)) return "error";
31003
31982
  return "unknown";
31004
31983
  }
31005
31984
  function isCursorHeartbeatFrame(frame) {
31006
- return isRecord11(frame.interactionUpdate) && isRecord11(frame.interactionUpdate.heartbeat);
31985
+ return isRecord13(frame.interactionUpdate) && isRecord13(frame.interactionUpdate.heartbeat);
31007
31986
  }
31008
31987
  function cursorNestedRecordCase(value, cases) {
31009
- return cases.find((candidate) => isRecord11(value[candidate])) ?? "unknown";
31988
+ return cases.find((candidate) => isRecord13(value[candidate])) ?? "unknown";
31010
31989
  }
31011
31990
  function positiveTokenCount(value) {
31012
31991
  if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) return void 0;
@@ -31018,8 +31997,8 @@ function cursorInteractionQueryReply(query) {
31018
31997
  const response = (result = {}) => ({
31019
31998
  interactionResponse: { id, ...result }
31020
31999
  });
31021
- if (isRecord11(query.createPlanRequestQuery)) {
31022
- const args = isRecord11(query.createPlanRequestQuery.args) ? query.createPlanRequestQuery.args : void 0;
32000
+ if (isRecord13(query.createPlanRequestQuery)) {
32001
+ const args = isRecord13(query.createPlanRequestQuery.args) ? query.createPlanRequestQuery.args : void 0;
31023
32002
  const name = stringValue3(args?.name)?.trim();
31024
32003
  const overview = stringValue3(args?.overview)?.trim();
31025
32004
  const plan = stringValue3(args?.plan)?.trim();
@@ -31035,7 +32014,7 @@ function cursorInteractionQueryReply(query) {
31035
32014
  ` } : {}
31036
32015
  };
31037
32016
  }
31038
- if (isRecord11(query.askQuestionInteractionQuery)) {
32017
+ if (isRecord13(query.askQuestionInteractionQuery)) {
31039
32018
  return {
31040
32019
  message: response({
31041
32020
  askQuestionInteractionResponse: {
@@ -31045,7 +32024,7 @@ function cursorInteractionQueryReply(query) {
31045
32024
  replyKind: "interaction.askQuestion.rejected"
31046
32025
  };
31047
32026
  }
31048
- if (isRecord11(query.switchModeRequestQuery)) {
32027
+ if (isRecord13(query.switchModeRequestQuery)) {
31049
32028
  return {
31050
32029
  message: response({
31051
32030
  switchModeRequestResponse: {
@@ -31055,19 +32034,19 @@ function cursorInteractionQueryReply(query) {
31055
32034
  replyKind: "interaction.switchMode.rejected"
31056
32035
  };
31057
32036
  }
31058
- if (isRecord11(query.webSearchRequestQuery)) {
32037
+ if (isRecord13(query.webSearchRequestQuery)) {
31059
32038
  return {
31060
32039
  message: response({ webSearchRequestResponse: { approved: {} } }),
31061
32040
  replyKind: "interaction.webSearch.approved"
31062
32041
  };
31063
32042
  }
31064
- if (isRecord11(query.exaSearchRequestQuery)) {
32043
+ if (isRecord13(query.exaSearchRequestQuery)) {
31065
32044
  return {
31066
32045
  message: response({ exaSearchRequestResponse: { approved: {} } }),
31067
32046
  replyKind: "interaction.exaSearch.approved"
31068
32047
  };
31069
32048
  }
31070
- if (isRecord11(query.exaFetchRequestQuery)) {
32049
+ if (isRecord13(query.exaFetchRequestQuery)) {
31071
32050
  return {
31072
32051
  message: response({ exaFetchRequestResponse: { approved: {} } }),
31073
32052
  replyKind: "interaction.exaFetch.approved"
@@ -31077,7 +32056,7 @@ function cursorInteractionQueryReply(query) {
31077
32056
  }
31078
32057
  function kvReply(kv, blobs) {
31079
32058
  const id = kv.id ?? 0;
31080
- if (isRecord11(kv.getBlobArgs)) {
32059
+ if (isRecord13(kv.getBlobArgs)) {
31081
32060
  const blobId = typeof kv.getBlobArgs.blobId === "string" ? kv.getBlobArgs.blobId : "";
31082
32061
  const blobData = blobs.get(blobId);
31083
32062
  return {
@@ -31089,7 +32068,7 @@ function kvReply(kv, blobs) {
31089
32068
  }
31090
32069
  };
31091
32070
  }
31092
- if (isRecord11(kv.setBlobArgs)) {
32071
+ if (isRecord13(kv.setBlobArgs)) {
31093
32072
  const blobId = typeof kv.setBlobArgs.blobId === "string" ? kv.setBlobArgs.blobId : "";
31094
32073
  const blobData = typeof kv.setBlobArgs.blobData === "string" ? kv.setBlobArgs.blobData : "";
31095
32074
  if (blobId) blobs.set(blobId, blobData);
@@ -31140,7 +32119,7 @@ function repairCursorArgumentValue(value, schema) {
31140
32119
  return { value: String(value), count: 1 };
31141
32120
  }
31142
32121
  if (Array.isArray(value)) {
31143
- const itemSchema = isRecord11(schema) ? schema.items : void 0;
32122
+ const itemSchema = isRecord13(schema) ? schema.items : void 0;
31144
32123
  if (itemSchema === void 0) return { value, count: 0 };
31145
32124
  let repairedValues;
31146
32125
  let count2 = 0;
@@ -31153,7 +32132,7 @@ function repairCursorArgumentValue(value, schema) {
31153
32132
  });
31154
32133
  return { value: repairedValues ?? value, count: count2 };
31155
32134
  }
31156
- if (!isRecord11(value) || !isRecord11(schema) || !isRecord11(schema.properties)) {
32135
+ if (!isRecord13(value) || !isRecord13(schema) || !isRecord13(schema.properties)) {
31157
32136
  return { value, count: 0 };
31158
32137
  }
31159
32138
  let repairedValue;
@@ -31169,12 +32148,12 @@ function repairCursorArgumentValue(value, schema) {
31169
32148
  return { value: repairedValue ?? value, count };
31170
32149
  }
31171
32150
  function cursorSchemaRequiresString(schema) {
31172
- if (!isRecord11(schema)) return false;
32151
+ if (!isRecord13(schema)) return false;
31173
32152
  if (schema.type === "string") return true;
31174
32153
  return Array.isArray(schema.type) && schema.type.includes("string") && schema.type.every((type) => type === "string" || type === "null");
31175
32154
  }
31176
32155
  function mcpCallFromToolUpdate(value) {
31177
- const toolCall = isRecord11(value.toolCall) ? value.toolCall : void 0;
32156
+ const toolCall = isRecord13(value.toolCall) ? value.toolCall : void 0;
31178
32157
  const args = toolCall ? mcpArgsFromToolCall(toolCall) : void 0;
31179
32158
  if (!args) return null;
31180
32159
  const publicCallId = stringValue3(value.callId);
@@ -31199,7 +32178,7 @@ var CURSOR_TOOL_UPDATE_CASES = [
31199
32178
  function cursorToolUpdateIdentifiers(update) {
31200
32179
  for (const key of CURSOR_TOOL_UPDATE_CASES) {
31201
32180
  const value = update[key];
31202
- if (!isRecord11(value)) continue;
32181
+ if (!isRecord13(value)) continue;
31203
32182
  const call = mcpCallFromToolUpdate(value);
31204
32183
  if (!call) return [];
31205
32184
  return [...new Set(
@@ -31209,9 +32188,9 @@ function cursorToolUpdateIdentifiers(update) {
31209
32188
  return void 0;
31210
32189
  }
31211
32190
  function isCursorClientToolFrame(frame, tools, redirectTools) {
31212
- const update = isRecord11(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
32191
+ const update = isRecord13(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
31213
32192
  if (update !== void 0) return cursorToolUpdateIdentifiers(update) !== void 0;
31214
- const exec2 = isRecord11(frame.execServerMessage) ? frame.execServerMessage : void 0;
32193
+ const exec2 = isRecord13(frame.execServerMessage) ? frame.execServerMessage : void 0;
31215
32194
  if (exec2 === void 0) return false;
31216
32195
  const wireCall = mcpCallFromExecMessage(exec2);
31217
32196
  const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
@@ -31227,16 +32206,16 @@ function isCursorClientToolFrame(frame, tools, redirectTools) {
31227
32206
  ) !== null;
31228
32207
  }
31229
32208
  function isCursorParkedResidueFrame(frame, parked) {
31230
- const update = isRecord11(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
32209
+ const update = isRecord13(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
31231
32210
  if (update === void 0) return false;
31232
- if (isRecord11(update.tokenDelta)) return true;
32211
+ if (isRecord13(update.tokenDelta)) return true;
31233
32212
  const identifiers = cursorToolUpdateIdentifiers(update);
31234
32213
  if (identifiers === void 0 || identifiers.length === 0 || parked === void 0) return false;
31235
32214
  const sealed = new Set(parked.flatMap((call) => [call.callId, call.toolCallId]));
31236
32215
  return identifiers.some((identifier) => sealed.has(identifier));
31237
32216
  }
31238
32217
  function mcpCallFromExecMessage(value) {
31239
- const args = isRecord11(value.mcpArgs) ? value.mcpArgs : void 0;
32218
+ const args = isRecord13(value.mcpArgs) ? value.mcpArgs : void 0;
31240
32219
  if (!args) return null;
31241
32220
  const toolCallId = stringValue3(args.toolCallId);
31242
32221
  if (!toolCallId) return null;
@@ -31254,14 +32233,14 @@ function mcpCallFromExecMessage(value) {
31254
32233
  };
31255
32234
  }
31256
32235
  function mcpArgsFromToolCall(toolCall) {
31257
- const direct = isRecord11(toolCall.mcpToolCall) ? toolCall.mcpToolCall : void 0;
31258
- if (direct && isRecord11(direct.args)) return direct.args;
31259
- const tool = isRecord11(toolCall.tool) ? toolCall.tool : void 0;
31260
- const nested = tool && isRecord11(tool.mcpToolCall) ? tool.mcpToolCall : void 0;
31261
- return nested && isRecord11(nested.args) ? nested.args : void 0;
32236
+ const direct = isRecord13(toolCall.mcpToolCall) ? toolCall.mcpToolCall : void 0;
32237
+ if (direct && isRecord13(direct.args)) return direct.args;
32238
+ const tool = isRecord13(toolCall.tool) ? toolCall.tool : void 0;
32239
+ const nested = tool && isRecord13(tool.mcpToolCall) ? tool.mcpToolCall : void 0;
32240
+ return nested && isRecord13(nested.args) ? nested.args : void 0;
31262
32241
  }
31263
32242
  function cursorMcpArguments(args) {
31264
- if (!isRecord11(args.args) || Object.keys(args.args).length === 0) return {};
32243
+ if (!isRecord13(args.args) || Object.keys(args.args).length === 0) return {};
31265
32244
  const decoded = {};
31266
32245
  for (const [name, value] of Object.entries(args.args)) {
31267
32246
  if (typeof value !== "string") {
@@ -31336,7 +32315,7 @@ function cursorError(value) {
31336
32315
  message: typeof value.message === "string" ? value.message : "Cursor request failed"
31337
32316
  };
31338
32317
  }
31339
- function isRecord11(value) {
32318
+ function isRecord13(value) {
31340
32319
  return typeof value === "object" && value !== null && !Array.isArray(value);
31341
32320
  }
31342
32321
  var DEFAULT_CURSOR_DIAGNOSTIC_MAX_BYTES = 4 * 1024 * 1024;
@@ -31370,7 +32349,7 @@ var CURSOR_DIAGNOSTIC_EVENTS = /* @__PURE__ */ new Set([
31370
32349
  "turn.finish"
31371
32350
  ]);
31372
32351
  function createCursorDiagnosticLog(dir, options = {}) {
31373
- const logPath = path32__default.join(dir, CURSOR_DIAGNOSTIC_FILE);
32352
+ const logPath = path42__default.join(dir, CURSOR_DIAGNOSTIC_FILE);
31374
32353
  const backupPath = `${logPath}.1`;
31375
32354
  const maxBytes = positiveInteger2(options.maxBytes) ?? DEFAULT_CURSOR_DIAGNOSTIC_MAX_BYTES;
31376
32355
  let initialized = false;
@@ -31751,27 +32730,32 @@ function createFailureJournal(options) {
31751
32730
  flush: () => chain
31752
32731
  };
31753
32732
  }
32733
+ var antigravityRequestPolicy = {
32734
+ provider: "antigravity",
32735
+ shapeRequest: (request, steps) => steps.stripClientIdentity(steps.withholdWebSearchTools(steps.pruneSkillPayloads(request)))
32736
+ };
31754
32737
  var codexRequestPolicy = {
31755
32738
  provider: "codex",
31756
- shapeRequest: (request, steps) => steps.withholdWebSearchTools(steps.pruneSkillPayloads(request))
32739
+ shapeRequest: (request, steps) => steps.stripClientIdentity(steps.withholdWebSearchTools(steps.pruneSkillPayloads(request)))
31757
32740
  };
31758
32741
  var cursorRequestPolicy = {
31759
32742
  provider: "cursor",
31760
- shapeRequest: (request, steps) => steps.withholdWebSearchTools(steps.pruneSkillPayloads(request))
32743
+ shapeRequest: (request, steps) => steps.stripClientIdentity(steps.withholdWebSearchTools(steps.pruneSkillPayloads(request)))
31761
32744
  };
31762
32745
  var kimiRequestPolicy = {
31763
32746
  provider: "kimi",
31764
- shapeRequest: (request, steps) => steps.pruneSkillPayloads(request)
32747
+ shapeRequest: (request, steps) => steps.stripClientIdentity(steps.pruneSkillPayloads(request))
31765
32748
  };
31766
32749
  var opencodeGoRequestPolicy = {
31767
32750
  provider: "opencode",
31768
- shapeRequest: (request, steps) => steps.withholdWebSearchTools(steps.pruneSkillPayloads(request))
32751
+ shapeRequest: (request, steps) => steps.stripClientIdentity(steps.withholdWebSearchTools(steps.pruneSkillPayloads(request)))
31769
32752
  };
31770
32753
  var xaiRequestPolicy = {
31771
32754
  provider: "xai",
31772
- shapeRequest: (request, steps) => steps.withholdWebSearchTools(steps.pruneSkillPayloads(request))
32755
+ shapeRequest: (request, steps) => steps.stripClientIdentity(steps.withholdWebSearchTools(steps.pruneSkillPayloads(request)))
31773
32756
  };
31774
32757
  var POLICIES = {
32758
+ antigravity: antigravityRequestPolicy,
31775
32759
  codex: codexRequestPolicy,
31776
32760
  cursor: cursorRequestPolicy,
31777
32761
  kimi: kimiRequestPolicy,
@@ -31805,6 +32789,15 @@ function buildPolicySteps(context) {
31805
32789
  withholdWebSearchTools: (request) => {
31806
32790
  const omitted = omitClaudeWebSearchTools(request);
31807
32791
  return omitted.changed ? omitted.request : request;
32792
+ },
32793
+ stripClientIdentity: (request) => {
32794
+ const stripped = stripClaudeClientIdentity(request.system);
32795
+ if (!stripped.changed) return request;
32796
+ if (stripped.system === void 0) {
32797
+ const { system: _dropped, ...rest } = request;
32798
+ return rest;
32799
+ }
32800
+ return { ...request, system: [...stripped.system] };
31808
32801
  }
31809
32802
  };
31810
32803
  }
@@ -31934,6 +32927,13 @@ async function readXaiSubscriptionToken() {
31934
32927
  const credentials = await resolveXaiCliCredentials(defaultCredentialDeps);
31935
32928
  return credentials?.accessToken ?? null;
31936
32929
  }
32930
+ async function readAntigravitySubscriptionToken(options = {}) {
32931
+ const credentials = await resolveAntigravityCredentials(
32932
+ defaultCredentialDeps,
32933
+ options.forceRenew === true ? { forceRefresh: true } : {}
32934
+ );
32935
+ return credentials?.accessToken ?? null;
32936
+ }
31937
32937
  async function readCodexSubscriptionAuth() {
31938
32938
  const credentials = await resolveCodexCredentials(defaultCredentialDeps);
31939
32939
  if (!credentials?.accountId) return null;
@@ -31948,6 +32948,16 @@ function createAiGatewayRouter(deps) {
31948
32948
  const fetchImpl = upstreamGate.fetch;
31949
32949
  const ownedCursorAdapter = deps.gateway ? void 0 : new CursorAdapter({ diagnostics: deps.cursorDiagnostics });
31950
32950
  const ownedCursorGateway = ownedCursorAdapter ? new AnthropicMessagesGateway(ownedCursorAdapter) : void 0;
32951
+ let ownedAntigravityGateway;
32952
+ const antigravityGateway = () => {
32953
+ ownedAntigravityGateway ??= new AnthropicMessagesGateway(
32954
+ new AntigravityGenerateContentAdapter({
32955
+ fetch: fetchImpl,
32956
+ ...deps.renewAntigravityToken ? { renewCredential: async () => await deps.renewAntigravityToken?.() ?? null } : {}
32957
+ })
32958
+ );
32959
+ return ownedAntigravityGateway;
32960
+ };
31951
32961
  const withheldSkills = /* @__PURE__ */ new Set();
31952
32962
  const gatewaySettings = () => deps.readAiGatewaySettings ? deps.readAiGatewaySettings() : void 0;
31953
32963
  const isModelExposed = (model) => {
@@ -32084,6 +33094,13 @@ function createAiGatewayRouter(deps) {
32084
33094
  return true;
32085
33095
  }
32086
33096
  credential = xaiToken;
33097
+ } else if (target2?.provider === "antigravity") {
33098
+ const antigravityToken = await deps.readAntigravityToken?.();
33099
+ if (!antigravityToken) {
33100
+ writeAnthropicError(res, 401, "authentication_error", "No active Antigravity sign-in was found. Run `agy` and sign in first.");
33101
+ return true;
33102
+ }
33103
+ credential = antigravityToken;
32087
33104
  }
32088
33105
  const controller = new AbortController();
32089
33106
  const abort = () => controller.abort(new Error("client disconnected"));
@@ -32130,7 +33147,7 @@ function createAiGatewayRouter(deps) {
32130
33147
  ) : target2.provider === "xai" ? new AnthropicMessagesGateway(new XaiResponsesAdapter({
32131
33148
  fetch: fetchImpl,
32132
33149
  endpoint: xaiEndpoint()
32133
- })) : createGatewayFor(target2, chatgptAccountId, deps.originator, fetchImpl));
33150
+ })) : target2.provider === "antigravity" ? antigravityGateway() : createGatewayFor(target2, chatgptAccountId, deps.originator, fetchImpl));
32134
33151
  const diagnosticsEnabled = target2.provider === "cursor" ? cursorDiagnosticsEnabled() : void 0;
32135
33152
  const modelContextWindow = typeof target2.contextWindow === "number" && Number.isFinite(target2.contextWindow) && target2.contextWindow > 0 ? target2.contextWindow : void 0;
32136
33153
  const upstream = await gateway.stream(body, {
@@ -32265,11 +33282,11 @@ var LOCK_OWNER_FILE_NAME2 = "owner";
32265
33282
  var TEMP_FILE_PREFIX2 = `${AI_GATEWAY_SETTINGS_FILE_NAME}.`;
32266
33283
  function createAiGatewaySettingsStore(deps = {}) {
32267
33284
  const dataDir = deps.dataDir ?? getFleetDataDir();
32268
- const settingsPath = path32.join(dataDir, AI_GATEWAY_SETTINGS_FILE_NAME);
32269
- const legacyPath = deps.legacyDir === void 0 ? void 0 : path32.join(deps.legacyDir, AI_GATEWAY_SETTINGS_FILE_NAME);
33285
+ const settingsPath = path42.join(dataDir, AI_GATEWAY_SETTINGS_FILE_NAME);
33286
+ const legacyPath = deps.legacyDir === void 0 ? void 0 : path42.join(deps.legacyDir, AI_GATEWAY_SETTINGS_FILE_NAME);
32270
33287
  const store = createDurableJsonStore({
32271
33288
  filePath: settingsPath,
32272
- lockDir: path32.join(dataDir, LOCK_DIR_NAME2),
33289
+ lockDir: path42.join(dataDir, LOCK_DIR_NAME2),
32273
33290
  lockOwnerFileName: LOCK_OWNER_FILE_NAME2,
32274
33291
  sanitize: (value) => normalizeAiGatewaySettings(value),
32275
33292
  sensitivity: "sensitive",
@@ -32439,14 +33456,14 @@ function prepareAiGatewayLaunchProfile(profile, options) {
32439
33456
  return { ...profile, env };
32440
33457
  }
32441
33458
  function writeClaudeGatewayModelCache(baseUrl, env, homeDir, exposedModels = GATEWAY_MODELS) {
32442
- const configDir = env.CLAUDE_CONFIG_DIR && env.CLAUDE_CONFIG_DIR.length > 0 ? env.CLAUDE_CONFIG_DIR : path18__default.join(homeDir, ".claude");
33459
+ const configDir = env.CLAUDE_CONFIG_DIR && env.CLAUDE_CONFIG_DIR.length > 0 ? env.CLAUDE_CONFIG_DIR : path19__default.join(homeDir, ".claude");
32443
33460
  return writeGatewayModelCacheForHome({ baseUrl, configDir, models: exposedModels });
32444
33461
  }
32445
33462
  function writeGatewayModelCacheForHome(options) {
32446
33463
  const { baseUrl, configDir } = options;
32447
33464
  const exposedModels = options.models ?? GATEWAY_MODELS;
32448
- const cacheDir = path18__default.join(configDir, "cache");
32449
- const cachePath = path18__default.join(cacheDir, "gateway-models.json");
33465
+ const cacheDir = path19__default.join(configDir, "cache");
33466
+ const cachePath = path19__default.join(cacheDir, "gateway-models.json");
32450
33467
  const models = buildAnthropicModelList(exposedModels).data.filter((model) => /^(claude|anthropic)/i.test(model.id)).map((model) => ({ id: model.id, display_name: model.display_name }));
32451
33468
  fs9__default.mkdirSync(cacheDir, { recursive: true, mode: 448 });
32452
33469
  writeAtomicSync(cachePath, JSON.stringify({ baseUrl, fetchedAt: Date.now(), models }), { mode: 384 });
@@ -32763,7 +33780,7 @@ function createChildEnv(env, overlay) {
32763
33780
  return child;
32764
33781
  }
32765
33782
  function wrapWindowsShim(resolved, env, platform) {
32766
- if (platform !== "win32" || !WINDOWS_SHIM_EXTENSIONS.has(path18__default.extname(resolved).toLowerCase())) {
33783
+ if (platform !== "win32" || !WINDOWS_SHIM_EXTENSIONS.has(path19__default.extname(resolved).toLowerCase())) {
32767
33784
  return { bin: resolved, prefixArgs: [] };
32768
33785
  }
32769
33786
  rejectCmdExpansionSensitiveShim(resolved);
@@ -32781,13 +33798,13 @@ function forceWindowsArgQuoting(value) {
32781
33798
  return `${value} `;
32782
33799
  }
32783
33800
  function findOnPath(bin, pathValue, pathExts, platform) {
32784
- const pathSeparator = platform === "win32" ? WINDOWS_PATH_SEPARATOR : path18__default.delimiter;
32785
- if (hasPathSeparator(bin, platform) || path18__default.isAbsolute(bin)) {
33801
+ const pathSeparator = platform === "win32" ? WINDOWS_PATH_SEPARATOR : path19__default.delimiter;
33802
+ if (hasPathSeparator(bin, platform) || path19__default.isAbsolute(bin)) {
32786
33803
  return resolveWithExtensions(bin, pathExts, platform);
32787
33804
  }
32788
33805
  for (const entry of pathValue.split(pathSeparator)) {
32789
33806
  const searchDir = entry.length === 0 ? "." : entry;
32790
- const candidate = resolveWithExtensions(path18__default.join(searchDir, bin), pathExts, platform);
33807
+ const candidate = resolveWithExtensions(path19__default.join(searchDir, bin), pathExts, platform);
32791
33808
  if (candidate) {
32792
33809
  return candidate;
32793
33810
  }
@@ -32795,7 +33812,7 @@ function findOnPath(bin, pathValue, pathExts, platform) {
32795
33812
  return void 0;
32796
33813
  }
32797
33814
  function resolveWithExtensions(candidate, pathExts, platform) {
32798
- if (platform !== "win32" || path18__default.extname(candidate).length > 0) {
33815
+ if (platform !== "win32" || path19__default.extname(candidate).length > 0) {
32799
33816
  return isAccessibleExecutable(candidate, platform) ? candidate : void 0;
32800
33817
  }
32801
33818
  for (const ext of pathExts) {
@@ -33041,7 +34058,7 @@ function writePrivateJson(filePath, value, rootBase) {
33041
34058
  function writePrivateFile(filePath, content, rootBase) {
33042
34059
  const resolvedBase = ensureRootBase(rootBase);
33043
34060
  ensurePathWithinRoot(resolvedBase, filePath);
33044
- ensureDirectorySegments(resolvedBase, path18__default.dirname(filePath));
34061
+ ensureDirectorySegments(resolvedBase, path19__default.dirname(filePath));
33045
34062
  writeFileNoFollow(filePath, content);
33046
34063
  chmodBestEffort2(filePath, FILE_MODE);
33047
34064
  }
@@ -33088,20 +34105,20 @@ function writeFileNoFollow(filePath, content) {
33088
34105
  }
33089
34106
  }
33090
34107
  function ensureRootBase(rootBase) {
33091
- const resolvedBase = path18__default.resolve(rootBase);
33092
- const anchor = findExistingDirectoryAnchor(path18__default.dirname(resolvedBase));
34108
+ const resolvedBase = path19__default.resolve(rootBase);
34109
+ const anchor = findExistingDirectoryAnchor(path19__default.dirname(resolvedBase));
33093
34110
  ensureDirectorySegments(anchor, resolvedBase);
33094
34111
  assertDirectorySafe(resolvedBase, "Plugin root base");
33095
34112
  return resolvedBase;
33096
34113
  }
33097
34114
  function assertRootBaseSafe(rootBase) {
33098
- const resolvedBase = path18__default.resolve(rootBase);
33099
- assertExistingSegmentsSafe(findExistingDirectoryAnchor(path18__default.dirname(resolvedBase)), resolvedBase);
34115
+ const resolvedBase = path19__default.resolve(rootBase);
34116
+ assertExistingSegmentsSafe(findExistingDirectoryAnchor(path19__default.dirname(resolvedBase)), resolvedBase);
33100
34117
  assertDirectorySafe(resolvedBase, "Plugin root base");
33101
34118
  return resolvedBase;
33102
34119
  }
33103
34120
  function findExistingDirectoryAnchor(targetPath) {
33104
- const resolvedTarget = path18__default.resolve(targetPath);
34121
+ const resolvedTarget = path19__default.resolve(targetPath);
33105
34122
  let current = resolvedTarget;
33106
34123
  while (true) {
33107
34124
  try {
@@ -33109,7 +34126,7 @@ function findExistingDirectoryAnchor(targetPath) {
33109
34126
  return current;
33110
34127
  } catch (error51) {
33111
34128
  if (error51 instanceof Error && "code" in error51 && error51.code === "ENOENT") {
33112
- const parent = path18__default.dirname(current);
34129
+ const parent = path19__default.dirname(current);
33113
34130
  if (parent === current) throw error51;
33114
34131
  current = parent;
33115
34132
  continue;
@@ -33128,17 +34145,17 @@ function assertDirectorySafe(dirPath, label) {
33128
34145
  }
33129
34146
  }
33130
34147
  function ensurePathWithinRoot(resolvedBase, candidatePath) {
33131
- const resolvedCandidate = path18__default.resolve(candidatePath);
33132
- const relative = path18__default.relative(resolvedBase, resolvedCandidate);
33133
- if (relative === "" || !relative.startsWith("..") && !path18__default.isAbsolute(relative)) return;
34148
+ const resolvedCandidate = path19__default.resolve(candidatePath);
34149
+ const relative = path19__default.relative(resolvedBase, resolvedCandidate);
34150
+ if (relative === "" || !relative.startsWith("..") && !path19__default.isAbsolute(relative)) return;
33134
34151
  throw new Error(`Plugin path escapes root base: ${candidatePath}`);
33135
34152
  }
33136
34153
  function ensureDirectorySegments(resolvedBase, dirPath) {
33137
- const target2 = path18__default.resolve(dirPath);
33138
- const relative = path18__default.relative(resolvedBase, target2);
34154
+ const target2 = path19__default.resolve(dirPath);
34155
+ const relative = path19__default.relative(resolvedBase, target2);
33139
34156
  let current = resolvedBase;
33140
- for (const segment of relative.split(path18__default.sep).filter(Boolean)) {
33141
- current = path18__default.join(current, segment);
34157
+ for (const segment of relative.split(path19__default.sep).filter(Boolean)) {
34158
+ current = path19__default.join(current, segment);
33142
34159
  try {
33143
34160
  const stat4 = lstatSync(current);
33144
34161
  if (stat4.isSymbolicLink()) {
@@ -33159,11 +34176,11 @@ function ensureDirectorySegments(resolvedBase, dirPath) {
33159
34176
  }
33160
34177
  }
33161
34178
  function assertExistingSegmentsSafe(resolvedBase, targetPath) {
33162
- const target2 = path18__default.resolve(targetPath);
33163
- const relative = path18__default.relative(resolvedBase, target2);
34179
+ const target2 = path19__default.resolve(targetPath);
34180
+ const relative = path19__default.relative(resolvedBase, target2);
33164
34181
  let current = resolvedBase;
33165
- for (const segment of relative.split(path18__default.sep).filter(Boolean)) {
33166
- current = path18__default.join(current, segment);
34182
+ for (const segment of relative.split(path19__default.sep).filter(Boolean)) {
34183
+ current = path19__default.join(current, segment);
33167
34184
  const stat4 = lstatSync(current);
33168
34185
  if (stat4.isSymbolicLink()) {
33169
34186
  throw new Error(`Plugin path segment is a symlink: ${current}`);
@@ -33175,13 +34192,13 @@ function assertExistingSegmentsSafe(resolvedBase, targetPath) {
33175
34192
  }
33176
34193
  }
33177
34194
  function assertExistingParentSegmentsSafe(resolvedBase, targetPath) {
33178
- assertExistingSegmentsSafe(resolvedBase, path18__default.dirname(targetPath));
34195
+ assertExistingSegmentsSafe(resolvedBase, path19__default.dirname(targetPath));
33179
34196
  }
33180
34197
  function assertSegmentRealpathWithinRoot(resolvedBase, segmentPath) {
33181
34198
  const baseRealpath = realpathSync(resolvedBase);
33182
34199
  const segmentRealpath = realpathSync(segmentPath);
33183
- const relative = path18__default.relative(baseRealpath, segmentRealpath);
33184
- if (relative === "" || !relative.startsWith("..") && !path18__default.isAbsolute(relative)) return;
34200
+ const relative = path19__default.relative(baseRealpath, segmentRealpath);
34201
+ if (relative === "" || !relative.startsWith("..") && !path19__default.isAbsolute(relative)) return;
33185
34202
  throw new Error(`Plugin path segment escapes root base: ${segmentPath}`);
33186
34203
  }
33187
34204
 
@@ -33201,23 +34218,23 @@ function resolveAssetPluginDirectoryName() {
33201
34218
  function renderAssetPluginRoot(pluginRoot, bundle, options) {
33202
34219
  renderEmbeddedSkillAssets(pluginRoot);
33203
34220
  const modelGuardScriptPath = writeModelGuardScript(pluginRoot);
33204
- writePrivateJson(path18__default.join(pluginRoot, "hooks", "hooks.json"), claudeHooks(options, modelGuardScriptPath), pluginRoot);
34221
+ writePrivateJson(path19__default.join(pluginRoot, "hooks", "hooks.json"), claudeHooks(options, modelGuardScriptPath), pluginRoot);
33205
34222
  renderGatewayAgentAssets(pluginRoot, options);
33206
34223
  }
33207
34224
  function renderEmbeddedSkillAssets(pluginRoot) {
33208
34225
  for (const asset of EMBEDDED_AGENT_CLI_SKILL_ASSETS) {
33209
- writePrivateFile(path18__default.join(pluginRoot, "skills", asset.relativePath), asset.content, pluginRoot);
34226
+ writePrivateFile(path19__default.join(pluginRoot, "skills", asset.relativePath), asset.content, pluginRoot);
33210
34227
  }
33211
34228
  }
33212
34229
  function renderGatewayAgentAssets(pluginRoot, options) {
33213
34230
  for (const file2 of buildGatewayAgentFiles(options.gatewayDelegationModels ?? [], options.gatewayEffortExposure)) {
33214
- writePrivateFile(path18__default.join(pluginRoot, "agents", file2.fileName), file2.content, pluginRoot);
34231
+ writePrivateFile(path19__default.join(pluginRoot, "agents", file2.fileName), file2.content, pluginRoot);
33215
34232
  }
33216
34233
  }
33217
34234
  function writeModelGuardScript(pluginRoot) {
33218
34235
  const asset = EMBEDDED_AGENT_CLI_HOOK_ASSETS.find((entry) => entry.relativePath === MODEL_GUARD_SCRIPT_NAME);
33219
34236
  if (!asset) throw new Error(`Missing embedded ${MODEL_GUARD_SCRIPT_NAME} hook asset`);
33220
- const scriptPath = path18__default.join(pluginRoot, "hooks", MODEL_GUARD_SCRIPT_NAME);
34237
+ const scriptPath = path19__default.join(pluginRoot, "hooks", MODEL_GUARD_SCRIPT_NAME);
33221
34238
  writePrivateFile(scriptPath, asset.content, pluginRoot);
33222
34239
  return scriptPath;
33223
34240
  }
@@ -33339,7 +34356,7 @@ function resolveRenderablePluginBundles(fleetRoot, options) {
33339
34356
  function homeMarketplaceTarget(fleetRoot) {
33340
34357
  return {
33341
34358
  name: FLEET_MARKETPLACE_NAME,
33342
- root: path18__default.join(fleetRoot, MARKETPLACE_DIR_NAME)
34359
+ root: path19__default.join(fleetRoot, MARKETPLACE_DIR_NAME)
33343
34360
  };
33344
34361
  }
33345
34362
  function groupRenderableBundlesByMarketplace(bundles) {
@@ -33355,16 +34372,16 @@ function groupRenderableBundlesByMarketplace(bundles) {
33355
34372
  return groups;
33356
34373
  }
33357
34374
  function renderPluginRoot(pluginRoot, bundle, options) {
33358
- const parentRoot = path18__default.dirname(pluginRoot);
34375
+ const parentRoot = path19__default.dirname(pluginRoot);
33359
34376
  ensurePrivateDir(parentRoot, parentRoot);
33360
34377
  const stageParent = createStagingDir(parentRoot);
33361
- const stagedPluginRoot = path18__default.join(stageParent, path18__default.basename(pluginRoot));
34378
+ const stagedPluginRoot = path19__default.join(stageParent, path19__default.basename(pluginRoot));
33362
34379
  try {
33363
34380
  ensurePrivateDir(stagedPluginRoot, stagedPluginRoot);
33364
- writePrivateJson(path18__default.join(stagedPluginRoot, ".claude-plugin", "plugin.json"), claudeManifest(bundle), stagedPluginRoot);
34381
+ writePrivateJson(path19__default.join(stagedPluginRoot, ".claude-plugin", "plugin.json"), claudeManifest(bundle), stagedPluginRoot);
33365
34382
  switch (bundle.source) {
33366
34383
  case "asset":
33367
- ensurePrivateDir(path18__default.join(stagedPluginRoot, "agents"), stagedPluginRoot);
34384
+ ensurePrivateDir(path19__default.join(stagedPluginRoot, "agents"), stagedPluginRoot);
33368
34385
  renderAssetPluginRoot(stagedPluginRoot, bundle, options);
33369
34386
  break;
33370
34387
  }
@@ -33379,11 +34396,11 @@ function renderMarketplaceRoot(target2, bundles) {
33379
34396
  ensurePrivateDir(marketplaceRoot, marketplaceRoot);
33380
34397
  const stagedRoot = createStagingDir(marketplaceRoot);
33381
34398
  try {
33382
- writePrivateJson(path18__default.join(stagedRoot, ".claude-plugin", "marketplace.json"), claudeMarketplace(target2, bundles), stagedRoot);
34399
+ writePrivateJson(path19__default.join(stagedRoot, ".claude-plugin", "marketplace.json"), claudeMarketplace(target2, bundles), stagedRoot);
33383
34400
  pruneMarketplaceRoot(target2);
33384
34401
  pruneStalePluginDirs(target2, bundles);
33385
34402
  for (const entry of readdirSync(stagedRoot)) {
33386
- renameSync$1(path18__default.join(stagedRoot, entry), path18__default.join(marketplaceRoot, entry));
34403
+ renameSync$1(path19__default.join(stagedRoot, entry), path19__default.join(marketplaceRoot, entry));
33387
34404
  }
33388
34405
  } finally {
33389
34406
  cleanupPrivateRoot(stagedRoot, marketplaceRoot);
@@ -33391,11 +34408,11 @@ function renderMarketplaceRoot(target2, bundles) {
33391
34408
  }
33392
34409
  function pruneMarketplaceRoot(target2) {
33393
34410
  for (const entry of MARKETPLACE_PRUNE_ENTRIES) {
33394
- removePrivatePath(path18__default.join(target2.root, entry), target2.root);
34411
+ removePrivatePath(path19__default.join(target2.root, entry), target2.root);
33395
34412
  }
33396
34413
  }
33397
34414
  function pruneStalePluginDirs(target2, bundles) {
33398
- const pluginsDir = path18__default.join(target2.root, PLUGIN_BUNDLES_DIR_NAME);
34415
+ const pluginsDir = path19__default.join(target2.root, PLUGIN_BUNDLES_DIR_NAME);
33399
34416
  if (!existsSync(pluginsDir)) return;
33400
34417
  const activeDirectoryNames = /* @__PURE__ */ new Set();
33401
34418
  for (const bundle of bundles) {
@@ -33409,11 +34426,11 @@ function pruneStalePluginDirs(target2, bundles) {
33409
34426
  }
33410
34427
  for (const entry of readdirSync(pluginsDir)) {
33411
34428
  if (activeDirectoryNames.has(entry)) continue;
33412
- removePrivatePath(path18__default.join(pluginsDir, entry), target2.root);
34429
+ removePrivatePath(path19__default.join(pluginsDir, entry), target2.root);
33413
34430
  }
33414
34431
  }
33415
34432
  function createStagingDir(rootPath) {
33416
- const stageRoot = mkdtempSync(path18__default.join(rootPath, `.fleet-stage-${process.pid}-${Date.now()}-`));
34433
+ const stageRoot = mkdtempSync(path19__default.join(rootPath, `.fleet-stage-${process.pid}-${Date.now()}-`));
33417
34434
  return stageRoot;
33418
34435
  }
33419
34436
  function claudeMarketplace(target2, bundles) {
@@ -33435,7 +34452,7 @@ function claudeMarketplace(target2, bundles) {
33435
34452
  };
33436
34453
  }
33437
34454
  function pluginRootForTarget(target2, bundle) {
33438
- return path18__default.join(target2.root, PLUGIN_BUNDLES_DIR_NAME, bundle.directoryName);
34455
+ return path19__default.join(target2.root, PLUGIN_BUNDLES_DIR_NAME, bundle.directoryName);
33439
34456
  }
33440
34457
  function marketplacePluginPath(target2, bundle) {
33441
34458
  return `./${PLUGIN_BUNDLES_DIR_NAME}/${bundle.directoryName}`;
@@ -34733,18 +35750,18 @@ Always read \`schema/wiki-schema.md\` directly before composing or revising entr
34733
35750
  `;
34734
35751
  async function ensureWorkspaceSchema(paths) {
34735
35752
  await mkdir$1(paths.schemaDir, { recursive: true });
34736
- await writeDefaultFileIfMissing(path18__default.join(paths.schemaDir, WORKSPACE_SCHEMA_AGENTS_FILENAME), DEFAULT_WORKSPACE_SCHEMA_AGENTS);
34737
- await writeDefaultFileIfMissing(path18__default.join(paths.schemaDir, WORKSPACE_SCHEMA_FILENAME), DEFAULT_WORKSPACE_WIKI_SCHEMA);
35753
+ await writeDefaultFileIfMissing(path19__default.join(paths.schemaDir, WORKSPACE_SCHEMA_AGENTS_FILENAME), DEFAULT_WORKSPACE_SCHEMA_AGENTS);
35754
+ await writeDefaultFileIfMissing(path19__default.join(paths.schemaDir, WORKSPACE_SCHEMA_FILENAME), DEFAULT_WORKSPACE_WIKI_SCHEMA);
34738
35755
  await writeDefaultFileIfMissing(buildTemplatePath(paths, "prd"), DEFAULT_TEMPLATE_PRD);
34739
35756
  return readWorkspaceSchemaSummary(paths);
34740
35757
  }
34741
35758
  async function ensureWorkspaceDoctrine(paths) {
34742
35759
  await mkdir$1(paths.root, { recursive: true });
34743
- await writeDefaultFileIfMissing(path18__default.join(paths.root, WORKSPACE_KNOWLEDGE_AGENTS_FILENAME), DEFAULT_WORKSPACE_KNOWLEDGE_AGENTS);
35760
+ await writeDefaultFileIfMissing(path19__default.join(paths.root, WORKSPACE_KNOWLEDGE_AGENTS_FILENAME), DEFAULT_WORKSPACE_KNOWLEDGE_AGENTS);
34744
35761
  }
34745
35762
  async function readWorkspaceSchemaSummary(paths) {
34746
- const agentsPath = path18__default.join(paths.schemaDir, WORKSPACE_SCHEMA_AGENTS_FILENAME);
34747
- const wikiSchemaPath = path18__default.join(paths.schemaDir, WORKSPACE_SCHEMA_FILENAME);
35763
+ const agentsPath = path19__default.join(paths.schemaDir, WORKSPACE_SCHEMA_AGENTS_FILENAME);
35764
+ const wikiSchemaPath = path19__default.join(paths.schemaDir, WORKSPACE_SCHEMA_FILENAME);
34748
35765
  const wikiSchemaContent = await tryReadSchemaFile(paths, wikiSchemaPath);
34749
35766
  const templates = await scanTemplates(paths);
34750
35767
  if (wikiSchemaContent === null) {
@@ -34783,7 +35800,7 @@ async function scanTemplates(paths) {
34783
35800
  if (!entry.name.startsWith(WORKSPACE_TEMPLATE_PREFIX) || !entry.name.endsWith(WORKSPACE_TEMPLATE_SUFFIX)) continue;
34784
35801
  const id = entry.name.slice(WORKSPACE_TEMPLATE_PREFIX.length, -WORKSPACE_TEMPLATE_SUFFIX.length);
34785
35802
  if (!TEMPLATE_ID_PATTERN.test(id)) continue;
34786
- const filePath = path18__default.join(paths.schemaDir, entry.name);
35803
+ const filePath = path19__default.join(paths.schemaDir, entry.name);
34787
35804
  try {
34788
35805
  const parsed = parseTemplateMarkdown(await readFile(filePath, "utf8"));
34789
35806
  templates.push({
@@ -34815,7 +35832,7 @@ async function readSchemaCatalog(paths) {
34815
35832
  }
34816
35833
  async function readSchemaDocument(paths, resource, templateId) {
34817
35834
  const ref = resource === "schema" ? "schema/wiki-schema.md" : schemaTemplateRef(templateId ?? "");
34818
- const absolute = path18__default.resolve(paths.root, ref);
35835
+ const absolute = path19__default.resolve(paths.root, ref);
34819
35836
  await assertContainedSchemaFile(paths, absolute, false);
34820
35837
  return { ref, content: await readFile(absolute, "utf8") };
34821
35838
  }
@@ -34840,10 +35857,10 @@ async function validateSchemaTemplateCreate(paths, templateId, markdown) {
34840
35857
  if (folded.has(key)) throw new Error(`schema template contains duplicate ## section: ${section}`);
34841
35858
  folded.add(key);
34842
35859
  }
34843
- const absolute = path18__default.resolve(paths.root, ref);
35860
+ const absolute = path19__default.resolve(paths.root, ref);
34844
35861
  await assertContainedSchemaFile(paths, absolute, true);
34845
35862
  const entries = await readdir(paths.schemaDir).catch(() => []);
34846
- const basename = path18__default.basename(absolute).toLocaleLowerCase("en-US");
35863
+ const basename = path19__default.basename(absolute).toLocaleLowerCase("en-US");
34847
35864
  if (entries.some((entry) => entry.toLocaleLowerCase("en-US") === basename)) throw new Error("schema template target already exists");
34848
35865
  return absolute;
34849
35866
  }
@@ -34851,13 +35868,13 @@ function assertTemplateId(id) {
34851
35868
  if (!TEMPLATE_ID_PATTERN.test(id)) throw new Error("template_id must match /^[a-z][a-z0-9-]{0,63}$/");
34852
35869
  }
34853
35870
  async function assertContainedSchemaFile(paths, absolute, allowMissing) {
34854
- const schemaReal = await realpath(paths.schemaDir).catch(() => path18__default.resolve(paths.schemaDir));
34855
- const parentReal = await realpath(path18__default.dirname(absolute)).catch(() => path18__default.resolve(path18__default.dirname(absolute)));
35871
+ const schemaReal = await realpath(paths.schemaDir).catch(() => path19__default.resolve(paths.schemaDir));
35872
+ const parentReal = await realpath(path19__default.dirname(absolute)).catch(() => path19__default.resolve(path19__default.dirname(absolute)));
34856
35873
  if (parentReal !== schemaReal) throw new Error("schema resource escapes schema directory");
34857
- const relative = path18__default.relative(paths.root, absolute);
35874
+ const relative = path19__default.relative(paths.root, absolute);
34858
35875
  let cursor = paths.root;
34859
- for (const part of relative.split(path18__default.sep)) {
34860
- cursor = path18__default.join(cursor, part);
35876
+ for (const part of relative.split(path19__default.sep)) {
35877
+ cursor = path19__default.join(cursor, part);
34861
35878
  try {
34862
35879
  if ((await lstat(cursor)).isSymbolicLink()) throw new Error("schema resource path contains symlink");
34863
35880
  } catch (error51) {
@@ -34885,7 +35902,7 @@ async function validateTemplateCompliance(paths, templateId, body) {
34885
35902
  }
34886
35903
  }
34887
35904
  function inferTemplateIdFromTarget(target2, knownTemplateIds) {
34888
- const basename = path18__default.basename(target2, ".md");
35905
+ const basename = path19__default.basename(target2, ".md");
34889
35906
  const ids = knownTemplateIds ?? DEFAULT_TEMPLATE_IDS;
34890
35907
  const sorted = [...ids].sort((a, b) => b.length - a.length);
34891
35908
  for (const id of sorted) {
@@ -34917,7 +35934,7 @@ function extractSchemaSummary(content) {
34917
35934
  return lines.find((line) => line.length > 0 && !line.startsWith("#")) ?? "Workspace schema is present.";
34918
35935
  }
34919
35936
  function buildTemplatePath(paths, id) {
34920
- return path18__default.join(paths.schemaDir, `${WORKSPACE_TEMPLATE_PREFIX}${id}${WORKSPACE_TEMPLATE_SUFFIX}`);
35937
+ return path19__default.join(paths.schemaDir, `${WORKSPACE_TEMPLATE_PREFIX}${id}${WORKSPACE_TEMPLATE_SUFFIX}`);
34921
35938
  }
34922
35939
  function parseTemplateMarkdown(content) {
34923
35940
  const normalized = content.replace(/\r\n/g, "\n");
@@ -35022,18 +36039,18 @@ function isAlreadyExistsError(error51) {
35022
36039
 
35023
36040
  // ../../packages/fleet-wiki/src/paths.ts
35024
36041
  function resolveMemoryPaths(cwd) {
35025
- return createMemoryPaths(path18__default.join(cwd, KNOWLEDGE_ROOT_DIRNAME));
36042
+ return createMemoryPaths(path19__default.join(cwd, KNOWLEDGE_ROOT_DIRNAME));
35026
36043
  }
35027
36044
  function createMemoryPaths(root) {
35028
36045
  return {
35029
36046
  root,
35030
- rawDir: path18__default.join(root, RAW_DIRNAME),
35031
- wikiDir: path18__default.join(root, WIKI_DIRNAME),
35032
- schemaDir: path18__default.join(root, SCHEMA_DIRNAME),
35033
- queueDir: path18__default.join(root, QUEUE_DIRNAME),
35034
- archiveDir: path18__default.join(root, ARCHIVE_DIRNAME),
35035
- conflictsDir: path18__default.join(root, CONFLICTS_DIRNAME),
35036
- indexFile: path18__default.join(root, INDEX_FILENAME)
36047
+ rawDir: path19__default.join(root, RAW_DIRNAME),
36048
+ wikiDir: path19__default.join(root, WIKI_DIRNAME),
36049
+ schemaDir: path19__default.join(root, SCHEMA_DIRNAME),
36050
+ queueDir: path19__default.join(root, QUEUE_DIRNAME),
36051
+ archiveDir: path19__default.join(root, ARCHIVE_DIRNAME),
36052
+ conflictsDir: path19__default.join(root, CONFLICTS_DIRNAME),
36053
+ indexFile: path19__default.join(root, INDEX_FILENAME)
35037
36054
  };
35038
36055
  }
35039
36056
  function resolveToolMemoryPaths(ctx) {
@@ -35051,10 +36068,10 @@ async function ensureMemoryRoot(paths) {
35051
36068
  await ensureWorkspaceDoctrine(paths);
35052
36069
  }
35053
36070
  function getIndexMarkdownFile(paths) {
35054
- return path18__default.join(paths.wikiDir, INDEX_MD_FILENAME);
36071
+ return path19__default.join(paths.wikiDir, INDEX_MD_FILENAME);
35055
36072
  }
35056
36073
  function getLogFile(paths) {
35057
- return path18__default.join(paths.root, LOG_MD_FILENAME);
36074
+ return path19__default.join(paths.root, LOG_MD_FILENAME);
35058
36075
  }
35059
36076
 
35060
36077
  // ../../packages/fleet-wiki/src/conflicts.ts
@@ -35066,7 +36083,7 @@ async function createConflict(input, paths) {
35066
36083
  await ensureMemoryRoot(paths);
35067
36084
  const now = input.now ?? /* @__PURE__ */ new Date();
35068
36085
  const conflictId = buildConflictId(now, input.wikiId, input.reason, input.proposed);
35069
- const conflictDir = path18__default.join(paths.conflictsDir, conflictId);
36086
+ const conflictDir = path19__default.join(paths.conflictsDir, conflictId);
35070
36087
  await mkdir$1(conflictDir, { recursive: true });
35071
36088
  const meta3 = {
35072
36089
  id: conflictId,
@@ -35086,13 +36103,13 @@ async function createConflict(input, paths) {
35086
36103
  currentHash: input.currentHash,
35087
36104
  warnings: input.warnings
35088
36105
  };
35089
- await writeJsonFile(path18__default.join(conflictDir, CONFLICT_META_FILENAME), meta3, paths);
35090
- await writePatchFile(path18__default.join(conflictDir, CONFLICT_PROPOSED_FILENAME), input.proposed, paths);
36106
+ await writeJsonFile(path19__default.join(conflictDir, CONFLICT_META_FILENAME), meta3, paths);
36107
+ await writePatchFile(path19__default.join(conflictDir, CONFLICT_PROPOSED_FILENAME), input.proposed, paths);
35091
36108
  if (input.current !== void 0) {
35092
- await writePatchFile(path18__default.join(conflictDir, CONFLICT_CURRENT_FILENAME), input.current, paths);
36109
+ await writePatchFile(path19__default.join(conflictDir, CONFLICT_CURRENT_FILENAME), input.current, paths);
35093
36110
  }
35094
36111
  if (input.rawSource !== void 0) {
35095
- await writePatchFile(path18__default.join(conflictDir, CONFLICT_RAW_SOURCE_FILENAME), input.rawSource, paths);
36112
+ await writePatchFile(path19__default.join(conflictDir, CONFLICT_RAW_SOURCE_FILENAME), input.rawSource, paths);
35096
36113
  }
35097
36114
  return {
35098
36115
  meta: meta3,
@@ -35106,7 +36123,7 @@ async function listConflicts(paths) {
35106
36123
  const metas = [];
35107
36124
  for (const id of ids) {
35108
36125
  try {
35109
- metas.push(await readJsonFile2(path18__default.join(paths.conflictsDir, id, CONFLICT_META_FILENAME)));
36126
+ metas.push(await readJsonFile2(path19__default.join(paths.conflictsDir, id, CONFLICT_META_FILENAME)));
35110
36127
  } catch {
35111
36128
  continue;
35112
36129
  }
@@ -35115,13 +36132,13 @@ async function listConflicts(paths) {
35115
36132
  }
35116
36133
  async function readConflict(conflictId, paths) {
35117
36134
  const conflictDir = resolveConflictDir(conflictId, paths);
35118
- const meta3 = await readJsonFile2(path18__default.join(conflictDir, CONFLICT_META_FILENAME));
35119
- const currentPath = path18__default.join(conflictDir, CONFLICT_CURRENT_FILENAME);
35120
- const rawSourcePath = path18__default.join(conflictDir, CONFLICT_RAW_SOURCE_FILENAME);
36135
+ const meta3 = await readJsonFile2(path19__default.join(conflictDir, CONFLICT_META_FILENAME));
36136
+ const currentPath = path19__default.join(conflictDir, CONFLICT_CURRENT_FILENAME);
36137
+ const rawSourcePath = path19__default.join(conflictDir, CONFLICT_RAW_SOURCE_FILENAME);
35121
36138
  return {
35122
36139
  meta: meta3,
35123
36140
  current: await pathExists(currentPath) ? await readPatchFile(currentPath) : void 0,
35124
- proposed: await readPatchFile(path18__default.join(conflictDir, CONFLICT_PROPOSED_FILENAME)),
36141
+ proposed: await readPatchFile(path19__default.join(conflictDir, CONFLICT_PROPOSED_FILENAME)),
35125
36142
  rawSource: await pathExists(rawSourcePath) ? await readPatchFile(rawSourcePath) : void 0
35126
36143
  };
35127
36144
  }
@@ -35140,9 +36157,9 @@ function sanitizeConflictToken(value) {
35140
36157
  return value.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64) || "unknown";
35141
36158
  }
35142
36159
  function resolveConflictDir(conflictId, paths) {
35143
- const conflictDir = path18__default.resolve(paths.conflictsDir, conflictId);
35144
- const relative = path18__default.relative(paths.conflictsDir, conflictDir);
35145
- if (!relative || relative.startsWith("..") || path18__default.isAbsolute(relative)) {
36160
+ const conflictDir = path19__default.resolve(paths.conflictsDir, conflictId);
36161
+ const relative = path19__default.relative(paths.conflictsDir, conflictDir);
36162
+ if (!relative || relative.startsWith("..") || path19__default.isAbsolute(relative)) {
35146
36163
  throw new Error(`[fleet-wiki] conflict id escapes conflicts/: ${conflictId}`);
35147
36164
  }
35148
36165
  return conflictDir;
@@ -35306,11 +36323,11 @@ async function validatePatch(patch, paths) {
35306
36323
  if (!target2 || !summary || !proposer || !created) throw new Error("patch frontmatter is incomplete");
35307
36324
  if (summary.length > 120) throw new Error("patch summary exceeds 120 chars");
35308
36325
  assertCanonicalPatchTarget(target2);
35309
- const absoluteTarget = path18__default.resolve(paths.root, target2);
35310
- if (!absoluteTarget.startsWith(`${paths.root}${path18__default.sep}`) && absoluteTarget !== paths.root) {
36326
+ const absoluteTarget = path19__default.resolve(paths.root, target2);
36327
+ if (!absoluteTarget.startsWith(`${paths.root}${path19__default.sep}`) && absoluteTarget !== paths.root) {
35311
36328
  throw new Error("patch target escapes wiki root");
35312
36329
  }
35313
- if (!absoluteTarget.startsWith(`${paths.wikiDir}${path18__default.sep}`)) throw new Error("wiki patch must target wiki/");
36330
+ if (!absoluteTarget.startsWith(`${paths.wikiDir}${path19__default.sep}`)) throw new Error("wiki patch must target wiki/");
35314
36331
  assertNoSymlinkPathComponents(target2, paths);
35315
36332
  if (op === "create_wiki" && await pathExists(absoluteTarget)) {
35316
36333
  throw new Error(
@@ -35331,19 +36348,19 @@ async function applyPatch(patch, paths) {
35331
36348
  async function enqueuePatch(patch, paths, metaOverrides) {
35332
36349
  await ensureMemoryRoot(paths);
35333
36350
  const patchId = buildPatchId(patch.frontmatter.created, patch.frontmatter.summary, patch.frontmatter.target, patch.body);
35334
- const queueDir = path18__default.join(paths.queueDir, patchId);
36351
+ const queueDir = path19__default.join(paths.queueDir, patchId);
35335
36352
  if (await pathExists(queueDir)) {
35336
36353
  throw new Error(`[fleet-wiki] patch id collision: ${patchId} - this should never happen with target+body hashing`);
35337
36354
  }
35338
36355
  await mkdir$1(queueDir, { recursive: true });
35339
- await writePatchFile(path18__default.join(queueDir, PATCH_FILENAME), serializePatch(patch), paths);
36356
+ await writePatchFile(path19__default.join(queueDir, PATCH_FILENAME), serializePatch(patch), paths);
35340
36357
  const meta3 = {
35341
36358
  id: patchId,
35342
36359
  status: "pending",
35343
36360
  createdAt: patch.frontmatter.created,
35344
36361
  ...metaOverrides
35345
36362
  };
35346
- await writeJsonFile(path18__default.join(queueDir, PATCH_META_FILENAME), meta3, paths);
36363
+ await writeJsonFile(path19__default.join(queueDir, PATCH_META_FILENAME), meta3, paths);
35347
36364
  await appendLog(paths, "patch enqueued", {
35348
36365
  patch_id: patchId,
35349
36366
  patch_set_id: meta3.patch_set_id ?? null,
@@ -35361,7 +36378,7 @@ async function listQueue(paths) {
35361
36378
  for (const id of ids) {
35362
36379
  if (id === "_sets") continue;
35363
36380
  try {
35364
- const meta3 = await readJsonFile2(path18__default.join(paths.queueDir, id, PATCH_META_FILENAME));
36381
+ const meta3 = await readJsonFile2(path19__default.join(paths.queueDir, id, PATCH_META_FILENAME));
35365
36382
  results.push({ id, meta: meta3 });
35366
36383
  } catch {
35367
36384
  continue;
@@ -35386,17 +36403,17 @@ async function resolveQueueSelection(id, paths) {
35386
36403
  }
35387
36404
  async function showQueue(id, paths) {
35388
36405
  const selection = await resolveQueueSelection(id, paths);
35389
- const queueDir = path18__default.join(paths.queueDir, selection.id);
35390
- const patch = await parsePatch(await readPatchFile(path18__default.join(queueDir, PATCH_FILENAME)));
35391
- const meta3 = await readJsonFile2(path18__default.join(queueDir, PATCH_META_FILENAME));
36406
+ const queueDir = path19__default.join(paths.queueDir, selection.id);
36407
+ const patch = await parsePatch(await readPatchFile(path19__default.join(queueDir, PATCH_FILENAME)));
36408
+ const meta3 = await readJsonFile2(path19__default.join(queueDir, PATCH_META_FILENAME));
35392
36409
  return { patch, meta: meta3 };
35393
36410
  }
35394
36411
  async function rewriteQueuedPatch(id, paths, patch, meta3, expectedPatchHash) {
35395
36412
  assertSafeQueueId(id);
35396
36413
  return withPatchEditLock(paths, id, async () => {
35397
- const queueDir = path18__default.join(paths.queueDir, id);
36414
+ const queueDir = path19__default.join(paths.queueDir, id);
35398
36415
  if (expectedPatchHash !== void 0) {
35399
- const currentMarkdown = await readPatchFile(path18__default.join(queueDir, PATCH_FILENAME));
36416
+ const currentMarkdown = await readPatchFile(path19__default.join(queueDir, PATCH_FILENAME));
35400
36417
  const currentHash = computeContentHash(currentMarkdown);
35401
36418
  if (currentHash !== expectedPatchHash) {
35402
36419
  throw new Error(`[fleet-wiki] wiki_patch_edit stale base_patch_hash: expected ${currentHash}, got ${expectedPatchHash}`);
@@ -35405,8 +36422,8 @@ async function rewriteQueuedPatch(id, paths, patch, meta3, expectedPatchHash) {
35405
36422
  const patchMarkdown = serializePatch(patch);
35406
36423
  const patchHash = computeContentHash(patchMarkdown);
35407
36424
  const nextMeta = { ...meta3, lastEditHash: patchHash };
35408
- await writePatchFile(path18__default.join(queueDir, PATCH_FILENAME), patchMarkdown, paths);
35409
- await writeJsonFile(path18__default.join(queueDir, PATCH_META_FILENAME), nextMeta, paths);
36425
+ await writePatchFile(path19__default.join(queueDir, PATCH_FILENAME), patchMarkdown, paths);
36426
+ await writeJsonFile(path19__default.join(queueDir, PATCH_META_FILENAME), nextMeta, paths);
35410
36427
  return patchHash;
35411
36428
  });
35412
36429
  }
@@ -35430,8 +36447,8 @@ async function approvePatch(id, paths) {
35430
36447
  rawSourceRef: meta3.rawSourceRef,
35431
36448
  warnings: meta3.warnings
35432
36449
  });
35433
- const queueDir = path18__default.join(paths.queueDir, id);
35434
- await writeJsonFile(path18__default.join(queueDir, PATCH_META_FILENAME), {
36450
+ const queueDir = path19__default.join(paths.queueDir, id);
36451
+ await writeJsonFile(path19__default.join(queueDir, PATCH_META_FILENAME), {
35435
36452
  ...meta3,
35436
36453
  conflictId
35437
36454
  }, paths);
@@ -35467,7 +36484,7 @@ async function approvePatchSet(patchSetId, paths) {
35467
36484
  const failed = [];
35468
36485
  const missing = [];
35469
36486
  for (const patchId of patchSet.patchIds) {
35470
- const queueDir = path18__default.join(paths.queueDir, patchId);
36487
+ const queueDir = path19__default.join(paths.queueDir, patchId);
35471
36488
  if (!await pathExists(queueDir)) {
35472
36489
  missing.push(patchId);
35473
36490
  continue;
@@ -35533,7 +36550,7 @@ ${patch.body}`;
35533
36550
  }
35534
36551
  async function normalizeWikiEntryPatch(entry, target2, paths) {
35535
36552
  assertSafeEntryId(entry.id);
35536
- if (entry.id !== path18__default.basename(target2, ".md")) {
36553
+ if (entry.id !== path19__default.basename(target2, ".md")) {
35537
36554
  throw new Error("wiki patch body id must match target filename");
35538
36555
  }
35539
36556
  const inlineRawSourceRef = extractInlineRawSourceRef(entry.body);
@@ -35576,9 +36593,9 @@ function buildPatchId(createdAt, summary, target2, body) {
35576
36593
  }
35577
36594
  async function validatePatchBase(patch, meta3, paths) {
35578
36595
  if (patch.frontmatter.op !== "update_wiki" || !meta3?.baseVersion && !meta3?.baseHash) return;
35579
- const wikiId = path18__default.basename(patch.frontmatter.target, ".md");
36596
+ const wikiId = path19__default.basename(patch.frontmatter.target, ".md");
35580
36597
  const currentEntry = await readWikiEntry(wikiId, paths);
35581
- const currentPath = path18__default.join(paths.root, patch.frontmatter.target);
36598
+ const currentPath = path19__default.join(paths.root, patch.frontmatter.target);
35582
36599
  const currentMarkdown = await pathExists(currentPath) ? await readPatchFile(currentPath) : void 0;
35583
36600
  if (meta3.baseVersion !== void 0 && currentEntry?.version !== meta3.baseVersion) {
35584
36601
  throw new Error(
@@ -35637,17 +36654,17 @@ function assertCanonicalPatchTarget(target2) {
35637
36654
  if (target2.endsWith("/")) {
35638
36655
  throw new Error("patch target must not end with a slash");
35639
36656
  }
35640
- if (target2.startsWith("/") || path18__default.posix.isAbsolute(target2) || path18__default.win32.isAbsolute(target2)) {
36657
+ if (target2.startsWith("/") || path19__default.posix.isAbsolute(target2) || path19__default.win32.isAbsolute(target2)) {
35641
36658
  throw new Error("patch target must be relative");
35642
36659
  }
35643
- if (path18__default.posix.normalize(target2) !== target2) {
36660
+ if (path19__default.posix.normalize(target2) !== target2) {
35644
36661
  throw new Error("patch target must not contain dot segments or redundant separators");
35645
36662
  }
35646
36663
  }
35647
36664
  function canonicalApprovalLockKey(paths, target2) {
35648
36665
  const wikiRoot = realpathSync(paths.wikiDir);
35649
- const relativeTarget = path18__default.posix.relative("wiki", target2);
35650
- const targetPath = path18__default.join(wikiRoot, ...relativeTarget.split("/"));
36666
+ const relativeTarget = path19__default.posix.relative("wiki", target2);
36667
+ const targetPath = path19__default.join(wikiRoot, ...relativeTarget.split("/"));
35651
36668
  return `${wikiRoot}\0${targetPath}`.toLowerCase();
35652
36669
  }
35653
36670
  function canonicalPatchEditLockKey(paths, patchId) {
@@ -35663,7 +36680,7 @@ function assertNoSymlinkPathComponents(target2, paths) {
35663
36680
  throw error51;
35664
36681
  }
35665
36682
  for (const part of parts) {
35666
- current = path18__default.join(current, part);
36683
+ current = path19__default.join(current, part);
35667
36684
  try {
35668
36685
  if (lstatSync(current).isSymbolicLink()) {
35669
36686
  throw new Error("patch target must not include symlink path components");
@@ -35678,8 +36695,8 @@ function assertSafeRawSourceRef(rawSourceRef, paths) {
35678
36695
  if (!rawSourceRef.startsWith("raw/")) {
35679
36696
  throw new Error("raw source provenance must point into raw/");
35680
36697
  }
35681
- const absoluteRef = path18__default.resolve(paths.root, rawSourceRef);
35682
- if (!absoluteRef.startsWith(`${paths.rawDir}${path18__default.sep}`)) {
36698
+ const absoluteRef = path19__default.resolve(paths.root, rawSourceRef);
36699
+ if (!absoluteRef.startsWith(`${paths.rawDir}${path19__default.sep}`)) {
35683
36700
  throw new Error("raw source provenance must point into raw/");
35684
36701
  }
35685
36702
  }
@@ -35695,14 +36712,14 @@ function classifyPatchConflict(error51) {
35695
36712
  }
35696
36713
  async function recordPatchConflict(patch, paths, reason, options) {
35697
36714
  const now = /* @__PURE__ */ new Date();
35698
- const targetPath = path18__default.join(paths.root, patch.frontmatter.target);
36715
+ const targetPath = path19__default.join(paths.root, patch.frontmatter.target);
35699
36716
  const current = await pathExists(targetPath) ? await readPatchFile(targetPath) : void 0;
35700
36717
  const currentEntry = current ? parseStoredWikiEntry(current) : void 0;
35701
36718
  const proposedEntry = parsePatchBodyEntry(patch.body);
35702
36719
  const record7 = await createConflict({
35703
36720
  reason,
35704
36721
  target: patch.frontmatter.target,
35705
- wikiId: proposedEntry?.id ?? path18__default.basename(patch.frontmatter.target, ".md"),
36722
+ wikiId: proposedEntry?.id ?? path19__default.basename(patch.frontmatter.target, ".md"),
35706
36723
  title: proposedEntry?.title,
35707
36724
  proposer: patch.frontmatter.proposer,
35708
36725
  rawSourceRef: options?.rawSourceRef,
@@ -35814,11 +36831,11 @@ function parseInlineArray(value) {
35814
36831
  return inner.split(",").map((item) => decodeFrontmatter(item.trim().replace(/^"(.*)"$/, "$1")));
35815
36832
  }
35816
36833
  async function archiveQueueEntry(id, paths, meta3) {
35817
- const fromDir = path18__default.join(paths.queueDir, id);
35818
- const toDir = path18__default.join(paths.archiveDir, id);
36834
+ const fromDir = path19__default.join(paths.queueDir, id);
36835
+ const toDir = path19__default.join(paths.archiveDir, id);
35819
36836
  await removePath(toDir);
35820
36837
  await movePath(fromDir, toDir);
35821
- await writeJsonFile(path18__default.join(toDir, PATCH_META_FILENAME), meta3, paths);
36838
+ await writeJsonFile(path19__default.join(toDir, PATCH_META_FILENAME), meta3, paths);
35822
36839
  }
35823
36840
  function buildQueueIdHelp(prefix, availableIds) {
35824
36841
  if (availableIds.length === 0) {
@@ -35850,15 +36867,15 @@ var PATCH_SET_DIRNAME = "_sets";
35850
36867
  var PATCH_SET_META_FILENAME = PATCH_META_FILENAME;
35851
36868
  function getPatchSetDir(paths, patchSetId) {
35852
36869
  assertSafePatchSetId(patchSetId);
35853
- const patchSetDir = path18__default.join(paths.queueDir, PATCH_SET_DIRNAME, patchSetId);
35854
- const relative = path18__default.relative(path18__default.join(paths.queueDir, PATCH_SET_DIRNAME), patchSetDir);
35855
- if (!relative || relative.startsWith("..") || path18__default.isAbsolute(relative)) {
36870
+ const patchSetDir = path19__default.join(paths.queueDir, PATCH_SET_DIRNAME, patchSetId);
36871
+ const relative = path19__default.relative(path19__default.join(paths.queueDir, PATCH_SET_DIRNAME), patchSetDir);
36872
+ if (!relative || relative.startsWith("..") || path19__default.isAbsolute(relative)) {
35856
36873
  throw new Error(`[fleet-wiki] patch set id escapes queue/_sets: ${patchSetId}`);
35857
36874
  }
35858
36875
  return patchSetDir;
35859
36876
  }
35860
36877
  function getPatchSetMetaFile(paths, patchSetId) {
35861
- return path18__default.join(getPatchSetDir(paths, patchSetId), PATCH_SET_META_FILENAME);
36878
+ return path19__default.join(getPatchSetDir(paths, patchSetId), PATCH_SET_META_FILENAME);
35862
36879
  }
35863
36880
  function buildPatchSetId(createdAt, sourceRef) {
35864
36881
  const compact = createdAt.replace(/[:.]/g, "-");
@@ -35917,12 +36934,12 @@ async function readWikiEntry(id, paths) {
35917
36934
  const index = await loadIndex(paths);
35918
36935
  const indexed = index[id];
35919
36936
  if (indexed) {
35920
- const resolved = path18__default.resolve(paths.root, indexed.path);
35921
- const rel = path18__default.relative(paths.wikiDir, resolved);
35922
- if (!rel || rel.startsWith("..") || path18__default.isAbsolute(rel)) return null;
36937
+ const resolved = path19__default.resolve(paths.root, indexed.path);
36938
+ const rel = path19__default.relative(paths.wikiDir, resolved);
36939
+ if (!rel || rel.startsWith("..") || path19__default.isAbsolute(rel)) return null;
35923
36940
  return readMarkdownFile(resolved);
35924
36941
  }
35925
- const fallbackPath = path18__default.join(paths.wikiDir, `${id}.md`);
36942
+ const fallbackPath = path19__default.join(paths.wikiDir, `${id}.md`);
35926
36943
  if (await pathExists(fallbackPath)) {
35927
36944
  return readMarkdownFile(fallbackPath);
35928
36945
  }
@@ -35933,20 +36950,20 @@ async function readWikiEntry(id, paths) {
35933
36950
  async function writeWikiEntryAtTarget(entry, target2, paths) {
35934
36951
  await ensureMemoryRoot(paths);
35935
36952
  assertSafeEntryId(entry.id);
35936
- const absoluteTarget = path18__default.resolve(paths.root, target2);
35937
- const relativeTarget = path18__default.relative(paths.wikiDir, absoluteTarget);
35938
- if (!relativeTarget || relativeTarget.startsWith("..") || path18__default.isAbsolute(relativeTarget)) {
36953
+ const absoluteTarget = path19__default.resolve(paths.root, target2);
36954
+ const relativeTarget = path19__default.relative(paths.wikiDir, absoluteTarget);
36955
+ if (!relativeTarget || relativeTarget.startsWith("..") || path19__default.isAbsolute(relativeTarget)) {
35939
36956
  throw new Error(`[fleet-wiki] wiki target escapes wiki/: ${target2}`);
35940
36957
  }
35941
36958
  if (!absoluteTarget.endsWith(".md")) {
35942
36959
  throw new Error(`[fleet-wiki] wiki target must end with .md: ${target2}`);
35943
36960
  }
35944
- if (path18__default.basename(absoluteTarget, ".md") !== entry.id) {
36961
+ if (path19__default.basename(absoluteTarget, ".md") !== entry.id) {
35945
36962
  throw new Error("wiki patch body id must match target filename");
35946
36963
  }
35947
- await mkdir$1(path18__default.dirname(absoluteTarget), { recursive: true });
36964
+ await mkdir$1(path19__default.dirname(absoluteTarget), { recursive: true });
35948
36965
  await writeAtomic(absoluteTarget, serializeWikiEntry(entry), paths);
35949
- return path18__default.join("wiki", relativeTarget).replaceAll(path18__default.sep, "/");
36966
+ return path19__default.join("wiki", relativeTarget).replaceAll(path19__default.sep, "/");
35950
36967
  }
35951
36968
  async function writeRawSourceEntry(entry, paths) {
35952
36969
  await ensureMemoryRoot(paths);
@@ -35965,11 +36982,11 @@ async function writeRawSourceEntry(entry, paths) {
35965
36982
  },
35966
36983
  entry.content
35967
36984
  );
35968
- await writeAtomic(path18__default.join(paths.root, relativePath), content, paths);
36985
+ await writeAtomic(path19__default.join(paths.root, relativePath), content, paths);
35969
36986
  return relativePath;
35970
36987
  }
35971
36988
  async function readRawSourceEntry(rawSourceRef, paths) {
35972
- const absolutePath = path18__default.resolve(paths.root, rawSourceRef);
36989
+ const absolutePath = path19__default.resolve(paths.root, rawSourceRef);
35973
36990
  assertWithinRawDir(absolutePath, paths);
35974
36991
  const parsed = parseMarkdown(await readFile(absolutePath, "utf8"));
35975
36992
  return {
@@ -36160,8 +37177,8 @@ function computeContentHash(content) {
36160
37177
  return crypto5.createHash("sha256").update(content, "utf8").digest("hex").slice(0, 8);
36161
37178
  }
36162
37179
  function assertWithinRawDir(absolutePath, paths) {
36163
- const relative = path18__default.relative(paths.rawDir, absolutePath);
36164
- if (!relative || relative.startsWith("..") || path18__default.isAbsolute(relative)) {
37180
+ const relative = path19__default.relative(paths.rawDir, absolutePath);
37181
+ if (!relative || relative.startsWith("..") || path19__default.isAbsolute(relative)) {
36165
37182
  throw new Error(`[fleet-wiki] raw source ref escapes raw/: ${absolutePath}`);
36166
37183
  }
36167
37184
  }
@@ -36217,7 +37234,7 @@ function parseWikiEntry(content) {
36217
37234
  async function listWikiRecords(paths) {
36218
37235
  return listMarkdownEntriesRecursive(paths.wikiDir, paths, (content, filePath) => ({
36219
37236
  entry: parseWikiEntry(content),
36220
- path: path18__default.relative(paths.root, filePath).replaceAll(path18__default.sep, "/")
37237
+ path: path19__default.relative(paths.root, filePath).replaceAll(path19__default.sep, "/")
36221
37238
  }));
36222
37239
  }
36223
37240
  async function listMarkdownEntriesRecursive(dirPath, paths, parser) {
@@ -36230,7 +37247,7 @@ async function listMarkdownEntriesRecursive(dirPath, paths, parser) {
36230
37247
  }
36231
37248
  const sortedEntries = entries.sort((left, right) => left.name.localeCompare(right.name));
36232
37249
  for (const entry of sortedEntries) {
36233
- const filePath = path18__default.join(dirPath, entry.name);
37250
+ const filePath = path19__default.join(dirPath, entry.name);
36234
37251
  if (entry.isDirectory()) {
36235
37252
  items.push(...await listMarkdownEntriesRecursive(filePath, paths, parser));
36236
37253
  continue;
@@ -36365,8 +37382,8 @@ async function writeJsonAtomic(filePath, value, paths) {
36365
37382
  }
36366
37383
  async function writeAtomic(filePath, content, paths) {
36367
37384
  await ensureMemoryRoot(paths);
36368
- const tempPath = path18__default.join(
36369
- path18__default.dirname(filePath),
37385
+ const tempPath = path19__default.join(
37386
+ path19__default.dirname(filePath),
36370
37387
  `.tmp-${process.pid}-${Date.now()}-${crypto5.randomUUID()}-${os3__default.hostname()}`
36371
37388
  );
36372
37389
  await writeFile(tempPath, content, "utf8");
@@ -36447,7 +37464,7 @@ function extractLegacyMarkdownWikiLinks(body, wikiDir, basePath) {
36447
37464
  }
36448
37465
  function resolveLegacyWikiTarget(target2, wikiDir, basePath) {
36449
37466
  if (!target2 || target2.startsWith("#")) return null;
36450
- if (path18__default.isAbsolute(target2)) return null;
37467
+ if (path19__default.isAbsolute(target2)) return null;
36451
37468
  if (/^[a-z][a-z0-9+.-]*:/i.test(target2)) return null;
36452
37469
  const withoutFragment = target2.split("#", 1)[0]?.split("?", 1)[0] ?? "";
36453
37470
  if (!withoutFragment.endsWith(".md")) return null;
@@ -36457,12 +37474,12 @@ function resolveLegacyWikiTarget(target2, wikiDir, basePath) {
36457
37474
  } catch {
36458
37475
  return null;
36459
37476
  }
36460
- const resolved = path18__default.resolve(path18__default.dirname(basePath), decodedTarget);
36461
- const relative = path18__default.relative(wikiDir, resolved);
36462
- if (!relative || relative.startsWith("..") || path18__default.isAbsolute(relative)) return null;
37477
+ const resolved = path19__default.resolve(path19__default.dirname(basePath), decodedTarget);
37478
+ const relative = path19__default.relative(wikiDir, resolved);
37479
+ if (!relative || relative.startsWith("..") || path19__default.isAbsolute(relative)) return null;
36463
37480
  return {
36464
37481
  target: target2,
36465
- entryId: path18__default.basename(relative, ".md")
37482
+ entryId: path19__default.basename(relative, ".md")
36466
37483
  };
36467
37484
  }
36468
37485
  var FLEET_WIKI_ENTRY_BEGIN = "<<<FLEET_WIKI_ENTRY_BEGIN";
@@ -36529,7 +37546,7 @@ async function enhancedSearch(paths, options) {
36529
37546
  for (const entry of entries) {
36530
37547
  if (!index[entry.id]) {
36531
37548
  index[entry.id] = {
36532
- path: path18__default.join("wiki", `${entry.id}.md`),
37549
+ path: path19__default.join("wiki", `${entry.id}.md`),
36533
37550
  title: entry.title,
36534
37551
  tags: entry.tags,
36535
37552
  updated: entry.updated
@@ -36665,7 +37682,7 @@ function toEnhancedHit(entry, signals) {
36665
37682
  score: enhancedScore,
36666
37683
  reason: signals.legacyReason ?? "body",
36667
37684
  excerpt,
36668
- path: path18__default.join("wiki", `${entry.id}.md`),
37685
+ path: path19__default.join("wiki", `${entry.id}.md`),
36669
37686
  tags: entry.tags,
36670
37687
  updated: entry.updated,
36671
37688
  version: entry.version,
@@ -36861,7 +37878,7 @@ function toRankedHit(entry, reason, detail, graphBoost, backlinksById) {
36861
37878
  score: basePriority * 100 + statusPriority * 10 + graphScore + (detail.tagBoost ?? 0),
36862
37879
  reason,
36863
37880
  excerpt,
36864
- path: path18__default.join("wiki", `${entry.id}.md`),
37881
+ path: path19__default.join("wiki", `${entry.id}.md`),
36865
37882
  tags: entry.tags,
36866
37883
  updated: entry.updated,
36867
37884
  version: entry.version,
@@ -41627,13 +42644,13 @@ async function readClaims(entryId, paths) {
41627
42644
  }
41628
42645
  }
41629
42646
  function getClaimsDir(paths) {
41630
- return path18__default.join(paths.wikiDir, CLAIMS_DIRNAME);
42647
+ return path19__default.join(paths.wikiDir, CLAIMS_DIRNAME);
41631
42648
  }
41632
42649
  function getClaimsFile(paths, entryId) {
41633
42650
  assertSafeEntryId(entryId);
41634
- const claimsFile = path18__default.join(getClaimsDir(paths), `${entryId}.json`);
41635
- const relative = path18__default.relative(getClaimsDir(paths), claimsFile);
41636
- if (!relative || relative.startsWith("..") || path18__default.isAbsolute(relative)) {
42651
+ const claimsFile = path19__default.join(getClaimsDir(paths), `${entryId}.json`);
42652
+ const relative = path19__default.relative(getClaimsDir(paths), claimsFile);
42653
+ if (!relative || relative.startsWith("..") || path19__default.isAbsolute(relative)) {
41637
42654
  throw new Error(`[fleet-wiki] claims sidecar escapes wiki/.claims: ${entryId}`);
41638
42655
  }
41639
42656
  return claimsFile;
@@ -41724,7 +42741,7 @@ function assertSafeClaimRawRef(ref) {
41724
42741
  if (!ref.startsWith("raw/")) {
41725
42742
  throw new Error(`claim sourceRef must point into raw/: ${ref}`);
41726
42743
  }
41727
- if (ref.includes("..") || path18__default.isAbsolute(ref)) {
42744
+ if (ref.includes("..") || path19__default.isAbsolute(ref)) {
41728
42745
  throw new Error(`claim sourceRef escapes raw/: ${ref}`);
41729
42746
  }
41730
42747
  }
@@ -41802,22 +42819,22 @@ async function runDryDock(paths, options = {}) {
41802
42819
  }
41803
42820
  for (const fileName of await listFileNames(paths.rawDir)) {
41804
42821
  if (!fileName.endsWith(".md")) continue;
41805
- const filePath = path18__default.join(paths.rawDir, fileName);
42822
+ const filePath = path19__default.join(paths.rawDir, fileName);
41806
42823
  issues.push(...safetyIssues(await readPatchFile(filePath), filePath));
41807
42824
  }
41808
42825
  for (const queueId of await listDirectoryNames(paths.queueDir)) {
41809
42826
  if (queueId === PATCH_SET_DIRNAME) continue;
41810
- const queueDir = path18__default.join(paths.queueDir, queueId);
42827
+ const queueDir = path19__default.join(paths.queueDir, queueId);
41811
42828
  try {
41812
- const patchContent = await readPatchFile(path18__default.join(queueDir, PATCH_FILENAME));
41813
- issues.push(...safetyIssues(patchContent, path18__default.join(queueDir, PATCH_FILENAME)));
41814
- await readJsonFile2(path18__default.join(queueDir, PATCH_META_FILENAME));
42829
+ const patchContent = await readPatchFile(path19__default.join(queueDir, PATCH_FILENAME));
42830
+ issues.push(...safetyIssues(patchContent, path19__default.join(queueDir, PATCH_FILENAME)));
42831
+ await readJsonFile2(path19__default.join(queueDir, PATCH_META_FILENAME));
41815
42832
  } catch {
41816
42833
  issues.push(issue2("malformed_queue", "error", "\uC190\uC0C1\uB41C queue \uC5D4\uD2B8\uB9AC", queueDir));
41817
42834
  }
41818
42835
  }
41819
- for (const patchSetId of await listDirectoryNames(path18__default.join(paths.queueDir, PATCH_SET_DIRNAME))) {
41820
- const patchSetMetaFile = path18__default.join(paths.queueDir, PATCH_SET_DIRNAME, patchSetId, PATCH_META_FILENAME);
42836
+ for (const patchSetId of await listDirectoryNames(path19__default.join(paths.queueDir, PATCH_SET_DIRNAME))) {
42837
+ const patchSetMetaFile = path19__default.join(paths.queueDir, PATCH_SET_DIRNAME, patchSetId, PATCH_META_FILENAME);
41821
42838
  let patchSet;
41822
42839
  try {
41823
42840
  patchSet = await readPatchSet(paths, patchSetId);
@@ -41826,8 +42843,8 @@ async function runDryDock(paths, options = {}) {
41826
42843
  continue;
41827
42844
  }
41828
42845
  for (const patchId of patchSet.patchIds) {
41829
- const queueMetaFile = path18__default.join(paths.queueDir, patchId, PATCH_META_FILENAME);
41830
- const archiveMetaFile = path18__default.join(paths.archiveDir, patchId, PATCH_META_FILENAME);
42846
+ const queueMetaFile = path19__default.join(paths.queueDir, patchId, PATCH_META_FILENAME);
42847
+ const archiveMetaFile = path19__default.join(paths.archiveDir, patchId, PATCH_META_FILENAME);
41831
42848
  if (!await pathExists(queueMetaFile) && !await pathExists(archiveMetaFile)) {
41832
42849
  issues.push(
41833
42850
  issue2(
@@ -41864,7 +42881,7 @@ async function runDryDock(paths, options = {}) {
41864
42881
  "conflict_unresolved",
41865
42882
  "warning",
41866
42883
  `\uBBF8\uD574\uACB0 conflict: ${conflict.reason} (${conflict.target})`,
41867
- path18__default.join(paths.conflictsDir, conflict.id, "meta.json")
42884
+ path19__default.join(paths.conflictsDir, conflict.id, "meta.json")
41868
42885
  )
41869
42886
  );
41870
42887
  }
@@ -41877,7 +42894,7 @@ async function runDryDock(paths, options = {}) {
41877
42894
  "unresolved_conflict",
41878
42895
  "warning",
41879
42896
  "\uC190\uC0C1\uB41C conflict \uC5D4\uD2B8\uB9AC",
41880
- path18__default.join(paths.conflictsDir, conflictId, "meta.json")
42897
+ path19__default.join(paths.conflictsDir, conflictId, "meta.json")
41881
42898
  )
41882
42899
  );
41883
42900
  }
@@ -41934,8 +42951,8 @@ async function claimIssues(paths, wikiIds) {
41934
42951
  const claimsDir = getClaimsDir(paths);
41935
42952
  for (const fileName of await listFileNames(claimsDir)) {
41936
42953
  if (!fileName.endsWith(".json")) continue;
41937
- const filePath = path18__default.join(claimsDir, fileName);
41938
- const entryIdFromFile = path18__default.basename(fileName, ".json");
42954
+ const filePath = path19__default.join(claimsDir, fileName);
42955
+ const entryIdFromFile = path19__default.basename(fileName, ".json");
41939
42956
  let raw;
41940
42957
  try {
41941
42958
  raw = await readJsonFile2(filePath);
@@ -42014,7 +43031,7 @@ function toSemanticEntry(filePath, frontmatter, body) {
42014
43031
  async function schemaIssues(paths) {
42015
43032
  const issues = [];
42016
43033
  const schema = await readWorkspaceSchemaSummary(paths);
42017
- const agentsPath = path18__default.join(paths.schemaDir, WORKSPACE_SCHEMA_AGENTS_FILENAME);
43034
+ const agentsPath = path19__default.join(paths.schemaDir, WORKSPACE_SCHEMA_AGENTS_FILENAME);
42018
43035
  if (!await pathExists(schema.wikiSchemaPath)) {
42019
43036
  issues.push(issue2("schema_missing", "warning", `Workspace schema file is missing: schema/${WORKSPACE_SCHEMA_FILENAME}`, schema.wikiSchemaPath));
42020
43037
  } else {
@@ -42401,7 +43418,7 @@ async function listWikiMarkdownFiles(dirPath) {
42401
43418
  const files = [];
42402
43419
  const sortedEntries = entries.sort((left, right) => left.name.localeCompare(right.name));
42403
43420
  for (const entry of sortedEntries) {
42404
- const filePath = path18__default.join(dirPath, entry.name);
43421
+ const filePath = path19__default.join(dirPath, entry.name);
42405
43422
  if (entry.isDirectory()) {
42406
43423
  files.push(...await listWikiMarkdownFiles(filePath));
42407
43424
  continue;
@@ -42625,7 +43642,7 @@ async function resolveCompileSource(input, paths, now) {
42625
43642
  }
42626
43643
  async function buildCompileProposals(input, paths, now, resolvedSource) {
42627
43644
  const sourceTarget = `wiki/sources/${resolvedSource.sourcePageId}.md`;
42628
- const sourceExists = await pathExists(path18__default.join(paths.root, sourceTarget));
43645
+ const sourceExists = await pathExists(path19__default.join(paths.root, sourceTarget));
42629
43646
  const existingEntries = await listWiki(paths);
42630
43647
  const sourcePageTitle = resolvedSource.sourceTitle?.trim() || `Source ${resolvedSource.sourcePageId}`;
42631
43648
  const existingSourceEntry = existingEntries.find((entry) => entry.id === resolvedSource.sourcePageId);
@@ -42647,7 +43664,7 @@ async function buildCompileProposals(input, paths, now, resolvedSource) {
42647
43664
  target: sourceTarget,
42648
43665
  summary: truncateSummary(`Compile source page ${sourcePageTitle}`),
42649
43666
  entry: sourceEntry,
42650
- baseHash: sourceExists ? computeContentHash(await readPatchFile(path18__default.join(paths.root, sourceTarget))) : void 0,
43667
+ baseHash: sourceExists ? computeContentHash(await readPatchFile(path19__default.join(paths.root, sourceTarget))) : void 0,
42651
43668
  baseVersion: existingSourceEntry?.version
42652
43669
  }];
42653
43670
  const relatedCandidates = await discoverRelatedEntryCandidates(paths, resolvedSource.sourceContent, resolvedSource.sourceTitle);
@@ -42667,7 +43684,7 @@ async function buildCompileProposals(input, paths, now, resolvedSource) {
42667
43684
  rawSourceRefs: mergeRawSourceRefs(existing.rawSourceRefs, existing.rawSourceRef, { ref: resolvedSource.rawSourceRef }),
42668
43685
  body: appendSourceCompileNote(existing.body, resolvedSource.sourcePageId, resolvedSource.rawSourceRef)
42669
43686
  },
42670
- baseHash: computeContentHash(await readPatchFile(path18__default.join(paths.wikiDir, `${existing.id}.md`))),
43687
+ baseHash: computeContentHash(await readPatchFile(path19__default.join(paths.wikiDir, `${existing.id}.md`))),
42671
43688
  baseVersion: existing.version
42672
43689
  });
42673
43690
  }
@@ -42841,7 +43858,7 @@ async function planIngest(input, paths, now) {
42841
43858
  const target2 = `wiki/${input.id}.md`;
42842
43859
  const proposer = input.proposer ?? "tool:wiki_ingest";
42843
43860
  const currentEntry = await readWikiEntry(input.id, paths);
42844
- const currentMarkdown = currentEntry ? await readPatchFile(path18__default.join(paths.wikiDir, `${input.id}.md`)) : void 0;
43861
+ const currentMarkdown = currentEntry ? await readPatchFile(path19__default.join(paths.wikiDir, `${input.id}.md`)) : void 0;
42845
43862
  const currentHash = currentMarkdown ? computeContentHash(currentMarkdown) : void 0;
42846
43863
  const rawSource = buildRawSourceEntry(input, now);
42847
43864
  await ensureWorkspaceSchema(paths);
@@ -43520,11 +44537,11 @@ async function editQueuedPatch(input, paths) {
43520
44537
  };
43521
44538
  }
43522
44539
  async function readQueuedPatchSnapshot(paths, patchId) {
43523
- const queueDir = path18__default.join(paths.queueDir, patchId);
43524
- const markdown = await readPatchFile(path18__default.join(queueDir, PATCH_FILENAME));
44540
+ const queueDir = path19__default.join(paths.queueDir, patchId);
44541
+ const markdown = await readPatchFile(path19__default.join(queueDir, PATCH_FILENAME));
43525
44542
  return {
43526
44543
  patch: await parsePatch(markdown),
43527
- meta: await readJsonFile2(path18__default.join(queueDir, PATCH_META_FILENAME)),
44544
+ meta: await readJsonFile2(path19__default.join(queueDir, PATCH_META_FILENAME)),
43528
44545
  patchHash: computeContentHash(markdown)
43529
44546
  };
43530
44547
  }
@@ -44286,7 +45303,7 @@ ${input.answer ?? ""}`)}`;
44286
45303
  assertSafeEntryId(targetId);
44287
45304
  const subdir = input.targetType === "synthesis" ? "synthesis" : "queries";
44288
45305
  const target2 = `wiki/${subdir}/${targetId}.md`;
44289
- const absoluteTarget = path18__default.join(paths.root, target2);
45306
+ const absoluteTarget = path19__default.join(paths.root, target2);
44290
45307
  const exists = await pathExists(absoluteTarget);
44291
45308
  const existingEntry = exists ? await readWikiEntry(targetId, paths) : null;
44292
45309
  if (exists && !existingEntry) {
@@ -44368,7 +45385,7 @@ function assertSafeRawRef(rawRef) {
44368
45385
  if (!rawRef.startsWith("raw/")) {
44369
45386
  throw new Error(`[fleet-wiki] wiki_query raw source ref must point into raw/: ${rawRef}`);
44370
45387
  }
44371
- if (rawRef.includes("..") || path18__default.isAbsolute(rawRef)) {
45388
+ if (rawRef.includes("..") || path19__default.isAbsolute(rawRef)) {
44372
45389
  throw new Error(`[fleet-wiki] wiki_query raw source ref escapes raw/: ${rawRef}`);
44373
45390
  }
44374
45391
  }
@@ -44974,16 +45991,16 @@ function createResolver(deps, hooks) {
44974
45991
  } };
44975
45992
  }
44976
45993
  function resolveLocked(workspace, hooks) {
44977
- const destination = path18__default.join(workspace.path, "knowledge");
44978
- const source = path18__default.join(workspace.cwd, ".fleet", "knowledge");
44979
- const markerPath = path18__default.join(workspace.path, MARKER_NAME);
45994
+ const destination = path19__default.join(workspace.path, "knowledge");
45995
+ const source = path19__default.join(workspace.cwd, ".fleet", "knowledge");
45996
+ const markerPath = path19__default.join(workspace.path, MARKER_NAME);
44980
45997
  const destinationState = inspectTree(destination, true);
44981
45998
  if (destinationState === "content") return createMemoryPaths(destination);
44982
45999
  if (destinationState === "unsafe") throw new Error("Unsafe Fleet Wiki destination state");
44983
46000
  const marker = readMarker(markerPath);
44984
46001
  const stagingEntries = inspectReservedControlState(workspace.path);
44985
46002
  if (marker) {
44986
- const staging2 = path18__default.join(workspace.path, `${STAGING_PREFIX}${marker.transactionId}`);
46003
+ const staging2 = path19__default.join(workspace.path, `${STAGING_PREFIX}${marker.transactionId}`);
44987
46004
  const stagingState = inspectTree(staging2);
44988
46005
  if (stagingState === "content") {
44989
46006
  removeEmptyDirectories(destination);
@@ -44998,7 +46015,7 @@ function resolveLocked(workspace, hooks) {
44998
46015
  if (sourceState !== "content") return createMemoryPaths(destination);
44999
46016
  removeEmptyDirectories(destination);
45000
46017
  const transactionId = randomUUID$1();
45001
- const staging = path18__default.join(workspace.path, `${STAGING_PREFIX}${transactionId}`);
46018
+ const staging = path19__default.join(workspace.path, `${STAGING_PREFIX}${transactionId}`);
45002
46019
  copyTree(source, staging, hooks);
45003
46020
  if (inspectTree(staging) !== "content") throw new Error("Invalid Fleet Wiki migration staging result");
45004
46021
  syncDirectory(staging);
@@ -45026,7 +46043,7 @@ function inspectTree(target2, regularRootIsContent = false, treeRoot = target2)
45026
46043
  if (nodeKind === "file") return regularRootIsContent ? "content" : "unsafe";
45027
46044
  let content = false;
45028
46045
  for (const entry of fs9.readdirSync(target2, { withFileTypes: true })) {
45029
- const entryPath = path18__default.join(target2, entry.name);
46046
+ const entryPath = path19__default.join(target2, entry.name);
45030
46047
  if (entry.isSymbolicLink()) {
45031
46048
  if (readSafeFileSymlink(treeRoot, entryPath) === null) return "unsafe";
45032
46049
  content = true;
@@ -45065,8 +46082,8 @@ function readMarker(markerPath) {
45065
46082
  function copyTree(source, destination, hooks, sourceRoot = source) {
45066
46083
  fs9.mkdirSync(destination, { recursive: true });
45067
46084
  for (const entry of fs9.readdirSync(source, { withFileTypes: true })) {
45068
- const from = path18__default.join(source, entry.name);
45069
- const to = path18__default.join(destination, entry.name);
46085
+ const from = path19__default.join(source, entry.name);
46086
+ const to = path19__default.join(destination, entry.name);
45070
46087
  const stat4 = fs9.lstatSync(from);
45071
46088
  if (stat4.isSymbolicLink()) {
45072
46089
  const target2 = readSafeFileSymlink(sourceRoot, from);
@@ -45086,9 +46103,9 @@ function copyTree(source, destination, hooks, sourceRoot = source) {
45086
46103
  }
45087
46104
  function readSafeFileSymlink(treeRoot, linkPath) {
45088
46105
  const target2 = fs9.readlinkSync(linkPath);
45089
- if (path18__default.posix.isAbsolute(target2) || path18__default.win32.isAbsolute(target2)) return null;
45090
- const lexicalRoot = path18__default.resolve(treeRoot);
45091
- const lexicalTarget = path18__default.resolve(path18__default.dirname(linkPath), target2);
46106
+ if (path19__default.posix.isAbsolute(target2) || path19__default.win32.isAbsolute(target2)) return null;
46107
+ const lexicalRoot = path19__default.resolve(treeRoot);
46108
+ const lexicalTarget = path19__default.resolve(path19__default.dirname(linkPath), target2);
45092
46109
  if (!isWithinRoot(lexicalRoot, lexicalTarget)) return null;
45093
46110
  let canonicalRoot;
45094
46111
  let canonicalTarget;
@@ -45105,8 +46122,8 @@ function readSafeFileSymlink(treeRoot, linkPath) {
45105
46122
  return target2;
45106
46123
  }
45107
46124
  function isWithinRoot(root, target2) {
45108
- const relative = path18__default.relative(root, target2);
45109
- return relative === "" || relative !== ".." && !relative.startsWith(`..${path18__default.sep}`) && !path18__default.isAbsolute(relative);
46125
+ const relative = path19__default.relative(root, target2);
46126
+ return relative === "" || relative !== ".." && !relative.startsWith(`..${path19__default.sep}`) && !path19__default.isAbsolute(relative);
45110
46127
  }
45111
46128
  function classifyWikiWorkspaceNodeForTest(stat4) {
45112
46129
  if (stat4.isSymbolicLink()) return "unsafe";
@@ -45121,13 +46138,13 @@ function removeEmptyDirectories(target2) {
45121
46138
  if (state === "empty") fs9.rmSync(target2, { recursive: true, force: false });
45122
46139
  }
45123
46140
  function removePriorStaging(workspacePath, stagingEntries) {
45124
- for (const name of stagingEntries) fs9.rmSync(path18__default.join(workspacePath, name), { recursive: true, force: false });
46141
+ for (const name of stagingEntries) fs9.rmSync(path19__default.join(workspacePath, name), { recursive: true, force: false });
45125
46142
  }
45126
46143
  function inspectReservedControlState(workspacePath) {
45127
46144
  const stagingEntries = [];
45128
46145
  for (const entry of fs9.readdirSync(workspacePath, { withFileTypes: true })) {
45129
46146
  if (entry.name.startsWith(`${MARKER_NAME}.`)) {
45130
- const residuePath = path18__default.join(workspacePath, entry.name);
46147
+ const residuePath = path19__default.join(workspacePath, entry.name);
45131
46148
  const residue = fs9.lstatSync(residuePath);
45132
46149
  if (MARKER_TEMP_REGEXP.test(entry.name) && residue.isFile() && !residue.isSymbolicLink()) {
45133
46150
  fs9.unlinkSync(residuePath);
@@ -45137,7 +46154,7 @@ function inspectReservedControlState(workspacePath) {
45137
46154
  }
45138
46155
  if (!entry.name.startsWith(STAGING_PREFIX)) continue;
45139
46156
  if (!/^[0-9a-f-]{36}$/i.test(entry.name.slice(STAGING_PREFIX.length)) || entry.isSymbolicLink() || !entry.isDirectory()) throw new Error("Unsafe Fleet Wiki migration staging state");
45140
- if (inspectTree(path18__default.join(workspacePath, entry.name)) === "unsafe") throw new Error("Unsafe Fleet Wiki migration staging state");
46157
+ if (inspectTree(path19__default.join(workspacePath, entry.name)) === "unsafe") throw new Error("Unsafe Fleet Wiki migration staging state");
45141
46158
  stagingEntries.push(entry.name);
45142
46159
  }
45143
46160
  return stagingEntries;
@@ -45225,18 +46242,18 @@ function resolveConsolePackageRequire(currentFile, fallback) {
45225
46242
  function findConsolePackageRequire(currentFile) {
45226
46243
  const explicitRoot = process.env.FLEET_CONSOLE_PACKAGE_ROOT;
45227
46244
  if (explicitRoot) {
45228
- const explicitPackageJson = path18__default.join(explicitRoot, "package.json");
46245
+ const explicitPackageJson = path19__default.join(explicitRoot, "package.json");
45229
46246
  if (isFleetConsolePackage(explicitPackageJson)) return createRequire(explicitPackageJson);
45230
46247
  }
45231
- let dir = path18__default.dirname(currentFile);
46248
+ let dir = path19__default.dirname(currentFile);
45232
46249
  while (true) {
45233
- const packageJson = path18__default.join(dir, "package.json");
46250
+ const packageJson = path19__default.join(dir, "package.json");
45234
46251
  if (isFleetConsolePackage(packageJson)) return createRequire(packageJson);
45235
- const nestedConsolePackage = path18__default.join(dir, "runtime", "fleet-console", "package.json");
46252
+ const nestedConsolePackage = path19__default.join(dir, "runtime", "fleet-console", "package.json");
45236
46253
  if (isFleetConsolePackage(nestedConsolePackage)) return createRequire(nestedConsolePackage);
45237
- const siblingConsolePackage = path18__default.join(dir, "..", "..", "fleet-console", "package.json");
46254
+ const siblingConsolePackage = path19__default.join(dir, "..", "..", "fleet-console", "package.json");
45238
46255
  if (isFleetConsolePackage(siblingConsolePackage)) return createRequire(siblingConsolePackage);
45239
- const parent = path18__default.dirname(dir);
46256
+ const parent = path19__default.dirname(dir);
45240
46257
  if (parent === dir) return null;
45241
46258
  dir = parent;
45242
46259
  }
@@ -45308,7 +46325,7 @@ function resolveUseConptyDll(platform, env) {
45308
46325
  }
45309
46326
  function loadNodePty() {
45310
46327
  const nodePtyRequire = loadNodePtyRequire(fileURLToPath(import.meta.url));
45311
- ensureNodePtySpawnHelpersExecutable(path18__default.dirname(nodePtyRequire.resolve("node-pty/package.json")));
46328
+ ensureNodePtySpawnHelpersExecutable(path19__default.dirname(nodePtyRequire.resolve("node-pty/package.json")));
45312
46329
  return nodePtyRequire("node-pty");
45313
46330
  }
45314
46331
  function loadNodePtyRequire(currentFile) {
@@ -45317,7 +46334,7 @@ function loadNodePtyRequire(currentFile) {
45317
46334
  function ensureNodePtySpawnHelpersExecutable(packageRoot, platform = process4.platform, architecture = process4.arch) {
45318
46335
  if (platform !== "darwin") return;
45319
46336
  for (const directory of ["build/Release", "build/Debug", `prebuilds/darwin-${architecture}`]) {
45320
- const helper = path18__default.join(packageRoot, directory, "spawn-helper");
46337
+ const helper = path19__default.join(packageRoot, directory, "spawn-helper");
45321
46338
  try {
45322
46339
  const stat4 = lstatSync(helper);
45323
46340
  if (!stat4.isFile() || stat4.isSymbolicLink() || (stat4.mode & 73) === 73) continue;
@@ -46050,7 +47067,7 @@ function serializeAgentCliPathsWrite(write) {
46050
47067
  return result;
46051
47068
  }
46052
47069
  function normalizeAgentCliPaths(value) {
46053
- if (!isRecord12(value) || value.version !== 1 || !isRecord12(value.paths)) {
47070
+ if (!isRecord14(value) || value.version !== 1 || !isRecord14(value.paths)) {
46054
47071
  return { version: 1, paths: {} };
46055
47072
  }
46056
47073
  const paths = {};
@@ -46065,7 +47082,7 @@ function resolveAgentCliBinary(options) {
46065
47082
  const envName = OVERRIDE_ENV_BY_COMMAND[options.cliCommand];
46066
47083
  const envOverride = envName ? options.env[envName]?.trim() : void 0;
46067
47084
  if (envOverride) {
46068
- const searchedPathEntries2 = path18__default.isAbsolute(envOverride) ? [] : readPathEntries(options.env, platform);
47085
+ const searchedPathEntries2 = path19__default.isAbsolute(envOverride) ? [] : readPathEntries(options.env, platform);
46069
47086
  const resolved2 = resolveBinarySafely(envOverride, options.env, platform);
46070
47087
  if (!resolved2) {
46071
47088
  return { resolved: void 0, source: "env", error: "path_not_found", launchPath: envOverride, searchedPathEntries: searchedPathEntries2 };
@@ -46107,7 +47124,7 @@ function applyAgentCliPathEnvOverlay(env, cliId, userPaths) {
46107
47124
  return { ...env, [envName]: userPath };
46108
47125
  }
46109
47126
  function resolveConfiguredPath(executablePath, env, platform) {
46110
- if (executablePath.includes("\0") || executablePath.startsWith("~") || !path18__default.isAbsolute(executablePath)) {
47127
+ if (executablePath.includes("\0") || executablePath.startsWith("~") || !path19__default.isAbsolute(executablePath)) {
46111
47128
  return { resolved: void 0, error: "path_not_absolute" };
46112
47129
  }
46113
47130
  let stats;
@@ -46148,10 +47165,10 @@ function validateResolvedFile(resolved, platform) {
46148
47165
  }
46149
47166
  function readPathEntries(env, platform) {
46150
47167
  const value = platform === "win32" ? env.Path ?? env.PATH ?? "" : env.PATH ?? "";
46151
- const separator = platform === "win32" ? ";" : path18__default.delimiter;
47168
+ const separator = platform === "win32" ? ";" : path19__default.delimiter;
46152
47169
  return value.split(separator).filter((entry) => entry.length > 0);
46153
47170
  }
46154
- function isRecord12(value) {
47171
+ function isRecord14(value) {
46155
47172
  return typeof value === "object" && value !== null && !Array.isArray(value);
46156
47173
  }
46157
47174
  function isNodeError(error51) {
@@ -46435,19 +47452,6 @@ function looksSecretToken(rawToken) {
46435
47452
  return token.length >= SECRET_MIN_TOKEN_LENGTH && SECRET_CHARSET_PATTERN.test(token) && /[0-9]/.test(token) && /[A-Za-z]/.test(token);
46436
47453
  }
46437
47454
 
46438
- // ../fleet-plugins/terminal/server/agent-api/attention-hook.ts
46439
- var ATTENTION_REASONS = /* @__PURE__ */ new Set([
46440
- "idle_prompt",
46441
- "permission_prompt",
46442
- "auth_success",
46443
- "elicitation_dialog",
46444
- "elicitation_complete",
46445
- "elicitation_response"
46446
- ]);
46447
- function normalizeAttentionReason(value) {
46448
- return typeof value === "string" && ATTENTION_REASONS.has(value) ? value : void 0;
46449
- }
46450
-
46451
47455
  // ../fleet-plugins/terminal/server/agent-api/background-report.ts
46452
47456
  var AGENT_BACKGROUND_TASK_TYPES = /* @__PURE__ */ new Set(["subagent", "teammate", "workflow"]);
46453
47457
  var NON_AGENT_BACKGROUND_TASK_TYPES = /* @__PURE__ */ new Set(["shell", "monitor"]);
@@ -46728,7 +47732,7 @@ function claudeGatewayModelCache(options) {
46728
47732
 
46729
47733
  // ../../packages/core-agent/src/claude/config-dir.ts
46730
47734
  function createSharedClaudeConfigHome(configDir) {
46731
- if (typeof configDir !== "string" || !path18__default.isAbsolute(configDir)) {
47735
+ if (typeof configDir !== "string" || !path19__default.isAbsolute(configDir)) {
46732
47736
  throw new TypeError("A shared Claude config home requires an absolute config directory path.");
46733
47737
  }
46734
47738
  return {
@@ -46740,9 +47744,9 @@ function createSharedClaudeConfigHome(configDir) {
46740
47744
  };
46741
47745
  }
46742
47746
  async function createIsolatedClaudeConfigDir(tempRoot = tmpdir()) {
46743
- const root = await mkdtemp(path18__default.join(tempRoot, "core-agent-claude-"));
46744
- const cachePath = path18__default.join(root, CLAUDE_GATEWAY_MODEL_CACHE_RELPATH);
46745
- await mkdir$1(path18__default.dirname(cachePath), { recursive: true, mode: 448 });
47747
+ const root = await mkdtemp(path19__default.join(tempRoot, "core-agent-claude-"));
47748
+ const cachePath = path19__default.join(root, CLAUDE_GATEWAY_MODEL_CACHE_RELPATH);
47749
+ await mkdir$1(path19__default.dirname(cachePath), { recursive: true, mode: 448 });
46746
47750
  let disposed = false;
46747
47751
  return {
46748
47752
  path: root,
@@ -47219,7 +48223,7 @@ function createClaudeExecutionEventDecoder() {
47219
48223
  const toolNames = /* @__PURE__ */ new Map();
47220
48224
  return {
47221
48225
  decode(message) {
47222
- if (!isRecord13(message)) return [];
48226
+ if (!isRecord15(message)) return [];
47223
48227
  if (message.type === "stream_event") return decodeStreamEvent(message);
47224
48228
  if (message.type === "assistant") return decodeAssistant(message, toolNames);
47225
48229
  if (message.type === "user") return decodeUser(message, toolNames);
@@ -47284,9 +48288,9 @@ function blocks(message) {
47284
48288
  return Array.isArray(content) ? content.map(record5) : [];
47285
48289
  }
47286
48290
  function record5(value) {
47287
- return isRecord13(value) ? value : {};
48291
+ return isRecord15(value) ? value : {};
47288
48292
  }
47289
- function isRecord13(value) {
48293
+ function isRecord15(value) {
47290
48294
  return value !== null && typeof value === "object" && !Array.isArray(value);
47291
48295
  }
47292
48296
 
@@ -47630,7 +48634,7 @@ function buildConsoleAutoNameHookCommand(entry) {
47630
48634
  return buildConsoleCliHookExec(entry, ["hook", "auto-name"]);
47631
48635
  }
47632
48636
  function buildConsoleCaptureHookCommand(entry, cliId, createCaptureHook = createSessionCaptureHookExec) {
47633
- const extension = path18__default.extname(entry.entryPath);
48637
+ const extension = path19__default.extname(entry.entryPath);
47634
48638
  if (JAVASCRIPT_ENTRY_EXTENSIONS.has(extension)) {
47635
48639
  return createCaptureHook({
47636
48640
  entryPath: entry.entryPath,
@@ -47656,11 +48660,11 @@ function toCaptureProvider(cliId) {
47656
48660
  }
47657
48661
  function withConsoleMarketplaceLock(target2, fn) {
47658
48662
  const lockDir = `${target2}${MARKETPLACE_LOCK_DIR_SUFFIX}`;
47659
- mkdirSync(path18__default.dirname(lockDir), { recursive: true });
48663
+ mkdirSync(path19__default.dirname(lockDir), { recursive: true });
47660
48664
  return withDirectoryLock({ lockDir }, fn);
47661
48665
  }
47662
48666
  function buildConsoleCliHookExec(entry, trailingArgs) {
47663
- const extension = path18__default.extname(entry.entryPath);
48667
+ const extension = path19__default.extname(entry.entryPath);
47664
48668
  if (JAVASCRIPT_ENTRY_EXTENSIONS.has(extension)) {
47665
48669
  return {
47666
48670
  command: entry.execPath,
@@ -47801,7 +48805,7 @@ function resolveHookEntryPath(candidate) {
47801
48805
  return CONSOLE_ENTRY_PATH;
47802
48806
  }
47803
48807
  function hasHookEntryExtension(entryPath) {
47804
- return HOOK_ENTRY_EXTENSIONS.has(path18__default.extname(entryPath));
48808
+ return HOOK_ENTRY_EXTENSIONS.has(path19__default.extname(entryPath));
47805
48809
  }
47806
48810
  async function createAgentCliLaunchSpec(options) {
47807
48811
  const cleanupStack = [];
@@ -48076,8 +49080,8 @@ function createLaunchAttachmentStore(options) {
48076
49080
  );
48077
49081
  }
48078
49082
  mkdirSync(namespaceRoot, { recursive: true });
48079
- const dir = mkdtempSync(path18__default.join(namespaceRoot, "attachment-"));
48080
- const filePath = path18__default.join(dir, `image.${sniffed.ext}`);
49083
+ const dir = mkdtempSync(path19__default.join(namespaceRoot, "attachment-"));
49084
+ const filePath = path19__default.join(dir, `image.${sniffed.ext}`);
48081
49085
  try {
48082
49086
  writeFileSync(filePath, bytes, { flag: "wx", mode: LAUNCH_ATTACHMENT_FILE_MODE });
48083
49087
  chmodBestEffort3(filePath, LAUNCH_ATTACHMENT_FILE_MODE);
@@ -48155,8 +49159,8 @@ function createLaunchAttachmentStore(options) {
48155
49159
  };
48156
49160
  }
48157
49161
  function resolveLaunchAttachmentNamespaceRoot(dataDir) {
48158
- const hash2 = crypto5.createHash("sha256").update(path18__default.resolve(dataDir)).digest("hex").slice(0, 12);
48159
- return path18__default.join(path18__default.resolve(os3__default.tmpdir()), `${LAUNCH_ATTACHMENT_NAMESPACE_PREFIX}${hash2}`);
49162
+ const hash2 = crypto5.createHash("sha256").update(path19__default.resolve(dataDir)).digest("hex").slice(0, 12);
49163
+ return path19__default.join(path19__default.resolve(os3__default.tmpdir()), `${LAUNCH_ATTACHMENT_NAMESPACE_PREFIX}${hash2}`);
48160
49164
  }
48161
49165
  function chmodBestEffort3(targetPath, mode) {
48162
49166
  try {
@@ -48250,7 +49254,7 @@ function createConsoleObservabilityStore(deps = {}) {
48250
49254
  return terminalSessionsById.get(sessionId)?.cwd ?? workspacesByCliRunId.get(sessionId)?.session.cwd ?? null;
48251
49255
  }
48252
49256
  function createPendingTerminalSession(input) {
48253
- if (!path18__default.isAbsolute(input.cwd)) throw new Error("Terminal session cwd must be absolute");
49257
+ if (!path19__default.isAbsolute(input.cwd)) throw new Error("Terminal session cwd must be absolute");
48254
49258
  const createdAt = input.createdAt ?? now();
48255
49259
  const canonicalCwd = canonicalizeTheaterPath(input.cwd);
48256
49260
  const theaterId = workspaceHash(canonicalCwd);
@@ -48260,7 +49264,7 @@ function createConsoleObservabilityStore(deps = {}) {
48260
49264
  sessionId: input.sessionId,
48261
49265
  cwd: input.cwd,
48262
49266
  canonicalCwd,
48263
- cwdLabel: path18__default.basename(input.cwd) || input.cwd,
49267
+ cwdLabel: path19__default.basename(input.cwd) || input.cwd,
48264
49268
  cliId: input.cliId,
48265
49269
  createdAt,
48266
49270
  theaterId,
@@ -48277,7 +49281,7 @@ function createConsoleObservabilityStore(deps = {}) {
48277
49281
  sessionId: operation.sessionId,
48278
49282
  cwd: operation.cwd,
48279
49283
  canonicalCwd: canonicalizeTheaterPath(operation.cwd),
48280
- cwdLabel: path18__default.basename(operation.cwd) || operation.cwd,
49284
+ cwdLabel: path19__default.basename(operation.cwd) || operation.cwd,
48281
49285
  label: operation.label,
48282
49286
  labelSource: operation.labelSource,
48283
49287
  providerTitle: operation.providerTitle,
@@ -48583,7 +49587,7 @@ function defaultWorkspaceHash(canonicalCwd) {
48583
49587
  return crypto5.createHash("sha256").update(canonicalCwd).digest("hex").slice(0, 12);
48584
49588
  }
48585
49589
  function defaultCanonicalizeTheaterPath(cwd) {
48586
- const resolved = path18__default.resolve(cwd);
49590
+ const resolved = path19__default.resolve(cwd);
48587
49591
  try {
48588
49592
  return fs9__default.realpathSync.native(resolved);
48589
49593
  } catch {
@@ -49446,7 +50450,7 @@ var AgentChatSession = class {
49446
50450
  this.operationId = operationId;
49447
50451
  this.seed = seed;
49448
50452
  this.createSdk = createSdk;
49449
- this.latestSessionId = seed.origin.kind === "resume" ? path18__default.basename(seed.origin.transcriptPath, ".jsonl") : null;
50453
+ this.latestSessionId = seed.origin.kind === "resume" ? path19__default.basename(seed.origin.transcriptPath, ".jsonl") : null;
49450
50454
  }
49451
50455
  get busy() {
49452
50456
  return this.pendingTurns > 0;
@@ -49728,7 +50732,7 @@ var AgentChatSession = class {
49728
50732
  const id = message.task_id;
49729
50733
  const file2 = message.output_file;
49730
50734
  if (typeof id !== "string" || id.length === 0) return;
49731
- if (typeof file2 !== "string" || !path18__default.isAbsolute(file2)) return;
50735
+ if (typeof file2 !== "string" || !path19__default.isAbsolute(file2)) return;
49732
50736
  this.jobOutputs.set(id, file2);
49733
50737
  if (this.jobOutputs.size > JOB_KIND_CAP) {
49734
50738
  const oldest = this.jobOutputs.keys().next();
@@ -49761,7 +50765,7 @@ var AgentChatSession = class {
49761
50765
  }
49762
50766
  const dir = await this.resolveJobSessionDir();
49763
50767
  if (dir === null) return null;
49764
- const window = await readFileTail(path18__default.join(dir, "subagents", `agent-${jobId}.jsonl`), JOB_TRANSCRIPT_READ_BYTES);
50768
+ const window = await readFileTail(path19__default.join(dir, "subagents", `agent-${jobId}.jsonl`), JOB_TRANSCRIPT_READ_BYTES);
49765
50769
  if (window === null) return null;
49766
50770
  const trail = chatSubagentTrailFromTranscript(window.text, { cwd: this.seed.cwd });
49767
50771
  return { kind: "agent", steps: trail.steps, truncated: trail.truncated || window.headCut };
@@ -49783,7 +50787,7 @@ var AgentChatSession = class {
49783
50787
  if (!sessionId) return null;
49784
50788
  const transcriptPath = await this.locateTranscript(sessionId);
49785
50789
  if (!transcriptPath) return null;
49786
- return path18__default.join(path18__default.dirname(transcriptPath), sessionId);
50790
+ return path19__default.join(path19__default.dirname(transcriptPath), sessionId);
49787
50791
  }
49788
50792
  /**
49789
50793
  * 자식이 도구를 쓰기 전에 부르는 자리. 대화형 도구 둘만 여기서 멈춰 사용자를 기다리고,
@@ -49918,7 +50922,7 @@ var AgentChatSession = class {
49918
50922
  if (message.type !== "stream_event") return;
49919
50923
  if (typeof message.parent_tool_use_id === "string" && message.parent_tool_use_id.length > 0) return;
49920
50924
  const event = message.event;
49921
- if (!isRecord14(event) || event.type !== "message_delta") return;
50925
+ if (!isRecord16(event) || event.type !== "message_delta") return;
49922
50926
  const total = readClaudeOccupiedInputTokens(event.usage);
49923
50927
  if (total === null) return;
49924
50928
  const claudeCoordinate = this.claudeCoordinate();
@@ -50360,15 +51364,15 @@ var AgentChatSession = class {
50360
51364
  */
50361
51365
  async locateTranscript(sessionId) {
50362
51366
  if (this.seed.origin.kind === "resume") {
50363
- const sibling = path18__default.join(path18__default.dirname(this.seed.origin.transcriptPath), `${sessionId}.jsonl`);
51367
+ const sibling = path19__default.join(path19__default.dirname(this.seed.origin.transcriptPath), `${sessionId}.jsonl`);
50364
51368
  if (await isExistingFile(sibling)) return sibling;
50365
51369
  }
50366
- const projectsRoot = path18__default.join(this.seed.claudeConfigDir, "projects");
51370
+ const projectsRoot = path19__default.join(this.seed.claudeConfigDir, "projects");
50367
51371
  const entries = await promises.readdir(projectsRoot, { withFileTypes: true }).catch(() => null);
50368
51372
  if (!entries) return null;
50369
51373
  for (const entry of entries) {
50370
51374
  if (!entry.isDirectory()) continue;
50371
- const candidate = path18__default.join(projectsRoot, entry.name, `${sessionId}.jsonl`);
51375
+ const candidate = path19__default.join(projectsRoot, entry.name, `${sessionId}.jsonl`);
50372
51376
  if (await isExistingFile(candidate)) return candidate;
50373
51377
  }
50374
51378
  return null;
@@ -50437,11 +51441,11 @@ var AgentChatRegistry = class {
50437
51441
  await Promise.all([...operationIds].map((operationId) => this.dispose(operationId)));
50438
51442
  }
50439
51443
  };
50440
- function isRecord14(value) {
51444
+ function isRecord16(value) {
50441
51445
  return typeof value === "object" && value !== null && !Array.isArray(value);
50442
51446
  }
50443
51447
  function readClaudeOccupiedInputTokens(usage4) {
50444
- if (!isRecord14(usage4)) return null;
51448
+ if (!isRecord16(usage4)) return null;
50445
51449
  let total = 0;
50446
51450
  let found = false;
50447
51451
  for (const field of ["input_tokens", "cache_read_input_tokens", "cache_creation_input_tokens"]) {
@@ -50625,7 +51629,7 @@ function analysisError(code, message) {
50625
51629
  return { error: { code, message } };
50626
51630
  }
50627
51631
  function isAnalysisSelection(catalog, value) {
50628
- if (!isRecord15(value) || !hasExactKeys(value, ["cliId", "model", "effort", "language"]) || typeof value.cliId !== "string" || typeof value.model !== "string" || value.effort !== void 0 && typeof value.effort !== "string" || value.language !== void 0 && value.language !== "en" && value.language !== "ko") return false;
51632
+ if (!isRecord17(value) || !hasExactKeys(value, ["cliId", "model", "effort", "language"]) || typeof value.cliId !== "string" || typeof value.model !== "string" || value.effort !== void 0 && typeof value.effort !== "string" || value.language !== void 0 && value.language !== "en" && value.language !== "ko") return false;
50629
51633
  const cli = catalog.clis.find((candidate) => candidate.cliId === value.cliId);
50630
51634
  if (!cli?.available) return false;
50631
51635
  const model = cli.models.find((candidate) => candidate.id === value.model);
@@ -50634,9 +51638,9 @@ function isAnalysisSelection(catalog, value) {
50634
51638
  return typeof value.effort === "string" && value.effort.length > 0 && model.effortLevels.includes(value.effort);
50635
51639
  }
50636
51640
  function isMessageBody(value) {
50637
- return isRecord15(value) && hasExactKeys(value, ["text"]) && typeof value.text === "string" && value.text.trim().length > 0;
51641
+ return isRecord17(value) && hasExactKeys(value, ["text"]) && typeof value.text === "string" && value.text.trim().length > 0;
50638
51642
  }
50639
- function isRecord15(value) {
51643
+ function isRecord17(value) {
50640
51644
  return typeof value === "object" && value !== null && !Array.isArray(value);
50641
51645
  }
50642
51646
  function hasExactKeys(value, keys) {
@@ -50644,14 +51648,14 @@ function hasExactKeys(value, keys) {
50644
51648
  }
50645
51649
  async function resolveTranscriptPath(capturePath, operationCreatedAt) {
50646
51650
  if (await transcriptFileExists(capturePath)) return capturePath;
50647
- const dir = path18__default.dirname(capturePath);
51651
+ const dir = path19__default.dirname(capturePath);
50648
51652
  const bornCutoff = operationCreatedAt - 6e4;
50649
51653
  try {
50650
51654
  const entries = await promises.readdir(dir);
50651
51655
  const candidates = [];
50652
51656
  for (const entry of entries) {
50653
51657
  if (!entry.endsWith(".jsonl")) continue;
50654
- const candidate = path18__default.join(dir, entry);
51658
+ const candidate = path19__default.join(dir, entry);
50655
51659
  const stat4 = await promises.stat(candidate).catch(() => null);
50656
51660
  if (!stat4?.isFile()) continue;
50657
51661
  if (stat4.birthtimeMs > 0 && stat4.birthtimeMs < bornCutoff) continue;
@@ -50668,6 +51672,19 @@ async function transcriptFileExists(filePath) {
50668
51672
  return stat4?.isFile() ?? false;
50669
51673
  }
50670
51674
 
51675
+ // ../fleet-plugins/terminal/server/agent-api/types.ts
51676
+ var AGENT_ATTENTION_REASONS = [
51677
+ "idle_prompt",
51678
+ "permission_prompt",
51679
+ "auth_success",
51680
+ "elicitation_dialog",
51681
+ "elicitation_complete",
51682
+ "elicitation_response"
51683
+ ];
51684
+ function normalizeAttentionReason(value) {
51685
+ return typeof value === "string" && AGENT_ATTENTION_REASONS.includes(value) ? value : void 0;
51686
+ }
51687
+
50671
51688
  // ../fleet-plugins/terminal/server/agent-idle-dormant-sweeper.ts
50672
51689
  var AGENT_IDLE_DORMANT_SWEEP_INTERVAL_MS = 6e4;
50673
51690
  function sweepIdleAgentSessions(deps) {
@@ -50713,7 +51730,7 @@ var CHAT_SUPPORTED_CLI_ID = "claude-gateway";
50713
51730
  var MAX_CHAT_ANSWER_MESSAGE_CHARS2 = 2e3;
50714
51731
  function resolveClaudeConfigDir() {
50715
51732
  const configured = process4.env.CLAUDE_CONFIG_DIR;
50716
- return configured && configured.length > 0 ? configured : path18__default.join(os3__default.homedir(), ".claude");
51733
+ return configured && configured.length > 0 ? configured : path19__default.join(os3__default.homedir(), ".claude");
50717
51734
  }
50718
51735
  async function registerAgentRoutes(ctx, terminalRuntime, deps) {
50719
51736
  const api = await createAgentApi(ctx, terminalRuntime, deps);
@@ -51240,7 +52257,7 @@ async function createAgentApi(ctx, terminalRuntime, deps) {
51240
52257
  theaterId,
51241
52258
  type: AGENT_OPERATION_TYPE,
51242
52259
  pluginId: ctx.pluginId,
51243
- title: namedSession.label ?? session.label ?? path18__default.basename(cwd),
52260
+ title: namedSession.label ?? session.label ?? path19__default.basename(cwd),
51244
52261
  // 공급자는 실행 시점에 한 번 확정되고 이후 어떤 patch도 다시 쓰지 않는다 —
51245
52262
  // toOperationPayload가 지우는 키 목록 밖이라 resume·복원을 지나도 그대로 남는다.
51246
52263
  payload: {
@@ -51871,7 +52888,7 @@ async function createAgentApi(ctx, terminalRuntime, deps) {
51871
52888
  if (result?.renamed) {
51872
52889
  observability.notifySessionUpdated(result.session);
51873
52890
  const autoNameCwd = readPayloadString(ctx.host.operations.get(sessionId)?.payload ?? {}, "cwd") ?? result.session.cwdLabel;
51874
- ctx.host.operations.patch(sessionId, { title: result.session.label ?? path18__default.basename(autoNameCwd) });
52891
+ ctx.host.operations.patch(sessionId, { title: result.session.label ?? path19__default.basename(autoNameCwd) });
51875
52892
  }
51876
52893
  ctx.host.http.writeJson(res, 200, { ok: true, renamed: result?.renamed === true });
51877
52894
  return true;
@@ -52125,7 +53142,7 @@ function createTerminalWikiToolSpecs(fleetDataDir) {
52125
53142
  const resolver = createWikiWorkspaceResolver({
52126
53143
  ensureWorkspace: (cwd) => ensureWorkspaceDirectory(fleetDataDir, cwd),
52127
53144
  withMigrationLock: (workspace, operation) => withDirectoryLock(
52128
- { lockDir: path18__default.join(workspace.path, "knowledge.migration.lock") },
53145
+ { lockDir: path19__default.join(workspace.path, "knowledge.migration.lock") },
52129
53146
  operation
52130
53147
  )
52131
53148
  });
@@ -53481,12 +54498,12 @@ function artifactHeaders() {
53481
54498
  return { "Content-Type": "text/html; charset=utf-8", "Content-Security-Policy": ANALYSIS_ARTIFACT_CSP, "Cache-Control": "no-store", "Referrer-Policy": "no-referrer", "X-Content-Type-Options": "nosniff" };
53482
54499
  }
53483
54500
  function registerAiGatewayRoutes(ctx, deps = {}) {
53484
- const ownedDiagnostics = deps.cursorDiagnostics ? void 0 : createCursorDiagnosticLog(path18__default.join(
54501
+ const ownedDiagnostics = deps.cursorDiagnostics ? void 0 : createCursorDiagnosticLog(path19__default.join(
53485
54502
  ctx.host.paths.pluginDataDir(ctx.pluginId),
53486
54503
  "ai-gateway"
53487
54504
  ));
53488
54505
  const ownedFailureJournal = deps.failureJournal ? void 0 : createFailureJournal({
53489
- filePath: path18__default.join(
54506
+ filePath: path19__default.join(
53490
54507
  ctx.host.paths.pluginDataDir(ctx.pluginId),
53491
54508
  "ai-gateway",
53492
54509
  "failures.jsonl"
@@ -53500,6 +54517,8 @@ function registerAiGatewayRoutes(ctx, deps = {}) {
53500
54517
  readAuth: deps.readAuth ?? (() => readCodexSubscriptionAuth()),
53501
54518
  readCursorToken: deps.readCursorToken ?? (() => readCursorSubscriptionToken()),
53502
54519
  readXaiToken: deps.readXaiToken ?? (() => readXaiSubscriptionToken()),
54520
+ readAntigravityToken: deps.readAntigravityToken ?? (() => readAntigravitySubscriptionToken()),
54521
+ renewAntigravityToken: deps.renewAntigravityToken ?? (() => readAntigravitySubscriptionToken({ forceRenew: true })),
53503
54522
  readModelOverride: () => process.env[AI_GATEWAY_MODEL_ENV],
53504
54523
  cursorDiagnostics: deps.cursorDiagnostics ?? ownedDiagnostics?.write
53505
54524
  });
@@ -53777,7 +54796,7 @@ function isRestoredShellEvent(value, pluginId) {
53777
54796
  var CONTROL_HOLDER_EVENT_CHANNEL = "control:holder";
53778
54797
  function applyWireLog(ctx, stored) {
53779
54798
  setWireLogTarget(stored === void 0 ? void 0 : stored ? {
53780
- path: path18__default.join(ctx.host.paths.pluginDataDir(ctx.pluginId), "ai-gateway", "wire-log.jsonl"),
54799
+ path: path19__default.join(ctx.host.paths.pluginDataDir(ctx.pluginId), "ai-gateway", "wire-log.jsonl"),
53781
54800
  maxBytes: DEFAULT_WIRE_LOG_MAX_BYTES
53782
54801
  } : null);
53783
54802
  }