@open-cr-agent/core 0.6.0 → 0.9.0

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 (222) hide show
  1. package/README.md +1 -1
  2. package/dist/agent/json.d.ts +0 -1
  3. package/dist/agent/json.js +0 -1
  4. package/dist/agent/model-call.d.ts +13 -0
  5. package/dist/agent/model-call.js +22 -0
  6. package/dist/agent/pool.d.ts +0 -1
  7. package/dist/agent/pool.js +0 -1
  8. package/dist/agent/settings.d.ts +9 -5
  9. package/dist/agent/settings.js +20 -8
  10. package/dist/agent/spend-limit.d.ts +18 -0
  11. package/dist/agent/spend-limit.js +53 -0
  12. package/dist/agent/usage.d.ts +0 -1
  13. package/dist/agent/usage.js +0 -1
  14. package/dist/anchor/anchor.d.ts +0 -1
  15. package/dist/anchor/anchor.js +0 -1
  16. package/dist/anchor/match.d.ts +0 -1
  17. package/dist/anchor/match.js +0 -1
  18. package/dist/anchor/relocate.d.ts +1 -2
  19. package/dist/anchor/relocate.js +8 -15
  20. package/dist/at.d.ts +0 -1
  21. package/dist/at.js +0 -1
  22. package/dist/bounded-file.d.ts +12 -0
  23. package/dist/bounded-file.js +47 -0
  24. package/dist/bundle/bundle.d.ts +0 -1
  25. package/dist/bundle/bundle.js +0 -1
  26. package/dist/bundle/grouping.d.ts +0 -1
  27. package/dist/bundle/grouping.js +0 -1
  28. package/dist/bundle/runtime-grouper.d.ts +1 -2
  29. package/dist/bundle/runtime-grouper.js +8 -15
  30. package/dist/contracts.d.ts +37 -1
  31. package/dist/contracts.js +14 -1
  32. package/dist/diff/hunks.d.ts +0 -1
  33. package/dist/diff/hunks.js +0 -1
  34. package/dist/diff/parse.d.ts +0 -1
  35. package/dist/diff/parse.js +0 -1
  36. package/dist/diff/quoted-path.d.ts +0 -1
  37. package/dist/diff/quoted-path.js +0 -1
  38. package/dist/domain.d.ts +11 -1
  39. package/dist/domain.js +2 -1
  40. package/dist/errors.d.ts +0 -1
  41. package/dist/errors.js +0 -1
  42. package/dist/hash.d.ts +0 -1
  43. package/dist/hash.js +0 -1
  44. package/dist/index.d.ts +10 -8
  45. package/dist/index.js +4 -5
  46. package/dist/internal.d.ts +10 -6
  47. package/dist/internal.js +9 -5
  48. package/dist/judge/judge.d.ts +1 -2
  49. package/dist/judge/judge.js +10 -14
  50. package/dist/judge/prompt.d.ts +1 -2
  51. package/dist/judge/prompt.js +10 -2
  52. package/dist/judge/verdict.d.ts +2 -2
  53. package/dist/judge/verdict.js +4 -3
  54. package/dist/knowledge/learning.d.ts +21 -0
  55. package/dist/knowledge/learning.js +1 -0
  56. package/dist/knowledge/select.d.ts +15 -0
  57. package/dist/knowledge/select.js +175 -0
  58. package/dist/learn/draft.d.ts +21 -0
  59. package/dist/learn/draft.js +123 -0
  60. package/dist/{pipeline → matrix}/matrix.d.ts +1 -3
  61. package/dist/{pipeline → matrix}/matrix.js +1 -2
  62. package/dist/memory/memory.d.ts +0 -1
  63. package/dist/memory/memory.js +0 -1
  64. package/dist/net/proxied-fetch.d.ts +0 -1
  65. package/dist/net/proxied-fetch.js +0 -1
  66. package/dist/pipeline/assemble-report.d.ts +0 -7
  67. package/dist/pipeline/assemble-report.js +33 -21
  68. package/dist/pipeline/check-stage.d.ts +0 -1
  69. package/dist/pipeline/check-stage.js +31 -12
  70. package/dist/pipeline/context.d.ts +2 -2
  71. package/dist/pipeline/context.js +26 -7
  72. package/dist/pipeline/coverage.d.ts +1 -2
  73. package/dist/pipeline/coverage.js +37 -17
  74. package/dist/pipeline/execute-stage.d.ts +5 -6
  75. package/dist/pipeline/execute-stage.js +50 -29
  76. package/dist/pipeline/execute.d.ts +13 -7
  77. package/dist/pipeline/execute.js +108 -43
  78. package/dist/pipeline/filter-stage.d.ts +0 -1
  79. package/dist/pipeline/filter-stage.js +2 -1
  80. package/dist/pipeline/findings.d.ts +0 -1
  81. package/dist/pipeline/findings.js +0 -1
  82. package/dist/pipeline/imports.d.ts +0 -1
  83. package/dist/pipeline/imports.js +2 -17
  84. package/dist/pipeline/options.d.ts +22 -2
  85. package/dist/pipeline/options.js +31 -1
  86. package/dist/pipeline/plan-output.d.ts +7 -1
  87. package/dist/pipeline/plan-output.js +9 -2
  88. package/dist/pipeline/plan.d.ts +14 -9
  89. package/dist/pipeline/plan.js +64 -10
  90. package/dist/pipeline/preview.d.ts +5 -5
  91. package/dist/pipeline/preview.js +18 -28
  92. package/dist/pipeline/provenance.d.ts +0 -1
  93. package/dist/pipeline/provenance.js +0 -1
  94. package/dist/pipeline/resume.d.ts +22 -0
  95. package/dist/pipeline/resume.js +24 -0
  96. package/dist/pipeline/run-id.d.ts +0 -1
  97. package/dist/pipeline/run-id.js +0 -1
  98. package/dist/pipeline/run.d.ts +0 -1
  99. package/dist/pipeline/run.js +18 -45
  100. package/dist/pipeline/task-prompt.d.ts +13 -0
  101. package/dist/pipeline/task-prompt.js +43 -0
  102. package/dist/pipeline/task.d.ts +8 -8
  103. package/dist/pipeline/task.js +11 -7
  104. package/dist/plugin/builtin.d.ts +1 -1
  105. package/dist/plugin/builtin.js +12 -3
  106. package/dist/plugin/host.d.ts +0 -1
  107. package/dist/plugin/host.js +0 -1
  108. package/dist/plugin/registry.d.ts +0 -1
  109. package/dist/plugin/registry.js +0 -1
  110. package/dist/plugin/types.d.ts +0 -1
  111. package/dist/plugin/types.js +0 -1
  112. package/dist/report/output-schema.d.ts +69 -1
  113. package/dist/report/output-schema.js +34 -5
  114. package/dist/report/output.d.ts +0 -1
  115. package/dist/report/output.js +31 -4
  116. package/dist/report/provenance.d.ts +0 -1
  117. package/dist/report/provenance.js +0 -1
  118. package/dist/report/read.d.ts +0 -1
  119. package/dist/report/read.js +5 -3
  120. package/dist/report/report.d.ts +57 -4
  121. package/dist/report/report.js +40 -3
  122. package/dist/report/serialize.d.ts +0 -1
  123. package/dist/report/serialize.js +0 -1
  124. package/dist/rereview/presence.d.ts +0 -1
  125. package/dist/rereview/presence.js +0 -1
  126. package/dist/rereview/quote.d.ts +0 -1
  127. package/dist/rereview/quote.js +0 -1
  128. package/dist/rereview/reconcile.d.ts +0 -1
  129. package/dist/rereview/reconcile.js +0 -1
  130. package/dist/review/impact.d.ts +20 -5
  131. package/dist/review/impact.js +153 -29
  132. package/dist/review/plan-phase.d.ts +1 -2
  133. package/dist/review/plan-phase.js +13 -13
  134. package/dist/review/prompt-text.d.ts +1 -2
  135. package/dist/review/prompt-text.js +82 -21
  136. package/dist/review/prompt.d.ts +6 -1
  137. package/dist/review/prompt.js +57 -3
  138. package/dist/review/reviewer.d.ts +0 -1
  139. package/dist/review/reviewer.js +0 -1
  140. package/dist/review/reviewers/agents-md.d.ts +0 -1
  141. package/dist/review/reviewers/agents-md.js +0 -1
  142. package/dist/review/reviewers/correctness.d.ts +0 -1
  143. package/dist/review/reviewers/correctness.js +0 -1
  144. package/dist/review/reviewers/docs.d.ts +0 -1
  145. package/dist/review/reviewers/docs.js +0 -1
  146. package/dist/review/reviewers/performance.d.ts +0 -1
  147. package/dist/review/reviewers/performance.js +0 -1
  148. package/dist/review/reviewers/scopes.d.ts +0 -1
  149. package/dist/review/reviewers/scopes.js +0 -1
  150. package/dist/review/reviewers/security.d.ts +0 -1
  151. package/dist/review/reviewers/security.js +0 -1
  152. package/dist/review/tools.d.ts +1 -1
  153. package/dist/review/tools.js +1 -1
  154. package/dist/rules/builtin/general.d.ts +0 -1
  155. package/dist/rules/builtin/general.js +0 -1
  156. package/dist/rules/builtin/go.d.ts +0 -1
  157. package/dist/rules/builtin/go.js +0 -1
  158. package/dist/rules/builtin/index.d.ts +0 -1
  159. package/dist/rules/builtin/index.js +0 -1
  160. package/dist/rules/builtin/java.d.ts +0 -1
  161. package/dist/rules/builtin/java.js +0 -1
  162. package/dist/rules/builtin/performance.d.ts +0 -1
  163. package/dist/rules/builtin/performance.js +0 -1
  164. package/dist/rules/builtin/python.d.ts +0 -1
  165. package/dist/rules/builtin/python.js +0 -1
  166. package/dist/rules/builtin/security.d.ts +0 -1
  167. package/dist/rules/builtin/security.js +0 -1
  168. package/dist/rules/builtin/typescript.d.ts +0 -1
  169. package/dist/rules/builtin/typescript.js +0 -1
  170. package/dist/rules/languages.d.ts +0 -1
  171. package/dist/rules/languages.js +0 -1
  172. package/dist/rules/repo-rules.d.ts +0 -1
  173. package/dist/rules/repo-rules.js +0 -1
  174. package/dist/rules/resolve.d.ts +0 -1
  175. package/dist/rules/resolve.js +0 -1
  176. package/dist/rules/rule-set.d.ts +0 -1
  177. package/dist/rules/rule-set.js +0 -1
  178. package/dist/runtime/attempt.d.ts +27 -2
  179. package/dist/runtime/attempt.js +68 -2
  180. package/dist/runtime/chain-runner.d.ts +2 -3
  181. package/dist/runtime/chain-runner.js +0 -1
  182. package/dist/runtime/effort-capability.d.ts +0 -1
  183. package/dist/runtime/effort-capability.js +0 -1
  184. package/dist/runtime/failback.d.ts +2 -3
  185. package/dist/runtime/failback.js +61 -15
  186. package/dist/runtime/models.d.ts +0 -1
  187. package/dist/runtime/models.js +14 -13
  188. package/dist/runtime/quota.d.ts +1 -1
  189. package/dist/runtime/quota.js +3 -2
  190. package/dist/runtime/tools.d.ts +0 -1
  191. package/dist/runtime/tools.js +11 -1
  192. package/dist/runtime/wrap-up.d.ts +6 -0
  193. package/dist/runtime/wrap-up.js +27 -0
  194. package/dist/sarif/candidates.d.ts +3 -3
  195. package/dist/sarif/candidates.js +2 -1
  196. package/dist/sarif/evidence.d.ts +35 -0
  197. package/dist/sarif/evidence.js +128 -0
  198. package/dist/sarif/schema.d.ts +18 -1
  199. package/dist/sarif/schema.js +8 -1
  200. package/dist/select/patterns.d.ts +1 -1
  201. package/dist/select/patterns.js +46 -1
  202. package/dist/select/select.d.ts +2 -1
  203. package/dist/select/select.js +34 -4
  204. package/dist/session/jsonl.d.ts +2 -2
  205. package/dist/session/jsonl.js +9 -4
  206. package/dist/session/resume-read.d.ts +2 -0
  207. package/dist/session/resume-read.js +131 -0
  208. package/dist/session/seal.d.ts +5 -0
  209. package/dist/session/seal.js +29 -0
  210. package/dist/triage.d.ts +0 -1
  211. package/dist/triage.js +0 -1
  212. package/dist/vcs.d.ts +0 -1
  213. package/dist/vcs.js +0 -1
  214. package/dist/verify/prompt.d.ts +6 -3
  215. package/dist/verify/prompt.js +13 -5
  216. package/dist/verify/related.d.ts +3 -0
  217. package/dist/verify/related.js +88 -0
  218. package/dist/verify/verify.d.ts +3 -4
  219. package/dist/verify/verify.js +27 -20
  220. package/package.json +3 -3
  221. package/dist/agent/budget.d.ts +0 -13
  222. package/dist/agent/budget.js +0 -28
@@ -2,8 +2,8 @@ export declare const REVIEW_TOOLS: {
2
2
  readonly readFile: "read_file";
3
3
  readonly readDiff: "read_diff";
4
4
  readonly codeSearch: "code_search";
5
+ readonly readLearning: "read_learning";
5
6
  readonly reportFinding: "report_finding";
6
7
  readonly taskDone: "task_done";
7
8
  };
8
9
  export type ReviewToolName = (typeof REVIEW_TOOLS)[keyof typeof REVIEW_TOOLS];
9
- //# sourceMappingURL=tools.d.ts.map
@@ -2,7 +2,7 @@ export const REVIEW_TOOLS = {
2
2
  readFile: "read_file",
3
3
  readDiff: "read_diff",
4
4
  codeSearch: "code_search",
5
+ readLearning: "read_learning",
5
6
  reportFinding: "report_finding",
6
7
  taskDone: "task_done",
7
8
  };
8
- //# sourceMappingURL=tools.js.map
@@ -1,2 +1 @@
1
1
  export declare const GENERAL_RULES = "### General correctness\n- Logic that produces a wrong result on a reachable input: inverted or incomplete conditions, off-by-one bounds, wrong operator, wrong variable, unreachable or dead branches that were meant to run.\n- Broken contracts between changed code and its callers or callees: changed signatures, return shapes, units, nullability or error behavior whose other side was not updated.\n- Error handling that hides failure: swallowed exceptions, errors converted to success or default values, partial writes reported as complete, cleanup that masks the original error.\n- State and resource bugs: missing cleanup on error paths, double release, leaked handles, mutation of shared or input data that callers do not expect.\n- Concurrency hazards that the code makes reachable: unsynchronized shared state, check-then-act races, missing cancellation or timeouts on blocking work.\n- Data integrity: lost updates, non-idempotent retries, inconsistent writes across stores, incorrect migrations or backfills.\n- Security defects visible in the change: injection, missing authorization on a new path, secrets in code or logs, unsafe deserialization.";
2
- //# sourceMappingURL=general.d.ts.map
@@ -6,4 +6,3 @@ export const GENERAL_RULES = `### General correctness
6
6
  - Concurrency hazards that the code makes reachable: unsynchronized shared state, check-then-act races, missing cancellation or timeouts on blocking work.
7
7
  - Data integrity: lost updates, non-idempotent retries, inconsistent writes across stores, incorrect migrations or backfills.
8
8
  - Security defects visible in the change: injection, missing authorization on a new path, secrets in code or logs, unsafe deserialization.`;
9
- //# sourceMappingURL=general.js.map
@@ -1,2 +1 @@
1
1
  export declare const GO_RULES = "### Go\n- Errors that are ignored, overwritten before being checked, or wrapped with `%v` where callers rely on `errors.Is`/`errors.As`.\n- Typed nil values stored in interfaces and then compared with `nil`; nil map writes; nil pointer dereferences reachable from real inputs.\n- Goroutines that can block forever or outlive their owner; missing cancellation; `context.Background()` used where the caller's context should flow.\n- `WithCancel`/`WithTimeout` whose cancel function is never called; timers or tickers left running.\n- Data races on maps, slices or counters shared between goroutines; locks held across blocking I/O; copying values that contain a `sync.Mutex`.\n- `defer` inside loops that delays cleanup until function exit; deferred `Close` errors dropped on write paths.\n- Loop variable capture in goroutines or closures when the module targets Go older than 1.22.";
2
- //# sourceMappingURL=go.d.ts.map
@@ -6,4 +6,3 @@ export const GO_RULES = `### Go
6
6
  - Data races on maps, slices or counters shared between goroutines; locks held across blocking I/O; copying values that contain a \`sync.Mutex\`.
7
7
  - \`defer\` inside loops that delays cleanup until function exit; deferred \`Close\` errors dropped on write paths.
8
8
  - Loop variable capture in goroutines or closures when the module targets Go older than 1.22.`;
9
- //# sourceMappingURL=go.js.map
@@ -2,4 +2,3 @@ import type { RuleSet } from "../rule-set.js";
2
2
  export { PERFORMANCE_RULES } from "./performance.js";
3
3
  export { SECURITY_RULES } from "./security.js";
4
4
  export declare const CORRECTNESS_RULES: RuleSet;
5
- //# sourceMappingURL=index.d.ts.map
@@ -12,4 +12,3 @@ const LANGUAGE_RULES = {
12
12
  java: JAVA_RULES,
13
13
  };
14
14
  export const CORRECTNESS_RULES = { general: GENERAL_RULES, languages: LANGUAGE_RULES };
15
- //# sourceMappingURL=index.js.map
@@ -1,2 +1 @@
1
1
  export declare const JAVA_RULES = "### Java\n- `equals`/`hashCode` inconsistencies, reference comparison (`==`) of strings or boxed numbers, and unboxing of possibly-null values.\n- Resources not closed with try-with-resources on paths that can throw; streams, connections or locks leaked on error.\n- Exceptions caught and ignored, logged and then treated as success, or rethrown without the cause.\n- Shared mutable state accessed from multiple threads without synchronization; non-thread-safe types (`SimpleDateFormat`, `HashMap`) in shared fields; double-checked locking without `volatile`.\n- `Optional.get()` or collection access without checking presence; modification of a collection while iterating it.\n- Transaction boundaries that do not cover all related writes; `@Transactional` on private or self-invoked methods.\n- SQL or JPQL built by string concatenation from input; deserialization of untrusted data.";
2
- //# sourceMappingURL=java.d.ts.map
@@ -6,4 +6,3 @@ export const JAVA_RULES = `### Java
6
6
  - \`Optional.get()\` or collection access without checking presence; modification of a collection while iterating it.
7
7
  - Transaction boundaries that do not cover all related writes; \`@Transactional\` on private or self-invoked methods.
8
8
  - SQL or JPQL built by string concatenation from input; deserialization of untrusted data.`;
9
- //# sourceMappingURL=java.js.map
@@ -1,2 +1 @@
1
1
  export declare const PERFORMANCE_RULES = "### Performance\n- Algorithmic complexity that grows with input the code cannot bound: nested loops over the same collections, repeated linear searches or `includes` inside loops where a set or map fits, sorting inside loops.\n- Round trips in loops: database queries, HTTP calls or file reads per item (N+1) where one batched call works; queries on new filters that fetch unbounded result sets without a limit or pagination.\n- Blocking work on latency-sensitive paths: synchronous file, network or CPU-heavy work in request handlers, event loops, UI threads or `async` functions.\n- Memory: whole files, streams or result sets buffered when their size is external; caches, maps or listener lists that grow without eviction or removal.\n- Repeated work on hot paths: recomputation or re-parsing inside loops, regular expressions or serializers rebuilt per call, React renders triggered by unstable dependencies or props.\n- Concurrency: independent I/O awaited one after another on a latency-critical path; unbounded parallelism that overwhelms a pool, a rate limit or memory.\n- Regressions of existing optimizations: removed indexes, caches, batching, streaming or early exits.";
2
- //# sourceMappingURL=performance.d.ts.map
@@ -6,4 +6,3 @@ export const PERFORMANCE_RULES = `### Performance
6
6
  - Repeated work on hot paths: recomputation or re-parsing inside loops, regular expressions or serializers rebuilt per call, React renders triggered by unstable dependencies or props.
7
7
  - Concurrency: independent I/O awaited one after another on a latency-critical path; unbounded parallelism that overwhelms a pool, a rate limit or memory.
8
8
  - Regressions of existing optimizations: removed indexes, caches, batching, streaming or early exits.`;
9
- //# sourceMappingURL=performance.js.map
@@ -1,2 +1 @@
1
1
  export declare const PYTHON_RULES = "### Python\n- Mutable default arguments or class attributes shared across calls or instances when per-call state was intended.\n- Broad `except` (bare or `Exception`) that swallows errors, including `KeyboardInterrupt`/`SystemExit` via bare `except`, or re-raises without the original cause.\n- Resources opened without `with` or `try/finally` on paths that can raise.\n- Blocking calls inside `async def` code, coroutines that are never awaited, or tasks created without keeping a reference.\n- Truthiness checks that misclassify valid values (`0`, `\"\"`, empty collections) where `is None` was meant.\n- Late-binding closures in loops, iteration while mutating the same collection, integer vs float division mistakes.\n- SQL, shell or template strings built from input instead of parameters; `pickle`/`yaml.load` on untrusted data.";
2
- //# sourceMappingURL=python.d.ts.map
@@ -6,4 +6,3 @@ export const PYTHON_RULES = `### Python
6
6
  - Truthiness checks that misclassify valid values (\`0\`, \`""\`, empty collections) where \`is None\` was meant.
7
7
  - Late-binding closures in loops, iteration while mutating the same collection, integer vs float division mistakes.
8
8
  - SQL, shell or template strings built from input instead of parameters; \`pickle\`/\`yaml.load\` on untrusted data.`;
9
- //# sourceMappingURL=python.js.map
@@ -1,2 +1 @@
1
1
  export declare const SECURITY_RULES = "### Security\n- Injection from input that reaches an interpreter: SQL or NoSQL built from strings, shell commands, template rendering, LDAP or XPath, HTML without escaping (XSS), headers or log lines with raw newlines.\n- Server-side request forgery and path traversal: URLs, hosts or file paths built from input without an allow-list or containment check, including archive extraction.\n- Authentication and authorization: new routes, handlers, jobs or queries without the checks their neighbours apply; object access by id without an ownership or tenant check (IDOR); privilege or role checks that can be bypassed or were weakened.\n- Secrets and sensitive data: credentials or tokens in code or config, secrets or personal data written to logs, errors, analytics or responses; session tokens or API keys exposed to the client.\n- Cryptography: home-made crypto, weak or misused algorithms (MD5/SHA-1 for passwords, ECB, static IVs), non-cryptographic randomness for tokens, disabled certificate or signature verification, timing-unsafe secret comparison.\n- Unsafe parsing: deserialization of untrusted data (pickle, Java serialization, YAML full loaders), XML external entities, prototype pollution through deep merges, regular expressions with catastrophic backtracking on input.\n- Resource exhaustion from untrusted input: unbounded sizes, counts, recursion or allocation that an external caller controls.\n- Configuration: permissive CORS with credentials, cookies without Secure/HttpOnly/SameSite where they carry sessions, debug modes or verbose errors enabled in production paths, world-writable files.\n- CI and supply chain: untrusted pull request text or branch names interpolated into workflow `run:` steps, `pull_request_target` checking out untrusted code with secrets, broadened workflow permissions, new dependencies from unexpected sources or install scripts.";
2
- //# sourceMappingURL=security.d.ts.map
@@ -8,4 +8,3 @@ export const SECURITY_RULES = `### Security
8
8
  - Resource exhaustion from untrusted input: unbounded sizes, counts, recursion or allocation that an external caller controls.
9
9
  - Configuration: permissive CORS with credentials, cookies without Secure/HttpOnly/SameSite where they carry sessions, debug modes or verbose errors enabled in production paths, world-writable files.
10
10
  - CI and supply chain: untrusted pull request text or branch names interpolated into workflow \`run:\` steps, \`pull_request_target\` checking out untrusted code with secrets, broadened workflow permissions, new dependencies from unexpected sources or install scripts.`;
11
- //# sourceMappingURL=security.js.map
@@ -1,2 +1 @@
1
1
  export declare const TYPESCRIPT_RULES = "### TypeScript and JavaScript\n- Promises that are neither awaited, returned nor explicitly handled, so failures become unhandled rejections or ordering is lost; `forEach` with async callbacks that callers assume completed.\n- `await` inside loops where independent work was meant to run concurrently, or `Promise.all` over work that must be sequential or bounded.\n- Truthiness checks that misclassify valid values (`0`, `\"\"`, `NaN`, `false`) where `??` or an explicit comparison was needed; `==` comparisons with surprising coercion.\n- Type assertions (`as`, non-null `!`, `any`) that bypass a check the runtime data can actually fail; parsed external data used without validation.\n- Mutation of arguments, shared module state or React state/props in place; missing or wrong hook dependencies that cause stale values or infinite loops.\n- Floating timers, listeners or subscriptions without cleanup on unmount, abort or error.\n- `JSON.parse`, `new URL`, `BigInt` and similar calls on external input without handling their exceptions.";
2
- //# sourceMappingURL=typescript.d.ts.map
@@ -6,4 +6,3 @@ export const TYPESCRIPT_RULES = `### TypeScript and JavaScript
6
6
  - Mutation of arguments, shared module state or React state/props in place; missing or wrong hook dependencies that cause stale values or infinite loops.
7
7
  - Floating timers, listeners or subscriptions without cleanup on unmount, abort or error.
8
8
  - \`JSON.parse\`, \`new URL\`, \`BigInt\` and similar calls on external input without handling their exceptions.`;
9
- //# sourceMappingURL=typescript.js.map
@@ -1,3 +1,2 @@
1
1
  export type Language = "typescript" | "python" | "go" | "java";
2
2
  export declare function detectLanguage(path: string): Language | undefined;
3
- //# sourceMappingURL=languages.d.ts.map
@@ -17,4 +17,3 @@ export function detectLanguage(path) {
17
17
  const dot = name.lastIndexOf(".");
18
18
  return dot > 0 ? EXTENSIONS[name.slice(dot + 1).toLowerCase()] : undefined;
19
19
  }
20
- //# sourceMappingURL=languages.js.map
@@ -10,4 +10,3 @@ export type SourcedRule = RepoRule & {
10
10
  };
11
11
  export declare const REPO_RULES_PATH = ".ocra/rules.json";
12
12
  export declare function parseRepoRules(json: string): RepoRule[];
13
- //# sourceMappingURL=repo-rules.d.ts.map
@@ -20,4 +20,3 @@ export function parseRepoRules(json) {
20
20
  }
21
21
  return parsed.data.rules;
22
22
  }
23
- //# sourceMappingURL=repo-rules.js.map
@@ -1,4 +1,3 @@
1
1
  import type { RepoRule } from "./repo-rules.js";
2
2
  import type { RuleSet } from "./rule-set.js";
3
3
  export declare function resolveRules(paths: readonly string[], repoRules: readonly RepoRule[], builtin?: RuleSet): string;
4
- //# sourceMappingURL=resolve.d.ts.map
@@ -24,4 +24,3 @@ export function resolveRules(paths, repoRules, builtin = {}) {
24
24
  }
25
25
  return sections.join("\n\n");
26
26
  }
27
- //# sourceMappingURL=resolve.js.map
@@ -3,4 +3,3 @@ export interface RuleSet {
3
3
  general?: string;
4
4
  languages?: Partial<Record<Language, string>>;
5
5
  }
6
- //# sourceMappingURL=rule-set.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=rule-set.js.map
@@ -1,7 +1,10 @@
1
- import type { Usage } from "../contracts.js";
1
+ import type { AttemptRecord, IncompleteEnding, Usage } from "../contracts.js";
2
2
  import type { QuotaError } from "./quota.js";
3
3
  export declare const MAX_AGENT_STEPS = 30;
4
4
  export declare const RESUME_MESSAGE: string;
5
+ export declare const WRAP_UP_TOOLS: readonly ["report_finding", "task_done"];
6
+ export declare const WRAP_UP_MESSAGE: string;
7
+ export declare const WRAP_UP_STEPS = 2;
5
8
  export declare function withoutSecrets(text: string, secrets: readonly string[]): string;
6
9
  export interface AttemptOutcome {
7
10
  findings: unknown[];
@@ -9,8 +12,20 @@ export interface AttemptOutcome {
9
12
  toolCalls: string[];
10
13
  text: string;
11
14
  resumed?: true;
15
+ atStepCap?: true;
16
+ read?: string[];
17
+ searched?: string[];
18
+ wrappedUp?: WrapUpOutcome;
12
19
  usage: Usage;
13
20
  error?: AttemptError;
21
+ unreadMessages?: number;
22
+ }
23
+ export interface WrapUpOutcome {
24
+ findings: number;
25
+ error?: string;
26
+ }
27
+ export interface TaskAttempt extends AttemptOutcome {
28
+ wrapUp?(): Promise<AttemptOutcome>;
14
29
  }
15
30
  export interface AttemptError {
16
31
  message: string;
@@ -19,4 +34,14 @@ export interface AttemptError {
19
34
  }
20
35
  export declare function attemptSummary(model: string, outcome: AttemptOutcome): string;
21
36
  export declare function toolSummary(toolCalls: readonly string[]): string;
22
- //# sourceMappingURL=attempt.d.ts.map
37
+ export type AttemptEnding = "done" | IncompleteEnding | "error";
38
+ export declare function attemptEnding(outcome: AttemptOutcome): AttemptEnding;
39
+ export interface ToolUse {
40
+ name: string;
41
+ input: unknown;
42
+ }
43
+ export declare function exploredBy(uses: readonly ToolUse[]): {
44
+ read: string[];
45
+ searched: string[];
46
+ };
47
+ export declare function attemptRecord(model: string, outcome: AttemptOutcome): AttemptRecord;
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  import { REVIEW_TOOLS } from "../review/tools.js";
2
3
  // Each step resends the whole conversation, so an unbounded loop is the
3
4
  // largest cost risk. At 20 steps a quarter of the review tasks on Vertex
@@ -11,6 +12,17 @@ export const MAX_AGENT_STEPS = 30;
11
12
  // the same conversation, which keeps what it read and is cheaper than
12
13
  // starting over.
13
14
  export const RESUME_MESSAGE = `You stopped before finishing the review. Continue with the files in <ocra_review_files> you have not reviewed yet, report each confirmed issue with ${REVIEW_TOOLS.reportFinding}, and call ${REVIEW_TOOLS.taskDone} when every file is done.`;
15
+ // A review that ends without the done tool, at the step cap or after
16
+ // stopping early, has often read the code and reached a conclusion it never
17
+ // reported (on its last step OpenCode tells it to answer in text only). One
18
+ // more turn in the same conversation, with only these tools, keeps what it
19
+ // confirmed.
20
+ export const WRAP_UP_TOOLS = [REVIEW_TOOLS.reportFinding, REVIEW_TOOLS.taskDone];
21
+ export const WRAP_UP_MESSAGE = `You have no steps left to read more code. Report each issue you have already confirmed with ${REVIEW_TOOLS.reportFinding}, then call ${REVIEW_TOOLS.taskDone}. Do not report anything you have not confirmed.`;
22
+ // The turn is one request in which the agent reports. It gets two: OpenCode
23
+ // tells an agent to answer in text only on its last step, and Gemini rejects
24
+ // a request that ends with a model turn (#66).
25
+ export const WRAP_UP_STEPS = 2;
14
26
  // Text with every secret replaced: a provider's error may echo the request's
15
27
  // headers, and a progress line or session file must not carry the key.
16
28
  export function withoutSecrets(text, secrets) {
@@ -21,7 +33,16 @@ export function withoutSecrets(text, secrets) {
21
33
  export function attemptSummary(model, outcome) {
22
34
  const { inputTokens, outputTokens, reasoningTokens, costUsd } = outcome.usage;
23
35
  const resumed = outcome.resumed ? ", resumed after stopping early" : "";
24
- return `${model}: ${outcome.steps} step(s), ${toolSummary(outcome.toolCalls)}${resumed}, ${inputTokens} in / ${outputTokens} out / ${reasoningTokens} reasoning tokens, $${costUsd.toFixed(4)}`;
36
+ const unread = outcome.unreadMessages
37
+ ? `, ${outcome.unreadMessages} session message(s) not read (their findings and usage are missing)`
38
+ : "";
39
+ return `${model}: ${outcome.steps} step(s), ${toolSummary(outcome.toolCalls)}${resumed}${wrapUpSummary(outcome.wrappedUp)}, ${inputTokens} in / ${outputTokens} out / ${reasoningTokens} reasoning tokens, $${costUsd.toFixed(4)}${unread}`;
40
+ }
41
+ function wrapUpSummary(wrapUp) {
42
+ if (!wrapUp)
43
+ return "";
44
+ const failed = wrapUp.error === undefined ? "" : `, then failed: ${wrapUp.error}`;
45
+ return `, wrap-up turn reported ${wrapUp.findings} finding(s)${failed}`;
25
46
  }
26
47
  export function toolSummary(toolCalls) {
27
48
  if (toolCalls.length === 0)
@@ -34,4 +55,49 @@ export function toolSummary(toolCalls) {
34
55
  const finished = names.includes(REVIEW_TOOLS.taskDone) ? "" : "; no task_done";
35
56
  return `${toolCalls.length} tool call(s) (${byUse.map(([n, c]) => `${n} ${c}`).join(", ")}${finished})`;
36
57
  }
37
- //# sourceMappingURL=attempt.js.map
58
+ export function attemptEnding(outcome) {
59
+ if (outcome.error)
60
+ return "error";
61
+ if (outcome.toolCalls.includes(REVIEW_TOOLS.taskDone))
62
+ return "done";
63
+ return outcome.atStepCap ? "step_cap" : "stopped_early";
64
+ }
65
+ // A model chooses these strings, so the session log keeps a bounded number
66
+ // of bounded ones.
67
+ const MAX_EXPLORED = 200;
68
+ const MAX_EXPLORED_CHARS = 500;
69
+ const MAX_TEXT_CHARS = 4_000;
70
+ // The files an attempt read and what it searched for, from its tool calls.
71
+ export function exploredBy(uses) {
72
+ return {
73
+ read: distinct(uses, REVIEW_TOOLS.readFile, (input) => readInput.safeParse(input).data?.path),
74
+ searched: distinct(uses, REVIEW_TOOLS.codeSearch, (input) => searchInput.safeParse(input).data?.literal),
75
+ };
76
+ }
77
+ const readInput = z.object({ path: z.string() });
78
+ const searchInput = z.object({ literal: z.string() });
79
+ function distinct(uses, tool, pick) {
80
+ const values = new Set();
81
+ for (const use of uses) {
82
+ const value = use.name === tool ? pick(use.input) : undefined;
83
+ if (value !== undefined)
84
+ values.add(cut(value, MAX_EXPLORED_CHARS));
85
+ if (values.size >= MAX_EXPLORED)
86
+ break;
87
+ }
88
+ return [...values];
89
+ }
90
+ export function attemptRecord(model, outcome) {
91
+ return {
92
+ model,
93
+ read: outcome.read ?? [],
94
+ searched: outcome.searched ?? [],
95
+ // The end of an answer is where a reviewer concludes.
96
+ text: outcome.text.length > MAX_TEXT_CHARS
97
+ ? `…${outcome.text.slice(-MAX_TEXT_CHARS)}`
98
+ : outcome.text,
99
+ };
100
+ }
101
+ function cut(text, max) {
102
+ return text.length > max ? `${text.slice(0, max)}…` : text;
103
+ }
@@ -1,10 +1,10 @@
1
1
  import type { AgentEvent, AgentTaskSpec, CompletionRequest, CompletionResult, ModelChains, Usage } from "../contracts.js";
2
2
  import { OcraError } from "../errors.js";
3
- import type { AttemptOutcome } from "./attempt.js";
3
+ import type { AttemptOutcome, TaskAttempt } from "./attempt.js";
4
4
  export interface ModelAttempts {
5
5
  refuse?(chain: readonly string[], own: boolean): OcraError | undefined;
6
6
  ready?(): Promise<void>;
7
- task(model: string, spec: AgentTaskSpec, signal: AbortSignal, onUsage: (spent: Usage) => void): Promise<AttemptOutcome>;
7
+ task(model: string, spec: AgentTaskSpec, signal: AbortSignal, onUsage: (spent: Usage) => void): Promise<TaskAttempt>;
8
8
  complete(model: string, request: CompletionRequest, signal: AbortSignal): Promise<AttemptOutcome>;
9
9
  }
10
10
  export declare class ChainRunner {
@@ -16,4 +16,3 @@ export declare class ChainRunner {
16
16
  complete(request: CompletionRequest, signal: AbortSignal): Promise<CompletionResult>;
17
17
  private refusal;
18
18
  }
19
- //# sourceMappingURL=chain-runner.d.ts.map
@@ -60,4 +60,3 @@ export class ChainRunner {
60
60
  function noModel(tier) {
61
61
  return new OcraError("CONFIG_INVALID", `No model configured for the "${tier}" tier; set models.${tier} in .ocra/config.json or OCRA_MODEL_${tier.toUpperCase()}`);
62
62
  }
63
- //# sourceMappingURL=chain-runner.js.map
@@ -11,4 +11,3 @@ export interface EffortCapability {
11
11
  export declare function effortCapability(model: string): EffortCapability | undefined;
12
12
  export declare const FALLBACK_OUTPUT_LIMIT = 32000;
13
13
  export declare function thinkingBudget(capability: EffortCapability, level: Effort, outputLimit?: number): number | undefined;
14
- //# sourceMappingURL=effort-capability.d.ts.map
@@ -67,4 +67,3 @@ export function thinkingBudget(capability, level, outputLimit) {
67
67
  return undefined;
68
68
  return Math.min(max, Math.max(min, Math.floor(limit * BUDGET_SHARE[level])));
69
69
  }
70
- //# sourceMappingURL=effort-capability.js.map
@@ -1,5 +1,5 @@
1
1
  import type { AgentEvent, CompletionResult, ModelTier, Usage } from "../contracts.js";
2
- import { type AttemptOutcome } from "./attempt.js";
2
+ import { type AttemptOutcome, type TaskAttempt } from "./attempt.js";
3
3
  import type { ModelHealth } from "./models.js";
4
4
  export interface FailbackOptions {
5
5
  taskId: string;
@@ -8,7 +8,7 @@ export interface FailbackOptions {
8
8
  chain: readonly string[];
9
9
  health: ModelHealth;
10
10
  signal: AbortSignal;
11
- attempt(model: string, onUsage: (spent: Usage) => void): Promise<AttemptOutcome>;
11
+ attempt(model: string, onUsage: (spent: Usage) => void): Promise<TaskAttempt>;
12
12
  }
13
13
  export declare function withFailback(options: FailbackOptions): AsyncGenerator<AgentEvent>;
14
14
  export interface CompleteOptions {
@@ -20,4 +20,3 @@ export interface CompleteOptions {
20
20
  attempt(model: string): Promise<AttemptOutcome>;
21
21
  }
22
22
  export declare function completeWithFailback(options: CompleteOptions): Promise<CompletionResult>;
23
- //# sourceMappingURL=failback.d.ts.map
@@ -1,7 +1,8 @@
1
1
  import { addUsage, emptyUsage } from "../agent/usage.js";
2
2
  import { CompletionError } from "../errors.js";
3
- import { attemptSummary } from "./attempt.js";
3
+ import { attemptEnding, attemptRecord, attemptSummary, } from "./attempt.js";
4
4
  import { sleep } from "./quota.js";
5
+ import { outcomeOf, pendingWrapUp, wrapUp } from "./wrap-up.js";
5
6
  // Findings from a failed attempt are still emitted: the pipeline deduplicates
6
7
  // by fingerprint, so a retry on the next model cannot double-report them.
7
8
  export async function* withFailback(options) {
@@ -18,32 +19,49 @@ export async function* withFailback(options) {
18
19
  taskId,
19
20
  message: `${model} is rate limited; waiting ${Math.ceil(pause / 1000)}s`,
20
21
  };
21
- await sleep(pause, signal);
22
+ await pauseOver(health, model, signal);
22
23
  if (signal.aborted)
23
24
  return;
24
25
  }
26
+ // Another task may have found it out of quota since the chain was read.
27
+ if (health.isOutOfQuota(model))
28
+ break;
25
29
  yield { type: "progress", taskId, message: `reviewing with ${model}` };
26
30
  // Spend is reported while the attempt runs, so a run's spend limit
27
31
  // can stop it; the finished attempt's total settles the rest.
28
32
  const live = new LiveUsage();
29
- const running = options.attempt(model, (spent) => live.observe(spent));
30
- const finished = running.then(() => false, () => false);
31
- while (await Promise.race([finished, live.changed().then(() => true)])) {
32
- yield { type: "usage", taskId, ...live.take() };
33
+ const attempt = yield* whileRunning(taskId, live, options.attempt(model, (spent) => live.observe(spent)));
34
+ yield { type: "usage", taskId, ...live.rest(attempt.usage) };
35
+ let outcome = outcomeOf(attempt);
36
+ // Read before the wrap-up turn, whose done tool reports what the agent
37
+ // had confirmed and reads nothing more: its files stay partly reviewed.
38
+ const ended = attemptEnding(outcome);
39
+ // Decided after the attempt's spend was handed over, so a spend limit
40
+ // it reached has already aborted the signal.
41
+ const turn = pendingWrapUp(attempt, ended, signal);
42
+ if (turn) {
43
+ outcome = yield* whileRunning(taskId, live, wrapUp(outcome, turn));
44
+ yield { type: "usage", taskId, ...live.rest(outcome.usage) };
33
45
  }
34
- const outcome = await running;
35
- yield { type: "usage", taskId, ...live.rest(outcome.usage) };
36
- yield { type: "progress", taskId, message: attemptSummary(model, outcome) };
46
+ yield {
47
+ type: "progress",
48
+ taskId,
49
+ message: attemptSummary(model, outcome),
50
+ attempt: attemptRecord(model, outcome),
51
+ };
37
52
  for (const finding of outcome.findings)
38
53
  yield { type: "finding", taskId, finding, model };
39
- // A cancelled attempt is neither finished nor the model's fault.
40
- if (signal.aborted)
41
- return;
54
+ // Ended without an error, the attempt finished even if the task was
55
+ // stopped meanwhile, as when the spend its last report added reached
56
+ // the run's limit: the pipeline decides what that stop means.
42
57
  if (!outcome.error) {
43
58
  health.recordSuccess(model);
44
- yield { type: "done", taskId };
59
+ yield doneEvent(taskId, ended, outcome.wrappedUp);
45
60
  return;
46
61
  }
62
+ // A cancelled attempt is neither finished nor the model's fault.
63
+ if (signal.aborted)
64
+ return;
47
65
  if (!outcome.error.retryable) {
48
66
  yield {
49
67
  type: "error",
@@ -72,6 +90,22 @@ export async function* withFailback(options) {
72
90
  retryable: true,
73
91
  };
74
92
  }
93
+ function doneEvent(taskId, ended, wrappedUp) {
94
+ return {
95
+ type: "done",
96
+ taskId,
97
+ ...(ended === "step_cap" || ended === "stopped_early" ? { ended } : {}),
98
+ ...(wrappedUp ? { wrapUp: { findings: wrappedUp.findings } } : {}),
99
+ };
100
+ }
101
+ // Yields the spend that grows while `running` runs, then returns its result.
102
+ async function* whileRunning(taskId, live, running) {
103
+ const finished = running.then(() => false, () => false);
104
+ while (await Promise.race([finished, live.changed().then(() => true)])) {
105
+ yield { type: "usage", taskId, ...live.take() };
106
+ }
107
+ return await running;
108
+ }
75
109
  // Hands out what an attempt has spent in increments, each what grew since the
76
110
  // last one; `rest` settles the finished attempt's total, so the increments
77
111
  // add up to it and nothing is counted twice.
@@ -141,9 +175,11 @@ export async function completeWithFailback(options) {
141
175
  let lastError = "";
142
176
  for (const model of health.order(options.chain)) {
143
177
  for (;;) {
144
- await sleep(health.pausedFor(model), signal);
178
+ await pauseOver(health, model, signal);
145
179
  if (signal.aborted)
146
180
  throw new CompletionError("cancelled", usage);
181
+ if (health.isOutOfQuota(model))
182
+ break;
147
183
  const outcome = await options.attempt(model);
148
184
  usage = addUsage(usage, outcome.usage);
149
185
  if (!outcome.error) {
@@ -167,9 +203,19 @@ export async function completeWithFailback(options) {
167
203
  }
168
204
  throw new CompletionError(`every ${chainName(options)} failed (${lastError})`, usage);
169
205
  }
206
+ // Waits until the model's pause ends as it stands on waking, not as it stood
207
+ // on falling asleep: another task's limit may have lengthened it, and a
208
+ // request sent inside it would only join it again.
209
+ async function pauseOver(health, model, signal) {
210
+ for (;;) {
211
+ const pause = health.pausedFor(model);
212
+ if (pause <= 0 || signal.aborted || health.isOutOfQuota(model))
213
+ return;
214
+ await sleep(pause, signal);
215
+ }
216
+ }
170
217
  function chainName(options) {
171
218
  return options.agent === undefined
172
219
  ? `${options.tier} model`
173
220
  : `model of ${options.agent}'s own chain`;
174
221
  }
175
- //# sourceMappingURL=failback.js.map
@@ -29,4 +29,3 @@ export declare class ModelHealth {
29
29
  isOutOfQuota(model: string): boolean;
30
30
  recordQuota(model: string, quota: QuotaError): "wait" | "out_of_quota";
31
31
  }
32
- //# sourceMappingURL=models.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { OcraError } from "../errors.js";
2
- import { MAX_QUOTA_WAIT_MS, QUOTA_RETRIES } from "./quota.js";
2
+ import { MAX_QUOTA_WAIT_MS, QUOTA_RETRIES, UNSTATED_QUOTA_WAIT_MS, } from "./quota.js";
3
3
  export function parseModel(model) {
4
4
  const slash = model.indexOf("/");
5
5
  if (slash <= 0 || slash === model.length - 1) {
@@ -73,23 +73,24 @@ export class ModelHealth {
73
73
  isOutOfQuota(model) {
74
74
  return this.outOfQuota.has(model);
75
75
  }
76
- // A rate limit with a short, stated wait pauses the model for every task;
77
- // a daily limit, no stated wait, a long one, or too many waits in a row
78
- // mean the model is out of quota for the rest of the run.
76
+ // A rate limit with a short wait pauses the model for every task; a daily
77
+ // limit, a long stated wait, or too many waits in a row mean the model is
78
+ // out of quota for the rest of the run. Vertex AI's shared quota answers
79
+ // 429 without a wait when it is busy, so a missing wait backs off instead.
80
+ // Tasks running at once are refused together: a limit that arrives while
81
+ // the model is paused joins that pause rather than counting another wait,
82
+ // and only a wait it states can lengthen the pause.
79
83
  recordQuota(model, quota) {
84
+ const now = this.now();
80
85
  const state = this.quotas.get(model) ?? { waits: 0, pausedUntil: 0 };
81
- const wait = quota.retryAfterMs;
82
- if (quota.daily ||
83
- wait === undefined ||
84
- wait > MAX_QUOTA_WAIT_MS ||
85
- state.waits >= QUOTA_RETRIES) {
86
+ const joins = state.pausedUntil > now;
87
+ const waits = joins ? state.waits : state.waits + 1;
88
+ const wait = quota.retryAfterMs ?? (joins ? 0 : UNSTATED_QUOTA_WAIT_MS * 2 ** (waits - 1));
89
+ if (quota.daily || wait > MAX_QUOTA_WAIT_MS || waits > QUOTA_RETRIES) {
86
90
  this.outOfQuota.add(model);
87
91
  return "out_of_quota";
88
92
  }
89
- state.waits += 1;
90
- state.pausedUntil = Math.max(state.pausedUntil, this.now() + wait);
91
- this.quotas.set(model, state);
93
+ this.quotas.set(model, { waits, pausedUntil: Math.max(state.pausedUntil, now + wait) });
92
94
  return "wait";
93
95
  }
94
96
  }
95
- //# sourceMappingURL=models.js.map
@@ -3,7 +3,7 @@ export interface QuotaError {
3
3
  daily: boolean;
4
4
  }
5
5
  export declare const MAX_QUOTA_WAIT_MS = 90000;
6
+ export declare const UNSTATED_QUOTA_WAIT_MS = 15000;
6
7
  export declare const QUOTA_RETRIES = 3;
7
8
  export declare function parseQuotaError(message: string, statusCode?: number): QuotaError | undefined;
8
9
  export declare function sleep(ms: number, signal: AbortSignal): Promise<void>;
9
- //# sourceMappingURL=quota.d.ts.map
@@ -1,11 +1,13 @@
1
1
  // Longest wait for a rate limit inside a run; per-minute limits ask for less.
2
2
  export const MAX_QUOTA_WAIT_MS = 90_000;
3
+ // First wait for a rate limit that states none, doubled on each repeat.
4
+ export const UNSTATED_QUOTA_WAIT_MS = 15_000;
3
5
  // Waits per model before it counts as out of quota for the rest of the run.
4
6
  export const QUOTA_RETRIES = 3;
5
7
  const QUOTA_MESSAGE = /exceeded your current quota|quota exceeded|resource[_ ]exhausted|rate limit/i;
6
8
  const RETRY_IN = /retry in ([\d.]+)\s*(ms|s)\b/i;
7
9
  const RETRY_DELAY = /"retryDelay"\s*:\s*"([\d.]+)s"/i;
8
- const DAILY = /per ?day|daily/i;
10
+ const DAILY = /per[- ]?day|daily/i;
9
11
  export function parseQuotaError(message, statusCode) {
10
12
  if (statusCode !== 429 && !QUOTA_MESSAGE.test(message))
11
13
  return undefined;
@@ -35,4 +37,3 @@ export function sleep(ms, signal) {
35
37
  signal.addEventListener("abort", done, { once: true });
36
38
  });
37
39
  }
38
- //# sourceMappingURL=quota.js.map
@@ -2,4 +2,3 @@ import type { ToolDefinition } from "../plugin/types.js";
2
2
  export declare const MAX_LINE_CHARS = 2000;
3
3
  export declare const MAX_RESULT_CHARS = 50000;
4
4
  export declare const reviewTools: readonly ToolDefinition[];
5
- //# sourceMappingURL=tools.d.ts.map
@@ -91,6 +91,16 @@ const codeSearch = {
91
91
  return promptData(shown.join("\n"));
92
92
  },
93
93
  };
94
+ const readLearning = {
95
+ name: REVIEW_TOOLS.readLearning,
96
+ description: "Read a team learning listed in <ocra_learning_index> by its id: its title and what to check.",
97
+ inputSchema: z.object({ id: z.string().min(1) }),
98
+ async execute(args, context) {
99
+ const { id } = args;
100
+ const learning = context.readLearning?.(id);
101
+ return promptData(learning ?? `No learning with id ${id}.`);
102
+ },
103
+ };
94
104
  const reportFinding = {
95
105
  name: REVIEW_TOOLS.reportFinding,
96
106
  description: "Report one confirmed defect. Call once per issue.",
@@ -107,7 +117,7 @@ export const reviewTools = [
107
117
  readFile,
108
118
  readDiff,
109
119
  codeSearch,
120
+ readLearning,
110
121
  reportFinding,
111
122
  taskDone,
112
123
  ];
113
- //# sourceMappingURL=tools.js.map
@@ -0,0 +1,6 @@
1
+ import type { AttemptEnding, AttemptOutcome, TaskAttempt } from "./attempt.js";
2
+ type WrapUp = NonNullable<TaskAttempt["wrapUp"]>;
3
+ export declare function pendingWrapUp(attempt: TaskAttempt, ended: AttemptEnding, signal: AbortSignal): WrapUp | undefined;
4
+ export declare function wrapUp(before: AttemptOutcome, turn: WrapUp): Promise<AttemptOutcome>;
5
+ export declare function outcomeOf(attempt: TaskAttempt): AttemptOutcome;
6
+ export {};