@andorra-labs/code 0.1.17 → 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/agent-execution.js +97 -11
- package/dist/src/andorra/errors.js +3 -0
- package/dist/src/app-server/protocol.d.ts +13 -2
- package/dist/src/app-server/protocol.js +1 -1
- package/dist/src/app-server/workspace.d.ts +19 -0
- package/dist/src/app-server/workspace.js +155 -4
- package/dist/src/app-server.d.ts +32 -1
- package/dist/src/app-server.js +622 -74
- 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/command.js +12 -0
- package/dist/src/bridge/control.d.ts +3 -1
- package/dist/src/bridge/control.js +7 -2
- 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 +1 -1
- package/dist/src/bridge/host-ops.js +11 -1
- package/dist/src/bridge/host.js +7 -4
- 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/cli.d.ts +1 -3
- package/dist/src/cli.js +10 -4
- package/dist/src/codex-provider.js +1 -1
- package/dist/src/coding-tools.js +9 -2
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.js +2 -1
- package/dist/src/completion.js +8 -4
- package/dist/src/config.js +3 -1
- package/dist/src/context-budget.js +15 -2
- 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/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/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/github-app/client.d.ts +19 -0
- package/dist/src/github-app/client.js +21 -1
- package/dist/src/github-names.d.ts +7 -0
- package/dist/src/github-names.js +7 -0
- package/dist/src/graph-preview.d.ts +2 -0
- package/dist/src/graph-preview.js +1 -0
- package/dist/src/graph-runner.js +1 -1
- package/dist/src/graph-server.js +4 -2
- package/dist/src/graph-ui/app.js +30 -0
- package/dist/src/graphs.d.ts +6 -0
- package/dist/src/graphs.js +7 -2
- package/dist/src/hardened-runtime.js +32 -21
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-override.d.ts +2 -1
- package/dist/src/model-override.js +9 -0
- package/dist/src/model-tiers.d.ts +3 -0
- package/dist/src/model-tiers.js +3 -3
- package/dist/src/provider-engine.d.ts +13 -1
- package/dist/src/provider-engine.js +74 -0
- package/dist/src/providers.d.ts +5 -0
- package/dist/src/providers.js +34 -8
- package/dist/src/pull-requests.d.ts +11 -1
- package/dist/src/pull-requests.js +53 -2
- package/dist/src/react-runtime.js +98 -15
- package/dist/src/remote/engine-pool.js +5 -5
- package/dist/src/runtime.d.ts +29 -1
- package/dist/src/runtime.js +8 -0
- package/dist/src/sessions.d.ts +24 -0
- package/dist/src/sessions.js +55 -2
- package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
- package/dist/src/skills/bundled/provenance.json +1 -1
- package/dist/src/task-checkout.d.ts +141 -0
- package/dist/src/task-checkout.js +558 -0
- package/dist/src/test-edit-guard.d.ts +30 -0
- package/dist/src/test-edit-guard.js +167 -2
- 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 +1 -0
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/transcript.js +1 -1
- package/dist/src/types.d.ts +34 -0
- package/package.json +1 -1
|
@@ -7,11 +7,14 @@ import { conversationContains, omittedContextNote, selectContext } from './conte
|
|
|
7
7
|
import { MAPPED_INPUTS_HEADING } from './context-compaction.js';
|
|
8
8
|
import { orderSkillCatalog, selectToolCatalog } from './tool-catalog.js';
|
|
9
9
|
import { decideModelTier } from './model-tiers.js';
|
|
10
|
+
import { decideEffort, EFFORT_ESCALATION_REASONS } from './effort-routing.js';
|
|
11
|
+
import { nearestEnabled } from './thinking-levels.js';
|
|
12
|
+
import { REASONING_EFFORTS, supportsReasoningEffort } from './providers.js';
|
|
10
13
|
import { structuredText } from './code-intelligence/CodeIntelligenceManager.js';
|
|
11
14
|
import { buildMemoryBlock } from './memory/MemoryRetriever.js';
|
|
12
15
|
import { discoverRuntimeSkills, matchRuntimeSkill, runtimeSkillTools } from './skills/runtime-skills.js';
|
|
13
16
|
import { promptSkillReferences } from './skills/prompt-skills.js';
|
|
14
|
-
import { BUG_REPORT_SKILL, bugReportTool } from './bug-report.js';
|
|
17
|
+
import { BUG_REPORT_SKILL, bugReportSessionsTool, bugReportTool } from './bug-report.js';
|
|
15
18
|
import { toolFamilies, routeToolFamilies, decisionExecutionGuidance } from './decision/toolFamilies.js';
|
|
16
19
|
import { allowsGraphRouting, route as codeGraphRoute } from './code-intelligence/ContextRouter.js';
|
|
17
20
|
import { randomUUID } from 'node:crypto';
|
|
@@ -21,7 +24,7 @@ import { promisify } from 'node:util';
|
|
|
21
24
|
import { mkdtemp, realpath } from 'node:fs/promises';
|
|
22
25
|
import { tmpdir } from 'node:os';
|
|
23
26
|
import { join, relative } from 'node:path';
|
|
24
|
-
import { ClarificationRequiredError, DEFAULT_GRAPH, LIMIT_KEYS, isUnlimitedAlias, resolveLimits, turnModelTask } from './runtime.js';
|
|
27
|
+
import { ClarificationRequiredError, DEFAULT_GRAPH, LIMIT_KEYS, isUnlimitedAlias, resolveLimits, turnModelCompletion, turnModelTask } from './runtime.js';
|
|
25
28
|
import { createRunTelemetry, mergeRunTelemetry, recordAttempt, recordDecisionEvent, recordEfficiencyEvent } from './telemetry/capture.js';
|
|
26
29
|
import { bindUserWaits, createRuntimeBudget } from './deadline.js';
|
|
27
30
|
import { createAgentEngine } from './hardened-runtime.js';
|
|
@@ -364,8 +367,8 @@ export async function executeAgentNode(node, options) {
|
|
|
364
367
|
throw new Error('Mapped inputs exceed context limit; pass artifact references instead');
|
|
365
368
|
const configuredProvider = configured.provider ?? options.provider;
|
|
366
369
|
const configuredModel = configured.model ?? (configured.provider === undefined ? options.model : undefined);
|
|
367
|
-
const resolve = async (provider, model) => retryReadOnly(context, signal => options.resolveModel
|
|
368
|
-
? options.resolveModel(provider, model, signal)
|
|
370
|
+
const resolve = async (provider, model, effort) => retryReadOnly(context, signal => options.resolveModel
|
|
371
|
+
? options.resolveModel(provider, model, signal, effort)
|
|
369
372
|
: provider === options.provider ? { model: options.model, adapter: options.adapter, contextWindow: options.contextWindow } : options.resolveProvider?.(provider));
|
|
370
373
|
let provider = configuredProvider, resolved = await resolve(provider, configuredModel);
|
|
371
374
|
if (!resolved)
|
|
@@ -373,6 +376,14 @@ export async function executeAgentNode(node, options) {
|
|
|
373
376
|
// The resolved model is the provider's own spelling of the configured one when they differ only in case.
|
|
374
377
|
const spelled = (wanted, got) => wanted !== undefined && wanted.toLowerCase() === got.toLowerCase() ? got : wanted ?? got;
|
|
375
378
|
let model = spelled(configured.model, resolved.model);
|
|
379
|
+
// The thinking level in force for this node's requests; a subagent that inherits the model runs at it too.
|
|
380
|
+
let activeEffort;
|
|
381
|
+
const asLevel = (value) => value !== undefined && REASONING_EFFORTS.includes(value) ? value : undefined;
|
|
382
|
+
const levelsFor = (id, name, type, forAuto) => options.thinkingLevels?.(id, name, forAuto) ?? (type === undefined || !supportsReasoningEffort(type) ? [] : forAuto ? ['low', 'medium', 'high'] : [...REASONING_EFFORTS]);
|
|
383
|
+
// The run's own model: the one it started on, or the one a live whole-run change moved it to.
|
|
384
|
+
let sessionModel = { provider: options.provider, model: options.model };
|
|
385
|
+
const wantedEffort = () => configured.reasoningEffort
|
|
386
|
+
?? (options.sessionEffortAuto && depth === 0 && provider === sessionModel.provider && model === sessionModel.model ? 'auto' : undefined);
|
|
376
387
|
let fallbackAttempt = parentFallback;
|
|
377
388
|
const orchestratorCompletionGuard = () => {
|
|
378
389
|
if (!clarified)
|
|
@@ -571,7 +582,10 @@ export async function executeAgentNode(node, options) {
|
|
|
571
582
|
const childProvider = policy.modelPolicy === 'specific' ? policy.provider ?? provider : policy.modelPolicy === 'per-role' ? role.provider ?? provider : provider;
|
|
572
583
|
const childModel = policy.modelPolicy === 'specific' ? policy.model : policy.modelPolicy === 'per-role' ? role.model ?? (childProvider === provider ? model : undefined) : model;
|
|
573
584
|
const child = { id: role.id, type: 'agent', executor: 'react-basic', name: role.name, instruction: role.instruction,
|
|
574
|
-
provider: childProvider, ...(childModel ? { model: childModel } : {}),
|
|
585
|
+
provider: childProvider, ...(childModel ? { model: childModel } : {}),
|
|
586
|
+
// With no model named, a child on the same provider runs that provider's default, which may not be the parent's.
|
|
587
|
+
...(activeEffort !== undefined && childProvider === provider && childModel === model ? { reasoningEffort: activeEffort } : {}),
|
|
588
|
+
capabilities: childCapabilities, tools: childToolNames,
|
|
575
589
|
completion: { mode: 'single', outcome: 'completed' }, inputSchema: role.inputSchema, outputSchema: role.outputSchema,
|
|
576
590
|
contextPolicy: { history: false, maxChars: Math.min(contextChars, 16000) } };
|
|
577
591
|
if (depth > 0 && active >= (policy.maxConcurrent ?? 3))
|
|
@@ -1002,9 +1016,9 @@ export async function executeAgentNode(node, options) {
|
|
|
1002
1016
|
}).map(requirePublishedPlan) : [];
|
|
1003
1017
|
if (skillTools.length)
|
|
1004
1018
|
tools = tools.filter(tool => tool.name !== 'read_skill_resource');
|
|
1005
|
-
// The report
|
|
1019
|
+
// The report tools exist only in a run that carries the bug-report skill, so no other run pays for their schemas.
|
|
1006
1020
|
if (depth === 0 && [...inheritedSkills, ...promptSkills].includes(BUG_REPORT_SKILL))
|
|
1007
|
-
tools.push(bugReportTool({ emit }));
|
|
1021
|
+
tools.push(bugReportSessionsTool(), bugReportTool({ emit }));
|
|
1008
1022
|
const effectiveTask = typeof inputs.taskInstruction === 'string' && inputs.taskInstruction.trim() ? inputs.taskInstruction.trim() : task;
|
|
1009
1023
|
const graphFirstSearch = depth === 0 && !!codeIntel?.active && codeGraphRoute(effectiveTask) === 'graph';
|
|
1010
1024
|
const decisionTask = depth > 0 ? task : options.decisionPreflight?.task ?? effectiveTask;
|
|
@@ -1016,6 +1030,8 @@ export async function executeAgentNode(node, options) {
|
|
|
1016
1030
|
? options.workspaceFacts ?? await collectWorkspaceFacts(context.workspace, { signal: context.signal }) : undefined;
|
|
1017
1031
|
const nodeBaseline = { provider, model };
|
|
1018
1032
|
let routedTier;
|
|
1033
|
+
let effortLevel;
|
|
1034
|
+
let effortEscalated = false;
|
|
1019
1035
|
let escalations = 0;
|
|
1020
1036
|
let previousAttemptReason;
|
|
1021
1037
|
let escalationPending = false;
|
|
@@ -1038,6 +1054,8 @@ export async function executeAgentNode(node, options) {
|
|
|
1038
1054
|
const liveNodeId = `${node.id}${subagentId ? '/' + configured.id : ''}${fallbackAttempt ? '#fallback' : ''}`;
|
|
1039
1055
|
const liveModel = await options.getLiveModel?.(liveNodeId, provider, model, context.signal);
|
|
1040
1056
|
const liveSelected = liveModel !== undefined;
|
|
1057
|
+
if (liveModel?.sessionModel)
|
|
1058
|
+
sessionModel = { provider: liveModel.provider, model: liveModel.model };
|
|
1041
1059
|
if (liveModel && (liveModel.provider !== provider || liveModel.model !== model)) {
|
|
1042
1060
|
provider = liveModel.provider;
|
|
1043
1061
|
model = liveModel.model;
|
|
@@ -1093,7 +1111,7 @@ export async function executeAgentNode(node, options) {
|
|
|
1093
1111
|
const spendRepoRoom = (chars) => { repoBudget -= chars; repoPolicyRoom -= chars; };
|
|
1094
1112
|
let committedChars = 0;
|
|
1095
1113
|
if (depth === 0 && codeLedger && codeIntel) {
|
|
1096
|
-
const historyChars = configured.contextPolicy?.history ? (options.history ?? []).reduce((sum, item) => sum + turnModelTask(item).length + JSON.stringify(item.completion).length, 0) : 0;
|
|
1114
|
+
const historyChars = configured.contextPolicy?.history ? (options.history ?? []).reduce((sum, item) => sum + turnModelTask(item).length + JSON.stringify(turnModelCompletion(item.completion)).length, 0) : 0;
|
|
1097
1115
|
const toolSchemaChars = JSON.stringify(tools.map(tool => ({ name: tool.name, description: tool.description, parameters: tool.parameters }))).length;
|
|
1098
1116
|
const contractChars = JSON.stringify({ outputSchema: configured.outputSchema, completion: configured.completion }).length;
|
|
1099
1117
|
const todoChars = JSON.stringify(todoStore.snapshot()).length;
|
|
@@ -1112,7 +1130,7 @@ export async function executeAgentNode(node, options) {
|
|
|
1112
1130
|
JSON.stringify(completionPolicy.mode === 'single' ? completionPolicy.outcome : completionPolicy.outcomes[0]),
|
|
1113
1131
|
JSON.stringify(todoStore.snapshot())];
|
|
1114
1132
|
const historyChars = JSON.stringify(configured.contextPolicy?.history ? (options.history ?? []).flatMap(turn => [
|
|
1115
|
-
{ role: 'user', content: turnModelTask(turn) }, { role: 'assistant', content: JSON.stringify(turn.completion) },
|
|
1133
|
+
{ role: 'user', content: turnModelTask(turn) }, { role: 'assistant', content: JSON.stringify(turnModelCompletion(turn.completion)) },
|
|
1116
1134
|
]) : []).length;
|
|
1117
1135
|
const schemaChars = JSON.stringify([...attemptTools, completionTool({ ...options, completionPolicy, outputSchema: configured.outputSchema })]
|
|
1118
1136
|
.map(({ name, description, parameters }) => ({ name, description, parameters }))).length
|
|
@@ -1143,7 +1161,9 @@ export async function executeAgentNode(node, options) {
|
|
|
1143
1161
|
consumers: { answerOnly: answerOnlyTask(decisionTask),
|
|
1144
1162
|
adaptiveRouting: attempt === 1 && depth === 0 && !subagentId && !fallbackAttempt
|
|
1145
1163
|
&& configured.provider === undefined && configured.model === undefined && !options.modelPinned && !liveSelected
|
|
1146
|
-
&& hasAdaptiveAlternative(efficiency.adaptiveRouting, nodeBaseline, options.configuredModels ?? [])
|
|
1164
|
+
&& hasAdaptiveAlternative(efficiency.adaptiveRouting, nodeBaseline, options.configuredModels ?? [])
|
|
1165
|
+
// A node on Auto thinking needs the same three answers to pick among its model's levels.
|
|
1166
|
+
|| attempt === 1 && depth === 0 && !subagentId && wantedEffort() === 'auto' && levelsFor(provider, model, resolved?.providerType, true).length >= 2,
|
|
1147
1167
|
},
|
|
1148
1168
|
}, { runId: options.runId, nodeId: configured.id, invocationId: randomUUID(), ...(subagentId ? { subagentId } : {}) }, { codeGraph: depth === 0 && !!codeIntel?.active && repoRoom() >= 512 && codeGraphRoute(effectiveTask) === 'graph', memory: depth === 0 && (options.decisionPreflight?.memory ?? (configured.agentRole !== 'orchestrator' && !!options.memory?.activeFor(options.runId) && options.memory.automaticRetrieval)) }, signal, event => {
|
|
1149
1169
|
if (signal.aborted)
|
|
@@ -1237,6 +1257,62 @@ export async function executeAgentNode(node, options) {
|
|
|
1237
1257
|
}
|
|
1238
1258
|
await emitEfficiency('efficiency.routing.decided', { tier: decision.tier, reason: unresolved ? 'unconfigured' : decision.reason, evidence: decision.evidence, applied, served, attempt });
|
|
1239
1259
|
}
|
|
1260
|
+
{
|
|
1261
|
+
// The thinking level is settled once per attempt, before the first request, and held for the whole attempt:
|
|
1262
|
+
// a change between requests makes the provider re-read the conversation uncached.
|
|
1263
|
+
const wanted = wantedEffort();
|
|
1264
|
+
const current = asLevel(resolved.reasoningEffort);
|
|
1265
|
+
const enabled = levelsFor(provider, model, resolved.providerType, false);
|
|
1266
|
+
if (wanted === undefined) {
|
|
1267
|
+
// The saved level is the session's or the provider's. A level switched off for this model is never sent.
|
|
1268
|
+
const allowed = current === undefined || enabled.length === 0 ? current : nearestEnabled(enabled, current);
|
|
1269
|
+
activeEffort = current;
|
|
1270
|
+
if (allowed !== undefined && allowed !== current) {
|
|
1271
|
+
try {
|
|
1272
|
+
const levelled = await resolve(provider, model, allowed);
|
|
1273
|
+
if (levelled) {
|
|
1274
|
+
resolved = levelled;
|
|
1275
|
+
activeEffort = allowed;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
catch {
|
|
1279
|
+
context.signal.throwIfAborted();
|
|
1280
|
+
}
|
|
1281
|
+
await emitEfficiency('efficiency.effort.decided', { mode: 'fixed', wanted: current, level: allowed, evidence: 'fixed', applied: activeEffort === allowed, attempt, ...(subagentId ? { subagentId } : {}) });
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
else {
|
|
1285
|
+
// Auto chooses among its own list; when that list is empty (every widely accepted level of an undetected
|
|
1286
|
+
// model was switched off) it chooses among everything still enabled, so a switched-off level is never kept.
|
|
1287
|
+
const forAuto = wanted === 'auto' ? levelsFor(provider, model, resolved.providerType, true) : [];
|
|
1288
|
+
const levels = forAuto.length > 0 ? forAuto : enabled;
|
|
1289
|
+
const decision = wanted === 'auto'
|
|
1290
|
+
// The task as the user wrote it, which is also what Jev was asked about.
|
|
1291
|
+
? decideEffort({ task: decisionTask, levels, hints: depth === 0 && !subagentId ? activeRouting?.decisions : undefined, fallback: current,
|
|
1292
|
+
previous: attempt > 1 && effortLevel !== undefined ? { level: effortLevel, reason: previousAttemptReason } : undefined })
|
|
1293
|
+
: { level: nearestEnabled(levels, wanted), evidence: 'fixed' };
|
|
1294
|
+
let inForce = current;
|
|
1295
|
+
if (decision.level !== undefined && decision.level !== current) {
|
|
1296
|
+
try {
|
|
1297
|
+
const levelled = await resolve(provider, model, decision.level);
|
|
1298
|
+
if (levelled) {
|
|
1299
|
+
resolved = levelled;
|
|
1300
|
+
inForce = decision.level;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
catch {
|
|
1304
|
+
context.signal.throwIfAborted();
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
effortLevel = wanted === 'auto' ? decision.level : undefined;
|
|
1308
|
+
activeEffort = inForce;
|
|
1309
|
+
if (wanted === 'auto' || decision.level !== wanted) {
|
|
1310
|
+
await emitEfficiency('efficiency.effort.decided', { mode: wanted === 'auto' ? 'auto' : 'fixed', ...(wanted === 'auto' ? {} : { wanted }),
|
|
1311
|
+
...(decision.level === undefined ? {} : { level: decision.level }), evidence: decision.evidence, applied: decision.level !== undefined && inForce === decision.level, attempt,
|
|
1312
|
+
...(subagentId ? { subagentId } : {}) });
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1240
1316
|
const inheritedConversation = depth === 0 && configured.contextPolicy?.conversation !== 'isolate' && configured.contextPolicy?.skillInheritance !== 'none'
|
|
1241
1317
|
&& options.previousConversation?.provider === provider && options.previousConversation.model === model ? options.previousConversation : undefined;
|
|
1242
1318
|
const historicalToolNames = [...new Set((inheritedConversation?.messages ?? []).flatMap(message => (message.toolCalls ?? []).map(call => call.name)))];
|
|
@@ -1552,7 +1628,17 @@ export async function executeAgentNode(node, options) {
|
|
|
1552
1628
|
if (attempt === attempts)
|
|
1553
1629
|
attempts = attempt + 1;
|
|
1554
1630
|
}
|
|
1555
|
-
|
|
1631
|
+
// A node on Auto thinking that ran out of steps gets one more attempt a level higher, when there is one.
|
|
1632
|
+
const effortLevels = effortLevel === undefined ? [] : levelsFor(provider, model, resolved.providerType, true);
|
|
1633
|
+
const raiseEffort = !escalate && !effortEscalated && depth === 0 && !subagentId && effortLevel !== undefined && result.status === 'exhausted'
|
|
1634
|
+
&& EFFORT_ESCALATION_REASONS.has(result.reason ?? '') && effortLevels.indexOf(effortLevel) < effortLevels.length - 1 && !context.signal.aborted
|
|
1635
|
+
&& (options.budget === undefined || options.budget.maxToolCalls === undefined || options.budget.toolCalls < options.budget.maxToolCalls);
|
|
1636
|
+
if (raiseEffort) {
|
|
1637
|
+
effortEscalated = true;
|
|
1638
|
+
if (attempt === attempts)
|
|
1639
|
+
attempts = attempt + 1;
|
|
1640
|
+
}
|
|
1641
|
+
if (!escalate && !raiseEffort && (result.status !== 'infrastructure_error' || result.providerRequestFailed || attempt === attempts))
|
|
1556
1642
|
break;
|
|
1557
1643
|
await emit('agent.retry', { attempt, reason: result.reason, ...(escalate ? { escalation: true, tier: routedTier } : {}) });
|
|
1558
1644
|
if (configured.retry?.fallback) {
|
|
@@ -35,5 +35,8 @@ export function andorraRefusal(status, body, retryAfter) {
|
|
|
35
35
|
const seconds = retrySeconds(retryAfter);
|
|
36
36
|
return `Andorra is busy. Try again in ${seconds === undefined ? 'a moment' : `${seconds} second${seconds === 1 ? '' : 's'}`}.`;
|
|
37
37
|
}
|
|
38
|
+
if (status === 429 && code === 'stream_limit_reached') {
|
|
39
|
+
return 'You are running your limit of concurrent requests. Finish one before starting another.';
|
|
40
|
+
}
|
|
38
41
|
return undefined;
|
|
39
42
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { SessionCheckout } from '../task-checkout.js';
|
|
1
2
|
export declare const APP_SERVER_PROTOCOL_VERSION = 2;
|
|
2
|
-
export declare const APP_SERVER_CAPABILITIES: readonly ["run.start.runPermissions", "model.relay", "automations", "providers.models", "providers.test", "providers.test.model", "providers.streamIdleTimeout", "providers.modelContextWindows", "providers.textOnlyModels", "providers.name", "providers.claude", "providers.claudeAuth", "providers.grok", "providers.google", "providers.opencode", "providers.auth.submit", "providers.opencodeGo", "providers.discover.draft", "providers.detectSignIns", "providers.codexAuth", "providers.codexAuth.logout", "providers.codexAccounts", "providers.anthropicConsole", "run.resume.direction", "run.resume.model", "run.resume.compact", "run.steer", "run.overrideAllNodes", "run.setModel", "run.setModel.node", "run.setPermissions", "run.start.continueSession", "run.start.entryHistory", "remote.owner.projects", "remote.engine.relay", "environments.bridge", "environments.cloud", "extensions.manage", "extensions.resources", "skills.invoke", "mcp.manage", "mcp.edit", "mcp.status", "runs.files", "sessions.files", "account.profile", "sessions.stats", "sessions.usage", "sessions.usage.hourly", "config.analytics", "config.analytics.planGate", "sessions.trajectory", "config.externalSubagent", "config.codeIntel", "config.decisions", "browser.view", "attachments.read", "config.general", "sessions.pullRequest", "sessions.pullRequest.details", "sessions.pullRequest.review", "sessions.pullRequest.review.teams", "sessions.pullRequest.merge", "sessions.pullRequest.create", "sessions.pullRequest.conversation", "sessions.pullRequest.suggestions", "sessions.pullRequest.checkLogs", "sessions.pullRequest.edit", "sessions.pullRequest.mergeQueue", "sessions.pullRequest.merge.bypass", "sessions.pullRequest.create.fork", "sessions.pullRequest.attach", "pullRequests.reviewRequests", "issues.list", "browser.view.go", "config.browser", "config.webSearch", "background.tasks", "workspace.warm", "browser.cookies.firefox", "browser.extensions", "sessions.compact", "sessions.goal", "sessions.changes", "run.current", "sessions.jev", "providers.andorra", "graphs.visibility", "github.app", "github.app.agentWrites", "github.app.triggers", "github.app.reviews", "sessions.pin", "workspace.files", "workspace.search", "workspace.linkBase", "workspace.write", "sessions.changes.authors", "run.note"];
|
|
3
|
+
export declare const APP_SERVER_CAPABILITIES: readonly ["run.start.runPermissions", "model.relay", "automations", "providers.models", "providers.test", "providers.test.model", "providers.thinkingLevels", "providers.streamIdleTimeout", "providers.modelContextWindows", "providers.textOnlyModels", "providers.name", "providers.claude", "providers.claudeAuth", "providers.grok", "providers.google", "providers.opencode", "providers.auth.submit", "providers.opencodeGo", "providers.discover.draft", "providers.detectSignIns", "providers.codexAuth", "providers.codexAuth.logout", "providers.codexAccounts", "providers.anthropicConsole", "run.resume.direction", "run.resume.model", "run.resume.compact", "run.steer", "run.overrideAllNodes", "run.setModel", "run.setModel.node", "run.setPermissions", "run.start.continueSession", "run.start.entryHistory", "remote.owner.projects", "remote.engine.relay", "environments.bridge", "environments.cloud", "extensions.manage", "extensions.resources", "skills.invoke", "mcp.manage", "mcp.edit", "mcp.status", "runs.files", "sessions.files", "account.profile", "sessions.stats", "sessions.usage", "sessions.usage.hourly", "config.analytics", "config.analytics.planGate", "sessions.trajectory", "config.externalSubagent", "config.codeIntel", "config.decisions", "browser.view", "attachments.read", "config.general", "sessions.pullRequest", "sessions.pullRequest.details", "sessions.pullRequest.review", "sessions.pullRequest.review.teams", "sessions.pullRequest.merge", "sessions.pullRequest.create", "sessions.pullRequest.conversation", "sessions.pullRequest.suggestions", "sessions.pullRequest.checkLogs", "sessions.pullRequest.edit", "sessions.pullRequest.mergeQueue", "sessions.pullRequest.merge.bypass", "sessions.pullRequest.create.fork", "sessions.pullRequest.attach", "pullRequests.reviewRequests", "issues.list", "browser.view.go", "config.browser", "config.webSearch", "background.tasks", "workspace.warm", "browser.cookies.firefox", "browser.extensions", "sessions.compact", "sessions.goal", "sessions.changes", "run.current", "sessions.jev", "providers.andorra", "graphs.visibility", "github.app", "github.app.agentWrites", "github.app.triggers", "github.app.reviews", "github.app.repositories", "sessions.pin", "workspace.files", "workspace.search", "workspace.linkBase", "workspace.write", "sessions.changes.authors", "run.note", "workspace.image", "workspace.taskCheckout", "sessions.review"];
|
|
3
4
|
/** Remote engine events about the engine version a desktop runs, sent to every connection of that version. */
|
|
4
5
|
export declare const REMOTE_ENGINE_INSTALLING_EVENT = "remote.engine.installing";
|
|
5
6
|
export declare const REMOTE_ENGINE_READY_EVENT = "remote.engine.ready";
|
|
@@ -37,7 +38,7 @@ export interface AppServerHostInfo {
|
|
|
37
38
|
running?: boolean;
|
|
38
39
|
capabilities: readonly string[];
|
|
39
40
|
}
|
|
40
|
-
export type AppServerErrorCode = 'invalid-request' | 'unknown-method' | 'invalid-params' | 'busy' | 'engine-busy' | 'not-found' | 'login-required' | 'auth' | 'storage' | 'network' | 'cancelled' | 'internal' | 'remote' | 'nothing-to-continue' | 'forbidden';
|
|
41
|
+
export type AppServerErrorCode = 'invalid-request' | 'unknown-method' | 'invalid-params' | 'busy' | 'engine-busy' | 'not-found' | 'login-required' | 'auth' | 'storage' | 'network' | 'cancelled' | 'internal' | 'remote' | 'nothing-to-continue' | 'forbidden' | 'checkout-missing';
|
|
41
42
|
export type AppServerPermissionMode = 'read-only' | 'plan' | 'ask-for-approval' | 'approve-for-me' | 'full-access';
|
|
42
43
|
export interface AppServerProviderAuth {
|
|
43
44
|
state: 'signedOut' | 'starting' | 'waiting' | 'signedIn' | 'cancelled' | 'error';
|
|
@@ -325,6 +326,16 @@ export interface AppServerSessionSummary {
|
|
|
325
326
|
archived?: boolean;
|
|
326
327
|
pinned?: boolean;
|
|
327
328
|
jevEnabled?: boolean;
|
|
329
|
+
/** Where the task works: its own worktree, or the project folder. */
|
|
330
|
+
checkout?: SessionCheckout;
|
|
331
|
+
/** The newest completed turn waiting for review in Needs you, and when it was marked reviewed. */
|
|
332
|
+
review?: {
|
|
333
|
+
runId: string;
|
|
334
|
+
finishedAt: string;
|
|
335
|
+
reviewedAt?: string;
|
|
336
|
+
headline?: string;
|
|
337
|
+
unverified?: string[];
|
|
338
|
+
};
|
|
328
339
|
lastTurnStatus?: AppServerTurnStatus;
|
|
329
340
|
timers?: AppServerTimerState[];
|
|
330
341
|
usage: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const APP_SERVER_PROTOCOL_VERSION = 2;
|
|
2
|
-
export const APP_SERVER_CAPABILITIES = ['run.start.runPermissions', 'model.relay', 'automations', 'providers.models', 'providers.test', 'providers.test.model', 'providers.streamIdleTimeout', 'providers.modelContextWindows', 'providers.textOnlyModels', 'providers.name', 'providers.claude', 'providers.claudeAuth', 'providers.grok', 'providers.google', 'providers.opencode', 'providers.auth.submit', 'providers.opencodeGo', 'providers.discover.draft', 'providers.detectSignIns', 'providers.codexAuth', 'providers.codexAuth.logout', 'providers.codexAccounts', 'providers.anthropicConsole', 'run.resume.direction', 'run.resume.model', 'run.resume.compact', 'run.steer', 'run.overrideAllNodes', 'run.setModel', 'run.setModel.node', 'run.setPermissions', 'run.start.continueSession', 'run.start.entryHistory', 'remote.owner.projects', 'remote.engine.relay', 'environments.bridge', 'environments.cloud', 'extensions.manage', 'extensions.resources', 'skills.invoke', 'mcp.manage', 'mcp.edit', 'mcp.status', 'runs.files', 'sessions.files', 'account.profile', 'sessions.stats', 'sessions.usage', 'sessions.usage.hourly', 'config.analytics', 'config.analytics.planGate', 'sessions.trajectory', 'config.externalSubagent', 'config.codeIntel', 'config.decisions', 'browser.view', 'attachments.read', 'config.general', 'sessions.pullRequest', 'sessions.pullRequest.details', 'sessions.pullRequest.review', 'sessions.pullRequest.review.teams', 'sessions.pullRequest.merge', 'sessions.pullRequest.create', 'sessions.pullRequest.conversation', 'sessions.pullRequest.suggestions', 'sessions.pullRequest.checkLogs', 'sessions.pullRequest.edit', 'sessions.pullRequest.mergeQueue', 'sessions.pullRequest.merge.bypass', 'sessions.pullRequest.create.fork', 'sessions.pullRequest.attach', 'pullRequests.reviewRequests', 'issues.list', 'browser.view.go', 'config.browser', 'config.webSearch', 'background.tasks', 'workspace.warm', 'browser.cookies.firefox', 'browser.extensions', 'sessions.compact', 'sessions.goal', 'sessions.changes', 'run.current', 'sessions.jev', 'providers.andorra', 'graphs.visibility', 'github.app', 'github.app.agentWrites', 'github.app.triggers', 'github.app.reviews', 'sessions.pin', 'workspace.files', 'workspace.search', 'workspace.linkBase', 'workspace.write', 'sessions.changes.authors', 'run.note'];
|
|
2
|
+
export const APP_SERVER_CAPABILITIES = ['run.start.runPermissions', 'model.relay', 'automations', 'providers.models', 'providers.test', 'providers.test.model', 'providers.thinkingLevels', 'providers.streamIdleTimeout', 'providers.modelContextWindows', 'providers.textOnlyModels', 'providers.name', 'providers.claude', 'providers.claudeAuth', 'providers.grok', 'providers.google', 'providers.opencode', 'providers.auth.submit', 'providers.opencodeGo', 'providers.discover.draft', 'providers.detectSignIns', 'providers.codexAuth', 'providers.codexAuth.logout', 'providers.codexAccounts', 'providers.anthropicConsole', 'run.resume.direction', 'run.resume.model', 'run.resume.compact', 'run.steer', 'run.overrideAllNodes', 'run.setModel', 'run.setModel.node', 'run.setPermissions', 'run.start.continueSession', 'run.start.entryHistory', 'remote.owner.projects', 'remote.engine.relay', 'environments.bridge', 'environments.cloud', 'extensions.manage', 'extensions.resources', 'skills.invoke', 'mcp.manage', 'mcp.edit', 'mcp.status', 'runs.files', 'sessions.files', 'account.profile', 'sessions.stats', 'sessions.usage', 'sessions.usage.hourly', 'config.analytics', 'config.analytics.planGate', 'sessions.trajectory', 'config.externalSubagent', 'config.codeIntel', 'config.decisions', 'browser.view', 'attachments.read', 'config.general', 'sessions.pullRequest', 'sessions.pullRequest.details', 'sessions.pullRequest.review', 'sessions.pullRequest.review.teams', 'sessions.pullRequest.merge', 'sessions.pullRequest.create', 'sessions.pullRequest.conversation', 'sessions.pullRequest.suggestions', 'sessions.pullRequest.checkLogs', 'sessions.pullRequest.edit', 'sessions.pullRequest.mergeQueue', 'sessions.pullRequest.merge.bypass', 'sessions.pullRequest.create.fork', 'sessions.pullRequest.attach', 'pullRequests.reviewRequests', 'issues.list', 'browser.view.go', 'config.browser', 'config.webSearch', 'background.tasks', 'workspace.warm', 'browser.cookies.firefox', 'browser.extensions', 'sessions.compact', 'sessions.goal', 'sessions.changes', 'run.current', 'sessions.jev', 'providers.andorra', 'graphs.visibility', 'github.app', 'github.app.agentWrites', 'github.app.triggers', 'github.app.reviews', 'github.app.repositories', 'sessions.pin', 'workspace.files', 'workspace.search', 'workspace.linkBase', 'workspace.write', 'sessions.changes.authors', 'run.note', 'workspace.image', 'workspace.taskCheckout', 'sessions.review'];
|
|
3
3
|
/** Remote engine events about the engine version a desktop runs, sent to every connection of that version. */
|
|
4
4
|
export const REMOTE_ENGINE_INSTALLING_EVENT = 'remote.engine.installing';
|
|
5
5
|
export const REMOTE_ENGINE_READY_EVENT = 'remote.engine.ready';
|
|
@@ -24,6 +24,25 @@ export declare function readWorkspaceFile(root: string, name: unknown): Promise<
|
|
|
24
24
|
hash?: string;
|
|
25
25
|
notUtf8?: true;
|
|
26
26
|
}>;
|
|
27
|
+
/** The largest image the Files tab previews; a larger one keeps the binary note. */
|
|
28
|
+
export declare const MAX_IMAGE_BYTES: number;
|
|
29
|
+
export declare function imageTypeOf(path: string): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* A project image's bytes, base64, for the Files tab's preview (`workspace.image`). `tooLarge` past 10 MB, with no
|
|
32
|
+
* bytes. The type comes from the extension only: the desktop draws it in an <img>, which never runs an SVG's script.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readWorkspaceImage(root: string, name: unknown): Promise<{
|
|
35
|
+
mimeType: string;
|
|
36
|
+
size: number;
|
|
37
|
+
dataBase64?: string;
|
|
38
|
+
tooLarge?: true;
|
|
39
|
+
}>;
|
|
40
|
+
export declare function globMatches(path: string, glob: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* A glob list's problems ripgrep would refuse, said before a search: an unclosed `{`, or so many alternatives or
|
|
43
|
+
* `**` that matching could take seconds.
|
|
44
|
+
*/
|
|
45
|
+
export declare function globProblem(glob: string): string | undefined;
|
|
27
46
|
/** The most a save from the Files tab may write. */
|
|
28
47
|
export declare const MAX_WRITE_BYTES: number;
|
|
29
48
|
/** `workspace.write`'s checked parameters: the file, as a project-relative path with `/`, and the bytes to save. */
|
|
@@ -3,7 +3,7 @@ import { createHash } from 'node:crypto';
|
|
|
3
3
|
import { createReadStream } from 'node:fs';
|
|
4
4
|
import { opendir, open, readFile, readdir, realpath, stat } from 'node:fs/promises';
|
|
5
5
|
import { StringDecoder } from 'node:string_decoder';
|
|
6
|
-
import { dirname, isAbsolute, join,
|
|
6
|
+
import { dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
|
|
7
7
|
import { runRecordPath, runRecordsDirectory, sessionHasOpenRun } from '../run-records.js';
|
|
8
8
|
import { validSavedSession } from '../sessions.js';
|
|
9
9
|
import { listBundles } from '../extensions.js';
|
|
@@ -162,6 +162,150 @@ export async function readWorkspaceFile(root, name) {
|
|
|
162
162
|
await handle.close();
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
+
/** The image types the Files tab previews (`workspace.image`), by extension. */
|
|
166
|
+
const IMAGE_TYPES = {
|
|
167
|
+
'.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.gif': 'image/gif', '.webp': 'image/webp',
|
|
168
|
+
'.bmp': 'image/bmp', '.ico': 'image/x-icon', '.svg': 'image/svg+xml',
|
|
169
|
+
};
|
|
170
|
+
/** The largest image the Files tab previews; a larger one keeps the binary note. */
|
|
171
|
+
export const MAX_IMAGE_BYTES = 10 * 1024 * 1024;
|
|
172
|
+
export function imageTypeOf(path) {
|
|
173
|
+
return IMAGE_TYPES[extname(path).toLowerCase()];
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* A project image's bytes, base64, for the Files tab's preview (`workspace.image`). `tooLarge` past 10 MB, with no
|
|
177
|
+
* bytes. The type comes from the extension only: the desktop draws it in an <img>, which never runs an SVG's script.
|
|
178
|
+
*/
|
|
179
|
+
export async function readWorkspaceImage(root, name) {
|
|
180
|
+
const path = await resolveInside(root, name);
|
|
181
|
+
const mimeType = imageTypeOf(path);
|
|
182
|
+
if (!mimeType)
|
|
183
|
+
throw new Error('This file is not an image the Files tab can show');
|
|
184
|
+
const info = await stat(path);
|
|
185
|
+
if (!info.isFile())
|
|
186
|
+
throw new Error('Only files can be opened');
|
|
187
|
+
if (info.size > MAX_IMAGE_BYTES)
|
|
188
|
+
return { mimeType, size: info.size, tooLarge: true };
|
|
189
|
+
const bytes = await readFile(path);
|
|
190
|
+
if (bytes.length > MAX_IMAGE_BYTES)
|
|
191
|
+
return { mimeType, size: bytes.length, tooLarge: true };
|
|
192
|
+
return { mimeType, size: bytes.length, dataBase64: bytes.toString('base64') };
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Whether a project path matches a glob as ripgrep's `--glob` does: `*` and `?` stay inside one folder, `**` crosses
|
|
196
|
+
* folders, `{a,b}` and `[…]` work, and a leading dot is matched like any other character (Node's matcher skips
|
|
197
|
+
* dotfiles, so the built-in search's globs missed `.eslintrc.js` and `.github/…`).
|
|
198
|
+
*/
|
|
199
|
+
/** A path and each folder above it: `a/b/c.ts`, `a/b`, `a`. */
|
|
200
|
+
function withAncestors(path) {
|
|
201
|
+
const parts = path.split('/');
|
|
202
|
+
return parts.map((_, index) => parts.slice(0, parts.length - index).join('/'));
|
|
203
|
+
}
|
|
204
|
+
export function globMatches(path, glob) {
|
|
205
|
+
return globRegExp(glob).test(path);
|
|
206
|
+
}
|
|
207
|
+
const globCache = new Map();
|
|
208
|
+
const GLOB_CACHE_LIMIT = 500;
|
|
209
|
+
function globRegExp(raw) {
|
|
210
|
+
const cached = globCache.get(raw);
|
|
211
|
+
if (cached)
|
|
212
|
+
return cached;
|
|
213
|
+
// A leading slash anchors at the project, as every glob here already is; repeated `**/` mean one.
|
|
214
|
+
const glob = raw.replace(/^\/+/, '').replace(/(\*\*\/){2,}/g, '**/');
|
|
215
|
+
let out = '';
|
|
216
|
+
let braces = 0;
|
|
217
|
+
for (let index = 0; index < glob.length; index += 1) {
|
|
218
|
+
const char = glob[index];
|
|
219
|
+
if (char === '*') {
|
|
220
|
+
if (glob[index + 1] === '*') {
|
|
221
|
+
// `**` crosses folders only as a whole path part (`**/`, `/**`, or alone in an alternative); elsewhere, as in
|
|
222
|
+
// ripgrep, it is two `*`.
|
|
223
|
+
const before = index === 0 ? '/' : glob[index - 1];
|
|
224
|
+
const after = glob[index + 2] ?? '';
|
|
225
|
+
const whole = (before === '/' || (braces > 0 && (before === '{' || before === ','))) && (after === '' || after === '/' || (braces > 0 && (after === '}' || after === ',')));
|
|
226
|
+
if (whole && after === '/') {
|
|
227
|
+
out += '(?:.*/)?';
|
|
228
|
+
index += 2;
|
|
229
|
+
}
|
|
230
|
+
else if (whole) {
|
|
231
|
+
out += '.*';
|
|
232
|
+
index += 1;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
out += '[^/]*';
|
|
236
|
+
index += 1;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
else
|
|
240
|
+
out += '[^/]*';
|
|
241
|
+
}
|
|
242
|
+
else if (char === '?')
|
|
243
|
+
out += '[^/]';
|
|
244
|
+
else if (char === '{') {
|
|
245
|
+
out += '(?:';
|
|
246
|
+
braces += 1;
|
|
247
|
+
}
|
|
248
|
+
else if (char === '}' && braces > 0) {
|
|
249
|
+
out += ')';
|
|
250
|
+
braces -= 1;
|
|
251
|
+
}
|
|
252
|
+
else if (char === ',' && braces > 0)
|
|
253
|
+
out += '|';
|
|
254
|
+
else if (char === '[') {
|
|
255
|
+
const end = glob.indexOf(']', index + 2);
|
|
256
|
+
if (end < 0) {
|
|
257
|
+
out += '\\[';
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
let body = glob.slice(index + 1, end);
|
|
261
|
+
if (body.startsWith('!'))
|
|
262
|
+
body = `^${body.slice(1)}`;
|
|
263
|
+
out += `[${body.replace(/\\/g, '\\\\')}]`;
|
|
264
|
+
index = end;
|
|
265
|
+
}
|
|
266
|
+
else if (char === '\\' && index + 1 < glob.length) {
|
|
267
|
+
out += glob[index + 1].replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
|
|
268
|
+
index += 1;
|
|
269
|
+
}
|
|
270
|
+
else
|
|
271
|
+
out += char.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
|
|
272
|
+
}
|
|
273
|
+
let pattern;
|
|
274
|
+
// Case-sensitive everywhere, as ripgrep's --glob is.
|
|
275
|
+
try {
|
|
276
|
+
pattern = new RegExp(`^${out}$`);
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
pattern = /(?!)/;
|
|
280
|
+
}
|
|
281
|
+
if (globCache.size >= GLOB_CACHE_LIMIT)
|
|
282
|
+
globCache.clear();
|
|
283
|
+
globCache.set(raw, pattern);
|
|
284
|
+
return pattern;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* A glob list's problems ripgrep would refuse, said before a search: an unclosed `{`, or so many alternatives or
|
|
288
|
+
* `**` that matching could take seconds.
|
|
289
|
+
*/
|
|
290
|
+
export function globProblem(glob) {
|
|
291
|
+
let depth = 0;
|
|
292
|
+
for (let index = 0; index < glob.length; index += 1) {
|
|
293
|
+
const char = glob[index];
|
|
294
|
+
if (char === '\\') {
|
|
295
|
+
index += 1;
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (char === '{')
|
|
299
|
+
depth += 1;
|
|
300
|
+
else if (char === '}' && depth > 0)
|
|
301
|
+
depth -= 1;
|
|
302
|
+
}
|
|
303
|
+
if (depth > 0)
|
|
304
|
+
return `The glob "${glob}" has an unclosed {`;
|
|
305
|
+
if ((glob.match(/\{/g) ?? []).length > 8 || (glob.match(/\*\*/g) ?? []).length > 8)
|
|
306
|
+
return `The glob "${glob}" is too complex to search with`;
|
|
307
|
+
return undefined;
|
|
308
|
+
}
|
|
165
309
|
/** The most a save from the Files tab may write. */
|
|
166
310
|
export const MAX_WRITE_BYTES = 16 * 1024 * 1024;
|
|
167
311
|
/** `workspace.write`'s checked parameters: the file, as a project-relative path with `/`, and the bytes to save. */
|
|
@@ -1035,7 +1179,13 @@ export function globList(value) {
|
|
|
1035
1179
|
current += char;
|
|
1036
1180
|
}
|
|
1037
1181
|
parts.push(current);
|
|
1038
|
-
|
|
1182
|
+
const globs = parts.map(part => part.trim()).filter(Boolean);
|
|
1183
|
+
for (const glob of globs) {
|
|
1184
|
+
const problem = globProblem(glob);
|
|
1185
|
+
if (problem)
|
|
1186
|
+
throw new Error(problem);
|
|
1187
|
+
}
|
|
1188
|
+
return globs;
|
|
1039
1189
|
}
|
|
1040
1190
|
export function searchOptions(params) {
|
|
1041
1191
|
const query = params.query;
|
|
@@ -1219,7 +1369,7 @@ async function searchBuiltIn(root, options, signal) {
|
|
|
1219
1369
|
const include = globList(options.include);
|
|
1220
1370
|
const exclude = globList(options.exclude);
|
|
1221
1371
|
// A glob without a folder matches the file's name anywhere, as ripgrep's --glob does.
|
|
1222
|
-
const matchesGlob = (path, glob) =>
|
|
1372
|
+
const matchesGlob = (path, glob) => globMatches(path, glob) || (!glob.includes('/') && globMatches(posix.basename(path), glob));
|
|
1223
1373
|
const collected = new SearchCollector();
|
|
1224
1374
|
const deadline = Date.now() + SEARCH_TIME_MS;
|
|
1225
1375
|
let incomplete;
|
|
@@ -1234,7 +1384,8 @@ async function searchBuiltIn(root, options, signal) {
|
|
|
1234
1384
|
continue;
|
|
1235
1385
|
if (include.length && !include.some(glob => matchesGlob(file.path, glob)))
|
|
1236
1386
|
continue;
|
|
1237
|
-
|
|
1387
|
+
// An exclude that names a folder leaves out everything in it, as ripgrep's does.
|
|
1388
|
+
if (exclude.some(glob => withAncestors(file.path).some(path => matchesGlob(path, glob))))
|
|
1238
1389
|
continue;
|
|
1239
1390
|
if (scanned >= SEARCH_FALLBACK_FILES) {
|
|
1240
1391
|
incomplete = `Search stopped at ${SEARCH_FALLBACK_FILES.toLocaleString('en-US')} files`;
|
package/dist/src/app-server.d.ts
CHANGED
|
@@ -222,7 +222,8 @@ export declare class AppServer {
|
|
|
222
222
|
private readonly titleReleases;
|
|
223
223
|
private readonly titleAnswered;
|
|
224
224
|
private readonly sessionTitles;
|
|
225
|
-
|
|
225
|
+
/** Automatic titles waiting to be asked again, by session, after an attempt was refused, failed, or cut short. */
|
|
226
|
+
private readonly titleRetries;
|
|
226
227
|
private readonly operations;
|
|
227
228
|
private prepareTask?;
|
|
228
229
|
private foreignEngineWatch?;
|
|
@@ -319,6 +320,12 @@ export declare class AppServer {
|
|
|
319
320
|
private anthropicProviderAuth;
|
|
320
321
|
private recordCodexEmail;
|
|
321
322
|
private testProviderEndpoint;
|
|
323
|
+
private thinkingLevelTarget;
|
|
324
|
+
private thinkingLevelsView;
|
|
325
|
+
/** Finds out which thinking levels a model accepts and saves them. An inconclusive answer saves nothing. */
|
|
326
|
+
private detectThinkingLevels;
|
|
327
|
+
private setThinkingLevels;
|
|
328
|
+
private saveThinkingLevels;
|
|
322
329
|
private operation;
|
|
323
330
|
private accountStatus;
|
|
324
331
|
private accountProfile;
|
|
@@ -358,12 +365,23 @@ export declare class AppServer {
|
|
|
358
365
|
private compactSession;
|
|
359
366
|
private saveFinalizedSession;
|
|
360
367
|
private setSessionArchived;
|
|
368
|
+
/** Marks a task's completed turn reviewed, as Needs you's Mark Reviewed does: only the turn the lead was shown. */
|
|
369
|
+
private setSessionReviewed;
|
|
361
370
|
/** Pins or unpins a task in the rail. The pin is rail-owned like a rename, so this window's own run may be pinned too: the run carries it forward when it saves. */
|
|
362
371
|
private setSessionPinned;
|
|
363
372
|
private deleteSession;
|
|
364
373
|
private startRun;
|
|
365
374
|
private resumeRun;
|
|
366
375
|
private switchBranch;
|
|
376
|
+
/** Makes a writing task's worktree before its run starts; the same key returns the same worktree on a retry. */
|
|
377
|
+
private prepareTaskCheckout;
|
|
378
|
+
private sessionCheckoutState;
|
|
379
|
+
private refuseCheckoutChange;
|
|
380
|
+
/** Recreates a task's missing worktree from its branch, or takes the folder it moved to. */
|
|
381
|
+
private recoverSessionCheckout;
|
|
382
|
+
private inspectSessionCheckout;
|
|
383
|
+
/** Removes a task's worktree after the lead saw what it holds; the branch stays when it has commits nothing else has. */
|
|
384
|
+
private removeSessionCheckout;
|
|
367
385
|
private assertRunning;
|
|
368
386
|
private prepareRun;
|
|
369
387
|
private graphForRun;
|
|
@@ -371,7 +389,15 @@ export declare class AppServer {
|
|
|
371
389
|
private loadResumeGraph;
|
|
372
390
|
private prepareRunValidated;
|
|
373
391
|
private titleSessionFromPrompt;
|
|
392
|
+
/** Saves an automatic title under the same lock and guards a user rename takes. */
|
|
393
|
+
/** `saved`: the name landed. `busy`: a run owns the session — the title can land once it settles. `stale`: the record is gone, renamed, already carrying the name, or waiting on a failed final save that recovery owns. */
|
|
394
|
+
private saveSessionTitle;
|
|
395
|
+
/** A title that never landed waits and asks again, so one busy moment does not leave the session with its prompt's first words. */
|
|
396
|
+
private scheduleTitleRetry;
|
|
397
|
+
private retrySessionTitle;
|
|
398
|
+
private runTitleRetry;
|
|
374
399
|
private releaseTitleWaiter;
|
|
400
|
+
/** Abort title work for the session given, or for all: the request on the wire, and a retry that is still waiting is moved back, not dropped. */
|
|
375
401
|
private cancelSessionTitles;
|
|
376
402
|
private executeRun;
|
|
377
403
|
private reasoningAdapter;
|
|
@@ -451,6 +477,7 @@ export declare class AppServer {
|
|
|
451
477
|
* (a person's own action) asks it regardless.
|
|
452
478
|
*/
|
|
453
479
|
private listedEnvironmentIds;
|
|
480
|
+
private offlineEnvironmentLine;
|
|
454
481
|
/** A call for a machine whose link is waiting for it to come back fails now instead of at its deadline. */
|
|
455
482
|
private refuseWhileReconnecting;
|
|
456
483
|
private hostOperation;
|
|
@@ -561,6 +588,8 @@ export declare class AppServer {
|
|
|
561
588
|
private remoteOwnerRoots;
|
|
562
589
|
private remoteOwnerBrowse;
|
|
563
590
|
private remoteOwnerAddProject;
|
|
591
|
+
/** Asks a Cloud machine to clone a GitHub repository and register it; answered at once, and asked again while it clones. */
|
|
592
|
+
private remoteOwnerGitHubClone;
|
|
564
593
|
private listProjects;
|
|
565
594
|
private addProject;
|
|
566
595
|
private removeProject;
|
|
@@ -665,6 +694,8 @@ export declare class AppServer {
|
|
|
665
694
|
*/
|
|
666
695
|
private wakeForMention;
|
|
667
696
|
private githubConnect;
|
|
697
|
+
/** The repositories the GitHub App can reach for this account's linked GitHub user: what a Cloud machine may clone. */
|
|
698
|
+
private githubRepositories;
|
|
668
699
|
private githubDisconnect;
|
|
669
700
|
/**
|
|
670
701
|
* The PR tab's read of a task's pull request: branches, author, mergeability, description, commits,
|