@andorra-labs/code 0.1.15 → 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-definitions.js +29 -6
- package/dist/src/agent-execution.js +15 -10
- package/dist/src/agent-mcp-catalog.js +1 -0
- package/dist/src/agent-mcp.d.ts +4 -1
- package/dist/src/agent-mcp.js +46 -10
- 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 +22 -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 +465 -32
- package/dist/src/app-server.js +3308 -517
- package/dist/src/auth/deployment.js +2 -2
- 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-runner.js +1 -0
- package/dist/src/browser-server.js +7 -1
- package/dist/src/browser-ui/style.css +3 -3
- package/dist/src/browser-ui/tokens.css +28 -17
- package/dist/src/change-authors.d.ts +41 -0
- package/dist/src/change-authors.js +146 -0
- package/dist/src/claude-provider.js +3 -1
- package/dist/src/cli.js +202 -38
- package/dist/src/codex-errors.js +4 -1
- package/dist/src/coding-tools.js +15 -15
- package/dist/src/command-screens.d.ts +6 -0
- package/dist/src/command-screens.js +19 -14
- package/dist/src/commands.d.ts +14 -1
- package/dist/src/compaction-phrases.d.ts +4 -0
- package/dist/src/compaction-phrases.js +20 -0
- 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/context-compaction.js +2 -1
- package/dist/src/deadline.js +13 -1
- package/dist/src/decision/DecisionManager.js +3 -2
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/requestPhrases.d.ts +4 -0
- package/dist/src/decision/requestPhrases.js +22 -0
- 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-inbox.d.ts +55 -0
- package/dist/src/github-inbox.js +153 -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 +13 -4
- 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 +34 -11
- package/dist/src/graph-quota.d.ts +29 -2
- package/dist/src/graph-quota.js +68 -10
- package/dist/src/graph-runner.js +88 -10
- package/dist/src/graph-server.d.ts +1 -1
- package/dist/src/graph-server.js +11 -9
- package/dist/src/graph-sync.js +3 -3
- package/dist/src/graph-ui/app.js +201 -40
- package/dist/src/graph-ui/controls.css +1 -0
- package/dist/src/graph-ui/embed.js +2 -2
- package/dist/src/graph-ui/icons.js +3 -1
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graph-ui/manager.css +1 -1
- package/dist/src/graph-ui/manager.js +2 -2
- package/dist/src/graph-ui/sidebar.js +30 -0
- package/dist/src/graph-ui/studio-canvas.js +26 -13
- package/dist/src/graph-ui/studio.css +15 -7
- package/dist/src/graph-ui/studio.js +26 -5
- package/dist/src/graph-ui/style.css +77 -45
- package/dist/src/graph-ui/theme.js +3 -36
- package/dist/src/graph-ui/tokens.css +28 -20
- package/dist/src/graphs.d.ts +34 -1
- package/dist/src/graphs.js +162 -17
- package/dist/src/image-input.d.ts +16 -0
- package/dist/src/image-input.js +41 -0
- package/dist/src/membership.d.ts +30 -1
- package/dist/src/membership.js +48 -8
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +7 -1
- package/dist/src/model-metadata.js +39 -17
- 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/plan-pass.d.ts +59 -0
- package/dist/src/plan-pass.js +165 -0
- package/dist/src/project-registry.d.ts +21 -0
- package/dist/src/project-registry.js +74 -0
- package/dist/src/provider-engine.js +3 -0
- package/dist/src/provider-import.d.ts +0 -12
- package/dist/src/provider-import.js +7 -195
- package/dist/src/providers.d.ts +40 -2
- package/dist/src/providers.js +93 -23
- package/dist/src/pull-request-checks.d.ts +26 -0
- package/dist/src/pull-request-checks.js +56 -0
- package/dist/src/pull-request-conversation.d.ts +134 -0
- package/dist/src/pull-request-conversation.js +221 -0
- package/dist/src/pull-request-create.d.ts +175 -0
- package/dist/src/pull-request-create.js +392 -0
- package/dist/src/pull-request-details.d.ts +242 -0
- package/dist/src/pull-request-details.js +614 -0
- package/dist/src/pull-request-edit.d.ts +23 -0
- package/dist/src/pull-request-edit.js +91 -0
- package/dist/src/pull-request-logs.d.ts +87 -0
- package/dist/src/pull-request-logs.js +183 -0
- package/dist/src/pull-request-merge.d.ts +112 -0
- package/dist/src/pull-request-merge.js +258 -0
- package/dist/src/pull-request-review.d.ts +137 -0
- package/dist/src/pull-request-review.js +401 -0
- package/dist/src/pull-requests.d.ts +369 -8
- package/dist/src/pull-requests.js +524 -55
- package/dist/src/react-runtime.js +38 -5
- package/dist/src/remote/engine-pool.d.ts +88 -4
- package/dist/src/remote/engine-pool.js +379 -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 +17 -0
- package/dist/src/run-control.js +47 -0
- package/dist/src/run-progress.d.ts +10 -0
- package/dist/src/run-progress.js +122 -0
- package/dist/src/run-records.d.ts +7 -2
- package/dist/src/run-records.js +71 -6
- package/dist/src/runtime.d.ts +9 -1
- package/dist/src/runtime.js +24 -4
- 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/subagent-run.js +1 -0
- package/dist/src/telemetry/capture-core.d.ts +17 -0
- package/dist/src/telemetry/capture-core.js +59 -1
- package/dist/src/telemetry/classify.d.ts +3 -1
- package/dist/src/telemetry/classify.js +37 -0
- package/dist/src/telemetry/emitter.d.ts +17 -0
- package/dist/src/telemetry/emitter.js +76 -5
- package/dist/src/telemetry/schema.d.ts +47 -2
- package/dist/src/telemetry/schema.js +120 -5
- package/dist/src/telemetry/surface.d.ts +3 -1
- package/dist/src/telemetry/surface.js +4 -1
- package/dist/src/telemetry/uploader.d.ts +6 -1
- package/dist/src/telemetry/uploader.js +22 -3
- 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/dist/src/transcript.js +8 -2
- package/dist/src/types.d.ts +7 -0
- package/dist/src/usage-analytics.js +18 -10
- 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/config.js
CHANGED
|
@@ -43,6 +43,164 @@ export function isProjectExtensionOverride(entry) {
|
|
|
43
43
|
return false;
|
|
44
44
|
return true;
|
|
45
45
|
}
|
|
46
|
+
/** At most this many machines are allowed per account; allowing another drops the oldest. */
|
|
47
|
+
export const MODEL_RELAY_ALLOWED_LIMIT = 64;
|
|
48
|
+
const MODEL_RELAY_ACCOUNT_LIMIT = 64;
|
|
49
|
+
const ENVIRONMENT_ID = /^env_[A-Za-z0-9_-]{22}$/;
|
|
50
|
+
const ACCOUNT_SUBJECT = /^[A-Za-z0-9-]{1,128}$/;
|
|
51
|
+
/** The machines `subject` allowed to use this computer's models, from a saved `environments.modelRelay`. */
|
|
52
|
+
export function modelRelayAllowedFor(environments, subject) {
|
|
53
|
+
const saved = environments?.modelRelay;
|
|
54
|
+
if (subject === undefined || !saved || Array.isArray(saved) || !Object.hasOwn(saved, subject))
|
|
55
|
+
return [];
|
|
56
|
+
return [...saved[subject]];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* `map` with `subject`'s list set to `list` and moved to the end: the object's key order is the order in which the
|
|
60
|
+
* accounts' lists were last written. Past 64 accounts, the least recently written are dropped, so the file always
|
|
61
|
+
* validates. (Account subjects are Cognito ids, never integer-like keys, so the order holds.)
|
|
62
|
+
*/
|
|
63
|
+
export function withModelRelayEntry(map, subject, list) {
|
|
64
|
+
const others = Object.entries(map).filter(([key]) => key !== subject);
|
|
65
|
+
return Object.fromEntries([...others.slice(Math.max(0, others.length - (MODEL_RELAY_ACCOUNT_LIMIT - 1))), [subject, list.slice(-MODEL_RELAY_ALLOWED_LIMIT)]]);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The Andorra GitHub App, per user. `app.enabled: false` turns its events off on this installation (every PR
|
|
69
|
+
* is polled through gh, as without the App). `app.agentWrites` says who the agent's replies, resolves and PR
|
|
70
|
+
* comments post as on a PR the App covers: `bot` (the default) for the App's bot, `me` for the person's own gh
|
|
71
|
+
* account. `app.triggers: false` stops a mention of the App's bot on a task's PR from waking the task on this
|
|
72
|
+
* installation (the per-machine opt-out; on by default). `app.reviews: false` refuses switching the Andorra review loop
|
|
73
|
+
* on here (on by default); `app.reviewNewPullRequests: true` switches it on for each PR a task opens (off by default).
|
|
74
|
+
* Other keys under `github.app` belong to later versions and are kept as written.
|
|
75
|
+
*/
|
|
76
|
+
export const GITHUB_AGENT_WRITES = ['bot', 'me'];
|
|
77
|
+
export function validateGitHubConfig(value) {
|
|
78
|
+
const c = value;
|
|
79
|
+
if (!c || typeof c !== 'object' || Array.isArray(c))
|
|
80
|
+
throw new Error('Invalid github configuration');
|
|
81
|
+
if (c.app !== undefined && (!c.app || typeof c.app !== 'object' || Array.isArray(c.app)))
|
|
82
|
+
throw new Error('Invalid github.app configuration');
|
|
83
|
+
if (c.app?.enabled !== undefined && typeof c.app.enabled !== 'boolean')
|
|
84
|
+
throw new Error('github.app.enabled must be a boolean');
|
|
85
|
+
if (c.app?.agentWrites !== undefined && !GITHUB_AGENT_WRITES.includes(c.app.agentWrites))
|
|
86
|
+
throw new Error('github.app.agentWrites must be bot or me');
|
|
87
|
+
if (c.app?.triggers !== undefined && typeof c.app.triggers !== 'boolean')
|
|
88
|
+
throw new Error('github.app.triggers must be a boolean');
|
|
89
|
+
if (c.app?.reviews !== undefined && typeof c.app.reviews !== 'boolean')
|
|
90
|
+
throw new Error('github.app.reviews must be a boolean');
|
|
91
|
+
if (c.app?.reviewNewPullRequests !== undefined && typeof c.app.reviewNewPullRequests !== 'boolean')
|
|
92
|
+
throw new Error('github.app.reviewNewPullRequests must be a boolean');
|
|
93
|
+
return c;
|
|
94
|
+
}
|
|
95
|
+
/** Who the agent's PR writes post as: `me` only when the config says so; anything else, or no config, is `bot`. */
|
|
96
|
+
function agentWritesOf(config) {
|
|
97
|
+
const github = typeof config === 'object' && config !== null ? config.github : undefined;
|
|
98
|
+
const app = typeof github === 'object' && github !== null ? github.app : undefined;
|
|
99
|
+
return typeof app === 'object' && app !== null && app.agentWrites === 'me' ? 'me' : 'bot';
|
|
100
|
+
}
|
|
101
|
+
export function githubAgentWrites(config) {
|
|
102
|
+
return agentWritesOf(config);
|
|
103
|
+
}
|
|
104
|
+
/** The same, read from `config.json` for each write and each Auto-fix prompt, without validation or keyring; unreadable reads as `bot`. */
|
|
105
|
+
export async function readGitHubAgentWrites(directory) {
|
|
106
|
+
let value;
|
|
107
|
+
try {
|
|
108
|
+
value = JSON.parse(await readFile(join(directory, 'config.json'), 'utf8'));
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return 'bot';
|
|
112
|
+
}
|
|
113
|
+
return agentWritesOf(value);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The one rule for whether the GitHub App's events may run here: not switched off by `ANDORRA_GITHUB_APP=off`,
|
|
117
|
+
* nor by `github.app.enabled: false` in the config (parsed, or read raw from `config.json`).
|
|
118
|
+
*/
|
|
119
|
+
function githubAppEventsAllowed(config, env) {
|
|
120
|
+
if (env.ANDORRA_GITHUB_APP?.trim().toLowerCase() === 'off')
|
|
121
|
+
return false;
|
|
122
|
+
const github = typeof config === 'object' && config !== null ? config.github : undefined;
|
|
123
|
+
const app = typeof github === 'object' && github !== null ? github.app : undefined;
|
|
124
|
+
return !(typeof app === 'object' && app !== null && app.enabled === false);
|
|
125
|
+
}
|
|
126
|
+
/** Whether the GitHub App's events may run here: not switched off in config, nor by `ANDORRA_GITHUB_APP=off`. */
|
|
127
|
+
export function githubAppEventsEnabled(config, env = process.env) {
|
|
128
|
+
return githubAppEventsAllowed(config, env);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The same, read cheaply for a check that runs every minute: only `github.app.enabled` is taken from
|
|
132
|
+
* `config.json`, with no validation, no provider keys and no keyring. A missing or unreadable file reads as on,
|
|
133
|
+
* as `loadConfig`'s default config would.
|
|
134
|
+
*/
|
|
135
|
+
export async function readGitHubAppEventsEnabled(directory, env = process.env) {
|
|
136
|
+
if (!githubAppEventsAllowed(undefined, env))
|
|
137
|
+
return false;
|
|
138
|
+
let value;
|
|
139
|
+
try {
|
|
140
|
+
value = JSON.parse(await readFile(join(directory, 'config.json'), 'utf8'));
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
return githubAppEventsAllowed(value, env);
|
|
146
|
+
}
|
|
147
|
+
/** A mention of the bot may wake a task here: only `github.app.triggers: false` says no. */
|
|
148
|
+
function triggersOf(config) {
|
|
149
|
+
const github = typeof config === 'object' && config !== null ? config.github : undefined;
|
|
150
|
+
const app = typeof github === 'object' && github !== null ? github.app : undefined;
|
|
151
|
+
return !(typeof app === 'object' && app !== null && app.triggers === false);
|
|
152
|
+
}
|
|
153
|
+
export function githubAppTriggersEnabled(config) {
|
|
154
|
+
return triggersOf(config);
|
|
155
|
+
}
|
|
156
|
+
/** The same, read from `config.json` for each mention, without validation or keyring; a missing or unreadable file reads as on. */
|
|
157
|
+
export async function readGitHubAppTriggersEnabled(directory) {
|
|
158
|
+
let value;
|
|
159
|
+
try {
|
|
160
|
+
value = JSON.parse(await readFile(join(directory, 'config.json'), 'utf8'));
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
return triggersOf(value);
|
|
166
|
+
}
|
|
167
|
+
/** One boolean key under `github.app`, or undefined when the config does not set it. */
|
|
168
|
+
function githubAppFlag(config, key) {
|
|
169
|
+
const github = typeof config === 'object' && config !== null ? config.github : undefined;
|
|
170
|
+
const app = typeof github === 'object' && github !== null ? github.app : undefined;
|
|
171
|
+
const value = typeof app === 'object' && app !== null ? app[key] : undefined;
|
|
172
|
+
return typeof value === 'boolean' ? value : undefined;
|
|
173
|
+
}
|
|
174
|
+
/** The Andorra review loop may be switched on here: only `github.app.reviews: false` says no. */
|
|
175
|
+
export function githubAppReviewsEnabled(config) {
|
|
176
|
+
return githubAppFlag(config, 'reviews') !== false;
|
|
177
|
+
}
|
|
178
|
+
/** The same, read from `config.json` without validation or keyring; a missing or unreadable file reads as on. */
|
|
179
|
+
export async function readGitHubAppReviewsEnabled(directory) {
|
|
180
|
+
let value;
|
|
181
|
+
try {
|
|
182
|
+
value = JSON.parse(await readFile(join(directory, 'config.json'), 'utf8'));
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
return githubAppFlag(value, 'reviews') !== false;
|
|
188
|
+
}
|
|
189
|
+
/** A PR a task opens starts with the review loop on: only `github.app.reviewNewPullRequests: true` says so. */
|
|
190
|
+
export function githubAppReviewNewPullRequests(config) {
|
|
191
|
+
return githubAppFlag(config, 'reviewNewPullRequests') === true;
|
|
192
|
+
}
|
|
193
|
+
/** The same, read from `config.json`; a missing or unreadable file reads as off. */
|
|
194
|
+
export async function readGitHubAppReviewNewPullRequests(directory) {
|
|
195
|
+
let value;
|
|
196
|
+
try {
|
|
197
|
+
value = JSON.parse(await readFile(join(directory, 'config.json'), 'utf8'));
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
return githubAppFlag(value, 'reviewNewPullRequests') === true;
|
|
203
|
+
}
|
|
46
204
|
export const MAX_CAPSOLVER_API_KEY_LENGTH = 256;
|
|
47
205
|
export function validateBrowserConfig(value) {
|
|
48
206
|
const c = value;
|
|
@@ -235,6 +393,8 @@ export function validateConfig(value) {
|
|
|
235
393
|
validateBrowserConfig(c.browser);
|
|
236
394
|
if (c.webSearch !== undefined)
|
|
237
395
|
validateWebSearchConfig(c.webSearch);
|
|
396
|
+
if (c.github !== undefined)
|
|
397
|
+
validateGitHubConfig(c.github);
|
|
238
398
|
if (c.extensions !== undefined) {
|
|
239
399
|
if (!c.extensions || typeof c.extensions !== 'object' || Array.isArray(c.extensions))
|
|
240
400
|
throw new Error('Invalid extensions configuration');
|
|
@@ -256,8 +416,10 @@ export function validateConfig(value) {
|
|
|
256
416
|
|| Object.entries(c.projectExtensions).some(([key, entry]) => !/^[a-f0-9]{64}$/.test(key) || !isProjectExtensionOverride(entry)))) {
|
|
257
417
|
throw new Error('Invalid projectExtensions configuration');
|
|
258
418
|
}
|
|
259
|
-
if (c.
|
|
260
|
-
|
|
419
|
+
if (c.bridge !== undefined)
|
|
420
|
+
validateBridgeConfig(c.bridge);
|
|
421
|
+
if (c.environments !== undefined)
|
|
422
|
+
validateEnvironmentsConfig(c.environments);
|
|
261
423
|
if (c.projects !== undefined)
|
|
262
424
|
validateProjectsConfig(c.projects);
|
|
263
425
|
if (c.externalSubagent !== undefined && !c.providers.some(p => p?.id === c.externalSubagent.provider)) {
|
|
@@ -271,6 +433,9 @@ export function validateConfig(value) {
|
|
|
271
433
|
const ids = new Set();
|
|
272
434
|
let andorraSeen = false;
|
|
273
435
|
for (const p of c.providers) {
|
|
436
|
+
// A relayed provider lives only in the run that a desktop started with it: never in a config file.
|
|
437
|
+
if (p && typeof p === 'object' && p.type === 'relayed')
|
|
438
|
+
throw new Error('Relayed providers cannot be saved.');
|
|
274
439
|
if (p && typeof p === 'object' && p.type === 'andorra')
|
|
275
440
|
normaliseAndorraEntry(p);
|
|
276
441
|
if (!p || typeof p.id !== 'string' || !/^[\w-]+$/.test(p.id) || ids.has(p.id)
|
|
@@ -294,6 +459,9 @@ export function validateConfig(value) {
|
|
|
294
459
|
throw new Error(`The active model must be one of provider ${p.id}'s configured models`);
|
|
295
460
|
}
|
|
296
461
|
}
|
|
462
|
+
if (p.textOnlyModels !== undefined && (!Array.isArray(p.textOnlyModels) || p.textOnlyModels.some((model) => typeof model !== 'string' || !model.trim() || model.length > 500))) {
|
|
463
|
+
throw new Error('Provider textOnlyModels must be a list of nonempty model ids');
|
|
464
|
+
}
|
|
297
465
|
if (p.modelContextWindows !== undefined) {
|
|
298
466
|
if (!p.modelContextWindows || typeof p.modelContextWindows !== 'object' || Array.isArray(p.modelContextWindows)) {
|
|
299
467
|
throw new Error('Provider modelContextWindows must map model ids to positive integer context windows');
|
|
@@ -785,9 +953,6 @@ export function resolveCodeIntelConfig(config) {
|
|
|
785
953
|
validateCodeIntelConfig(codeIntel);
|
|
786
954
|
return codeIntel;
|
|
787
955
|
}
|
|
788
|
-
const BASE64URL_32 = /^[A-Za-z0-9_-]{43}$/;
|
|
789
|
-
const HEX_16 = /^[a-f0-9]{16}$/;
|
|
790
|
-
const HEX_32 = /^[a-f0-9]{32}$/;
|
|
791
956
|
const HEX_12 = /^[a-f0-9]{12}$/;
|
|
792
957
|
const ISO_DATE = /^\d{4}-\d{2}-\d{2}T/;
|
|
793
958
|
function isDisplayLabel(value) {
|
|
@@ -796,80 +961,40 @@ function isDisplayLabel(value) {
|
|
|
796
961
|
function isIsoDate(value) {
|
|
797
962
|
return typeof value === 'string' && ISO_DATE.test(value) && !Number.isNaN(Date.parse(value));
|
|
798
963
|
}
|
|
799
|
-
function
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
if (h.transport !== undefined && h.transport !== 'https' && h.transport !== 'http')
|
|
815
|
-
throw new Error('remote.hosting.transport must be https or http');
|
|
816
|
-
if (h.invitation !== undefined && h.invitation !== null) {
|
|
817
|
-
const i = h.invitation;
|
|
818
|
-
if (!i || typeof i !== 'object' || Array.isArray(i) || !BASE64URL_32.test(i.token) || !isIsoDate(i.createdAt) || !isIsoDate(i.expiresAt)
|
|
819
|
-
|| (i.redeemedAt !== undefined && !isIsoDate(i.redeemedAt))
|
|
820
|
-
|| (i.grant !== undefined && i.grant !== 'browse' && i.grant !== 'full'))
|
|
821
|
-
throw new Error('Invalid remote invitation');
|
|
822
|
-
}
|
|
823
|
-
if (h.devices !== undefined) {
|
|
824
|
-
if (!Array.isArray(h.devices) || h.devices.length > 32)
|
|
825
|
-
throw new Error('remote.hosting.devices must be an array of at most 32 devices');
|
|
826
|
-
const ids = new Set();
|
|
827
|
-
for (const device of h.devices) {
|
|
828
|
-
if (!device || typeof device !== 'object' || Array.isArray(device) || !HEX_16.test(device.id) || ids.has(device.id)
|
|
829
|
-
|| !BASE64URL_32.test(device.token) || !isIsoDate(device.addedAt)
|
|
830
|
-
|| (device.label !== undefined && !isDisplayLabel(device.label))
|
|
831
|
-
|| (device.lastSeenAt !== undefined && !isIsoDate(device.lastSeenAt))
|
|
832
|
-
|| (device.grant !== undefined && device.grant !== 'browse' && device.grant !== 'full'))
|
|
833
|
-
throw new Error('Invalid paired remote device');
|
|
834
|
-
ids.add(device.id);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
if (h.shares !== undefined) {
|
|
838
|
-
if (!Array.isArray(h.shares) || h.shares.length > 64)
|
|
839
|
-
throw new Error('remote.hosting.shares must be an array of at most 64 shares');
|
|
840
|
-
const ids = new Set();
|
|
841
|
-
for (const share of h.shares) {
|
|
842
|
-
if (!share || typeof share !== 'object' || Array.isArray(share) || !HEX_12.test(share.id) || ids.has(share.id)
|
|
843
|
-
|| typeof share.path !== 'string' || !share.path.trim() || share.path.includes('\0')
|
|
844
|
-
|| (share.label !== undefined && !isDisplayLabel(share.label)))
|
|
845
|
-
throw new Error('Invalid remote share');
|
|
846
|
-
ids.add(share.id);
|
|
847
|
-
}
|
|
848
|
-
}
|
|
964
|
+
export function validateBridgeConfig(bridge) {
|
|
965
|
+
const b = bridge;
|
|
966
|
+
if (!b || typeof b !== 'object' || Array.isArray(b))
|
|
967
|
+
throw new Error('Invalid bridge configuration');
|
|
968
|
+
if (b.folders === undefined)
|
|
969
|
+
return;
|
|
970
|
+
if (!Array.isArray(b.folders) || b.folders.length > 64)
|
|
971
|
+
throw new Error('bridge.folders must be an array of at most 64 folders');
|
|
972
|
+
const ids = new Set();
|
|
973
|
+
for (const folder of b.folders) {
|
|
974
|
+
if (!folder || typeof folder !== 'object' || Array.isArray(folder) || typeof folder.id !== 'string' || !HEX_12.test(folder.id) || ids.has(folder.id)
|
|
975
|
+
|| typeof folder.path !== 'string' || !folder.path.trim() || folder.path.includes('\0')
|
|
976
|
+
|| (folder.label !== undefined && !isDisplayLabel(folder.label)))
|
|
977
|
+
throw new Error('Invalid bridge folder');
|
|
978
|
+
ids.add(folder.id);
|
|
849
979
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|| (workspace.transport === 'https'
|
|
863
|
-
? (typeof workspace.certPem !== 'string' || !workspace.certPem.includes('BEGIN CERTIFICATE'))
|
|
864
|
-
: (workspace.certPem !== undefined && typeof workspace.certPem !== 'string'))
|
|
865
|
-
|| !BASE64URL_32.test(workspace.token) || !isIsoDate(workspace.addedAt)
|
|
866
|
-
|| (workspace.hostname !== undefined && (typeof workspace.hostname !== 'string' || !workspace.hostname.trim() || workspace.hostname.length > 128 || /[\0\r\n]/.test(workspace.hostname)))
|
|
867
|
-
|| (workspace.platform !== undefined && (typeof workspace.platform !== 'string' || !workspace.platform.trim() || workspace.platform.length > 64 || /[\0\r\n]/.test(workspace.platform)))
|
|
868
|
-
|| (workspace.version !== undefined && (typeof workspace.version !== 'string' || !workspace.version.trim() || workspace.version.length > 64 || /[\0\r\n]/.test(workspace.version))))
|
|
869
|
-
throw new Error('Invalid paired remote workspace');
|
|
870
|
-
ids.add(workspace.id);
|
|
871
|
-
}
|
|
980
|
+
}
|
|
981
|
+
export function validateEnvironmentsConfig(environments) {
|
|
982
|
+
const e = environments;
|
|
983
|
+
if (!e || typeof e !== 'object' || Array.isArray(e) || Object.keys(e).some(key => key !== 'modelRelay'))
|
|
984
|
+
throw new Error('Invalid environments configuration');
|
|
985
|
+
if (e.modelRelay === undefined)
|
|
986
|
+
return;
|
|
987
|
+
// The earlier list shape is read as nothing allowed; it is still a valid file.
|
|
988
|
+
if (Array.isArray(e.modelRelay)) {
|
|
989
|
+
if (e.modelRelay.length > MODEL_RELAY_ALLOWED_LIMIT || e.modelRelay.some(id => typeof id !== 'string'))
|
|
990
|
+
throw new Error('environments.modelRelay must map accounts to at most 64 environment ids');
|
|
991
|
+
return;
|
|
872
992
|
}
|
|
993
|
+
const byAccount = e.modelRelay;
|
|
994
|
+
if (!byAccount || typeof byAccount !== 'object' || Object.keys(byAccount).length > MODEL_RELAY_ACCOUNT_LIMIT
|
|
995
|
+
|| Object.entries(byAccount).some(([subject, ids]) => !ACCOUNT_SUBJECT.test(subject) || !Array.isArray(ids) || ids.length > MODEL_RELAY_ALLOWED_LIMIT
|
|
996
|
+
|| ids.some(id => typeof id !== 'string' || !ENVIRONMENT_ID.test(id))))
|
|
997
|
+
throw new Error('environments.modelRelay must map accounts to at most 64 environment ids');
|
|
873
998
|
}
|
|
874
999
|
export function validateProjectsConfig(projects) {
|
|
875
1000
|
if (!Array.isArray(projects) || projects.length > 256)
|
|
@@ -2,6 +2,7 @@ import { engineModel } from './engine/protocol.js';
|
|
|
2
2
|
import { generateWithUsage } from './runtime.js';
|
|
3
3
|
import { selectCompactGroups } from '../vendor/zcode/source/compact/selection.js';
|
|
4
4
|
import { serializeContext } from './context-budget.js';
|
|
5
|
+
import { pickCompactionPhrase } from './compaction-phrases.js';
|
|
5
6
|
export const EFFICIENT_CONTEXT_POLICY = { triggerChars: 128_000, targetChars: 64_000, keepRecentToolTurns: 8, protectDiscovery: true };
|
|
6
7
|
function completeExchanges(messages) {
|
|
7
8
|
const exchanges = [];
|
|
@@ -248,7 +249,7 @@ export class HistoryCompactor {
|
|
|
248
249
|
let batchTarget = targetChars;
|
|
249
250
|
let batchMaxTokens = maxTokens;
|
|
250
251
|
await options.onEvent?.({ type: 'agent.context.compaction.started', time: new Date().toISOString(), data: {
|
|
251
|
-
runId: result.id, nodeId: options.nodeId ?? 'engineer', ...(options.subagentId ? { subagentId: options.subagentId } : {}), maxTokens: batchMaxTokens, batch: batchNumber,
|
|
252
|
+
runId: result.id, nodeId: options.nodeId ?? 'engineer', ...(options.subagentId ? { subagentId: options.subagentId } : {}), maxTokens: batchMaxTokens, batch: batchNumber, text: pickCompactionPhrase(),
|
|
252
253
|
} });
|
|
253
254
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
254
255
|
signal.throwIfAborted();
|
package/dist/src/deadline.js
CHANGED
|
@@ -84,8 +84,20 @@ export function createRuntimeBudget(callerSignal, wallTimeMs, control) {
|
|
|
84
84
|
resume = undefined;
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
|
|
87
|
+
const unsubscribePause = control.onChange(changed);
|
|
88
88
|
changed(control.isPaused);
|
|
89
|
+
let resumeHold;
|
|
90
|
+
const held = (holding) => {
|
|
91
|
+
if (holding)
|
|
92
|
+
resumeHold ??= budget.suspend();
|
|
93
|
+
else {
|
|
94
|
+
resumeHold?.();
|
|
95
|
+
resumeHold = undefined;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const unsubscribeHold = control.onBudgetHold(held);
|
|
99
|
+
held(control.budgetsHeld);
|
|
100
|
+
unsubscribe = () => { unsubscribePause(); unsubscribeHold(); };
|
|
89
101
|
}
|
|
90
102
|
return budget;
|
|
91
103
|
}
|
|
@@ -10,6 +10,7 @@ import { HOSTED_SKILL_LIMIT, hostedSkillLimitNotice, rankHostedSkills } from './
|
|
|
10
10
|
import { markFactGuidance } from './guidancePolicy.js';
|
|
11
11
|
import { actionablePreflightQuestion, answerOnlyTask } from './optimizationPolicy.js';
|
|
12
12
|
import { parseToolRouteEvidence } from './routeTools.js';
|
|
13
|
+
import { pickJevRequestPhrase } from './requestPhrases.js';
|
|
13
14
|
const FACT_TIMEOUT_MS = 2000;
|
|
14
15
|
const families = new Set(['filesystem-read', 'filesystem-write', 'code-search', 'codegraph', 'git', 'shell', 'memory', 'web', 'browser', 'subagents', 'artifact']);
|
|
15
16
|
export const toolFamilyQuestion = (family) => `tool_family_${family.replace(/-/g, '_')}`;
|
|
@@ -173,7 +174,7 @@ export class DecisionManager {
|
|
|
173
174
|
};
|
|
174
175
|
const evaluateFact = this.provider.evaluateFact?.bind(this.provider);
|
|
175
176
|
if (!evaluateFact) {
|
|
176
|
-
emit('decision.requested', { questions: [request.id] });
|
|
177
|
+
emit('decision.requested', { questions: [request.id], text: pickJevRequestPhrase() });
|
|
177
178
|
emit('decision.fallback', { reason: 'provider_unavailable' });
|
|
178
179
|
return undefined;
|
|
179
180
|
}
|
|
@@ -229,7 +230,7 @@ export class DecisionManager {
|
|
|
229
230
|
return this.settle(questions.map(q => q.id), (controllerSignal, deadlineAt) => this.provider.evaluate(structuredClone(snapshot), structuredClone(questions), controllerSignal, this.observer(emit), { deadlineAt }), value => validateBatch(value, questions), batch => Object.fromEntries(Object.entries(batch).map(([id, r]) => [id, r.type === 'noul' ? { probability: r.probability } : r.type === 'score' ? { score: r.score, confidence: r.confidence } : { ...(id === 'verification_tier' ? { choice: r.choice } : {}), confidence: r.confidence, selected: r.probabilities[r.choice] ?? 0 }])), signal, emit, this.config.requestTimeoutMs ?? DECISION_DEFAULTS.requestTimeoutMs);
|
|
230
231
|
}
|
|
231
232
|
async settle(questionIds, evaluate, validate, describe, signal, emit, timeoutMs) {
|
|
232
|
-
emit('decision.requested', { questions: questionIds });
|
|
233
|
+
emit('decision.requested', { questions: questionIds, text: pickJevRequestPhrase() });
|
|
233
234
|
if (this.config.mode === 'active' && !this.active) {
|
|
234
235
|
emit('decision.fallback', { reason: 'active_unsupported' });
|
|
235
236
|
return undefined;
|
|
@@ -197,7 +197,7 @@ export function replayableTestRun(line) {
|
|
|
197
197
|
const source = line.trim().replace(/^cd\s+"?\$\(pwd\)"?\s*&&\s*/, '');
|
|
198
198
|
if (!source || MUTATING_FLAG.test(source) || source.includes('<<'))
|
|
199
199
|
return undefined;
|
|
200
|
-
const masked = source.replace(/'[^']*'/g, quoted => `'${'_'.repeat(quoted.length - 2)}'`).replace(/"
|
|
200
|
+
const masked = source.replace(/'[^']*'/g, quoted => `'${'_'.repeat(quoted.length - 2)}'`).replace(/"[^"$`]*"/g, quoted => `"${'_'.repeat(quoted.length - 2)}"`);
|
|
201
201
|
let cut = -1;
|
|
202
202
|
for (let index = 0; index < masked.length; index++) {
|
|
203
203
|
if (masked[index] !== '|')
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const JEV_DEFAULT_REQUEST_PHRASE = "Evaluating context needs";
|
|
2
|
+
export declare const JEV_REQUEST_PHRASES: readonly string[];
|
|
3
|
+
export declare function pickJevRequestPhrase(random?: () => number): string;
|
|
4
|
+
export declare function jevRequestPhrase(text: unknown): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// What the transcript says while a Jev request is in flight. The engine picks one per request and
|
|
2
|
+
// carries it on `decision.requested` as `text`, so the CLI and the desktop show the same line.
|
|
3
|
+
export const JEV_DEFAULT_REQUEST_PHRASE = 'Evaluating context needs';
|
|
4
|
+
export const JEV_REQUEST_PHRASES = [
|
|
5
|
+
'Asking the tokens to carpool',
|
|
6
|
+
'Clipping coupons for your context',
|
|
7
|
+
'Checking which tokens spark joy',
|
|
8
|
+
'Haggling with the token meter',
|
|
9
|
+
'Teaching the prompt to travel light',
|
|
10
|
+
'Bargain-hunting for bytes',
|
|
11
|
+
"Shrinking the bill before it's printed",
|
|
12
|
+
'Leaving the extra tokens at home',
|
|
13
|
+
'Sending unnecessary tokens home',
|
|
14
|
+
];
|
|
15
|
+
export function pickJevRequestPhrase(random = Math.random) {
|
|
16
|
+
const index = Math.floor(random() * JEV_REQUEST_PHRASES.length);
|
|
17
|
+
return JEV_REQUEST_PHRASES[Math.min(Math.max(index, 0), JEV_REQUEST_PHRASES.length - 1)] ?? JEV_DEFAULT_REQUEST_PHRASE;
|
|
18
|
+
}
|
|
19
|
+
// Only a phrase from the list is shown; anything else on the event falls back to the default line.
|
|
20
|
+
export function jevRequestPhrase(text) {
|
|
21
|
+
return typeof text === 'string' && JEV_REQUEST_PHRASES.includes(text) ? text : JEV_DEFAULT_REQUEST_PHRASE;
|
|
22
|
+
}
|
|
@@ -2,7 +2,7 @@ export const DEFAULT_AGENT_GRAPH = {
|
|
|
2
2
|
name: 'Andorra Agent', entry: 'engineer',
|
|
3
3
|
nodes: {
|
|
4
4
|
engineer: { id: 'engineer', name: 'Andorra Agent', type: 'agent', executor: 'react-basic',
|
|
5
|
-
instruction: 'Handle the user\'s task end to end, whether it is a coding task or a general one: implement code and verify changes with appropriate tools, and answer general research, writing and analysis directly from the available sources. Ask for clarification when needed. Report the result and any remaining issues. For follow-up questions, use the retained conversation and prior results first. Answer directly when they contain the answer; do not restart completed work or scan unrelated files.
|
|
5
|
+
instruction: 'Handle the user\'s task end to end, whether it is a coding task or a general one: implement code and verify changes with appropriate tools, and answer general research, writing and analysis directly from the available sources. Ask for clarification when needed. Report the result and any remaining issues. For follow-up questions, use the retained conversation and prior results first. Answer directly when they contain the answer; do not restart completed work or scan unrelated files. Never guess a pull request number. Mention pull requests in the report only when the task asked for one or one was opened; a pull request nobody asked for is not unfinished work. Start new implementation work only when the user requests it.',
|
|
6
6
|
contextPolicy: { history: true }, jevEnabled: true,
|
|
7
7
|
subagents: { enabled: false }, position: { x: 120, y: 120 } },
|
|
8
8
|
done: { id: 'done', name: 'Done', type: 'end', position: { x: 440, y: 120 } },
|
package/dist/src/file-diff.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export interface FileDiffLine {
|
|
|
5
5
|
newLine?: number;
|
|
6
6
|
noNewline?: true;
|
|
7
7
|
clipped?: true;
|
|
8
|
+
/** Set on a file the person also edited (`change-authors.ts`): who added or removed the line. */
|
|
9
|
+
author?: 'agent' | 'user';
|
|
8
10
|
}
|
|
9
11
|
export interface FileDiffHunk {
|
|
10
12
|
oldStart: number;
|
|
@@ -19,6 +21,8 @@ export interface FileDiff {
|
|
|
19
21
|
linesRemoved: number;
|
|
20
22
|
hiddenLines: number;
|
|
21
23
|
coarse?: true;
|
|
24
|
+
/** The line matcher gave up (too many edits, or too slow), so the middle is shown as all removed, then all added. */
|
|
25
|
+
approximate?: true;
|
|
22
26
|
}
|
|
23
27
|
export type DiffSide = Buffer | string | null;
|
|
24
28
|
export type FileDiffResult = {
|
package/dist/src/file-diff.js
CHANGED
|
@@ -74,6 +74,7 @@ export function textDiff(oldText, newText, options = {}) {
|
|
|
74
74
|
let changes = midA.length && midB.length
|
|
75
75
|
? diffArrays(midA, midB, { timeout: MATCH_TIMEOUT_MS, maxEditLength: MATCH_EDIT_LIMIT })
|
|
76
76
|
: undefined;
|
|
77
|
+
const approximate = changes === undefined && midA.length > 0 && midB.length > 0;
|
|
77
78
|
changes ??= [
|
|
78
79
|
...(midA.length ? [{ value: midA, added: false, removed: true }] : []),
|
|
79
80
|
...(midB.length ? [{ value: midB, added: true, removed: false }] : []),
|
|
@@ -179,7 +180,7 @@ export function textDiff(oldText, newText, options = {}) {
|
|
|
179
180
|
if (lines.length)
|
|
180
181
|
hunks.push({ oldStart, oldLines, newStart, newLines, lines });
|
|
181
182
|
}
|
|
182
|
-
return { hunks, linesAdded, linesRemoved, hiddenLines: hidden };
|
|
183
|
+
return { hunks, linesAdded, linesRemoved, hiddenLines: hidden, ...(approximate ? { approximate: true } : {}) };
|
|
183
184
|
}
|
|
184
185
|
export function coarseCounts(oldText, newText) {
|
|
185
186
|
if (oldText === newText)
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { GhRunner, SessionPullRequest } from '../pull-requests.js';
|
|
2
|
+
import { type BotWriteAction, type BotWriteFallback, type GitHubAppClient, type GitHubCoverage } from './client.js';
|
|
3
|
+
/**
|
|
4
|
+
* The agent's writes on its session's pull request (`design/specs/github-app.md`, "Bot replies"): a reply to a
|
|
5
|
+
* review thread, resolving or reopening one, and a comment on the PR's conversation. On a PR the GitHub App
|
|
6
|
+
* covers, with agent writes set to the bot, the account API makes the write as the App's bot; the engine never
|
|
7
|
+
* holds the installation token that does it. Otherwise, and whenever the service says it wrote nothing, the
|
|
8
|
+
* write goes through gh as the account the session's PR record names, and never as another account. A write
|
|
9
|
+
* whose fate is unknown is never repeated through gh.
|
|
10
|
+
*/
|
|
11
|
+
/** `github.app.agentWrites`: who the agent's PR writes post as. */
|
|
12
|
+
export type AgentWritesSetting = 'bot' | 'me';
|
|
13
|
+
export type AgentPullRequestWrite = {
|
|
14
|
+
action: 'reply';
|
|
15
|
+
threadId: string;
|
|
16
|
+
body: string;
|
|
17
|
+
} | {
|
|
18
|
+
action: 'resolve';
|
|
19
|
+
threadId: string;
|
|
20
|
+
resolved: boolean;
|
|
21
|
+
} | {
|
|
22
|
+
action: 'comment';
|
|
23
|
+
body: string;
|
|
24
|
+
};
|
|
25
|
+
/** A thread the agent named that is not on its session's PR: refused before anything was written. */
|
|
26
|
+
export declare class ThreadElsewhere extends Error {
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The person's own pending review on the PR: GitHub files a reply made through gh into it, where nobody sees it
|
|
30
|
+
* until the person submits the review. Refused before anything is written.
|
|
31
|
+
*/
|
|
32
|
+
export declare class PendingReview extends Error {
|
|
33
|
+
}
|
|
34
|
+
export declare const AGENT_WRITE_ACTIONS: readonly ["reply", "resolve", "comment"];
|
|
35
|
+
/** A ULID: 48 bits of milliseconds, then 80 random bits, in Crockford's base 32. */
|
|
36
|
+
export declare function newRequestId(now?: number, random?: Uint8Array): string;
|
|
37
|
+
/** The write the pull_request tool's `reply`, `resolve` or `comment` asks for, checked before anything is approved or sent. */
|
|
38
|
+
export declare function agentWriteFromArgs(args: Record<string, unknown>): AgentPullRequestWrite;
|
|
39
|
+
export declare const botAction: (write: AgentPullRequestWrite) => BotWriteAction;
|
|
40
|
+
/** Why a write went through gh without asking the service: the PR's coverage, or the person's setting. */
|
|
41
|
+
export declare function coverageReason(coverage: GitHubCoverage, pullRequest: SessionPullRequest): string;
|
|
42
|
+
/** Why the service wrote nothing, in the words the tool result uses. */
|
|
43
|
+
export declare function fallbackReason(reason: BotWriteFallback, pullRequest: SessionPullRequest): string;
|
|
44
|
+
export declare const AS_ME_REASON = "agent replies on pull requests are set to post as you";
|
|
45
|
+
export interface AgentWriteResult {
|
|
46
|
+
/** The tool result: who posted (or may have) and why. */
|
|
47
|
+
text: string;
|
|
48
|
+
/** `pending`: filed into the person's pending review, not visible yet. `unknown`: it may have been written. */
|
|
49
|
+
by: 'bot' | 'gh' | 'pending' | 'unknown';
|
|
50
|
+
as?: string;
|
|
51
|
+
url?: string;
|
|
52
|
+
/** The new comment's GraphQL node id, when GitHub's answer named it (the gh route's reply and comment). */
|
|
53
|
+
nodeId?: string;
|
|
54
|
+
/** Why it went through gh. */
|
|
55
|
+
reason?: string;
|
|
56
|
+
requestId?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface AgentWriteOptions {
|
|
59
|
+
pullRequest: SessionPullRequest;
|
|
60
|
+
write: AgentPullRequestWrite;
|
|
61
|
+
setting: AgentWritesSetting;
|
|
62
|
+
/** The PR's coverage, as the event source last learned it. Only `covered` and `permissions-pending` ask the service. */
|
|
63
|
+
coverage: GitHubCoverage;
|
|
64
|
+
client: Pick<GitHubAppClient, 'write'>;
|
|
65
|
+
gh: GhRunner;
|
|
66
|
+
/**
|
|
67
|
+
* Asked once the route is known and the write passes its checks, before anything is sent anywhere, with who
|
|
68
|
+
* the write posts as (see `approvalDetail`). A fallback to gh after the bot wrote nothing is not asked again.
|
|
69
|
+
*/
|
|
70
|
+
approve(detail: string): Promise<void>;
|
|
71
|
+
/** The bot's login, for the approval (`GET /v1/github`'s `bot`); unknown, "the Andorra Code bot". */
|
|
72
|
+
botName?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Reads the PR record, the setting and the coverage again once the approval is given: a write whose PR, account
|
|
75
|
+
* or route changed while the person was asked is refused, so it never goes where the approval did not say.
|
|
76
|
+
*/
|
|
77
|
+
current?(): Promise<{
|
|
78
|
+
pullRequest: SessionPullRequest;
|
|
79
|
+
setting: AgentWritesSetting;
|
|
80
|
+
coverage: GitHubCoverage;
|
|
81
|
+
} | undefined>;
|
|
82
|
+
signal?: AbortSignal;
|
|
83
|
+
requestId?: () => string;
|
|
84
|
+
}
|
|
85
|
+
export declare const CHANGED_WHILE_APPROVING = "The pull request or reply setting changed while awaiting approval; retry.";
|
|
86
|
+
/**
|
|
87
|
+
* What the approval says the write does and who it posts as: the bot first and the PR record's account if the
|
|
88
|
+
* bot cannot, or the account alone. One approval covers both, so a fallback is never asked about again.
|
|
89
|
+
*/
|
|
90
|
+
export declare function approvalDetail(write: AgentPullRequestWrite, pullRequest: SessionPullRequest, bot: boolean, botName?: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* Whether an agent write goes to the service first: agent writes set to the bot, and the PR covered (or
|
|
93
|
+
* `permissions-pending`, where the service decides per action). The Auto-fix prompt uses the same rule, so
|
|
94
|
+
* the prompt and the tool agree on who the replies post as.
|
|
95
|
+
*/
|
|
96
|
+
export declare const asksBot: (setting: AgentWritesSetting, coverage: GitHubCoverage) => boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Carries out one agent write on the session's tracked PR. Throws for a write that must not fall back (the
|
|
99
|
+
* service refused it as malformed, or the thread is not on this PR), for one the person's pending review would
|
|
100
|
+
* swallow, and for a gh write that certainly failed; answers the tool result otherwise.
|
|
101
|
+
*/
|
|
102
|
+
export declare function performAgentWrite(options: AgentWriteOptions): Promise<AgentWriteResult>;
|