@mcoda/mswarm 0.1.135-codali.42 → 0.1.135-codali.47

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 (92) hide show
  1. package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.d.ts +5 -0
  2. package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.d.ts.map +1 -1
  3. package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.js +63 -0
  4. package/dist/vendor/codali/eval/fixtures/MixedMediaRecoveryJourney.js +2 -2
  5. package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.js +2 -2
  6. package/dist/vendor/codali/permissions/PermissionGate.js +1 -1
  7. package/dist/vendor/codali/providers/ClaudeCliProvider.d.ts.map +1 -1
  8. package/dist/vendor/codali/providers/ClaudeCliProvider.js +1 -0
  9. package/dist/vendor/codali/providers/CodexCliProvider.d.ts.map +1 -1
  10. package/dist/vendor/codali/providers/CodexCliProvider.js +1 -0
  11. package/dist/vendor/codali/providers/ModelServiceError.d.ts +14 -0
  12. package/dist/vendor/codali/providers/ModelServiceError.d.ts.map +1 -1
  13. package/dist/vendor/codali/providers/ModelServiceError.js +15 -2
  14. package/dist/vendor/codali/providers/OllamaRemoteProvider.d.ts.map +1 -1
  15. package/dist/vendor/codali/providers/OllamaRemoteProvider.js +1 -0
  16. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
  17. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +4 -0
  18. package/dist/vendor/codali/providers/ProviderTypes.d.ts +4 -0
  19. package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -1
  20. package/dist/vendor/codali/runtime/AnswerEdits.d.ts +39 -0
  21. package/dist/vendor/codali/runtime/AnswerEdits.d.ts.map +1 -0
  22. package/dist/vendor/codali/runtime/AnswerEdits.js +134 -0
  23. package/dist/vendor/codali/runtime/AnswerVerification.d.ts.map +1 -1
  24. package/dist/vendor/codali/runtime/AnswerVerification.js +4 -2
  25. package/dist/vendor/codali/runtime/AuditGuards.d.ts +41 -0
  26. package/dist/vendor/codali/runtime/AuditGuards.d.ts.map +1 -0
  27. package/dist/vendor/codali/runtime/AuditGuards.js +81 -0
  28. package/dist/vendor/codali/runtime/CompletionReport.d.ts +4 -2
  29. package/dist/vendor/codali/runtime/CompletionReport.d.ts.map +1 -1
  30. package/dist/vendor/codali/runtime/CompletionReport.js +8 -3
  31. package/dist/vendor/codali/runtime/DeliveryDocs.d.ts +21 -0
  32. package/dist/vendor/codali/runtime/DeliveryDocs.d.ts.map +1 -0
  33. package/dist/vendor/codali/runtime/DeliveryDocs.js +148 -0
  34. package/dist/vendor/codali/runtime/FigureCheck.d.ts +61 -2
  35. package/dist/vendor/codali/runtime/FigureCheck.d.ts.map +1 -1
  36. package/dist/vendor/codali/runtime/FigureCheck.js +210 -14
  37. package/dist/vendor/codali/runtime/GatewayRequest.d.ts +13 -0
  38. package/dist/vendor/codali/runtime/GatewayRequest.d.ts.map +1 -1
  39. package/dist/vendor/codali/runtime/GatewayRequest.js +54 -1
  40. package/dist/vendor/codali/runtime/InspectionConvergence.d.ts +4 -0
  41. package/dist/vendor/codali/runtime/InspectionConvergence.d.ts.map +1 -1
  42. package/dist/vendor/codali/runtime/InspectionConvergence.js +24 -1
  43. package/dist/vendor/codali/runtime/NumericProvenance.d.ts +102 -0
  44. package/dist/vendor/codali/runtime/NumericProvenance.d.ts.map +1 -0
  45. package/dist/vendor/codali/runtime/NumericProvenance.js +411 -0
  46. package/dist/vendor/codali/runtime/OutageWait.d.ts +13 -0
  47. package/dist/vendor/codali/runtime/OutageWait.d.ts.map +1 -1
  48. package/dist/vendor/codali/runtime/OutageWait.js +13 -0
  49. package/dist/vendor/codali/runtime/ResearchEvidence.d.ts.map +1 -1
  50. package/dist/vendor/codali/runtime/ResearchEvidence.js +79 -3
  51. package/dist/vendor/codali/runtime/ReviewCoordinator.d.ts +22 -0
  52. package/dist/vendor/codali/runtime/ReviewCoordinator.d.ts.map +1 -1
  53. package/dist/vendor/codali/runtime/ReviewCoordinator.js +201 -24
  54. package/dist/vendor/codali/runtime/SessionController.d.ts +31 -22
  55. package/dist/vendor/codali/runtime/SessionController.d.ts.map +1 -1
  56. package/dist/vendor/codali/runtime/SessionController.js +592 -176
  57. package/dist/vendor/codali/runtime/StructuralEvidence.d.ts +10 -0
  58. package/dist/vendor/codali/runtime/StructuralEvidence.d.ts.map +1 -1
  59. package/dist/vendor/codali/runtime/StructuralEvidence.js +10 -0
  60. package/dist/vendor/codali/runtime/TaskReview.d.ts +10 -0
  61. package/dist/vendor/codali/runtime/TaskReview.d.ts.map +1 -1
  62. package/dist/vendor/codali/runtime/TaskReview.js +14 -1
  63. package/dist/vendor/codali/tools/ToolRegistry.d.ts.map +1 -1
  64. package/dist/vendor/codali/tools/ToolRegistry.js +11 -2
  65. package/dist/vendor/codali/tools/browser/BrowserWorker.js +142 -2
  66. package/dist/vendor/codali/tools/calculation/CalculatorTool.d.ts +1 -1
  67. package/dist/vendor/codali/tools/calculation/CalculatorTool.d.ts.map +1 -1
  68. package/dist/vendor/codali/tools/calculation/CalculatorTool.js +209 -41
  69. package/dist/vendor/codali/tools/deterministic/DeterministicTools.js +1 -1
  70. package/dist/vendor/codali/tools/deterministic/node-worker.cjs +10 -10
  71. package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts +2 -0
  72. package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts.map +1 -1
  73. package/dist/vendor/codali/tools/shell/AsyncProcess.js +32 -5
  74. package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts +29 -1
  75. package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts.map +1 -1
  76. package/dist/vendor/codali/tools/shell/IsolatedExecutor.js +169 -7
  77. package/dist/vendor/codali/tools/shell/ShellTool.js +1 -1
  78. package/dist/vendor/codali/tools/verification/CodeRunTool.d.ts +19 -0
  79. package/dist/vendor/codali/tools/verification/CodeRunTool.d.ts.map +1 -0
  80. package/dist/vendor/codali/tools/verification/CodeRunTool.js +104 -0
  81. package/dist/vendor/codali/tools/verification/JavaScriptVerificationTool.d.ts.map +1 -1
  82. package/dist/vendor/codali/tools/verification/JavaScriptVerificationTool.js +21 -10
  83. package/dist/vendor/codali/tools/verification/VitestTool.d.ts +27 -0
  84. package/dist/vendor/codali/tools/verification/VitestTool.d.ts.map +1 -1
  85. package/dist/vendor/codali/tools/verification/VitestTool.js +160 -16
  86. package/dist/vendor/config/deterministic/node-worker.mjs +15 -2
  87. package/dist/vendor/config/skills/code-implementation/SKILL.md +1 -1
  88. package/dist/vendor/config/skills/planning/SKILL.md +1 -1
  89. package/dist/vendor/config/skills/ui-ux-design/SKILL.md +1 -1
  90. package/dist/vendor/config/skills/webapp-testing/SKILL.md +2 -11
  91. package/dist/vendor/config/skills/webapp-testing/journey-driver.mjs +104 -3
  92. package/package.json +3 -3
@@ -6,6 +6,16 @@ export interface StructuralAnalysis {
6
6
  valid: boolean;
7
7
  }
8
8
  export declare const isSourcePath: (file: string) => boolean;
9
+ /**
10
+ * Build output (build/, dist/, out/, coverage/, framework caches, minified
11
+ * bundles, source maps) is produced from other files: nothing calls into it and
12
+ * a build replaces it wholesale. dist/, coverage/, .next/ and .nuxt/ are output
13
+ * at any depth (packages/web/dist/); build/ and out/ only at the root, since
14
+ * nested folders of those names often hold authored build scripts. This is a
15
+ * location rule only: SessionController never treats a Git-tracked file as
16
+ * generated.
17
+ */
18
+ export declare const isGeneratedOutput: (file: string) => boolean;
9
19
  /** Installed dependencies/toolchains are inventoried for isolation, not authored source. */
10
20
  export declare const isDependencyArtifact: (file: string) => boolean;
11
21
  export declare const workspaceRelativePath: (root: string, file: string) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"StructuralEvidence.d.ts","sourceRoot":"","sources":["../../src/runtime/StructuralEvidence.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,MAAM,WAAW,kBAAkB;IAC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./WorkspaceSnapshot.js";
4
4
  import { isWithinScope } from "../session/WorkspaceScope.js";
5
5
  export { isWithinScope } from "../session/WorkspaceScope.js";
6
6
  export const isSourcePath = (file) => /\.(?:[cm]?[jt]sx?|py|rs|go|java|kt|kts|c|cc|cpp|cxx|h|hpp|cs|rb|php|swift|sh|bash|lua|ex|exs|scala|sc|vue|svelte)$/i.test(file);
7
+ /**
8
+ * Build output (build/, dist/, out/, coverage/, framework caches, minified
9
+ * bundles, source maps) is produced from other files: nothing calls into it and
10
+ * a build replaces it wholesale. dist/, coverage/, .next/ and .nuxt/ are output
11
+ * at any depth (packages/web/dist/); build/ and out/ only at the root, since
12
+ * nested folders of those names often hold authored build scripts. This is a
13
+ * location rule only: SessionController never treats a Git-tracked file as
14
+ * generated.
15
+ */
16
+ export const isGeneratedOutput = (file) => /^(?:build|out)\/|(?:^|\/)(?:dist|coverage|\.next|\.nuxt)\//.test(file) || /\.min\.(?:js|css)$|\.map$/.test(file);
7
17
  /** Installed dependencies/toolchains are inventoried for isolation, not authored source. */
8
18
  export const isDependencyArtifact = (file) => file.split("/").some(part => ["node_modules", ".gradle", ".npm-cache", ".pnpm-store", ".toolchain"].includes(part));
9
19
  export const workspaceRelativePath = (root, file) => {
@@ -10,6 +10,12 @@ export interface ReviewSourcePage {
10
10
  export interface TaskReviewResult {
11
11
  passed: boolean;
12
12
  findings: string[];
13
+ /** Checks the portion budget left unreviewed (not rejected). */
14
+ unreviewed?: {
15
+ id: string;
16
+ sourceId: string;
17
+ expectedBehavior: string;
18
+ }[];
13
19
  }
14
20
  /** Read-only evidence requests share the caller's model budget and acceptance fence. */
15
21
  export declare function runTaskReview(options: {
@@ -21,5 +27,9 @@ export declare function runTaskReview(options: {
21
27
  maxInputChars: number;
22
28
  maxOutputTokens?: number;
23
29
  signal?: AbortSignal;
30
+ /** Checks an approval before it is accepted. Problems get one repair round,
31
+ * in which the reviewer may supply the missing evidence or reject; problems
32
+ * that remain become the review's findings. */
33
+ approve?: (verdict: Readonly<Record<string, unknown>>) => Promise<string[]>;
24
34
  }): Promise<TaskReviewResult>;
25
35
  //# sourceMappingURL=TaskReview.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TaskReview.d.ts","sourceRoot":"","sources":["../../src/runtime/TaskReview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAE/E,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAAG,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE;AAEzE,wFAAwF;AACxF,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAC3C,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,oBAAoB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC5E,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAsG5B"}
1
+ {"version":3,"file":"TaskReview.d.ts","sourceRoot":"","sources":["../../src/runtime/TaskReview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,+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;
9
9
  let repeatReminded = false;
10
+ let evidenceRepaired = false;
10
11
  // Four evidence rounds followed by a final decision. No execution tool or
11
12
  // permission widening is available. One received malformed JSON reply may be
12
13
  // repaired, still within the original contract, context and model-call budget.
13
- for (let call = 0; call < 6; call++) {
14
+ for (let call = 0; call < 7; call++) {
14
15
  options.signal?.throwIfAborted();
15
16
  if (JSON.stringify(messages).length > options.maxInputChars) {
16
17
  return reject("Required review evidence exceeds the configured model context. Split the task or select a larger compatible reviewer context; acceptance is not established.");
@@ -43,6 +44,18 @@ export async function runTaskReview(options) {
43
44
  if (typeof result.passed !== "boolean" || !Array.isArray(result.findings) || !result.findings.every(finding => typeof finding === "string")) {
44
45
  return reject("Review did not provide valid acceptance evidence.");
45
46
  }
47
+ if (result.passed === true && result.findings.length === 0 && options.approve) {
48
+ const problems = await options.approve(result);
49
+ if (problems.length) {
50
+ if (evidenceRepaired)
51
+ return { passed: false, findings: problems };
52
+ evidenceRepaired = true;
53
+ messages.push({ role: "assistant", content: response.message.content });
54
+ messages.push({ role: "user", content: JSON.stringify({ evidenceProblems: problems,
55
+ instruction: "The approval was not accepted: these checks lack verifiable evidence. For each one, cite evidence that exists exactly as quoted, or reject with a finding that names what is missing. Do not approve a check you cannot prove. Reply with the same verdict format, including evidence for every check in this portion." }) });
56
+ continue;
57
+ }
58
+ }
46
59
  return { passed: result.passed === true && result.findings.length === 0,
47
60
  findings: result.findings.length ? result.findings : result.passed ? [] : ["Review rejected acceptance without a specific finding."] };
48
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ToolRegistry.d.ts","sourceRoot":"","sources":["../../src/tools/ToolRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,cAAc,EAGnB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EAE1B,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM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K,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAwBrC,CAAC;AA2LF,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAqC;IAElD,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAOpC,IAAI,IAAI,cAAc,EAAE;IAIxB,wEAAwE;IACxE,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAE9B,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,aAAa,GAAG,aAAa,CAAC,CAAC;IAQ/E;;;;OAIG;IACH,OAAO,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,EAAE;IAOpD,2EAA2E;IAC3E,YAAY,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC,cAAc,EAAE,cAAc,EAAE,CAAC;IAaxE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAqE/F"}
@@ -430,8 +430,17 @@ export class ToolRegistry {
430
430
  error: normalizeExecutionError(error),
431
431
  };
432
432
  }
433
- // Persistence failures must stop the run, not silently acknowledge a side effect.
434
- await context.afterTool?.(toolDescriptorFor(tool), sanitized.value, execution);
433
+ // Persistence failures must stop the run, not silently acknowledge a side
434
+ // effect. A ToolExecutionError from the host's check of this call (a scope
435
+ // or workspace conflict) fails only this call; the model sees it.
436
+ try {
437
+ await context.afterTool?.(toolDescriptorFor(tool), sanitized.value, execution);
438
+ }
439
+ catch (error) {
440
+ if (!(error instanceof ToolExecutionError) || context.signal?.aborted)
441
+ throw error;
442
+ execution = { ok: false, output: "", error: normalizeExecutionError(error) };
443
+ }
435
444
  context.signal?.throwIfAborted();
436
445
  return execution;
437
446
  }
@@ -1,6 +1,18 @@
1
1
  import { chromium } from "playwright-core";
2
2
  // This process runs in a private empty directory with an explicit environment.
3
3
  // browser-use reads .env at import time, so never import it in the CLI process.
4
+ /** Below this many characters of readable text the page may still be rendering. */
5
+ const RENDER_MIN_CHARS = 200;
6
+ /** Upper bound on waiting for a script-built page, from the end of navigation. */
7
+ const RENDER_WAIT_MS = 10000;
8
+ const RENDER_NETWORK_IDLE_MS = 6000;
9
+ /** Text unchanged this long counts as rendered. */
10
+ const RENDER_STABLE_MS = 1200;
11
+ const RENDER_POLL_MS = 250;
12
+ const COLLAPSED_MARKER = "[Collapsed section, expanded for reading]";
13
+ /** Bounds on text revealed from collapsed sections, per section and per page. */
14
+ const COLLAPSED_PANEL_MAX_CHARS = 20000;
15
+ const COLLAPSED_PAGE_MAX_CHARS = 100000;
4
16
  process.once("message", async (input) => {
5
17
  let browser;
6
18
  let session;
@@ -53,6 +65,131 @@ process.once("message", async (input) => {
53
65
  await new Promise(resolve => setTimeout(resolve, 1000));
54
66
  }
55
67
  }
68
+ // Single-page applications (legislation portals, gazettes) are an empty
69
+ // shell at DOMContentLoaded and fill in after fetching their data, so an
70
+ // immediate read returned "empty" for pages that do have text. When the
71
+ // readable region is still short, wait for the network to settle and the
72
+ // text to stop growing, within a fixed bound. Pages with text proceed at once.
73
+ const readableChars = () => tab.evaluate(() => {
74
+ const main = document.querySelector('main,[role="main"]');
75
+ return ((main?.innerText.trim() ? main : document.body)?.innerText ?? "").trim().length;
76
+ }).catch(() => 0);
77
+ const notices = [];
78
+ const renderStarted = Date.now();
79
+ const initialChars = await readableChars();
80
+ if (initialChars < RENDER_MIN_CHARS) {
81
+ const deadline = renderStarted + RENDER_WAIT_MS;
82
+ await tab.waitForLoadState("networkidle", { timeout: Math.min(RENDER_NETWORK_IDLE_MS, RENDER_WAIT_MS) }).catch(() => undefined);
83
+ let last = await readableChars(), stableSince = Date.now();
84
+ while (Date.now() < deadline && Date.now() - stableSince < RENDER_STABLE_MS) {
85
+ await tab.waitForTimeout(RENDER_POLL_MS);
86
+ const current = await readableChars();
87
+ if (current !== last) {
88
+ last = current;
89
+ stableSince = Date.now();
90
+ }
91
+ }
92
+ if (last > initialChars)
93
+ notices.push(`The page builds its content with scripts; it was read after waiting ${Math.round((Date.now() - renderStarted) / 100) / 10} s for it to render.`);
94
+ }
95
+ // Collapsed sections (closed <details>, accordion panels and inactive tabs
96
+ // tied to their toggle by aria-controls) are part of the page a reader can
97
+ // open, but rendered text omits them: a country update read as its heading
98
+ // only. Reveal them in this disposable DOM without clicking anything, and
99
+ // mark the text so it is not mistaken for what the page shows by default.
100
+ // Content hidden for other reasons stays hidden.
101
+ // Only a section the reader could open is revealed: its toggle (summary or
102
+ // aria-controls button) must itself be visible, sized and on the page, and
103
+ // the panel must render once opened. A hidden toggle wired to a hidden panel
104
+ // is hidden text like any other and stays hidden. Revealed text is capped per
105
+ // section and per page so a page cannot flood the snapshot this way.
106
+ const expansion = await tab.evaluate(({ marker, panelMaxChars, pageMaxChars }) => {
107
+ let count = 0, skipped = 0, budget = pageMaxChars;
108
+ const visible = (element) => {
109
+ const box = element;
110
+ if (typeof box.checkVisibility === "function" && !box.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true, contentVisibilityAuto: true }))
111
+ return false;
112
+ // checkVisibility covers display/visibility/opacity on the element and its ancestors;
113
+ // also refuse zero-size and off-page placement and near-transparent ancestors.
114
+ const rect = box.getBoundingClientRect();
115
+ if (rect.width < 4 || rect.height < 4)
116
+ return false;
117
+ const left = rect.left + window.scrollX, top = rect.top + window.scrollY;
118
+ const doc = document.documentElement;
119
+ if (left + rect.width <= 0 || top + rect.height <= 0 || left >= Math.max(doc.scrollWidth, window.innerWidth) || top >= Math.max(doc.scrollHeight, window.innerHeight))
120
+ return false;
121
+ const own = getComputedStyle(box);
122
+ if (own.visibility !== "visible" || parseFloat(own.fontSize) < 4 && !box.getAttribute("aria-label"))
123
+ return false;
124
+ for (let node = box; node; node = node.parentElement)
125
+ if (Number(getComputedStyle(node).opacity) < 0.1)
126
+ return false;
127
+ return true;
128
+ };
129
+ const admit = (element) => {
130
+ const size = (element.textContent ?? "").length;
131
+ if (size > panelMaxChars || size > budget) {
132
+ skipped++;
133
+ return false;
134
+ }
135
+ budget -= size;
136
+ return true;
137
+ };
138
+ const mark = (element, after) => {
139
+ const note = document.createTextNode(`${marker} `);
140
+ if (after)
141
+ after.after(note);
142
+ else
143
+ element.prepend(note);
144
+ count++;
145
+ };
146
+ for (const details of Array.from(document.querySelectorAll("details:not([open])")).slice(0, 200)) {
147
+ const summary = details.querySelector(":scope > summary");
148
+ if (!visible(summary ?? details))
149
+ continue;
150
+ if (!admit(details))
151
+ continue;
152
+ details.setAttribute("open", "");
153
+ mark(details, summary);
154
+ }
155
+ const toggles = document.querySelectorAll('[aria-controls][aria-expanded="false"], [role="tab"][aria-controls][aria-selected="false"]');
156
+ for (const toggle of Array.from(toggles).slice(0, 200)) {
157
+ if (!visible(toggle))
158
+ continue;
159
+ for (const id of (toggle.getAttribute("aria-controls") ?? "").split(/\s+/).filter(Boolean).slice(0, 8)) {
160
+ const panel = document.getElementById(id);
161
+ if (!panel || panel.dataset.codaliExpanded)
162
+ continue;
163
+ if (!panel.hidden && getComputedStyle(panel).display !== "none")
164
+ continue;
165
+ if (!admit(panel))
166
+ continue;
167
+ const hiddenAttribute = panel.hasAttribute("hidden"), inlineDisplay = panel.style.getPropertyValue("display"), inlinePriority = panel.style.getPropertyPriority("display");
168
+ panel.removeAttribute("hidden");
169
+ if (getComputedStyle(panel).display === "none")
170
+ panel.style.setProperty("display", "block", "important");
171
+ panel.dataset.codaliExpanded = "1";
172
+ if (!visible(panel)) {
173
+ // Opened, it still would not render to a reader: put it back.
174
+ if (hiddenAttribute)
175
+ panel.setAttribute("hidden", "");
176
+ if (inlineDisplay)
177
+ panel.style.setProperty("display", inlineDisplay, inlinePriority);
178
+ else
179
+ panel.style.removeProperty("display");
180
+ budget += (panel.textContent ?? "").length;
181
+ continue;
182
+ }
183
+ mark(panel);
184
+ }
185
+ }
186
+ return { count, skipped };
187
+ }, { marker: COLLAPSED_MARKER, panelMaxChars: COLLAPSED_PANEL_MAX_CHARS, pageMaxChars: COLLAPSED_PAGE_MAX_CHARS }).catch(() => ({ count: 0, skipped: 0 }));
188
+ const expanded = expansion.count;
189
+ if (expanded)
190
+ notices.push(`${expanded} collapsed section${expanded === 1 ? " was" : "s were"} expanded for reading; ${expanded === 1 ? "its" : "their"} text starts with "${COLLAPSED_MARKER}".`);
191
+ if (expansion.skipped)
192
+ notices.push(`${expansion.skipped} collapsed section${expansion.skipped === 1 ? " was" : "s were"} left closed: over the size allowed for expanded text.`);
56
193
  // Accessibility snapshots otherwise flatten deleted/struck-through text
57
194
  // into apparently current prose. Mark revisions in this disposable DOM;
58
195
  // no page action, form submission or remote mutation is performed.
@@ -65,7 +202,10 @@ process.once("message", async (input) => {
65
202
  }
66
203
  });
67
204
  const main = tab.getByRole("main");
68
- const useMain = input.scope !== "page" && await main.count() > 0;
205
+ // A main landmark that stayed empty (the application renders elsewhere)
206
+ // would read as an empty page; read the body's rendered text instead.
207
+ const useMain = input.scope !== "page" && await main.count() > 0
208
+ && !!(await main.first().innerText({ timeout: 5000 }).catch(() => "")).trim();
69
209
  const root = useMain ? main.first() : tab.locator("body");
70
210
  let content;
71
211
  let format = "accessibility";
@@ -107,7 +247,7 @@ process.once("message", async (input) => {
107
247
  else
108
248
  content = await tab.ariaSnapshot({ mode: "default", depth: 20, timeout: 5000 });
109
249
  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 } };
250
+ format, content: content.slice(0, 1000000), truncated: content.length > 1000000, ...(notices.length ? { notice: notices.join(" ") } : {}) } };
111
251
  }
112
252
  catch (error) {
113
253
  reply = { ok: false, message: error instanceof Error ? error.message : String(error) };
@@ -13,7 +13,7 @@ export declare const evaluateCalculation: (expression: string, options?: Calcula
13
13
  * The models write multi-step arithmetic this way; refusing it cost a round
14
14
  * trip on about one calculator call in three. */
15
15
  export declare const evaluateCalculationScript: (script: string, options?: CalculationOptions) => {
16
- result: number;
16
+ result: number | number[];
17
17
  values: Record<string, number>;
18
18
  };
19
19
  export declare const createCalculatorTool: () => ToolDefinition;
@@ -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;AA4F1E,MAAM,WAAW,kBAAkB;IACjC,gFAAgF;IAChF,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,yGAAyG;AACzG,eAAO,MAAM,mBAAmB,GAAI,YAAY,MAAM,EAAE,UAAS,kBAAuB,KAAG,MAM1F,CAAC;AAmEF;;;;iDAIiD;AACjD,eAAO,MAAM,yBAAyB,GAAI,QAAQ,MAAM,EAAE,UAAS,kBAAuB,KAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAiC5I,CAAC;AAWF,eAAO,MAAM,oBAAoB,QAAO,cAuCtC,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;AAkJ1E,MAAM,WAAW,kBAAkB;IACjC,gFAAgF;IAChF,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,yGAAyG;AACzG,eAAO,MAAM,mBAAmB,GAAI,YAAY,MAAM,EAAE,UAAS,kBAAuB,KAAG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