@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
package/dist/src/bug-report.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { sessionAttachments, type SessionAttachments } from './bug-report-attachments.js';
|
|
1
2
|
import type { Tool } from './types.js';
|
|
2
3
|
/** The built-in skill that interviews the user; a run that carries it also gets the tool below. */
|
|
3
4
|
export declare const BUG_REPORT_SKILL = "andorra:bug-report";
|
|
4
5
|
export declare const BUG_REPORT_TOOL = "submit_bug_report";
|
|
6
|
+
/** Tells the interview which session this conversation is and which others exist, so it can ask where the bug was. */
|
|
7
|
+
export declare const BUG_REPORT_SESSIONS_TOOL = "list_bug_report_sessions";
|
|
8
|
+
/** The two `session` answers that are not a session id. */
|
|
9
|
+
export declare const CURRENT_SESSION = "current";
|
|
10
|
+
export declare const NO_SESSION = "none";
|
|
5
11
|
export declare const SEND_CHOICE = "Send report";
|
|
6
12
|
export declare const CANCEL_CHOICE = "Do not send";
|
|
7
13
|
/** The report's text fields with the byte limits the service enforces (infra/andorra-auth/bug_report.py). */
|
|
@@ -32,10 +38,11 @@ declare const FIELDS: readonly [{
|
|
|
32
38
|
readonly heading: "Actual";
|
|
33
39
|
}];
|
|
34
40
|
type FieldName = typeof FIELDS[number]['name'];
|
|
41
|
+
/** `graph` and `trajectory` are read from the session the user named; the model never writes them. */
|
|
35
42
|
export type BugReport = {
|
|
36
43
|
title: string;
|
|
37
44
|
description: string;
|
|
38
|
-
} & Partial<Record<Exclude<FieldName, 'title' | 'description'>, string
|
|
45
|
+
} & Partial<Record<Exclude<FieldName, 'title' | 'description'>, string>> & SessionAttachments;
|
|
39
46
|
export interface BugReportEnvironment {
|
|
40
47
|
appVersion?: string;
|
|
41
48
|
surface?: 'cli' | 'desktop';
|
|
@@ -49,8 +56,16 @@ export declare class BugReportError extends Error {
|
|
|
49
56
|
}
|
|
50
57
|
/** The report as it will be sent: trimmed, bounded, and with anything credential-shaped replaced. */
|
|
51
58
|
export declare function normalizeBugReport(args: Record<string, unknown>): BugReport;
|
|
52
|
-
/**
|
|
53
|
-
export declare function
|
|
59
|
+
/** Which session the report is about: this one, a named one, or none (a bug in the program, not in a session). */
|
|
60
|
+
export declare function reportSession(args: Record<string, unknown>): string;
|
|
61
|
+
/** What the closing line of the confirmation promises about the report. Shown every time, just above the choices. */
|
|
62
|
+
export declare const REPORT_USE = "is used only to debug the problem. It is kept in the Andorra team's private bug tracker and is never used to train models.";
|
|
63
|
+
/**
|
|
64
|
+
* Exactly what the user is asked to approve: every field that will be sent, the graph and trajectory in full
|
|
65
|
+
* when a session is attached, and how the report is used. `sessionNamed` is set when the user named a session,
|
|
66
|
+
* so a session that left nothing to attach is said rather than passed over.
|
|
67
|
+
*/
|
|
68
|
+
export declare function bugReportPreview(report: BugReport, environment: BugReportEnvironment, sessionNamed?: boolean): string;
|
|
54
69
|
export declare function bugReportEnvironment(env?: NodeJS.ProcessEnv, version?: () => Promise<string | undefined>): Promise<BugReportEnvironment>;
|
|
55
70
|
export interface BugReportDependencies {
|
|
56
71
|
accessToken(signal?: AbortSignal): Promise<string>;
|
|
@@ -69,10 +84,15 @@ export declare function createBugReportClient(deps: BugReportDependencies): BugR
|
|
|
69
84
|
export declare const bugReports: BugReportClient;
|
|
70
85
|
export interface BugReportToolOptions {
|
|
71
86
|
client?: BugReportClient;
|
|
87
|
+
/** Where sessions and trajectories are kept. Defaults to the run's own home. */
|
|
88
|
+
home?: string;
|
|
89
|
+
attachments?: typeof sessionAttachments;
|
|
72
90
|
environment?: () => Promise<BugReportEnvironment>;
|
|
73
91
|
/** Tells the surface a question is open, the way ask_user does, so the tool clock pauses while it waits. */
|
|
74
92
|
emit?: (type: string, data: Record<string, unknown>) => void | Promise<void>;
|
|
75
93
|
}
|
|
94
|
+
/** Lists the sessions a report can be about. It reads names and dates only, and nothing leaves the machine. */
|
|
95
|
+
export declare function bugReportSessionsTool(options?: Pick<BugReportToolOptions, 'home'>): Tool;
|
|
76
96
|
/**
|
|
77
97
|
* Files a bug report with the Andorra team. The report leaves the machine only after the user has read
|
|
78
98
|
* exactly what will be sent and chosen to send it, so the tool refuses on a surface where nobody can answer.
|
package/dist/src/bug-report.js
CHANGED
|
@@ -2,10 +2,17 @@ import { readFile } from 'node:fs/promises';
|
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { AUTH_DEPLOYMENT } from './auth/deployment.js';
|
|
4
4
|
import { AuthError } from './auth/types.js';
|
|
5
|
+
import { configDirectory } from './config.js';
|
|
5
6
|
import { redactSecrets } from './memory/redaction.js';
|
|
7
|
+
import { GRAPH_LIMIT, TRAJECTORY_LIMIT, listReportSessions, sessionAttachments, sessionExists } from './bug-report-attachments.js';
|
|
6
8
|
/** The built-in skill that interviews the user; a run that carries it also gets the tool below. */
|
|
7
9
|
export const BUG_REPORT_SKILL = 'andorra:bug-report';
|
|
8
10
|
export const BUG_REPORT_TOOL = 'submit_bug_report';
|
|
11
|
+
/** Tells the interview which session this conversation is and which others exist, so it can ask where the bug was. */
|
|
12
|
+
export const BUG_REPORT_SESSIONS_TOOL = 'list_bug_report_sessions';
|
|
13
|
+
/** The two `session` answers that are not a session id. */
|
|
14
|
+
export const CURRENT_SESSION = 'current';
|
|
15
|
+
export const NO_SESSION = 'none';
|
|
9
16
|
export const SEND_CHOICE = 'Send report';
|
|
10
17
|
export const CANCEL_CHOICE = 'Do not send';
|
|
11
18
|
/** The report's text fields with the byte limits the service enforces (infra/andorra-auth/bug_report.py). */
|
|
@@ -49,9 +56,9 @@ function fieldText(value, field) {
|
|
|
49
56
|
}
|
|
50
57
|
/** The report as it will be sent: trimmed, bounded, and with anything credential-shaped replaced. */
|
|
51
58
|
export function normalizeBugReport(args) {
|
|
52
|
-
const unknown = Object.keys(args).filter(key => !FIELDS.some(field => field.name === key));
|
|
59
|
+
const unknown = Object.keys(args).filter(key => key !== 'session' && !FIELDS.some(field => field.name === key));
|
|
53
60
|
if (unknown.length)
|
|
54
|
-
throw new BugReportError('invalid', `Unknown bug report field${unknown.length === 1 ? '' : 's'}: ${unknown.join(', ')}. Use title, description, steps, expected and
|
|
61
|
+
throw new BugReportError('invalid', `Unknown bug report field${unknown.length === 1 ? '' : 's'}: ${unknown.join(', ')}. Use title, description, steps, expected, actual and session.`);
|
|
55
62
|
const report = {};
|
|
56
63
|
for (const field of FIELDS) {
|
|
57
64
|
const text = fieldText(args[field.name], field);
|
|
@@ -60,13 +67,32 @@ export function normalizeBugReport(args) {
|
|
|
60
67
|
}
|
|
61
68
|
return report;
|
|
62
69
|
}
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
const SESSION_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
71
|
+
/** Which session the report is about: this one, a named one, or none (a bug in the program, not in a session). */
|
|
72
|
+
export function reportSession(args) {
|
|
73
|
+
const value = typeof args.session === 'string' ? args.session.trim() : '';
|
|
74
|
+
if (value === CURRENT_SESSION || value === NO_SESSION || SESSION_ID.test(value))
|
|
75
|
+
return value;
|
|
76
|
+
throw new BugReportError('invalid', `A bug report needs session: "${CURRENT_SESSION}" when the problem is in this conversation's session, a session id from ${BUG_REPORT_SESSIONS_TOOL} when it is in another one, or "${NO_SESSION}" when it is not tied to a session. Ask the user which, and call again.`);
|
|
77
|
+
}
|
|
78
|
+
/** What the closing line of the confirmation promises about the report. Shown every time, just above the choices. */
|
|
79
|
+
export const REPORT_USE = 'is used only to debug the problem. It is kept in the Andorra team\'s private bug tracker and is never used to train models.';
|
|
80
|
+
/**
|
|
81
|
+
* Exactly what the user is asked to approve: every field that will be sent, the graph and trajectory in full
|
|
82
|
+
* when a session is attached, and how the report is used. `sessionNamed` is set when the user named a session,
|
|
83
|
+
* so a session that left nothing to attach is said rather than passed over.
|
|
84
|
+
*/
|
|
85
|
+
export function bugReportPreview(report, environment, sessionNamed = false) {
|
|
65
86
|
const attached = [environment.appVersion ? `Andorra Code ${environment.appVersion}` : undefined, environment.surface, environment.os, environment.arch].filter(Boolean).join(', ');
|
|
87
|
+
const session = report.graph !== undefined || report.trajectory !== undefined;
|
|
66
88
|
return [
|
|
67
89
|
'Send this bug report to the Andorra team?',
|
|
68
90
|
...FIELDS.filter(field => report[field.name] !== undefined).map(field => `${field.heading}:\n${report[field.name]}`),
|
|
69
|
-
|
|
91
|
+
...(report.graph === undefined ? [] : [`Affected graph (its settings and routes; the text of each instruction is left out):\n${report.graph}`]),
|
|
92
|
+
...(report.trajectory === undefined ? [] : [`Compressed trajectory of the session (steps, tools, outcomes and error text):\n${report.trajectory}`]),
|
|
93
|
+
...(sessionNamed && !session ? ['That session left no graph or trajectory on this machine, so none is attached.'] : []),
|
|
94
|
+
`Also sent: your account id and plan, and ${attached}. Nothing else: no files, prompts or ${session ? 'model replies' : 'conversation'}.`,
|
|
95
|
+
`This report${session ? ', with the graph and trajectory above,' : ''} ${REPORT_USE}`,
|
|
70
96
|
].join('\n\n');
|
|
71
97
|
}
|
|
72
98
|
async function packageVersion() {
|
|
@@ -173,6 +199,29 @@ export const bugReports = createBugReportClient({
|
|
|
173
199
|
apiBaseUrl: () => AUTH_DEPLOYMENT.apiBaseUrl,
|
|
174
200
|
fetch: (...args) => globalThis.fetch(...args),
|
|
175
201
|
});
|
|
202
|
+
function attachment(name, value, limit) {
|
|
203
|
+
const text = value?.trim();
|
|
204
|
+
return text && Buffer.byteLength(text, 'utf8') <= limit ? { [name]: text } : {};
|
|
205
|
+
}
|
|
206
|
+
/** Lists the sessions a report can be about. It reads names and dates only, and nothing leaves the machine. */
|
|
207
|
+
export function bugReportSessionsTool(options = {}) {
|
|
208
|
+
return {
|
|
209
|
+
name: BUG_REPORT_SESSIONS_TOOL, executionMode: 'sequential',
|
|
210
|
+
description: 'List the sessions a bug report can be about: the one this conversation is in (marked current) and the most recent others, newest first. Call it once during the bug-report interview, before asking the user which session has the problem. It reads session names and dates on this machine and sends nothing.',
|
|
211
|
+
parameters: { type: 'object', properties: {}, additionalProperties: false },
|
|
212
|
+
eventOutput: () => 'Listed sessions.',
|
|
213
|
+
execute: async (_args, ctx) => {
|
|
214
|
+
ctx.signal.throwIfAborted();
|
|
215
|
+
const sessions = await listReportSessions(options.home ?? ctx.automationDirectory ?? configDirectory(), ctx.sessionId);
|
|
216
|
+
const current = sessions.find(session => session.current);
|
|
217
|
+
return JSON.stringify({
|
|
218
|
+
current: current ? { id: current.id, name: current.name } : null,
|
|
219
|
+
others: sessions.filter(session => !session.current).map(({ id, name, updatedAt }) => ({ id, name, updatedAt })),
|
|
220
|
+
note: `Ask the user whether the problem is in ${current ? `this session ("${current.name}")` : 'this conversation'}, in another session, or not tied to a session. Pass ${BUG_REPORT_TOOL} session "${CURRENT_SESSION}", the other session's id, or "${NO_SESSION}".${current ? '' : ' This conversation has not been saved as a session yet, so "current" has nothing to attach.'}`,
|
|
221
|
+
});
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
}
|
|
176
225
|
/**
|
|
177
226
|
* Files a bug report with the Andorra team. The report leaves the machine only after the user has read
|
|
178
227
|
* exactly what will be sent and chosen to send it, so the tool refuses on a surface where nobody can answer.
|
|
@@ -183,14 +232,15 @@ export function bugReportTool(options = {}) {
|
|
|
183
232
|
const text = { type: 'string', minLength: 1 };
|
|
184
233
|
return {
|
|
185
234
|
name: BUG_REPORT_TOOL, executionMode: 'sequential',
|
|
186
|
-
description: 'Send a bug report about Andorra Code to the Andorra team. Call it only after the bug-report skill\'s interview, with the answers the user gave: never invent steps or details. The tool shows the user the exact report and sends it only if they choose to; a different answer comes back to you as their requested change. It needs a signed-in Andorra account (any plan). Never put credentials, private code or file contents in a report.',
|
|
235
|
+
description: 'Send a bug report about Andorra Code to the Andorra team. Call it only after the bug-report skill\'s interview, with the answers the user gave: never invent steps or details. Pass the session the user said has the problem; the tool reads that session\'s graph and a compressed trajectory itself and attaches them, so do not write either into the text. The tool shows the user the exact report and sends it only if they choose to; a different answer comes back to you as their requested change. It needs a signed-in Andorra account (any plan). Never put credentials, private code or file contents in a report.',
|
|
187
236
|
parameters: { type: 'object', properties: {
|
|
188
237
|
title: { ...text, maxLength: 120, description: 'One line naming the problem, for example "Send button does nothing after attaching a file".' },
|
|
189
238
|
description: { ...text, maxLength: 4000, description: 'What happened, in the user\'s words, with any error text they saw.' },
|
|
190
239
|
steps: { ...text, maxLength: 2000, description: 'Numbered steps that reproduce it, if the user knows them.' },
|
|
191
240
|
expected: { ...text, maxLength: 1000, description: 'What the user expected to happen.' },
|
|
192
241
|
actual: { ...text, maxLength: 2000, description: 'What happened instead.' },
|
|
193
|
-
|
|
242
|
+
session: { ...text, maxLength: 64, description: `Where the problem happened, as the user answered: "${CURRENT_SESSION}" for this conversation's session, the id of another session from ${BUG_REPORT_SESSIONS_TOOL}, or "${NO_SESSION}" for a bug in the program that is not tied to a session.` },
|
|
243
|
+
}, required: ['title', 'description', 'session'], additionalProperties: false },
|
|
194
244
|
eventOutput: output => {
|
|
195
245
|
try {
|
|
196
246
|
const result = JSON.parse(output);
|
|
@@ -202,13 +252,26 @@ export function bugReportTool(options = {}) {
|
|
|
202
252
|
},
|
|
203
253
|
execute: async (args, ctx) => {
|
|
204
254
|
ctx.signal.throwIfAborted();
|
|
205
|
-
const
|
|
255
|
+
const written = normalizeBugReport(args);
|
|
256
|
+
const session = reportSession(args);
|
|
206
257
|
if (ctx.approvalMode === 'headless' || !ctx.askUser)
|
|
207
258
|
throw new BugReportError('refused', 'A bug report is sent only after the user reads and confirms it, and nobody can answer on this surface. Nothing was sent. Tell the user to run /bug-report in an interactive session (the terminal app or the desktop app).');
|
|
208
259
|
// Checked first so a signed-out user is never asked to confirm a report that cannot be sent.
|
|
209
260
|
await client.token(ctx.signal);
|
|
210
261
|
const environment = await environmentOf();
|
|
211
|
-
const
|
|
262
|
+
const home = options.home ?? ctx.automationDirectory ?? configDirectory();
|
|
263
|
+
let found = {};
|
|
264
|
+
if (session !== NO_SESSION) {
|
|
265
|
+
const id = session === CURRENT_SESSION ? ctx.sessionId : session;
|
|
266
|
+
if (!id)
|
|
267
|
+
throw new BugReportError('invalid', `This conversation has no saved session to attach. Nothing was sent. Ask the user whether another session has the problem (${BUG_REPORT_SESSIONS_TOOL} lists them) or pass session "${NO_SESSION}".`);
|
|
268
|
+
if (!options.attachments && !await sessionExists(home, id))
|
|
269
|
+
throw new BugReportError('invalid', `There is no session ${id} on this machine. Nothing was sent. Use an id from ${BUG_REPORT_SESSIONS_TOOL}, "${CURRENT_SESSION}" or "${NO_SESSION}".`);
|
|
270
|
+
found = await (options.attachments ?? sessionAttachments)(home, id, { current: id === ctx.sessionId, signal: ctx.signal });
|
|
271
|
+
}
|
|
272
|
+
// Bounded again here: the attachments are built on this machine, and the service refuses a report over its limits.
|
|
273
|
+
const report = { ...written, ...attachment('graph', found.graph, GRAPH_LIMIT), ...attachment('trajectory', found.trajectory, TRAJECTORY_LIMIT) };
|
|
274
|
+
const question = bugReportPreview(report, environment, session !== NO_SESSION);
|
|
212
275
|
const choices = [SEND_CHOICE, CANCEL_CHOICE];
|
|
213
276
|
await options.emit?.('agent.clarification.requested', { question, choices });
|
|
214
277
|
let answer;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type FileDiffHunk } from './file-diff.js';
|
|
2
|
+
/**
|
|
3
|
+
* Who wrote which lines of a file the agent and the person both changed (design/specs/files-tab-v3.md, "As built
|
|
4
|
+
* (wrap-up)"). Three texts are compared: the baseline from before the task, what the agent last wrote (with the
|
|
5
|
+
* person's lines it carried over from an earlier save), and the file now. A line of the file now that is not in the
|
|
6
|
+
* agent's copy is the person's; a baseline line that the agent's copy kept but the file now lacks is one the person
|
|
7
|
+
* removed. Everything else the task changed is the agent's.
|
|
8
|
+
*/
|
|
9
|
+
export type LineRange = [number, number];
|
|
10
|
+
/** How the lines of one text map to another's: lines only in the new text, lines only in the old, and the rest paired. */
|
|
11
|
+
export interface LineMap {
|
|
12
|
+
added: Set<number>;
|
|
13
|
+
removed: Set<number>;
|
|
14
|
+
newOfOld: Map<number, number>;
|
|
15
|
+
}
|
|
16
|
+
/** The line pairing of two texts, or undefined when they are too large to pair line by line. Lines count from 1. */
|
|
17
|
+
export declare function lineMap(oldText: string, newText: string): LineMap | undefined;
|
|
18
|
+
/** Sorted, merged ranges of a set of line numbers. */
|
|
19
|
+
export declare function rangesOf(lines: Iterable<number>): LineRange[];
|
|
20
|
+
/**
|
|
21
|
+
* The person's lines in `current`: those not in the agent's copy, and those the agent's copy carried over from the
|
|
22
|
+
* person (`carried`, in the agent copy's numbering) that are still there. Undefined when the texts are too large.
|
|
23
|
+
*/
|
|
24
|
+
export declare function userLines(agentText: string, current: string, carried?: readonly LineRange[]): Set<number> | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The person's lines an agent write keeps: the person's lines in the text the agent wrote over (`before`) that the
|
|
27
|
+
* agent's text (`after`) still has, in the agent text's numbering.
|
|
28
|
+
*/
|
|
29
|
+
export declare function carriedUserLines(previousAgent: string, previousCarried: readonly LineRange[], before: string, after: string): LineRange[] | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* The baseline lines the person removed, in the baseline's numbering (which never moves): those the agent's copy kept
|
|
32
|
+
* that `current` lacks, and those an earlier save removed (`carried`) that are still gone.
|
|
33
|
+
*/
|
|
34
|
+
export declare function userRemovedLines(baseline: string, agentText: string, current: string, carried?: readonly LineRange[]): Set<number> | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Marks each added and removed line of the task's diff (baseline against the file now) with its author. Returns false,
|
|
37
|
+
* leaving the hunks unmarked, when the texts are too large to pair.
|
|
38
|
+
*/
|
|
39
|
+
export declare function markAuthors(hunks: FileDiffHunk[], baseline: string, agentText: string, current: string, carried?: readonly LineRange[], carriedRemoved?: readonly LineRange[]): boolean;
|
|
40
|
+
/** "line 12", "lines 12–14", "lines 3, 12–14 and 30"; past `limit` ranges, "… and 9 more places". */
|
|
41
|
+
export declare function linesWords(ranges: readonly LineRange[], limit?: number): string;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { textDiff } from './file-diff.js';
|
|
2
|
+
/** The line pairing of two texts, or undefined when they are too large to pair line by line. Lines count from 1. */
|
|
3
|
+
export function lineMap(oldText, newText) {
|
|
4
|
+
const diff = textDiff(oldText, newText, { context: 0, maxLines: Number.MAX_SAFE_INTEGER, maxChars: Number.MAX_SAFE_INTEGER, lineChars: 1 });
|
|
5
|
+
// A matcher that gave up pairs nothing in the middle: no line could be told apart, so nothing is claimed.
|
|
6
|
+
if (diff.coarse || diff.approximate)
|
|
7
|
+
return undefined;
|
|
8
|
+
const added = new Set();
|
|
9
|
+
const removed = new Set();
|
|
10
|
+
for (const hunk of diff.hunks)
|
|
11
|
+
for (const line of hunk.lines) {
|
|
12
|
+
if (line.kind === 'add' && line.newLine !== undefined)
|
|
13
|
+
added.add(line.newLine);
|
|
14
|
+
else if (line.kind === 'del' && line.oldLine !== undefined)
|
|
15
|
+
removed.add(line.oldLine);
|
|
16
|
+
}
|
|
17
|
+
const newOfOld = new Map();
|
|
18
|
+
const oldCount = countLines(oldText);
|
|
19
|
+
const newCount = countLines(newText);
|
|
20
|
+
for (let oldLine = 1, newLine = 1; oldLine <= oldCount; oldLine++) {
|
|
21
|
+
if (removed.has(oldLine))
|
|
22
|
+
continue;
|
|
23
|
+
while (newLine <= newCount && added.has(newLine))
|
|
24
|
+
newLine++;
|
|
25
|
+
if (newLine > newCount)
|
|
26
|
+
break;
|
|
27
|
+
newOfOld.set(oldLine, newLine);
|
|
28
|
+
newLine++;
|
|
29
|
+
}
|
|
30
|
+
return { added, removed, newOfOld };
|
|
31
|
+
}
|
|
32
|
+
function countLines(text) {
|
|
33
|
+
if (text === '')
|
|
34
|
+
return 0;
|
|
35
|
+
let count = 0;
|
|
36
|
+
for (let at = text.indexOf('\n'); at >= 0; at = text.indexOf('\n', at + 1))
|
|
37
|
+
count++;
|
|
38
|
+
return text.endsWith('\n') ? count : count + 1;
|
|
39
|
+
}
|
|
40
|
+
/** Whether `line` falls in sorted, non-overlapping `ranges` (binary search: a file can hold many of them). */
|
|
41
|
+
const inRanges = (ranges, line) => {
|
|
42
|
+
let low = 0, high = ranges.length - 1;
|
|
43
|
+
while (low <= high) {
|
|
44
|
+
const middle = (low + high) >> 1;
|
|
45
|
+
const [start, end] = ranges[middle];
|
|
46
|
+
if (line < start)
|
|
47
|
+
high = middle - 1;
|
|
48
|
+
else if (line > end)
|
|
49
|
+
low = middle + 1;
|
|
50
|
+
else
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
};
|
|
55
|
+
/** Sorted, merged ranges of a set of line numbers. */
|
|
56
|
+
export function rangesOf(lines) {
|
|
57
|
+
const sorted = [...new Set(lines)].sort((left, right) => left - right);
|
|
58
|
+
const out = [];
|
|
59
|
+
for (const line of sorted) {
|
|
60
|
+
const last = out.at(-1);
|
|
61
|
+
if (last && line === last[1] + 1)
|
|
62
|
+
last[1] = line;
|
|
63
|
+
else
|
|
64
|
+
out.push([line, line]);
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The person's lines in `current`: those not in the agent's copy, and those the agent's copy carried over from the
|
|
70
|
+
* person (`carried`, in the agent copy's numbering) that are still there. Undefined when the texts are too large.
|
|
71
|
+
*/
|
|
72
|
+
export function userLines(agentText, current, carried = []) {
|
|
73
|
+
const map = lineMap(agentText, current);
|
|
74
|
+
if (!map)
|
|
75
|
+
return undefined;
|
|
76
|
+
const lines = new Set(map.added);
|
|
77
|
+
if (carried.length)
|
|
78
|
+
for (const [oldLine, newLine] of map.newOfOld)
|
|
79
|
+
if (inRanges(carried, oldLine))
|
|
80
|
+
lines.add(newLine);
|
|
81
|
+
return lines;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The person's lines an agent write keeps: the person's lines in the text the agent wrote over (`before`) that the
|
|
85
|
+
* agent's text (`after`) still has, in the agent text's numbering.
|
|
86
|
+
*/
|
|
87
|
+
export function carriedUserLines(previousAgent, previousCarried, before, after) {
|
|
88
|
+
const theirs = userLines(previousAgent, before, previousCarried);
|
|
89
|
+
if (!theirs)
|
|
90
|
+
return undefined;
|
|
91
|
+
if (!theirs.size)
|
|
92
|
+
return [];
|
|
93
|
+
const map = lineMap(before, after);
|
|
94
|
+
if (!map)
|
|
95
|
+
return undefined;
|
|
96
|
+
const kept = [];
|
|
97
|
+
for (const line of theirs) {
|
|
98
|
+
const moved = map.newOfOld.get(line);
|
|
99
|
+
if (moved !== undefined)
|
|
100
|
+
kept.push(moved);
|
|
101
|
+
}
|
|
102
|
+
return rangesOf(kept);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The baseline lines the person removed, in the baseline's numbering (which never moves): those the agent's copy kept
|
|
106
|
+
* that `current` lacks, and those an earlier save removed (`carried`) that are still gone.
|
|
107
|
+
*/
|
|
108
|
+
export function userRemovedLines(baseline, agentText, current, carried = []) {
|
|
109
|
+
const agentKept = lineMap(baseline, agentText);
|
|
110
|
+
const now = lineMap(baseline, current);
|
|
111
|
+
if (!agentKept || !now)
|
|
112
|
+
return undefined;
|
|
113
|
+
const lines = new Set();
|
|
114
|
+
for (const line of now.removed)
|
|
115
|
+
if (!agentKept.removed.has(line) || inRanges(carried, line))
|
|
116
|
+
lines.add(line);
|
|
117
|
+
return lines;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Marks each added and removed line of the task's diff (baseline against the file now) with its author. Returns false,
|
|
121
|
+
* leaving the hunks unmarked, when the texts are too large to pair.
|
|
122
|
+
*/
|
|
123
|
+
export function markAuthors(hunks, baseline, agentText, current, carried = [], carriedRemoved = []) {
|
|
124
|
+
const theirs = userLines(agentText, current, carried);
|
|
125
|
+
const removed = userRemovedLines(baseline, agentText, current, carriedRemoved);
|
|
126
|
+
if (!theirs || !removed)
|
|
127
|
+
return false;
|
|
128
|
+
for (const hunk of hunks)
|
|
129
|
+
for (const line of hunk.lines) {
|
|
130
|
+
if (line.kind === 'add' && line.newLine !== undefined)
|
|
131
|
+
line.author = theirs.has(line.newLine) ? 'user' : 'agent';
|
|
132
|
+
else if (line.kind === 'del' && line.oldLine !== undefined)
|
|
133
|
+
line.author = removed.has(line.oldLine) ? 'user' : 'agent';
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
/** "line 12", "lines 12–14", "lines 3, 12–14 and 30"; past `limit` ranges, "… and 9 more places". */
|
|
138
|
+
export function linesWords(ranges, limit = 8) {
|
|
139
|
+
if (ranges.length > limit) {
|
|
140
|
+
const rest = ranges.length - limit;
|
|
141
|
+
return `${linesWords(ranges.slice(0, limit), limit).replace(' and ', ', ')}, and ${rest} more ${rest === 1 ? 'place' : 'places'}`;
|
|
142
|
+
}
|
|
143
|
+
const words = ranges.map(([start, end]) => (start === end ? `${start}` : `${start}–${end}`));
|
|
144
|
+
const noun = ranges.length === 1 && ranges[0][0] === ranges[0][1] ? 'line' : 'lines';
|
|
145
|
+
return `${noun} ${words.length > 1 ? `${words.slice(0, -1).join(', ')} and ${words.at(-1)}` : words[0]}`;
|
|
146
|
+
}
|
package/dist/src/cli.d.ts
CHANGED
|
@@ -13,9 +13,7 @@ export declare function isContinuationPrompt(text: string): boolean;
|
|
|
13
13
|
export declare function continuedTodos(task: string, lastRun?: RunResult): import('./todos.js').TodoItem[];
|
|
14
14
|
export { providerSecrets };
|
|
15
15
|
export declare function appendRunEvent(directory: string, event: RuntimeEvent): Promise<void>;
|
|
16
|
-
export type ResolvedNodeModel = import('./runtime.js').ResolvedGraphModel
|
|
17
|
-
reasoningEffort?: string;
|
|
18
|
-
};
|
|
16
|
+
export type ResolvedNodeModel = import('./runtime.js').ResolvedGraphModel;
|
|
19
17
|
export declare function withNodeModelResolution(event: RuntimeEvent, lookup: (provider: string, model: string) => Promise<ResolvedNodeModel | undefined> | undefined): Promise<RuntimeEvent>;
|
|
20
18
|
export declare function main(argv?: string[], dependencies?: {
|
|
21
19
|
loadGraph?: typeof loadAccessibleGraph;
|