@nervekit/desktop 0.43.0 → 0.43.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/builtin/configure-nerve/reference/extensions/api/extension-sdk/components/components.d.ts +2 -0
  2. package/dist/builtin/configure-nerve/reference/extensions/api/extension-sdk/components/ui-kit/components/composites/log-view/index.d.ts +3 -0
  3. package/dist/builtin/configure-nerve/reference/extensions/api/extension-sdk/components/ui-kit/components/composites/log-view/log-source.d.ts +43 -0
  4. package/dist/builtin/configure-nerve/reference/extensions/api/extension-sdk/components/ui-kit/components/composites/log-view/log-view.svelte.d.ts +22 -0
  5. package/dist/builtin/configure-nerve/reference/extensions/api/extension-sdk/components/ui-kit/components/composites/log-view/log-window.d.ts +77 -0
  6. package/dist/builtin/configure-nerve/reference/extensions/api/extension-sdk/components/ui-kit/components/composites/log-view/terminal-text.svelte.d.ts +6 -0
  7. package/dist/builtin/configure-nerve/reference/extensions/api/extension-sdk/components/ui-kit/terminal/ansi.d.ts +4 -0
  8. package/dist/builtin/configure-nerve/reference/extensions/components.md +2 -1
  9. package/dist/builtin/configure-nerve/reference/extensions/scripts/nerve-version.json +1 -1
  10. package/dist/{chunk-XIVWNWL7.js → chunk-3LWB5SGT.js} +3 -18
  11. package/dist/{chunk-EBDLSTDH.js → chunk-WQHOXPLV.js} +549 -236
  12. package/dist/{chunk-HKBJTS2Z.js → chunk-ZTG7VIGB.js} +1 -1
  13. package/dist/daemon.js +3 -3
  14. package/dist/main.js +2 -2
  15. package/dist/web/assets/AsyncBashCenterHost-BlxXoXd6.js +2 -0
  16. package/dist/web/assets/{ConversationListItem-DALhochc.js → ConversationListItem-DfSMoYfe.js} +1 -1
  17. package/dist/web/assets/{ConversationsWorkbenchPanel-ChtoTW2H.js → ConversationsWorkbenchPanel-BOIMwRZx.js} +1 -1
  18. package/dist/web/assets/{DiscoverCenterHost-Bju7ypB-.js → DiscoverCenterHost-Bi6audxE.js} +1 -1
  19. package/dist/web/assets/{ExtensionPageCenterHost-BO-5q4j_.js → ExtensionPageCenterHost-DEg-LHcU.js} +1 -1
  20. package/dist/web/assets/{FileCenterComposedHost-BxLlLMBI.js → FileCenterComposedHost-CPwzMZI9.js} +1 -1
  21. package/dist/web/assets/FilesWorkbenchPanel-DnKQd6QC.js +12 -0
  22. package/dist/web/assets/{GitDiffCenterHost-D8i3Jq9A.js → GitDiffCenterHost-DtsFPa1z.js} +1 -1
  23. package/dist/web/assets/{GitWorkbenchPanel-CtZPJKqJ.js → GitWorkbenchPanel-BfJKdIkE.js} +1 -1
  24. package/dist/web/assets/LaunchCenterHost-C5Bd9ELF.js +1 -0
  25. package/dist/web/assets/LaunchConfigurationNotice-Dp3rBKil.js +1 -0
  26. package/dist/web/assets/LaunchOutputPane-BuCSQcxg.js +2 -0
  27. package/dist/web/assets/LaunchesWorkbenchPanel-CMd3Xcbp.js +1 -0
  28. package/dist/web/assets/{LogsCenterHost-xynA0TWK.js → LogsCenterHost-Be6EbsrZ.js} +1 -1
  29. package/dist/web/assets/{MermaidCenterHost-kAV1ocvE.js → MermaidCenterHost-BdQ8CGeb.js} +1 -1
  30. package/dist/web/assets/{MobileFilesBody-CiwIT8Vf.js → MobileFilesBody-C1q-YRaD.js} +1 -1
  31. package/dist/web/assets/{MobileFilesHost-DvQOpQFH.js → MobileFilesHost-DK769osZ.js} +1 -1
  32. package/dist/web/assets/MobileLaunchOutputHost-BLDX3-Tn.js +1 -0
  33. package/dist/web/assets/MobileLaunchesHost-Dv2gfOEY.js +2 -0
  34. package/dist/web/assets/{MobileNoteEditorHost-DSuZ0mU5.js → MobileNoteEditorHost-ZRzzwCYD.js} +1 -1
  35. package/dist/web/assets/{MobileNotesHost-Lg699XCv.js → MobileNotesHost-COOtVfAp.js} +1 -1
  36. package/dist/web/assets/{MobileSettingsHost-Bv1P74ck.js → MobileSettingsHost-BU2lCcG2.js} +1 -1
  37. package/dist/web/assets/{MobileSettingsPageHost-DudFqhZC.js → MobileSettingsPageHost-BC5LOq7Y.js} +1 -1
  38. package/dist/web/assets/{NotesWorkbenchPanel-C8sctQWR.js → NotesWorkbenchPanel-BiTDbfjj.js} +1 -1
  39. package/dist/web/assets/{PullRequestCenterHost-BWJ-exw1.js → PullRequestCenterHost-DV3V3yxm.js} +1 -1
  40. package/dist/web/assets/{PullRequestsWorkbenchPanel-8Fb0-hW3.js → PullRequestsWorkbenchPanel-Dpvt9W-q.js} +1 -1
  41. package/dist/web/assets/{SearchWorkbenchPanel-B35YmwtL.js → SearchWorkbenchPanel-Bfj8fwPg.js} +1 -1
  42. package/dist/web/assets/{SettingsCenterHost-BuiirrId.js → SettingsCenterHost-sHWZehrB.js} +1 -1
  43. package/dist/web/assets/{SystemPromptCenterHost-BqKV92Ew.js → SystemPromptCenterHost-CA9i8UbB.js} +1 -1
  44. package/dist/web/assets/{ThemePreviewPicker-C6J0H91i.js → ThemePreviewPicker-PySjP6aS.js} +1 -1
  45. package/dist/web/assets/{adapters-C5HB2cBr.js → adapters-fVomUv3-.js} +1 -1
  46. package/dist/web/assets/{agent-profiles.svelte-DjdXLJnE.js → agent-profiles.svelte-CenutfXA.js} +1 -1
  47. package/dist/web/assets/{appearance.svelte-fB4gKc-X.js → appearance.svelte-BKxiMJ3c.js} +1 -1
  48. package/dist/web/assets/{center-tabs.svelte-8YpJhA1o.js → center-tabs.svelte-i0d5hUO3.js} +1 -1
  49. package/dist/web/assets/{channel-3Wv484LF.js → channel-DB8mSlhP.js} +2 -2
  50. package/dist/web/assets/{client-CjIsgPXA.js → client-DHxa8CWS.js} +1 -1
  51. package/dist/web/assets/{code-BDTZAlQg.js → code-CsVM8hq8.js} +2 -2
  52. package/dist/web/assets/{conversation-connection-Dm9Zr6Yb.js → conversation-connection-CaV3KY7Z.js} +1 -1
  53. package/dist/web/assets/{discover-Cwv6pB0p.js → discover-Do0oQbdF.js} +1 -1
  54. package/dist/web/assets/{dist-BENZZeCy.js → dist-B887qHIr.js} +1 -1
  55. package/dist/web/assets/{dist-CIK1TmOX.js → dist-Bg8Vm0DE.js} +1 -1
  56. package/dist/web/assets/{dist-DoKRJEPu.js → dist-C2z70795.js} +1 -1
  57. package/dist/web/assets/{dist-DUPZ8ZaX.js → dist-CcBabmlO.js} +1 -1
  58. package/dist/web/assets/{dist-BBlCv_-z.js → dist-HSfz5y1D.js} +1 -1
  59. package/dist/web/assets/{dist-BB4fpXjy.js → dist-HUxdivoH.js} +1 -1
  60. package/dist/web/assets/{dist-BqcaQXZ-.js → dist-wvfFRict.js} +1 -1
  61. package/dist/web/assets/{extension-themes.svelte-D2TAUtUA.js → extension-themes.svelte-nXDPOl_E.js} +1 -1
  62. package/dist/web/assets/{file-tabs.svelte-DxL_vZZv.js → file-tabs.svelte-BxCAtif2.js} +2 -2
  63. package/dist/web/assets/{files-vq7_WbHL.js → files-DcUCbPX1.js} +1 -1
  64. package/dist/web/assets/filesystem-9b72Tdkw.js +1 -0
  65. package/dist/web/assets/{git-store.svelte-D9S4P9gI.js → git-store.svelte-DIVFeLGG.js} +1 -1
  66. package/dist/web/assets/{index-B8XniJoh.js → index-6mIS-NWJ.js} +108 -108
  67. package/dist/web/assets/index-D2aeJHnc.css +1 -0
  68. package/dist/web/assets/launches-Dafgn_my.js +5 -0
  69. package/dist/web/assets/{launches.api-C4z0obJK.js → launches.api-ZZ-IwIQ_.js} +1 -1
  70. package/dist/web/assets/log-view-Dqspnrs0.js +1 -0
  71. package/dist/web/assets/{logs.api-BtGxtYFi.js → logs.api-BxN21LL0.js} +1 -1
  72. package/dist/web/assets/{maintenance-state.svelte-BusQWeCR.js → maintenance-state.svelte-BAKtNG-i.js} +1 -1
  73. package/dist/web/assets/{menu-icons-DLuZ586C.js → menu-icons-tnCN992t.js} +1 -1
  74. package/dist/web/assets/page-tabs.svelte-wduGZwmi.js +4 -0
  75. package/dist/web/assets/{popover-panel-SA7quIc1.js → popover-panel-DO5nPkvA.js} +1 -1
  76. package/dist/web/assets/pr-view-loader.svelte-RSHgeFYM.js +1 -0
  77. package/dist/web/assets/{progress-BZbo8ynI.js → progress-CRuzrJQt.js} +1 -1
  78. package/dist/web/assets/{scratch-notes-state.svelte-B4NySamQ.js → scratch-notes-state.svelte-BcqgnE6z.js} +1 -1
  79. package/dist/web/assets/{scratch-notes.api-BMBs2yoU.js → scratch-notes.api-D9wtv1Mn.js} +1 -1
  80. package/dist/web/assets/{settings-Cu_0wNkX.js → settings-CKsESd2i.js} +1 -1
  81. package/dist/web/assets/{settings-DTw27q0i.js → settings-Crny2xGb.js} +1 -1
  82. package/dist/web/assets/{settings-scope-Bz4U5ImL.js → settings-scope-BiY5kIdC.js} +1 -1
  83. package/dist/web/assets/shell-layout.svelte-9B3T60gv.js +2 -0
  84. package/dist/web/assets/{views-DIrSFdZB.js → views-Bl6CiPE0.js} +1 -1
  85. package/dist/web/assets/{workbench-connection-BpvUZMVX.js → workbench-connection-CyMud_mZ.js} +1 -1
  86. package/dist/web/assets/{workspace-uXAUsF3x.js → workspace-V-yCOfn1.js} +1 -1
  87. package/dist/web/assets/workspace-actions.svelte-D8-Agx2d.js +1 -0
  88. package/dist/web/assets/{workspace-selectors.svelte-B90FdGfV.js → workspace-selectors.svelte-DQ1mQdvX.js} +1 -1
  89. package/dist/web/index.html +36 -37
  90. package/dist/web/sw.js +1 -1
  91. package/dist/worker.js +2 -2
  92. package/package.json +7 -7
  93. package/dist/web/assets/AsyncBashCenterHost-Dcx6zVCo.js +0 -2
  94. package/dist/web/assets/FilesWorkbenchPanel-jyqwIQAe.js +0 -12
  95. package/dist/web/assets/LaunchCenterHost-CSy1io6s.js +0 -1
  96. package/dist/web/assets/LaunchConfigurationNotice-DugBa05c.js +0 -1
  97. package/dist/web/assets/LaunchesWorkbenchPanel-CNqGG_AP.js +0 -1
  98. package/dist/web/assets/LogStream-C70iQmUI.css +0 -1
  99. package/dist/web/assets/LogStream-DfJ4LiCv.js +0 -1
  100. package/dist/web/assets/MobileLaunchOutputHost-pFJgIV1_.js +0 -1
  101. package/dist/web/assets/MobileLaunchesHost-0VtdW0x8.js +0 -2
  102. package/dist/web/assets/filesystem-DiVFVMn3.js +0 -1
  103. package/dist/web/assets/index-DC_ohlBG.css +0 -1
  104. package/dist/web/assets/launches-CmB4KShL.js +0 -5
  105. package/dist/web/assets/launches.svelte-D2bNAphM.js +0 -2
  106. package/dist/web/assets/page-tabs.svelte-Cc5F8hMx.js +0 -4
  107. package/dist/web/assets/pr-view-loader.svelte-eOmDNaGf.js +0 -1
  108. package/dist/web/assets/shell-layout.svelte-Dyx_fbRn.js +0 -2
  109. package/dist/web/assets/workspace-actions.svelte-DE0mQsY6.js +0 -1
  110. /package/dist/{chunk-EBDLSTDH.js.LEGAL.txt → chunk-WQHOXPLV.js.LEGAL.txt} +0 -0
@@ -67,7 +67,6 @@ import {
67
67
  allToolDescriptors,
68
68
  ambiguousMessage,
69
69
  appendJsonLine,
70
- appendJsonLines,
71
70
  applicationConfigurationSnapshotSchema,
72
71
  applicationLogPruneRequestSchema,
73
72
  applicationLogPruneResponseSchema,
@@ -315,7 +314,7 @@ import {
315
314
  withTimeoutSignal,
316
315
  writeTextFileAtomically,
317
316
  writeTextFileIfMissing
318
- } from "./chunk-XIVWNWL7.js";
317
+ } from "./chunk-3LWB5SGT.js";
319
318
  import {
320
319
  gitPathKey,
321
320
  relativePathInside
@@ -38387,7 +38386,7 @@ function tokenize(source3, slashAfterCloser) {
38387
38386
  let i = 0;
38388
38387
  let at = 0;
38389
38388
  const push2 = (kind, text13) => tokens.push({ kind, text: text13, start: at, end: i });
38390
- const templateText = (open13) => {
38389
+ const templateText = (open14) => {
38391
38390
  let text13 = "";
38392
38391
  while (i < source3.length) {
38393
38392
  const char = source3[i];
@@ -38397,7 +38396,7 @@ function tokenize(source3, slashAfterCloser) {
38397
38396
  i = end;
38398
38397
  } else if (char === "`") {
38399
38398
  i += 1;
38400
- push2(open13 ? "tmpl" : "str", text13);
38399
+ push2(open14 ? "tmpl" : "str", text13);
38401
38400
  return;
38402
38401
  } else if (char === "$" && source3[i + 1] === "{") {
38403
38402
  i += 2;
@@ -38588,14 +38587,14 @@ function lastExpression(code2, slashAfterCloser) {
38588
38587
  const openOf = /* @__PURE__ */ new Map();
38589
38588
  const opens = [];
38590
38589
  const word = (index) => tokens[index]?.kind === "id" ? tokens[index].text : "";
38591
- const opensBlock = (open13) => {
38592
- if (BLOCK_WORDS.has(word(open13 - 1)))
38590
+ const opensBlock = (open14) => {
38591
+ if (BLOCK_WORDS.has(word(open14 - 1)))
38593
38592
  return true;
38594
- if (!isPunct(tokens[open13 - 1], ")"))
38593
+ if (!isPunct(tokens[open14 - 1], ")"))
38595
38594
  return false;
38596
- if (headerClose.has(open13 - 1))
38595
+ if (headerClose.has(open14 - 1))
38597
38596
  return true;
38598
- const params = openOf.get(open13 - 1);
38597
+ const params = openOf.get(open14 - 1);
38599
38598
  if (params === void 0)
38600
38599
  return false;
38601
38600
  let keyword = params - 2;
@@ -38616,14 +38615,14 @@ function lastExpression(code2, slashAfterCloser) {
38616
38615
  opens.push(index);
38617
38616
  } else if (/^[)\]}]$/.test(token.text)) {
38618
38617
  depth -= 1;
38619
- const open13 = opens.pop();
38620
- if (open13 === void 0)
38618
+ const open14 = opens.pop();
38619
+ if (open14 === void 0)
38621
38620
  return void 0;
38622
- openOf.set(index, open13);
38623
- const before = word(open13 - 1);
38624
- if (token.text === ")" && (HEADERS.has(before) || before === "await" && word(open13 - 2) === "for"))
38621
+ openOf.set(index, open14);
38622
+ const before = word(open14 - 1);
38623
+ if (token.text === ")" && (HEADERS.has(before) || before === "await" && word(open14 - 2) === "for"))
38625
38624
  headerClose.add(index);
38626
- if (token.text === "}" && isPunct(tokens[open13], "{") && opensBlock(open13))
38625
+ if (token.text === "}" && isPunct(tokens[open14], "{") && opensBlock(open14))
38627
38626
  blockClose.add(index);
38628
38627
  }
38629
38628
  }
@@ -53803,8 +53802,8 @@ function createTunnelRuntime(input) {
53803
53802
  });
53804
53803
  return {
53805
53804
  tunnel,
53806
- setListenerFactory: (open13) => {
53807
- openListener = open13;
53805
+ setListenerFactory: (open14) => {
53806
+ openListener = open14;
53808
53807
  }
53809
53808
  };
53810
53809
  }
@@ -67235,9 +67234,9 @@ function rateLimitBackoff(now2, failures, headers) {
67235
67234
  function retainPrs(prs, demands) {
67236
67235
  const branchLatest = new Set(demands.flatMap((demand) => demand.branch ? prs.filter((pr) => pr.headRefName === demand.branch).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt)).slice(0, 1).map((pr) => pr.number) : []));
67237
67236
  const retained = (pr) => branchLatest.has(pr.number) || demands.some((demand) => demand.prs.includes(pr.number) || demand.activePr === pr.number);
67238
- const open13 = prs.filter((pr) => pr.state === "OPEN").sort((a, b) => Number(retained(b)) - Number(retained(a)) || b.updatedAt.localeCompare(a.updatedAt)).slice(0, 100);
67237
+ const open14 = prs.filter((pr) => pr.state === "OPEN").sort((a, b) => Number(retained(b)) - Number(retained(a)) || b.updatedAt.localeCompare(a.updatedAt)).slice(0, 100);
67239
67238
  return [
67240
- ...open13,
67239
+ ...open14,
67241
67240
  ...prs.filter((pr) => pr.state !== "OPEN" && retained(pr))
67242
67241
  ].sort((a, b) => b.number - a.number);
67243
67242
  }
@@ -68313,8 +68312,8 @@ var SIGNATURE_FILE_LIMIT = 200;
68313
68312
  async function statSignature(repoDir, paths) {
68314
68313
  const parts = await Promise.all(paths.slice(0, SIGNATURE_FILE_LIMIT).map(async (path7) => {
68315
68314
  try {
68316
- const stat21 = await lstat10(join33(repoDir, path7));
68317
- return `${path7}:${stat21.size}:${Math.trunc(stat21.mtimeMs)}`;
68315
+ const stat22 = await lstat10(join33(repoDir, path7));
68316
+ return `${path7}:${stat22.size}:${Math.trunc(stat22.mtimeMs)}`;
68318
68317
  } catch {
68319
68318
  return `${path7}:-`;
68320
68319
  }
@@ -70562,11 +70561,11 @@ function parseStorage(xml) {
70562
70561
  const line2 = lineAt(i);
70563
70562
  if (inner.startsWith("/")) {
70564
70563
  const name3 = inner.slice(1).trim();
70565
- const open13 = stack.length > 1 ? stack.pop() : void 0;
70566
- if (!open13) {
70564
+ const open14 = stack.length > 1 ? stack.pop() : void 0;
70565
+ if (!open14) {
70567
70566
  fail2(`Unexpected closing tag </${name3}> with nothing open`, i);
70568
- } else if (open13.name !== name3) {
70569
- throw new StorageXmlError(`Closing tag </${name3}> at line ${line2} does not match <${open13.name}> opened at line ${open13.line}`);
70567
+ } else if (open14.name !== name3) {
70568
+ throw new StorageXmlError(`Closing tag </${name3}> at line ${line2} does not match <${open14.name}> opened at line ${open14.line}`);
70570
70569
  }
70571
70570
  i = j + 1;
70572
70571
  continue;
@@ -70590,8 +70589,8 @@ function parseStorage(xml) {
70590
70589
  i = j + 1;
70591
70590
  }
70592
70591
  if (stack.length > 1) {
70593
- const open13 = stack.at(-1);
70594
- throw new StorageXmlError(`<${open13.name}> opened at line ${open13.line} is never closed`);
70592
+ const open14 = stack.at(-1);
70593
+ throw new StorageXmlError(`<${open14.name}> opened at line ${open14.line} is never closed`);
70595
70594
  }
70596
70595
  return root;
70597
70596
  }
@@ -74038,11 +74037,11 @@ async function boardSprints(session, boardId, state, allPages) {
74038
74037
  }
74039
74038
  async function sprints(session, key3, closed) {
74040
74039
  const perBoard = await Promise.all((await boards(session, key3)).map(async (board) => {
74041
- const [open13, done] = await Promise.all([
74040
+ const [open14, done] = await Promise.all([
74042
74041
  boardSprints(session, board.id, "active,future", false),
74043
74042
  closed ? boardSprints(session, board.id, "closed", true) : Promise.resolve([])
74044
74043
  ]);
74045
- return [...done.slice(-CLOSED_SPRINTS), ...open13].map((item) => {
74044
+ return [...done.slice(-CLOSED_SPRINTS), ...open14].map((item) => {
74046
74045
  const sprint = record5(item);
74047
74046
  return {
74048
74047
  id: Number(sprint.id),
@@ -74771,13 +74770,13 @@ var jiraSprintMethods = [
74771
74770
  if (openIssues?.more) {
74772
74771
  throw new Error(`Sprint ${id2} has more than ${MAX_ISSUES2} open issues; sprints.close moves at most ${MAX_ISSUES2}. Nothing was changed. Move some with issues.move, then close again.`);
74773
74772
  }
74774
- const open13 = (openIssues?.items ?? []).map((raw2) => String(raw2.key ?? ""));
74773
+ const open14 = (openIssues?.items ?? []).map((raw2) => String(raw2.key ?? ""));
74775
74774
  const closed = await putSprint(session, current, { state: "closed" });
74776
- if (moveOpenTo !== void 0 && open13.length > 0) {
74777
- await moveIssues(session, open13, moveOpenTo);
74775
+ if (moveOpenTo !== void 0 && open14.length > 0) {
74776
+ await moveIssues(session, open14, moveOpenTo);
74778
74777
  }
74779
74778
  noteChange(session, "updated", `sprint ${id2}`);
74780
- return { ...closed, moved: open13 };
74779
+ return { ...closed, moved: open14 };
74781
74780
  }
74782
74781
  }),
74783
74782
  defineMethod2({
@@ -75927,7 +75926,7 @@ function createMarkdownConverter() {
75927
75926
  ["*", "<em>", "</em>"],
75928
75927
  ["_", "<em>", "</em>"]
75929
75928
  ];
75930
- for (const [marker, open13, close] of forms) {
75929
+ for (const [marker, open14, close] of forms) {
75931
75930
  if (!rest.startsWith(marker))
75932
75931
  continue;
75933
75932
  if (marker[0] === "_" && i > 0 && /\w/.test(text13[i - 1]))
@@ -75945,7 +75944,7 @@ function createMarkdownConverter() {
75945
75944
  const closes = before !== void 0 && !/\s/.test(before) && before !== "\\" && !(marker.length === 1 && next2 === marker) && !(marker[0] === "_" && next2 !== void 0 && /\w/.test(next2));
75946
75945
  if (closes && end > marker.length) {
75947
75946
  return {
75948
- open: open13,
75947
+ open: open14,
75949
75948
  close,
75950
75949
  inner: rest.slice(marker.length, end),
75951
75950
  end: i + end + marker.length
@@ -76624,11 +76623,11 @@ function replaceTags(text13) {
76624
76623
  let out = "";
76625
76624
  let position = 0;
76626
76625
  for (; ; ) {
76627
- const open13 = text13.indexOf("<", position);
76628
- const close = open13 < 0 ? -1 : text13.indexOf(">", open13);
76626
+ const open14 = text13.indexOf("<", position);
76627
+ const close = open14 < 0 ? -1 : text13.indexOf(">", open14);
76629
76628
  if (close < 0)
76630
76629
  return out + text13.slice(position);
76631
- out += `${text13.slice(position, open13)} `;
76630
+ out += `${text13.slice(position, open14)} `;
76632
76631
  position = close + 1;
76633
76632
  }
76634
76633
  }
@@ -80205,10 +80204,10 @@ function quickScriptDescription({ namespaces: configured = [] } = {}, registry)
80205
80204
 
80206
80205
  // packages/tools/dist/quick-script/runtime/script-literals.js
80207
80206
  var TARGET_KEYS = /* @__PURE__ */ new Set(["id", "key", "space", "project"]);
80208
- function callArguments(tokens, open13) {
80207
+ function callArguments(tokens, open14) {
80209
80208
  const args = [];
80210
80209
  let depth = 0;
80211
- for (let i = open13; i < tokens.length; i += 1) {
80210
+ for (let i = open14; i < tokens.length; i += 1) {
80212
80211
  const token = tokens[i];
80213
80212
  if (token.kind === "punct") {
80214
80213
  if (["(", "[", "{", "${"].includes(token.text)) {
@@ -81587,12 +81586,12 @@ var completionPolicyWeights = Object.freeze({
81587
81586
  function rankCompletionCandidates(items, context2 = {}, usage = /* @__PURE__ */ new Map(), options2 = {}) {
81588
81587
  const referenced = new Set(context2.referencedPaths);
81589
81588
  const edited = new Set(context2.editedPaths);
81590
- const open13 = new Set(context2.openPaths);
81589
+ const open14 = new Set(context2.openPaths);
81591
81590
  return items.map((item, index) => {
81592
81591
  const path7 = item.info;
81593
81592
  const rawUsage = usage.get(completionUsageId(item.kind, item.documentId ?? item.label)) ?? 0;
81594
81593
  const usageCount = Number.isFinite(rawUsage) ? Math.max(0, rawUsage) : 0;
81595
- const contextBoost = (path7 && referenced.has(path7) ? completionPolicyWeights.referenced : 0) + (path7 && edited.has(path7) ? completionPolicyWeights.edited : 0) + (path7 && open13.has(path7) ? completionPolicyWeights.open : 0);
81594
+ const contextBoost = (path7 && referenced.has(path7) ? completionPolicyWeights.referenced : 0) + (path7 && edited.has(path7) ? completionPolicyWeights.edited : 0) + (path7 && open14.has(path7) ? completionPolicyWeights.open : 0);
81596
81595
  const usageBoost = Math.round(Math.min(completionPolicyWeights.maxUsage, completionPolicyWeights.usage * Math.log2(1 + Math.min(100, usageCount))));
81597
81596
  const prior = !options2.emptyQuery && (item.kind === "file" || item.kind === "directory") ? completionPolicyWeights.filePrior : 0;
81598
81597
  const boost = contextBoost + usageBoost + prior;
@@ -86806,8 +86805,7 @@ var LaunchRuns = class {
86806
86805
  stderr: launch.stderrPath
86807
86806
  },
86808
86807
  status: launch.status,
86809
- exitCode: launch.exitCode,
86810
- captureTruncated: launch.outputRetention?.truncated
86808
+ exitCode: launch.exitCode
86811
86809
  });
86812
86810
  this.options.notify(owner, launch, `Launch ${JSON.stringify(runName(launch))} (run ${launch.id}, command ${JSON.stringify(launch.command)}) exited: ${launch.status}
86813
86811
  ${output}`);
@@ -86935,7 +86933,6 @@ ${output}`);
86935
86933
  stderr: run3.stderrPath
86936
86934
  },
86937
86935
  status: run3.status,
86938
- captureTruncated: run3.outputRetention?.truncated,
86939
86936
  offset: page2.offset,
86940
86937
  limit: page2.limit
86941
86938
  })
@@ -93595,30 +93592,352 @@ function createConversationCore(deps, launchServices, onProjectDeleted, processH
93595
93592
  };
93596
93593
  }
93597
93594
 
93595
+ // packages/workbench-server/dist/domains/launches/persistence/launch-log-index.js
93596
+ import { open as open11, stat as stat18 } from "node:fs/promises";
93597
+ var LOG_INDEX_STRIDE = 256;
93598
+ var READ_CHUNK_BYTES = 64 * 1024;
93599
+ var MAX_CACHED_INDEXES = 64;
93600
+ var LaunchLogIndex = class {
93601
+ bytes = 0;
93602
+ count = 0;
93603
+ lastSeq = 0;
93604
+ reconstructed = false;
93605
+ seqs = [];
93606
+ offsets = [];
93607
+ catchUpPromise;
93608
+ /**
93609
+ * Extend an index that currently covers exactly `from` bytes with `entries`
93610
+ * and the extent `to` they (and any unparsable lines) reach. False when the
93611
+ * index is not at `from`, e.g. because a scan advanced it first.
93612
+ */
93613
+ append(from, entries3, to, reconstructed = false) {
93614
+ if (from !== this.bytes)
93615
+ return false;
93616
+ for (const entry of entries3) {
93617
+ if (this.count % LOG_INDEX_STRIDE === 0) {
93618
+ this.seqs.push(entry.seq);
93619
+ this.offsets.push(entry.start);
93620
+ }
93621
+ this.count += 1;
93622
+ this.lastSeq = entry.seq;
93623
+ }
93624
+ this.bytes = to;
93625
+ this.reconstructed ||= reconstructed;
93626
+ return true;
93627
+ }
93628
+ snapshot() {
93629
+ return {
93630
+ bytes: this.bytes,
93631
+ count: this.count,
93632
+ lastSeq: this.lastSeq,
93633
+ reconstructed: this.reconstructed,
93634
+ offsets: this.offsets,
93635
+ seqs: this.seqs,
93636
+ checkpointCount: this.seqs.length
93637
+ };
93638
+ }
93639
+ };
93640
+ function seekCheckpoint(snapshot, seq, inclusive) {
93641
+ let low = 0;
93642
+ let high = snapshot.checkpointCount - 1;
93643
+ let found = -1;
93644
+ while (low <= high) {
93645
+ const middle = low + high >> 1;
93646
+ const value = snapshot.seqs[middle];
93647
+ if (inclusive ? value <= seq : value < seq) {
93648
+ found = middle;
93649
+ low = middle + 1;
93650
+ } else
93651
+ high = middle - 1;
93652
+ }
93653
+ return found < 0 ? { offset: 0, ordinal: 0 } : { offset: snapshot.offsets[found], ordinal: found * LOG_INDEX_STRIDE };
93654
+ }
93655
+ function parseLineSeq(line2) {
93656
+ if (line2.length === 0)
93657
+ return void 0;
93658
+ try {
93659
+ const value = JSON.parse(line2.toString("utf8"));
93660
+ if (typeof value !== "object" || value === null)
93661
+ return void 0;
93662
+ const { seq } = value;
93663
+ return typeof seq === "number" && Number.isInteger(seq) ? seq : void 0;
93664
+ } catch {
93665
+ return void 0;
93666
+ }
93667
+ }
93668
+ async function scanLines(path7, from, to, visit) {
93669
+ if (from >= to)
93670
+ return;
93671
+ const handle2 = await open11(path7, "r").catch((error3) => {
93672
+ if (error3.code === "ENOENT")
93673
+ return void 0;
93674
+ throw error3;
93675
+ });
93676
+ if (!handle2)
93677
+ return;
93678
+ try {
93679
+ const chunk = Buffer.allocUnsafe(READ_CHUNK_BYTES);
93680
+ let position = from;
93681
+ let lineStart = from;
93682
+ let carry = Buffer.alloc(0);
93683
+ while (position < to) {
93684
+ const length = Math.min(READ_CHUNK_BYTES, to - position);
93685
+ const { bytesRead } = await handle2.read(chunk, 0, length, position);
93686
+ if (bytesRead === 0)
93687
+ return;
93688
+ const data = carry.length > 0 ? Buffer.concat([carry, chunk.subarray(0, bytesRead)]) : chunk.subarray(0, bytesRead);
93689
+ const dataStart = position - carry.length;
93690
+ let start = 0;
93691
+ for (; ; ) {
93692
+ const newline = data.indexOf(10, start);
93693
+ if (newline < 0)
93694
+ break;
93695
+ const end = dataStart + newline + 1;
93696
+ if (visit(data.subarray(start, newline), lineStart, end) === false)
93697
+ return;
93698
+ lineStart = end;
93699
+ start = newline + 1;
93700
+ }
93701
+ carry = Buffer.from(data.subarray(start));
93702
+ position += bytesRead;
93703
+ }
93704
+ } finally {
93705
+ await handle2.close();
93706
+ }
93707
+ }
93708
+ var LaunchLogIndexes = class {
93709
+ maxEntries;
93710
+ indexes = /* @__PURE__ */ new Map();
93711
+ constructor(maxEntries2 = MAX_CACHED_INDEXES) {
93712
+ this.maxEntries = maxEntries2;
93713
+ }
93714
+ /** Index kept current by the writer; created empty for a new file. */
93715
+ ensure(path7) {
93716
+ let index = this.indexes.get(path7);
93717
+ if (index)
93718
+ this.indexes.delete(path7);
93719
+ else
93720
+ index = new LaunchLogIndex();
93721
+ this.indexes.set(path7, index);
93722
+ for (const key3 of this.indexes.keys()) {
93723
+ if (this.indexes.size <= this.maxEntries)
93724
+ break;
93725
+ if (key3 !== path7)
93726
+ this.indexes.delete(key3);
93727
+ }
93728
+ return index;
93729
+ }
93730
+ peek(path7) {
93731
+ return this.indexes.get(path7);
93732
+ }
93733
+ forget(path7) {
93734
+ this.indexes.delete(path7);
93735
+ }
93736
+ clear() {
93737
+ this.indexes.clear();
93738
+ }
93739
+ /** Snapshot after scanning whatever the file gained since the index last saw it. */
93740
+ async snapshot(path7) {
93741
+ const index = this.ensure(path7);
93742
+ for (; ; ) {
93743
+ const size = await stat18(path7).then((value) => value.size).catch((error3) => {
93744
+ if (error3.code === "ENOENT")
93745
+ return 0;
93746
+ throw error3;
93747
+ });
93748
+ if (index.bytes >= size)
93749
+ return index.snapshot();
93750
+ const before = index.bytes;
93751
+ index.catchUpPromise ??= this.catchUp(path7, index, size).finally(() => {
93752
+ index.catchUpPromise = void 0;
93753
+ });
93754
+ await index.catchUpPromise;
93755
+ if (index.bytes === before)
93756
+ return index.snapshot();
93757
+ }
93758
+ }
93759
+ async catchUp(path7, index, size) {
93760
+ const from = index.bytes;
93761
+ const entries3 = [];
93762
+ let end = from;
93763
+ let reconstructed = false;
93764
+ await scanLines(path7, from, size, (line2, start, lineEnd) => {
93765
+ end = lineEnd;
93766
+ const seq = parseLineSeq(line2);
93767
+ if (seq === void 0)
93768
+ return;
93769
+ entries3.push({ seq, start, end: lineEnd });
93770
+ if (line2.includes('"reconstructed"'))
93771
+ reconstructed = true;
93772
+ });
93773
+ index.append(from, entries3, end, reconstructed);
93774
+ }
93775
+ };
93776
+
93598
93777
  // packages/workbench-server/dist/domains/launches/application/launch-log-query.js
93599
- function queryLaunchLogEvents(source3, query = {}) {
93778
+ async function queryLaunchLogEvents(path7, snapshot, query = {}) {
93600
93779
  const mode = query.mode ?? "recent";
93601
93780
  const limit = query.limit ?? 100;
93602
- const ordered = [...source3].sort((a, b) => a.seq - b.seq);
93603
- const latestCursor = ordered.at(-1)?.seq ?? 0;
93604
- let matching = eventsForMode(ordered, query);
93605
- if (query.contains) {
93606
- const contains = query.contains.toLowerCase();
93607
- matching = matching.filter((event) => event.line.toLowerCase().includes(contains));
93608
- }
93609
- if (query.regex) {
93610
- const matcher = new RegExp(query.regex, "i");
93611
- matching = matching.filter((event) => matcher.test(event.line));
93781
+ const filter = textFilter(query);
93782
+ const context2 = { path: path7, snapshot, query, mode, limit };
93783
+ if (mode === "recent" && !filter)
93784
+ return queryRecent(context2);
93785
+ if (mode === "since_cursor" && !filter && query.beforeSeq === void 0)
93786
+ return querySince(context2);
93787
+ if (mode === "first_failure")
93788
+ return queryFirstFailure(context2, filter);
93789
+ return queryStreaming(context2, filter);
93790
+ }
93791
+ async function queryRecent(context2) {
93792
+ const { path: path7, snapshot, query, limit } = context2;
93793
+ const end = query.beforeSeq === void 0 || query.beforeSeq > snapshot.lastSeq ? snapshot.bytes : await offsetOfFirstSeqAtLeast(path7, snapshot, query.beforeSeq);
93794
+ const newestFirst = [];
93795
+ if (end > 0)
93796
+ await forEachJsonLineReverse(path7, launchLogEventSchema, (event) => {
93797
+ newestFirst.push(event);
93798
+ return newestFirst.length <= limit;
93799
+ }, end);
93800
+ const events = newestFirst.slice(0, limit).reverse();
93801
+ const lastSeq = events.at(-1)?.seq;
93802
+ return buildPage(context2, {
93803
+ events,
93804
+ matching: snapshot.count,
93805
+ hasMoreBefore: newestFirst.length > limit,
93806
+ hasMoreAfter: lastSeq !== void 0 && lastSeq < snapshot.lastSeq
93807
+ });
93808
+ }
93809
+ async function offsetOfFirstSeqAtLeast(path7, snapshot, seq) {
93810
+ const from = seekCheckpoint(snapshot, seq, false).offset;
93811
+ let found = snapshot.bytes;
93812
+ await scanLines(path7, from, snapshot.bytes, (line2, start) => {
93813
+ const lineSeq = parseLineSeq(line2);
93814
+ if (lineSeq === void 0 || lineSeq < seq)
93815
+ return;
93816
+ found = start;
93817
+ return false;
93818
+ });
93819
+ return found;
93820
+ }
93821
+ async function querySince(context2) {
93822
+ const { path: path7, snapshot, query, limit } = context2;
93823
+ const sinceSeq = query.sinceSeq ?? 0;
93824
+ const events = [];
93825
+ if (sinceSeq < snapshot.lastSeq) {
93826
+ const checkpoint = seekCheckpoint(snapshot, sinceSeq, true);
93827
+ let ordinal = checkpoint.ordinal;
93828
+ let firstOrdinal = ordinal;
93829
+ await scanLines(path7, checkpoint.offset, snapshot.bytes, (line2) => {
93830
+ const seq = parseLineSeq(line2);
93831
+ if (seq === void 0)
93832
+ return;
93833
+ ordinal += 1;
93834
+ if (seq <= sinceSeq)
93835
+ return;
93836
+ const event = parseEvent(line2);
93837
+ if (!event)
93838
+ return;
93839
+ if (events.length === 0)
93840
+ firstOrdinal = ordinal - 1;
93841
+ events.push(event);
93842
+ return events.length < limit;
93843
+ });
93844
+ const lastSeq = events.at(-1)?.seq;
93845
+ return buildPage(context2, {
93846
+ events,
93847
+ matching: events.length === 0 ? 0 : snapshot.count - firstOrdinal,
93848
+ hasMoreBefore: false,
93849
+ hasMoreAfter: lastSeq !== void 0 && lastSeq < snapshot.lastSeq
93850
+ });
93612
93851
  }
93852
+ return buildPage(context2, {
93853
+ events,
93854
+ matching: 0,
93855
+ hasMoreBefore: false,
93856
+ hasMoreAfter: false
93857
+ });
93858
+ }
93859
+ async function queryStreaming(context2, filter) {
93860
+ const { path: path7, snapshot, query, mode, limit } = context2;
93861
+ const include = modeFilter(mode);
93862
+ const forward = mode === "since_cursor";
93863
+ const sinceSeq = query.sinceSeq ?? 0;
93864
+ const from = forward ? seekCheckpoint(snapshot, sinceSeq, true).offset : 0;
93865
+ const page2 = [];
93866
+ let matching = 0;
93867
+ let candidates = 0;
93868
+ await scanLines(path7, from, snapshot.bytes, (line2) => {
93869
+ const event = parseEvent(line2);
93870
+ if (!event)
93871
+ return;
93872
+ if (forward && event.seq <= sinceSeq)
93873
+ return;
93874
+ if (!include(event) || filter && !filter(event))
93875
+ return;
93876
+ matching += 1;
93877
+ if (query.beforeSeq !== void 0 && event.seq >= query.beforeSeq)
93878
+ return;
93879
+ candidates += 1;
93880
+ if (forward) {
93881
+ if (page2.length < limit)
93882
+ page2.push(event);
93883
+ return;
93884
+ }
93885
+ page2.push(event);
93886
+ if (page2.length >= limit * 2)
93887
+ page2.splice(0, page2.length - limit);
93888
+ });
93889
+ const events = forward ? page2 : page2.slice(-limit);
93890
+ return buildPage(context2, {
93891
+ events,
93892
+ matching,
93893
+ hasMoreBefore: !forward && candidates > events.length,
93894
+ hasMoreAfter: forward ? matching > events.length : matching > candidates
93895
+ });
93896
+ }
93897
+ async function queryFirstFailure(context2, filter) {
93898
+ const { path: path7, snapshot, query } = context2;
93899
+ const contextLines = query.contextLines ?? 2;
93900
+ const before = [];
93901
+ const window2 = [];
93902
+ let remaining2 = -1;
93903
+ await scanLines(path7, 0, snapshot.bytes, (line2) => {
93904
+ const event = parseEvent(line2);
93905
+ if (!event)
93906
+ return;
93907
+ if (remaining2 < 0) {
93908
+ if (event.level !== "error") {
93909
+ before.push(event);
93910
+ if (before.length > contextLines)
93911
+ before.shift();
93912
+ return;
93913
+ }
93914
+ window2.push(...before, event);
93915
+ remaining2 = contextLines;
93916
+ } else {
93917
+ window2.push(event);
93918
+ remaining2 -= 1;
93919
+ }
93920
+ return remaining2 > 0;
93921
+ });
93922
+ const matching = filter ? window2.filter(filter) : window2;
93613
93923
  const candidates = query.beforeSeq === void 0 ? matching : matching.filter((event) => event.seq < query.beforeSeq);
93614
- const page2 = mode === "since_cursor" ? candidates.slice(0, limit) : mode === "first_failure" ? candidates : candidates.slice(-limit);
93615
- const firstSeq = page2[0]?.seq;
93616
- const lastSeq = page2.at(-1)?.seq;
93617
- const hasMoreBefore = firstSeq !== void 0 && matching.some((event) => event.seq < firstSeq);
93618
- const hasMoreAfter = lastSeq !== void 0 && matching.some((event) => event.seq > lastSeq);
93619
- const nextCursor2 = mode === "since_cursor" ? lastSeq ?? query.sinceSeq ?? latestCursor : latestCursor;
93924
+ const first2 = candidates[0]?.seq;
93925
+ const last = candidates.at(-1)?.seq;
93926
+ return buildPage(context2, {
93927
+ events: candidates,
93928
+ matching: matching.length,
93929
+ hasMoreBefore: first2 !== void 0 && matching.some((event) => event.seq < first2),
93930
+ hasMoreAfter: last !== void 0 && matching.some((event) => event.seq > last)
93931
+ });
93932
+ }
93933
+ function buildPage(context2, page2) {
93934
+ const { snapshot, query, mode } = context2;
93935
+ const { events, matching, hasMoreBefore, hasMoreAfter } = page2;
93936
+ const firstSeq = events[0]?.seq;
93937
+ const lastSeq = events.at(-1)?.seq;
93938
+ const nextCursor2 = mode === "since_cursor" ? lastSeq ?? query.sinceSeq ?? snapshot.lastSeq : snapshot.lastSeq;
93620
93939
  return {
93621
- events: page2,
93940
+ events,
93622
93941
  nextCursor: nextCursor2,
93623
93942
  ...firstSeq !== void 0 ? { firstSeq } : {},
93624
93943
  ...lastSeq !== void 0 ? { lastSeq } : {},
@@ -93626,79 +93945,154 @@ function queryLaunchLogEvents(source3, query = {}) {
93626
93945
  hasMoreAfter,
93627
93946
  ...hasMoreBefore && firstSeq !== void 0 ? { olderBeforeSeq: firstSeq } : {},
93628
93947
  ...lastSeq !== void 0 ? { futureSinceSeq: lastSeq } : {},
93629
- originalEventCount: matching.length,
93630
- displayedEventCount: page2.length,
93631
- omittedEventCount: Math.max(0, matching.length - page2.length),
93948
+ originalEventCount: matching,
93949
+ displayedEventCount: events.length,
93950
+ omittedEventCount: Math.max(0, matching - events.length),
93632
93951
  mode
93633
93952
  };
93634
93953
  }
93635
- function eventsForMode(ordered, query) {
93636
- const mode = query.mode ?? "recent";
93637
- if (mode === "since_cursor")
93638
- return ordered.filter((event) => event.seq > (query.sinceSeq ?? 0));
93954
+ function modeFilter(mode) {
93639
93955
  if (mode === "errors")
93640
- return ordered.filter((event) => event.level === "error");
93956
+ return (event) => event.level === "error";
93641
93957
  if (mode === "warnings")
93642
- return ordered.filter((event) => event.level === "warn");
93643
- if (mode === "first_failure") {
93644
- const index = ordered.findIndex((event) => event.level === "error");
93645
- if (index < 0)
93646
- return [];
93647
- const contextLines = query.contextLines ?? 2;
93648
- return ordered.slice(Math.max(0, index - contextLines), index + contextLines + 1);
93958
+ return (event) => event.level === "warn";
93959
+ return () => true;
93960
+ }
93961
+ function textFilter(query) {
93962
+ const contains = query.contains?.toLowerCase();
93963
+ const matcher = query.regex ? new RegExp(query.regex, "i") : void 0;
93964
+ if (!contains && !matcher)
93965
+ return void 0;
93966
+ return (event) => (!contains || event.line.toLowerCase().includes(contains)) && (!matcher || matcher.test(event.line));
93967
+ }
93968
+ function parseEvent(line2) {
93969
+ if (line2.length === 0)
93970
+ return void 0;
93971
+ try {
93972
+ const parsed = launchLogEventSchema.safeParse(JSON.parse(line2.toString("utf8")));
93973
+ return parsed.success ? parsed.data : void 0;
93974
+ } catch {
93975
+ return void 0;
93649
93976
  }
93650
- return [...ordered];
93651
93977
  }
93652
93978
 
93653
- // packages/workbench-server/dist/domains/launches/application/launch-log.service.js
93654
- import { mkdir as mkdir25, open as open11 } from "node:fs/promises";
93979
+ // packages/workbench-server/dist/domains/launches/persistence/launch-log-writer.js
93980
+ import { mkdir as mkdir25, open as open12 } from "node:fs/promises";
93655
93981
  import { dirname as dirname25 } from "node:path";
93982
+ var LaunchLogWriter = class {
93983
+ paths;
93984
+ indexes;
93985
+ files = /* @__PURE__ */ new Map();
93986
+ queue = new SerialQueue();
93987
+ constructor(paths, indexes) {
93988
+ this.paths = paths;
93989
+ this.indexes = indexes;
93990
+ }
93991
+ appendOutput(stream, bytes3) {
93992
+ return this.queue.run(async () => {
93993
+ await this.write(stream === "stdout" ? this.paths.stdoutPath : this.paths.stderrPath, bytes3);
93994
+ if (this.paths.combinedPath)
93995
+ await this.write(this.paths.combinedPath, Buffer.concat([
93996
+ Buffer.from(`[${stream}]
93997
+ `, "utf8"),
93998
+ bytes3,
93999
+ bytes3.at(-1) === 10 ? Buffer.alloc(0) : Buffer.from("\n")
94000
+ ]));
94001
+ });
94002
+ }
94003
+ appendEvents(events) {
94004
+ if (events.length === 0)
94005
+ return Promise.resolve();
94006
+ return this.queue.run(async () => {
94007
+ const lines = events.map((event) => Buffer.from(`${JSON.stringify(event)}
94008
+ `, "utf8"));
94009
+ const start = await this.write(this.paths.logsPath, Buffer.concat(lines));
94010
+ let position = start;
94011
+ const entries3 = events.map((event, index) => {
94012
+ const entry = {
94013
+ seq: event.seq,
94014
+ start: position,
94015
+ end: position + lines[index].byteLength
94016
+ };
94017
+ position = entry.end;
94018
+ return entry;
94019
+ });
94020
+ this.indexes.ensure(this.paths.logsPath).append(start, entries3, position);
94021
+ });
94022
+ }
94023
+ /** Sync every open file and release the handles. */
94024
+ close() {
94025
+ return this.queue.run(async () => {
94026
+ const opened = [...this.files.values()];
94027
+ this.files.clear();
94028
+ await Promise.allSettled(opened.map(async ({ handle: handle2 }) => {
94029
+ try {
94030
+ await handle2.sync();
94031
+ } finally {
94032
+ await handle2.close();
94033
+ }
94034
+ }));
94035
+ });
94036
+ }
94037
+ /** Appends and returns the offset the bytes start at. */
94038
+ async write(path7, bytes3) {
94039
+ const file = await this.file(path7);
94040
+ const start = file.size;
94041
+ try {
94042
+ const { bytesWritten } = await file.handle.write(bytes3);
94043
+ file.size += bytesWritten;
94044
+ if (bytesWritten !== bytes3.byteLength)
94045
+ throw new Error(`Short write to ${path7}`);
94046
+ } catch (error3) {
94047
+ this.files.delete(path7);
94048
+ await file.handle.close().catch(() => void 0);
94049
+ throw error3;
94050
+ }
94051
+ return start;
94052
+ }
94053
+ async file(path7) {
94054
+ const existing = this.files.get(path7);
94055
+ if (existing)
94056
+ return existing;
94057
+ await mkdir25(dirname25(path7), { recursive: true, mode: 448 });
94058
+ const handle2 = await open12(path7, "a", 384);
94059
+ const file = { handle: handle2, size: (await handle2.stat()).size };
94060
+ this.files.set(path7, file);
94061
+ return file;
94062
+ }
94063
+ };
94064
+
94065
+ // packages/workbench-server/dist/domains/launches/application/launch-log.service.js
93656
94066
  var MAX_BUFFERED_LOG_LINE_CHARS = 256 * 1024;
93657
- var TASK_OUTPUT_HEAD_MAX_BYTES = 32 * 1024 * 1024;
93658
- var TASK_OUTPUT_TAIL_MAX_BYTES = 512 * 1024;
93659
94067
  function createLaunchLogCursor(logSeq = 0) {
93660
94068
  return {
93661
94069
  logSeq,
93662
94070
  lineBuffers: { stdout: "", stderr: "" },
93663
94071
  rawBuffers: { stdout: Buffer.alloc(0), stderr: Buffer.alloc(0) },
93664
94072
  streamBytes: { stdout: 0, stderr: 0 },
93665
- logQueue: Promise.resolve(),
93666
- totalBytes: 0,
93667
- retainedBytes: 0,
93668
- omittedBytes: 0,
93669
- totalLines: 0,
93670
- retainedLines: 0,
93671
- omittedLines: 0,
93672
- tailChunks: [],
93673
- tailBytes: 0,
93674
- tailDirtyBytes: 0
94073
+ logQueue: Promise.resolve()
93675
94074
  };
93676
94075
  }
93677
94076
  var LaunchLogService = class {
93678
94077
  events;
93679
94078
  options;
94079
+ indexes = new LaunchLogIndexes();
94080
+ writers = /* @__PURE__ */ new Map();
93680
94081
  constructor(events, options2 = {}) {
93681
94082
  this.events = events;
93682
94083
  this.options = options2;
93683
94084
  }
93684
94085
  async queryLogs(launch, query = {}) {
93685
- const headEvents = await this.readLogEvents(launch.logsPath);
93686
- const tailEvents = launch.outputRetention?.tailPath ? await this.tailLogEvents(launch, (headEvents.at(-1)?.seq ?? 0) + (launch.outputRetention.truncated ? 2 : 1)) : [];
93687
- const allEvents = launch.outputRetention?.truncated ? [
93688
- ...headEvents,
93689
- omissionEvent(headEvents, launch.outputRetention.omittedBytes),
93690
- ...tailEvents
93691
- ] : [...headEvents, ...tailEvents];
94086
+ const snapshot = await this.indexes.snapshot(launch.logsPath);
93692
94087
  return {
93693
94088
  launch,
93694
- ...queryLaunchLogEvents(allEvents, query),
93695
- outputRetention: launch.outputRetention,
94089
+ ...await queryLaunchLogEvents(launch.logsPath, snapshot, query),
93696
94090
  streamArtifacts: {
93697
94091
  stdoutPath: launch.stdoutPath,
93698
94092
  stderrPath: launch.stderrPath,
93699
94093
  eventsPath: launch.logsPath,
93700
94094
  ...launch.combinedPath ? { combinedPath: launch.combinedPath } : {},
93701
- fidelity: allEvents.some((event) => event.raw?.fidelity === "reconstructed") ? "reconstructed" : "captured"
94095
+ fidelity: snapshot.reconstructed ? "reconstructed" : "captured"
93702
94096
  }
93703
94097
  };
93704
94098
  }
@@ -93719,62 +94113,29 @@ var LaunchLogService = class {
93719
94113
  async flushOutput(record9, cursor, stream, onLog) {
93720
94114
  return this.enqueue(cursor, () => this.flushOutputNow(record9, cursor, stream, onLog));
93721
94115
  }
94116
+ /** Flush partial lines at the end of a run, then sync and close its files. */
93722
94117
  async flushOutputBuffers(record9, cursor, onLog) {
93723
- return this.enqueue(cursor, async () => {
94118
+ await this.enqueue(cursor, async () => {
93724
94119
  await this.flushOutputNow(record9, cursor, "stdout", onLog);
93725
94120
  await this.flushOutputNow(record9, cursor, "stderr", onLog);
93726
- await this.persistTail(record9, cursor);
93727
94121
  });
93728
- }
93729
- async persistTailSnapshot(record9, cursor) {
93730
- await this.enqueue(cursor, () => this.persistTail(record9, cursor));
93731
- }
93732
- retention(record9, cursor) {
93733
- ensureLogCursorState(cursor);
93734
- void record9;
93735
- return {
93736
- totalBytes: cursor.totalBytes,
93737
- retainedBytes: cursor.totalBytes,
93738
- omittedBytes: 0,
93739
- totalLines: cursor.totalLines,
93740
- retainedLines: cursor.totalLines,
93741
- omittedLines: 0,
93742
- headMaxBytes: TASK_OUTPUT_HEAD_MAX_BYTES,
93743
- tailMaxBytes: TASK_OUTPUT_TAIL_MAX_BYTES,
93744
- truncated: false
93745
- };
93746
- }
93747
- async readTail(record9) {
93748
- void record9;
93749
- return [];
93750
- }
93751
- async tailLogEvents(record9, firstSeq) {
93752
- const events = [];
93753
- let seq = firstSeq;
93754
- for (const chunk of await this.readTail(record9)) {
93755
- for (const line2 of chunk.text.split(/\r?\n/)) {
93756
- const cleaned = line2.trimEnd();
93757
- if (!cleaned)
93758
- continue;
93759
- events.push({
93760
- seq,
93761
- ts: record9.finishedAt ?? record9.updatedAt,
93762
- stream: chunk.stream,
93763
- level: classifyLogLevel(chunk.stream, cleaned),
93764
- line: cleaned
93765
- });
93766
- seq += 1;
93767
- }
93768
- }
93769
- return events;
94122
+ await this.release(record9);
93770
94123
  }
93771
94124
  async latestLogSeq(logsPath) {
93772
- const events = await this.readLogEvents(logsPath);
93773
- return events.at(-1)?.seq ?? 0;
94125
+ return (await this.indexes.snapshot(logsPath)).lastSeq;
93774
94126
  }
93775
- async readLogEvents(logsPath) {
93776
- const values = await readJsonLines(logsPath, launchLogEventSchema).catch(() => []);
93777
- return values.sort((a, b) => a.seq - b.seq);
94127
+ /** Sync and close a launch's files and drop its index (exit, delete). */
94128
+ async release(record9) {
94129
+ const writer = this.writers.get(record9.id);
94130
+ this.writers.delete(record9.id);
94131
+ await writer?.close();
94132
+ this.indexes.forget(record9.logsPath);
94133
+ }
94134
+ /** Sync and close every open launch file (daemon shutdown). */
94135
+ async closeAll() {
94136
+ const writers = [...this.writers.values()];
94137
+ this.writers.clear();
94138
+ await Promise.allSettled(writers.map((writer) => writer.close()));
93778
94139
  }
93779
94140
  enqueue(cursor, launch) {
93780
94141
  ensureLogCursorState(cursor);
@@ -93782,23 +94143,17 @@ var LaunchLogService = class {
93782
94143
  cursor.logQueue = queued.catch(() => void 0);
93783
94144
  return queued;
93784
94145
  }
94146
+ writer(record9) {
94147
+ let writer = this.writers.get(record9.id);
94148
+ if (!writer) {
94149
+ writer = new LaunchLogWriter(record9, this.indexes);
94150
+ this.writers.set(record9.id, writer);
94151
+ }
94152
+ return writer;
94153
+ }
93785
94154
  async captureBoundedOutputNow(record9, cursor, stream, bytes3, onLog) {
93786
94155
  ensureLogCursorState(cursor);
93787
- cursor.totalBytes += bytes3.byteLength;
93788
- cursor.totalLines += countOutputLines(bytes3.toString("utf8"));
93789
- cursor.retainedBytes += bytes3.byteLength;
93790
- cursor.retainedLines = cursor.totalLines;
93791
- await mkdir25(dirname25(record9.logsPath), { recursive: true, mode: 448 });
93792
- const streamPath = stream === "stdout" ? record9.stdoutPath : record9.stderrPath;
93793
- await appendAndSync(streamPath, bytes3);
93794
- if (record9.combinedPath) {
93795
- await appendAndSync(record9.combinedPath, Buffer.concat([
93796
- Buffer.from(`[${stream}]
93797
- `, "utf8"),
93798
- bytes3,
93799
- bytes3.at(-1) === 10 ? Buffer.alloc(0) : Buffer.from("\n")
93800
- ]));
93801
- }
94156
+ await this.writer(record9).appendOutput(stream, bytes3);
93802
94157
  await this.captureOutputNow(record9, cursor, stream, bytes3, onLog);
93803
94158
  }
93804
94159
  async captureOutputNow(record9, cursor, stream, chunk, onLog) {
@@ -93857,10 +94212,6 @@ var LaunchLogService = class {
93857
94212
  });
93858
94213
  await this.persistLogLines(record9, event ? [event] : [], onLog);
93859
94214
  }
93860
- async persistTail(record9, cursor) {
93861
- void record9;
93862
- cursor.tailDirtyBytes = 0;
93863
- }
93864
94215
  createLogLine(cursor, stream, line2, raw2) {
93865
94216
  const cleaned = line2.trimEnd();
93866
94217
  if (cleaned.length === 0)
@@ -93878,7 +94229,7 @@ var LaunchLogService = class {
93878
94229
  async persistLogLines(record9, events, onLog) {
93879
94230
  if (events.length === 0)
93880
94231
  return;
93881
- await appendJsonLines(record9.logsPath, events, 384);
94232
+ await this.writer(record9).appendEvents(events);
93882
94233
  for (const event of events) {
93883
94234
  this.options.diagnostics?.count("launch.outputLine");
93884
94235
  if (this.options.publishOutputEvents !== false) {
@@ -93893,15 +94244,6 @@ var LaunchLogService = class {
93893
94244
  }
93894
94245
  }
93895
94246
  };
93896
- async function appendAndSync(path7, bytes3) {
93897
- const file = await open11(path7, "a", 384);
93898
- try {
93899
- await file.write(bytes3);
93900
- await file.sync();
93901
- } finally {
93902
- await file.close();
93903
- }
93904
- }
93905
94247
  function ensureLogCursorState(cursor) {
93906
94248
  cursor.lineBuffers ??= { stdout: "", stderr: "" };
93907
94249
  cursor.lineBuffers.stdout ??= "";
@@ -93913,24 +94255,6 @@ function ensureLogCursorState(cursor) {
93913
94255
  cursor.streamBytes.stdout ??= 0;
93914
94256
  cursor.streamBytes.stderr ??= 0;
93915
94257
  cursor.logQueue ??= Promise.resolve();
93916
- cursor.totalBytes ??= 0;
93917
- cursor.retainedBytes ??= 0;
93918
- cursor.omittedBytes ??= 0;
93919
- cursor.totalLines ??= 0;
93920
- cursor.retainedLines ??= 0;
93921
- cursor.omittedLines ??= 0;
93922
- cursor.tailChunks ??= [];
93923
- cursor.tailBytes ??= 0;
93924
- cursor.tailDirtyBytes ??= 0;
93925
- }
93926
- function countOutputLines(text13) {
93927
- if (text13.length === 0)
93928
- return 0;
93929
- let lines = 0;
93930
- for (const character of text13)
93931
- if (character === "\n")
93932
- lines += 1;
93933
- return lines;
93934
94258
  }
93935
94259
  var WORD_LEFT_BOUNDARY = "(?:^|[^A-Za-z0-9_-])";
93936
94260
  var WORD_RIGHT_BOUNDARY = "(?=$|[^A-Za-z0-9_-])";
@@ -93940,16 +94264,6 @@ var stdoutErrorPattern = new RegExp([
93940
94264
  "^\\s*(error|failed|failure|fatal)(:|\\b)",
93941
94265
  "^\\s*(fatal\\s+error|uncaught\\s+exception|traceback)(:|\\b)"
93942
94266
  ].join("|"), "i");
93943
- function omissionEvent(headEvents, omittedBytes) {
93944
- const last = headEvents.at(-1);
93945
- return {
93946
- seq: (last?.seq ?? 0) + 1,
93947
- ts: last?.ts ?? (/* @__PURE__ */ new Date(0)).toISOString(),
93948
- stream: "stdout",
93949
- level: "info",
93950
- line: `[${omittedBytes} output bytes omitted by launch retention]`
93951
- };
93952
- }
93953
94267
  function classifyLogLevel(stream, line2) {
93954
94268
  if (warningPattern.test(line2))
93955
94269
  return "warn";
@@ -94301,6 +94615,11 @@ function createWorkbenchLaunchResources(storage, events, logger, options2) {
94301
94615
  });
94302
94616
  const supervisor = options2.supervisor ?? defaultLaunchSupervisor;
94303
94617
  const readiness = new OutputReadinessCoordinator();
94618
+ void repository.bundles.reconcile({ has: (id2) => launches.has(id2) }).catch((error3) => {
94619
+ void logger?.warn("Launch log bundle reconciliation failed", {
94620
+ context: { error: error3 }
94621
+ });
94622
+ });
94304
94623
  const eventPublisher = {
94305
94624
  publish: async (event) => {
94306
94625
  await events.publish(event.type, event.data);
@@ -94337,9 +94656,12 @@ function createWorkbenchLaunchResources(storage, events, logger, options2) {
94337
94656
  await repository.bundles.initializeLaunch(launch.id);
94338
94657
  },
94339
94658
  remove: async (id2) => {
94659
+ const launch = launches.get(id2);
94340
94660
  launches.delete(id2);
94341
94661
  managed.delete(id2);
94342
94662
  readiness.forget(id2);
94663
+ if (launch)
94664
+ await logs.release(launch);
94343
94665
  await repository.bundles.remove(id2);
94344
94666
  }
94345
94667
  },
@@ -94366,18 +94688,9 @@ function createWorkbenchLaunchResources(storage, events, logger, options2) {
94366
94688
  readiness.capture(launch.id, Buffer.isBuffer(chunk) ? chunk.toString("utf8") : chunk);
94367
94689
  await logs.captureOutput(launch, state, stream, chunk, async () => void 0);
94368
94690
  },
94369
- query: async (launch, query) => {
94370
- const state = managed.get(launch.id);
94371
- if (state)
94372
- await logs.persistTailSnapshot(launch, state);
94373
- const outputRetention = state ? logs.retention(launch, state) : launch.outputRetention;
94374
- return await logs.queryLogs({ ...launch, outputRetention }, query);
94375
- },
94691
+ query: (launch, query) => logs.queryLogs(launch, query),
94376
94692
  remove: async () => void 0,
94377
- retention: (launch) => {
94378
- const state = managed.get(launch.id);
94379
- return state ? logs.retention(launch, state) : launch.outputRetention;
94380
- }
94693
+ close: () => logs.closeAll()
94381
94694
  },
94382
94695
  readiness: {
94383
94696
  wait: (launch, request) => readiness.wait(launch, request)
@@ -95044,7 +95357,6 @@ var LaunchService = class {
95044
95357
  launch.finishedAt = exit.exitedAt;
95045
95358
  launch.updatedAt = exit.exitedAt;
95046
95359
  launch.status = status;
95047
- launch.outputRetention = this.ports.logs.retention?.(launch);
95048
95360
  if (reason2)
95049
95361
  launch.error = reason2;
95050
95362
  else if (status === "timed_out")
@@ -95118,6 +95430,7 @@ var LaunchService = class {
95118
95430
  timeoutMs: 100,
95119
95431
  reason: "daemon_shutdown"
95120
95432
  })));
95433
+ await this.ports.logs.close?.().catch(() => void 0);
95121
95434
  }
95122
95435
  async updateLaunch(id2, patch) {
95123
95436
  const current = this.resources.launches.get(id2);
@@ -95500,7 +95813,7 @@ import { homedir as homedir7 } from "node:os";
95500
95813
  import { join as join53 } from "node:path";
95501
95814
 
95502
95815
  // packages/workbench-server/dist/domains/projects/project-launch-target.js
95503
- import { realpath as realpath16, stat as stat18 } from "node:fs/promises";
95816
+ import { realpath as realpath16, stat as stat19 } from "node:fs/promises";
95504
95817
  import { isAbsolute as isAbsolute17, relative as relative17, resolve as resolve24, sep as sep12 } from "node:path";
95505
95818
  async function resolveProjectLaunchTarget(project2, rawPath, options2 = {}) {
95506
95819
  const root = await canonicalPath2(project2.directory, "PROJECT_PATH_NOT_FOUND");
@@ -95514,7 +95827,7 @@ async function resolveProjectLaunchTarget(project2, rawPath, options2 = {}) {
95514
95827
  throw invalidPath("Project launch path escapes the project root.");
95515
95828
  }
95516
95829
  if (options2.directory) {
95517
- const info = await stat18(target2);
95830
+ const info = await stat19(target2);
95518
95831
  if (!info.isDirectory()) {
95519
95832
  throw new ApplicationError(400, "PROJECT_PATH_NOT_DIRECTORY", "Terminal launch path must be a directory.");
95520
95833
  }
@@ -95849,13 +96162,13 @@ var ProjectTerminalService = class {
95849
96162
  };
95850
96163
  }
95851
96164
  if (this.platform === "darwin") {
95852
- const open13 = await this.locate("/usr/bin/open");
95853
- if (!open13)
96165
+ const open14 = await this.locate("/usr/bin/open");
96166
+ if (!open14)
95854
96167
  return void 0;
95855
96168
  return {
95856
96169
  source: "system",
95857
- executable: open13.path,
95858
- command: open13,
96170
+ executable: open14.path,
96171
+ command: open14,
95859
96172
  argsForDir: (dir) => ["-a", "Terminal", dir],
95860
96173
  windowsHide: true
95861
96174
  };
@@ -95886,7 +96199,7 @@ function unavailableStatus2() {
95886
96199
 
95887
96200
  // packages/workbench-server/dist/domains/projects/project-icon.service.js
95888
96201
  import { createHash as createHash30 } from "node:crypto";
95889
- import { realpath as realpath17, readFile as readFile33, stat as stat19 } from "node:fs/promises";
96202
+ import { realpath as realpath17, readFile as readFile33, stat as stat20 } from "node:fs/promises";
95890
96203
  import { isAbsolute as isAbsolute18, relative as relative18, resolve as resolve26, sep as sep13 } from "node:path";
95891
96204
 
95892
96205
  // packages/workbench-server/dist/domains/projects/project-icon-discovery.js
@@ -96784,7 +97097,7 @@ async function readSmallContainedFile(root, candidate, maxBytes2) {
96784
97097
  const resolvedPath = await realpath17(path7);
96785
97098
  if (!isInside3(root, resolvedPath))
96786
97099
  return void 0;
96787
- const metadata = await stat19(resolvedPath);
97100
+ const metadata = await stat20(resolvedPath);
96788
97101
  if (!metadata.isFile() || metadata.size < 1 || metadata.size > maxBytes2) {
96789
97102
  return void 0;
96790
97103
  }
@@ -100354,7 +100667,7 @@ function createExtensionFrameRoutes(state, assetsPath = resolveFrameAssetsPath(i
100354
100667
  // packages/workbench-server/dist/domains/filesystem/html-preview.service.js
100355
100668
  import { randomBytes as randomBytes9 } from "node:crypto";
100356
100669
  import { constants as constants9 } from "node:fs";
100357
- import { open as open12, realpath as realpath20, stat as stat20 } from "node:fs/promises";
100670
+ import { open as open13, realpath as realpath20, stat as stat21 } from "node:fs/promises";
100358
100671
  import { dirname as dirname28, extname as extname10, isAbsolute as isAbsolute20, relative as relative21, resolve as resolve30, win32 as win322 } from "node:path";
100359
100672
 
100360
100673
  // node_modules/.pnpm/parse5@8.0.0/node_modules/parse5/dist/common/unicode.js
@@ -108388,12 +108701,12 @@ async function openProjectFile(root, path7, mime) {
108388
108701
  const target2 = await realpath20(requested);
108389
108702
  if (!contained2(root, target2) || mime && mimeTypes[extname10(target2).toLowerCase()] !== mime)
108390
108703
  missing2();
108391
- const file = await open12(target2, constants9.O_RDONLY | (constants9.O_NOFOLLOW ?? 0));
108704
+ const file = await open13(target2, constants9.O_RDONLY | (constants9.O_NOFOLLOW ?? 0));
108392
108705
  try {
108393
108706
  const canonical3 = await realpath20(requested);
108394
108707
  if (canonical3 !== target2 || !contained2(root, canonical3) || mime && mimeTypes[extname10(canonical3).toLowerCase()] !== mime)
108395
108708
  missing2();
108396
- const [opened, current] = await Promise.all([file.stat(), stat20(canonical3)]);
108709
+ const [opened, current] = await Promise.all([file.stat(), stat21(canonical3)]);
108397
108710
  if (!opened.isFile() || opened.dev !== current.dev || opened.ino !== current.ino)
108398
108711
  missing2();
108399
108712
  return file;
@@ -108532,13 +108845,13 @@ var HtmlPreviewService = class {
108532
108845
  missing2();
108533
108846
  const file = await openProjectFile(session.root, path7, mime).catch(() => missing2());
108534
108847
  try {
108535
- const stat21 = await file.stat();
108536
- if (!stat21.isFile() || stat21.size > MAX_ASSET_BYTES)
108848
+ const stat22 = await file.stat();
108849
+ if (!stat22.isFile() || stat22.size > MAX_ASSET_BYTES)
108537
108850
  missing2();
108538
108851
  headers["Content-Type"] = mime;
108539
108852
  if (head)
108540
108853
  return new Response(null, { headers });
108541
- const buffer = Buffer.alloc(Math.min(stat21.size + 1, MAX_ASSET_BYTES + 1));
108854
+ const buffer = Buffer.alloc(Math.min(stat22.size + 1, MAX_ASSET_BYTES + 1));
108542
108855
  let bytesRead = 0;
108543
108856
  while (bytesRead < buffer.length) {
108544
108857
  const result = await file.read(buffer, bytesRead, buffer.length - bytesRead, bytesRead);
@@ -109480,4 +109793,4 @@ export {
109480
109793
  legacyTokenRedirect,
109481
109794
  createApp
109482
109795
  };
109483
- /*! For license information please see chunk-EBDLSTDH.js.LEGAL.txt */
109796
+ /*! For license information please see chunk-WQHOXPLV.js.LEGAL.txt */