@mcoda/mswarm 0.1.135-codali.29 → 0.1.135-codali.32

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 (176) hide show
  1. package/dist/codali-executor.d.ts +6 -0
  2. package/dist/codali-executor.d.ts.map +1 -1
  3. package/dist/codali-executor.js +8 -0
  4. package/dist/codali-executor.js.map +1 -1
  5. package/dist/runtime.d.ts +3 -0
  6. package/dist/runtime.d.ts.map +1 -1
  7. package/dist/runtime.js +2 -1
  8. package/dist/runtime.js.map +1 -1
  9. package/dist/vendor/codali/cli/TerminalCommand.d.ts +2 -1
  10. package/dist/vendor/codali/cli/TerminalCommand.d.ts.map +1 -1
  11. package/dist/vendor/codali/cli/TerminalCommand.js +27 -27
  12. package/dist/vendor/codali/cli/tui/TerminalPresentation.d.ts +2 -0
  13. package/dist/vendor/codali/cli/tui/TerminalPresentation.d.ts.map +1 -1
  14. package/dist/vendor/codali/cli/tui/TerminalPresentation.js +77 -2
  15. package/dist/vendor/codali/cli/tui/TerminalTui.d.ts.map +1 -1
  16. package/dist/vendor/codali/cli/tui/TerminalTui.js +14 -3
  17. package/dist/vendor/codali/config/OrchestrationConfig.d.ts +7 -0
  18. package/dist/vendor/codali/config/OrchestrationConfig.d.ts.map +1 -1
  19. package/dist/vendor/codali/config/OrchestrationConfig.js +15 -2
  20. package/dist/vendor/codali/docdex/DocdexClient.d.ts +1 -0
  21. package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -1
  22. package/dist/vendor/codali/docdex/DocdexClient.js +1 -1
  23. package/dist/vendor/codali/docdex/ManagedDocdex.d.ts +3 -0
  24. package/dist/vendor/codali/docdex/ManagedDocdex.d.ts.map +1 -1
  25. package/dist/vendor/codali/docdex/ManagedDocdex.js +17 -1
  26. package/dist/vendor/codali/gateway/GroundingMode.d.ts.map +1 -1
  27. package/dist/vendor/codali/gateway/GroundingMode.js +23 -3
  28. package/dist/vendor/codali/permissions/PermissionGate.d.ts.map +1 -1
  29. package/dist/vendor/codali/permissions/PermissionGate.js +7 -5
  30. package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts.map +1 -1
  31. package/dist/vendor/codali/providers/ConfiguredModelScope.js +2 -1
  32. package/dist/vendor/codali/providers/ConfiguredProvider.d.ts +1 -0
  33. package/dist/vendor/codali/providers/ConfiguredProvider.d.ts.map +1 -1
  34. package/dist/vendor/codali/providers/ConfiguredProvider.js +51 -30
  35. package/dist/vendor/codali/providers/ModelCapacityWait.d.ts +21 -0
  36. package/dist/vendor/codali/providers/ModelCapacityWait.d.ts.map +1 -0
  37. package/dist/vendor/codali/providers/ModelCapacityWait.js +40 -0
  38. package/dist/vendor/codali/providers/ModelServiceError.d.ts +11 -2
  39. package/dist/vendor/codali/providers/ModelServiceError.d.ts.map +1 -1
  40. package/dist/vendor/codali/providers/ModelServiceError.js +13 -5
  41. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
  42. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +20 -5
  43. package/dist/vendor/codali/providers/ProviderTypes.d.ts +4 -0
  44. package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -1
  45. package/dist/vendor/codali/providers/RequestSize.d.ts +5 -0
  46. package/dist/vendor/codali/providers/RequestSize.d.ts.map +1 -0
  47. package/dist/vendor/codali/providers/RequestSize.js +10 -0
  48. package/dist/vendor/codali/runtime/AnswerVerification.d.ts +17 -0
  49. package/dist/vendor/codali/runtime/AnswerVerification.d.ts.map +1 -0
  50. package/dist/vendor/codali/runtime/AnswerVerification.js +39 -0
  51. package/dist/vendor/codali/runtime/CompletionReport.d.ts +2 -0
  52. package/dist/vendor/codali/runtime/CompletionReport.d.ts.map +1 -1
  53. package/dist/vendor/codali/runtime/CompletionReport.js +17 -0
  54. package/dist/vendor/codali/runtime/ContextCompression.d.ts +19 -3
  55. package/dist/vendor/codali/runtime/ContextCompression.d.ts.map +1 -1
  56. package/dist/vendor/codali/runtime/ContextCompression.js +224 -14
  57. package/dist/vendor/codali/runtime/GatewayRequest.d.ts +5 -0
  58. package/dist/vendor/codali/runtime/GatewayRequest.d.ts.map +1 -0
  59. package/dist/vendor/codali/runtime/GatewayRequest.js +19 -0
  60. package/dist/vendor/codali/runtime/InspectionBudget.d.ts +4 -1
  61. package/dist/vendor/codali/runtime/InspectionBudget.d.ts.map +1 -1
  62. package/dist/vendor/codali/runtime/InspectionBudget.js +14 -16
  63. package/dist/vendor/codali/runtime/InspectionConvergence.d.ts +24 -0
  64. package/dist/vendor/codali/runtime/InspectionConvergence.d.ts.map +1 -0
  65. package/dist/vendor/codali/runtime/InspectionConvergence.js +67 -0
  66. package/dist/vendor/codali/runtime/InteractionContract.d.ts +2 -0
  67. package/dist/vendor/codali/runtime/InteractionContract.d.ts.map +1 -1
  68. package/dist/vendor/codali/runtime/InteractionContract.js +14 -0
  69. package/dist/vendor/codali/runtime/InteractionRouter.d.ts +6 -4
  70. package/dist/vendor/codali/runtime/InteractionRouter.d.ts.map +1 -1
  71. package/dist/vendor/codali/runtime/InteractionRouter.js +15 -11
  72. package/dist/vendor/codali/runtime/PlanCoverage.d.ts +9 -0
  73. package/dist/vendor/codali/runtime/PlanCoverage.d.ts.map +1 -0
  74. package/dist/vendor/codali/runtime/PlanCoverage.js +12 -0
  75. package/dist/vendor/codali/runtime/ProgressTracker.d.ts +1 -0
  76. package/dist/vendor/codali/runtime/ProgressTracker.d.ts.map +1 -1
  77. package/dist/vendor/codali/runtime/ProgressTracker.js +25 -5
  78. package/dist/vendor/codali/runtime/ResearchEvidence.d.ts +19 -0
  79. package/dist/vendor/codali/runtime/ResearchEvidence.d.ts.map +1 -0
  80. package/dist/vendor/codali/runtime/ResearchEvidence.js +55 -0
  81. package/dist/vendor/codali/runtime/ReviewCoordinator.d.ts +2 -0
  82. package/dist/vendor/codali/runtime/ReviewCoordinator.d.ts.map +1 -1
  83. package/dist/vendor/codali/runtime/ReviewCoordinator.js +3 -1
  84. package/dist/vendor/codali/runtime/SessionController.d.ts +20 -4
  85. package/dist/vendor/codali/runtime/SessionController.d.ts.map +1 -1
  86. package/dist/vendor/codali/runtime/SessionController.js +869 -213
  87. package/dist/vendor/codali/runtime/SpecialistTools.d.ts +6 -0
  88. package/dist/vendor/codali/runtime/SpecialistTools.d.ts.map +1 -0
  89. package/dist/vendor/codali/runtime/SpecialistTools.js +69 -0
  90. package/dist/vendor/codali/runtime/StructuralEvidence.d.ts +4 -2
  91. package/dist/vendor/codali/runtime/StructuralEvidence.d.ts.map +1 -1
  92. package/dist/vendor/codali/runtime/StructuralEvidence.js +22 -5
  93. package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts +2 -0
  94. package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts.map +1 -1
  95. package/dist/vendor/codali/runtime/WorkspaceLedger.js +44 -20
  96. package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -1
  97. package/dist/vendor/codali/runtime/WorkspaceLock.js +9 -1
  98. package/dist/vendor/codali/runtime/WorkspaceSnapshot.d.ts.map +1 -1
  99. package/dist/vendor/codali/runtime/WorkspaceSnapshot.js +3 -2
  100. package/dist/vendor/codali/runtime/WriteSyntaxCheck.d.ts +10 -0
  101. package/dist/vendor/codali/runtime/WriteSyntaxCheck.d.ts.map +1 -0
  102. package/dist/vendor/codali/runtime/WriteSyntaxCheck.js +34 -0
  103. package/dist/vendor/codali/session/SessionStoragePath.d.ts.map +1 -1
  104. package/dist/vendor/codali/session/SessionStoragePath.js +7 -2
  105. package/dist/vendor/codali/session/SkillCatalog.d.ts.map +1 -1
  106. package/dist/vendor/codali/session/SkillCatalog.js +6 -3
  107. package/dist/vendor/codali/session/WorkState.d.ts +2 -0
  108. package/dist/vendor/codali/session/WorkState.d.ts.map +1 -1
  109. package/dist/vendor/codali/session/WorkState.js +14 -2
  110. package/dist/vendor/codali/session/WorkspaceScope.d.ts +3 -0
  111. package/dist/vendor/codali/session/WorkspaceScope.d.ts.map +1 -0
  112. package/dist/vendor/codali/session/WorkspaceScope.js +19 -0
  113. package/dist/vendor/codali/tools/ToolTypes.d.ts +2 -0
  114. package/dist/vendor/codali/tools/ToolTypes.d.ts.map +1 -1
  115. package/dist/vendor/codali/tools/browser/BrowserSessionTool.d.ts +16 -0
  116. package/dist/vendor/codali/tools/browser/BrowserSessionTool.d.ts.map +1 -0
  117. package/dist/vendor/codali/tools/browser/BrowserSessionTool.js +326 -0
  118. package/dist/vendor/codali/tools/browser/BrowserTool.d.ts +8 -0
  119. package/dist/vendor/codali/tools/browser/BrowserTool.d.ts.map +1 -1
  120. package/dist/vendor/codali/tools/browser/BrowserTool.js +152 -13
  121. package/dist/vendor/codali/tools/browser/BrowserWorker.js +74 -4
  122. package/dist/vendor/codali/tools/calculation/CalculatorTool.d.ts.map +1 -1
  123. package/dist/vendor/codali/tools/calculation/CalculatorTool.js +33 -7
  124. package/dist/vendor/codali/tools/deterministic/DeterministicTools.d.ts.map +1 -1
  125. package/dist/vendor/codali/tools/deterministic/DeterministicTools.js +17 -3
  126. package/dist/vendor/codali/tools/deterministic/python-worker.py +18 -3
  127. package/dist/vendor/codali/tools/docdex/DocdexCatalogTools.d.ts.map +1 -1
  128. package/dist/vendor/codali/tools/docdex/DocdexCatalogTools.js +2 -1
  129. package/dist/vendor/codali/tools/docdex/DocdexTools.js +10 -2
  130. package/dist/vendor/codali/tools/filesystem/FileTools.d.ts.map +1 -1
  131. package/dist/vendor/codali/tools/filesystem/FileTools.js +58 -11
  132. package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts +4 -0
  133. package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts.map +1 -1
  134. package/dist/vendor/codali/tools/shell/AsyncProcess.js +9 -3
  135. package/dist/vendor/codali/tools/shell/HostToolchain.d.ts.map +1 -1
  136. package/dist/vendor/codali/tools/shell/HostToolchain.js +19 -1
  137. package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts +3 -2
  138. package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts.map +1 -1
  139. package/dist/vendor/codali/tools/shell/IsolatedExecutor.js +93 -28
  140. package/dist/vendor/codali/tools/shell/ShellTool.d.ts +2 -0
  141. package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -1
  142. package/dist/vendor/codali/tools/shell/ShellTool.js +18 -4
  143. package/dist/vendor/codali/tools/system/CalendarTool.d.ts +15 -0
  144. package/dist/vendor/codali/tools/system/CalendarTool.d.ts.map +1 -0
  145. package/dist/vendor/codali/tools/system/CalendarTool.js +44 -0
  146. package/dist/vendor/codali/tools/system/TextTool.d.ts +4 -0
  147. package/dist/vendor/codali/tools/system/TextTool.d.ts.map +1 -0
  148. package/dist/vendor/codali/tools/system/TextTool.js +39 -0
  149. package/dist/vendor/codali/tools/verification/VitestTool.d.ts +3 -0
  150. package/dist/vendor/codali/tools/verification/VitestTool.d.ts.map +1 -1
  151. package/dist/vendor/codali/tools/verification/VitestTool.js +65 -9
  152. package/dist/vendor/config/AGENTS.md +6 -0
  153. package/dist/vendor/config/deterministic/python-worker.py +18 -3
  154. package/dist/vendor/config/skills/architecture-design/SKILL.md +14 -0
  155. package/dist/vendor/config/skills/browser-session/SKILL.md +16 -0
  156. package/dist/vendor/config/skills/browser-use/SKILL.md +14 -0
  157. package/dist/vendor/config/skills/code-implementation/SKILL.md +18 -0
  158. package/dist/vendor/config/skills/code-review/SKILL.md +14 -0
  159. package/dist/vendor/config/skills/docdex-research/SKILL.md +18 -0
  160. package/dist/vendor/config/skills/docdex-research/references/catalog.md +111 -0
  161. package/dist/vendor/config/skills/docdex-research/references/memory.md +22 -0
  162. package/dist/vendor/config/skills/docdex-research/references/operations.md +19 -0
  163. package/dist/vendor/config/skills/docdex-research/references/retrieval.md +13 -0
  164. package/dist/vendor/config/skills/planning/SKILL.md +9 -8
  165. package/dist/vendor/config/skills/system-diagnostics/SKILL.md +14 -0
  166. package/dist/vendor/config/skills/system-services/SKILL.md +17 -0
  167. package/dist/vendor/config/skills/system-services/references/docker.md +11 -0
  168. package/dist/vendor/config/skills/system-services/references/linux.md +9 -0
  169. package/dist/vendor/config/skills/system-services/references/macos.md +9 -0
  170. package/dist/vendor/config/skills/systematic-debugging/SKILL.md +14 -0
  171. package/dist/vendor/config/skills/testing-and-verification/SKILL.md +16 -0
  172. package/dist/vendor/config/skills/tool-selection/SKILL.md +16 -0
  173. package/dist/vendor/config/skills/ui-ux-design/SKILL.md +16 -0
  174. package/dist/vendor/config/skills/ui-ux-design/references/validation.md +13 -0
  175. package/dist/vendor/config/skills/webapp-testing/SKILL.md +12 -0
  176. package/package.json +3 -3
@@ -24,6 +24,14 @@ process.once("message", async (input) => {
24
24
  });
25
25
  await context.routeWebSocket("**/*", socket => socket.close());
26
26
  const tab = await context.newPage();
27
+ let httpStatus = null;
28
+ let contentType = null;
29
+ tab.on("response", response => {
30
+ if (response.request().isNavigationRequest() && response.frame() === tab.mainFrame()) {
31
+ httpStatus = response.status();
32
+ contentType = response.headers()["content-type"] ?? null;
33
+ }
34
+ });
27
35
  context.on("page", popup => { if (popup !== tab)
28
36
  void popup.close().catch(() => undefined); });
29
37
  tab.on("dialog", dialog => { void dialog.dismiss().catch(() => undefined); });
@@ -32,12 +40,74 @@ process.once("message", async (input) => {
32
40
  profile: { accept_downloads: false, enable_default_extensions: false, captcha_solver: false,
33
41
  keep_alive: false, permissions: [], minimum_wait_page_load_time: 0,
34
42
  wait_for_network_idle_page_load_time: 0.1, maximum_wait_page_load_time: 1 } });
35
- await session.navigate_to(input.url, { wait_until: "domcontentloaded", timeout_ms: 25000 });
43
+ // A network-interface change aborts navigation immediately and says nothing
44
+ // about the page itself, so a single retry is cheap and cannot mask a 404.
45
+ for (let attempt = 0;; attempt++) {
46
+ try {
47
+ await session.navigate_to(input.url, { wait_until: "domcontentloaded", timeout_ms: 25000 });
48
+ break;
49
+ }
50
+ catch (error) {
51
+ if (attempt >= 1 || !String(error).includes("ERR_NETWORK_CHANGED"))
52
+ throw error;
53
+ await new Promise(resolve => setTimeout(resolve, 1000));
54
+ }
55
+ }
56
+ // Accessibility snapshots otherwise flatten deleted/struck-through text
57
+ // into apparently current prose. Mark revisions in this disposable DOM;
58
+ // no page action, form submission or remote mutation is performed.
59
+ await tab.locator('del, s, strike, [style*="line-through"]').evaluateAll(elements => {
60
+ for (const element of elements.slice(0, 100)) {
61
+ if (element.parentElement?.closest('del, s, strike, [style*="line-through"]'))
62
+ continue;
63
+ element.prepend(document.createTextNode("[DELETED/STRUCK-THROUGH TEXT — not current guidance: "));
64
+ element.append(document.createTextNode("]"));
65
+ }
66
+ });
36
67
  const main = tab.getByRole("main");
37
68
  const useMain = input.scope !== "page" && await main.count() > 0;
38
- const content = useMain ? await main.first().ariaSnapshot({ timeout: 5000 }) : await tab.ariaSnapshot({ mode: "default", depth: 20, timeout: 5000 });
39
- reply = { ok: true, value: { url: tab.url(), title: (await tab.title()).slice(0, 1000), scope: useMain ? "main" : "page",
40
- content: content.slice(0, 100000), truncated: content.length > 100000 } };
69
+ const root = useMain ? main.first() : tab.locator("body");
70
+ let content;
71
+ let format = "accessibility";
72
+ if (input.scope !== "page") {
73
+ // Inline links/emphasis split ordinary prose into many ARIA records. Read
74
+ // rendered text for research, retaining heading scopes and revision marks.
75
+ // The disposable page is never submitted or persisted remotely.
76
+ const links = await root.locator("a[href]").evaluateAll(elements => elements.slice(0, 128).flatMap(element => {
77
+ const link = element;
78
+ if (link.closest('nav,[role="navigation"]') || !link.getClientRects().length)
79
+ return [];
80
+ try {
81
+ const url = new URL(link.href);
82
+ return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password
83
+ ? [`- link ${JSON.stringify((link.innerText || link.textContent || "").trim().slice(0, 160))}\n - /url: ${url.href.slice(0, 1000)}`] : [];
84
+ }
85
+ catch {
86
+ return [];
87
+ }
88
+ }));
89
+ await root.locator('h1,h2,h3,h4,h5,h6,[role="heading"]').evaluateAll(elements => {
90
+ for (const element of elements) {
91
+ const heading = element;
92
+ const level = Number(heading.getAttribute("aria-level") || heading.tagName.slice(1)) || 2;
93
+ const label = heading.innerText?.trim();
94
+ if (label)
95
+ heading.textContent = `- heading ${JSON.stringify(label)} [level=${Math.min(6, Math.max(1, level))}]`;
96
+ }
97
+ });
98
+ content = await root.innerText({ timeout: 5000 });
99
+ if (content.trim()) {
100
+ format = "rendered_text";
101
+ if (links.length)
102
+ content += `\n\nSource links (first 128, bounded; not additional retrieved evidence):\n${links.join("\n").slice(0, 16000)}`;
103
+ }
104
+ else
105
+ content = await root.ariaSnapshot({ timeout: 5000 });
106
+ }
107
+ else
108
+ content = await tab.ariaSnapshot({ mode: "default", depth: 20, timeout: 5000 });
109
+ reply = { ok: true, value: { url: tab.url(), httpStatus, contentType, title: (await tab.title()).slice(0, 1000), scope: useMain ? "main" : "page",
110
+ format, content: content.slice(0, 1000000), truncated: content.length > 1000000 } };
41
111
  }
42
112
  catch (error) {
43
113
  reply = { ok: false, message: error instanceof Error ? error.message : String(error) };
@@ -1 +1 @@
1
- {"version":3,"file":"CalculatorTool.d.ts","sourceRoot":"","sources":["../../../src/tools/calculation/CalculatorTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAoC1E,yGAAyG;AACzG,eAAO,MAAM,mBAAmB,GAAI,YAAY,MAAM,KAAG,MA0DxD,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAO,cAatC,CAAC"}
1
+ {"version":3,"file":"CalculatorTool.d.ts","sourceRoot":"","sources":["../../../src/tools/calculation/CalculatorTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA8C1E,yGAAyG;AACzG,eAAO,MAAM,mBAAmB,GAAI,YAAY,MAAM,KAAG,MA0DxD,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAO,cA0BtC,CAAC"}
@@ -10,7 +10,7 @@ const finite = (value) => {
10
10
  const tokenize = (expression) => {
11
11
  if (typeof expression !== "string" || !expression.trim() || expression.length > 4096)
12
12
  throw new Error("Expected an expression of 1 to 4096 characters");
13
- const pattern = /\s+|(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|[A-Za-z_][A-Za-z_0-9]*|\*\*|[+*/%^(),-]/y;
13
+ const pattern = /\s+|(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|Math\.[A-Za-z_][A-Za-z_0-9]*|[A-Za-z_][A-Za-z_0-9]*|\*\*|[+*/%^(),-]/y;
14
14
  const tokens = [];
15
15
  let offset = 0;
16
16
  while (offset < expression.length) {
@@ -19,8 +19,10 @@ const tokenize = (expression) => {
19
19
  if (!match)
20
20
  throw new Error(`Unsupported character at position ${offset + 1}`);
21
21
  offset = pattern.lastIndex;
22
- if (match[0].trim())
23
- tokens.push(match[0]);
22
+ // Literal aliases enter the same bounded grammar; no object lookup or code execution.
23
+ const token = match[0].startsWith("Math.") ? match[0].slice(5) : match[0];
24
+ if (token.trim())
25
+ tokens.push(token === "PI" ? "pi" : token === "E" ? "e" : token);
24
26
  if (tokens.length > 1024)
25
27
  throw new Error("Expression exceeds 1024 tokens");
26
28
  }
@@ -29,6 +31,14 @@ const tokenize = (expression) => {
29
31
  const functions = new Map([
30
32
  ["abs", { min: 1, max: 1, run: Math.abs }],
31
33
  ["sqrt", { min: 1, max: 1, run: Math.sqrt }],
34
+ ["exp", { min: 1, max: 1, run: Math.exp }],
35
+ ["ln", { min: 1, max: 1, run: Math.log }],
36
+ ["log", { min: 1, max: 1, run: Math.log }],
37
+ ["log10", { min: 1, max: 1, run: Math.log10 }],
38
+ ["sin", { min: 1, max: 1, run: Math.sin }],
39
+ ["cos", { min: 1, max: 1, run: Math.cos }],
40
+ ["tan", { min: 1, max: 1, run: Math.tan }],
41
+ ["pow", { min: 2, max: 2, run: Math.pow }],
32
42
  ["floor", { min: 1, max: 1, run: Math.floor }],
33
43
  ["ceil", { min: 1, max: 1, run: Math.ceil }],
34
44
  ["round", { min: 1, max: 1, run: Math.round }],
@@ -122,16 +132,32 @@ export const evaluateCalculation = (expression) => {
122
132
  };
123
133
  export const createCalculatorTool = () => ({
124
134
  name: "calculate", capability: "calculation", readOnly: true,
125
- description: "Evaluate a numeric expression. Supports + - * / %, powers ^ or **, parentheses, pi, e, abs/sqrt/floor/ceil/round (one argument), min/max/sum (1-128 comma-separated arguments). % is signed remainder; round ties toward positive infinity. IEEE-754 floating-point, not exact decimal arithmetic; unsafe integers rejected. No variables, code, files or network. Use observed results to check arithmetic; you remain responsible for choosing the right formula and units.",
126
- inputSchema: { type: "object", properties: { expression: { type: "string", minLength: 1, maxLength: 4096 } }, required: ["expression"], additionalProperties: false },
135
+ description: "Calculate {expression:'formula'} OR {expressions:{label:'formula'}} (up to16). Supports exp,ln/log(natural),log10,pow,sin/cos/tan(radians),abs,sqrt,floor,ceil,round,min,max,sum; + - * / %, ^ **, pi,e. Math.function aliases accepted only for this allowlist. No variables, assignments or code. IEEE-754 approximate; exact decimals use decimal_calculate. Tool success checks arithmetic, not whether your formula models the request.",
136
+ inputSchema: { type: "object", properties: { expression: { type: "string", description: "One numeric formula, e.g. exp(-2)*3. Supply this OR expressions.", minLength: 1, maxLength: 4096 },
137
+ expressions: { type: "object", description: "Map labels to complete formula STRINGS, e.g. {total:'2*3+4',check:'10'}. Each formula is independent; labels are not variables. Supply this OR expression.", minProperties: 1, maxProperties: 16, propertyNames: { pattern: "^[A-Za-z][A-Za-z0-9_]{0,63}$" }, additionalProperties: true },
138
+ }, oneOf: [{ required: ["expression"] }, { required: ["expressions"] }], additionalProperties: false },
127
139
  handler: async (args, context) => {
128
140
  context.signal?.throwIfAborted();
129
141
  try {
130
- const result = evaluateCalculation(args.expression);
142
+ const input = args;
143
+ if (!input || typeof input !== "object" || Array.isArray(input) || input.expression === undefined && input.expressions === undefined)
144
+ throw new Error('Use {"expression":"2+3"} or {"expressions":{"total":"2+3"}}; formulas must be strings');
145
+ if (input.expressions !== undefined) {
146
+ if (input.expression !== undefined || !input.expressions || Array.isArray(input.expressions) || Object.keys(input.expressions).length < 1 || Object.keys(input.expressions).length > 16)
147
+ throw new Error("Supply expression or up to16 named expressions, not both");
148
+ const results = Object.fromEntries(Object.entries(input.expressions).map(([label, expression]) => {
149
+ if (!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(label))
150
+ throw new Error("Invalid calculation label");
151
+ return [label, evaluateCalculation(expression)];
152
+ }));
153
+ return { output: JSON.stringify({ results, arithmetic: "IEEE-754 double; not exact decimal arithmetic" }) };
154
+ }
155
+ const result = evaluateCalculation(input.expression);
131
156
  return { output: JSON.stringify({ result, arithmetic: "IEEE-754 double; not exact decimal arithmetic" }) };
132
157
  }
133
158
  catch (error) {
134
- throw new ToolExecutionError("tool_invalid_args", error instanceof Error ? error.message : String(error), { retryable: false });
159
+ const message = error instanceof Error ? error.message : String(error);
160
+ throw new ToolExecutionError("tool_invalid_args", `${message}. Correct the arguments before retrying; use tools_describe for the schema. No assignments or arbitrary code; supported functions include exp(x), ln(x), log10(x), pow(x,y).`, { retryable: false });
135
161
  }
136
162
  },
137
163
  });
@@ -1 +1 @@
1
- {"version":3,"file":"DeterministicTools.d.ts","sourceRoot":"","sources":["../../../src/tools/deterministic/DeterministicTools.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwC,KAAK,cAAc,EAAmD,MAAM,iBAAiB,CAAC;AAmC7I,sFAAsF;AACtF,MAAM,WAAW,wBAAwB;IAAG,UAAU,CAAC,EAAE,MAAM,CAAC;CAAE;AAClE,eAAO,MAAM,qBAAqB,QAAO,MAAmI,CAAC;AAqC7K,eAAO,MAAM,wBAAwB,GAAI,UAAS,wBAA6B,KAAG,cAAc,EAG7F,CAAC"}
1
+ {"version":3,"file":"DeterministicTools.d.ts","sourceRoot":"","sources":["../../../src/tools/deterministic/DeterministicTools.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwC,KAAK,cAAc,EAAmD,MAAM,iBAAiB,CAAC;AAqC7I,sFAAsF;AACtF,MAAM,WAAW,wBAAwB;IAAG,UAAU,CAAC,EAAE,MAAM,CAAC;CAAE;AAClE,eAAO,MAAM,qBAAqB,QAAO,MAAmI,CAAC;AA6C7K,eAAO,MAAM,wBAAwB,GAAI,UAAS,wBAA6B,KAAG,cAAc,EAG7F,CAAC"}
@@ -18,7 +18,9 @@ const schemas = {
18
18
  validate_json: object({ schema: jsonValue, data: jsonValue }, ["schema", "data"]),
19
19
  symbolic_math: object({ operation: choices("simplify", "factor", "expand", "differentiate", "integrate", "solve"), expression: string(), symbols: array(identifier, 16), variable: identifier }, ["operation", "expression", "symbols"]),
20
20
  solve_constraints: object({ variables: { type: "object", additionalProperties: true }, constraints: array(string(), 64, 1) }, ["variables", "constraints"]),
21
- query_data: object({ sql: string(8000), tables: array(object({ name: identifier, columns: { type: "object", additionalProperties: true }, rows: array(array(scalar, 32, 1), 2000) }, ["name", "columns", "rows"]), 8) }, ["sql", "tables"]),
21
+ query_data: object({ sql: string(8000), tables: array(object({ name: identifier, columns: { type: "object", additionalProperties: true },
22
+ columnOrder: array(identifier, 32, 1), rows: array({ type: ["array", "object"], items: scalar, minItems: 1, maxItems: 32, additionalProperties: true }, 2000) }, ["name", "columns", "rows"]), 8),
23
+ expectedRows: array(array(scalar, 32), 1000), rowOrder: choices("ordered", "unordered") }, ["sql", "tables"]),
22
24
  transform_data: object({ rows: array({ type: "object", additionalProperties: true }, 2000), steps: array(object({
23
25
  operation: choices("select", "sort", "head", "filter", "aggregate"), columns: array(string(128), 32, 1), descending: { type: "boolean" },
24
26
  count: { type: "integer", minimum: 0, maximum: 1000 }, column: string(128), comparison: choices("eq", "ne", "gt", "ge", "lt", "le"), value: scalar,
@@ -31,7 +33,7 @@ const descriptions = {
31
33
  validate_json: "Ajv validates data against JSON Schema draft-07, without mutation/coercion, remote refs or format checks. Returns valid/errors. Offline and bounded.",
32
34
  symbolic_math: "SymPy exact symbolic algebra/calculus. Declare symbols; expression uses + - * / ** and sin/cos/tan/exp/log/sqrt/Abs, pi/E. solve treats expression as zero; variable required for solve/differentiate/integrate.",
33
35
  solve_constraints: "Z3 satisfiability. variables maps names to Int/Real/Bool. constraints use arithmetic, comparisons, and/or/not, And/Or/Not/If/Implies/Distinct. Returns sat/model with checks, unsat, or unknown; no claims of optimum.",
34
- query_data: "DuckDB SELECT over supplied in-memory tables. columns maps names to BIGINT/DOUBLE/VARCHAR/BOOLEAN/DECIMAL(p,s); rows are ordered arrays. Decimal/large integer values use strings. No files/network/extensions; max 1000 output rows.",
36
+ query_data: "Execute DuckDB SQL SELECT on in-memory tables. Use named row objects, or arrays with explicit columnOrder matching their value order (required for multiple columns). columns maps names to BIGINT/DOUBLE/VARCHAR/BOOLEAN/DECIMAL(p,s). Decimal/large integers use strings. expectedRows checks typed results; rowOrder ordered(default) or unordered preserves duplicates. Examples do not prove general correctness. No files/network/extensions; max1000 output rows.",
35
37
  transform_data: "Polars transforms supplied JSON rows through select/sort/head/filter/aggregate steps. aggregate uses by columns and {column,function,alias}; filter uses column/comparison/value. No files or code execution; max 1000 output rows.",
36
38
  };
37
39
  const pythonPackages = { symbolic_math: ["sympy", "1.14.0"], solve_constraints: ["z3-solver", "5.3.3.0"], query_data: ["duckdb", "2.0.0"], transform_data: ["polars", "2.1.0"] };
@@ -62,7 +64,7 @@ async function execute(name, args, context, options) {
62
64
  const script = path.join(root, python ? "worker.py" : "worker.cjs");
63
65
  await fs.writeFile(script, source, { mode: 0o600 });
64
66
  await fs.writeFile(path.join(root, "input.json"), payload, { mode: 0o600 });
65
- const result = await createIsolatedExecutor({ network: false, readOnlyRuntimeRoots: python ? [runtime] : [] })(python ? path.join(runtime, "bin", "python") : process.execPath, python ? ["-I", "-B", script] : ["--max-old-space-size=128", script], { workspaceRoot: root, signal: context.signal, allowedWritePaths: [], shellTimeoutMs: 7000, shellMaxOutputBytes: 128000 });
67
+ const result = await createIsolatedExecutor({ network: false, readOnlyRuntimeRoots: python ? [runtime] : [] })(python ? path.join(runtime, "bin", "python") : process.execPath, python ? ["-I", "-B", script] : ["--max-old-space-size=128", script], { workspaceRoot: root, signal: context.signal, allowedWritePaths: [], shellTimeoutMs: python ? 15000 : 7000, shellMaxOutputBytes: 128000 });
66
68
  const observation = result.data;
67
69
  if (observation.truncated)
68
70
  throw new ToolExecutionError("tool_execution_failed", "Deterministic output exceeded the limit");
@@ -72,6 +74,18 @@ async function execute(name, args, context, options) {
72
74
  const [library, version] = (python ? pythonPackages : nodePackages)[name];
73
75
  if (data.library !== library || data.version !== version)
74
76
  throw new ToolExecutionError("tool_execution_failed", "Tool runtime version does not match the pinned contract");
77
+ const input = args;
78
+ if (name === "query_data" && input.expectedRows !== undefined) {
79
+ if (!Array.isArray(data.rows))
80
+ throw new ToolExecutionError("tool_execution_failed", "Query runtime did not return rows for validation");
81
+ const actual = data.rows.map(row => JSON.stringify(row)), expected = input.expectedRows.map(row => JSON.stringify(row));
82
+ if (input.rowOrder === "unordered") {
83
+ actual.sort();
84
+ expected.sort();
85
+ }
86
+ data.validation = { passed: JSON.stringify(actual) === JSON.stringify(expected), comparison: input.rowOrder ?? "ordered",
87
+ expectedCount: expected.length, actualCount: actual.length, scope: "provided examples only; no type coercion" };
88
+ }
75
89
  const receipt = { inputSha256: createHash("sha256").update(payload).digest("hex"), workerSha256: createHash("sha256").update(source).digest("hex"), elapsedMs: Date.now() - started,
76
90
  isolation: "offline, ephemeral input only", ...data };
77
91
  return { output: JSON.stringify(receipt), data: receipt };
@@ -146,14 +146,29 @@ def query(a):
146
146
  table_name = name(table["name"])
147
147
  columns = table["columns"]
148
148
  require(isinstance(columns, dict) and 1 <= len(columns) <= 32, "Use 1..32 typed columns")
149
+ column_order = table.get("columnOrder", list(columns))
150
+ require(isinstance(column_order, list) and all(isinstance(key, str) for key in column_order)
151
+ and len(column_order) == len(columns) and set(column_order) == set(columns),
152
+ "columnOrder must name each column exactly once")
153
+ rows = table["rows"]
154
+ require(isinstance(rows, list) and len(rows) <= 2000, "Use at most 2000 table rows")
155
+ if rows and all(isinstance(row, dict) for row in rows):
156
+ require(all(set(row) == set(columns) for row in rows), "Named rows must contain exactly the declared column names")
157
+ rows = [[row[key] for key in column_order] for row in rows]
158
+ else:
159
+ require(all(isinstance(row, list) and len(row) == len(columns) for row in rows),
160
+ "Use either named row objects or equal-width row arrays; do not mix them")
161
+ require(not rows or len(columns) == 1 or "columnOrder" in table,
162
+ "Multi-column array rows require columnOrder matching their value order; alternatively use named row objects")
163
+ require(all(value is None or isinstance(value, (str, int, float, bool)) for row in rows for value in row),
164
+ "Table cells must be strings, numbers, booleans or null")
149
165
  definitions = []
150
- for key, value in columns.items():
166
+ for key in column_order:
167
+ value = columns[key]
151
168
  name(key)
152
169
  require(isinstance(value, str) and re.fullmatch(r"(?:VARCHAR|BIGINT|DOUBLE|BOOLEAN|DECIMAL\((?:[1-9]|[12][0-9]|3[0-8]),(?:[0-9]|[12][0-9]|3[0-8])\))", value), "Unsupported column type")
153
170
  definitions.append('"' + key + '" ' + value)
154
171
  connection.execute('CREATE TABLE "' + table_name + '" (' + ','.join(definitions) + ')')
155
- rows = table["rows"]
156
- require(isinstance(rows, list) and len(rows) <= 2000 and all(isinstance(row, list) and len(row) == len(columns) for row in rows), "Invalid table rows")
157
172
  if rows: connection.executemany('INSERT INTO "' + table_name + '" VALUES (' + ','.join('?' for _ in columns) + ')', rows)
158
173
  sql = a["sql"]
159
174
  require(isinstance(sql, str) and 0 < len(sql) <= 8000, "SQL length out of range")
@@ -1 +1 @@
1
- {"version":3,"file":"DocdexCatalogTools.d.ts","sourceRoot":"","sources":["../../../src/tools/docdex/DocdexCatalogTools.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAG1E,eAAO,MAAM,wBAAwB,GAAI,QAAQ,YAAY,EAAE,UAAU,WAAW,CAAC,MAAM,CAAC,KAAG,cAAc,EAiC3G,CAAC"}
1
+ {"version":3,"file":"DocdexCatalogTools.d.ts","sourceRoot":"","sources":["../../../src/tools/docdex/DocdexCatalogTools.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAG1E,eAAO,MAAM,wBAAwB,GAAI,QAAQ,YAAY,EAAE,UAAU,WAAW,CAAC,MAAM,CAAC,KAAG,cAAc,EAmC3G,CAAC"}
@@ -26,8 +26,9 @@ export const createDocdexCatalogTools = (client, existing) => docdexCatalog.filt
26
26
  args.allow_sensitive = false;
27
27
  if (entry.name === "docdex_conversation_hook")
28
28
  args.wait_for_processing = true;
29
+ // The shared daemon owns delegation routing and fallback policy. Never
30
+ // override it with the removed private inference bridge or model input.
29
31
  if (entry.name === "docdex_local_completion") {
30
- args.agent = "model:configured-docdex-helper";
31
32
  args.mode = "draft_only";
32
33
  args.max_tokens = Math.min(2048, Number(args.max_tokens) || 1024);
33
34
  }
@@ -419,8 +419,16 @@ const docdexToolDefinitions = (client, options) => [
419
419
  handler: async (args) => {
420
420
  const { docId, path, window, textOnly, startLine, endLine, head, clamp } = args;
421
421
  if (path) {
422
- const result = await client.openFile(path, { startLine, endLine, head, clamp: clamp ?? true });
423
- return toOutput(result);
422
+ try {
423
+ const result = await client.openFile(path, { startLine, endLine, head, clamp: clamp ?? true });
424
+ return toOutput(result);
425
+ }
426
+ catch (error) {
427
+ if (error instanceof Error && /^internal error$/i.test(error.message.trim())) {
428
+ throw new Error(`Docdex could not read ${path}: internal error. Check this path with stat_path before retrying. If absent, do not repeat the read; if present, check Docdex index health or use read_file. This failure does not prove the file is missing.`);
429
+ }
430
+ throw error;
431
+ }
424
432
  }
425
433
  if (!docId) {
426
434
  throw new Error("docdex_open requires either docId or path");
@@ -1 +1 @@
1
- {"version":3,"file":"FileTools.d.ts","sourceRoot":"","sources":["../../../src/tools/filesystem/FileTools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA8EnE,eAAO,MAAM,eAAe,QAAO,cAAc,EAkGhD,CAAC"}
1
+ {"version":3,"file":"FileTools.d.ts","sourceRoot":"","sources":["../../../src/tools/filesystem/FileTools.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA2FnE,eAAO,MAAM,eAAe,QAAO,cAAc,EA8HhD,CAAC"}
@@ -1,5 +1,28 @@
1
1
  import { promises as fs, realpathSync } from "node:fs";
2
2
  import path from "node:path";
3
+ import { createHash } from "node:crypto";
4
+ import { isWithinScope } from "../../session/WorkspaceScope.js";
5
+ // Resolve every replacement against the same original file before writing any
6
+ // bytes. Batched patches retain one fresh read/analysis boundary.
7
+ function applyExactEdits(current, edits) {
8
+ const ranges = edits.map(edit => {
9
+ if (!edit.search.length)
10
+ throw new Error("Patch search must not be empty");
11
+ const start = current.indexOf(edit.search);
12
+ if (start < 0)
13
+ throw new Error("Patch search not found; read the current file before retrying");
14
+ if (current.indexOf(edit.search, start + 1) >= 0)
15
+ throw new Error("Patch search is ambiguous; include more surrounding text");
16
+ return { start, end: start + edit.search.length, content: edit.content };
17
+ }).sort((a, b) => a.start - b.start);
18
+ for (let i = 1; i < ranges.length; i++) {
19
+ if (ranges[i].start < ranges[i - 1].end)
20
+ throw new Error("Patch searches overlap; combine them into one replacement");
21
+ }
22
+ for (const edit of ranges.reverse())
23
+ current = current.slice(0, edit.start) + edit.content + current.slice(edit.end);
24
+ return current;
25
+ }
3
26
  const resolveWorkspacePath = async (context, targetPath) => {
4
27
  const resolved = path.resolve(context.workspaceRoot, targetPath);
5
28
  if (context.allowOutsideWorkspace) {
@@ -41,17 +64,12 @@ const normalizeScope = (value) => {
41
64
  }
42
65
  return normalized;
43
66
  };
44
- const isWithinScope = (relativePath, scope) => {
45
- if (scope === ".")
46
- return true;
47
- return relativePath === scope || relativePath.startsWith(`${scope}/`);
48
- };
49
67
  const assertPathScope = (context, resolvedPath, scopes, action) => {
50
68
  if (!scopes?.length)
51
69
  return;
52
70
  const relativePath = normalizeScope(toRelative(context, resolvedPath));
53
71
  const normalizedScopes = scopes.map(normalizeScope);
54
- if (!normalizedScopes.some((scope) => isWithinScope(relativePath, scope))) {
72
+ if (!isWithinScope(relativePath, normalizedScopes)) {
55
73
  throw new Error(`Path is outside allowed ${action} scopes`);
56
74
  }
57
75
  };
@@ -70,6 +88,20 @@ const listFilesRecursive = async (basePath, maxDepth, currentDepth = 0, entries
70
88
  };
71
89
  export const createFileTools = () => {
72
90
  return [
91
+ {
92
+ name: "create_directory", description: "Create a workspace directory and missing parents before using it as a shell writePaths mount. Existing directories are unchanged; files are never replaced.",
93
+ readOnly: false, capability: "workspace",
94
+ inputSchema: { type: "object", required: ["path"], additionalProperties: false,
95
+ properties: { path: { type: "string", minLength: 1, maxLength: 4096 } } },
96
+ handler: async (args, context) => {
97
+ context.signal?.throwIfAborted();
98
+ const resolved = await resolveWorkspacePath(context, args.path);
99
+ assertPathScope(context, resolved, context.allowedWritePaths, "write");
100
+ await context.checkPath?.(resolved, "write");
101
+ await fs.mkdir(resolved, { recursive: true });
102
+ return { output: `Created directory ${toRelative(context, resolved)}` };
103
+ },
104
+ },
73
105
  {
74
106
  name: "read_file",
75
107
  description: "Read a text file from the workspace.",
@@ -93,28 +125,43 @@ export const createFileTools = () => {
93
125
  },
94
126
  {
95
127
  name: "write_file",
96
- description: "Write content to a file inside the workspace.",
128
+ description: "Write a file with content, patch one unique search with content, or supply edits:[{search,content}] for multiple nonoverlapping replacements against the same original file. Combine same-file patches in one call after prepare_edit; all matches are validated before writing.",
97
129
  readOnly: false,
98
130
  capability: "workspace",
99
131
  inputSchema: {
100
132
  type: "object",
101
- required: ["path", "content"],
133
+ required: ["path"],
102
134
  properties: {
103
135
  path: { type: "string" },
104
136
  content: { type: "string" },
137
+ search: { type: "string", minLength: 1, description: "Exact unique old text to replace; omit only when writing the entire file." },
138
+ edits: { type: "array", minItems: 1, maxItems: 20, items: { type: "object", required: ["search", "content"], additionalProperties: false,
139
+ properties: { search: { type: "string", minLength: 1 }, content: { type: "string" } } } },
105
140
  },
106
141
  },
107
142
  handler: async (args, context) => {
108
- const { path: target, content } = args;
143
+ const { path: target, content, search, edits } = args;
144
+ if (edits !== undefined ? content !== undefined || search !== undefined || !Array.isArray(edits) || !edits.length || edits.length > 20
145
+ || edits.some(edit => !edit || typeof edit.search !== "string" || !edit.search.length || typeof edit.content !== "string")
146
+ : typeof content !== "string")
147
+ throw new Error("Supply either content (and optional search), or edits; do not combine these forms");
109
148
  const resolved = await resolveWorkspacePath(context, target);
110
149
  assertPathScope(context, resolved, context.allowedWritePaths, "write");
111
150
  await context.checkPath?.(resolved, "write");
151
+ let nextContent = content;
152
+ if (search !== undefined || edits !== undefined) {
153
+ assertPathScope(context, resolved, context.allowedReadPaths, "read");
154
+ await context.checkPath?.(resolved, "read");
155
+ const current = await fs.readFile(resolved, "utf8");
156
+ nextContent = applyExactEdits(current, edits ?? [{ search: search, content: content }]);
157
+ }
112
158
  await fs.mkdir(path.dirname(resolved), { recursive: true });
113
- await fs.writeFile(resolved, content, "utf8");
159
+ await fs.writeFile(resolved, nextContent, "utf8");
114
160
  if (context.recordTouchedFile) {
115
161
  context.recordTouchedFile(toRelative(context, resolved));
116
162
  }
117
- return { output: `Wrote ${toRelative(context, resolved)}` };
163
+ return { output: `${search === undefined && edits === undefined ? "Wrote" : "Patched"} ${toRelative(context, resolved)}`,
164
+ data: { path: toRelative(context, resolved), contentHash: createHash("sha256").update(nextContent, "utf8").digest("hex") } };
118
165
  },
119
166
  },
120
167
  {
@@ -9,6 +9,10 @@ export interface ProcessEnvironment {
9
9
  XDG_CACHE_HOME?: string;
10
10
  PYTHONPYCACHEPREFIX?: string;
11
11
  PYTHONUSERBASE?: string;
12
+ NPM_CONFIG_CACHE?: string;
13
+ GRADLE_USER_HOME?: string;
14
+ PIP_CACHE_DIR?: string;
15
+ UV_CACHE_DIR?: string;
12
16
  SDKROOT?: string;
13
17
  DEVELOPER_DIR?: string;
14
18
  GIT_CONFIG_NOSYSTEM?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"AsyncProcess.d.ts","sourceRoot":"","sources":["../../../src/tools/shell/AsyncProcess.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAG/F,eAAO,MAAM,sBAAsB,QAAO,MAAM,CAAC,UAGhD,CAAC;AAEF,kFAAkF;AAClF,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACpG,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IACzC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACtF;AAED,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,MAAM,MAAM,EAAE,EAAE,SAAS,WAAW,EAAE,cAAa,kBAAuB,KAAG,OAAO,CAAC,iBAAiB,CAgDjJ,CAAC"}
1
+ {"version":3,"file":"AsyncProcess.d.ts","sourceRoot":"","sources":["../../../src/tools/shell/AsyncProcess.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAG/F,eAAO,MAAM,sBAAsB,QAAO,MAAM,CAAC,UAGhD,CAAC;AAEF,kFAAkF;AAClF,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACpG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IACpG,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IACzC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACtF;AASD,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,MAAM,MAAM,EAAE,EAAE,SAAS,WAAW,EAAE,cAAa,kBAAuB,KAAG,OAAO,CAAC,iBAAiB,CAgDjJ,CAAC"}
@@ -4,6 +4,12 @@ import { ToolExecutionError } from "../ToolTypes.js";
4
4
  import { resolveShellWorkingDirectory } from "./ShellWorkingDirectory.js";
5
5
  export const safeProcessEnvironment = () => Object.fromEntries(["PATH", "LANG", "LC_ALL", "LC_CTYPE", "TERM", "TZ", "TMPDIR", "SYSTEMROOT", "WINDIR", "COMSPEC", "PATHEXT"]
6
6
  .filter(key => process.env[key] !== undefined).map(key => [key, process.env[key]]));
7
+ // Failed commands are rendered from error.message by native tool loops. Preserve
8
+ // both streams there, not only in details that those loops may never expose.
9
+ const processFailureMessage = (reason, stdout, stderr) => {
10
+ const excerpt = (value) => value.length <= 3000 ? value : `${value.slice(0, 1400)}\n[diagnostic excerpt truncated]\n${value.slice(-1500)}`;
11
+ return [reason, stdout && `stdout:\n${excerpt(stdout)}`, stderr && `stderr:\n${excerpt(stderr)}`].filter(Boolean).join("\n\n");
12
+ };
7
13
  export const runProcess = (command, args, context, environment = {}) => {
8
14
  context.signal?.throwIfAborted();
9
15
  const timeoutMs = context.shellTimeoutMs ?? 120000;
@@ -14,7 +20,7 @@ export const runProcess = (command, args, context, environment = {}) => {
14
20
  return new Promise((resolve, reject) => {
15
21
  const group = process.platform !== "win32";
16
22
  const env = safeProcessEnvironment();
17
- for (const key of ["HOME", "TMPDIR", "PATH", "CARGO_HOME", "XDG_CACHE_HOME", "PYTHONPYCACHEPREFIX", "PYTHONUSERBASE", "SDKROOT", "DEVELOPER_DIR", "GIT_CONFIG_NOSYSTEM", "GIT_CONFIG_GLOBAL", "GIT_ATTR_NOSYSTEM"])
23
+ for (const key of ["HOME", "TMPDIR", "PATH", "CARGO_HOME", "XDG_CACHE_HOME", "PYTHONPYCACHEPREFIX", "PYTHONUSERBASE", "NPM_CONFIG_CACHE", "GRADLE_USER_HOME", "PIP_CACHE_DIR", "UV_CACHE_DIR", "SDKROOT", "DEVELOPER_DIR", "GIT_CONFIG_NOSYSTEM", "GIT_CONFIG_GLOBAL", "GIT_ATTR_NOSYSTEM"])
18
24
  if (typeof environment[key] === "string")
19
25
  env[key] = environment[key];
20
26
  const child = spawn(command, args, { cwd, env, detached: group, stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
@@ -81,11 +87,11 @@ export const runProcess = (command, args, context, environment = {}) => {
81
87
  return;
82
88
  }
83
89
  if (timedOut) {
84
- reject(new ToolExecutionError("tool_timeout", "Process deadline exceeded", { retryable: false, details }));
90
+ reject(new ToolExecutionError("tool_timeout", processFailureMessage("Process deadline exceeded", stdout, stderr), { retryable: false, details }));
85
91
  return;
86
92
  }
87
93
  if (exitCode !== 0 || signal) {
88
- reject(new ToolExecutionError("tool_execution_failed", stderr || stdout || `Process terminated (${signal ?? exitCode})`, { retryable: false, details }));
94
+ reject(new ToolExecutionError("tool_execution_failed", processFailureMessage(`Process terminated (${signal ?? exitCode})`, stdout, stderr), { retryable: false, details }));
89
95
  return;
90
96
  }
91
97
  resolve({ output: (stdout || stderr) + (truncated ? "\n[output truncated]" : ""), data: details });
@@ -1 +1 @@
1
- {"version":3,"file":"HostToolchain.d.ts","sourceRoot":"","sources":["../../../src/tools/shell/HostToolchain.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAAG,YAAY,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;CAAE;AAC/E,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACnD,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/D,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1D;AAkID;;kFAEkF;AAClF,eAAO,MAAM,qBAAqB,GAAI,eAAe,MAAM,EAAE,mBAAmC,KAAG,WAAW,EAqE7G,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,UAAU,WAAW,EAAE,KAAG,gBAAgB,EAM5E,CAAC"}
1
+ {"version":3,"file":"HostToolchain.d.ts","sourceRoot":"","sources":["../../../src/tools/shell/HostToolchain.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAAG,YAAY,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;CAAE;AAC/E,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACnD,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/D,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1D;AAmID;;kFAEkF;AAClF,eAAO,MAAM,qBAAqB,GAAI,eAAe,MAAM,EAAE,mBAAmC,KAAG,WAAW,EAkF7G,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,UAAU,WAAW,EAAE,KAAG,gBAAgB,EAM5E,CAAC"}
@@ -20,6 +20,7 @@ const executableBinary = (file) => {
20
20
  return ["7f454c46", "feedface", "feedfacf", "cefaedfe", "cffaedfe", "cafebabe", "bebafeca", "cafebabf", "bfbafeca"].includes(bytes.toString("hex"));
21
21
  };
22
22
  const rustTools = new Set(["cargo", "rustc", "rustdoc"]);
23
+ const browserTools = ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"];
23
24
  /** Resolve a rustup proxy without executing it or consulting repository overrides.
24
25
  * Only an already-installed, host-selected toolchain can become a runtime mount. */
25
26
  const resolveRustProxy = (name, executable, home) => {
@@ -167,7 +168,7 @@ export const discoverHostToolchain = (workspaceRoot, searchPath = process.env.PA
167
168
  const workspace = realpathSync.native(workspaceRoot);
168
169
  const home = realpathSync.native(os.homedir());
169
170
  const result = darwinDeveloperTools(workspace, home);
170
- for (const name of ["node", "npm", "pnpm", "yarn", "bun", "python3", "python", "rustc", "cargo", "rustdoc", "cc", "ar"]) {
171
+ for (const name of ["node", "npm", "pnpm", "yarn", "bun", "python3", "python", "rustc", "cargo", "rustdoc", "cc", "ar", "rg", ...browserTools]) {
171
172
  if (result.some(runtime => runtime.name === name))
172
173
  continue;
173
174
  const candidates = name === "node" ? [process.execPath] : searchPath.split(path.delimiter).filter(Boolean).map(directory => path.resolve(directory, name));
@@ -198,6 +199,23 @@ export const discoverHostToolchain = (workspaceRoot, searchPath = process.env.PA
198
199
  result.push(pythonAlias({ name, executable, readOnlyRoot: executable, directory: false }));
199
200
  break;
200
201
  }
202
+ if (browserTools.includes(name)) {
203
+ // Debian Chrome launchers resolve outside /usr. Mount only the known
204
+ // installation bundle, never /opt, alternatives, or a browser profile.
205
+ // The private PATH alias points straight at the canonical launcher.
206
+ const bundle = path.dirname(executable);
207
+ if (process.platform !== "linux" || !["/opt/google/chrome", "/opt/google/chrome-beta", "/opt/google/chrome-unstable"].includes(bundle))
208
+ continue;
209
+ if ([bundle, path.dirname(bundle), "/opt"].some(directory => { const stat = statSync(directory); return stat.uid !== 0 || (stat.mode & 0o022) !== 0; }))
210
+ continue;
211
+ if (!["chrome", "resources.pak", "icudtl.dat"].every(file => {
212
+ const target = realpathSync.native(path.join(bundle, file));
213
+ return within(target, bundle) && statSync(target).isFile();
214
+ }) || !executableBinary(path.join(bundle, "chrome")))
215
+ continue;
216
+ result.push({ name, executable, readOnlyRoot: bundle, directory: true });
217
+ break;
218
+ }
201
219
  if (rustTools.has(name) || name === "python" || name === "python3") {
202
220
  const runtime = languageRuntime(name, executable, workspace, home);
203
221
  if (runtime) {
@@ -6,11 +6,12 @@ export interface ExecutorStatus {
6
6
  reason?: string;
7
7
  }
8
8
  /** All paths have been canonicalized by the host, before launching the sandbox. */
9
- export declare const darwinSandboxProfile: (root: string, scratch: string, writePaths: string[], runtimes: HostRuntime[], network?: boolean, runtimeRoots?: string[]) => string;
9
+ export declare const darwinSandboxProfile: (root: string, scratch: string, writePaths: string[], runtimes: HostRuntime[], network?: boolean, runtimeRoots?: string[], protectedPaths?: string[], cacheRoot?: string) => string;
10
10
  export declare const executorStatus: () => ExecutorStatus;
11
11
  export declare const createIsolatedExecutor: (options?: {
12
12
  network?: boolean;
13
- status?: ExecutorStatus; /** Trusted installed libraries only; never model arguments. */
13
+ status?: ExecutorStatus; /** Host-owned disposable cache; never model arguments. */
14
+ cacheRoot?: string; /** Trusted installed libraries only; never model arguments. */
14
15
  readOnlyRuntimeRoots?: string[];
15
16
  }) => ((command: string, args: string[], context: ToolContext) => Promise<ToolHandlerResult>);
16
17
  //# sourceMappingURL=IsolatedExecutor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IsolatedExecutor.d.ts","sourceRoot":"","sources":["../../../src/tools/shell/IsolatedExecutor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAA6C,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjG,MAAM,WAAW,cAAc;IAAG,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,YAAY,GAAG,cAAc,GAAG,aAAa,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAAE;AAEhI,mFAAmF;AACnF,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,EAAE,SAAS,MAAM,EAAE,YAAY,MAAM,EAAE,EAAE,UAAU,WAAW,EAAE,EAAE,iBAAe,EAAE,eAAc,MAAM,EAAO,KAAG,MA+BjK,CAAC;AAoBF,eAAO,MAAM,cAAc,QAAO,cAcjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,UAAS;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC,+DAA+D;IAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,KAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,iBAAiB,CAAC,CA2D5R,CAAC"}
1
+ {"version":3,"file":"IsolatedExecutor.d.ts","sourceRoot":"","sources":["../../../src/tools/shell/IsolatedExecutor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAA6C,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjG,MAAM,WAAW,cAAc;IAAG,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,YAAY,GAAG,cAAc,GAAG,aAAa,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAAE;AAEhI,mFAAmF;AACnF,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,EAAE,SAAS,MAAM,EAAE,YAAY,MAAM,EAAE,EAAE,UAAU,WAAW,EAAE,EAAE,iBAAe,EAAE,eAAc,MAAM,EAAO,EAAE,iBAAgB,MAAM,EAAO,EAAE,YAAY,MAAM,KAAG,MAiCpN,CAAC;AA0BF,eAAO,MAAM,cAAc,QAAO,cAcjC,CAAC;AAuBF,eAAO,MAAM,sBAAsB,GAAI,UAAS;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC,0DAA0D;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC,+DAA+D;IAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,KAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAkF3W,CAAC"}