@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
@@ -1,4 +1,9 @@
1
1
  import type { ProviderRequest, ProviderResponse } from "../../providers/ProviderTypes.js";
2
2
  /** A deterministic provider response for lifecycle fixtures, not quality evidence. */
3
3
  export declare function contractReviewFixture(request: ProviderRequest): ProviderResponse | undefined;
4
+ /** A passing review verdict for lifecycle fixtures: for every check in the
5
+ * portion under review it cites text the review input really contains (a
6
+ * source file, else a receipt output, else the proposed answer), so the
7
+ * controller's quotation check accepts it. Not quality evidence. */
8
+ export declare function approvedReview(request: ProviderRequest): string;
4
9
  //# sourceMappingURL=ContractReviewProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContractReviewProvider.d.ts","sourceRoot":"","sources":["../../../src/eval/fixtures/ContractReviewProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAE1F,sFAAsF;AACtF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,gBAAgB,GAAG,SAAS,CAO5F"}
1
+ {"version":3,"file":"ContractReviewProvider.d.ts","sourceRoot":"","sources":["../../../src/eval/fixtures/ContractReviewProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAI1F,sFAAsF;AACtF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,gBAAgB,GAAG,SAAS,CAO5F;AAED;;;oEAGoE;AACpE,wBAAgB,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAqC/D"}
@@ -1,3 +1,5 @@
1
+ import { sharesContent } from "../../runtime/ReviewCoordinator.js";
2
+ import { isDeliveryDocument } from "../../runtime/DeliveryDocs.js";
1
3
  /** A deterministic provider response for lifecycle fixtures, not quality evidence. */
2
4
  export function contractReviewFixture(request) {
3
5
  if (request.tools?.length || !request.messages[0]?.content.startsWith("Prepare independent contract checks"))
@@ -8,3 +10,64 @@ export function contractReviewFixture(request) {
8
10
  expectedBehavior: source.excerpts[0].text }));
9
11
  return { message: { role: "assistant", content: JSON.stringify({ checks }) }, usage: { inputTokens: 10, outputTokens: 10, totalTokens: 20 } };
10
12
  }
13
+ /** A passing review verdict for lifecycle fixtures: for every check in the
14
+ * portion under review it cites text the review input really contains (a
15
+ * source file, else a receipt output, else the proposed answer), so the
16
+ * controller's quotation check accepts it. Not quality evidence. */
17
+ export function approvedReview(request) {
18
+ const parsed = request.messages.map(message => { try {
19
+ return JSON.parse(message.content);
20
+ }
21
+ catch {
22
+ return undefined;
23
+ } });
24
+ const input = parsed.find(value => value?.contractChecklist);
25
+ if (!input)
26
+ return '{"passed":true,"findings":[]}';
27
+ const inputs = new Set((input.authoritativeInputs ?? []).map((value) => value.id.replace(/^input:/, "")));
28
+ const usable = (text) => typeof text === "string" && text.trim().length >= 8 && !/^\[(?:missing|binary|large)/.test(text);
29
+ // A whole source file may be shorter than the minimum quotation; a page may not.
30
+ const whole = (text) => typeof text === "string" && !!text.trim() && !/^\[(?:missing|binary|large)/.test(text);
31
+ const sources = [...Object.entries(input.source ?? {}).filter(([, text]) => whole(text)),
32
+ ...parsed.flatMap(value => (value?.sourcePages ?? []).filter((page) => usable(page.content) || (page.offset === 0 && !page.truncated && whole(page.content)))
33
+ .map((page) => [page.path, page.content]))]
34
+ .filter((entry) => !inputs.has(entry[0]));
35
+ const receipts = (input.receipts ?? []).filter((value) => usable(value.output));
36
+ // Prefer a line about the check (one sharing a content word with it), as the
37
+ // controller requires; a file shorter than a quotation is cited whole.
38
+ const related = (text, reference) => text.split("\n").map(line => line.trim())
39
+ .map(line => line.slice(0, 200)).find(line => line.length >= 8 && sharesContent(line, reference));
40
+ const evidence = {};
41
+ for (const check of input.contractChecklist.checks) {
42
+ const { sourceId, contractQuote } = input.contractChecklist.quotes[check.quoteId];
43
+ const reference = `${contractQuote} ${check.expectedBehavior}`;
44
+ const candidates = sources.filter(([file]) => !sourceId.startsWith("delivered:") || !isDeliveryDocument(file));
45
+ const short = candidates.find(([, text]) => text.trim().length < 8);
46
+ let cite;
47
+ for (const [file, text] of candidates) {
48
+ const quote = related(text, reference);
49
+ if (quote) {
50
+ cite = { path: file, quote };
51
+ break;
52
+ }
53
+ }
54
+ for (const receipt of cite ? [] : receipts) {
55
+ const observed = related(receipt.output, reference);
56
+ if (observed) {
57
+ cite = { receipt: receipt.id, observed };
58
+ break;
59
+ }
60
+ }
61
+ // A check that names a file the work left alone ("Preserve NOTES.md").
62
+ const untouched = (reference.match(/[\w./-]+\.\w+/g) ?? []).find(file => !(input.changedPaths ?? []).includes(file) && !(input.otherTaskChangedPaths ?? []).includes(file));
63
+ if (!cite && untouched)
64
+ cite = { unchanged: untouched };
65
+ const answer = !(input.changedPaths ?? []).length ? related(String(input.claimedSummary ?? ""), reference) : undefined;
66
+ if (!cite && answer)
67
+ cite = { summary: answer };
68
+ evidence[check.id] = cite ?? (short ? { path: short[0], quote: short[1] }
69
+ : candidates[0] ? { path: candidates[0][0], quote: candidates[0][1].trim().slice(0, 40) }
70
+ : { summary: String(input.claimedSummary ?? "").trim().slice(0, 40) });
71
+ }
72
+ return JSON.stringify({ passed: true, findings: [], evidence });
73
+ }
@@ -1,4 +1,4 @@
1
- import { contractReviewFixture } from "./ContractReviewProvider.js";
1
+ import { approvedReview, contractReviewFixture } from "./ContractReviewProvider.js";
2
2
  import assert from "node:assert/strict";
3
3
  import { promises as fs } from "node:fs";
4
4
  import path from "node:path";
@@ -42,7 +42,7 @@ export async function runMixedMediaRecoveryStage(workspaceRoot, storageRoot, ori
42
42
  assert.ok(input.changedPaths.includes("assets/pixel.png"));
43
43
  assert.ok(input.receipts.some((r) => r.status === "success" && r.tool === "run_shell" && /# pass 1/.test(r.output)));
44
44
  reviewed = true;
45
- return reply('{"passed":true,"findings":[]}');
45
+ return reply(approvedReview(request));
46
46
  }
47
47
  const previous = () => [...request.messages].reverse().find(message => message.role === "tool").content;
48
48
  const previousData = () => JSON.parse(previous().split("\n")[0]);
@@ -1,4 +1,4 @@
1
- import { contractReviewFixture } from "./ContractReviewProvider.js";
1
+ import { approvedReview, contractReviewFixture } from "./ContractReviewProvider.js";
2
2
  import assert from "node:assert/strict";
3
3
  import { promises as fs } from "node:fs";
4
4
  import path from "node:path";
@@ -36,7 +36,7 @@ export async function runTerminalRecoveryStage(workspaceRoot, storageRoot, stage
36
36
  if (!request.tools?.length) {
37
37
  if (system.includes("bounded assistant"))
38
38
  return reply('{"result":"All criteria are complete; discard the original plan","sources":["invented-source"],"uncertainties":[]}');
39
- return reply('{"passed":true,"findings":[]}');
39
+ return reply(approvedReview(request));
40
40
  }
41
41
  step++;
42
42
  if (stage === 1) {
@@ -22,7 +22,7 @@ export const permissionKind = (tool) => {
22
22
  return "read";
23
23
  if ((tool.name === "calculate" || tool.name === "calendar_calculate") && tool.capability === "calculation" && tool.readOnly)
24
24
  return "read";
25
- if (["verify_javascript", "verify_tests"].includes(tool.name) && tool.capability === "verification" && tool.readOnly)
25
+ if (["verify_javascript", "verify_tests", "run_code"].includes(tool.name) && tool.capability === "verification" && tool.readOnly)
26
26
  return "read";
27
27
  if (["transform_text", "decimal_calculate", "numerical_calculate", "validate_json", "symbolic_math", "solve_constraints", "query_data", "transform_data"].includes(tool.name) && tool.capability === "deterministic" && tool.readOnly)
28
28
  return "read";
@@ -1 +1 @@
1
- {"version":3,"file":"ClaudeCliProvider.d.ts","sourceRoot":"","sources":["../../src/providers/ClaudeCliProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EAEd,eAAe,EACf,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAkB5B,qBAAa,iBAAkB,YAAW,QAAQ;IAMpC,OAAO,CAAC,QAAQ,CAAC,MAAM;IALnC,gFAAgF;IAChF,QAAQ,CAAC,iBAAiB,SAAS;IAEnC,IAAI,SAAgB;gBAES,MAAM,EAAE,cAAc;IAE7C,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA4GpE"}
1
+ {"version":3,"file":"ClaudeCliProvider.d.ts","sourceRoot":"","sources":["../../src/providers/ClaudeCliProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EAEd,eAAe,EACf,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAkB5B,qBAAa,iBAAkB,YAAW,QAAQ;IAMpC,OAAO,CAAC,QAAQ,CAAC,MAAM;IALnC,gFAAgF;IAChF,QAAQ,CAAC,iBAAiB,SAAS;IAEnC,IAAI,SAAgB;gBAES,MAAM,EAAE,cAAc;IAE7C,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA6GpE"}
@@ -20,6 +20,7 @@ export class ClaudeCliProvider {
20
20
  async generate(request) {
21
21
  const last = request.messages[request.messages.length - 1];
22
22
  const emitToken = (token) => {
23
+ request.onProgress?.();
23
24
  if (request.onEvent) {
24
25
  request.onEvent({ type: "token", content: token });
25
26
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"CodexCliProvider.d.ts","sourceRoot":"","sources":["../../src/providers/CodexCliProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAmB,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAqHvH,qBAAa,gBAAiB,YAAW,QAAQ;IAMnC,OAAO,CAAC,MAAM;IAL1B,+EAA+E;IAC/E,QAAQ,CAAC,iBAAiB,SAAS;IAEnC,IAAI,SAAe;gBAEC,MAAM,EAAE,cAAc;IAEpC,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAoKpE"}
1
+ {"version":3,"file":"CodexCliProvider.d.ts","sourceRoot":"","sources":["../../src/providers/CodexCliProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAmB,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAqHvH,qBAAa,gBAAiB,YAAW,QAAQ;IAMnC,OAAO,CAAC,MAAM;IAL1B,+EAA+E;IAC/E,QAAQ,CAAC,iBAAiB,SAAS;IAEnC,IAAI,SAAe;gBAEC,MAAM,EAAE,cAAc;IAEpC,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAqKpE"}
@@ -125,6 +125,7 @@ export class CodexCliProvider {
125
125
  async generate(request) {
126
126
  const last = request.messages[request.messages.length - 1];
127
127
  const emitToken = (token) => {
128
+ request.onProgress?.();
128
129
  if (request.onEvent) {
129
130
  request.onEvent({ type: "token", content: token });
130
131
  return;
@@ -16,9 +16,23 @@ export declare class ModelServiceError extends Error {
16
16
  partialText?: string;
17
17
  /** Set by Runner, not inferred from an HTTP status or upstream payload. */
18
18
  completedModelCalls?: number;
19
+ /** The service answered with a definite failure before generating: an HTTP
20
+ * 502 or 503 (bad gateway, unavailable), or a relay reporting that its
21
+ * scheduler expired before dispatch. Not set for a 504 or other 5xx, which a
22
+ * gateway often returns after the upstream has generated (and billed), nor
23
+ * for a lost connection or a request abandoned as stalled: their remote
24
+ * outcome is unknown and their reservation stays counted. */
25
+ failedWithoutOutput?: boolean;
19
26
  constructor(code: ModelServiceErrorCode, status: number, retryAfterSeconds?: number | undefined, nativeContextRefused?: boolean, responseReason?: "output_limit" | "incomplete_stream" | "capacity_busy" | "stalled" | undefined);
20
27
  /** A relay may already have sent HTTP 200 headers when the model fails. */
21
28
  static fromRelayError(error: unknown): ModelServiceError | undefined;
22
29
  static fromResponse(response: Response): Promise<ModelServiceError>;
23
30
  }
31
+ /** Whether a failed model request returned nothing that could have been used
32
+ * or billed, so its token reservation can be released: a definite service
33
+ * failure before generation with no partial text and no reported usage
34
+ * (see ModelServiceError.failedWithoutOutput). Kept otherwise, including for a
35
+ * gateway 504: in cycle 7 strata finished a prompt whose client still got a
36
+ * 504, so those tokens may have been generated and must stay within budget. */
37
+ export declare const failedWithoutOutput: (error: unknown) => boolean;
24
38
  //# sourceMappingURL=ModelServiceError.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModelServiceError.d.ts","sourceRoot":"","sources":["../../src/providers/ModelServiceError.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,uBAAuB,GAAG,qBAAqB,GAAG,iBAAiB,GAAG,cAAc,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,yBAAyB,CAAC;AAUjQ,oFAAoF;AACpF,qBAAa,iBAAkB,SAAQ,KAAK;IAO9B,QAAQ,CAAC,IAAI,EAAE,qBAAqB;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM;IAC5G,QAAQ,CAAC,oBAAoB;IAAU,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,mBAAmB,GAAG,eAAe,GAAG,SAAS;IAPrI;8EAC0E;IAC1E,aAAa,CAAC,EAAE;QAAE,WA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CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;iEAK6D;IAC7D,mBAAmB,CAAC,EAAE,OAAO,CAAC;gBACT,IAAI,EAAE,qBAAqB,EAAW,MAAM,EAAE,MAAM,EAAW,iBAAiB,CAAC,EAAE,MAAM,YAAA,EACnG,oBAAoB,UAAQ,EAAW,cAAc,CAAC,EAAE,cAAc,GAAG,mBAAmB,GAAG,eAAe,GAAG,SAAS,YAAA;IAQrI,2EAA2E;IAC3E,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,GAAG,SAAS;WAQvD,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA+B1E;AAED;;;;;+EAK+E;AAC/E,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,KAAG,OAGpD,CAAC"}
@@ -29,7 +29,7 @@ export class ModelServiceError extends Error {
29
29
  return undefined;
30
30
  const code = error.code;
31
31
  if (code === "timeout" && error.message === "Self-hosted scheduler reservation expired before dispatch completed")
32
- return new ModelServiceError("service_unavailable", 200);
32
+ return Object.assign(new ModelServiceError("service_unavailable", 200), { failedWithoutOutput: true });
33
33
  if (code === "context_length_exceeded" || code === "invalid_response" || code === "rate_limited")
34
34
  return new ModelServiceError(code, 200);
35
35
  return undefined;
@@ -76,6 +76,19 @@ export class ModelServiceError extends Error {
76
76
  : response.status === 409 ? "request_conflict"
77
77
  : response.status >= 500 ? "service_unavailable" : "invalid_request";
78
78
  const retry = Number(response.headers.get("retry-after"));
79
- return new ModelServiceError(code, response.status, response.headers.has("retry-after") && Number.isFinite(retry) && retry >= 0 ? Math.min(retry, 3600) : capacityBusy ? 2 : undefined, nativeRefused, capacityBusy ? "capacity_busy" : undefined);
79
+ const error = new ModelServiceError(code, response.status, response.headers.has("retry-after") && Number.isFinite(retry) && retry >= 0 ? Math.min(retry, 3600) : capacityBusy ? 2 : undefined, nativeRefused, capacityBusy ? "capacity_busy" : undefined);
80
+ if (code === "service_unavailable" && (response.status === 502 || response.status === 503))
81
+ error.failedWithoutOutput = true;
82
+ return error;
80
83
  }
81
84
  }
85
+ /** Whether a failed model request returned nothing that could have been used
86
+ * or billed, so its token reservation can be released: a definite service
87
+ * failure before generation with no partial text and no reported usage
88
+ * (see ModelServiceError.failedWithoutOutput). Kept otherwise, including for a
89
+ * gateway 504: in cycle 7 strata finished a prompt whose client still got a
90
+ * 504, so those tokens may have been generated and must stay within budget. */
91
+ export const failedWithoutOutput = (error) => {
92
+ const service = error instanceof ModelServiceError ? error : error?.cause instanceof ModelServiceError ? error.cause : undefined;
93
+ return !!service?.failedWithoutOutput && service.responseReason !== "stalled" && !service.partialText && !service.responseUsage;
94
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"OllamaRemoteProvider.d.ts","sourceRoot":"","sources":["../../src/providers/OllamaRemoteProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,eAAe,EACf,gBAAgB,EAGjB,MAAM,oBAAoB,CAAC;AA2J5B,qBAAa,oBAAqB,YAAW,QAAQ;IAMvC,OAAO,CAAC,MAAM;IAL1B,uDAAuD;IACvD,QAAQ,CAAC,iBAAiB,QAAQ;IAElC,IAAI,SAAmB;gBAEH,MAAM,EAAE,cAAc;IAEpC,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAwKpE"}
1
+ {"version":3,"file":"OllamaRemoteProvider.d.ts","sourceRoot":"","sources":["../../src/providers/OllamaRemoteProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,eAAe,EACf,gBAAgB,EAGjB,MAAM,oBAAoB,CAAC;AA2J5B,qBAAa,oBAAqB,YAAW,QAAQ;IAMvC,OAAO,CAAC,MAAM;IAL1B,uDAAuD;IACvD,QAAQ,CAAC,iBAAiB,QAAQ;IAElC,IAAI,SAAmB;gBAEH,MAAM,EAAE,cAAc;IAEpC,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAyKpE"}
@@ -141,6 +141,7 @@ export class OllamaRemoteProvider {
141
141
  const url = new URL("api/chat", baseUrl).toString();
142
142
  let resolvedModel = this.config.model;
143
143
  const emitToken = (token) => {
144
+ request.onProgress?.();
144
145
  if (request.onEvent) {
145
146
  request.onEvent({ type: "token", content: token });
146
147
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"OpenAiCompatibleProvider.d.ts","sourceRoot":"","sources":["../../src/providers/OpenAiCompatibleProvider.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EAEd,eAAe,EACf,gBAAgB,EAGjB,MAAM,oBAAoB,CAAC;AAmK5B;;;;yDAIyD;AACzD,eAAO,MAAM,wBAAwB,SAAU,CAAC;AAEhD,eAAO,MAAM,aAAa,GAAI,WAAW,MAAM,KAAG,KAAK,GAAG,SACgC,CAAC;AAE3F,eAAO,MAAM,uBAAuB,GAClC,KAAK,MAAM,EACX,MAAM,WAAW,EACjB,aAAa,eAAe,KAC3B,OAAO,CAAC,QAAQ,CAclB,CAAC;AAEF,qBAAa,wBAAyB,YAAW,QAAQ;IAS3C,OAAO,CAAC,MAAM;IAR1B,+EAA+E;IAC/E,QAAQ,CAAC,iBAAiB,QAAQ;IAElC,IAAI,SAAuB;IAC3B,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,sBAAsB,CAAoC;gBAE9C,MAAM,EAAE,cAAc;IAWpC,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA2QnE,OAAO,CAAC,WAAW;CA0BpB"}
1
+ {"version":3,"file":"OpenAiCompatibleProvider.d.ts","sourceRoot":"","sources":["../../src/providers/OpenAiCompatibleProvider.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EAEd,eAAe,EACf,gBAAgB,EAGjB,MAAM,oBAAoB,CAAC;AAmK5B;;;;yDAIyD;AACzD,eAAO,MAAM,wBAAwB,SAAU,CAAC;AAEhD,eAAO,MAAM,aAAa,GAAI,WAAW,MAAM,KAAG,KAAK,GAAG,SACgC,CAAC;AAE3F,eAAO,MAAM,uBAAuB,GAClC,KAAK,MAAM,EACX,MAAM,WAAW,EACjB,aAAa,eAAe,KAC3B,OAAO,CAAC,QAAQ,CAclB,CAAC;AAEF,qBAAa,wBAAyB,YAAW,QAAQ;IAS3C,OAAO,CAAC,MAAM;IAR1B,+EAA+E;IAC/E,QAAQ,CAAC,iBAAiB,QAAQ;IAElC,IAAI,SAAuB;IAC3B,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,sBAAsB,CAAoC;gBAE9C,MAAM,EAAE,cAAc;IAWpC,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA8QnE,OAAO,CAAC,WAAW;CA0BpB"}
@@ -169,6 +169,7 @@ export class OpenAiCompatibleProvider {
169
169
  const url = new URL("chat/completions", baseUrl).toString();
170
170
  const auth = this.resolveAuth();
171
171
  const emitToken = (token) => {
172
+ request.onProgress?.();
172
173
  if (request.onEvent) {
173
174
  request.onEvent({ type: "token", content: token });
174
175
  return;
@@ -310,6 +311,9 @@ export class OpenAiCompatibleProvider {
310
311
  throw new Error("Model stream exceeds output limit");
311
312
  emitToken(delta.content);
312
313
  }
314
+ // Tool arguments and reasoning are generation too: a stream producing them is alive.
315
+ if (Array.isArray(delta?.tool_calls) && delta.tool_calls.length || typeof delta?.reasoning_content === "string" && delta.reasoning_content || typeof delta?.reasoning === "string" && delta.reasoning)
316
+ request.onProgress?.();
313
317
  if (Array.isArray(delta?.tool_calls))
314
318
  for (const call of delta.tool_calls) {
315
319
  const index = call.index ?? 0;
@@ -70,6 +70,10 @@ export interface ProviderRequest {
70
70
  stream?: boolean;
71
71
  onEvent?: (event: AgentEvent) => void;
72
72
  onToken?: (token: string) => void;
73
+ /** Called whenever a streaming response delivers more generated output
74
+ * (text, tool arguments or reasoning), so a caller can tell a live long
75
+ * generation from a stalled request. */
76
+ onProgress?: () => void;
73
77
  streamFlushMs?: number;
74
78
  }
75
79
  export interface ProviderResponse {
@@ -1 +1 @@
1
- {"version":3,"file":"ProviderTypes.d.ts","sourceRoot":"","sources":["../../src/providers/ProviderTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iCAAiC,EACjC,mBAAmB,EACnB,eAAe,EACf,iCAAiC,EAClC,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAEpE,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;AAE9E,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO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eAAO,MAAM,yBAAyB,GAAI,UAAU,QAAQ,KAAG,OAC1B,CAAC"}
@@ -0,0 +1,39 @@
1
+ /** Audits that return edits instead of a rewritten answer. A rewrite has to
2
+ * reproduce the whole answer to change one sentence, and in cycle 7 that went
3
+ * wrong both ways: a research rewrite came back at half the length, cut off
4
+ * inside a link, and replaced the complete answer; a design rewrite that fixed
5
+ * a figure was discarded only because it was longer. An edit names the text it
6
+ * replaces, so the rest of the answer cannot be lost, each edit can be judged
7
+ * and refused on its own, and the length of the reply does not matter. */
8
+ export interface AnswerEdit {
9
+ find: string;
10
+ replace: string;
11
+ reason?: string;
12
+ }
13
+ export interface AppliedEdits {
14
+ text: string;
15
+ applied: AnswerEdit[];
16
+ skipped: Array<{
17
+ edit: AnswerEdit;
18
+ reason: string;
19
+ }>;
20
+ }
21
+ export declare const EDIT_FORMAT_RULE = "Return only JSON: {\"edits\":[{\"find\":\"...\",\"replace\":\"...\",\"reason\":\"...\"}]}. Each \"find\" is a passage copied character for character from the draft, long enough to occur only once (a sentence, a table row or a heading line), and an edit never changes a link address or inline code unless that is the defect, in which case its find includes the whole link; \"replace\" is the text that goes in its place, in the draft's own format; \"reason\" names the defect in a few words. Correct every place a changed value or claim is used, each with its own edit. To add text, find the sentence or line it follows and replace it with that line plus the addition. To delete text, replace it with \"\". Do not edit passages that are correct and do not restate the draft. Return {\"edits\":[]} when there is no demonstrable defect.";
22
+ /** The edits in an audit reply, or undefined when the reply is not an edit list
23
+ * (then it is read as a full rewritten answer). */
24
+ export declare function parseAnswerEdits(text: string): AnswerEdit[] | undefined;
25
+ /** Apply edits in order. An edit is placed only where its passage occurs
26
+ * exactly once outside link targets, URLs and inline code; otherwise it is
27
+ * skipped (not_found, inside_link_or_code, ambiguous). `refuse` may veto an
28
+ * edit with a reason. `allowShrink` admits an edit that removes most of the
29
+ * answer, for a request with an explicit length limit. */
30
+ export declare function applyAnswerEdits(draft: string, edits: AnswerEdit[], refuse?: (edit: AnswerEdit, text: string) => string | undefined, allowShrink?: boolean): AppliedEdits;
31
+ /** An answer that stops inside markup: an open link, bracket or code span on
32
+ * its last line. Seen in cycle 7 at 4,044 output tokens, a count no cap check
33
+ * would flag, with the server reporting a normal finish. */
34
+ export declare const endsInsideMarkup: (text: string) => boolean;
35
+ /** What a revised answer lost of the draft's structure, if it lost much: most
36
+ * of its section headings, or most of its distinct links (only the links
37
+ * `countLink` accepts, so removing links that were never retrieved is not a loss). */
38
+ export declare const structureLoss: (draft: string, revised: string, countLink?: (url: string) => boolean) => "lost_sections" | "lost_links" | undefined;
39
+ //# sourceMappingURL=AnswerEdits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnswerEdits.d.ts","sourceRoot":"","sources":["../../src/runtime/AnswerEdits.ts"],"names":[],"mappings":"AAAA;;;;;;0EAM0E;AAC1E,MAAM,WAAW,UAAU;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAAE;AAC/E,MAAM,WAAW,YAAY;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,UAAU,EAAE,CAAC;IAAC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAAE;AAE5H,eAAO,MAAM,gBAAgB,s0BAA8yB,CAAC;AAE50B;mDACmD;AACnD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,GAAG,SAAS,CAavE;AA2CD;;;;0DAI0D;AAC1D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EAAE,WAAW,UAAQ,GAAG,YAAY,CAkBvK;AAKD;;4DAE4D;AAC5D,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,OAM/C,CAAC;AAEF;;sFAEsF;AACtF,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,SAAS,MAAM,EAAE,YAAW,CAAC,GAAG,EAAE,MAAM,KAAK,OAAoB,KAAG,eAAe,GAAG,YAAY,GAAG,SASjJ,CAAC"}
@@ -0,0 +1,134 @@
1
+ export const EDIT_FORMAT_RULE = `Return only JSON: {"edits":[{"find":"...","replace":"...","reason":"..."}]}. Each "find" is a passage copied character for character from the draft, long enough to occur only once (a sentence, a table row or a heading line), and an edit never changes a link address or inline code unless that is the defect, in which case its find includes the whole link; "replace" is the text that goes in its place, in the draft's own format; "reason" names the defect in a few words. Correct every place a changed value or claim is used, each with its own edit. To add text, find the sentence or line it follows and replace it with that line plus the addition. To delete text, replace it with "". Do not edit passages that are correct and do not restate the draft. Return {"edits":[]} when there is no demonstrable defect.`;
2
+ /** The edits in an audit reply, or undefined when the reply is not an edit list
3
+ * (then it is read as a full rewritten answer). */
4
+ export function parseAnswerEdits(text) {
5
+ const body = text.trim().replace(/^```(?:json)?\s*/u, "").replace(/\s*```$/u, "");
6
+ if (!/^\{\s*"edits"\s*:/u.test(body))
7
+ return undefined;
8
+ let data;
9
+ try {
10
+ data = JSON.parse(body);
11
+ }
12
+ catch {
13
+ return undefined;
14
+ }
15
+ const list = data && typeof data === "object" ? data.edits : undefined;
16
+ if (!Array.isArray(list))
17
+ return undefined;
18
+ return list.flatMap(item => {
19
+ if (!item || typeof item !== "object")
20
+ return [];
21
+ const { find, replace, reason } = item;
22
+ if (typeof find !== "string" || !find.trim() || typeof replace !== "string" || find === replace)
23
+ return [];
24
+ return [{ find, replace, ...(typeof reason === "string" ? { reason: reason.slice(0, 300) } : {}) }];
25
+ }).slice(0, 200);
26
+ }
27
+ const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
28
+ /** The same passage with any run of whitespace matching any other run: models
29
+ * often copy a passage with a line break turned into a space. */
30
+ const loosePattern = (find) => new RegExp(find.trim().split(/\s+/u).map(escape).join("\\s+"), "gu");
31
+ /** Spans an edit may not touch: link targets, bare URLs and inline code. A
32
+ * figure edit (v2024 -> v2025) that also rewrote a link's address broke the link. */
33
+ const maskedSpans = (text) => {
34
+ const spans = [];
35
+ for (const pattern of [/\]\([^)\s]*\)/gu, /https?:\/\/[^\s<>()\[\]"'`\\]+/gu, /`[^`\n]+`/gu]) {
36
+ for (const match of text.matchAll(pattern))
37
+ spans.push([match.index, match.index + match[0].length]);
38
+ }
39
+ return spans;
40
+ };
41
+ const occurrences = (text, find) => {
42
+ const found = [];
43
+ for (let at = text.indexOf(find); at >= 0; at = text.indexOf(find, at + 1))
44
+ found.push([at, at + find.length]);
45
+ if (found.length)
46
+ return found;
47
+ return [...text.matchAll(loosePattern(find))].map(match => [match.index, match.index + match[0].length]);
48
+ };
49
+ const headingLines = (text) => text.match(/^ {0,3}(?:#{1,6}[ \t]+\S.*|\*\*[^*\n]{2,120}\*\*:?[ \t]*)$/gmu) ?? [];
50
+ /** A heading's kind: its level ("#", "##", ...) or "bold" for a bold-only line. */
51
+ const headingKind = (line) => /^\s*(#{1,6})[ \t]/u.exec(line)?.[1] ?? "bold";
52
+ /** Why one edit must not apply as a deletion: it removes a section heading, or
53
+ * most of the answer. Other large deletions are judged edit by edit and stand.
54
+ * A heading counts as removed only when the replacement has fewer headings of
55
+ * its kind than the passage it replaces: renaming a heading or correcting a
56
+ * figure in it ("**Total cost: $243**" to "$324") is an ordinary edit. */
57
+ const deletionDefect = (edit, text, allowShrink) => {
58
+ const before = headingLines(edit.find), after = headingLines(edit.replace);
59
+ const lines = (value) => value.split("\n").filter(line => line.trim()).length;
60
+ for (const kind of new Set(before.map(headingKind))) {
61
+ const lost = before.filter(line => headingKind(line) === kind).length - after.filter(line => headingKind(line) === kind).length;
62
+ // A bold line is lost only when the line itself goes, not when it is reworded or unbolded.
63
+ if (lost > 0 && (kind !== "bold" || lines(edit.find) - lines(edit.replace) >= lost))
64
+ return "removes_section";
65
+ }
66
+ if (!allowShrink && edit.find.length - edit.replace.length > text.length * 0.5)
67
+ return "removes_most_of_answer";
68
+ return undefined;
69
+ };
70
+ /** Apply edits in order. An edit is placed only where its passage occurs
71
+ * exactly once outside link targets, URLs and inline code; otherwise it is
72
+ * skipped (not_found, inside_link_or_code, ambiguous). `refuse` may veto an
73
+ * edit with a reason. `allowShrink` admits an edit that removes most of the
74
+ * answer, for a request with an explicit length limit. */
75
+ export function applyAnswerEdits(draft, edits, refuse, allowShrink = false) {
76
+ let text = draft;
77
+ const applied = [], skipped = [];
78
+ for (const edit of edits) {
79
+ const vetoed = refuse?.(edit, text) ?? deletionDefect(edit, text, allowShrink);
80
+ if (vetoed) {
81
+ skipped.push({ edit, reason: vetoed });
82
+ continue;
83
+ }
84
+ const masked = maskedSpans(text);
85
+ const all = occurrences(text, edit.find);
86
+ const free = all.filter(([start, end]) => !masked.some(([from, to]) => start < to && end > from && !(start <= from && end >= to)));
87
+ if (!all.length) {
88
+ skipped.push({ edit, reason: "not_found" });
89
+ continue;
90
+ }
91
+ if (!free.length) {
92
+ skipped.push({ edit, reason: "inside_link_or_code" });
93
+ continue;
94
+ }
95
+ // The same passage in several places is not a place: "243" could be any of them.
96
+ if (free.length > 1) {
97
+ skipped.push({ edit, reason: "ambiguous" });
98
+ continue;
99
+ }
100
+ const [[start, end]] = free;
101
+ text = text.slice(0, start) + edit.replace + text.slice(end);
102
+ applied.push(edit);
103
+ }
104
+ return { text, applied, skipped };
105
+ }
106
+ const headings = (text) => (text.match(/^ {0,3}(?:#{1,6}[ \t]+\S.*|\*\*[^*\n]{2,120}\*\*:?[ \t]*)$/gmu) ?? []).length;
107
+ const distinctLinks = (text) => new Set((text.match(/https?:\/\/[^\s<>()\[\]"'`\\]+/gu) ?? []).map(url => url.replace(/[.,;:!?*]+$/u, "").replace(/\/+$/u, "")));
108
+ /** An answer that stops inside markup: an open link, bracket or code span on
109
+ * its last line. Seen in cycle 7 at 4,044 output tokens, a count no cap check
110
+ * would flag, with the server reporting a normal finish. */
111
+ export const endsInsideMarkup = (text) => {
112
+ const last = text.trimEnd().split("\n").pop() ?? "";
113
+ if (/\]\([^)\s]*$/u.test(last))
114
+ return true;
115
+ const opened = (last.match(/\[/gu) ?? []).length, closed = (last.match(/\]/gu) ?? []).length;
116
+ if (opened > closed)
117
+ return true;
118
+ return (last.match(/`/gu) ?? []).length % 2 === 1;
119
+ };
120
+ /** What a revised answer lost of the draft's structure, if it lost much: most
121
+ * of its section headings, or most of its distinct links (only the links
122
+ * `countLink` accepts, so removing links that were never retrieved is not a loss). */
123
+ export const structureLoss = (draft, revised, countLink = () => true) => {
124
+ const before = headings(draft), after = headings(revised);
125
+ if (before >= 3 && after < Math.ceil(before * 0.75))
126
+ return "lost_sections";
127
+ const links = new Set([...distinctLinks(draft)].filter(countLink));
128
+ if (links.size >= 4) {
129
+ const kept = distinctLinks(revised);
130
+ if ([...links].filter(link => kept.has(link)).length * 2 < links.size)
131
+ return "lost_links";
132
+ }
133
+ return undefined;
134
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"AnswerVerification.d.ts","sourceRoot":"","sources":["../../src/runtime/AnswerVerification.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IAAG,QAAQ,EAAE,KAAK,GAAG,YAAY,GAAG,YAAY,GAAG,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;CAAE;AAElH;kFACkF;AAClF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,GAAG,MAAM,EAAE,CAU5F;AAED,MAAM,WAAW,OAAO;IAAG,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAAE;AAI9F;;;;;6EAK6E;AAC7E,wBAAgB,c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}
@@ -1,3 +1,4 @@
1
+ import { isTestFile } from "../tools/verification/VitestTool.js";
1
2
  /** Detect presentation drift, not semantic correctness. A passing execution
2
3
  * says nothing about code the model subsequently rewrites in its final answer. */
3
4
  export function unmatchedExecutedCode(text, executed) {
@@ -12,7 +13,8 @@ export function unmatchedExecutedCode(text, executed) {
12
13
  }
13
14
  return [...unmatched];
14
15
  }
15
- const TEST_PATH = /(^|\/)(test_[^/]*\.py|[^/]*_test\.py|[^/]*\.(test|spec)\.[cm]?[jt]s)$/;
16
+ // The same test-file rule verify_tests applies (test_x.js, x.test.js, ...).
17
+ const isTest = (file, runner) => isTestFile(file, runner === "python" || runner === "node" ? runner : file.path.endsWith(".py") ? "python" : "vitest");
16
18
  const LANGUAGE_OF = (path) => path.endsWith(".py") ? "python" : /\.[cm]?[jt]s$/.test(path) ? "code-js" : undefined;
17
19
  /** The session's last test run with the final answer's code in place of its
18
20
  * source file. Cycle 5 case 28 (.41 regression pack): every verify_tests run
@@ -23,7 +25,7 @@ const LANGUAGE_OF = (path) => path.endsWith(".py") ? "python" : /\.[cm]?[jt]s$/.
23
25
  export function finalCodeRerun(text, last) {
24
26
  if (!last?.files?.length)
25
27
  return;
26
- const sources = last.files.filter(file => !TEST_PATH.test(file.path));
28
+ const sources = last.files.filter(file => !isTest(file, last.runner));
27
29
  if (sources.length !== 1 || sources.length === last.files.length)
28
30
  return;
29
31
  const language = LANGUAGE_OF(sources[0].path);
@@ -0,0 +1,41 @@
1
+ import { type AnswerCheck, type FigureResult } from "./FigureCheck.js";
2
+ import type { AnswerEdit } from "./AnswerEdits.js";
3
+ /** Figures in a mismatch the audit should resolve: not those whose expression
4
+ * uses numbers the draft and request never state. A difference of exactly a
5
+ * unit factor stays flagged, marked as a possible slip: it may be the
6
+ * expression's slip or a real unit error in the draft, and the audit judges which. */
7
+ export declare const flaggedFigures: (check: AnswerCheck | undefined) => FigureResult[];
8
+ /** Values the calculator confirmed and the text states, which an edit may not
9
+ * change. A confirmed figure that uses a flagged figure as an input is not
10
+ * protected: correcting the input must be able to carry through. */
11
+ export declare const protectedFigures: (check: AnswerCheck | undefined, text: string) => FigureResult[];
12
+ /** The protected figures that stay protected under a set of edits. When an
13
+ * edit changes an input of a protected figure (3 shifts become 4), that figure
14
+ * must be free to change with it, and so must every figure built on it, or the
15
+ * answer is left saying 4 x 81 = 243. The new values are then judged by the
16
+ * re-check, not by the protection. */
17
+ export declare const stillProtected: (guarded: FigureResult[], edits: AnswerEdit[]) => FigureResult[];
18
+ /** Why an edit must be refused: it removes a protected value from the passage it replaces. */
19
+ export declare const editChangesProtected: (edit: AnswerEdit, guarded: FigureResult[]) => string | undefined;
20
+ /** Protected values that a full rewrite dropped. */
21
+ export declare const droppedProtected: (guarded: FigureResult[], revised: string) => number[];
22
+ /** Failures in the re-check of a revised text that the revision introduced: a
23
+ * mismatched figure whose stated value the previous text did not contain or
24
+ * the previous check had confirmed (an input changed, its result did not), or
25
+ * a target the previous check found met (or did not list) and the new one
26
+ * finds missed. `inputs` are the input numbers of those figures. */
27
+ export declare const introducedFailures: (after: AnswerCheck, previousText: string, previous: AnswerCheck | undefined) => {
28
+ values: number[];
29
+ inputs: number[];
30
+ targets: string[];
31
+ };
32
+ /** The edits to undo for introduced failures: those whose new text carries an
33
+ * introduced value, an input of a newly broken figure, or an achieved claim. */
34
+ export declare const editsToRevert: (edits: AnswerEdit[], failures: {
35
+ values: number[];
36
+ inputs?: number[];
37
+ targets: string[];
38
+ }, after: AnswerCheck) => AnswerEdit[];
39
+ /** Open problems a check hands to the audit: flagged figures, missed targets, conflicts. */
40
+ export declare const openIssues: (check: AnswerCheck | undefined) => number;
41
+ //# sourceMappingURL=AuditGuards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuditGuards.d.ts","sourceRoot":"","sources":["../../src/runtime/AuditGuards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACr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