@open-cr-agent/core 0.6.0 → 0.7.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.
- package/README.md +1 -1
- package/dist/agent/budget.d.ts +0 -1
- package/dist/agent/budget.js +0 -1
- package/dist/agent/json.d.ts +0 -1
- package/dist/agent/json.js +0 -1
- package/dist/agent/pool.d.ts +0 -1
- package/dist/agent/pool.js +0 -1
- package/dist/agent/settings.d.ts +0 -1
- package/dist/agent/settings.js +0 -1
- package/dist/agent/usage.d.ts +0 -1
- package/dist/agent/usage.js +0 -1
- package/dist/anchor/anchor.d.ts +0 -1
- package/dist/anchor/anchor.js +0 -1
- package/dist/anchor/match.d.ts +0 -1
- package/dist/anchor/match.js +0 -1
- package/dist/anchor/relocate.d.ts +0 -1
- package/dist/anchor/relocate.js +0 -1
- package/dist/at.d.ts +0 -1
- package/dist/at.js +0 -1
- package/dist/bounded-file.d.ts +12 -0
- package/dist/bounded-file.js +47 -0
- package/dist/bundle/bundle.d.ts +0 -1
- package/dist/bundle/bundle.js +0 -1
- package/dist/bundle/grouping.d.ts +0 -1
- package/dist/bundle/grouping.js +0 -1
- package/dist/bundle/runtime-grouper.d.ts +0 -1
- package/dist/bundle/runtime-grouper.js +0 -1
- package/dist/contracts.d.ts +10 -1
- package/dist/contracts.js +4 -1
- package/dist/diff/hunks.d.ts +0 -1
- package/dist/diff/hunks.js +0 -1
- package/dist/diff/parse.d.ts +0 -1
- package/dist/diff/parse.js +0 -1
- package/dist/diff/quoted-path.d.ts +0 -1
- package/dist/diff/quoted-path.js +0 -1
- package/dist/domain.d.ts +4 -1
- package/dist/domain.js +0 -1
- package/dist/errors.d.ts +0 -1
- package/dist/errors.js +0 -1
- package/dist/hash.d.ts +0 -1
- package/dist/hash.js +0 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -3
- package/dist/internal.d.ts +3 -3
- package/dist/internal.js +2 -2
- package/dist/judge/judge.d.ts +0 -1
- package/dist/judge/judge.js +0 -1
- package/dist/judge/prompt.d.ts +0 -1
- package/dist/judge/prompt.js +0 -1
- package/dist/judge/verdict.d.ts +0 -1
- package/dist/judge/verdict.js +0 -1
- package/dist/memory/memory.d.ts +0 -1
- package/dist/memory/memory.js +0 -1
- package/dist/net/proxied-fetch.d.ts +0 -1
- package/dist/net/proxied-fetch.js +0 -1
- package/dist/pipeline/assemble-report.d.ts +0 -1
- package/dist/pipeline/assemble-report.js +0 -1
- package/dist/pipeline/check-stage.d.ts +0 -1
- package/dist/pipeline/check-stage.js +0 -1
- package/dist/pipeline/context.d.ts +0 -1
- package/dist/pipeline/context.js +8 -5
- package/dist/pipeline/coverage.d.ts +0 -1
- package/dist/pipeline/coverage.js +37 -17
- package/dist/pipeline/execute-stage.d.ts +0 -1
- package/dist/pipeline/execute-stage.js +29 -3
- package/dist/pipeline/execute.d.ts +9 -2
- package/dist/pipeline/execute.js +90 -9
- package/dist/pipeline/filter-stage.d.ts +0 -1
- package/dist/pipeline/filter-stage.js +0 -1
- package/dist/pipeline/findings.d.ts +0 -1
- package/dist/pipeline/findings.js +0 -1
- package/dist/pipeline/imports.d.ts +0 -1
- package/dist/pipeline/imports.js +0 -1
- package/dist/pipeline/matrix.d.ts +0 -1
- package/dist/pipeline/matrix.js +0 -1
- package/dist/pipeline/options.d.ts +2 -1
- package/dist/pipeline/options.js +0 -1
- package/dist/pipeline/plan-output.d.ts +0 -1
- package/dist/pipeline/plan-output.js +0 -1
- package/dist/pipeline/plan.d.ts +1 -2
- package/dist/pipeline/plan.js +6 -2
- package/dist/pipeline/preview.d.ts +0 -1
- package/dist/pipeline/preview.js +0 -1
- package/dist/pipeline/provenance.d.ts +0 -1
- package/dist/pipeline/provenance.js +0 -1
- package/dist/pipeline/resume.d.ts +22 -0
- package/dist/pipeline/resume.js +24 -0
- package/dist/pipeline/run-id.d.ts +0 -1
- package/dist/pipeline/run-id.js +0 -1
- package/dist/pipeline/run.d.ts +0 -1
- package/dist/pipeline/run.js +0 -1
- package/dist/pipeline/task.d.ts +5 -8
- package/dist/pipeline/task.js +8 -6
- package/dist/plugin/builtin.d.ts +1 -1
- package/dist/plugin/builtin.js +12 -3
- package/dist/plugin/host.d.ts +0 -1
- package/dist/plugin/host.js +0 -1
- package/dist/plugin/registry.d.ts +0 -1
- package/dist/plugin/registry.js +0 -1
- package/dist/plugin/types.d.ts +0 -1
- package/dist/plugin/types.js +0 -1
- package/dist/report/output-schema.d.ts +39 -1
- package/dist/report/output-schema.js +10 -3
- package/dist/report/output.d.ts +0 -1
- package/dist/report/output.js +7 -4
- package/dist/report/provenance.d.ts +0 -1
- package/dist/report/provenance.js +0 -1
- package/dist/report/read.d.ts +0 -1
- package/dist/report/read.js +5 -3
- package/dist/report/report.d.ts +26 -3
- package/dist/report/report.js +11 -3
- package/dist/report/serialize.d.ts +0 -1
- package/dist/report/serialize.js +0 -1
- package/dist/rereview/presence.d.ts +0 -1
- package/dist/rereview/presence.js +0 -1
- package/dist/rereview/quote.d.ts +0 -1
- package/dist/rereview/quote.js +0 -1
- package/dist/rereview/reconcile.d.ts +0 -1
- package/dist/rereview/reconcile.js +0 -1
- package/dist/review/impact.d.ts +0 -1
- package/dist/review/impact.js +0 -1
- package/dist/review/plan-phase.d.ts +0 -1
- package/dist/review/plan-phase.js +0 -1
- package/dist/review/prompt-text.d.ts +0 -1
- package/dist/review/prompt-text.js +0 -1
- package/dist/review/prompt.d.ts +0 -1
- package/dist/review/prompt.js +0 -1
- package/dist/review/reviewer.d.ts +0 -1
- package/dist/review/reviewer.js +0 -1
- package/dist/review/reviewers/agents-md.d.ts +0 -1
- package/dist/review/reviewers/agents-md.js +0 -1
- package/dist/review/reviewers/correctness.d.ts +0 -1
- package/dist/review/reviewers/correctness.js +0 -1
- package/dist/review/reviewers/docs.d.ts +0 -1
- package/dist/review/reviewers/docs.js +0 -1
- package/dist/review/reviewers/performance.d.ts +0 -1
- package/dist/review/reviewers/performance.js +0 -1
- package/dist/review/reviewers/scopes.d.ts +0 -1
- package/dist/review/reviewers/scopes.js +0 -1
- package/dist/review/reviewers/security.d.ts +0 -1
- package/dist/review/reviewers/security.js +0 -1
- package/dist/review/tools.d.ts +0 -1
- package/dist/review/tools.js +0 -1
- package/dist/rules/builtin/general.d.ts +0 -1
- package/dist/rules/builtin/general.js +0 -1
- package/dist/rules/builtin/go.d.ts +0 -1
- package/dist/rules/builtin/go.js +0 -1
- package/dist/rules/builtin/index.d.ts +0 -1
- package/dist/rules/builtin/index.js +0 -1
- package/dist/rules/builtin/java.d.ts +0 -1
- package/dist/rules/builtin/java.js +0 -1
- package/dist/rules/builtin/performance.d.ts +0 -1
- package/dist/rules/builtin/performance.js +0 -1
- package/dist/rules/builtin/python.d.ts +0 -1
- package/dist/rules/builtin/python.js +0 -1
- package/dist/rules/builtin/security.d.ts +0 -1
- package/dist/rules/builtin/security.js +0 -1
- package/dist/rules/builtin/typescript.d.ts +0 -1
- package/dist/rules/builtin/typescript.js +0 -1
- package/dist/rules/languages.d.ts +0 -1
- package/dist/rules/languages.js +0 -1
- package/dist/rules/repo-rules.d.ts +0 -1
- package/dist/rules/repo-rules.js +0 -1
- package/dist/rules/resolve.d.ts +0 -1
- package/dist/rules/resolve.js +0 -1
- package/dist/rules/rule-set.d.ts +0 -1
- package/dist/rules/rule-set.js +0 -1
- package/dist/runtime/attempt.d.ts +15 -2
- package/dist/runtime/attempt.js +47 -1
- package/dist/runtime/chain-runner.d.ts +0 -1
- package/dist/runtime/chain-runner.js +0 -1
- package/dist/runtime/effort-capability.d.ts +0 -1
- package/dist/runtime/effort-capability.js +0 -1
- package/dist/runtime/failback.d.ts +0 -1
- package/dist/runtime/failback.js +38 -9
- package/dist/runtime/models.d.ts +0 -1
- package/dist/runtime/models.js +14 -13
- package/dist/runtime/quota.d.ts +1 -1
- package/dist/runtime/quota.js +3 -2
- package/dist/runtime/tools.d.ts +0 -1
- package/dist/runtime/tools.js +0 -1
- package/dist/sarif/candidates.d.ts +0 -1
- package/dist/sarif/candidates.js +0 -1
- package/dist/sarif/schema.d.ts +0 -1
- package/dist/sarif/schema.js +0 -1
- package/dist/select/patterns.d.ts +0 -1
- package/dist/select/patterns.js +0 -1
- package/dist/select/select.d.ts +1 -1
- package/dist/select/select.js +16 -3
- package/dist/session/jsonl.d.ts +2 -2
- package/dist/session/jsonl.js +9 -4
- package/dist/session/resume-read.d.ts +2 -0
- package/dist/session/resume-read.js +128 -0
- package/dist/session/seal.d.ts +5 -0
- package/dist/session/seal.js +24 -0
- package/dist/triage.d.ts +0 -1
- package/dist/triage.js +0 -1
- package/dist/vcs.d.ts +0 -1
- package/dist/vcs.js +0 -1
- package/dist/verify/prompt.d.ts +0 -1
- package/dist/verify/prompt.js +0 -1
- package/dist/verify/verify.d.ts +0 -1
- package/dist/verify/verify.js +0 -1
- package/package.json +1 -1
|
@@ -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
|
package/dist/rules/builtin/go.js
CHANGED
|
@@ -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
|
|
@@ -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
|
package/dist/rules/languages.js
CHANGED
package/dist/rules/repo-rules.js
CHANGED
package/dist/rules/resolve.d.ts
CHANGED
package/dist/rules/resolve.js
CHANGED
package/dist/rules/rule-set.d.ts
CHANGED
package/dist/rules/rule-set.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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;
|
|
@@ -9,6 +9,9 @@ export interface AttemptOutcome {
|
|
|
9
9
|
toolCalls: string[];
|
|
10
10
|
text: string;
|
|
11
11
|
resumed?: true;
|
|
12
|
+
atStepCap?: true;
|
|
13
|
+
read?: string[];
|
|
14
|
+
searched?: string[];
|
|
12
15
|
usage: Usage;
|
|
13
16
|
error?: AttemptError;
|
|
14
17
|
}
|
|
@@ -19,4 +22,14 @@ export interface AttemptError {
|
|
|
19
22
|
}
|
|
20
23
|
export declare function attemptSummary(model: string, outcome: AttemptOutcome): string;
|
|
21
24
|
export declare function toolSummary(toolCalls: readonly string[]): string;
|
|
22
|
-
|
|
25
|
+
export type AttemptEnding = "done" | IncompleteEnding | "error";
|
|
26
|
+
export declare function attemptEnding(outcome: AttemptOutcome): AttemptEnding;
|
|
27
|
+
export interface ToolUse {
|
|
28
|
+
name: string;
|
|
29
|
+
input: unknown;
|
|
30
|
+
}
|
|
31
|
+
export declare function exploredBy(uses: readonly ToolUse[]): {
|
|
32
|
+
read: string[];
|
|
33
|
+
searched: string[];
|
|
34
|
+
};
|
|
35
|
+
export declare function attemptRecord(model: string, outcome: AttemptOutcome): AttemptRecord;
|
package/dist/runtime/attempt.js
CHANGED
|
@@ -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
|
|
@@ -34,4 +35,49 @@ export function toolSummary(toolCalls) {
|
|
|
34
35
|
const finished = names.includes(REVIEW_TOOLS.taskDone) ? "" : "; no task_done";
|
|
35
36
|
return `${toolCalls.length} tool call(s) (${byUse.map(([n, c]) => `${n} ${c}`).join(", ")}${finished})`;
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
+
export function attemptEnding(outcome) {
|
|
39
|
+
if (outcome.error)
|
|
40
|
+
return "error";
|
|
41
|
+
if (outcome.toolCalls.includes(REVIEW_TOOLS.taskDone))
|
|
42
|
+
return "done";
|
|
43
|
+
return outcome.atStepCap ? "step_cap" : "stopped_early";
|
|
44
|
+
}
|
|
45
|
+
// A model chooses these strings, so the session log keeps a bounded number
|
|
46
|
+
// of bounded ones.
|
|
47
|
+
const MAX_EXPLORED = 200;
|
|
48
|
+
const MAX_EXPLORED_CHARS = 500;
|
|
49
|
+
const MAX_TEXT_CHARS = 4_000;
|
|
50
|
+
// The files an attempt read and what it searched for, from its tool calls.
|
|
51
|
+
export function exploredBy(uses) {
|
|
52
|
+
return {
|
|
53
|
+
read: distinct(uses, REVIEW_TOOLS.readFile, (input) => readInput.safeParse(input).data?.path),
|
|
54
|
+
searched: distinct(uses, REVIEW_TOOLS.codeSearch, (input) => searchInput.safeParse(input).data?.literal),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const readInput = z.object({ path: z.string() });
|
|
58
|
+
const searchInput = z.object({ literal: z.string() });
|
|
59
|
+
function distinct(uses, tool, pick) {
|
|
60
|
+
const values = new Set();
|
|
61
|
+
for (const use of uses) {
|
|
62
|
+
const value = use.name === tool ? pick(use.input) : undefined;
|
|
63
|
+
if (value !== undefined)
|
|
64
|
+
values.add(cut(value, MAX_EXPLORED_CHARS));
|
|
65
|
+
if (values.size >= MAX_EXPLORED)
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
return [...values];
|
|
69
|
+
}
|
|
70
|
+
export function attemptRecord(model, outcome) {
|
|
71
|
+
return {
|
|
72
|
+
model,
|
|
73
|
+
read: outcome.read ?? [],
|
|
74
|
+
searched: outcome.searched ?? [],
|
|
75
|
+
// The end of an answer is where a reviewer concludes.
|
|
76
|
+
text: outcome.text.length > MAX_TEXT_CHARS
|
|
77
|
+
? `…${outcome.text.slice(-MAX_TEXT_CHARS)}`
|
|
78
|
+
: outcome.text,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function cut(text, max) {
|
|
82
|
+
return text.length > max ? `${text.slice(0, max)}…` : text;
|
|
83
|
+
}
|
|
@@ -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
|
package/dist/runtime/failback.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
5
|
// Findings from a failed attempt are still emitted: the pipeline deduplicates
|
|
6
6
|
// by fingerprint, so a retry on the next model cannot double-report them.
|
|
@@ -18,10 +18,13 @@ export async function* withFailback(options) {
|
|
|
18
18
|
taskId,
|
|
19
19
|
message: `${model} is rate limited; waiting ${Math.ceil(pause / 1000)}s`,
|
|
20
20
|
};
|
|
21
|
-
await
|
|
21
|
+
await pauseOver(health, model, signal);
|
|
22
22
|
if (signal.aborted)
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
+
// Another task may have found it out of quota since the chain was read.
|
|
26
|
+
if (health.isOutOfQuota(model))
|
|
27
|
+
break;
|
|
25
28
|
yield { type: "progress", taskId, message: `reviewing with ${model}` };
|
|
26
29
|
// Spend is reported while the attempt runs, so a run's spend limit
|
|
27
30
|
// can stop it; the finished attempt's total settles the rest.
|
|
@@ -32,18 +35,27 @@ export async function* withFailback(options) {
|
|
|
32
35
|
yield { type: "usage", taskId, ...live.take() };
|
|
33
36
|
}
|
|
34
37
|
const outcome = await running;
|
|
38
|
+
const ended = attemptEnding(outcome);
|
|
35
39
|
yield { type: "usage", taskId, ...live.rest(outcome.usage) };
|
|
36
|
-
yield {
|
|
40
|
+
yield {
|
|
41
|
+
type: "progress",
|
|
42
|
+
taskId,
|
|
43
|
+
message: attemptSummary(model, outcome),
|
|
44
|
+
attempt: attemptRecord(model, outcome),
|
|
45
|
+
};
|
|
37
46
|
for (const finding of outcome.findings)
|
|
38
47
|
yield { type: "finding", taskId, finding, model };
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
// Ended without an error, the attempt finished even if the task was
|
|
49
|
+
// stopped meanwhile, as when the spend its last report added reached
|
|
50
|
+
// the run's limit: the pipeline decides what that stop means.
|
|
42
51
|
if (!outcome.error) {
|
|
43
52
|
health.recordSuccess(model);
|
|
44
|
-
yield
|
|
53
|
+
yield doneEvent(taskId, ended);
|
|
45
54
|
return;
|
|
46
55
|
}
|
|
56
|
+
// A cancelled attempt is neither finished nor the model's fault.
|
|
57
|
+
if (signal.aborted)
|
|
58
|
+
return;
|
|
47
59
|
if (!outcome.error.retryable) {
|
|
48
60
|
yield {
|
|
49
61
|
type: "error",
|
|
@@ -72,6 +84,11 @@ export async function* withFailback(options) {
|
|
|
72
84
|
retryable: true,
|
|
73
85
|
};
|
|
74
86
|
}
|
|
87
|
+
function doneEvent(taskId, ended) {
|
|
88
|
+
return ended === "step_cap" || ended === "stopped_early"
|
|
89
|
+
? { type: "done", taskId, ended }
|
|
90
|
+
: { type: "done", taskId };
|
|
91
|
+
}
|
|
75
92
|
// Hands out what an attempt has spent in increments, each what grew since the
|
|
76
93
|
// last one; `rest` settles the finished attempt's total, so the increments
|
|
77
94
|
// add up to it and nothing is counted twice.
|
|
@@ -141,9 +158,11 @@ export async function completeWithFailback(options) {
|
|
|
141
158
|
let lastError = "";
|
|
142
159
|
for (const model of health.order(options.chain)) {
|
|
143
160
|
for (;;) {
|
|
144
|
-
await
|
|
161
|
+
await pauseOver(health, model, signal);
|
|
145
162
|
if (signal.aborted)
|
|
146
163
|
throw new CompletionError("cancelled", usage);
|
|
164
|
+
if (health.isOutOfQuota(model))
|
|
165
|
+
break;
|
|
147
166
|
const outcome = await options.attempt(model);
|
|
148
167
|
usage = addUsage(usage, outcome.usage);
|
|
149
168
|
if (!outcome.error) {
|
|
@@ -167,9 +186,19 @@ export async function completeWithFailback(options) {
|
|
|
167
186
|
}
|
|
168
187
|
throw new CompletionError(`every ${chainName(options)} failed (${lastError})`, usage);
|
|
169
188
|
}
|
|
189
|
+
// Waits until the model's pause ends as it stands on waking, not as it stood
|
|
190
|
+
// on falling asleep: another task's limit may have lengthened it, and a
|
|
191
|
+
// request sent inside it would only join it again.
|
|
192
|
+
async function pauseOver(health, model, signal) {
|
|
193
|
+
for (;;) {
|
|
194
|
+
const pause = health.pausedFor(model);
|
|
195
|
+
if (pause <= 0 || signal.aborted || health.isOutOfQuota(model))
|
|
196
|
+
return;
|
|
197
|
+
await sleep(pause, signal);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
170
200
|
function chainName(options) {
|
|
171
201
|
return options.agent === undefined
|
|
172
202
|
? `${options.tier} model`
|
|
173
203
|
: `model of ${options.agent}'s own chain`;
|
|
174
204
|
}
|
|
175
|
-
//# sourceMappingURL=failback.js.map
|
package/dist/runtime/models.d.ts
CHANGED
package/dist/runtime/models.js
CHANGED
|
@@ -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
|
|
77
|
-
//
|
|
78
|
-
//
|
|
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
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
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
|
package/dist/runtime/quota.d.ts
CHANGED
|
@@ -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
|
package/dist/runtime/quota.js
CHANGED
|
@@ -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
|
package/dist/runtime/tools.d.ts
CHANGED
package/dist/runtime/tools.js
CHANGED
package/dist/sarif/candidates.js
CHANGED
package/dist/sarif/schema.d.ts
CHANGED
package/dist/sarif/schema.js
CHANGED
package/dist/select/patterns.js
CHANGED
package/dist/select/select.d.ts
CHANGED
|
@@ -25,5 +25,5 @@ export interface SelectionPolicy {
|
|
|
25
25
|
}
|
|
26
26
|
export declare const defaultSelectionPolicy: SelectionPolicy;
|
|
27
27
|
export declare function isSecretPath(path: string): boolean;
|
|
28
|
+
export declare function foldPath(path: string): string;
|
|
28
29
|
export declare function selectFiles(diffs: readonly FileDiff[], policy?: SelectionPolicy): FileDecision[];
|
|
29
|
-
//# sourceMappingURL=select.d.ts.map
|
package/dist/select/select.js
CHANGED
|
@@ -20,8 +20,22 @@ const isSecret = picomatch(SECRET_PATTERNS, { ...globOptions, ignore: ENV_TEMPLA
|
|
|
20
20
|
const isGenerated = picomatch(GENERATED_PATTERNS, globOptions);
|
|
21
21
|
const isMigration = picomatch(MIGRATION_PATTERNS, globOptions);
|
|
22
22
|
const nonReviewableExtensions = new Set(NON_REVIEWABLE_EXTENSIONS);
|
|
23
|
+
// The raw path is matched too: NFKC can fold a character into "/", which a
|
|
24
|
+
// pattern's "*" matches only in the raw path.
|
|
23
25
|
export function isSecretPath(path) {
|
|
24
|
-
return isSecret(path);
|
|
26
|
+
return isSecret(path) || isSecret(foldPath(path));
|
|
27
|
+
}
|
|
28
|
+
const IGNORABLE = /\p{Default_Ignorable_Code_Point}/gu;
|
|
29
|
+
// A case-insensitive file system opens a file under any name that folds to
|
|
30
|
+
// the same as its own. APFS normalizes and applies full Unicode case folding,
|
|
31
|
+
// so a Kelvin sign opens "k", a long s "s", "ß" "ss" and a ligature its
|
|
32
|
+
// letters; HFS+ also skips some invisible characters. The access policy
|
|
33
|
+
// compares this form, which folds the ASCII names it refuses at least as far,
|
|
34
|
+
// so that no spelling of such a name passes. NFKC takes the Kelvin sign, the
|
|
35
|
+
// long s and ligatures to ASCII; upper-casing expands "ß" (and "ẞ", once
|
|
36
|
+
// lower-cased), which lower-casing keeps.
|
|
37
|
+
export function foldPath(path) {
|
|
38
|
+
return path.normalize("NFKC").replace(IGNORABLE, "").toLowerCase().toUpperCase().toLowerCase();
|
|
25
39
|
}
|
|
26
40
|
export function selectFiles(diffs, policy = defaultSelectionPolicy) {
|
|
27
41
|
const isUserExcluded = matcher(policy.exclude);
|
|
@@ -35,7 +49,7 @@ function exclusionReason(diff, policy, isUserExcluded, isUserIncluded) {
|
|
|
35
49
|
const path = diff.newPath;
|
|
36
50
|
if (diff.isBinary)
|
|
37
51
|
return "binary";
|
|
38
|
-
if (
|
|
52
|
+
if (isSecretPath(diff.oldPath) || isSecretPath(path))
|
|
39
53
|
return "secret";
|
|
40
54
|
if (diff.kind === "deleted")
|
|
41
55
|
return "deleted";
|
|
@@ -59,4 +73,3 @@ function extension(path) {
|
|
|
59
73
|
const dot = name.lastIndexOf(".");
|
|
60
74
|
return dot > 0 ? name.slice(dot + 1).toLowerCase() : "";
|
|
61
75
|
}
|
|
62
|
-
//# sourceMappingURL=select.js.map
|
package/dist/session/jsonl.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const REPORT_FILE = "report.json";
|
|
|
4
4
|
export declare class JsonlSessionWriter {
|
|
5
5
|
readonly dir: string;
|
|
6
6
|
readonly id: string;
|
|
7
|
-
|
|
7
|
+
private readonly sealKey;
|
|
8
|
+
constructor(sessionsDir: string, id?: string, sealKey?: string);
|
|
8
9
|
write(event: ReviewEvent): void;
|
|
9
10
|
}
|
|
10
|
-
//# sourceMappingURL=jsonl.d.ts.map
|
package/dist/session/jsonl.js
CHANGED
|
@@ -4,15 +4,20 @@ import { isNotFound, OcraError } from "../errors.js";
|
|
|
4
4
|
import { newRunId } from "../pipeline/run-id.js";
|
|
5
5
|
import { toReportOutput } from "../report/output.js";
|
|
6
6
|
import { serializeOutput } from "../report/serialize.js";
|
|
7
|
+
import { sealLine } from "./seal.js";
|
|
7
8
|
export const EVENTS_FILE = "events.jsonl";
|
|
8
9
|
export const REPORT_FILE = "report.json";
|
|
9
10
|
// Events are appended synchronously, one JSON object per line, so the log
|
|
10
|
-
// stays valid and ordered even if the process dies mid-run.
|
|
11
|
+
// stays valid and ordered even if the process dies mid-run. With a seal key
|
|
12
|
+
// (this machine's, seal.ts), each line is sealed so that --resume can tell
|
|
13
|
+
// it from a line a change brought into the tree.
|
|
11
14
|
export class JsonlSessionWriter {
|
|
12
15
|
dir;
|
|
13
16
|
id;
|
|
14
|
-
|
|
17
|
+
sealKey;
|
|
18
|
+
constructor(sessionsDir, id = newRunId(), sealKey) {
|
|
15
19
|
this.id = id;
|
|
20
|
+
this.sealKey = sealKey;
|
|
16
21
|
// The sessions directory lives in the reviewed tree, which may carry
|
|
17
22
|
// links planted to send the logs, or the .gitignore write, elsewhere.
|
|
18
23
|
for (const dir of [dirname(sessionsDir), sessionsDir])
|
|
@@ -30,7 +35,8 @@ export class JsonlSessionWriter {
|
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
write(event) {
|
|
33
|
-
const
|
|
38
|
+
const serialized = serializeOutput({ time: new Date().toISOString(), ...event }, 0);
|
|
39
|
+
const line = this.sealKey ? sealLine(this.sealKey, this.id, serialized) : serialized;
|
|
34
40
|
appendFileSync(join(this.dir, EVENTS_FILE), `${line}\n`);
|
|
35
41
|
if (event.type === "run_finished") {
|
|
36
42
|
const report = toReportOutput(event.report);
|
|
@@ -49,4 +55,3 @@ function refuseSymlink(path) {
|
|
|
49
55
|
throw error;
|
|
50
56
|
}
|
|
51
57
|
}
|
|
52
|
-
//# sourceMappingURL=jsonl.js.map
|