@andorra-labs/code 0.1.16 → 0.1.18
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/dist/src/acp-agent.d.ts +6 -0
- package/dist/src/acp-agent.js +15 -4
- package/dist/src/agent-execution.js +108 -19
- package/dist/src/agent-mcp-catalog.js +1 -0
- package/dist/src/agent-mcp.d.ts +3 -0
- package/dist/src/agent-mcp.js +33 -1
- package/dist/src/andorra/entry.d.ts +10 -0
- package/dist/src/andorra/entry.js +18 -4
- package/dist/src/andorra/errors.js +3 -0
- package/dist/src/andorra/hosted.d.ts +2 -1
- package/dist/src/andorra/hosted.js +2 -1
- package/dist/src/andorra/notices.d.ts +5 -0
- package/dist/src/andorra/notices.js +7 -0
- package/dist/src/andorra/state.d.ts +3 -2
- package/dist/src/andorra/state.js +4 -4
- package/dist/src/andorra/terminal.js +7 -2
- package/dist/src/anthropic-credentials.js +2 -0
- package/dist/src/app-server/error.d.ts +5 -0
- package/dist/src/app-server/error.js +7 -0
- package/dist/src/app-server/protocol.d.ts +30 -44
- package/dist/src/app-server/protocol.js +5 -1
- package/dist/src/app-server/workspace.d.ts +108 -0
- package/dist/src/app-server/workspace.js +608 -11
- package/dist/src/app-server.d.ts +390 -33
- package/dist/src/app-server.js +3033 -565
- package/dist/src/attachments.d.ts +10 -0
- package/dist/src/attachments.js +102 -7
- package/dist/src/automation-tool.js +2 -1
- package/dist/src/bridge/cloud.d.ts +27 -0
- package/dist/src/bridge/cloud.js +187 -0
- package/dist/src/bridge/command.d.ts +30 -0
- package/dist/src/bridge/command.js +359 -0
- package/dist/src/bridge/control.d.ts +70 -0
- package/dist/src/bridge/control.js +238 -0
- package/dist/src/bridge/engines.d.ts +90 -0
- package/dist/src/bridge/engines.js +601 -0
- package/dist/src/bridge/github.d.ts +108 -0
- package/dist/src/bridge/github.js +378 -0
- package/dist/src/bridge/host-ops.d.ts +9 -0
- package/dist/src/bridge/host-ops.js +139 -0
- package/dist/src/bridge/host.d.ts +47 -0
- package/dist/src/bridge/host.js +543 -0
- package/dist/src/bridge/link.d.ts +38 -0
- package/dist/src/bridge/link.js +508 -0
- package/dist/src/bridge/login-link.d.ts +29 -0
- package/dist/src/bridge/login-link.js +54 -0
- package/dist/src/bridge/protocol.d.ts +136 -0
- package/dist/src/bridge/protocol.js +11 -0
- package/dist/src/bridge/store.d.ts +12 -0
- package/dist/src/bridge/store.js +61 -0
- package/dist/src/bridge/wording.d.ts +6 -0
- package/dist/src/bridge/wording.js +10 -0
- package/dist/src/browser-server.js +7 -1
- package/dist/src/browser-ui/tokens.css +1 -1
- package/dist/src/bug-report-attachments.d.ts +48 -0
- package/dist/src/bug-report-attachments.js +327 -0
- package/dist/src/bug-report.d.ts +23 -3
- package/dist/src/bug-report.js +72 -9
- package/dist/src/change-authors.d.ts +41 -0
- package/dist/src/change-authors.js +146 -0
- package/dist/src/cli.d.ts +1 -3
- package/dist/src/cli.js +191 -35
- package/dist/src/codex-provider.js +1 -1
- package/dist/src/coding-tools.js +24 -17
- package/dist/src/command-screens.d.ts +6 -0
- package/dist/src/command-screens.js +14 -11
- package/dist/src/commands.d.ts +15 -3
- package/dist/src/commands.js +2 -1
- package/dist/src/compaction-phrases.js +1 -1
- package/dist/src/completion.js +89 -8
- package/dist/src/config.d.ts +71 -3
- package/dist/src/config.js +205 -78
- package/dist/src/context-budget.js +15 -2
- package/dist/src/deadline.js +13 -1
- package/dist/src/decision/DecisionEngine.d.ts +2 -0
- package/dist/src/decision/DecisionManager.d.ts +11 -0
- package/dist/src/decision/DecisionManager.js +36 -0
- package/dist/src/decision/applyTaskKind.d.ts +8 -0
- package/dist/src/decision/applyTaskKind.js +53 -0
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/hostedPolicy.js +2 -1
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +2 -0
- package/dist/src/decision/providers/AndorraDecisionProvider.js +12 -0
- package/dist/src/decision/requestPhrases.js +0 -1
- package/dist/src/decision/taskKind.d.ts +52 -0
- package/dist/src/decision/taskKind.js +76 -0
- package/dist/src/decision/types.d.ts +1 -1
- package/dist/src/default-graph.js +1 -1
- package/dist/src/efficiency.d.ts +5 -0
- package/dist/src/efficiency.js +5 -1
- package/dist/src/effort-routing.d.ts +27 -0
- package/dist/src/effort-routing.js +34 -0
- package/dist/src/evidence.d.ts +110 -0
- package/dist/src/evidence.js +195 -0
- package/dist/src/file-diff.d.ts +4 -0
- package/dist/src/file-diff.js +2 -1
- package/dist/src/github-app/agent-writes.d.ts +102 -0
- package/dist/src/github-app/agent-writes.js +320 -0
- package/dist/src/github-app/client.d.ts +368 -0
- package/dist/src/github-app/client.js +830 -0
- package/dist/src/github-app/event-source.d.ts +208 -0
- package/dist/src/github-app/event-source.js +684 -0
- package/dist/src/github-app/metrics.d.ts +32 -0
- package/dist/src/github-app/metrics.js +49 -0
- package/dist/src/github-app/review-loop.d.ts +274 -0
- package/dist/src/github-app/review-loop.js +1177 -0
- package/dist/src/github-app/review-node.d.ts +81 -0
- package/dist/src/github-app/review-node.js +205 -0
- package/dist/src/github-app/review-post.d.ts +73 -0
- package/dist/src/github-app/review-post.js +139 -0
- package/dist/src/github-app/review-text.d.ts +107 -0
- package/dist/src/github-app/review-text.js +1133 -0
- package/dist/src/github-app/review-threads.d.ts +47 -0
- package/dist/src/github-app/review-threads.js +107 -0
- package/dist/src/github-app/reviewer.d.ts +121 -0
- package/dist/src/github-app/reviewer.js +598 -0
- package/dist/src/github-app/store.d.ts +59 -0
- package/dist/src/github-app/store.js +148 -0
- package/dist/src/github-app/triggers.d.ts +141 -0
- package/dist/src/github-app/triggers.js +441 -0
- package/dist/src/github-names.d.ts +15 -0
- package/dist/src/github-names.js +15 -0
- package/dist/src/glob-search.d.ts +61 -0
- package/dist/src/glob-search.js +180 -0
- package/dist/src/graph-health.js +6 -1
- package/dist/src/graph-manager-chat.js +1 -1
- package/dist/src/graph-preview.d.ts +48 -0
- package/dist/src/graph-preview.js +56 -0
- package/dist/src/graph-provider-portability.js +2 -1
- package/dist/src/graph-runner.js +65 -4
- package/dist/src/graph-server.js +7 -5
- package/dist/src/graph-sync.js +3 -3
- package/dist/src/graph-ui/app.js +121 -7
- package/dist/src/graph-ui/icons.js +2 -1
- package/dist/src/graph-ui/studio.js +15 -1
- package/dist/src/graph-ui/tokens.css +1 -1
- package/dist/src/graphs.d.ts +40 -1
- package/dist/src/graphs.js +164 -15
- package/dist/src/hardened-runtime.js +32 -21
- package/dist/src/image-input.d.ts +16 -0
- package/dist/src/image-input.js +41 -0
- package/dist/src/membership.d.ts +10 -0
- package/dist/src/membership.js +19 -4
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +6 -0
- package/dist/src/model-metadata.js +35 -15
- package/dist/src/model-override.d.ts +2 -1
- package/dist/src/model-override.js +9 -0
- package/dist/src/model-relay/local.d.ts +116 -0
- package/dist/src/model-relay/local.js +468 -0
- package/dist/src/model-relay/remote.d.ts +129 -0
- package/dist/src/model-relay/remote.js +252 -0
- package/dist/src/model-relay/runs.d.ts +34 -0
- package/dist/src/model-relay/runs.js +146 -0
- package/dist/src/model-relay/wire.d.ts +5 -0
- package/dist/src/model-relay/wire.js +5 -0
- package/dist/src/model-tiers.d.ts +3 -0
- package/dist/src/model-tiers.js +3 -3
- package/dist/src/project-registry.d.ts +21 -0
- package/dist/src/project-registry.js +74 -0
- package/dist/src/provider-engine.d.ts +13 -1
- package/dist/src/provider-engine.js +74 -0
- package/dist/src/provider-import.d.ts +0 -12
- package/dist/src/provider-import.js +7 -195
- package/dist/src/providers.d.ts +28 -2
- package/dist/src/providers.js +59 -12
- package/dist/src/pull-request-logs.d.ts +12 -1
- package/dist/src/pull-request-logs.js +14 -3
- package/dist/src/pull-requests.d.ts +338 -8
- package/dist/src/pull-requests.js +482 -53
- package/dist/src/react-runtime.js +99 -16
- package/dist/src/remote/engine-pool.d.ts +88 -4
- package/dist/src/remote/engine-pool.js +367 -90
- package/dist/src/remote/roots.d.ts +19 -0
- package/dist/src/remote/roots.js +45 -7
- package/dist/src/remote/types.d.ts +0 -44
- package/dist/src/run-control.d.ts +7 -0
- package/dist/src/run-control.js +23 -0
- package/dist/src/run-records.d.ts +7 -2
- package/dist/src/run-records.js +71 -6
- package/dist/src/runtime.d.ts +34 -2
- package/dist/src/runtime.js +18 -2
- package/dist/src/session-changes.d.ts +35 -0
- package/dist/src/session-changes.js +194 -6
- package/dist/src/session-monitor.js +2 -1
- package/dist/src/session-reaper.d.ts +1 -1
- package/dist/src/session-reaper.js +6 -1
- package/dist/src/session-summary.d.ts +2 -1
- package/dist/src/session-summary.js +2 -1
- package/dist/src/sessions.d.ts +35 -1
- package/dist/src/sessions.js +70 -4
- package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
- package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
- package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
- package/dist/src/skills/bundled/provenance.json +3 -3
- package/dist/src/skills/runtime-skills.js +1 -1
- package/dist/src/task-checkout.d.ts +141 -0
- package/dist/src/task-checkout.js +558 -0
- package/dist/src/telemetry/emitter.d.ts +15 -0
- package/dist/src/telemetry/emitter.js +35 -1
- package/dist/src/telemetry/schema.d.ts +25 -2
- package/dist/src/telemetry/schema.js +52 -4
- package/dist/src/telemetry/surface.d.ts +2 -1
- package/dist/src/telemetry/surface.js +4 -1
- package/dist/src/terminal-ui.d.ts +1 -0
- package/dist/src/terminal-ui.js +10 -3
- package/dist/src/test-edit-guard.d.ts +37 -0
- package/dist/src/test-edit-guard.js +216 -3
- package/dist/src/thinking-level-detect.d.ts +11 -0
- package/dist/src/thinking-level-detect.js +47 -0
- package/dist/src/thinking-levels.d.ts +30 -0
- package/dist/src/thinking-levels.js +124 -0
- package/dist/src/timers.d.ts +3 -0
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/tools.js +59 -9
- package/dist/src/transcript.js +1 -1
- package/dist/src/types.d.ts +34 -0
- package/package.json +6 -1
- package/dist/src/remote/cert.d.ts +0 -11
- package/dist/src/remote/cert.js +0 -87
- package/dist/src/remote/client.d.ts +0 -119
- package/dist/src/remote/client.js +0 -544
- package/dist/src/remote/command.d.ts +0 -4
- package/dist/src/remote/command.js +0 -194
- package/dist/src/remote/errors.d.ts +0 -11
- package/dist/src/remote/errors.js +0 -14
- package/dist/src/remote/network.d.ts +0 -22
- package/dist/src/remote/network.js +0 -102
- package/dist/src/remote/pairing.d.ts +0 -63
- package/dist/src/remote/pairing.js +0 -299
- package/dist/src/remote/pem.d.ts +0 -2
- package/dist/src/remote/pem.js +0 -7
- package/dist/src/remote/serve.d.ts +0 -68
- package/dist/src/remote/serve.js +0 -244
- package/dist/src/remote/server.d.ts +0 -21
- package/dist/src/remote/server.js +0 -406
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { GitHubCoverage } from './client.js';
|
|
2
|
+
export interface GitHubWatchSummary {
|
|
3
|
+
/** How many minutes the window covers, 1 to 60: a window cut short by the engine closing is shorter. */
|
|
4
|
+
minutes: number;
|
|
5
|
+
/** Per coverage state: how many watched PRs were in it during the window, and how many gh calls the watcher made for them. */
|
|
6
|
+
coverage: {
|
|
7
|
+
state: GitHubCoverage;
|
|
8
|
+
prs: number;
|
|
9
|
+
calls: number;
|
|
10
|
+
}[];
|
|
11
|
+
/** Seconds from a code-review notice's time to the Auto-fix wake it caused, whole seconds. */
|
|
12
|
+
wakeLatencies: number[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Counts for product telemetry (ADR 0021, `github.watch`): gh calls per watched PR by coverage, and wake
|
|
16
|
+
* latency. Only numbers and coverage states are kept: no PR, repository or session leaves this object.
|
|
17
|
+
*/
|
|
18
|
+
export declare class GitHubWatchMetrics {
|
|
19
|
+
private readonly windowMs;
|
|
20
|
+
private started?;
|
|
21
|
+
private readonly prs;
|
|
22
|
+
private readonly calls;
|
|
23
|
+
private latencies;
|
|
24
|
+
constructor(windowMs?: number);
|
|
25
|
+
private begin;
|
|
26
|
+
watched(sessionId: string, coverage: GitHubCoverage, now: number): void;
|
|
27
|
+
call(sessionId: string, coverage: GitHubCoverage, now: number): void;
|
|
28
|
+
wake(latencyMs: number, now: number): void;
|
|
29
|
+
due(now: number): boolean;
|
|
30
|
+
/** The window so far, and a fresh one begun; undefined when no PR was watched in it. */
|
|
31
|
+
take(now: number): GitHubWatchSummary | undefined;
|
|
32
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const WINDOW_MS = 60 * 60_000;
|
|
2
|
+
const MAX_LATENCIES = 60;
|
|
3
|
+
const MAX_LATENCY_SECONDS = 86_400;
|
|
4
|
+
/**
|
|
5
|
+
* Counts for product telemetry (ADR 0021, `github.watch`): gh calls per watched PR by coverage, and wake
|
|
6
|
+
* latency. Only numbers and coverage states are kept: no PR, repository or session leaves this object.
|
|
7
|
+
*/
|
|
8
|
+
export class GitHubWatchMetrics {
|
|
9
|
+
windowMs;
|
|
10
|
+
started;
|
|
11
|
+
prs = new Map();
|
|
12
|
+
calls = new Map();
|
|
13
|
+
latencies = [];
|
|
14
|
+
constructor(windowMs = WINDOW_MS) {
|
|
15
|
+
this.windowMs = windowMs;
|
|
16
|
+
}
|
|
17
|
+
begin(now) { this.started ??= now; }
|
|
18
|
+
watched(sessionId, coverage, now) {
|
|
19
|
+
this.begin(now);
|
|
20
|
+
const set = this.prs.get(coverage) ?? new Set();
|
|
21
|
+
set.add(sessionId);
|
|
22
|
+
this.prs.set(coverage, set);
|
|
23
|
+
}
|
|
24
|
+
call(sessionId, coverage, now) {
|
|
25
|
+
this.watched(sessionId, coverage, now);
|
|
26
|
+
this.calls.set(coverage, (this.calls.get(coverage) ?? 0) + 1);
|
|
27
|
+
}
|
|
28
|
+
wake(latencyMs, now) {
|
|
29
|
+
this.begin(now);
|
|
30
|
+
if (this.latencies.length >= MAX_LATENCIES || !Number.isFinite(latencyMs))
|
|
31
|
+
return;
|
|
32
|
+
this.latencies.push(Math.max(0, Math.min(MAX_LATENCY_SECONDS, Math.round(latencyMs / 1000))));
|
|
33
|
+
}
|
|
34
|
+
due(now) { return this.started !== undefined && now - this.started >= this.windowMs; }
|
|
35
|
+
/** The window so far, and a fresh one begun; undefined when no PR was watched in it. */
|
|
36
|
+
take(now) {
|
|
37
|
+
const started = this.started;
|
|
38
|
+
const coverage = [...this.prs.entries()].map(([state, sessions]) => ({ state, prs: Math.min(sessions.size, 10_000), calls: this.calls.get(state) ?? 0 }));
|
|
39
|
+
const latencies = this.latencies;
|
|
40
|
+
this.started = undefined;
|
|
41
|
+
this.prs.clear();
|
|
42
|
+
this.calls.clear();
|
|
43
|
+
this.latencies = [];
|
|
44
|
+
if (started === undefined || coverage.length === 0)
|
|
45
|
+
return undefined;
|
|
46
|
+
const minutes = Math.max(1, Math.min(60, Math.ceil((now - started) / 60_000)));
|
|
47
|
+
return { minutes, coverage, wakeLatencies: latencies };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { type AutoFixWrites, type GhRunner, type ReviewLoopSettings, type ReviewLoopState, type SessionPullRequest } from '../pull-requests.js';
|
|
2
|
+
import type { GitHubAppClient, GitHubCoverage } from './client.js';
|
|
3
|
+
import { type ReviewLoopEnd } from './review-post.js';
|
|
4
|
+
import { prepareReviewWorkspace, runReviewer } from './reviewer.js';
|
|
5
|
+
/**
|
|
6
|
+
* The Andorra review loop for chat tasks (design/specs/andorra-review-loop.md, "Starting and running a loop"): when a
|
|
7
|
+
* round starts (R8), the round itself (review-check, the reviewer child, posting under the request-id rules), how a loop
|
|
8
|
+
* stops (R9), and the fixer's wake (R10).
|
|
9
|
+
*
|
|
10
|
+
* - Rounds start only in the process that holds the watcher's lease, the one that reads PRs and pulls the App's notices.
|
|
11
|
+
* Any process may end a loop (a switch-off, a dismiss), and the lease holder's round notices it at its next step.
|
|
12
|
+
* - Everything the loop knows is on the PR record, so another process, or this one after a restart, picks it up there:
|
|
13
|
+
* a round in `reviewing` starts again, one in `posting` resumes with the marker check, and a fixer that waits in
|
|
14
|
+
* await_review in another process is seen through `review.waiting`.
|
|
15
|
+
* - A round that is stopped (switch-off, shutdown) writes nothing more: whoever stopped it has written the end already,
|
|
16
|
+
* or the next lease holder resumes it.
|
|
17
|
+
*/
|
|
18
|
+
/** A graph round stopped because the engine is closing: the round stays as it is, and the run's resume takes it up. */
|
|
19
|
+
export declare class ReviewLoopStopping extends Error {
|
|
20
|
+
constructor();
|
|
21
|
+
}
|
|
22
|
+
export interface ReviewLoopEvent {
|
|
23
|
+
sessionId: string;
|
|
24
|
+
kind: 'round-started' | 'posted' | 'ended';
|
|
25
|
+
round: number;
|
|
26
|
+
rounds: number;
|
|
27
|
+
reason?: ReviewLoopEnd;
|
|
28
|
+
detail?: string;
|
|
29
|
+
url?: string;
|
|
30
|
+
blocking?: number;
|
|
31
|
+
nits?: number;
|
|
32
|
+
reviewerRun?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ReviewLoopDependencies {
|
|
35
|
+
home: string;
|
|
36
|
+
gh: GhRunner;
|
|
37
|
+
client: Pick<GitHubAppClient, 'review' | 'reviewCheck'>;
|
|
38
|
+
/** Whether this process holds the watcher's lease: only it starts rounds. */
|
|
39
|
+
holdsLease(): boolean;
|
|
40
|
+
/** The PR's GitHub App coverage, as the event source (or, in another process, the lease holder) last learned it. */
|
|
41
|
+
coverage(sessionId: string, pullRequest: SessionPullRequest): Promise<GitHubCoverage>;
|
|
42
|
+
/** Reads the session's PR now (the watcher's read, which keeps the head and the record current). */
|
|
43
|
+
readNow(sessionId: string): Promise<void>;
|
|
44
|
+
/** The head the watcher last read for the session. */
|
|
45
|
+
headSha(sessionId: string): string | undefined;
|
|
46
|
+
/** Whether a run of the session is open anywhere on the home, leaving out `except` (a run held in await_review). */
|
|
47
|
+
sessionBusy(sessionId: string, except?: string): Promise<boolean>;
|
|
48
|
+
/** Whether that run is still open, in this process or another. */
|
|
49
|
+
runOpen(runId: string): Promise<boolean>;
|
|
50
|
+
/** Whether that run stopped without finishing: its engine was killed or closed with it (not stopped by the person). */
|
|
51
|
+
runInterrupted(runId: string): Promise<boolean>;
|
|
52
|
+
/** The task's checkout, where the reviewer's worktree is added. */
|
|
53
|
+
workspace(sessionId: string): Promise<string | undefined>;
|
|
54
|
+
/** The config's default provider and model, for a loop and a PR record that name none. */
|
|
55
|
+
defaultModel(): Promise<{
|
|
56
|
+
provider: string;
|
|
57
|
+
model: string;
|
|
58
|
+
} | undefined>;
|
|
59
|
+
/** Who the fixer's replies post as, for the wake's account clause (the Auto-fix prompt's rule). */
|
|
60
|
+
writes(sessionId: string): Promise<AutoFixWrites>;
|
|
61
|
+
/**
|
|
62
|
+
* Hands the fixer its wake: into a run of the session waiting in await_review in this process (`heldBy` is that
|
|
63
|
+
* run), or as a wake the timers deliver as the next turn.
|
|
64
|
+
*/
|
|
65
|
+
wake(sessionId: string, prompt: string, pullRequest: SessionPullRequest): {
|
|
66
|
+
wakeId: string;
|
|
67
|
+
heldBy?: string;
|
|
68
|
+
};
|
|
69
|
+
/** Whether this process still holds that wake (armed, or being delivered). */
|
|
70
|
+
wakeArmed(wakeId: string): boolean;
|
|
71
|
+
cancelWake(sessionId: string, wakeId: string): void;
|
|
72
|
+
emitUpdated(sessionId: string, pullRequest: SessionPullRequest | null): void;
|
|
73
|
+
emitLoop(event: ReviewLoopEvent): void;
|
|
74
|
+
/** How many turns the task's history holds now, a running turn included, for the transcript's lines; undefined when unread. */
|
|
75
|
+
turns?(sessionId: string): Promise<number | undefined>;
|
|
76
|
+
log(level: 'info' | 'warn', detail: string): void;
|
|
77
|
+
prepareWorkspace?: typeof prepareReviewWorkspace;
|
|
78
|
+
runReviewer?: typeof runReviewer;
|
|
79
|
+
sweep?: () => Promise<number>;
|
|
80
|
+
newRequestId?: () => string;
|
|
81
|
+
sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
82
|
+
now?: () => number;
|
|
83
|
+
/** How often the loop looks at its records without a gh call (60 s). */
|
|
84
|
+
tickMs?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Whether the lease holder watches the PR records folder, so a change another engine process on this home made (the
|
|
87
|
+
* person's switch, a setting, a fixer's await_review) is looked at at once rather than at the next minute's look.
|
|
88
|
+
*/
|
|
89
|
+
watchRecords?: boolean;
|
|
90
|
+
/** The reviewer child's environment, on top of the engine's (the engine's home). */
|
|
91
|
+
reviewerEnv?: NodeJS.ProcessEnv;
|
|
92
|
+
}
|
|
93
|
+
export declare const REVIEW_LOOP_TICK_MS = 60000;
|
|
94
|
+
/** Rounds that fail this many times in a row (a gh read, the worktree, a marker check) end the loop `unavailable`. */
|
|
95
|
+
export declare const ROUND_CRASHES = 3;
|
|
96
|
+
/** GitHub shows a push about 2 seconds after it lands: a fixer's head that looks unchanged is read once more after this. */
|
|
97
|
+
export declare const HEAD_RECHECK_MS = 5000;
|
|
98
|
+
/** How long a round waits for coverage that is `pending` or `unavailable` before the loop ends `unavailable`. */
|
|
99
|
+
export declare const COVERAGE_WAIT_MS: number;
|
|
100
|
+
/** Why switching the review on, or a round, cannot go on for this coverage state. */
|
|
101
|
+
export declare function coverageRefusal(coverage: GitHubCoverage, pullRequest: Pick<SessionPullRequest, 'owner' | 'repo'>): string;
|
|
102
|
+
/** Whether a switch-on may go ahead with this coverage: covered, or lost for a moment (the round waits for it). */
|
|
103
|
+
export declare const coverageAllowsReview: (coverage: GitHubCoverage) => boolean;
|
|
104
|
+
/** The loop state after an end: off, with the reason, and none of the round's bookkeeping. */
|
|
105
|
+
export declare function endedReview(review: ReviewLoopState, reason: ReviewLoopEnd, at: string, detail?: string, afterTurns?: number): ReviewLoopState;
|
|
106
|
+
/**
|
|
107
|
+
* The record with the review settings applied: a switch-on starts a new loop (a fresh id, round 0, `waiting`, chat),
|
|
108
|
+
* a switch-off ends a running one `switched-off`. The caller has made the switch-on checks. Answers what changed.
|
|
109
|
+
*/
|
|
110
|
+
export declare function applyReviewSettings(current: SessionPullRequest, changes: ReviewLoopSettings, options: {
|
|
111
|
+
now: Date;
|
|
112
|
+
newLoop: () => string;
|
|
113
|
+
model?: {
|
|
114
|
+
provider: string;
|
|
115
|
+
model: string;
|
|
116
|
+
} | null;
|
|
117
|
+
afterTurns?: number;
|
|
118
|
+
}): {
|
|
119
|
+
next: SessionPullRequest;
|
|
120
|
+
switchedOn: boolean;
|
|
121
|
+
switchedOff: boolean;
|
|
122
|
+
};
|
|
123
|
+
/** The fixer's wake (R10). The text of a finding never enters it: the agent reads the review with gh. */
|
|
124
|
+
export declare function reviewFixPrompt(pullRequest: SessionPullRequest, input: {
|
|
125
|
+
loop: string;
|
|
126
|
+
round: number;
|
|
127
|
+
rounds: number;
|
|
128
|
+
reviewUrl: string;
|
|
129
|
+
inline: number;
|
|
130
|
+
summary: number;
|
|
131
|
+
writes: AutoFixWrites;
|
|
132
|
+
form?: 'chat' | 'graph';
|
|
133
|
+
}): string;
|
|
134
|
+
/**
|
|
135
|
+
* The fixer's turn is held in await_review: the run that took the wake started waiting after it took it. A wake handed
|
|
136
|
+
* straight into a wait leaves that wait's older marker behind until the wait clears it; that marker never counts.
|
|
137
|
+
*/
|
|
138
|
+
export declare function fixerHeld(review: ReviewLoopState): boolean;
|
|
139
|
+
export declare class ReviewLoopController {
|
|
140
|
+
private readonly deps;
|
|
141
|
+
private readonly inFlight;
|
|
142
|
+
private readonly queues;
|
|
143
|
+
private timer?;
|
|
144
|
+
private ticking?;
|
|
145
|
+
private leased;
|
|
146
|
+
private resuming?;
|
|
147
|
+
private stopped;
|
|
148
|
+
/** Aborted by `stop()`: a decision waiting out the head's recheck stops with it. */
|
|
149
|
+
private readonly stopping;
|
|
150
|
+
private readonly now;
|
|
151
|
+
private readonly sleep;
|
|
152
|
+
private readonly requestId;
|
|
153
|
+
constructor(deps: ReviewLoopDependencies);
|
|
154
|
+
start(): void;
|
|
155
|
+
/** Stops every round in flight (its reviewer child too) without ending a loop: the next lease holder resumes them. */
|
|
156
|
+
stop(): Promise<void>;
|
|
157
|
+
/** Every round and decision in flight, finished (for tests). */
|
|
158
|
+
settled(): Promise<void>;
|
|
159
|
+
roundInFlight(sessionId: string): boolean;
|
|
160
|
+
/** The watcher read the session's PR. */
|
|
161
|
+
pullRequestRead(sessionId: string, _pullRequest: SessionPullRequest): void;
|
|
162
|
+
/** A run of the session ended in this process. Only the run that took the loop's wake ends a round; the wake kind is a hint, never trusted alone. */
|
|
163
|
+
runEnded(sessionId: string, _runId: string, _wake?: string): void;
|
|
164
|
+
/** A run of the session started waiting in await_review. */
|
|
165
|
+
waitStarted(sessionId: string): void;
|
|
166
|
+
settingsChanged(sessionId: string): void;
|
|
167
|
+
/** This process took the watcher's lease: leftover worktrees are swept, then every loop is looked at, rounds resumed. */
|
|
168
|
+
leaseAcquired(): void;
|
|
169
|
+
/** The 60-second look over every running loop. Local state only: a gh call follows only when a round is due. */
|
|
170
|
+
tick(): Promise<void>;
|
|
171
|
+
private checkLease;
|
|
172
|
+
private watchedFolder?;
|
|
173
|
+
private readonly onFolder;
|
|
174
|
+
/** What each record's loop looked like when it was last looked at for a write: a write that changes none of it is not. */
|
|
175
|
+
private readonly seenLoops;
|
|
176
|
+
private nudging?;
|
|
177
|
+
private looking?;
|
|
178
|
+
private lookAgain;
|
|
179
|
+
/**
|
|
180
|
+
* Only rounds in the lease holder start, and an engine that runs a task (the desktop runs one per task) is often not
|
|
181
|
+
* the lease holder: the record is the only signal it can give. The folder's change time is polled (a stat, no
|
|
182
|
+
* inotify, which a busy machine can run out of); a record written there changes it.
|
|
183
|
+
*/
|
|
184
|
+
private watchRecords;
|
|
185
|
+
private unwatchRecords;
|
|
186
|
+
private nudge;
|
|
187
|
+
/** The folder changed: each loop whose record changed in what the loop's decisions read is looked at. */
|
|
188
|
+
private recordsChanged;
|
|
189
|
+
/** Whether a running loop has something to do now, from local state only. */
|
|
190
|
+
private due;
|
|
191
|
+
/** Looks at one session's loop: one decision at a time per session, and at most one round. */
|
|
192
|
+
consider(sessionId: string): Promise<void>;
|
|
193
|
+
private evaluate;
|
|
194
|
+
/** The PR's head now, as a round reads it; undefined (and logged) when gh cannot say. */
|
|
195
|
+
private headNow;
|
|
196
|
+
/**
|
|
197
|
+
* The fixer's wake armed again from the record: one no process holds any more (its engine stopped, or the timers were
|
|
198
|
+
* full), or, with `interrupted`, once more for a turn that its engine lost before it finished.
|
|
199
|
+
*/
|
|
200
|
+
private rearm;
|
|
201
|
+
/** The fixer's wake, or undefined when it cannot be armed now (the timers are full): the next look arms it. */
|
|
202
|
+
private armWake;
|
|
203
|
+
private heldFields;
|
|
204
|
+
private launch;
|
|
205
|
+
/** A round failed: counted on the record, and the loop ends `unavailable` after ROUND_CRASHES in a row. */
|
|
206
|
+
private crashed;
|
|
207
|
+
/**
|
|
208
|
+
* Changes the loop under the PR's lock, only while it is still this running loop: answers the written record, or
|
|
209
|
+
* undefined when the loop has ended or gone (the caller stops).
|
|
210
|
+
*/
|
|
211
|
+
/** The task's turn count for a transcript line; a read that fails leaves the line without one (shown at the end). */
|
|
212
|
+
private turns;
|
|
213
|
+
private update;
|
|
214
|
+
/** Ends a running loop: it is final, and switching on again starts a new one. Any process may end one. */
|
|
215
|
+
end(sessionId: string, loop: string, reason: ReviewLoopEnd, detail?: string): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* What follows the end of a loop, wherever the end was written: its wake withdrawn, its round stopped, its post record
|
|
218
|
+
* removed, and the transcript row. Also for a loop whose record went (a dismissed PR, a deleted session).
|
|
219
|
+
*/
|
|
220
|
+
ended(sessionId: string, before: ReviewLoopState, reason: ReviewLoopEnd, detail?: string): void;
|
|
221
|
+
/** At delivery: whether the fixer's wake is still wanted. The PR is read on GitHub, as Auto-fix's wake is. */
|
|
222
|
+
confirmWake(sessionId: string, wakeId: string): Promise<boolean>;
|
|
223
|
+
/** The fixer's wake started (or continued) a run: that run's end, or its wait in await_review, ends the round. */
|
|
224
|
+
wakeDelivered(sessionId: string, wakeId: string, runId: string): Promise<void>;
|
|
225
|
+
/** The fixer's wake could not be delivered at all (a refusal no retry changes): the loop cannot go on. */
|
|
226
|
+
wakeSpent(sessionId: string, wakeId: string, reason: string): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* A graph run's `review` node starts a loop on the session's PR: a new id, driven by that run, so the chat controller
|
|
229
|
+
* never starts its rounds or wakes the task for it (R17). Refused, with undefined, while any loop runs on the record.
|
|
230
|
+
*/
|
|
231
|
+
startGraphLoop(sessionId: string, runId: string, settings: {
|
|
232
|
+
rounds: number;
|
|
233
|
+
instruction?: string;
|
|
234
|
+
model?: {
|
|
235
|
+
provider: string;
|
|
236
|
+
model: string;
|
|
237
|
+
};
|
|
238
|
+
nodeId?: string;
|
|
239
|
+
}): Promise<string | undefined>;
|
|
240
|
+
/** A resumed graph run takes over the loop of the run it resumed: the loop's rounds and log go on under the new run. */
|
|
241
|
+
adoptGraphLoop(sessionId: string, loop: string, fromRunId: string, runId: string): Promise<boolean>;
|
|
242
|
+
/**
|
|
243
|
+
* One round of a graph run's loop, now, in this process: the review-check, the reviewer and the post, or the resume
|
|
244
|
+
* of a round its engine stopped in (`reviewing` starts it again; `posting` resumes with the marker check). A round
|
|
245
|
+
* that fails throws; the caller ends the loop.
|
|
246
|
+
*/
|
|
247
|
+
graphRound(sessionId: string, loop: string, signal: AbortSignal): Promise<void>;
|
|
248
|
+
private round;
|
|
249
|
+
/** The review-check, then the reviewer on the PR's head, then the post; again on a new head after one `stale_head`. */
|
|
250
|
+
private reviewAndPost;
|
|
251
|
+
/** `gh pr view` as the record's account: the head and base the round reviews, and the text the reviewer reads. */
|
|
252
|
+
private view;
|
|
253
|
+
/** This loop's earlier rounds for the reviewer's rounds.json, and the inline findings whose threads are still open. */
|
|
254
|
+
private earlierRounds;
|
|
255
|
+
/**
|
|
256
|
+
* One reviewer run on `head`, retried once on a failure; a second ends the loop `reviewer-failed`. The worktree is
|
|
257
|
+
* removed whatever happened. Answers the findings and the diff they map onto, or undefined when the round stops.
|
|
258
|
+
*/
|
|
259
|
+
private runReviewer;
|
|
260
|
+
/** The findings as a review, kept on disk, then posted; a 422 is retried once with every finding in the summary. */
|
|
261
|
+
private compose;
|
|
262
|
+
/**
|
|
263
|
+
* Sends one composed review and acts on the outcome. A marker check that throws leaves the round in `posting` with
|
|
264
|
+
* its attempt (the outcome is still unknown), and the round is resumed later with the same request id.
|
|
265
|
+
*/
|
|
266
|
+
private post;
|
|
267
|
+
/** Records a posted round, then ends the loop, or hands the findings to the task. */
|
|
268
|
+
private posted;
|
|
269
|
+
/**
|
|
270
|
+
* R10: the fixer is woken only where the record's gh account can push to the head. A check gh cannot answer is asked
|
|
271
|
+
* once more; `unknown` after that, and the caller fails closed.
|
|
272
|
+
*/
|
|
273
|
+
private canPush;
|
|
274
|
+
}
|