@ycodium-ai/agent-claude 0.2.5029 → 0.2.5100

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 (2) hide show
  1. package/dist/index.js +825 -791
  2. package/package.json +9 -3
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // src/index.ts
2
- import * as NodePath20 from "node:path";
2
+ import * as NodePath21 from "node:path";
3
3
  import { definePlugin } from "@ycodium-ai/plugin-api";
4
4
 
5
5
  // ../../packages/plugin-api/src/version.ts
6
- var PLUGIN_API_VERSION = 143;
6
+ var PLUGIN_API_VERSION = 148;
7
7
 
8
8
  // src/index.ts
9
9
  import {
@@ -296,8 +296,8 @@ var waitForJsonlHistory = (input) => {
296
296
  signal.throwIfAborted();
297
297
  if (error !== void 0) throw error;
298
298
  if (!dirty)
299
- await new Promise((resolve6) => {
300
- wake = resolve6;
299
+ await new Promise((resolve7) => {
300
+ wake = resolve7;
301
301
  });
302
302
  signal.throwIfAborted();
303
303
  dirty = false;
@@ -1366,8 +1366,8 @@ async function openJsonlHistory(path, layout, signal) {
1366
1366
  readSignal.throwIfAborted();
1367
1367
  if (failure !== void 0) throw failure;
1368
1368
  if (!dirty)
1369
- await new Promise((resolve6) => {
1370
- wake = resolve6;
1369
+ await new Promise((resolve7) => {
1370
+ wake = resolve7;
1371
1371
  });
1372
1372
  readSignal.throwIfAborted();
1373
1373
  dirty = false;
@@ -1447,45 +1447,15 @@ async function openJsonlHistory(path, layout, signal) {
1447
1447
  };
1448
1448
  }
1449
1449
 
1450
- // src/sessions.ts
1451
- import * as NodeFS3 from "node:fs";
1452
- import * as NodeOS from "node:os";
1450
+ // ../../packages/ycodium-jsonl-stream/src/claudeSessions.ts
1453
1451
  import * as NodePath3 from "node:path";
1454
1452
  import * as NodeProcess from "node:process";
1455
-
1456
- // src/sessionScope.ts
1457
- var EXTENDED_LENGTH_UNC = "//?/UNC/";
1458
- var EXTENDED_LENGTH = "//?/";
1459
- function normalize(value, caseInsensitive) {
1460
- let unified = value.trim().replace(/\\/gu, "/");
1461
- const upper = unified.toUpperCase();
1462
- if (upper.startsWith(EXTENDED_LENGTH_UNC)) {
1463
- unified = `//${unified.slice(EXTENDED_LENGTH_UNC.length)}`;
1464
- } else if (upper.startsWith(EXTENDED_LENGTH)) {
1465
- unified = unified.slice(EXTENDED_LENGTH.length);
1466
- }
1467
- const isUnc = unified.startsWith("//");
1468
- unified = unified.replace(/\/+/gu, "/").replace(/\/+$/u, "");
1469
- if (isUnc) unified = `/${unified}`;
1470
- return caseInsensitive ? unified.toLowerCase() : unified;
1471
- }
1472
- function isWithinDirectory(candidate, root, caseInsensitive) {
1473
- const normalizedRoot = normalize(root, caseInsensitive);
1474
- if (normalizedRoot.length === 0 || normalizedRoot === "/") return false;
1475
- const normalizedCandidate = normalize(candidate, caseInsensitive);
1476
- return normalizedCandidate === normalizedRoot || normalizedCandidate.startsWith(`${normalizedRoot}/`);
1477
- }
1478
-
1479
- // src/sessions.ts
1480
1453
  var PREVIEW_LIMIT = 200;
1481
- var MAX_SCANNED_FILES = 200;
1482
- var MAX_ROWS = 50;
1483
- var MAX_PARSED_LINE_BYTES = 1e6;
1484
- var TRANSCRIPT_SUFFIX = ".jsonl";
1454
+ var CLAUDE_MAX_SCANNED_FILES = 200;
1455
+ var CLAUDE_MAX_ROWS = 50;
1456
+ var CLAUDE_MAX_PARSED_LINE_BYTES = 1e6;
1457
+ var CLAUDE_TRANSCRIPT_SUFFIX = ".jsonl";
1485
1458
  var DIGEST_TEXT_KEEP_CHARS = 4096;
1486
- var fileSource = {
1487
- createReadStream: (path) => NodeFS3.createReadStream(path)
1488
- };
1489
1459
  var DIGEST_FIELDS = [
1490
1460
  { path: ["type"] },
1491
1461
  { path: ["cwd"] },
@@ -1497,19 +1467,6 @@ var DIGEST_FIELDS = [
1497
1467
  { path: ["message", "content", "*", "type"] },
1498
1468
  { path: ["message", "content", "*", "text"], maxChars: DIGEST_TEXT_KEEP_CHARS }
1499
1469
  ];
1500
- var RECORD_FIELDS = [
1501
- { path: ["type"] },
1502
- { path: ["uuid"] },
1503
- { path: ["isSidechain"] },
1504
- { path: ["isSideChain"] },
1505
- { path: ["isMeta"] },
1506
- { path: ["parent_tool_use_id"] },
1507
- { path: ["timestamp"] },
1508
- { path: ["message", "model"] },
1509
- { path: ["message", "content"], scalarOnly: true },
1510
- { path: ["message", "content", "*", "type"] },
1511
- { path: ["message", "content", "*", "text"] }
1512
- ];
1513
1470
  function truncate(value) {
1514
1471
  const trimmed = value?.trim() ?? "";
1515
1472
  if (trimmed.length === 0) return null;
@@ -1529,7 +1486,7 @@ function textFromContent(content) {
1529
1486
  }
1530
1487
  return parts.join("\n\n").trim();
1531
1488
  }
1532
- async function readClaudeTranscriptDigest(filePath) {
1489
+ async function readClaudeTranscriptDigest(source, filePath) {
1533
1490
  let cwd = null;
1534
1491
  let model = null;
1535
1492
  let preview = null;
@@ -1537,8 +1494,8 @@ async function readClaudeTranscriptDigest(filePath) {
1537
1494
  let aiTitle = null;
1538
1495
  let turnCount = 0;
1539
1496
  try {
1540
- const entries = readJsonlEntries(fileSource, filePath, {
1541
- maxLineChars: MAX_PARSED_LINE_BYTES,
1497
+ const entries = readJsonlEntries(source, filePath, {
1498
+ maxLineChars: CLAUDE_MAX_PARSED_LINE_BYTES,
1542
1499
  fields: DIGEST_FIELDS
1543
1500
  });
1544
1501
  for await (const entry of entries) {
@@ -1581,10 +1538,10 @@ async function readClaudeTranscriptDigest(filePath) {
1581
1538
  turnCount
1582
1539
  };
1583
1540
  }
1584
- function listTranscriptFiles(transcriptDir, directory) {
1541
+ async function listClaudeTranscriptFiles(fs2, transcriptDir, directory) {
1585
1542
  let dirs;
1586
1543
  try {
1587
- dirs = NodeFS3.readdirSync(transcriptDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
1544
+ dirs = (await fs2.readDir(transcriptDir)).filter((entry) => entry.type === "directory").map((entry) => entry.name);
1588
1545
  } catch {
1589
1546
  return [];
1590
1547
  }
@@ -1596,20 +1553,20 @@ function listTranscriptFiles(transcriptDir, directory) {
1596
1553
  const projectDir = NodePath3.join(transcriptDir, dir);
1597
1554
  let names;
1598
1555
  try {
1599
- names = NodeFS3.readdirSync(projectDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(TRANSCRIPT_SUFFIX)).map((entry) => entry.name);
1556
+ names = (await fs2.readDir(projectDir)).filter((entry) => entry.type === "file" && entry.name.endsWith(CLAUDE_TRANSCRIPT_SUFFIX)).map((entry) => entry.name);
1600
1557
  } catch {
1601
1558
  continue;
1602
1559
  }
1603
1560
  for (const name of names) {
1604
1561
  let stat5;
1605
1562
  try {
1606
- stat5 = NodeFS3.statSync(NodePath3.join(projectDir, name));
1563
+ stat5 = await fs2.stat(NodePath3.join(projectDir, name));
1607
1564
  } catch {
1608
1565
  continue;
1609
1566
  }
1610
1567
  found.push({
1611
1568
  path: NodePath3.join(projectDir, name),
1612
- sessionId: name.slice(0, -TRANSCRIPT_SUFFIX.length),
1569
+ sessionId: name.slice(0, -CLAUDE_TRANSCRIPT_SUFFIX.length),
1613
1570
  size: stat5.size,
1614
1571
  mtimeMs: Number.isFinite(stat5.mtimeMs) ? stat5.mtimeMs : 0
1615
1572
  });
@@ -1617,19 +1574,19 @@ function listTranscriptFiles(transcriptDir, directory) {
1617
1574
  }
1618
1575
  return found;
1619
1576
  }
1620
- function readClaudeLiveSessionIds(configDir) {
1577
+ async function readClaudeLiveSessionIds(fs2, configDir) {
1621
1578
  const live = /* @__PURE__ */ new Set();
1622
1579
  const markerDir = NodePath3.join(configDir, "sessions");
1623
1580
  let entries;
1624
1581
  try {
1625
- entries = NodeFS3.readdirSync(markerDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name);
1582
+ entries = (await fs2.readDir(markerDir)).filter((entry) => entry.type === "file" && entry.name.endsWith(".json")).map((entry) => entry.name);
1626
1583
  } catch {
1627
1584
  return live;
1628
1585
  }
1629
1586
  for (const entry of entries) {
1630
1587
  let marker;
1631
1588
  try {
1632
- marker = JSON.parse(NodeFS3.readFileSync(NodePath3.join(markerDir, entry), "utf8"));
1589
+ marker = JSON.parse(await fs2.readFile(NodePath3.join(markerDir, entry)));
1633
1590
  } catch {
1634
1591
  continue;
1635
1592
  }
@@ -1645,134 +1602,28 @@ function readClaudeLiveSessionIds(configDir) {
1645
1602
  }
1646
1603
  return live;
1647
1604
  }
1648
- async function scanClaudeSessions(input) {
1649
- let root;
1650
- try {
1651
- root = NodeFS3.statSync(input.transcriptDir);
1652
- } catch (error) {
1653
- throw new Error(`The Claude transcript directory ${input.transcriptDir} is not a directory.`, {
1654
- cause: error
1655
- });
1656
- }
1657
- if (!root.isDirectory()) {
1658
- throw new Error(`The Claude transcript directory ${input.transcriptDir} is not a directory.`);
1659
- }
1660
- const files = [...listTranscriptFiles(input.transcriptDir, input.directory)].sort((left, right) => right.mtimeMs - left.mtimeMs).slice(0, MAX_SCANNED_FILES);
1661
- const live = readClaudeLiveSessionIds(input.configDir);
1662
- const caseInsensitive = input.caseInsensitive ?? NodeOS.type() === "Windows_NT";
1663
- const rows = [];
1664
- for (const file of files) {
1665
- if (rows.length >= MAX_ROWS) break;
1666
- const digest = await readClaudeTranscriptDigest(file.path);
1667
- if (digest === null || digest.cwd === null) continue;
1668
- if (!isWithinDirectory(digest.cwd, input.directory, caseInsensitive)) continue;
1669
- rows.push({
1670
- nativeSessionId: file.sessionId,
1671
- cwd: digest.cwd,
1672
- title: digest.title,
1673
- preview: digest.preview,
1674
- model: digest.model,
1675
- turnCount: digest.turnCount,
1676
- updatedAt: file.mtimeMs,
1677
- availability: "importable",
1678
- openElsewhere: live.has(file.sessionId)
1679
- });
1680
- }
1681
- return rows;
1682
- }
1683
- function resolveTranscriptPath(input) {
1684
- const fileName = `${input.sessionId}${TRANSCRIPT_SUFFIX}`;
1685
- if (input.cwd !== void 0 && input.cwd.length > 0) {
1686
- const direct = NodePath3.join(
1687
- input.transcriptDir,
1688
- encodeClaudeProjectDirName(input.cwd),
1689
- fileName
1690
- );
1691
- try {
1692
- if (NodeFS3.statSync(direct).isFile()) return direct;
1693
- } catch {
1694
- }
1695
- }
1696
- let dirs;
1697
- try {
1698
- dirs = NodeFS3.readdirSync(input.transcriptDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
1699
- } catch {
1700
- return null;
1701
- }
1702
- for (const dir of dirs) {
1703
- const candidate = NodePath3.join(input.transcriptDir, dir, fileName);
1704
- try {
1705
- if (NodeFS3.statSync(candidate).isFile()) return candidate;
1706
- } catch {
1707
- continue;
1708
- }
1605
+
1606
+ // ../../packages/ycodium-workspace-path/src/directoryScope.ts
1607
+ var EXTENDED_LENGTH_UNC = "//?/UNC/";
1608
+ var EXTENDED_LENGTH = "//?/";
1609
+ function normalize(value, caseInsensitive) {
1610
+ let unified = value.trim().replace(/\\/gu, "/");
1611
+ const upper = unified.toUpperCase();
1612
+ if (upper.startsWith(EXTENDED_LENGTH_UNC)) {
1613
+ unified = `//${unified.slice(EXTENDED_LENGTH_UNC.length)}`;
1614
+ } else if (upper.startsWith(EXTENDED_LENGTH)) {
1615
+ unified = unified.slice(EXTENDED_LENGTH.length);
1709
1616
  }
1710
- return null;
1711
- }
1712
- function isRecord(value) {
1713
- return typeof value === "object" && value !== null && !Array.isArray(value);
1714
- }
1715
- function nonempty(value) {
1716
- return typeof value === "string" && value.trim().length > 0 ? value : void 0;
1617
+ const isUnc = unified.startsWith("//");
1618
+ unified = unified.replace(/\/+/gu, "/").replace(/\/+$/u, "");
1619
+ if (isUnc) unified = `/${unified}`;
1620
+ return caseInsensitive ? unified.toLowerCase() : unified;
1717
1621
  }
1718
- async function readClaudeSessionRecord(input) {
1719
- const path = resolveTranscriptPath({
1720
- transcriptDir: input.transcriptDir,
1721
- sessionId: input.nativeSessionId,
1722
- cwd: input.cwd
1723
- });
1724
- if (path === null) {
1725
- throw new Error(`No transcript file for Claude session ${input.nativeSessionId}.`);
1726
- }
1727
- const messages = [];
1728
- const byUuid = /* @__PURE__ */ new Map();
1729
- let model = null;
1730
- const entries = readJsonlEntries(fileSource, path, {
1731
- maxLineChars: MAX_PARSED_LINE_BYTES,
1732
- fields: RECORD_FIELDS
1733
- });
1734
- for await (const entry of entries) {
1735
- const parsed = jsonlEntryRecord(
1736
- entry,
1737
- (line) => line.includes('"type":"user"') || line.includes('"type":"assistant"')
1738
- );
1739
- if (!isRecord(parsed)) continue;
1740
- if (parsed.type !== "user" && parsed.type !== "assistant") continue;
1741
- if (parsed.isSidechain === true || parsed.isSideChain === true || parsed.isMeta === true)
1742
- continue;
1743
- if (nonempty(parsed.parent_tool_use_id)) continue;
1744
- const uuid = nonempty(parsed.uuid) ?? `record:${messages.length}`;
1745
- byUuid.set(uuid, parsed);
1746
- }
1747
- for (const value of byUuid.values()) {
1748
- const message = isRecord(value.message) ? value.message : void 0;
1749
- if (!message) continue;
1750
- const content = message.content;
1751
- const blocks = typeof content === "string" ? [{ type: "text", text: content }] : Array.isArray(content) ? content : [];
1752
- const hasToolResult = blocks.some((block) => isRecord(block) && block.type === "tool_result");
1753
- const text2 = blocks.flatMap((block) => {
1754
- const typed = isRecord(block) ? block : void 0;
1755
- if (!typed) return [];
1756
- if (typed.type === "text" && typeof typed.text === "string") return [typed.text];
1757
- return [];
1758
- }).join("\n\n").trim();
1759
- if (text2.length === 0) continue;
1760
- if (value.type === "user" && hasToolResult) continue;
1761
- const role = value.type === "assistant" ? "assistant" : "user";
1762
- if (role === "assistant" && typeof message.model === "string") model = message.model;
1763
- const timestamp = typeof value.timestamp === "string" ? Date.parse(value.timestamp) : typeof value.timestamp === "number" ? value.timestamp : void 0;
1764
- messages.push({
1765
- role,
1766
- text: text2,
1767
- ...timestamp !== void 0 && Number.isFinite(timestamp) ? { createdAt: timestamp } : {}
1768
- });
1769
- }
1770
- return {
1771
- nativeSessionId: input.nativeSessionId,
1772
- messages,
1773
- resumeCursor: { resume: input.nativeSessionId },
1774
- model
1775
- };
1622
+ function isWithinDirectory(candidate, root, caseInsensitive) {
1623
+ const normalizedRoot = normalize(root, caseInsensitive);
1624
+ if (normalizedRoot.length === 0 || normalizedRoot === "/") return false;
1625
+ const normalizedCandidate = normalize(candidate, caseInsensitive);
1626
+ return normalizedCandidate === normalizedRoot || normalizedCandidate.startsWith(`${normalizedRoot}/`);
1776
1627
  }
1777
1628
 
1778
1629
  // src/liveHistory.ts
@@ -1889,7 +1740,7 @@ var openClaudeHistory = (input) => {
1889
1740
 
1890
1741
  // src/claudeInstance.ts
1891
1742
  import * as NodeOS10 from "node:os";
1892
- import * as NodePath19 from "node:path";
1743
+ import * as NodePath20 from "node:path";
1893
1744
 
1894
1745
  // ../../node_modules/.pnpm/@anthropic-ai+claude-agent-sdk@0.3.170_@anthropic-ai+sdk@0.93.0_zod@4.6.5__@modelcontex_64204813d4dba2ebc464c3aa751485a4/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
1895
1746
  import { createRequire as xz } from "node:module";
@@ -21322,7 +21173,7 @@ function HU(e, t) {
21322
21173
  }
21323
21174
 
21324
21175
  // src/claudeInstance.ts
21325
- import { mergeLaunchEnv as mergeLaunchEnv4 } from "@ycodium-ai/plugin-api/executor";
21176
+ import { mergeLaunchEnv as mergeLaunchEnv5 } from "@ycodium-ai/plugin-api/executor";
21326
21177
  import { isOperationCleanupError as isOperationCleanupError3 } from "@ycodium-ai/plugin-api/process-operation";
21327
21178
 
21328
21179
  // src/claudeProbe.ts
@@ -21337,11 +21188,12 @@ import {
21337
21188
  } from "@ycodium-ai/plugin-api/process-operation";
21338
21189
 
21339
21190
  // src/claudeAccount.ts
21340
- import * as NodeFS4 from "node:fs";
21341
- import * as NodeOS2 from "node:os";
21191
+ import * as NodeOS from "node:os";
21342
21192
  import * as NodePath5 from "node:path";
21343
- var OAUTH_KEY = "claudeAiOauth";
21344
- var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
21193
+
21194
+ // ../../packages/ycodium-credential-account/src/credentialAccount.ts
21195
+ import * as NodeFS3 from "node:fs";
21196
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
21345
21197
  var parseJsonRecord = (raw) => {
21346
21198
  let parsed;
21347
21199
  try {
@@ -21349,31 +21201,24 @@ var parseJsonRecord = (raw) => {
21349
21201
  } catch {
21350
21202
  return void 0;
21351
21203
  }
21352
- return isRecord2(parsed) ? parsed : void 0;
21204
+ return isRecord(parsed) ? parsed : void 0;
21353
21205
  };
21354
21206
  var directoryExists = (homePath) => {
21355
21207
  try {
21356
- return NodeFS4.statSync(homePath).isDirectory();
21208
+ return NodeFS3.statSync(homePath).isDirectory();
21357
21209
  } catch {
21358
21210
  return false;
21359
21211
  }
21360
21212
  };
21361
21213
  var readCredentialFile = (path) => {
21362
21214
  try {
21363
- return NodeFS4.readFileSync(path, "utf8");
21215
+ return NodeFS3.readFileSync(path, "utf8");
21364
21216
  } catch {
21365
21217
  return void 0;
21366
21218
  }
21367
21219
  };
21368
- var signedOutProbe = (exists) => ({
21369
- state: "signed-out",
21370
- directoryExists: exists,
21371
- email: void 0,
21372
- name: void 0,
21373
- expiresAt: void 0
21374
- });
21375
- var unreadableProbe = (exists) => ({
21376
- state: "unreadable",
21220
+ var accountWithoutIdentity = (state, exists) => ({
21221
+ state,
21377
21222
  directoryExists: exists,
21378
21223
  email: void 0,
21379
21224
  name: void 0,
@@ -21384,8 +21229,11 @@ var epochMillisToIso = (value) => {
21384
21229
  const date = new Date(value);
21385
21230
  return Number.isNaN(date.getTime()) ? void 0 : date.toISOString();
21386
21231
  };
21232
+
21233
+ // src/claudeAccount.ts
21234
+ var OAUTH_KEY = "claudeAiOauth";
21387
21235
  function resolveClaudeAccountDirectory(credentialsDirPath) {
21388
- return credentialsDirPath ?? NodePath5.join(NodeOS2.homedir(), ".claude");
21236
+ return credentialsDirPath ?? NodePath5.join(NodeOS.homedir(), ".claude");
21389
21237
  }
21390
21238
  function claudeCredentialCandidatePaths(input) {
21391
21239
  return input.credentialsDirPath === null ? [
@@ -21397,7 +21245,7 @@ function readClaudeAccount(credentialsDirPath, credentialCandidates) {
21397
21245
  const accountDirectory = resolveClaudeAccountDirectory(credentialsDirPath);
21398
21246
  const exists = directoryExists(accountDirectory);
21399
21247
  const candidates = credentialCandidates ?? claudeCredentialCandidatePaths({
21400
- homePath: NodeOS2.homedir(),
21248
+ homePath: NodeOS.homedir(),
21401
21249
  credentialsDirPath
21402
21250
  });
21403
21251
  let raw;
@@ -21405,11 +21253,11 @@ function readClaudeAccount(credentialsDirPath, credentialCandidates) {
21405
21253
  raw = readCredentialFile(candidate);
21406
21254
  if (raw !== void 0) break;
21407
21255
  }
21408
- if (raw === void 0) return signedOutProbe(exists);
21256
+ if (raw === void 0) return accountWithoutIdentity("signed-out", exists);
21409
21257
  const parsed = parseJsonRecord(raw);
21410
21258
  const oauth = parsed === void 0 ? void 0 : parsed[OAUTH_KEY];
21411
- if (!isRecord2(oauth) || typeof oauth["accessToken"] !== "string" || oauth["accessToken"].trim().length === 0) {
21412
- return unreadableProbe(exists);
21259
+ if (!isRecord(oauth) || typeof oauth["accessToken"] !== "string" || oauth["accessToken"].trim().length === 0) {
21260
+ return accountWithoutIdentity("unreadable", exists);
21413
21261
  }
21414
21262
  const expiresAtMs = typeof oauth["expiresAt"] === "number" && Number.isFinite(oauth["expiresAt"]) ? oauth["expiresAt"] : void 0;
21415
21263
  const expiresAt = epochMillisToIso(expiresAtMs);
@@ -21424,28 +21272,40 @@ function readClaudeAccount(credentialsDirPath, credentialCandidates) {
21424
21272
  }
21425
21273
 
21426
21274
  // src/usageRead/quota.ts
21427
- import * as NodeFS5 from "node:fs";
21275
+ import * as NodeFS4 from "node:fs";
21428
21276
  import * as NodePath8 from "node:path";
21429
- import { mergeLaunchEnv, setsOwnModelConnection } from "@ycodium-ai/plugin-api/executor";
21277
+ import { mergeLaunchEnv as mergeLaunchEnv2, setsOwnModelConnection } from "@ycodium-ai/plugin-api/executor";
21430
21278
  import {
21431
21279
  parseRetryAfterMs
21432
21280
  } from "@ycodium-ai/plugin-api/usage";
21433
21281
 
21434
- // src/claudeHome.ts
21435
- import * as NodeOS4 from "node:os";
21436
- import * as NodePath7 from "node:path";
21437
-
21438
- // src/pathExpansion.ts
21439
- import * as NodeOS3 from "node:os";
21282
+ // ../../packages/ycodium-instance-config/src/homePath.ts
21283
+ import * as NodeOS2 from "node:os";
21440
21284
  import * as NodePath6 from "node:path";
21285
+ import { mergeLaunchEnv } from "@ycodium-ai/plugin-api/executor";
21441
21286
  function expandHomePath(value) {
21442
- if (value === "~") return NodeOS3.homedir();
21287
+ if (value === "~") return NodeOS2.homedir();
21443
21288
  if (value.startsWith("~/") || value.startsWith("~\\")) {
21444
- return NodePath6.join(NodeOS3.homedir(), value.slice(2));
21289
+ return NodePath6.join(NodeOS2.homedir(), value.slice(2));
21445
21290
  }
21446
21291
  return value;
21447
21292
  }
21448
21293
 
21294
+ // src/claudeHome.ts
21295
+ import * as NodeOS3 from "node:os";
21296
+ import * as NodePath7 from "node:path";
21297
+
21298
+ // ../../packages/ycodium-duration-format/src/durationFormat.ts
21299
+ function formatCoarseWait(waitMs) {
21300
+ const totalMinutes = Math.max(1, Math.ceil(waitMs / 6e4));
21301
+ const days = Math.floor(totalMinutes / (24 * 60));
21302
+ const hours = Math.floor(totalMinutes % (24 * 60) / 60);
21303
+ const minutes = totalMinutes % 60;
21304
+ if (days > 0) return hours === 0 ? `${String(days)}d` : `${String(days)}d ${String(hours)}h`;
21305
+ if (hours === 0) return `${String(totalMinutes)}m`;
21306
+ return minutes === 0 ? `${String(hours)}h` : `${String(hours)}h ${String(minutes)}m`;
21307
+ }
21308
+
21449
21309
  // src/usageLimit.ts
21450
21310
  var WINDOW_NAMES = {
21451
21311
  five_hour: "5-hour",
@@ -21458,19 +21318,10 @@ var MAX_CREDIBLE_WAIT_MS = 30 * 24 * 60 * 60 * 1e3;
21458
21318
  var isBlockingRateLimit = (info) => info.status === "rejected" && info.overageStatus !== "allowed" && info.overageStatus !== "allowed_warning" && info.isUsingOverage !== true && info.overageInUse !== true;
21459
21319
  var isClearingRateLimit = (info) => info.status === "allowed" || info.status === "allowed_warning" || info.overageStatus === "allowed" || info.overageStatus === "allowed_warning" || info.isUsingOverage === true || info.overageInUse === true;
21460
21320
  var rateLimitKey = (info) => `${info.rateLimitType ?? "unknown"}:${String(info.resetsAt ?? "unknown")}`;
21461
- var formatLimitWait = (waitMs) => {
21462
- const totalMinutes = Math.max(1, Math.ceil(waitMs / 6e4));
21463
- const days = Math.floor(totalMinutes / (24 * 60));
21464
- const hours = Math.floor(totalMinutes % (24 * 60) / 60);
21465
- const minutes = totalMinutes % 60;
21466
- if (days > 0) return hours === 0 ? `${String(days)}d` : `${String(days)}d ${String(hours)}h`;
21467
- if (hours === 0) return `${String(totalMinutes)}m`;
21468
- return minutes === 0 ? `${String(hours)}h` : `${String(hours)}h ${String(minutes)}m`;
21469
- };
21470
21321
  var waitUntil = (resetsAtSeconds, nowMs) => {
21471
21322
  if (resetsAtSeconds === void 0 || !Number.isFinite(nowMs)) return void 0;
21472
21323
  const waitMs = resetsAtSeconds * 1e3 - nowMs;
21473
- return waitMs > 0 && waitMs <= MAX_CREDIBLE_WAIT_MS ? formatLimitWait(waitMs) : void 0;
21324
+ return waitMs > 0 && waitMs <= MAX_CREDIBLE_WAIT_MS ? formatCoarseWait(waitMs) : void 0;
21474
21325
  };
21475
21326
  var describeUsageLimitPause = (info, nowMs) => {
21476
21327
  const name = info.rateLimitType === void 0 ? void 0 : WINDOW_NAMES[info.rateLimitType];
@@ -21497,7 +21348,7 @@ var describeUsageLimitFailure = (rejected, nowMs) => {
21497
21348
  var CLAUDE_CREDENTIALS_DIR_ENVIRONMENT_VARIABLE = "CLAUDE_SECURESTORAGE_CONFIG_DIR";
21498
21349
  function resolveClaudeHomePath(homePath) {
21499
21350
  const trimmed = homePath.trim();
21500
- return NodePath7.resolve(trimmed.length > 0 ? expandHomePath(trimmed) : NodeOS4.homedir());
21351
+ return NodePath7.resolve(trimmed.length > 0 ? expandHomePath(trimmed) : NodeOS3.homedir());
21501
21352
  }
21502
21353
  function claudeContinuationKey(homePath) {
21503
21354
  return `claude:home:${resolveClaudeHomePath(homePath)}`;
@@ -21511,7 +21362,7 @@ function resolveClaudeConfigDirPath(homePath, environment, cwd) {
21511
21362
  if (environmentConfigDir.length > 0) {
21512
21363
  return cwd ? NodePath7.resolve(cwd, environmentConfigDir) : NodePath7.resolve(environmentConfigDir);
21513
21364
  }
21514
- return NodePath7.join(NodeOS4.homedir(), ".claude");
21365
+ return NodePath7.join(NodeOS3.homedir(), ".claude");
21515
21366
  }
21516
21367
  function resolveClaudeCredentialsDirPath(credentialsPath) {
21517
21368
  const trimmed = credentialsPath.trim();
@@ -21588,8 +21439,8 @@ var CLAUDE_QUOTA_WINDOWS = [
21588
21439
  { field: "five_hour", id: "session", labelKey: "usage.window.session", windowMs: 5 * HOUR_MS },
21589
21440
  { field: "seven_day", id: "weekly", labelKey: "usage.window.weekly", windowMs: 7 * 24 * HOUR_MS }
21590
21441
  ];
21591
- var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
21592
- var launchEnvironment = (recipe) => mergeLaunchEnv({
21442
+ var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
21443
+ var launchEnvironment = (recipe) => mergeLaunchEnv2({
21593
21444
  inherited: process.env,
21594
21445
  instanceTable: recipe.environment,
21595
21446
  handOverrides: claudeHomeVariables(resolveClaudeHomeLayout(recipe))
@@ -21615,7 +21466,7 @@ var readLoginCredential = (candidates) => {
21615
21466
  for (const path of candidates) {
21616
21467
  let raw;
21617
21468
  try {
21618
- raw = NodeFS5.readFileSync(path, "utf8");
21469
+ raw = NodeFS4.readFileSync(path, "utf8");
21619
21470
  } catch {
21620
21471
  continue;
21621
21472
  }
@@ -21626,8 +21477,8 @@ var readLoginCredential = (candidates) => {
21626
21477
  } catch {
21627
21478
  continue;
21628
21479
  }
21629
- const oauth = isRecord3(parsed) ? parsed["claudeAiOauth"] : void 0;
21630
- if (!isRecord3(oauth)) continue;
21480
+ const oauth = isRecord2(parsed) ? parsed["claudeAiOauth"] : void 0;
21481
+ if (!isRecord2(oauth)) continue;
21631
21482
  const accessToken = readString(oauth["accessToken"]);
21632
21483
  if (accessToken === void 0) continue;
21633
21484
  return {
@@ -21653,7 +21504,7 @@ var toIso = (value) => {
21653
21504
  };
21654
21505
  var readClaudeQuotaWindows = (body) => CLAUDE_QUOTA_WINDOWS.flatMap((spec) => {
21655
21506
  const row = body[spec.field];
21656
- if (!isRecord3(row)) return [];
21507
+ if (!isRecord2(row)) return [];
21657
21508
  const utilization = row["utilization"];
21658
21509
  if (typeof utilization !== "number" || !Number.isFinite(utilization)) return [];
21659
21510
  return [
@@ -21731,7 +21582,7 @@ var readClaudeQuota = async (request) => {
21731
21582
  } catch {
21732
21583
  return { status: "unavailable", reason: "unreachable" };
21733
21584
  }
21734
- if (!isRecord3(body)) return { status: "unavailable", reason: "unreachable" };
21585
+ if (!isRecord2(body)) return { status: "unavailable", reason: "unreachable" };
21735
21586
  const plan = claudePlanName(credential);
21736
21587
  return {
21737
21588
  status: "available",
@@ -21989,39 +21840,21 @@ function knownClaudeModelCapabilities(model, catalog, customModels) {
21989
21840
  function claudeModelCapabilities(model, catalog, customModels) {
21990
21841
  return knownClaudeModelCapabilities(model, catalog, customModels) ?? DEFAULT_CLAUDE_MODEL_CAPABILITIES;
21991
21842
  }
21992
- function isRecord4(value) {
21843
+ function isRecord3(value) {
21993
21844
  return typeof value === "object" && value !== null && !Array.isArray(value);
21994
21845
  }
21995
- function getModelSelectionStringOptionValue(modelSelection, optionId) {
21996
- if (!isRecord4(modelSelection)) return void 0;
21997
- const options = modelSelection["options"];
21998
- if (!Array.isArray(options)) return void 0;
21999
- for (const entry of options) {
22000
- if (!isRecord4(entry)) continue;
22001
- if (entry["id"] === optionId && typeof entry["value"] === "string") {
22002
- const trimmed = entry["value"].trim();
22003
- if (trimmed.length > 0) return trimmed;
22004
- }
22005
- }
22006
- return void 0;
22007
- }
22008
21846
  function getModelSelectionBooleanOptionValue(modelSelection, optionId) {
22009
- if (!isRecord4(modelSelection)) return void 0;
21847
+ if (!isRecord3(modelSelection)) return void 0;
22010
21848
  const options = modelSelection["options"];
22011
21849
  if (!Array.isArray(options)) return void 0;
22012
21850
  for (const entry of options) {
22013
- if (!isRecord4(entry)) continue;
21851
+ if (!isRecord3(entry)) continue;
22014
21852
  if (entry["id"] === optionId && typeof entry["value"] === "boolean") {
22015
21853
  return entry["value"];
22016
21854
  }
22017
21855
  }
22018
21856
  return void 0;
22019
21857
  }
22020
- function modelIdFromSelection(selection) {
22021
- if (!isRecord4(selection)) return void 0;
22022
- const model = selection["model"];
22023
- return typeof model === "string" ? model.trim() || void 0 : void 0;
22024
- }
22025
21858
  var RETIRED_CLAUDE_EFFORT = "ultrathink";
22026
21859
  function currentSelectValue(descriptor, raw) {
22027
21860
  if (raw === RETIRED_CLAUDE_EFFORT && (descriptor.promptInjectedValues?.includes(raw) || !descriptor.options.some((option) => option.id === raw))) {
@@ -22423,8 +22256,8 @@ async function readClaudeCliVersion(input) {
22423
22256
  }
22424
22257
 
22425
22258
  // src/claudeExecutable.ts
22426
- import * as NodeFS6 from "node:fs";
22427
- import * as NodeOS5 from "node:os";
22259
+ import * as NodeFS5 from "node:fs";
22260
+ import * as NodeOS4 from "node:os";
22428
22261
  import * as NodePath10 from "node:path";
22429
22262
  var WINDOWS_SHIM_EXTENSIONS = /* @__PURE__ */ new Set([".cmd", ".bat", ".ps1"]);
22430
22263
  var NPM_PACKAGE_ENTRY_CANDIDATES = [
@@ -22433,12 +22266,12 @@ var NPM_PACKAGE_ENTRY_CANDIDATES = [
22433
22266
  ];
22434
22267
  function isExistingFile(filePath) {
22435
22268
  try {
22436
- return NodeFS6.statSync(filePath).isFile();
22269
+ return NodeFS5.statSync(filePath).isFile();
22437
22270
  } catch {
22438
22271
  return false;
22439
22272
  }
22440
22273
  }
22441
- function resolveClaudeSdkExecutablePath(binaryPath, environment = process.env, isFile = isExistingFile, isWindows = NodeOS5.type() === "Windows_NT") {
22274
+ function resolveClaudeSdkExecutablePath(binaryPath, environment = process.env, isFile = isExistingFile, isWindows = NodeOS4.type() === "Windows_NT") {
22442
22275
  if (!isWindows) {
22443
22276
  return binaryPath;
22444
22277
  }
@@ -22583,11 +22416,12 @@ function toRequestError(threadId, method, cause) {
22583
22416
  return new Error(`${method} failed`, { cause });
22584
22417
  }
22585
22418
 
22586
- // src/toolLabel.ts
22419
+ // ../../packages/ycodium-tool-label/src/toolLabel.ts
22587
22420
  var DETAIL_MAX_CHARS = 200;
22588
22421
  var LABEL_TEXT_MAX_CHARS = 400;
22589
22422
  var SUMMARY_KEYS = [
22590
22423
  "description",
22424
+ "title",
22591
22425
  "query",
22592
22426
  "pattern",
22593
22427
  "url",
@@ -22712,6 +22546,10 @@ function compactJson(input) {
22712
22546
  function formatToolLabel(toolName, input) {
22713
22547
  const name = displayToolName(toolName);
22714
22548
  const diffStat = inputDiffStat(input);
22549
+ if (name.endsWith("visualize_visualize") && typeof input.fragment === "string") {
22550
+ const { fragment: _fragment, ...rest } = input;
22551
+ return formatToolLabel(toolName, rest);
22552
+ }
22715
22553
  for (const key of PATH_KEYS) {
22716
22554
  const path = asTrimmedString(input[key]);
22717
22555
  if (path === void 0) {
@@ -23210,9 +23048,9 @@ var PromptQueue = class {
23210
23048
  const queued = this.#queued.shift();
23211
23049
  if (queued !== void 0) return Promise.resolve(queued);
23212
23050
  if (this.#closed) return Promise.resolve(void 0);
23213
- return new Promise((resolve6) => {
23051
+ return new Promise((resolve7) => {
23214
23052
  this.#waiters.push((result) => {
23215
- resolve6(result.done ? void 0 : result.value);
23053
+ resolve7(result.done ? void 0 : result.value);
23216
23054
  });
23217
23055
  });
23218
23056
  }
@@ -23946,25 +23784,88 @@ var makeEventEmitter = (deps) => {
23946
23784
  return { nowIso, randomUUIDv4, makeEventStamp, eventHeader, offerRuntimeEvent };
23947
23785
  };
23948
23786
 
23949
- // src/shellWords.ts
23950
- function tokenizeShellWords(value) {
23951
- const input = value.trim();
23952
- if (!input) return [];
23953
- const tokens = [];
23954
- let current = "";
23955
- let quote2;
23956
- let quoted = false;
23957
- for (let index = 0; index < input.length; index++) {
23958
- const char = input[index];
23959
- if (char === void 0) continue;
23960
- if (quote2) {
23961
- if (char === quote2) {
23962
- quote2 = void 0;
23963
- quoted = true;
23964
- } else if (char === "\\" && quote2 === '"') {
23965
- const next = input[index + 1];
23966
- if (next !== void 0 && ['"', "\\", "$", "`"].includes(next)) {
23967
- current += next;
23787
+ // ../../packages/ycodium-instance-config/src/instanceConfig.ts
23788
+ import { modelSelectionStringOption } from "@ycodium-ai/plugin-api/executor";
23789
+ function isRecord4(value) {
23790
+ return typeof value === "object" && value !== null && !Array.isArray(value);
23791
+ }
23792
+ function readString3(value) {
23793
+ return typeof value === "string" ? value : "";
23794
+ }
23795
+ function readTrimmed(value) {
23796
+ return readString3(value).trim();
23797
+ }
23798
+ function modelIdFromSelection(selection) {
23799
+ if (!isRecord4(selection)) return void 0;
23800
+ const model = selection["model"];
23801
+ return typeof model === "string" ? model.trim() || void 0 : void 0;
23802
+ }
23803
+ function readEnvironment(value) {
23804
+ if (!Array.isArray(value)) return {};
23805
+ const env2 = {};
23806
+ for (const entry of value) {
23807
+ if (!isRecord4(entry)) continue;
23808
+ const name = readTrimmed(entry["name"]);
23809
+ if (name.length === 0) continue;
23810
+ env2[name] = readString3(entry["value"]);
23811
+ }
23812
+ return env2;
23813
+ }
23814
+ function instanceSettings(config) {
23815
+ if (!isRecord4(config)) return {};
23816
+ return isRecord4(config["config"]) ? config["config"] : config;
23817
+ }
23818
+ function readInstanceEnvelope(config) {
23819
+ const envelope = isRecord4(config) ? config : {};
23820
+ const settings = instanceSettings(config);
23821
+ return {
23822
+ settings,
23823
+ settingOrEnvelope: (key) => readTrimmed(settings[key]) || readTrimmed(envelope[key]),
23824
+ environment: readEnvironment(envelope["environment"]),
23825
+ envelopeDriver: readTrimmed(envelope["driver"]) || void 0
23826
+ };
23827
+ }
23828
+ function readCustomModel(entry) {
23829
+ if (typeof entry === "string") {
23830
+ const slug2 = entry.trim();
23831
+ return slug2.length > 0 ? { slug: slug2 } : void 0;
23832
+ }
23833
+ if (!isRecord4(entry)) return void 0;
23834
+ const slug = readTrimmed(entry["slug"]);
23835
+ if (slug.length === 0) return void 0;
23836
+ const aliasesRaw = entry["aliases"];
23837
+ const aliases = Array.isArray(aliasesRaw) ? aliasesRaw.filter(
23838
+ (alias) => typeof alias === "string" && alias.trim().length > 0
23839
+ ) : void 0;
23840
+ const contextWindow = typeof entry["contextWindow"] === "number" && Number.isFinite(entry["contextWindow"]) && entry["contextWindow"] > 0 ? Math.round(entry["contextWindow"]) : void 0;
23841
+ const label = readTrimmed(entry["label"]);
23842
+ return {
23843
+ slug,
23844
+ ...label ? { label } : {},
23845
+ ...contextWindow !== void 0 ? { contextWindow } : {},
23846
+ ...aliases && aliases.length > 0 ? { aliases } : {}
23847
+ };
23848
+ }
23849
+
23850
+ // ../../packages/ycodium-instance-config/src/launchArgs.ts
23851
+ function tokenizeShellWords(value) {
23852
+ const input = value.trim();
23853
+ if (!input) return [];
23854
+ const tokens = [];
23855
+ let current = "";
23856
+ let quote2;
23857
+ let quoted = false;
23858
+ for (let index = 0; index < input.length; index++) {
23859
+ const char = input[index];
23860
+ if (char === void 0) continue;
23861
+ if (quote2) {
23862
+ if (char === quote2) {
23863
+ quote2 = void 0;
23864
+ quoted = true;
23865
+ } else if (char === "\\" && quote2 === '"') {
23866
+ const next = input[index + 1];
23867
+ if (next !== void 0 && ['"', "\\", "$", "`"].includes(next)) {
23868
+ current += next;
23968
23869
  index++;
23969
23870
  } else {
23970
23871
  current += char;
@@ -24001,98 +23902,49 @@ function tokenizeShellWords(value) {
24001
23902
 
24002
23903
  // src/config.ts
24003
23904
  var CLAUDE_AUTO_COMPACT_WINDOW_PATTERN = /^(?:|[1-9]\d{5}|1000000)$/;
24004
- function isRecord5(value) {
24005
- return typeof value === "object" && value !== null && !Array.isArray(value);
24006
- }
24007
- function readString3(value) {
24008
- return typeof value === "string" ? value : "";
24009
- }
24010
- function readTrimmed(value) {
24011
- return readString3(value).trim();
24012
- }
24013
- function readEnvironment(value) {
24014
- if (!Array.isArray(value)) return {};
24015
- const env2 = {};
24016
- for (const entry of value) {
24017
- if (!isRecord5(entry)) continue;
24018
- const name = readTrimmed(entry["name"]);
24019
- if (name.length === 0) continue;
24020
- env2[name] = readString3(entry["value"]);
24021
- }
24022
- return env2;
23905
+ function readThinkingOptions(entry) {
23906
+ const thinkingRaw = entry["thinkingOptions"];
23907
+ const thinkingOptions = Array.isArray(thinkingRaw) ? thinkingRaw.flatMap((option) => {
23908
+ if (!isRecord4(option)) return [];
23909
+ const id2 = readTrimmed(option["id"]) || readTrimmed(option["value"]);
23910
+ const label = readTrimmed(option["label"]) || id2;
23911
+ if (id2.length === 0) return [];
23912
+ return [
23913
+ {
23914
+ id: id2,
23915
+ label,
23916
+ ...typeof option["description"] === "string" ? { description: option["description"] } : {},
23917
+ ...option["isDefault"] === true ? { isDefault: true } : {}
23918
+ }
23919
+ ];
23920
+ }) : void 0;
23921
+ return thinkingOptions && thinkingOptions.length > 0 ? { thinkingOptions } : {};
24023
23922
  }
24024
- function readCustomModels(value) {
23923
+ function readClaudeCustomModels(value) {
24025
23924
  if (!Array.isArray(value)) return [];
24026
- const models = [];
24027
- for (const entry of value) {
24028
- if (typeof entry === "string") {
24029
- const slug2 = entry.trim();
24030
- if (slug2.length > 0) models.push({ slug: slug2 });
24031
- continue;
24032
- }
24033
- if (!isRecord5(entry)) continue;
24034
- const slug = readTrimmed(entry["slug"]);
24035
- if (slug.length === 0) continue;
24036
- const thinkingRaw = entry["thinkingOptions"];
24037
- const thinkingOptions = Array.isArray(thinkingRaw) ? thinkingRaw.flatMap((option) => {
24038
- if (!isRecord5(option)) return [];
24039
- const id2 = readTrimmed(option["id"]) || readTrimmed(option["value"]);
24040
- const label = readTrimmed(option["label"]) || id2;
24041
- if (id2.length === 0) return [];
24042
- return [
24043
- {
24044
- id: id2,
24045
- label,
24046
- ...typeof option["description"] === "string" ? { description: option["description"] } : {},
24047
- ...option["isDefault"] === true ? { isDefault: true } : {}
24048
- }
24049
- ];
24050
- }) : void 0;
24051
- const aliasesRaw = entry["aliases"];
24052
- const aliases = Array.isArray(aliasesRaw) ? aliasesRaw.filter(
24053
- (alias) => typeof alias === "string" && alias.trim().length > 0
24054
- ) : void 0;
24055
- const contextWindow = typeof entry["contextWindow"] === "number" && Number.isFinite(entry["contextWindow"]) && entry["contextWindow"] > 0 ? Math.round(entry["contextWindow"]) : void 0;
24056
- models.push({
24057
- slug,
24058
- ...readTrimmed(entry["label"]) ? { label: readTrimmed(entry["label"]) } : {},
24059
- ...thinkingOptions && thinkingOptions.length > 0 ? { thinkingOptions } : {},
24060
- ...contextWindow !== void 0 ? { contextWindow } : {},
24061
- ...aliases && aliases.length > 0 ? { aliases } : {}
24062
- });
24063
- }
24064
- return models;
23925
+ return value.flatMap((entry) => {
23926
+ const model = readCustomModel(entry);
23927
+ if (model === void 0) return [];
23928
+ return [{ ...model, ...isRecord4(entry) ? readThinkingOptions(entry) : {} }];
23929
+ });
24065
23930
  }
24066
23931
  function readAutoCompactWindow(value) {
24067
23932
  const trimmed = readTrimmed(value);
24068
23933
  return CLAUDE_AUTO_COMPACT_WINDOW_PATTERN.test(trimmed) ? trimmed : "";
24069
23934
  }
24070
23935
  function parseClaudeInstanceConfig(config) {
24071
- if (!isRecord5(config)) {
24072
- return {
24073
- binaryPath: "",
24074
- homePath: "",
24075
- credentialsPath: "",
24076
- launchArgs: "",
24077
- autoCompactWindow: "",
24078
- customModels: [],
24079
- enabled: true,
24080
- environment: {},
24081
- envelopeDriver: void 0
24082
- };
24083
- }
24084
- const nested = isRecord5(config["config"]) ? config["config"] : void 0;
24085
- const settings = nested ?? config;
23936
+ const envelope = readInstanceEnvelope(config);
23937
+ const { settings } = envelope;
24086
23938
  return {
24087
23939
  binaryPath: readTrimmed(settings["binaryPath"]),
24088
- homePath: readTrimmed(settings["homePath"]) || readTrimmed(config["homePath"]),
24089
- credentialsPath: readTrimmed(settings["credentialsPath"]) || readTrimmed(config["credentialsPath"]),
23940
+ homePath: envelope.settingOrEnvelope("homePath"),
23941
+ credentialsPath: envelope.settingOrEnvelope("credentialsPath"),
24090
23942
  launchArgs: readString3(settings["launchArgs"]),
24091
23943
  autoCompactWindow: readAutoCompactWindow(settings["autoCompactWindow"]),
24092
- customModels: readCustomModels(settings["customModels"]),
23944
+ customModels: readClaudeCustomModels(settings["customModels"]),
24093
23945
  enabled: settings["enabled"] !== false,
24094
- environment: readEnvironment(config["environment"]),
24095
- envelopeDriver: readTrimmed(config["driver"]) || void 0
23946
+ environment: envelope.environment,
23947
+ envelopeDriver: envelope.envelopeDriver
24096
23948
  };
24097
23949
  }
24098
23950
  function parseCliArgs(args, options) {
@@ -24142,7 +23994,7 @@ import {
24142
23994
  } from "@ycodium-ai/plugin-api/executor";
24143
23995
 
24144
23996
  // src/sdkModels.ts
24145
- import * as NodeOS6 from "node:os";
23997
+ import * as NodeOS5 from "node:os";
24146
23998
  import { REASONING_OPTION_LABEL as REASONING_OPTION_LABEL2, reasoningEffortShortLabel } from "@ycodium-ai/plugin-api/executor";
24147
23999
  import { OperationCleanupError } from "@ycodium-ai/plugin-api/process-operation";
24148
24000
 
@@ -24309,12 +24161,12 @@ function makeClaudeProcessSpawner(host, stderr, config = {}) {
24309
24161
  // src/sdkRead.ts
24310
24162
  var silentPrompt = (signal) => ({
24311
24163
  [Symbol.asyncIterator]: () => ({
24312
- next: () => new Promise((resolve6) => {
24164
+ next: () => new Promise((resolve7) => {
24313
24165
  if (signal.aborted) {
24314
- resolve6({ done: true, value: void 0 });
24166
+ resolve7({ done: true, value: void 0 });
24315
24167
  return;
24316
24168
  }
24317
- signal.addEventListener("abort", () => resolve6({ done: true, value: void 0 }), {
24169
+ signal.addEventListener("abort", () => resolve7({ done: true, value: void 0 }), {
24318
24170
  once: true
24319
24171
  });
24320
24172
  }),
@@ -24452,7 +24304,7 @@ function claudeModelProbeEnvironment(environment) {
24452
24304
  CLAUDE_CODE_IDE_SKIP_AUTO_INSTALL: "1"
24453
24305
  };
24454
24306
  }
24455
- var claudeSdkModelsCwd = () => NodeOS6.tmpdir();
24307
+ var claudeSdkModelsCwd = () => NodeOS5.tmpdir();
24456
24308
 
24457
24309
  // src/spawnEnvironment.ts
24458
24310
  function changedSpawnEnvironmentKeys(previous, next) {
@@ -24713,6 +24565,11 @@ var makeSdkStream = (deps) => {
24713
24565
  return { runSdkStream };
24714
24566
  };
24715
24567
 
24568
+ // src/adapter/sendTurn.ts
24569
+ import {
24570
+ reasoningLevelFallbackWarning
24571
+ } from "@ycodium-ai/plugin-api/executor";
24572
+
24716
24573
  // ../../packages/ycodium-composer-tokens/src/skillTokens.ts
24717
24574
  var SKILL_TOKEN_NAME_PATTERN = "[a-zA-Z][a-zA-Z0-9:_-]*";
24718
24575
  var SESSION_SKILL_NAMESPACE = "ycodium";
@@ -25020,22 +24877,6 @@ function assertSteeringTarget(expectedTurnId, turnState) {
25020
24877
  throw rejected;
25021
24878
  }
25022
24879
 
25023
- // src/adapter/reasoningLevelFallback.ts
25024
- var REASONING_LEVEL_FALLBACK_CODE = "reasoning-level-fallback";
25025
- function reasoningLevelFallbackWarning(input) {
25026
- const model = input.model ?? "This model";
25027
- const outcome = input.appliedEffort === void 0 ? "so the agent picks this turn's level" : `so this turn uses its default, "${input.appliedEffort}"`;
25028
- return {
25029
- message: `${model} does not offer the "${input.requestedEffort}" reasoning effort, ${outcome}. Your saved choice is unchanged.`,
25030
- detail: {
25031
- code: REASONING_LEVEL_FALLBACK_CODE,
25032
- ...input.model === void 0 ? {} : { model: input.model },
25033
- requestedEffort: input.requestedEffort,
25034
- ...input.appliedEffort === void 0 ? {} : { appliedEffort: input.appliedEffort }
25035
- }
25036
- };
25037
- }
25038
-
25039
24880
  // src/hostMcpAllowRules.ts
25040
24881
  import { setsOwnModelConnection as setsOwnModelConnection2 } from "@ycodium-ai/plugin-api/executor";
25041
24882
  function claudeHostMcpAllowRules(servers) {
@@ -25095,11 +24936,12 @@ async function applyClaudePermissionMode(context, mode, control) {
25095
24936
  }
25096
24937
 
25097
24938
  // src/adapter/sessionOptions.ts
24939
+ import { modelSelectionStringOption as modelSelectionStringOption2 } from "@ycodium-ai/plugin-api/executor";
25098
24940
  function resolveClaudeSessionOptions(input) {
25099
24941
  const { modelSelection, recipe } = input;
25100
24942
  const caps = claudeModelCapabilities(modelSelection?.model, input.catalog, recipe.customModels);
25101
24943
  const descriptors = caps.optionDescriptors;
25102
- const rawEffort = getModelSelectionStringOptionValue(modelSelection, "effort");
24944
+ const rawEffort = modelSelectionStringOption2(modelSelection, "effort");
25103
24945
  const effort = resolveClaudeEffort(caps, rawEffort) ?? null;
25104
24946
  const supports = (id2) => descriptors.some((descriptor) => descriptor.type === "boolean" && descriptor.id === id2);
25105
24947
  const fastMode = getModelSelectionBooleanOptionValue(modelSelection, "fastMode") === true && supports("fastMode");
@@ -25914,7 +25756,7 @@ var makeSessionControls = (deps) => {
25914
25756
  context.query.interrupt().then(() => settled.promise).then(() => {
25915
25757
  acknowledged = true;
25916
25758
  }),
25917
- new Promise((resolve6) => setTimeout(resolve6, CLAUDE_INTERRUPT_GRACE_MS))
25759
+ new Promise((resolve7) => setTimeout(resolve7, CLAUDE_INTERRUPT_GRACE_MS))
25918
25760
  ]);
25919
25761
  } catch (cause) {
25920
25762
  throw toRequestError(threadId, "turn/interrupt", cause);
@@ -26046,8 +25888,8 @@ var makeSessionLifecycle = (deps) => {
26046
25888
  const claim = context.turnState?.resultClaim;
26047
25889
  if (claim === void 0) return;
26048
25890
  let timer;
26049
- const timeout = new Promise((resolve6) => {
26050
- timer = setTimeout(() => resolve6("timeout"), RESULT_CLAIM_WAIT_MS);
25891
+ const timeout = new Promise((resolve7) => {
25892
+ timer = setTimeout(() => resolve7("timeout"), RESULT_CLAIM_WAIT_MS);
26051
25893
  });
26052
25894
  try {
26053
25895
  const outcome = await Promise.race([claim.then(() => "settled"), timeout]);
@@ -26146,7 +25988,7 @@ var makeSessionLifecycle = (deps) => {
26146
25988
  if (streamFiber) {
26147
25989
  await Promise.race([
26148
25990
  streamFiber.catch(() => void 0),
26149
- new Promise((resolve6) => setTimeout(resolve6, 1e3))
25991
+ new Promise((resolve7) => setTimeout(resolve7, 1e3))
26150
25992
  ]);
26151
25993
  }
26152
25994
  const updatedAt = nowIso();
@@ -26317,7 +26159,7 @@ import * as NodeFSP6 from "node:fs/promises";
26317
26159
 
26318
26160
  // src/claudeMcpConfig.ts
26319
26161
  import * as NodeFSP5 from "node:fs/promises";
26320
- import * as NodeOS7 from "node:os";
26162
+ import * as NodeOS6 from "node:os";
26321
26163
  import * as NodePath12 from "node:path";
26322
26164
  import * as NodeProcess4 from "node:process";
26323
26165
  async function createClaudeMcpConfig(mcpServers, log) {
@@ -26333,7 +26175,7 @@ async function createClaudeMcpConfig(mcpServers, log) {
26333
26175
  return { path: void 0, cleanup };
26334
26176
  }
26335
26177
  try {
26336
- directory = await NodeFSP5.mkdtemp(NodePath12.join(NodeOS7.tmpdir(), "ycodium-claude-mcp-"));
26178
+ directory = await NodeFSP5.mkdtemp(NodePath12.join(NodeOS6.tmpdir(), "ycodium-claude-mcp-"));
26337
26179
  const file = NodePath12.join(directory, "mcp.json");
26338
26180
  await NodeFSP5.writeFile(file, JSON.stringify({ mcpServers }), { mode: 384 });
26339
26181
  await NodeFSP5.chmod(file, 384).catch((cause) => {
@@ -26575,8 +26417,8 @@ var makeStartSession = (deps) => {
26575
26417
  try {
26576
26418
  return await Promise.race([
26577
26419
  contextDeferred.promise,
26578
- new Promise((resolve6) => {
26579
- timer = setTimeout(() => resolve6(void 0), CLAUDE_SESSION_CONTEXT_WAIT_MS);
26420
+ new Promise((resolve7) => {
26421
+ timer = setTimeout(() => resolve7(void 0), CLAUDE_SESSION_CONTEXT_WAIT_MS);
26580
26422
  })
26581
26423
  ]);
26582
26424
  } catch {
@@ -28090,14 +27932,14 @@ var makeTurnMessageHandlers = (deps) => {
28090
27932
  result: toolResult.block
28091
27933
  };
28092
27934
  const updatedStamp = await makeEventStamp();
28093
- offerRuntimeEvent(context, {
28094
- type: "item.updated",
28095
- ...eventHeader(context, updatedStamp),
27935
+ const offerToolItem = (type4, stamp, status) => offerRuntimeEvent(context, {
27936
+ type: type4,
27937
+ ...eventHeader(context, stamp),
28096
27938
  ...context.turnState ? { turnId: asCanonicalTurnId(context.turnState.turnId) } : {},
28097
27939
  itemId: asRuntimeItemId(tool.itemId),
28098
27940
  payload: {
28099
27941
  itemType: tool.itemType,
28100
- status: toolResult.isError ? "failed" : "inProgress",
27942
+ status,
28101
27943
  title: tool.title,
28102
27944
  ...tool.detail ? { detail: tool.detail } : {},
28103
27945
  ...tool.agentId ? { agentId: tool.agentId } : {},
@@ -28113,6 +27955,7 @@ var makeTurnMessageHandlers = (deps) => {
28113
27955
  payload: message
28114
27956
  }
28115
27957
  });
27958
+ offerToolItem("item.updated", updatedStamp, toolResult.isError ? "failed" : "inProgress");
28116
27959
  const streamKind = toolResultStreamKind(tool.itemType);
28117
27960
  if (streamKind && toolResult.text.length > 0 && context.turnState) {
28118
27961
  const deltaStamp = await makeEventStamp();
@@ -28136,29 +27979,7 @@ var makeTurnMessageHandlers = (deps) => {
28136
27979
  });
28137
27980
  }
28138
27981
  const completedStamp = await makeEventStamp();
28139
- offerRuntimeEvent(context, {
28140
- type: "item.completed",
28141
- ...eventHeader(context, completedStamp),
28142
- ...context.turnState ? { turnId: asCanonicalTurnId(context.turnState.turnId) } : {},
28143
- itemId: asRuntimeItemId(tool.itemId),
28144
- payload: {
28145
- itemType: tool.itemType,
28146
- status: itemStatus,
28147
- title: tool.title,
28148
- ...tool.detail ? { detail: tool.detail } : {},
28149
- ...tool.agentId ? { agentId: tool.agentId } : {},
28150
- ...tool.parentToolUseId ? { parentToolUseId: tool.parentToolUseId } : {},
28151
- data: toolData
28152
- },
28153
- providerRefs: nativeProviderRefs({
28154
- providerItemId: tool.itemId
28155
- }),
28156
- raw: {
28157
- source: "claude.sdk.message",
28158
- method: "claude/user",
28159
- payload: message
28160
- }
28161
- });
27982
+ offerToolItem("item.completed", completedStamp, itemStatus);
28162
27983
  if (!toolResult.isError && tool.toolName.toLowerCase() === "workflow" && toolUseResult) {
28163
27984
  const workflowTaskId = trimmedString(toolUseResult.taskId);
28164
27985
  if (workflowTaskId) {
@@ -28351,91 +28172,244 @@ function claudeSignInCommand(credentialsPath, platform4) {
28351
28172
  return withClaudeCredentialsDir({ command, credentialsDirPath, platform: platform4 });
28352
28173
  }
28353
28174
 
28354
- // src/textGeneration.ts
28355
- import * as NodeFSP8 from "node:fs/promises";
28356
- import * as NodeOS8 from "node:os";
28175
+ // src/sessions.ts
28176
+ import * as NodeFS6 from "node:fs";
28177
+ import * as NodeOS7 from "node:os";
28357
28178
  import * as NodePath15 from "node:path";
28358
- import { mergeLaunchEnv as mergeLaunchEnv2 } from "@ycodium-ai/plugin-api/executor";
28359
- import {
28360
- OperationCleanupError as OperationCleanupError2,
28361
- isOperationCleanupError as isOperationCleanupError2,
28362
- runProcessOperation as runProcessOperation2
28363
- } from "@ycodium-ai/plugin-api/process-operation";
28364
-
28365
- // src/textGenerationUtils.ts
28366
- function limitSection(value, maxChars) {
28367
- if (value.length <= maxChars) return value;
28368
- const truncated = value.slice(0, maxChars);
28369
- return `${truncated}
28370
-
28371
- [truncated]`;
28372
- }
28373
- function sanitizeCommitSubject(raw) {
28374
- const singleLine = raw.trim().split(/\r?\n/g)[0]?.trim() ?? "";
28375
- const withoutTrailingPeriod = singleLine.replace(/[.]+$/g, "").trim();
28376
- if (withoutTrailingPeriod.length === 0) {
28377
- return "Update project files";
28179
+ var fileSource = {
28180
+ createReadStream: (path) => NodeFS6.createReadStream(path)
28181
+ };
28182
+ var RECORD_FIELDS = [
28183
+ { path: ["type"] },
28184
+ { path: ["uuid"] },
28185
+ { path: ["isSidechain"] },
28186
+ { path: ["isSideChain"] },
28187
+ { path: ["isMeta"] },
28188
+ { path: ["parent_tool_use_id"] },
28189
+ { path: ["timestamp"] },
28190
+ { path: ["message", "model"] },
28191
+ { path: ["message", "content"], scalarOnly: true },
28192
+ { path: ["message", "content", "*", "type"] },
28193
+ { path: ["message", "content", "*", "text"] }
28194
+ ];
28195
+ var sessionFileSystem = {
28196
+ readDir: async (path) => (await NodeFS6.promises.readdir(path, { withFileTypes: true })).map((entry) => ({
28197
+ name: entry.name,
28198
+ type: entry.isDirectory() ? "directory" : entry.isFile() ? "file" : "other"
28199
+ })),
28200
+ stat: async (path) => {
28201
+ const stat5 = await NodeFS6.promises.stat(path);
28202
+ return { size: stat5.size, mtimeMs: stat5.mtimeMs };
28203
+ },
28204
+ readFile: (path) => NodeFS6.promises.readFile(path, "utf8")
28205
+ };
28206
+ async function scanClaudeSessions(input) {
28207
+ let root;
28208
+ try {
28209
+ root = NodeFS6.statSync(input.transcriptDir);
28210
+ } catch (error) {
28211
+ throw new Error(`The Claude transcript directory ${input.transcriptDir} is not a directory.`, {
28212
+ cause: error
28213
+ });
28378
28214
  }
28379
- if (withoutTrailingPeriod.length <= 72) {
28380
- return withoutTrailingPeriod;
28215
+ if (!root.isDirectory()) {
28216
+ throw new Error(`The Claude transcript directory ${input.transcriptDir} is not a directory.`);
28381
28217
  }
28382
- return withoutTrailingPeriod.slice(0, 72).trimEnd();
28383
- }
28384
- function sanitizePrTitle(raw) {
28385
- const singleLine = raw.trim().split(/\r?\n/g)[0]?.trim() ?? "";
28386
- if (singleLine.length > 0) {
28387
- return singleLine;
28218
+ const files = [
28219
+ ...await listClaudeTranscriptFiles(sessionFileSystem, input.transcriptDir, input.directory)
28220
+ ].sort((left, right) => right.mtimeMs - left.mtimeMs).slice(0, CLAUDE_MAX_SCANNED_FILES);
28221
+ const live = await readClaudeLiveSessionIds(sessionFileSystem, input.configDir);
28222
+ const caseInsensitive = input.caseInsensitive ?? NodeOS7.type() === "Windows_NT";
28223
+ const rows = [];
28224
+ for (const file of files) {
28225
+ if (rows.length >= CLAUDE_MAX_ROWS) break;
28226
+ const digest = await readClaudeTranscriptDigest(fileSource, file.path);
28227
+ if (digest === null || digest.cwd === null) continue;
28228
+ if (!isWithinDirectory(digest.cwd, input.directory, caseInsensitive)) continue;
28229
+ rows.push({
28230
+ nativeSessionId: file.sessionId,
28231
+ cwd: digest.cwd,
28232
+ title: digest.title,
28233
+ preview: digest.preview,
28234
+ model: digest.model,
28235
+ turnCount: digest.turnCount,
28236
+ updatedAt: file.mtimeMs,
28237
+ availability: "importable",
28238
+ openElsewhere: live.has(file.sessionId)
28239
+ });
28388
28240
  }
28389
- return "Update project changes";
28241
+ return rows;
28390
28242
  }
28391
- function unwrapNestedTitleObject(raw) {
28392
- const trimmed = raw.trim();
28393
- if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) {
28394
- return raw;
28243
+ function resolveTranscriptPath(input) {
28244
+ const fileName = `${input.sessionId}${CLAUDE_TRANSCRIPT_SUFFIX}`;
28245
+ if (input.cwd !== void 0 && input.cwd.length > 0) {
28246
+ const direct = NodePath15.join(
28247
+ input.transcriptDir,
28248
+ encodeClaudeProjectDirName(input.cwd),
28249
+ fileName
28250
+ );
28251
+ try {
28252
+ if (NodeFS6.statSync(direct).isFile()) return direct;
28253
+ } catch {
28254
+ }
28395
28255
  }
28256
+ let dirs;
28396
28257
  try {
28397
- const parsed = JSON.parse(trimmed);
28398
- if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
28399
- const nested = parsed.title;
28400
- if (typeof nested === "string") {
28401
- return nested;
28402
- }
28403
- }
28258
+ dirs = NodeFS6.readdirSync(input.transcriptDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
28404
28259
  } catch {
28260
+ return null;
28405
28261
  }
28406
- return raw;
28407
- }
28408
- var MAX_THREAD_TITLE_CHARS = 120;
28409
- function limitTitleMessage(text2, budget) {
28410
- const marker = "\n[Content truncated]\n";
28411
- if (text2.length <= budget) return text2;
28412
- if (budget <= marker.length) return "";
28413
- const available = budget - marker.length;
28414
- const head = Math.ceil(available / 2);
28415
- const tail = available - head;
28416
- return `${text2.slice(0, head)}${marker}${tail > 0 ? text2.slice(-tail) : ""}`;
28417
- }
28418
- function sanitizeThreadTitle(raw) {
28419
- const normalized = unwrapNestedTitleObject(raw).trim().split(/\r?\n/g)[0]?.trim().replace(/^['"`]+|['"`]+$/g, "").trim().replace(/\s+/g, " ");
28420
- if (!normalized || normalized.trim().length === 0) {
28421
- return "New thread";
28422
- }
28423
- if (normalized.length <= MAX_THREAD_TITLE_CHARS) {
28424
- return normalized;
28262
+ for (const dir of dirs) {
28263
+ const candidate = NodePath15.join(input.transcriptDir, dir, fileName);
28264
+ try {
28265
+ if (NodeFS6.statSync(candidate).isFile()) return candidate;
28266
+ } catch {
28267
+ continue;
28268
+ }
28425
28269
  }
28426
- return `${normalized.slice(0, MAX_THREAD_TITLE_CHARS - 3).trimEnd()}...`;
28270
+ return null;
28427
28271
  }
28428
- function sanitizeBranchFragment(raw) {
28429
- const normalized = raw.trim().toLowerCase().replace(/['"`]/g, "").replace(/^[./\s_-]+|[./\s_-]+$/g, "");
28430
- const branchFragment = normalized.replace(/[^a-z0-9/_-]+/g, "-").replace(/\/+/g, "/").replace(/-+/g, "-").replace(/^[./_-]+|[./_-]+$/g, "").slice(0, 64).replace(/[./_-]+$/g, "");
28431
- return branchFragment.length > 0 ? branchFragment : "update";
28272
+ function isRecord5(value) {
28273
+ return typeof value === "object" && value !== null && !Array.isArray(value);
28432
28274
  }
28433
- function sanitizeFeatureBranchName(raw) {
28434
- const sanitized = sanitizeBranchFragment(raw);
28435
- if (sanitized.includes("/")) {
28436
- return sanitized.startsWith("feature/") ? sanitized : `feature/${sanitized}`;
28275
+ function nonempty(value) {
28276
+ return typeof value === "string" && value.trim().length > 0 ? value : void 0;
28277
+ }
28278
+ async function readClaudeSessionRecord(input) {
28279
+ const path = resolveTranscriptPath({
28280
+ transcriptDir: input.transcriptDir,
28281
+ sessionId: input.nativeSessionId,
28282
+ cwd: input.cwd
28283
+ });
28284
+ if (path === null) {
28285
+ throw new Error(`No transcript file for Claude session ${input.nativeSessionId}.`);
28437
28286
  }
28438
- return `feature/${sanitized}`;
28287
+ const messages = [];
28288
+ const byUuid = /* @__PURE__ */ new Map();
28289
+ let model = null;
28290
+ const entries = readJsonlEntries(fileSource, path, {
28291
+ maxLineChars: CLAUDE_MAX_PARSED_LINE_BYTES,
28292
+ fields: RECORD_FIELDS
28293
+ });
28294
+ for await (const entry of entries) {
28295
+ const parsed = jsonlEntryRecord(
28296
+ entry,
28297
+ (line) => line.includes('"type":"user"') || line.includes('"type":"assistant"')
28298
+ );
28299
+ if (!isRecord5(parsed)) continue;
28300
+ if (parsed.type !== "user" && parsed.type !== "assistant") continue;
28301
+ if (parsed.isSidechain === true || parsed.isSideChain === true || parsed.isMeta === true)
28302
+ continue;
28303
+ if (nonempty(parsed.parent_tool_use_id)) continue;
28304
+ const uuid = nonempty(parsed.uuid) ?? `record:${messages.length}`;
28305
+ byUuid.set(uuid, parsed);
28306
+ }
28307
+ for (const value of byUuid.values()) {
28308
+ const message = isRecord5(value.message) ? value.message : void 0;
28309
+ if (!message) continue;
28310
+ const content = message.content;
28311
+ const blocks = typeof content === "string" ? [{ type: "text", text: content }] : Array.isArray(content) ? content : [];
28312
+ const hasToolResult = blocks.some((block) => isRecord5(block) && block.type === "tool_result");
28313
+ const text2 = blocks.flatMap((block) => {
28314
+ const typed = isRecord5(block) ? block : void 0;
28315
+ if (!typed) return [];
28316
+ if (typed.type === "text" && typeof typed.text === "string") return [typed.text];
28317
+ return [];
28318
+ }).join("\n\n").trim();
28319
+ if (text2.length === 0) continue;
28320
+ if (value.type === "user" && hasToolResult) continue;
28321
+ const role = value.type === "assistant" ? "assistant" : "user";
28322
+ if (role === "assistant" && typeof message.model === "string") model = message.model;
28323
+ const timestamp = typeof value.timestamp === "string" ? Date.parse(value.timestamp) : typeof value.timestamp === "number" ? value.timestamp : void 0;
28324
+ messages.push({
28325
+ role,
28326
+ text: text2,
28327
+ ...timestamp !== void 0 && Number.isFinite(timestamp) ? { createdAt: timestamp } : {}
28328
+ });
28329
+ }
28330
+ return {
28331
+ nativeSessionId: input.nativeSessionId,
28332
+ messages,
28333
+ resumeCursor: { resume: input.nativeSessionId },
28334
+ model
28335
+ };
28336
+ }
28337
+
28338
+ // src/textGeneration.ts
28339
+ import * as NodeFSP8 from "node:fs/promises";
28340
+ import * as NodeOS8 from "node:os";
28341
+ import * as NodePath16 from "node:path";
28342
+ import { mergeLaunchEnv as mergeLaunchEnv3, modelSelectionStringOption as modelSelectionStringOption3 } from "@ycodium-ai/plugin-api/executor";
28343
+ import {
28344
+ OperationCleanupError as OperationCleanupError2,
28345
+ runProcessOperation as runProcessOperation2
28346
+ } from "@ycodium-ai/plugin-api/process-operation";
28347
+
28348
+ // ../../packages/ycodium-text-generation/src/structuredTextGeneration.ts
28349
+ import { isOperationCleanupError as isOperationCleanupError2 } from "@ycodium-ai/plugin-api/process-operation";
28350
+
28351
+ // ../../packages/ycodium-text-generation/src/sanitize.ts
28352
+ function limitSection(value, maxChars) {
28353
+ if (value.length <= maxChars) return value;
28354
+ const truncated = value.slice(0, maxChars);
28355
+ return `${truncated}
28356
+
28357
+ [truncated]`;
28358
+ }
28359
+ function sanitizeCommitSubject(raw) {
28360
+ const singleLine = raw.trim().split(/\r?\n/g)[0]?.trim() ?? "";
28361
+ const withoutTrailingPeriod = singleLine.replace(/[.]+$/g, "").trim();
28362
+ if (withoutTrailingPeriod.length === 0) {
28363
+ return "Update project files";
28364
+ }
28365
+ if (withoutTrailingPeriod.length <= 72) {
28366
+ return withoutTrailingPeriod;
28367
+ }
28368
+ return withoutTrailingPeriod.slice(0, 72).trimEnd();
28369
+ }
28370
+ function sanitizePrTitle(raw) {
28371
+ const singleLine = raw.trim().split(/\r?\n/g)[0]?.trim() ?? "";
28372
+ if (singleLine.length > 0) {
28373
+ return singleLine;
28374
+ }
28375
+ return "Update project changes";
28376
+ }
28377
+ function unwrapNestedTitleObject(raw) {
28378
+ const trimmed = raw.trim();
28379
+ if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) {
28380
+ return raw;
28381
+ }
28382
+ try {
28383
+ const parsed = JSON.parse(trimmed);
28384
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
28385
+ const nested = parsed.title;
28386
+ if (typeof nested === "string") {
28387
+ return nested;
28388
+ }
28389
+ }
28390
+ } catch {
28391
+ }
28392
+ return raw;
28393
+ }
28394
+ var MAX_THREAD_TITLE_CHARS = 120;
28395
+ function limitTitleMessage(text2, budget) {
28396
+ const marker = "\n[Content truncated]\n";
28397
+ if (text2.length <= budget) return text2;
28398
+ if (budget <= marker.length) return "";
28399
+ const available = budget - marker.length;
28400
+ const head = Math.ceil(available / 2);
28401
+ const tail = available - head;
28402
+ return `${text2.slice(0, head)}${marker}${tail > 0 ? text2.slice(-tail) : ""}`;
28403
+ }
28404
+ function sanitizeThreadTitle(raw) {
28405
+ const normalized = unwrapNestedTitleObject(raw).trim().split(/\r?\n/g)[0]?.trim().replace(/^['"`]+|['"`]+$/g, "").trim().replace(/\s+/g, " ");
28406
+ if (!normalized || normalized.trim().length === 0) {
28407
+ return "New thread";
28408
+ }
28409
+ if (normalized.length <= MAX_THREAD_TITLE_CHARS) {
28410
+ return normalized;
28411
+ }
28412
+ return `${normalized.slice(0, MAX_THREAD_TITLE_CHARS - 3).trimEnd()}...`;
28439
28413
  }
28440
28414
  function normalizeCliError(cliName, error, fallback) {
28441
28415
  if (error instanceof Error) {
@@ -28448,7 +28422,7 @@ function normalizeCliError(cliName, error, fallback) {
28448
28422
  return new Error(fallback);
28449
28423
  }
28450
28424
 
28451
- // src/textGenerationPrompts.ts
28425
+ // ../../packages/ycodium-text-generation/src/prompts.ts
28452
28426
  var EARLIER_CONTENT_TRUNCATION_MARKER = "[Earlier content truncated]\n\n";
28453
28427
  function policyInstruction(instruction) {
28454
28428
  const trimmed = instruction?.trim();
@@ -28722,14 +28696,184 @@ function buildHandoverSummaryPrompt(input) {
28722
28696
  return { prompt, outputSchema: HANDOVER_SUMMARY_SCHEMA };
28723
28697
  }
28724
28698
 
28725
- // src/textGeneration.ts
28726
- var CLAUDE_TIMEOUT_MS = 18e4;
28699
+ // ../../packages/ycodium-text-generation/src/branchName.ts
28700
+ function sanitizeBranchFragment(raw) {
28701
+ const normalized = raw.trim().toLowerCase().replace(/['"`]/g, "").replace(/^[./\s_-]+|[./\s_-]+$/g, "");
28702
+ const branchFragment = normalized.replace(/[^a-z0-9/_-]+/g, "-").replace(/\/+/g, "/").replace(/-+/g, "-").replace(/^[./_-]+|[./_-]+$/g, "").slice(0, 64).replace(/[./_-]+$/g, "");
28703
+ return branchFragment.length > 0 ? branchFragment : "update";
28704
+ }
28705
+ function sanitizeFeatureBranchName(raw) {
28706
+ const sanitized = sanitizeBranchFragment(raw);
28707
+ if (sanitized.includes("/")) {
28708
+ return sanitized.startsWith("feature/") ? sanitized : `feature/${sanitized}`;
28709
+ }
28710
+ return `feature/${sanitized}`;
28711
+ }
28712
+
28713
+ // ../../packages/ycodium-text-generation/src/structuredTextGeneration.ts
28714
+ var FAILURE_MESSAGES = {
28715
+ generateCommitMessage: "Failed to generate commit message",
28716
+ generatePrContent: "Failed to generate change request content",
28717
+ generateBranchName: "Failed to generate branch name",
28718
+ generateThreadTitle: "Failed to generate thread title",
28719
+ summarizeHandover: "Failed to summarize handover"
28720
+ };
28727
28721
  function isRecord6(value) {
28728
28722
  return typeof value === "object" && value !== null && !Array.isArray(value);
28729
28723
  }
28730
28724
  function readString4(value) {
28731
28725
  return typeof value === "string" ? value : "";
28732
28726
  }
28727
+ function optionalString(value) {
28728
+ return typeof value === "string" ? value : void 0;
28729
+ }
28730
+ function readPolicy(value) {
28731
+ if (!isRecord6(value)) return void 0;
28732
+ const commitInstructions = optionalString(value["commitInstructions"]);
28733
+ const changeRequestInstructions = optionalString(value["changeRequestInstructions"]);
28734
+ const branchInstructions = optionalString(value["branchInstructions"]);
28735
+ const threadTitleInstructions = optionalString(value["threadTitleInstructions"]);
28736
+ return {
28737
+ ...commitInstructions === void 0 ? {} : { commitInstructions },
28738
+ ...changeRequestInstructions === void 0 ? {} : { changeRequestInstructions },
28739
+ ...branchInstructions === void 0 ? {} : { branchInstructions },
28740
+ ...threadTitleInstructions === void 0 ? {} : { threadTitleInstructions }
28741
+ };
28742
+ }
28743
+ function promptAttachments(attachments) {
28744
+ return attachments.filter(isRecord6).map((attachment) => ({
28745
+ name: optionalString(attachment["name"]) ?? "attachment",
28746
+ mimeType: optionalString(attachment["mimeType"]) ?? "application/octet-stream",
28747
+ sizeBytes: typeof attachment["sizeBytes"] === "number" ? attachment["sizeBytes"] : 0
28748
+ }));
28749
+ }
28750
+ function createStructuredTextGeneration(options) {
28751
+ const generate = async (operation, raw, signal, produce) => {
28752
+ try {
28753
+ if (!isRecord6(raw) && options.invalidInput !== void 0) {
28754
+ throw options.invalidInput(operation);
28755
+ }
28756
+ const input = isRecord6(raw) ? raw : {};
28757
+ return await produce(
28758
+ input,
28759
+ (request) => options.run({
28760
+ ...request,
28761
+ operation,
28762
+ cwd: readString4(input["cwd"]) || ".",
28763
+ modelSelection: input["modelSelection"],
28764
+ ...signal === void 0 ? {} : { signal }
28765
+ })
28766
+ );
28767
+ } catch (error) {
28768
+ if (options.cliName === void 0 || isOperationCleanupError2(error)) throw error;
28769
+ throw normalizeCliError(options.cliName, error, FAILURE_MESSAGES[operation]);
28770
+ }
28771
+ };
28772
+ return {
28773
+ generateCommitMessage: (raw, signal) => generate("generateCommitMessage", raw, signal, async (input, run) => {
28774
+ const includeBranch = input["includeBranch"] === true;
28775
+ const policy = readPolicy(input["policy"]);
28776
+ const { prompt, outputSchema } = buildCommitMessagePrompt({
28777
+ branch: optionalString(input["branch"]) ?? null,
28778
+ stagedSummary: readString4(input["stagedSummary"]),
28779
+ stagedPatch: readString4(input["stagedPatch"]),
28780
+ includeBranch,
28781
+ ...policy === void 0 ? {} : { policy }
28782
+ });
28783
+ const generated = await run({
28784
+ prompt,
28785
+ outputSchema,
28786
+ schemaKeys: includeBranch ? ["subject", "body", "branch"] : ["subject", "body"],
28787
+ attachments: []
28788
+ });
28789
+ return {
28790
+ subject: sanitizeCommitSubject(readString4(generated["subject"])),
28791
+ body: readString4(generated["body"]).trim(),
28792
+ ...typeof generated["branch"] === "string" ? { branch: sanitizeFeatureBranchName(generated["branch"]) } : {}
28793
+ };
28794
+ }),
28795
+ generatePrContent: (raw, signal) => generate("generatePrContent", raw, signal, async (input, run) => {
28796
+ const changeRequestTemplate = optionalString(input["changeRequestTemplate"]);
28797
+ const policy = readPolicy(input["policy"]);
28798
+ const { prompt, outputSchema } = buildPrContentPrompt({
28799
+ baseBranch: readString4(input["baseBranch"]),
28800
+ headBranch: readString4(input["headBranch"]),
28801
+ commitSummary: readString4(input["commitSummary"]),
28802
+ diffSummary: readString4(input["diffSummary"]),
28803
+ diffPatch: readString4(input["diffPatch"]),
28804
+ ...changeRequestTemplate === void 0 ? {} : { changeRequestTemplate },
28805
+ ...policy === void 0 ? {} : { policy }
28806
+ });
28807
+ const generated = await run({
28808
+ prompt,
28809
+ outputSchema,
28810
+ schemaKeys: ["title", "body"],
28811
+ attachments: []
28812
+ });
28813
+ return {
28814
+ title: sanitizePrTitle(readString4(generated["title"])),
28815
+ body: readString4(generated["body"]).trim()
28816
+ };
28817
+ }),
28818
+ generateBranchName: (raw, signal) => generate("generateBranchName", raw, signal, async (input, run) => {
28819
+ const attachments = Array.isArray(input["attachments"]) ? input["attachments"] : [];
28820
+ const policy = readPolicy(input["policy"]);
28821
+ const { prompt, outputSchema } = buildBranchNamePrompt({
28822
+ message: readString4(input["message"]),
28823
+ attachments: promptAttachments(attachments),
28824
+ ...policy === void 0 ? {} : { policy }
28825
+ });
28826
+ const generated = await run({
28827
+ prompt,
28828
+ outputSchema,
28829
+ schemaKeys: ["branch"],
28830
+ attachments
28831
+ });
28832
+ return { branch: sanitizeBranchFragment(readString4(generated["branch"])) };
28833
+ }),
28834
+ generateThreadTitle: (raw, signal) => generate("generateThreadTitle", raw, signal, async (input, run) => {
28835
+ const attachments = Array.isArray(input["attachments"]) ? input["attachments"] : [];
28836
+ const linkedContext = optionalString(input["linkedContext"]);
28837
+ const previousTitle = optionalString(input["previousTitle"]);
28838
+ const policy = readPolicy(input["policy"]);
28839
+ const { prompt, outputSchema } = buildThreadTitlePrompt({
28840
+ message: readString4(input["message"]),
28841
+ ...linkedContext ? { linkedContext } : {},
28842
+ ...previousTitle === void 0 ? {} : { previousTitle },
28843
+ attachments: promptAttachments(attachments),
28844
+ ...policy === void 0 ? {} : { policy }
28845
+ });
28846
+ const generated = await run({
28847
+ prompt,
28848
+ outputSchema,
28849
+ schemaKeys: ["title"],
28850
+ attachments
28851
+ });
28852
+ return {
28853
+ title: sanitizeThreadTitle(readString4(generated["title"])),
28854
+ ...generated["needsRefinement"] === true ? { needsRefinement: true } : {}
28855
+ };
28856
+ }),
28857
+ summarizeHandover: (raw, signal) => generate("summarizeHandover", raw, signal, async (input, run) => {
28858
+ const { prompt, outputSchema } = buildHandoverSummaryPrompt({
28859
+ transcript: readString4(input["transcript"])
28860
+ });
28861
+ const generated = await run({
28862
+ prompt,
28863
+ outputSchema,
28864
+ schemaKeys: ["summary"],
28865
+ attachments: []
28866
+ });
28867
+ return { summary: readString4(generated["summary"]).trim() };
28868
+ })
28869
+ };
28870
+ }
28871
+
28872
+ // src/textGeneration.ts
28873
+ var CLAUDE_TIMEOUT_MS = 18e4;
28874
+ function isRecord7(value) {
28875
+ return typeof value === "object" && value !== null && !Array.isArray(value);
28876
+ }
28733
28877
  function decodeStructuredOutput(stdout, operation) {
28734
28878
  let parsed;
28735
28879
  try {
@@ -28739,8 +28883,8 @@ function decodeStructuredOutput(stdout, operation) {
28739
28883
  cause: error
28740
28884
  });
28741
28885
  }
28742
- const envelope = Array.isArray(parsed) ? parsed.findLast((message) => isRecord6(message) && message["type"] === "result") : parsed;
28743
- if (!isRecord6(envelope) || !("structured_output" in envelope)) {
28886
+ const envelope = Array.isArray(parsed) ? parsed.findLast((message) => isRecord7(message) && message["type"] === "result") : parsed;
28887
+ if (!isRecord7(envelope) || !("structured_output" in envelope)) {
28744
28888
  throw new Error(`${operation}: Claude CLI returned unexpected output format.`);
28745
28889
  }
28746
28890
  return envelope["structured_output"];
@@ -28748,14 +28892,14 @@ function decodeStructuredOutput(stdout, operation) {
28748
28892
  function createClaudeTextGeneration(recipe, host, modelCatalog) {
28749
28893
  const runClaudeJson = async (input) => {
28750
28894
  input.signal?.throwIfAborted();
28751
- const processEnv = mergeLaunchEnv2({
28895
+ const processEnv = mergeLaunchEnv3({
28752
28896
  instanceTable: recipe.environment,
28753
28897
  handOverrides: claudeHomeVariables(resolveClaudeHomeLayout(recipe))
28754
28898
  });
28755
- const modelSelection = isRecord6(input.modelSelection) ? input.modelSelection : {};
28899
+ const modelSelection = isRecord7(input.modelSelection) ? input.modelSelection : {};
28756
28900
  const requestedModel = modelIdFromSelection(modelSelection) ?? "claude-haiku-4-5";
28757
28901
  const caps = claudeModelCapabilities(requestedModel, modelCatalog(), recipe.customModels);
28758
- const rawEffort = getModelSelectionStringOptionValue(modelSelection, "effort");
28902
+ const rawEffort = modelSelectionStringOption3(modelSelection, "effort");
28759
28903
  const resolvedEffort = resolveClaudeEffort(caps, rawEffort);
28760
28904
  const cliEffort = normalizeClaudeCliEffort(resolvedEffort);
28761
28905
  const ultracode = isClaudeUltracodeEffort(resolvedEffort);
@@ -28815,7 +28959,7 @@ function createClaudeTextGeneration(recipe, host, modelCatalog) {
28815
28959
  };
28816
28960
  if (input.operation !== "generateThreadTitle") return runIn(input.cwd);
28817
28961
  const scratchDirectory = await NodeFSP8.mkdtemp(
28818
- NodePath15.join(NodeOS8.tmpdir(), "ycodium-claude-title-")
28962
+ NodePath16.join(NodeOS8.tmpdir(), "ycodium-claude-title-")
28819
28963
  );
28820
28964
  try {
28821
28965
  return await runIn(scratchDirectory);
@@ -28825,164 +28969,26 @@ function createClaudeTextGeneration(recipe, host, modelCatalog) {
28825
28969
  }
28826
28970
  }
28827
28971
  };
28828
- const asRecord2 = (value, operation) => {
28829
- if (!isRecord6(value))
28830
- throw new Error(`${operation}: Claude returned invalid structured output.`);
28831
- return value;
28832
- };
28833
- return {
28834
- generateCommitMessage: async (raw, signal) => {
28835
- try {
28836
- const input = asRecord2(raw, "generateCommitMessage");
28837
- const includeBranch = input["includeBranch"] === true;
28838
- const { prompt, outputSchema } = buildCommitMessagePrompt({
28839
- branch: typeof input["branch"] === "string" ? input["branch"] : null,
28840
- stagedSummary: readString4(input["stagedSummary"]),
28841
- stagedPatch: readString4(input["stagedPatch"]),
28842
- includeBranch,
28843
- ...isRecord6(input["policy"]) ? { policy: input["policy"] } : {}
28844
- });
28845
- const generated = asRecord2(
28846
- await runClaudeJson({
28847
- operation: "generateCommitMessage",
28848
- cwd: readString4(input["cwd"]) || ".",
28849
- prompt,
28850
- outputSchema,
28851
- modelSelection: input["modelSelection"],
28852
- ...signal === void 0 ? {} : { signal }
28853
- }),
28854
- "generateCommitMessage"
28855
- );
28856
- return {
28857
- subject: sanitizeCommitSubject(readString4(generated["subject"])),
28858
- body: readString4(generated["body"]).trim(),
28859
- ...typeof generated["branch"] === "string" ? { branch: sanitizeFeatureBranchName(generated["branch"]) } : {}
28860
- };
28861
- } catch (error) {
28862
- if (isOperationCleanupError2(error)) throw error;
28863
- throw normalizeCliError("claude", error, "Failed to generate commit message");
28864
- }
28865
- },
28866
- generatePrContent: async (raw, signal) => {
28867
- try {
28868
- const input = asRecord2(raw, "generatePrContent");
28869
- const { prompt, outputSchema } = buildPrContentPrompt({
28870
- baseBranch: readString4(input["baseBranch"]),
28871
- headBranch: readString4(input["headBranch"]),
28872
- commitSummary: readString4(input["commitSummary"]),
28873
- diffSummary: readString4(input["diffSummary"]),
28874
- diffPatch: readString4(input["diffPatch"]),
28875
- ...typeof input["changeRequestTemplate"] === "string" ? { changeRequestTemplate: input["changeRequestTemplate"] } : {},
28876
- ...isRecord6(input["policy"]) ? { policy: input["policy"] } : {}
28877
- });
28878
- const generated = asRecord2(
28879
- await runClaudeJson({
28880
- operation: "generatePrContent",
28881
- cwd: readString4(input["cwd"]) || ".",
28882
- prompt,
28883
- outputSchema,
28884
- modelSelection: input["modelSelection"],
28885
- ...signal === void 0 ? {} : { signal }
28886
- }),
28887
- "generatePrContent"
28888
- );
28889
- return {
28890
- title: sanitizePrTitle(readString4(generated["title"])),
28891
- body: readString4(generated["body"]).trim()
28892
- };
28893
- } catch (error) {
28894
- if (isOperationCleanupError2(error)) throw error;
28895
- throw normalizeCliError("claude", error, "Failed to generate change request content");
28896
- }
28897
- },
28898
- generateBranchName: async (raw, signal) => {
28899
- try {
28900
- const input = asRecord2(raw, "generateBranchName");
28901
- const { prompt, outputSchema } = buildBranchNamePrompt({
28902
- message: readString4(input["message"]),
28903
- ...Array.isArray(input["attachments"]) ? { attachments: input["attachments"] } : {},
28904
- ...isRecord6(input["policy"]) ? { policy: input["policy"] } : {}
28905
- });
28906
- const generated = asRecord2(
28907
- await runClaudeJson({
28908
- operation: "generateBranchName",
28909
- cwd: readString4(input["cwd"]) || ".",
28910
- prompt,
28911
- outputSchema,
28912
- modelSelection: input["modelSelection"],
28913
- ...signal === void 0 ? {} : { signal }
28914
- }),
28915
- "generateBranchName"
28916
- );
28917
- return { branch: sanitizeBranchFragment(readString4(generated["branch"])) };
28918
- } catch (error) {
28919
- if (isOperationCleanupError2(error)) throw error;
28920
- throw normalizeCliError("claude", error, "Failed to generate branch name");
28921
- }
28922
- },
28923
- generateThreadTitle: async (raw, signal) => {
28924
- try {
28925
- const input = asRecord2(raw, "generateThreadTitle");
28926
- const { prompt, outputSchema } = buildThreadTitlePrompt({
28927
- message: readString4(input["message"]),
28928
- ...typeof input["linkedContext"] === "string" && input["linkedContext"].length > 0 ? { linkedContext: input["linkedContext"] } : {},
28929
- ...typeof input["previousTitle"] === "string" ? { previousTitle: input["previousTitle"] } : {},
28930
- ...Array.isArray(input["attachments"]) ? { attachments: input["attachments"] } : {},
28931
- ...isRecord6(input["policy"]) ? { policy: input["policy"] } : {}
28932
- });
28933
- const generated = asRecord2(
28934
- await runClaudeJson({
28935
- operation: "generateThreadTitle",
28936
- cwd: readString4(input["cwd"]) || ".",
28937
- prompt,
28938
- outputSchema,
28939
- modelSelection: input["modelSelection"],
28940
- ...signal === void 0 ? {} : { signal }
28941
- }),
28942
- "generateThreadTitle"
28943
- );
28944
- return {
28945
- title: sanitizeThreadTitle(readString4(generated["title"])),
28946
- ...generated["needsRefinement"] === true ? { needsRefinement: true } : {}
28947
- };
28948
- } catch (error) {
28949
- if (isOperationCleanupError2(error)) throw error;
28950
- throw normalizeCliError("claude", error, "Failed to generate thread title");
28951
- }
28952
- },
28953
- summarizeHandover: async (raw, signal) => {
28954
- try {
28955
- const input = asRecord2(raw, "summarizeHandover");
28956
- const { prompt, outputSchema } = buildHandoverSummaryPrompt({
28957
- transcript: readString4(input["transcript"])
28958
- });
28959
- const generated = asRecord2(
28960
- await runClaudeJson({
28961
- operation: "summarizeHandover",
28962
- cwd: readString4(input["cwd"]) || ".",
28963
- prompt,
28964
- outputSchema,
28965
- modelSelection: input["modelSelection"],
28966
- ...signal === void 0 ? {} : { signal }
28967
- }),
28968
- "summarizeHandover"
28969
- );
28970
- return { summary: readString4(generated["summary"]).trim() };
28971
- } catch (error) {
28972
- if (isOperationCleanupError2(error)) throw error;
28973
- throw normalizeCliError("claude", error, "Failed to summarize handover");
28972
+ return createStructuredTextGeneration({
28973
+ cliName: "claude",
28974
+ invalidInput: (operation) => new Error(`${operation}: Claude returned invalid structured output.`),
28975
+ run: async (request) => {
28976
+ const generated = await runClaudeJson(request);
28977
+ if (!isRecord7(generated)) {
28978
+ throw new Error(`${request.operation}: Claude returned invalid structured output.`);
28974
28979
  }
28980
+ return generated;
28975
28981
  }
28976
- };
28982
+ });
28977
28983
  }
28978
28984
 
28979
28985
  // src/usageRead/index.ts
28980
- import * as NodePath18 from "node:path";
28986
+ import * as NodePath19 from "node:path";
28981
28987
 
28982
28988
  // src/usageRead/nativeQuota.ts
28983
28989
  import * as NodeOS9 from "node:os";
28984
- import { mergeLaunchEnv as mergeLaunchEnv3 } from "@ycodium-ai/plugin-api/executor";
28985
- var isRecord7 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
28990
+ import { mergeLaunchEnv as mergeLaunchEnv4 } from "@ycodium-ai/plugin-api/executor";
28991
+ var isRecord8 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
28986
28992
  function quotaWriter(write) {
28987
28993
  const decoder = new TextDecoder();
28988
28994
  let pending2 = "";
@@ -28994,7 +29000,7 @@ function quotaWriter(write) {
28994
29000
  pending2 = pending2.slice(end + 1);
28995
29001
  if (line.trim().length === 0) continue;
28996
29002
  const frame = JSON.parse(line);
28997
- if (isRecord7(frame) && frame.type === "control_request" && isRecord7(frame.request) && frame.request.subtype === "get_usage") {
29003
+ if (isRecord8(frame) && frame.type === "control_request" && isRecord8(frame.request) && frame.request.subtype === "get_usage") {
28998
29004
  frame.request = { ...frame.request, skip_behaviors: true };
28999
29005
  }
29000
29006
  await write(JSON.stringify(frame) + "\n");
@@ -29002,11 +29008,11 @@ function quotaWriter(write) {
29002
29008
  };
29003
29009
  }
29004
29010
  function quotaReading(value) {
29005
- if (!isRecord7(value)) return { status: "unavailable", reason: "unreachable" };
29011
+ if (!isRecord8(value)) return { status: "unavailable", reason: "unreachable" };
29006
29012
  if (value.rate_limits_available === false) {
29007
29013
  return { status: "unavailable", reason: "unsupportedLogin" };
29008
29014
  }
29009
- if (value.rate_limits_available !== true || !isRecord7(value.rate_limits)) {
29015
+ if (value.rate_limits_available !== true || !isRecord8(value.rate_limits)) {
29010
29016
  return { status: "unavailable", reason: "unreachable" };
29011
29017
  }
29012
29018
  const plan = claudePlanName({
@@ -29025,7 +29031,7 @@ async function readClaudeNativeQuota(input) {
29025
29031
  signal?.throwIfAborted();
29026
29032
  if (!recipe.binaryPath) return void 0;
29027
29033
  try {
29028
- const environment = mergeLaunchEnv3({
29034
+ const environment = mergeLaunchEnv4({
29029
29035
  inherited: process.env,
29030
29036
  instanceTable: recipe.environment,
29031
29037
  handOverrides: claudeHomeVariables(resolveClaudeHomeLayout(recipe))
@@ -29068,10 +29074,10 @@ async function readClaudeNativeQuota(input) {
29068
29074
  }
29069
29075
 
29070
29076
  // src/usageRead/rateLimitEvent.ts
29071
- var isRecord8 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
29077
+ var isRecord9 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
29072
29078
  var claudeQuotaFromRateLimitEvent = (message) => {
29073
- const info = isRecord8(message) ? message["rate_limit_info"] : void 0;
29074
- if (!isRecord8(info)) return null;
29079
+ const info = isRecord9(message) ? message["rate_limit_info"] : void 0;
29080
+ if (!isRecord9(info)) return null;
29075
29081
  const spec = CLAUDE_QUOTA_WINDOWS.find((window2) => window2.field === info["rateLimitType"]);
29076
29082
  const utilization = info["utilization"];
29077
29083
  if (spec === void 0 || typeof utilization !== "number" || !Number.isFinite(utilization)) {
@@ -29091,64 +29097,11 @@ var claudeQuotaFromRateLimitEvent = (message) => {
29091
29097
  };
29092
29098
  };
29093
29099
 
29094
- // src/usageRead/scanCache.ts
29095
- import * as NodePath17 from "node:path";
29096
-
29097
- // src/usageRead/transcriptScan.ts
29100
+ // ../../packages/ycodium-jsonl-stream/src/appendedJsonl.ts
29098
29101
  import * as NodeFS7 from "node:fs";
29099
- import * as NodePath16 from "node:path";
29100
-
29101
- // src/usageRead/transcriptLine.ts
29102
- var int = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.trunc(value) : 0;
29103
- var parseTimestampMs = (value) => {
29104
- if (typeof value !== "string") return null;
29105
- const parsed = Date.parse(value);
29106
- return Number.isNaN(parsed) ? null : parsed;
29107
- };
29108
- var mightCarryUsage = (line) => line.includes('"usage"');
29109
- var parseClaudeLine = (line) => {
29110
- let parsed;
29111
- try {
29112
- parsed = JSON.parse(line);
29113
- } catch {
29114
- return null;
29115
- }
29116
- if (typeof parsed !== "object" || parsed === null) return null;
29117
- const record2 = parsed;
29118
- if (record2["type"] !== "assistant") return null;
29119
- const message = record2["message"];
29120
- if (typeof message !== "object" || message === null) return null;
29121
- const messageRecord = message;
29122
- const usage = messageRecord["usage"];
29123
- if (typeof usage !== "object" || usage === null) return null;
29124
- const usageRecord = usage;
29125
- const timestampMs = parseTimestampMs(record2["timestamp"]);
29126
- if (timestampMs === null) return null;
29127
- const model = typeof messageRecord["model"] === "string" ? messageRecord["model"] : "";
29128
- if (model.length === 0) return null;
29129
- const messageId = typeof messageRecord["id"] === "string" ? messageRecord["id"] : null;
29130
- const requestId = typeof record2["requestId"] === "string" ? record2["requestId"] : null;
29131
- const dedupeKey = messageId === null && requestId === null ? null : `${messageId ?? ""}:${requestId ?? ""}`;
29132
- const cost = record2["costUSD"];
29133
- return {
29134
- timestampMs,
29135
- model,
29136
- sessionId: typeof record2["sessionId"] === "string" ? record2["sessionId"] : "",
29137
- totals: {
29138
- uncachedInputTokens: int(usageRecord["input_tokens"]),
29139
- cachedInputTokens: int(usageRecord["cache_read_input_tokens"]),
29140
- cacheCreationTokens: int(usageRecord["cache_creation_input_tokens"]),
29141
- outputTokens: int(usageRecord["output_tokens"]),
29142
- reasoningTokens: 0
29143
- },
29144
- reportedCostUsd: typeof cost === "number" && Number.isFinite(cost) ? cost : null,
29145
- dedupeKey
29146
- };
29147
- };
29148
-
29149
- // src/usageRead/transcriptScan.ts
29150
- var TRANSCRIPT_SUFFIX2 = ".jsonl";
29151
- async function listTranscriptFiles2(root, sinceMs) {
29102
+ import * as NodePath17 from "node:path";
29103
+ var JSONL_SUFFIX = ".jsonl";
29104
+ async function listJsonlFiles(root, sinceMs) {
29152
29105
  const found = [];
29153
29106
  const walk = async (dir) => {
29154
29107
  let entries;
@@ -29158,34 +29111,25 @@ async function listTranscriptFiles2(root, sinceMs) {
29158
29111
  return;
29159
29112
  }
29160
29113
  for (const entry of entries) {
29161
- const child = NodePath16.join(dir, entry.name);
29114
+ const child = NodePath17.join(dir, entry.name);
29162
29115
  if (entry.isDirectory()) {
29163
29116
  await walk(child);
29164
29117
  continue;
29165
29118
  }
29166
- if (!entry.isFile() || !entry.name.endsWith(TRANSCRIPT_SUFFIX2)) continue;
29119
+ if (!entry.isFile() || !entry.name.endsWith(JSONL_SUFFIX)) continue;
29167
29120
  let stat5;
29168
29121
  try {
29169
29122
  stat5 = await NodeFS7.promises.stat(child);
29170
29123
  } catch {
29171
29124
  continue;
29172
29125
  }
29173
- if (stat5.mtimeMs < sinceMs) continue;
29174
- found.push({ path: child, size: stat5.size, mtimeMs: stat5.mtimeMs });
29126
+ if (stat5.mtimeMs >= sinceMs)
29127
+ found.push({ path: child, size: stat5.size, mtimeMs: stat5.mtimeMs });
29175
29128
  }
29176
29129
  };
29177
29130
  await walk(root);
29178
29131
  return found;
29179
29132
  }
29180
- async function statTranscriptRoot(root) {
29181
- try {
29182
- const stat5 = await NodeFS7.promises.stat(root);
29183
- if (!stat5.isDirectory()) return null;
29184
- return { volumeId: stat5.ino === 0 ? "" : `${String(stat5.dev)}:${String(stat5.ino)}` };
29185
- } catch {
29186
- return null;
29187
- }
29188
- }
29189
29133
  var GUARD_LENGTH = 64;
29190
29134
  var NEWLINE = 10;
29191
29135
  var CARRIAGE_RETURN = 13;
@@ -29215,7 +29159,7 @@ async function readMatchingGuard(filePath, position) {
29215
29159
  return null;
29216
29160
  }
29217
29161
  }
29218
- async function readTranscriptRecords(filePath, resumeFrom) {
29162
+ async function readAppendedJsonl(filePath, resumeFrom, openParser) {
29219
29163
  try {
29220
29164
  let resumed = false;
29221
29165
  let start = 0;
@@ -29228,11 +29172,7 @@ async function readTranscriptRecords(filePath, resumeFrom) {
29228
29172
  resumed = true;
29229
29173
  }
29230
29174
  }
29231
- const parseLine = (line, out) => {
29232
- if (!mightCarryUsage(line)) return;
29233
- const record2 = parseClaudeLine(line);
29234
- if (record2 !== null) out.push(record2);
29235
- };
29175
+ const parser = openParser(resumed);
29236
29176
  const toLineString = (lineBuffer) => {
29237
29177
  const content = lineBuffer.length > 0 && lineBuffer[lineBuffer.length - 1] === CARRIAGE_RETURN ? lineBuffer.subarray(0, -1) : lineBuffer;
29238
29178
  return content.toString("utf8");
@@ -29252,7 +29192,8 @@ async function readTranscriptRecords(filePath, resumeFrom) {
29252
29192
  for (; ; ) {
29253
29193
  const newlineIndex = buffer.indexOf(NEWLINE, lineStart);
29254
29194
  if (newlineIndex === -1) break;
29255
- parseLine(toLineString(buffer.subarray(lineStart, newlineIndex)), records);
29195
+ const record2 = parser.line(toLineString(buffer.subarray(lineStart, newlineIndex)));
29196
+ if (record2 !== null) records.push(record2);
29256
29197
  lineStart = newlineIndex + 1;
29257
29198
  }
29258
29199
  resumeOffset += lineStart;
@@ -29263,7 +29204,10 @@ async function readTranscriptRecords(filePath, resumeFrom) {
29263
29204
  const tailRecords = [];
29264
29205
  if (pendingChunks.length > 0) {
29265
29206
  const pending2 = pendingChunks.length === 1 ? pendingChunks[0] : Buffer.concat(pendingChunks);
29266
- if (pending2.length > 0) parseLine(toLineString(pending2), tailRecords);
29207
+ if (pending2.length > 0) {
29208
+ const record2 = parser.tail(toLineString(pending2));
29209
+ if (record2 !== null) tailRecords.push(record2);
29210
+ }
29267
29211
  }
29268
29212
  return {
29269
29213
  records,
@@ -29280,25 +29224,67 @@ async function readTranscriptRecords(filePath, resumeFrom) {
29280
29224
  }
29281
29225
  }
29282
29226
 
29227
+ // ../../packages/ycodium-jsonl-stream/src/scanCache.ts
29228
+ import * as NodePath18 from "node:path";
29229
+ function createStringTable() {
29230
+ const values = [];
29231
+ const index = /* @__PURE__ */ new Map();
29232
+ return {
29233
+ values,
29234
+ intern: (value) => {
29235
+ const existing = index.get(value);
29236
+ if (existing !== void 0) return existing;
29237
+ const next = values.length;
29238
+ values.push(value);
29239
+ index.set(value, next);
29240
+ return next;
29241
+ }
29242
+ };
29243
+ }
29244
+ function encodeCachedFile(entry, serialize) {
29245
+ return {
29246
+ s: entry.size,
29247
+ m: entry.mtimeMs,
29248
+ r: entry.records.map(serialize),
29249
+ t: entry.tailRecords.map(serialize),
29250
+ o: entry.position.resumeOffset,
29251
+ gl: entry.position.guardLength,
29252
+ gh: entry.position.guardHash
29253
+ };
29254
+ }
29255
+ function decodeCachedPosition(entry) {
29256
+ const { o, gl: gl2, gh: gh2 } = entry;
29257
+ if (typeof o !== "number" || !Number.isSafeInteger(o) || o < 0 || typeof gl2 !== "number" || !Number.isSafeInteger(gl2) || gl2 < 0 || gl2 > GUARD_LENGTH || gl2 > o || typeof gh2 !== "number" || !Number.isFinite(gh2)) {
29258
+ return void 0;
29259
+ }
29260
+ return { resumeOffset: o, guardLength: gl2, guardHash: gh2 };
29261
+ }
29262
+ function pruneScanCache(cache, options) {
29263
+ let removed = 0;
29264
+ for (const [path, entry] of cache) {
29265
+ const agedOut = entry.mtimeMs < options.retentionCutoffMs;
29266
+ const underWalkedRoot = options.walkedRoots.some((root) => {
29267
+ const relative2 = NodePath18.relative(root, path);
29268
+ return relative2 === "" || relative2 !== ".." && !relative2.startsWith(`..${NodePath18.sep}`) && !NodePath18.isAbsolute(relative2);
29269
+ });
29270
+ const deleted = underWalkedRoot && entry.mtimeMs >= options.windowStartMs && !options.livePaths.has(path);
29271
+ if (agedOut || deleted) {
29272
+ cache.delete(path);
29273
+ removed += 1;
29274
+ }
29275
+ }
29276
+ return removed;
29277
+ }
29278
+
29283
29279
  // src/usageRead/scanCache.ts
29284
29280
  var USAGE_SCAN_CACHE_VERSION = 1;
29285
29281
  function encodeScanCache(cache) {
29286
- const models = [];
29287
- const sessions = [];
29288
- const modelIndex = /* @__PURE__ */ new Map();
29289
- const sessionIndex = /* @__PURE__ */ new Map();
29290
- const intern = (table, index, value) => {
29291
- const existing = index.get(value);
29292
- if (existing !== void 0) return existing;
29293
- const next = table.length;
29294
- table.push(value);
29295
- index.set(value, next);
29296
- return next;
29297
- };
29282
+ const models = createStringTable();
29283
+ const sessions = createStringTable();
29298
29284
  const serializeRecord = (record2) => [
29299
29285
  record2.timestampMs,
29300
- intern(models, modelIndex, record2.model),
29301
- intern(sessions, sessionIndex, record2.sessionId),
29286
+ models.intern(record2.model),
29287
+ sessions.intern(record2.sessionId),
29302
29288
  record2.totals.uncachedInputTokens,
29303
29289
  record2.totals.cachedInputTokens,
29304
29290
  record2.totals.cacheCreationTokens,
@@ -29309,17 +29295,14 @@ function encodeScanCache(cache) {
29309
29295
  ];
29310
29296
  const files = {};
29311
29297
  for (const [path, entry] of cache) {
29312
- files[path] = {
29313
- s: entry.size,
29314
- m: entry.mtimeMs,
29315
- r: entry.records.map(serializeRecord),
29316
- t: entry.tailRecords.map(serializeRecord),
29317
- o: entry.position.resumeOffset,
29318
- gl: entry.position.guardLength,
29319
- gh: entry.position.guardHash
29320
- };
29298
+ files[path] = encodeCachedFile(entry, serializeRecord);
29321
29299
  }
29322
- return { version: USAGE_SCAN_CACHE_VERSION, models, sessions, files };
29300
+ return {
29301
+ version: USAGE_SCAN_CACHE_VERSION,
29302
+ models: models.values,
29303
+ sessions: sessions.values,
29304
+ files
29305
+ };
29323
29306
  }
29324
29307
  function decodeScanCache(document) {
29325
29308
  const cache = /* @__PURE__ */ new Map();
@@ -29374,9 +29357,8 @@ function decodeScanCache(document) {
29374
29357
  const entry = raw;
29375
29358
  if (typeof entry.s !== "number" || typeof entry.m !== "number") continue;
29376
29359
  if (!Array.isArray(entry.r) || !Array.isArray(entry.t)) continue;
29377
- if (typeof entry.o !== "number" || !Number.isSafeInteger(entry.o) || entry.o < 0 || typeof entry.gl !== "number" || !Number.isSafeInteger(entry.gl) || entry.gl < 0 || entry.gl > GUARD_LENGTH || entry.gl > entry.o || typeof entry.gh !== "number" || !Number.isFinite(entry.gh)) {
29378
- continue;
29379
- }
29360
+ const position = decodeCachedPosition(entry);
29361
+ if (position === void 0) continue;
29380
29362
  const records = decodeRecords(entry.r);
29381
29363
  const tailRecords = decodeRecords(entry.t);
29382
29364
  if (records === null || tailRecords === null) continue;
@@ -29385,27 +29367,11 @@ function decodeScanCache(document) {
29385
29367
  mtimeMs: entry.m,
29386
29368
  records,
29387
29369
  tailRecords,
29388
- position: { resumeOffset: entry.o, guardLength: entry.gl, guardHash: entry.gh }
29370
+ position
29389
29371
  });
29390
29372
  }
29391
29373
  return cache;
29392
29374
  }
29393
- function pruneScanCache(cache, options) {
29394
- let removed = 0;
29395
- for (const [path, entry] of cache) {
29396
- const agedOut = entry.mtimeMs < options.retentionCutoffMs;
29397
- const underWalkedRoot = options.walkedRoots.some((root) => {
29398
- const relative2 = NodePath17.relative(root, path);
29399
- return relative2 === "" || relative2 !== ".." && !relative2.startsWith(`..${NodePath17.sep}`) && !NodePath17.isAbsolute(relative2);
29400
- });
29401
- const deleted = underWalkedRoot && entry.mtimeMs >= options.windowStartMs && !options.livePaths.has(path);
29402
- if (agedOut || deleted) {
29403
- cache.delete(path);
29404
- removed += 1;
29405
- }
29406
- }
29407
- return removed;
29408
- }
29409
29375
  function dedupeWithinFile(records, seen = /* @__PURE__ */ new Set()) {
29410
29376
  const kept = [];
29411
29377
  for (const record2 of records) {
@@ -29418,6 +29384,74 @@ function dedupeWithinFile(records, seen = /* @__PURE__ */ new Set()) {
29418
29384
  return kept;
29419
29385
  }
29420
29386
 
29387
+ // src/usageRead/transcriptScan.ts
29388
+ import * as NodeFS8 from "node:fs";
29389
+
29390
+ // ../../packages/ycodium-jsonl-stream/src/usageFields.ts
29391
+ var tokenCount = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.trunc(value) : 0;
29392
+ var parseTimestampMs = (value) => {
29393
+ if (typeof value !== "string") return null;
29394
+ const parsed = Date.parse(value);
29395
+ return Number.isNaN(parsed) ? null : parsed;
29396
+ };
29397
+
29398
+ // src/usageRead/transcriptLine.ts
29399
+ var mightCarryUsage = (line) => line.includes('"usage"');
29400
+ var parseClaudeLine = (line) => {
29401
+ let parsed;
29402
+ try {
29403
+ parsed = JSON.parse(line);
29404
+ } catch {
29405
+ return null;
29406
+ }
29407
+ if (typeof parsed !== "object" || parsed === null) return null;
29408
+ const record2 = parsed;
29409
+ if (record2["type"] !== "assistant") return null;
29410
+ const message = record2["message"];
29411
+ if (typeof message !== "object" || message === null) return null;
29412
+ const messageRecord = message;
29413
+ const usage = messageRecord["usage"];
29414
+ if (typeof usage !== "object" || usage === null) return null;
29415
+ const usageRecord = usage;
29416
+ const timestampMs = parseTimestampMs(record2["timestamp"]);
29417
+ if (timestampMs === null) return null;
29418
+ const model = typeof messageRecord["model"] === "string" ? messageRecord["model"] : "";
29419
+ if (model.length === 0) return null;
29420
+ const messageId = typeof messageRecord["id"] === "string" ? messageRecord["id"] : null;
29421
+ const requestId = typeof record2["requestId"] === "string" ? record2["requestId"] : null;
29422
+ const dedupeKey = messageId === null && requestId === null ? null : `${messageId ?? ""}:${requestId ?? ""}`;
29423
+ const cost = record2["costUSD"];
29424
+ return {
29425
+ timestampMs,
29426
+ model,
29427
+ sessionId: typeof record2["sessionId"] === "string" ? record2["sessionId"] : "",
29428
+ totals: {
29429
+ uncachedInputTokens: tokenCount(usageRecord["input_tokens"]),
29430
+ cachedInputTokens: tokenCount(usageRecord["cache_read_input_tokens"]),
29431
+ cacheCreationTokens: tokenCount(usageRecord["cache_creation_input_tokens"]),
29432
+ outputTokens: tokenCount(usageRecord["output_tokens"]),
29433
+ reasoningTokens: 0
29434
+ },
29435
+ reportedCostUsd: typeof cost === "number" && Number.isFinite(cost) ? cost : null,
29436
+ dedupeKey
29437
+ };
29438
+ };
29439
+
29440
+ // src/usageRead/transcriptScan.ts
29441
+ async function statTranscriptRoot(root) {
29442
+ try {
29443
+ const stat5 = await NodeFS8.promises.stat(root);
29444
+ if (!stat5.isDirectory()) return null;
29445
+ return { volumeId: stat5.ino === 0 ? "" : `${String(stat5.dev)}:${String(stat5.ino)}` };
29446
+ } catch {
29447
+ return null;
29448
+ }
29449
+ }
29450
+ var parseLine = (line) => mightCarryUsage(line) ? parseClaudeLine(line) : null;
29451
+ function readTranscriptRecords(filePath, resumeFrom) {
29452
+ return readAppendedJsonl(filePath, resumeFrom, () => ({ line: parseLine, tail: parseLine }));
29453
+ }
29454
+
29421
29455
  // src/usageRead/tokenUsage.ts
29422
29456
  var MTIME_SLACK_MS = 36 * 60 * 60 * 1e3;
29423
29457
  var CACHE_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
@@ -29487,7 +29521,7 @@ var createClaudeTokenReader = (options) => {
29487
29521
  await ensureLoaded(runtime, transcriptRoot, cache);
29488
29522
  const startedAtMs = Date.now();
29489
29523
  const windowStartMs = sinceMs - MTIME_SLACK_MS;
29490
- const files = (await listTranscriptFiles2(transcriptRoot, windowStartMs)).toSorted(
29524
+ const files = (await listJsonlFiles(transcriptRoot, windowStartMs)).toSorted(
29491
29525
  (a, b3) => a.path < b3.path ? -1 : a.path > b3.path ? 1 : 0
29492
29526
  );
29493
29527
  let scannedFiles = 0;
@@ -29572,7 +29606,7 @@ var createClaudeUsage = (input) => {
29572
29606
  });
29573
29607
  const tokens = createClaudeTokenReader({
29574
29608
  configDir,
29575
- transcriptRoot: NodePath18.join(configDir, "projects"),
29609
+ transcriptRoot: NodePath19.join(configDir, "projects"),
29576
29610
  cache: input.cache
29577
29611
  });
29578
29612
  return {
@@ -29652,7 +29686,7 @@ function createClaudeAdapter(recipe, host, options) {
29652
29686
  if (recipe.binaryPath.length === 0) throw new Error(CLAUDE_PROGRAM_NOT_CONFIGURED);
29653
29687
  return sdkCreateQuery(input);
29654
29688
  };
29655
- const buildLaunchEnvironment = () => mergeLaunchEnv4({
29689
+ const buildLaunchEnvironment = () => mergeLaunchEnv5({
29656
29690
  inherited: { ...process.env, ...options?.environment },
29657
29691
  instanceTable: recipe.environment,
29658
29692
  handOverrides: claudeHomeVariables(resolveClaudeHomeLayout(recipe))
@@ -29885,7 +29919,7 @@ function createClaudeInstance(config, host, attachments, overrides, usageCache)
29885
29919
  );
29886
29920
  return {
29887
29921
  configDir,
29888
- transcriptDir: NodePath19.join(configDir, "projects")
29922
+ transcriptDir: NodePath20.join(configDir, "projects")
29889
29923
  };
29890
29924
  };
29891
29925
  return {
@@ -30035,7 +30069,7 @@ var index_default = definePlugin({
30035
30069
  credentialsVariable,
30036
30070
  request,
30037
30071
  process.env,
30038
- (value) => NodePath20.resolve(value ?? "")
30072
+ (value) => NodePath21.resolve(value ?? "")
30039
30073
  ) : keychain ? { detailKey: "form.credentialsPath.keychain" } : { value: configDirectory, detailKey: "form.credentialsPath.sameAsHome" }
30040
30074
  };
30041
30075
  }