@andorra-labs/code 0.1.16 → 0.1.17
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 +11 -8
- 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/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 +19 -44
- package/dist/src/app-server/protocol.js +5 -1
- package/dist/src/app-server/workspace.d.ts +89 -0
- package/dist/src/app-server/workspace.js +457 -11
- package/dist/src/app-server.d.ts +358 -32
- package/dist/src/app-server.js +2429 -509
- 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 +347 -0
- package/dist/src/bridge/control.d.ts +68 -0
- package/dist/src/bridge/control.js +233 -0
- package/dist/src/bridge/engines.d.ts +90 -0
- package/dist/src/bridge/engines.js +601 -0
- package/dist/src/bridge/host-ops.d.ts +9 -0
- package/dist/src/bridge/host-ops.js +129 -0
- package/dist/src/bridge/host.d.ts +47 -0
- package/dist/src/bridge/host.js +540 -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/change-authors.d.ts +41 -0
- package/dist/src/change-authors.js +146 -0
- package/dist/src/cli.js +182 -32
- package/dist/src/coding-tools.js +15 -15
- package/dist/src/command-screens.d.ts +6 -0
- package/dist/src/command-screens.js +14 -11
- package/dist/src/commands.d.ts +14 -2
- package/dist/src/compaction-phrases.js +1 -1
- package/dist/src/completion.js +82 -5
- package/dist/src/config.d.ts +71 -3
- package/dist/src/config.js +202 -77
- package/dist/src/deadline.js +13 -1
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/requestPhrases.js +0 -1
- package/dist/src/default-graph.js +1 -1
- 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 +349 -0
- package/dist/src/github-app/client.js +810 -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 +8 -0
- package/dist/src/github-names.js +8 -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 +46 -0
- package/dist/src/graph-preview.js +55 -0
- package/dist/src/graph-provider-portability.js +2 -1
- package/dist/src/graph-runner.js +64 -3
- package/dist/src/graph-server.js +3 -3
- package/dist/src/graph-sync.js +3 -3
- package/dist/src/graph-ui/app.js +91 -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 +34 -1
- package/dist/src/graphs.js +158 -14
- 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-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/project-registry.d.ts +21 -0
- package/dist/src/project-registry.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 +23 -2
- package/dist/src/providers.js +25 -4
- 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 +327 -7
- package/dist/src/pull-requests.js +429 -51
- package/dist/src/react-runtime.js +1 -1
- package/dist/src/remote/engine-pool.d.ts +88 -4
- package/dist/src/remote/engine-pool.js +366 -89
- 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 +5 -1
- package/dist/src/runtime.js +10 -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 +11 -1
- package/dist/src/sessions.js +17 -4
- 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 +2 -2
- package/dist/src/skills/runtime-skills.js +1 -1
- 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 +7 -0
- package/dist/src/test-edit-guard.js +49 -1
- package/dist/src/timers.d.ts +2 -0
- package/dist/src/tools.js +59 -9
- 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
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The newest schema version this client implements. Each record carries the version that defines its event
|
|
3
|
+
* (`telemetrySchemaFor`): the run and session events are still version 1, so an ingest that implements only
|
|
4
|
+
* version 1 keeps storing them, and refuses `github.watch` (version 2) rather than mislabelling it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TELEMETRY_SCHEMA = 2;
|
|
2
7
|
export declare const TELEMETRY_BODY_LIMIT: number;
|
|
3
|
-
export declare const TELEMETRY_EVENTS: readonly ["session.started", "run.started", "run.finished"];
|
|
8
|
+
export declare const TELEMETRY_EVENTS: readonly ["session.started", "run.started", "run.finished", "github.watch"];
|
|
4
9
|
export type TelemetryEventName = typeof TELEMETRY_EVENTS[number];
|
|
10
|
+
export declare function telemetrySchemaFor(event: TelemetryEventName): number;
|
|
11
|
+
/** A watched pull request's GitHub App coverage, as the engine sees it (`design/specs/github-app.md`, "Fallback to gh"). */
|
|
12
|
+
export declare const TELEMETRY_GITHUB_COVERAGE: readonly ["covered", "signed-out", "not-connected", "not-installed", "not-covered", "suspended", "permissions-pending", "limit", "pending", "disabled", "unavailable"];
|
|
13
|
+
export type TelemetryGitHubCoverage = typeof TELEMETRY_GITHUB_COVERAGE[number];
|
|
14
|
+
/** One coverage state's share of a `github.watch` window: how many watched PRs were in it, and the gh calls made for them. */
|
|
15
|
+
export interface TelemetryGitHubWatchRecord {
|
|
16
|
+
coverage: TelemetryGitHubCoverage;
|
|
17
|
+
prs: number;
|
|
18
|
+
ghCalls: number;
|
|
19
|
+
}
|
|
5
20
|
export declare const TELEMETRY_SURFACES: readonly ["cli", "desktop", "remote", "subagent"];
|
|
6
21
|
export type TelemetrySurface = typeof TELEMETRY_SURFACES[number];
|
|
7
22
|
export declare const TELEMETRY_PLANS: readonly ["free", "legacy", "paid", "unknown"];
|
|
@@ -127,6 +142,10 @@ export interface TelemetryEvent extends TelemetryIdentity {
|
|
|
127
142
|
languages?: TelemetryLanguage[];
|
|
128
143
|
frameworks?: TelemetryFramework[];
|
|
129
144
|
taskCategory?: TelemetryTaskCategory;
|
|
145
|
+
/** `github.watch` only: the window's length in minutes, at most an hour. */
|
|
146
|
+
minutes?: number;
|
|
147
|
+
watched?: TelemetryGitHubWatchRecord[];
|
|
148
|
+
wakeLatencies?: number[];
|
|
130
149
|
}
|
|
131
150
|
export declare const TELEMETRY_BOUNDS: {
|
|
132
151
|
readonly token: 1000000000000;
|
|
@@ -137,6 +156,10 @@ export declare const TELEMETRY_BOUNDS: {
|
|
|
137
156
|
readonly jevCounter: 1000000;
|
|
138
157
|
readonly nodes: 10000;
|
|
139
158
|
readonly osMajor: 999;
|
|
159
|
+
readonly watchMinutes: 60;
|
|
160
|
+
readonly watchedPrs: 10000;
|
|
161
|
+
readonly wakeLatencySeconds: 86400;
|
|
162
|
+
readonly wakeLatencies: 60;
|
|
140
163
|
};
|
|
141
164
|
export declare function telemetryTimestamp(date?: Date): string;
|
|
142
165
|
export declare function telemetryEventId(): string;
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { isIP } from 'node:net';
|
|
3
3
|
import { CANONICAL_CODING_TOOLS, canonicalToolName } from '../tool-names.js';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The newest schema version this client implements. Each record carries the version that defines its event
|
|
6
|
+
* (`telemetrySchemaFor`): the run and session events are still version 1, so an ingest that implements only
|
|
7
|
+
* version 1 keeps storing them, and refuses `github.watch` (version 2) rather than mislabelling it.
|
|
8
|
+
*/
|
|
9
|
+
export const TELEMETRY_SCHEMA = 2;
|
|
5
10
|
export const TELEMETRY_BODY_LIMIT = 64 * 1024;
|
|
6
|
-
export const TELEMETRY_EVENTS = ['session.started', 'run.started', 'run.finished'];
|
|
11
|
+
export const TELEMETRY_EVENTS = ['session.started', 'run.started', 'run.finished', 'github.watch'];
|
|
12
|
+
export function telemetrySchemaFor(event) {
|
|
13
|
+
return event === 'github.watch' ? 2 : 1;
|
|
14
|
+
}
|
|
15
|
+
/** A watched pull request's GitHub App coverage, as the engine sees it (`design/specs/github-app.md`, "Fallback to gh"). */
|
|
16
|
+
export const TELEMETRY_GITHUB_COVERAGE = [
|
|
17
|
+
'covered', 'signed-out', 'not-connected', 'not-installed', 'not-covered', 'suspended', 'permissions-pending',
|
|
18
|
+
'limit', 'pending', 'disabled', 'unavailable',
|
|
19
|
+
];
|
|
7
20
|
export const TELEMETRY_SURFACES = ['cli', 'desktop', 'remote', 'subagent'];
|
|
8
21
|
export const TELEMETRY_PLANS = ['free', 'legacy', 'paid', 'unknown'];
|
|
9
22
|
export const TELEMETRY_OUTCOMES = ['completed', 'failed', 'cancelled', 'needs_clarification', 'interrupted'];
|
|
@@ -79,6 +92,10 @@ export const TELEMETRY_BOUNDS = {
|
|
|
79
92
|
jevCounter: 1_000_000,
|
|
80
93
|
nodes: 10_000,
|
|
81
94
|
osMajor: 999,
|
|
95
|
+
watchMinutes: 60,
|
|
96
|
+
watchedPrs: 10_000,
|
|
97
|
+
wakeLatencySeconds: 86_400,
|
|
98
|
+
wakeLatencies: 60,
|
|
82
99
|
};
|
|
83
100
|
const HEX_32 = /^[a-f0-9]{32}$/;
|
|
84
101
|
const isEnum = (allowed, value) => typeof value === 'string' && allowed.includes(value);
|
|
@@ -322,7 +339,7 @@ export function validateTelemetryEvent(value) {
|
|
|
322
339
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
323
340
|
throw new SchemaError('the body must be an object');
|
|
324
341
|
const v = value;
|
|
325
|
-
if (v.schema
|
|
342
|
+
if (!Number.isSafeInteger(v.schema) || v.schema < 1 || v.schema > TELEMETRY_SCHEMA)
|
|
326
343
|
throw new SchemaError(`unsupported schema version ${String(v.schema)}`);
|
|
327
344
|
if (!isString(v.eventId, 36) || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(v.eventId))
|
|
328
345
|
throw new SchemaError('eventId must be a UUID');
|
|
@@ -333,8 +350,11 @@ export function validateTelemetryEvent(value) {
|
|
|
333
350
|
if (!isString(v.appVersion, 64))
|
|
334
351
|
throw new SchemaError('appVersion is required');
|
|
335
352
|
const event = requireEnum(TELEMETRY_EVENTS, v.event, 'event');
|
|
353
|
+
// A record is labelled with the one version that defines its event.
|
|
354
|
+
if (v.schema !== telemetrySchemaFor(event))
|
|
355
|
+
throw new SchemaError(`unsupported schema version ${String(v.schema)} for ${event}`);
|
|
336
356
|
const identity = {
|
|
337
|
-
schema:
|
|
357
|
+
schema: v.schema,
|
|
338
358
|
eventId: v.eventId,
|
|
339
359
|
installId: v.installId,
|
|
340
360
|
ts: v.ts,
|
|
@@ -346,6 +366,8 @@ export function validateTelemetryEvent(value) {
|
|
|
346
366
|
plan: requireEnum(TELEMETRY_PLANS, v.plan, 'plan'),
|
|
347
367
|
};
|
|
348
368
|
const out = { ...identity, event };
|
|
369
|
+
if (event === 'github.watch')
|
|
370
|
+
return validateGitHubWatch(v, out);
|
|
349
371
|
if (event === 'session.started') {
|
|
350
372
|
if (v.runId !== undefined)
|
|
351
373
|
throw new SchemaError('runId belongs to no session');
|
|
@@ -469,6 +491,32 @@ export function validateTelemetryEvent(value) {
|
|
|
469
491
|
out.taskCategory = requireEnum(TELEMETRY_TASK_CATEGORIES, v.taskCategory, 'taskCategory');
|
|
470
492
|
return out;
|
|
471
493
|
}
|
|
494
|
+
/** `github.watch`: one engine's window of GitHub App watching. Counts and coverage states only. */
|
|
495
|
+
function validateGitHubWatch(v, out) {
|
|
496
|
+
if (v.runId !== undefined)
|
|
497
|
+
throw new SchemaError('runId belongs to no watch window');
|
|
498
|
+
out.minutes = requireInteger(v.minutes, 1, TELEMETRY_BOUNDS.watchMinutes, 'minutes');
|
|
499
|
+
if (!Array.isArray(v.watched) || v.watched.length < 1 || v.watched.length > TELEMETRY_GITHUB_COVERAGE.length) {
|
|
500
|
+
throw new SchemaError(`watched must be an array of 1 to ${TELEMETRY_GITHUB_COVERAGE.length} records`);
|
|
501
|
+
}
|
|
502
|
+
out.watched = v.watched.map((record, index) => {
|
|
503
|
+
if (!record || typeof record !== 'object' || Array.isArray(record))
|
|
504
|
+
throw new SchemaError(`watched[${index}] must be an object`);
|
|
505
|
+
const r = record;
|
|
506
|
+
return {
|
|
507
|
+
coverage: requireEnum(TELEMETRY_GITHUB_COVERAGE, r.coverage, `watched[${index}].coverage`),
|
|
508
|
+
prs: requireInteger(r.prs, 1, TELEMETRY_BOUNDS.watchedPrs, `watched[${index}].prs`),
|
|
509
|
+
ghCalls: requireInteger(r.ghCalls, 0, TELEMETRY_BOUNDS.counter, `watched[${index}].ghCalls`),
|
|
510
|
+
};
|
|
511
|
+
});
|
|
512
|
+
unique(out.watched, record => record.coverage, 'watched');
|
|
513
|
+
if (v.wakeLatencies !== undefined) {
|
|
514
|
+
if (!Array.isArray(v.wakeLatencies) || v.wakeLatencies.length > TELEMETRY_BOUNDS.wakeLatencies)
|
|
515
|
+
throw new SchemaError(`wakeLatencies must be an array of at most ${TELEMETRY_BOUNDS.wakeLatencies} values`);
|
|
516
|
+
out.wakeLatencies = v.wakeLatencies.map((seconds, index) => requireInteger(seconds, 0, TELEMETRY_BOUNDS.wakeLatencySeconds, `wakeLatencies[${index}]`));
|
|
517
|
+
}
|
|
518
|
+
return out;
|
|
519
|
+
}
|
|
472
520
|
export function serializeTelemetryEvent(event) {
|
|
473
521
|
return JSON.stringify(validateTelemetryEvent(event));
|
|
474
522
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Config } from '../config.js';
|
|
2
|
-
import { telemetryHome, type RunDimensions, type TelemetryContext } from './emitter.js';
|
|
2
|
+
import { telemetryHome, type GitHubWatchInput, type RunDimensions, type TelemetryContext } from './emitter.js';
|
|
3
3
|
import type { Graph } from '../graphs.js';
|
|
4
4
|
import type { RunTelemetry } from './capture.js';
|
|
5
5
|
import type { ClassifiableStatus } from './classify.js';
|
|
@@ -39,6 +39,7 @@ export declare function reportRunFinished(input: SurfaceInput, handle: RunTeleme
|
|
|
39
39
|
retries?: number;
|
|
40
40
|
}): Promise<void>;
|
|
41
41
|
export declare function reportInterruptedRuns(input: SurfaceInput, records: Record<string, unknown>[]): Promise<void>;
|
|
42
|
+
export declare function reportGitHubWatch(input: SurfaceInput, summary: GitHubWatchInput): Promise<void>;
|
|
42
43
|
export declare function reportSessionStarted(input: SurfaceInput & {
|
|
43
44
|
workspace?: string;
|
|
44
45
|
}): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { configDirectory, loadConfig } from '../config.js';
|
|
2
2
|
import { drainOutbox } from './uploader.js';
|
|
3
|
-
import { emitInterruptedRun, emitRunFinished, emitRunStarted, emitSessionStarted, telemetryHome, } from './emitter.js';
|
|
3
|
+
import { emitGitHubWatch, emitInterruptedRun, emitRunFinished, emitRunStarted, emitSessionStarted, telemetryHome, } from './emitter.js';
|
|
4
4
|
import { telemetryDirectory } from './identity.js';
|
|
5
5
|
import { telemetryGate } from './gate.js';
|
|
6
6
|
import { clearInterruptedTelemetry } from '../run-records.js';
|
|
@@ -60,6 +60,9 @@ export async function reportInterruptedRuns(input, records) {
|
|
|
60
60
|
if (reported.length)
|
|
61
61
|
await clearInterruptedTelemetry(input.home ?? configDirectory(), reported).catch(() => { });
|
|
62
62
|
}
|
|
63
|
+
export async function reportGitHubWatch(input, summary) {
|
|
64
|
+
await emitGitHubWatch(contextFor(input), summary);
|
|
65
|
+
}
|
|
63
66
|
export async function reportSessionStarted(input) {
|
|
64
67
|
await emitSessionStarted({ ...contextFor(input), workspace: input.workspace });
|
|
65
68
|
}
|
|
@@ -229,6 +229,7 @@ export declare class TerminalUI extends EventEmitter {
|
|
|
229
229
|
conversationPrompt?: boolean;
|
|
230
230
|
history?: boolean;
|
|
231
231
|
secret?: boolean;
|
|
232
|
+
yieldToQuestions?: boolean;
|
|
232
233
|
}): Promise<string>;
|
|
233
234
|
chooseQuestion(prompt: string, items: TerminalChoice[], options?: {
|
|
234
235
|
kind?: 'question' | 'approval';
|
package/dist/src/terminal-ui.js
CHANGED
|
@@ -85,7 +85,7 @@ const submittedCommand = (value) => {
|
|
|
85
85
|
};
|
|
86
86
|
const workingCommandHint = (command) => `${command} doesn't run while a task is working. Run ${command} once this task has finished.`
|
|
87
87
|
+ (command === '/graph' ? ' Switching graphs clears the previous graph progress and starts fresh.' : '');
|
|
88
|
-
const liveRunCommands = ['/model', '/browser', '/attach', '/compact', '/yolo', '/permissions', '/jev', '/help', '/status', '/usage', '/tools', '/exit', '/quit'];
|
|
88
|
+
const liveRunCommands = ['/model', '/providers', '/browser', '/attach', '/compact', '/yolo', '/permissions', '/jev', '/help', '/status', '/usage', '/tools', '/exit', '/quit'];
|
|
89
89
|
const paint = (text, color = GRAY) => typeof color === 'number'
|
|
90
90
|
? `\x1b[38;5;${color}m${text}\x1b[0m`
|
|
91
91
|
: `\x1b[${color}m${text}\x1b[0m`;
|
|
@@ -696,6 +696,13 @@ export class TerminalUI extends EventEmitter {
|
|
|
696
696
|
if (this.closed)
|
|
697
697
|
return Promise.reject(new Error('Terminal is closed'));
|
|
698
698
|
this.yieldScreen();
|
|
699
|
+
// A prompt that yields gives way to the run's question: the caller sees an AbortError and closes its screen.
|
|
700
|
+
if (this.pending && !options.yieldToQuestions) {
|
|
701
|
+
const held = this.pending;
|
|
702
|
+
if (!held.yieldToQuestions)
|
|
703
|
+
return Promise.reject(new Error('A terminal question is already active'));
|
|
704
|
+
held.abort?.();
|
|
705
|
+
}
|
|
699
706
|
if (this.pending)
|
|
700
707
|
return Promise.reject(new Error('A terminal question is already active'));
|
|
701
708
|
if (this.modal)
|
|
@@ -718,7 +725,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
718
725
|
if (!regular)
|
|
719
726
|
this.print(label);
|
|
720
727
|
return new Promise((resolve, reject) => {
|
|
721
|
-
const pending = { kind: options.kind ?? 'question', resolve, reject, signal: options.signal, label: oneLine(label), title: options.title ? oneLine(options.title).trim() : undefined, regular, cancelOnEscape: options.cancelOnEscape, conversationPrompt: options.conversationPrompt === true, secret: options.secret, history: regular && options.history !== false && !options.secret };
|
|
728
|
+
const pending = { kind: options.kind ?? 'question', resolve, reject, signal: options.signal, label: oneLine(label), title: options.title ? oneLine(options.title).trim() : undefined, regular, cancelOnEscape: options.cancelOnEscape, conversationPrompt: options.conversationPrompt === true, secret: options.secret, history: regular && options.history !== false && !options.secret, yieldToQuestions: options.yieldToQuestions === true };
|
|
722
729
|
pending.abort = () => { if (this.pending !== pending)
|
|
723
730
|
return; this.finishQuestion(); reject(new DOMException('Question aborted', 'AbortError')); this.scheduleRender(); };
|
|
724
731
|
this.pending = pending;
|
|
@@ -731,7 +738,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
731
738
|
if (!items.length || items.some(item => !item.id))
|
|
732
739
|
throw new Error('Question choices require nonempty IDs');
|
|
733
740
|
this.yieldScreen();
|
|
734
|
-
if (this.
|
|
741
|
+
if (this.modal || (this.pending && !this.pending.yieldToQuestions))
|
|
735
742
|
throw new Error('A terminal question or screen is already active');
|
|
736
743
|
const displayedPrompt = prompt === 'Choose an answer' ? this.dashboardNotices.at(-1) ?? prompt : prompt;
|
|
737
744
|
if (options.printPrompt !== false)
|
|
@@ -65,6 +65,13 @@ export declare class TestEditGuard {
|
|
|
65
65
|
* a file born after the run started was made by the run (through the shell, say) and is its own to change.
|
|
66
66
|
*/
|
|
67
67
|
noteToolMutation(target: string, existed: boolean, bornAtMs?: number): void;
|
|
68
|
+
/**
|
|
69
|
+
* The modified test files whose change only adds new tests: no line of the starting commit's file was
|
|
70
|
+
* removed or replaced, and nothing added switches a test off or defines again a name the file already
|
|
71
|
+
* had. Appending a regression test to an existing test file is ordinary work, not a rewrite of the
|
|
72
|
+
* tests that constrain the fix. Any doubt (a Git failure, a file that is not test code) keeps the file flagged.
|
|
73
|
+
*/
|
|
74
|
+
private onlyAddsTests;
|
|
68
75
|
private current;
|
|
69
76
|
/**
|
|
70
77
|
* Returns the changed pre-existing test files when at least one of them has not been reported yet,
|
|
@@ -10,6 +10,14 @@ function within(root, target) {
|
|
|
10
10
|
const TEST_DIRECTORY = /(?:^|\/)(?:tests?|testing|__tests__|__snapshots__|baseline_images|testdata|test_data)\//i;
|
|
11
11
|
const TEST_FILE = /(?:^|\/)(?:test_[^/]*\.py|conftest\.py|[^/]+_test\.[^/]+|[^/]+\.(?:test|spec)\.[^/]+)$/i;
|
|
12
12
|
const ASKS_FOR_TEST_CHANGES = /\b(?:add|adds|adding|update|updates|updating|fix|fixes|fixing|change|changes|changing|modify|modifying|rewrite|rewriting|adjust|adjusting|extend|extending|refactor|refactoring|delete|deleting|remove|removing|rename|renaming|migrate|migrating|port|porting|regenerate|regenerating|write|writing)\b[^.!?\n]{0,60}\b(?:tests?|specs?|test suite|fixtures?|snapshots?|baselines?|conftest)\b/i;
|
|
13
|
+
/** Test source files, where an added line is a new test rather than new expected output. */
|
|
14
|
+
const ADDITIVE_TEST_CODE = /\.(?:py|[cm]?[jt]sx?|go|rs|java|kt|rb|php|cs|c|cc|cpp|h|hpp|swift|scala)$/i;
|
|
15
|
+
const FIXTURE_LOCATION = /(?:^|\/)(?:conftest\.py$|(?:__snapshots__|baseline_images|testdata|test_data|fixtures?)\/)/i;
|
|
16
|
+
/** An added line that can switch an existing test off, or narrow the run to some tests. */
|
|
17
|
+
const DISABLES_TESTS = /skip|xfail|expectedFailure|\bx(?:it|test|describe)\b|\.(?:only|todo|fixme)\b|\bf(?:it|describe)\b|collect_ignore|pytestmark|\bignore\b|\bdisabled?\b|\bpending\b/i;
|
|
18
|
+
/** A named definition; one that repeats a name already in the file replaces the earlier one in most languages. */
|
|
19
|
+
const DECLARATION = /^\s*(?:export\s+)?(?:public\s+|private\s+|protected\s+|static\s+|async\s+)*(?:def|class|func|function|fn|fun|void|module)\s+([A-Za-z_$][\w$]*)/;
|
|
20
|
+
const ADDITIVE_FILE_LIMIT = 40;
|
|
13
21
|
const GIT_TIMEOUT_MS = 5_000;
|
|
14
22
|
const HASH_FILE_LIMIT = 8 * 1024 * 1024;
|
|
15
23
|
const BASELINE_DIRTY_LIMIT = 2_000;
|
|
@@ -42,7 +50,7 @@ export function testEditNudge(edits, restoreFrom) {
|
|
|
42
50
|
: 'undo those edits';
|
|
43
51
|
return `Completion not accepted yet. ${edits.length === 1 ? 'This test file' : 'These test files'} existed before this run and ${edits.length === 1 ? 'was' : 'were'} changed during it: ${named}${more}. `
|
|
44
52
|
+ 'An existing test that fails after your change is a constraint on the fix, not something to rewrite to fit it. '
|
|
45
|
-
+ `Unless the task explicitly asks for these tests to change, ${restore} and change the code until the original tests pass.${keep} Adding new test files is fine. `
|
|
53
|
+
+ `Unless the task explicitly asks for these tests to change, ${restore} and change the code until the original tests pass.${keep} Adding new test files is fine, and so is adding new tests to an existing file without changing what it already holds. `
|
|
46
54
|
+ 'If the task does require these edits, call complete_agent again to finish; this reminder is not repeated for the same files.';
|
|
47
55
|
}
|
|
48
56
|
function git(cwd, args, signal) {
|
|
@@ -205,6 +213,44 @@ export class TestEditGuard {
|
|
|
205
213
|
if (!this.created.has(relative) && isTestPath(relative))
|
|
206
214
|
this.toolEdits.set(relative, 'modified');
|
|
207
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* The modified test files whose change only adds new tests: no line of the starting commit's file was
|
|
218
|
+
* removed or replaced, and nothing added switches a test off or defines again a name the file already
|
|
219
|
+
* had. Appending a regression test to an existing test file is ordinary work, not a rewrite of the
|
|
220
|
+
* tests that constrain the fix. Any doubt (a Git failure, a file that is not test code) keeps the file flagged.
|
|
221
|
+
*/
|
|
222
|
+
async onlyAddsTests(baseline, names, signal) {
|
|
223
|
+
const candidates = names.filter(name => ADDITIVE_TEST_CODE.test(name) && !FIXTURE_LOCATION.test(name)
|
|
224
|
+
&& !baseline.dirty.has(name) && !baseline.unknown.has(name)).slice(0, ADDITIVE_FILE_LIMIT);
|
|
225
|
+
if (!candidates.length)
|
|
226
|
+
return [];
|
|
227
|
+
const additive = [];
|
|
228
|
+
try {
|
|
229
|
+
const counts = (await git(this.workspace, ['diff', '--numstat', '-z', '--no-renames', '--relative', baseline.head, '--', ...candidates], signal)).split('\0');
|
|
230
|
+
for (const entry of counts) {
|
|
231
|
+
const match = /^(\d+)\t0\t(.+)$/s.exec(entry);
|
|
232
|
+
if (!match || match[1] === '0' || !candidates.includes(match[2]))
|
|
233
|
+
continue;
|
|
234
|
+
const name = match[2];
|
|
235
|
+
const patch = await git(this.workspace, ['diff', '-U0', '--no-color', '--no-ext-diff', '--no-renames', '--relative', baseline.head, '--', name], signal);
|
|
236
|
+
const added = patch.split(/\r?\n/).filter(line => line.startsWith('+') && !line.startsWith('+++')).map(line => line.slice(1));
|
|
237
|
+
if (!added.length || added.some(line => DISABLES_TESTS.test(line)))
|
|
238
|
+
continue;
|
|
239
|
+
const declared = added.map(line => DECLARATION.exec(line)?.[1]).filter((item) => !!item);
|
|
240
|
+
if (declared.length) {
|
|
241
|
+
const before = await git(this.workspace, ['show', `${baseline.head}:${baseline.prefix}${name}`], signal);
|
|
242
|
+
const existing = new Set([...before.matchAll(new RegExp(DECLARATION.source, 'gm'))].map(found => found[1]));
|
|
243
|
+
if (declared.some(item => existing.has(item)) || new Set(declared).size !== declared.length)
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
additive.push(name);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
return additive;
|
|
251
|
+
}
|
|
252
|
+
return additive;
|
|
253
|
+
}
|
|
208
254
|
async current(signal) {
|
|
209
255
|
const baseline = await (this.baseline ?? Promise.resolve({ kind: 'none' }));
|
|
210
256
|
const edits = new Map();
|
|
@@ -216,6 +262,8 @@ export class TestEditGuard {
|
|
|
216
262
|
continue;
|
|
217
263
|
edits.set(name, status.startsWith('D') ? 'deleted' : 'modified');
|
|
218
264
|
}
|
|
265
|
+
for (const name of await this.onlyAddsTests(baseline, [...edits].filter(([, state]) => state === 'modified').map(([name]) => name), signal))
|
|
266
|
+
edits.delete(name);
|
|
219
267
|
for (const [name, before] of baseline.dirty) {
|
|
220
268
|
const now = await contentHash(path.join(baseline.root, baseline.prefix, name));
|
|
221
269
|
if (now === before)
|
package/dist/src/timers.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface WakeCarry {
|
|
|
10
10
|
reasoningEffort?: string;
|
|
11
11
|
overrideAllNodes?: boolean;
|
|
12
12
|
panelBrowserRelay?: boolean;
|
|
13
|
+
/** The session's run used a desktop's providers: a wake cannot start it here, only a resume from that desktop can. */
|
|
14
|
+
relayed?: boolean;
|
|
13
15
|
input?: Record<string, unknown>;
|
|
14
16
|
state?: Record<string, unknown>;
|
|
15
17
|
}
|
package/dist/src/tools.js
CHANGED
|
@@ -17,7 +17,8 @@ import { READ_IMAGE_FILE_LIMIT } from './read-image.js';
|
|
|
17
17
|
import { decodeLegacyText, sniffDocument } from './read-document.js';
|
|
18
18
|
import { READ_DOCUMENT_FILE_LIMIT } from './read-document-tool.js';
|
|
19
19
|
import { clipText } from './text.js';
|
|
20
|
-
import { pullRequestSettings } from './pull-requests.js';
|
|
20
|
+
import { pullRequestSettings, REVIEW_BUMP_COMMENT, REVIEW_INSTRUCTION_BYTES, REVIEW_ROUNDS_DEFAULT, REVIEW_ROUNDS_MAX, reviewLoopActive, reviewLoopSettings } from './pull-requests.js';
|
|
21
|
+
import { agentWriteFromArgs } from './github-app/agent-writes.js';
|
|
21
22
|
import { approveOperation } from './capabilities.js';
|
|
22
23
|
import { HARNESS_HOME_OFF_LIMITS, assertCommandAvoidsHarnessHome, guardsHarnessHome, insideHarnessHome } from './harness-home.js';
|
|
23
24
|
const OUTPUT_LIMIT = 32_768;
|
|
@@ -599,13 +600,44 @@ function qaPermissionTool(tool) {
|
|
|
599
600
|
} };
|
|
600
601
|
}
|
|
601
602
|
const AWAIT_REVIEW_DEFAULT_MINUTES = 360;
|
|
603
|
+
const REVIEW_PHASE_TEXT = { waiting: 'waiting to review', reviewing: 'reviewing', posting: 'posting a review', fixing: 'waiting for your fixes', ended: 'ended' };
|
|
604
|
+
/** The Andorra review loop in the tool's status: on with its round and phase, or off with how the last loop ended. */
|
|
605
|
+
function describeReview(pr) {
|
|
606
|
+
const review = pr.review;
|
|
607
|
+
if (review === undefined)
|
|
608
|
+
return 'Andorra review off';
|
|
609
|
+
if (reviewLoopActive(pr))
|
|
610
|
+
return `Andorra review on (${review.round} of ${review.rounds} reviews posted, ${REVIEW_PHASE_TEXT[review.phase]})`;
|
|
611
|
+
if (review.ended === undefined)
|
|
612
|
+
return `Andorra review off (${review.rounds} rounds when on)`;
|
|
613
|
+
return `Andorra review off (the last loop ended ${review.ended.reason} after ${review.round} of ${review.rounds} reviews${review.ended.detail === undefined ? '' : `: ${review.ended.detail}`})`;
|
|
614
|
+
}
|
|
615
|
+
/** What an Andorra review loop's end means for the agent waiting on it. */
|
|
616
|
+
const REVIEW_END_TEXT = {
|
|
617
|
+
'signed-off': 'Its last review found no P1 or P2 findings.',
|
|
618
|
+
'rounds-used': 'Its last round still found something, and those findings are left for the user: do not fix them unless the user asks.',
|
|
619
|
+
'review-only': 'This task cannot push to the pull request\'s head repository, so the review\'s findings are left for the user.',
|
|
620
|
+
'no-new-commits': 'The turn that took its findings ended without a new commit.',
|
|
621
|
+
'switched-off': 'Andorra review was switched off.',
|
|
622
|
+
};
|
|
623
|
+
function reviewLoopEndAnswer(ended) {
|
|
624
|
+
const why = REVIEW_END_TEXT[ended.reason] ?? (ended.detail === undefined ? '' : ended.detail);
|
|
625
|
+
const next = ended.pullRequest.autoFix
|
|
626
|
+
? 'Auto-fix is still on: call await_review again to wait for other reviewers, or finish and report.'
|
|
627
|
+
: 'There is no review left to wait for; finish your work and report.';
|
|
628
|
+
return `The Andorra review loop ended: ${ended.reason}.${why ? ` ${why}` : ''} ${next}`;
|
|
629
|
+
}
|
|
602
630
|
function reviewWaitAnswer(ended, minutes, signal) {
|
|
603
631
|
switch (ended.kind) {
|
|
632
|
+
// The loop's wake text already says to call await_review once the round is pushed and answered.
|
|
633
|
+
case 'review': return ended.prompt;
|
|
634
|
+
case 'review-ended': return reviewLoopEndAnswer(ended);
|
|
604
635
|
case 'comments': return `${ended.prompt}
|
|
605
636
|
|
|
606
637
|
When this round is pushed and its threads are answered, call pull_request with action await_review again to wait for the next review.`;
|
|
638
|
+
case 'approved': return `Codex signed off on ${ended.pullRequest.url}${ended.headSha === undefined ? '' : ` at ${ended.headSha.slice(0, 10)}`}: it reviewed that commit and found nothing (its thumbs-up on the pull request, or a review with no findings), and no new review comment is waiting. Treat this as an approval of that commit. There is no review left to wait for; finish your work and report, and merge only if the user asked you to. Call await_review again only after you push another commit.`;
|
|
607
639
|
case 'finished': return `${ended.pullRequest.url} is ${ended.pullRequest.state}, so Auto-fix is off and there is no review left to wait for. Finish your work and report.`;
|
|
608
|
-
case 'off': return `Auto-fix is off for ${ended.pullRequest.url}, so no review will be waited for. Finish your work and report; switch Auto-fix on only if the user asks.`;
|
|
640
|
+
case 'off': return `Auto-fix is off for ${ended.pullRequest.url} and no Andorra review loop is running, so no review will be waited for. Finish your work and report; switch Auto-fix or Andorra review on only if the user asks.`;
|
|
609
641
|
case 'none': return 'No pull request is tracked for this session, so there is no review to wait for.';
|
|
610
642
|
case 'timeout': return `No new review arrived in ${minutes} minute${minutes === 1 ? '' : 's'}. Call await_review again to keep waiting, or finish and report.`;
|
|
611
643
|
case 'steered': return 'The user sent you a message while you were waiting for a review. Read and answer it; call await_review again afterwards if the review loop should continue.';
|
|
@@ -751,20 +783,27 @@ export function createTools() {
|
|
|
751
783
|
context.wakesArmed?.push(timer.id);
|
|
752
784
|
return `Timer ${timer.id.slice(0, 8)} armed: your prompt will be delivered in ${args.seconds} second${args.seconds === 1 ? '' : 's'}, at ${new Date(timer.fireAt).toISOString()}. It fires once.`;
|
|
753
785
|
}),
|
|
754
|
-
{ ...tool('pull_request',
|
|
755
|
-
action: { type: 'string', enum: ['status', 'attach', 'update', 'await_review', 'dismiss'], description: 'status shows the tracked PR; attach starts tracking url; update changes settings; await_review waits for the next review round; dismiss stops tracking' },
|
|
786
|
+
{ ...tool('pull_request', `Show or change the pull request this session tracks in the desktop Plan card. A PR you open with \`gh pr create\` is attached automatically; use attach for one opened another way. update changes its settings when the user asks: mergeWhenReady enables GitHub auto-merge (gh pr merge --auto), draft converts to a draft or marks it ready, autoFix wakes you with a prompt when a code-review bot (Codex, CodeRabbit, Greptile, Copilot) comments and switches itself off once the PR is merged or closed. review switches on Andorra review: the Andorra Code bot reviews the PR up to reviewRounds times (1 to ${REVIEW_ROUNDS_MAX}, default ${REVIEW_ROUNDS_DEFAULT}) and you are woken to fix its findings between reviews; reviewInstruction tells the reviewer what to focus on, reviewModel picks its provider/model (default: this task's), and review false switches it off. It needs a paid Andorra plan and a pull request the Andorra Code GitHub App covers; the result says why when it cannot be switched on. await_review keeps you in this run while Auto-fix or Andorra review is on: it waits, without using the model, until new review comments arrive (and returns them), Andorra review posts its next round (and returns it) or ends, Codex signs off on the head commit (its thumbs-up on the pull request, which is its approval), the PR is merged or closed, the user messages you, or timeoutMinutes pass. Use it to own the review loop: fix a round, push, resolve the threads you fixed, then call await_review again, until the PR is merged or closed. Never wait for a review with sleep, a shell loop or set_timer. Where Codex reviews the repository but shows no sign of having picked up the head commit after 30 seconds (no eyes reaction, no review, no comment), the wait posts "@codex review" on the PR once for that commit, as the gh account that reads the PR; do not post that comment yourself. reply answers a review thread (threadId, body), resolve resolves one (resolved false reopens it), and comment posts on the PR's conversation (body); they act only on the tracked PR. Where the Andorra Code GitHub App covers the PR they post as its bot, otherwise as the gh account that reads the PR; the result says who posted and why. dismiss stops tracking an open PR, and only when the user asks you to: never dismiss as cleanup after a merge, because a merged or closed PR stays on the task as its record and dismiss refuses one. Only change a setting the user asked you to change.`, {
|
|
787
|
+
action: { type: 'string', enum: ['status', 'attach', 'update', 'await_review', 'reply', 'resolve', 'comment', 'dismiss'], description: 'status shows the tracked PR; attach starts tracking url; update changes settings; await_review waits for the next review round; reply, resolve and comment write on the tracked PR; dismiss stops tracking an open PR when the user asks (refused once it is merged or closed)' },
|
|
788
|
+
threadId: property('The review thread\'s id, PRRT_…, from gh\'s reviewThreads query (reply and resolve only)'),
|
|
789
|
+
body: property('The text to post (reply and comment only)'),
|
|
790
|
+
resolved: { type: 'boolean', description: 'resolve only: false reopens a resolved thread (default true)' },
|
|
756
791
|
url: property('The GitHub pull request URL (attach only)'),
|
|
757
792
|
autoFix: { type: 'boolean', description: 'Wake this session when a code-review bot (Codex, CodeRabbit, Greptile, Copilot) comments, until the PR is merged or closed' },
|
|
758
793
|
mergeWhenReady: { type: 'boolean', description: 'GitHub auto-merge once checks and reviews pass' },
|
|
759
794
|
draft: { type: 'boolean', description: 'true converts to a draft, false marks it ready for review' },
|
|
795
|
+
review: { type: 'boolean', description: 'Andorra review: true has the Andorra Code bot review the PR in rounds and wakes you to fix its findings between them; false stops it' },
|
|
796
|
+
reviewRounds: { type: 'integer', minimum: 1, maximum: REVIEW_ROUNDS_MAX, description: `How many reviews Andorra review posts at most (1 to ${REVIEW_ROUNDS_MAX}, default ${REVIEW_ROUNDS_DEFAULT})` },
|
|
797
|
+
reviewInstruction: property(`What Andorra review's reviewer should focus on, for example "focus on security" (at most ${REVIEW_INSTRUCTION_BYTES} bytes; empty clears it)`),
|
|
798
|
+
reviewModel: property('The reviewer\'s provider/model, for example anthropic/claude-sonnet-4-5 (empty: this task\'s model)'),
|
|
760
799
|
timeoutMinutes: { type: 'integer', minimum: 1, maximum: 1440, description: `How long await_review waits for a review before returning (1 to 1440, default ${AWAIT_REVIEW_DEFAULT_MINUTES})` },
|
|
761
800
|
}, ['action'], async (args, context) => {
|
|
762
801
|
const control = context.pullRequests;
|
|
763
802
|
if (!control)
|
|
764
803
|
throw new Error('pull_request is unavailable here; no session tracks a pull request for this run.');
|
|
765
|
-
const settings = pullRequestSettings(args);
|
|
804
|
+
const settings = { ...pullRequestSettings(args), ...reviewLoopSettings(args) };
|
|
766
805
|
const approve = () => approveOperation(context, 'pull_request', { ...args, warning: 'Changes the pull request on GitHub, or what Andorra does on its own when the PR changes.' });
|
|
767
|
-
const describe = (pr) => `${pr.url} (${pr.state})${pr.title ? ` "${pr.title}"` : ''}: autoFix ${pr.autoFix ? 'on' : 'off'}, mergeWhenReady ${pr.mergeWhenReady ? 'on' : 'off'}`;
|
|
806
|
+
const describe = (pr) => `${pr.url} (${pr.state})${pr.title ? ` "${pr.title}"` : ''}: autoFix ${pr.autoFix ? 'on' : 'off'}, mergeWhenReady ${pr.mergeWhenReady ? 'on' : 'off'}, ${describeReview(pr)}`;
|
|
768
807
|
switch (args.action) {
|
|
769
808
|
case 'status': {
|
|
770
809
|
const pr = await control.status();
|
|
@@ -778,7 +817,7 @@ export function createTools() {
|
|
|
778
817
|
}
|
|
779
818
|
case 'update': {
|
|
780
819
|
if (!Object.keys(settings).length)
|
|
781
|
-
throw new Error('update needs at least one of autoFix, mergeWhenReady, draft');
|
|
820
|
+
throw new Error('update needs at least one of autoFix, mergeWhenReady, draft, review, reviewRounds, reviewInstruction, reviewModel');
|
|
782
821
|
await approve();
|
|
783
822
|
return `Updated ${describe(await control.update(settings, context.wakeOrigin))}`;
|
|
784
823
|
}
|
|
@@ -789,14 +828,25 @@ export function createTools() {
|
|
|
789
828
|
if (typeof minutes !== 'number' || !Number.isSafeInteger(minutes) || minutes < 1 || minutes > 1_440)
|
|
790
829
|
throw new Error('timeoutMinutes must be an integer from 1 to 1440');
|
|
791
830
|
const awaitReview = control.awaitReview.bind(control);
|
|
792
|
-
const
|
|
831
|
+
const approveBump = (detail) => approveOperation(context, 'pull_request', { ...args, body: REVIEW_BUMP_COMMENT, warning: `Changes the pull request on GitHub. ${detail}` });
|
|
832
|
+
const wait = () => awaitReview(context.signal, minutes * 60_000, context.wakeOrigin, { approveBump });
|
|
793
833
|
const ended = await (context.waitOutside ? context.waitOutside(wait) : wait());
|
|
794
834
|
return reviewWaitAnswer(ended, minutes, context.signal);
|
|
795
835
|
}
|
|
836
|
+
case 'reply':
|
|
837
|
+
case 'resolve':
|
|
838
|
+
case 'comment': {
|
|
839
|
+
const write = agentWriteFromArgs(args);
|
|
840
|
+
if (!control.write)
|
|
841
|
+
throw new Error(`${args.action} is unavailable here; this surface cannot write on the pull request.`);
|
|
842
|
+
// Asked by the write once it knows the route and the write passes that route's checks (the bot's 16 KiB), before
|
|
843
|
+
// anything is sent; `detail` says who it posts as.
|
|
844
|
+
return control.write(write, { signal: context.signal, approve: detail => approveOperation(context, 'pull_request', { ...args, warning: `Changes the pull request on GitHub. ${detail}` }) });
|
|
845
|
+
}
|
|
796
846
|
case 'dismiss':
|
|
797
847
|
await control.dismiss();
|
|
798
848
|
return 'The pull request is no longer tracked for this session.';
|
|
799
|
-
default: throw new Error('action must be status, attach, update, await_review, or dismiss');
|
|
849
|
+
default: throw new Error('action must be status, attach, update, await_review, reply, resolve, comment, or dismiss');
|
|
800
850
|
}
|
|
801
851
|
}), family: 'git', executionMode: 'sequential' },
|
|
802
852
|
...createCodingTools({ safePath, read, readImage, readDocument, readLegacyText, atomicWrite, authorize, files, fileLimit: FILE_LIMIT }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andorra-labs/code",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "Terminal-first coding agent with a ReAct graph runtime",
|
|
5
5
|
"homepage": "https://andorracode.com",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -80,6 +80,11 @@
|
|
|
80
80
|
"typebox": "1.3.27",
|
|
81
81
|
"yaml": "2.9.0"
|
|
82
82
|
},
|
|
83
|
+
"overrides": {
|
|
84
|
+
"@npmcli/package-json": {
|
|
85
|
+
"glob": "14.0.6"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
83
88
|
"lavamoat": {
|
|
84
89
|
"allowScripts": {
|
|
85
90
|
"@google/genai#2.21.0": false,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
export interface RemoteTlsIdentity {
|
|
3
|
-
keyPem: string;
|
|
4
|
-
certPem: string;
|
|
5
|
-
fingerprint: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function certificateFingerprint(certPem: string): string;
|
|
8
|
-
export { pemFromDer } from './pem.js';
|
|
9
|
-
export declare function ensureRemoteTlsIdentity(tlsDirectory: string, options?: {
|
|
10
|
-
rotate?: boolean;
|
|
11
|
-
}): Promise<RemoteTlsIdentity>;
|
package/dist/src/remote/cert.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { createHash, createPrivateKey, createPublicKey, randomBytes, X509Certificate as NodeX509Certificate, webcrypto } from 'node:crypto';
|
|
2
|
-
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import 'reflect-metadata';
|
|
5
|
-
import * as x509 from '@peculiar/x509';
|
|
6
|
-
import { acquireSaveLock, SaveLockBusyError } from '../save-lock.js';
|
|
7
|
-
import { toPem } from './pem.js';
|
|
8
|
-
x509.cryptoProvider.set(webcrypto);
|
|
9
|
-
const CERTIFICATE_LIFETIME_MS = 10 * 365 * 24 * 60 * 60 * 1000;
|
|
10
|
-
export function certificateFingerprint(certPem) {
|
|
11
|
-
const der = new NodeX509Certificate(certPem).raw;
|
|
12
|
-
return createHash('sha256').update(der).digest('base64url');
|
|
13
|
-
}
|
|
14
|
-
export { pemFromDer } from './pem.js';
|
|
15
|
-
function storedPairUsable(certPem, keyPem) {
|
|
16
|
-
try {
|
|
17
|
-
const cert = new NodeX509Certificate(certPem);
|
|
18
|
-
const publicKeyPem = cert.publicKey.export({ type: 'spki', format: 'pem' });
|
|
19
|
-
const storedPublicKeyPem = createPublicKey(createPrivateKey(keyPem)).export({ type: 'spki', format: 'pem' });
|
|
20
|
-
return Date.parse(cert.validTo) >= Date.now() && publicKeyPem === storedPublicKeyPem;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async function loadStablePair(tlsDirectory) {
|
|
27
|
-
try {
|
|
28
|
-
const [certPem, keyPem] = await Promise.all([
|
|
29
|
-
readFile(join(tlsDirectory, 'cert.pem'), 'utf8'),
|
|
30
|
-
readFile(join(tlsDirectory, 'key.pem'), 'utf8'),
|
|
31
|
-
]);
|
|
32
|
-
if (!storedPairUsable(certPem, keyPem))
|
|
33
|
-
return null;
|
|
34
|
-
return { certPem, keyPem, fingerprint: certificateFingerprint(certPem) };
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export async function ensureRemoteTlsIdentity(tlsDirectory, options = {}) {
|
|
41
|
-
await mkdir(tlsDirectory, { recursive: true });
|
|
42
|
-
let release;
|
|
43
|
-
for (let attempt = 0; release === undefined; attempt += 1) {
|
|
44
|
-
try {
|
|
45
|
-
release = await acquireSaveLock(tlsDirectory);
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
if (!(error instanceof SaveLockBusyError))
|
|
49
|
-
throw error;
|
|
50
|
-
if (attempt >= 200) {
|
|
51
|
-
const published = await loadStablePair(tlsDirectory);
|
|
52
|
-
if (published)
|
|
53
|
-
return published;
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
56
|
-
await new Promise(resolve => setTimeout(resolve, 25));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
if (!options.rotate) {
|
|
61
|
-
const existing = await loadStablePair(tlsDirectory);
|
|
62
|
-
if (existing)
|
|
63
|
-
return existing;
|
|
64
|
-
}
|
|
65
|
-
const keys = await webcrypto.subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-256' }, true, ['sign', 'verify']);
|
|
66
|
-
const now = Date.now();
|
|
67
|
-
const certificate = await x509.X509CertificateGenerator.createSelfSigned({
|
|
68
|
-
serialNumber: randomBytes(8).toString('hex'),
|
|
69
|
-
name: 'CN=andorra-remote',
|
|
70
|
-
notBefore: new Date(now - 60_000),
|
|
71
|
-
notAfter: new Date(now + CERTIFICATE_LIFETIME_MS),
|
|
72
|
-
keys,
|
|
73
|
-
}, webcrypto);
|
|
74
|
-
const keyPem = toPem('PRIVATE KEY', new Uint8Array(await webcrypto.subtle.exportKey('pkcs8', keys.privateKey)));
|
|
75
|
-
const certPem = certificate.toString('pem');
|
|
76
|
-
const stagedKey = join(tlsDirectory, `key-${randomBytes(6).toString('hex')}.tmp`);
|
|
77
|
-
const stagedCert = join(tlsDirectory, `cert-${randomBytes(6).toString('hex')}.tmp`);
|
|
78
|
-
await writeFile(stagedKey, keyPem, { mode: 0o600 });
|
|
79
|
-
await writeFile(stagedCert, certPem, { mode: 0o600 });
|
|
80
|
-
await rename(stagedKey, join(tlsDirectory, 'key.pem'));
|
|
81
|
-
await rename(stagedCert, join(tlsDirectory, 'cert.pem'));
|
|
82
|
-
return { keyPem, certPem, fingerprint: certificateFingerprint(certPem) };
|
|
83
|
-
}
|
|
84
|
-
finally {
|
|
85
|
-
await release();
|
|
86
|
-
}
|
|
87
|
-
}
|