@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.
Files changed (94) hide show
  1. package/dist/src/agent-execution.js +97 -11
  2. package/dist/src/andorra/errors.js +3 -0
  3. package/dist/src/app-server/protocol.d.ts +13 -2
  4. package/dist/src/app-server/protocol.js +1 -1
  5. package/dist/src/app-server/workspace.d.ts +19 -0
  6. package/dist/src/app-server/workspace.js +155 -4
  7. package/dist/src/app-server.d.ts +32 -1
  8. package/dist/src/app-server.js +622 -74
  9. package/dist/src/attachments.d.ts +10 -0
  10. package/dist/src/attachments.js +102 -7
  11. package/dist/src/automation-tool.js +2 -1
  12. package/dist/src/bridge/command.js +12 -0
  13. package/dist/src/bridge/control.d.ts +3 -1
  14. package/dist/src/bridge/control.js +7 -2
  15. package/dist/src/bridge/github.d.ts +108 -0
  16. package/dist/src/bridge/github.js +378 -0
  17. package/dist/src/bridge/host-ops.d.ts +1 -1
  18. package/dist/src/bridge/host-ops.js +11 -1
  19. package/dist/src/bridge/host.js +7 -4
  20. package/dist/src/bug-report-attachments.d.ts +48 -0
  21. package/dist/src/bug-report-attachments.js +327 -0
  22. package/dist/src/bug-report.d.ts +23 -3
  23. package/dist/src/bug-report.js +72 -9
  24. package/dist/src/cli.d.ts +1 -3
  25. package/dist/src/cli.js +10 -4
  26. package/dist/src/codex-provider.js +1 -1
  27. package/dist/src/coding-tools.js +9 -2
  28. package/dist/src/commands.d.ts +1 -1
  29. package/dist/src/commands.js +2 -1
  30. package/dist/src/completion.js +8 -4
  31. package/dist/src/config.js +3 -1
  32. package/dist/src/context-budget.js +15 -2
  33. package/dist/src/decision/DecisionEngine.d.ts +2 -0
  34. package/dist/src/decision/DecisionManager.d.ts +11 -0
  35. package/dist/src/decision/DecisionManager.js +36 -0
  36. package/dist/src/decision/applyTaskKind.d.ts +8 -0
  37. package/dist/src/decision/applyTaskKind.js +53 -0
  38. package/dist/src/decision/hostedPolicy.js +2 -1
  39. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +2 -0
  40. package/dist/src/decision/providers/AndorraDecisionProvider.js +12 -0
  41. package/dist/src/decision/taskKind.d.ts +52 -0
  42. package/dist/src/decision/taskKind.js +76 -0
  43. package/dist/src/decision/types.d.ts +1 -1
  44. package/dist/src/default-graph.js +1 -1
  45. package/dist/src/efficiency.d.ts +5 -0
  46. package/dist/src/efficiency.js +5 -1
  47. package/dist/src/effort-routing.d.ts +27 -0
  48. package/dist/src/effort-routing.js +34 -0
  49. package/dist/src/evidence.d.ts +110 -0
  50. package/dist/src/evidence.js +195 -0
  51. package/dist/src/github-app/client.d.ts +19 -0
  52. package/dist/src/github-app/client.js +21 -1
  53. package/dist/src/github-names.d.ts +7 -0
  54. package/dist/src/github-names.js +7 -0
  55. package/dist/src/graph-preview.d.ts +2 -0
  56. package/dist/src/graph-preview.js +1 -0
  57. package/dist/src/graph-runner.js +1 -1
  58. package/dist/src/graph-server.js +4 -2
  59. package/dist/src/graph-ui/app.js +30 -0
  60. package/dist/src/graphs.d.ts +6 -0
  61. package/dist/src/graphs.js +7 -2
  62. package/dist/src/hardened-runtime.js +32 -21
  63. package/dist/src/model-health-cache.js +1 -1
  64. package/dist/src/model-override.d.ts +2 -1
  65. package/dist/src/model-override.js +9 -0
  66. package/dist/src/model-tiers.d.ts +3 -0
  67. package/dist/src/model-tiers.js +3 -3
  68. package/dist/src/provider-engine.d.ts +13 -1
  69. package/dist/src/provider-engine.js +74 -0
  70. package/dist/src/providers.d.ts +5 -0
  71. package/dist/src/providers.js +34 -8
  72. package/dist/src/pull-requests.d.ts +11 -1
  73. package/dist/src/pull-requests.js +53 -2
  74. package/dist/src/react-runtime.js +98 -15
  75. package/dist/src/remote/engine-pool.js +5 -5
  76. package/dist/src/runtime.d.ts +29 -1
  77. package/dist/src/runtime.js +8 -0
  78. package/dist/src/sessions.d.ts +24 -0
  79. package/dist/src/sessions.js +55 -2
  80. package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
  81. package/dist/src/skills/bundled/provenance.json +1 -1
  82. package/dist/src/task-checkout.d.ts +141 -0
  83. package/dist/src/task-checkout.js +558 -0
  84. package/dist/src/test-edit-guard.d.ts +30 -0
  85. package/dist/src/test-edit-guard.js +167 -2
  86. package/dist/src/thinking-level-detect.d.ts +11 -0
  87. package/dist/src/thinking-level-detect.js +47 -0
  88. package/dist/src/thinking-levels.d.ts +30 -0
  89. package/dist/src/thinking-levels.js +124 -0
  90. package/dist/src/timers.d.ts +1 -0
  91. package/dist/src/tool-catalog.js +1 -1
  92. package/dist/src/transcript.js +1 -1
  93. package/dist/src/types.d.ts +34 -0
  94. package/package.json +1 -1
@@ -0,0 +1,34 @@
1
+ import { DecisionPolicy } from './decision/DecisionPolicy.js';
2
+ import { MECHANICAL_MAX_CHARS, MECHANICAL_WORDS, RISK_WORDS } from './model-tiers.js';
3
+ import { nearestEnabled } from './thinking-levels.js';
4
+ /** A failed attempt moves up a level only when the failure suggests the model needed to think harder. */
5
+ export const EFFORT_ESCALATION_REASONS = new Set(['repeatedToolFailure', 'maxIterations']);
6
+ /**
7
+ * The thinking level for one start of a node on Auto. Risk takes the highest enabled level, a confident complexity
8
+ * score is spread evenly across the enabled levels, and an obviously mechanical short task takes the lowest. With no
9
+ * decisive signal the node keeps the level it would have had, moved onto an enabled one.
10
+ */
11
+ export function decideEffort(input) {
12
+ const { levels } = input;
13
+ if (levels.length === 0)
14
+ return { evidence: 'none' };
15
+ if (input.previous) {
16
+ const at = levels.indexOf(nearestEnabled(levels, input.previous.level));
17
+ const up = input.previous.reason !== undefined && EFFORT_ESCALATION_REASONS.has(input.previous.reason) && at < levels.length - 1;
18
+ return { level: levels[up ? at + 1 : at], evidence: up ? 'escalation' : 'none' };
19
+ }
20
+ if (levels.length === 1)
21
+ return { level: levels[0], evidence: 'none' };
22
+ const highest = levels[levels.length - 1];
23
+ const hints = input.hints;
24
+ if (hints && (DecisionPolicy.boolean(hints, 'security_sensitive') === true || DecisionPolicy.boolean(hints, 'architecture_affecting') === true))
25
+ return { level: highest, evidence: 'hint' };
26
+ if (RISK_WORDS.test(input.task))
27
+ return { level: highest, evidence: 'lexical' };
28
+ const complexity = hints ? DecisionPolicy.score(hints, 'task_complexity') : undefined;
29
+ if (complexity !== undefined)
30
+ return { level: levels[Math.min(levels.length - 1, Math.max(0, Math.floor(complexity * levels.length)))], evidence: 'hint' };
31
+ if (input.task.length <= MECHANICAL_MAX_CHARS && MECHANICAL_WORDS.test(input.task))
32
+ return { level: levels[0], evidence: 'lexical' };
33
+ return { level: input.fallback === undefined ? undefined : nearestEnabled(levels, input.fallback), evidence: 'none' };
34
+ }
@@ -0,0 +1,110 @@
1
+ /** What the agent lists in complete_agent's `outcomes`. */
2
+ export interface RequestedOutcome {
3
+ /** The outcome in plain language: "The SDK handles the API's final page". */
4
+ outcome: string;
5
+ status: 'passed' | 'failed' | 'not_checked';
6
+ /** The exact command that shows it, as it was run. */
7
+ command?: string;
8
+ /** The agent's own reading of the result. */
9
+ reading?: string;
10
+ /** For a not-checked outcome: why, and how a person can check it. */
11
+ why?: string;
12
+ how?: string;
13
+ }
14
+ /** The runtime's record of one command an agent ran. */
15
+ export interface CommandObservation {
16
+ id: string;
17
+ command: string;
18
+ directory: string;
19
+ startedAt: string;
20
+ endedAt?: string;
21
+ exitCode?: number;
22
+ /** The last 4 KB of what it printed. */
23
+ output?: string;
24
+ /**
25
+ * What it ran against, read just before it started: the commit, and the uncommitted files at that moment.
26
+ * `inputsUnknown`: Git could not list them (it timed out, say), so the revision is labelled as incomplete.
27
+ */
28
+ revision?: {
29
+ commit?: string;
30
+ dirty: string[];
31
+ dirtyCount: number;
32
+ inputsUnknown?: true;
33
+ };
34
+ }
35
+ export type EvidenceState = 'passed' | 'failed' | 'unchecked' | 'reported';
36
+ /** One row of a turn's evidence. Runtime facts and the agent's reading are kept apart. */
37
+ export interface EvidenceItem {
38
+ criterion: string;
39
+ state: EvidenceState;
40
+ /** The result in a few words: from the run for an observed row. */
41
+ result: string;
42
+ observation?: CommandObservation;
43
+ /** The agent's reading, labelled as such. */
44
+ agent?: string;
45
+ why?: string;
46
+ how?: string;
47
+ /** A neutral freshness note: the result stands, but what it covered may have changed. */
48
+ stale?: string;
49
+ }
50
+ export declare const MAX_OUTCOMES = 20;
51
+ /** Commands are kept, and compared, up to this length. */
52
+ export declare const COMMAND_LIMIT = 8000;
53
+ export declare const OUTPUT_TAIL_BYTES = 4096;
54
+ export declare const OUTCOMES_DESCRIPTION = "Optional. When the task asked for results that can be checked, list each requested outcome: outcome (plain language), status (passed, failed or not_checked), command (the exact command you ran that shows it, copied as you ran it), reading (your short reading of its result), and for not_checked: why, and how a person can check it. The runtime links each command to its own record of the run; an outcome with no recorded command shows as unverified.";
55
+ /** The JSON schema of `outcomes` in complete_agent. */
56
+ export declare const OUTCOMES_SCHEMA: {
57
+ readonly type: "array";
58
+ readonly maxItems: 20;
59
+ readonly description: "Optional. When the task asked for results that can be checked, list each requested outcome: outcome (plain language), status (passed, failed or not_checked), command (the exact command you ran that shows it, copied as you ran it), reading (your short reading of its result), and for not_checked: why, and how a person can check it. The runtime links each command to its own record of the run; an outcome with no recorded command shows as unverified.";
60
+ readonly items: {
61
+ readonly type: "object";
62
+ readonly properties: {
63
+ readonly outcome: {
64
+ readonly type: "string";
65
+ };
66
+ readonly status: {
67
+ readonly type: "string";
68
+ readonly enum: readonly ["passed", "failed", "not_checked"];
69
+ };
70
+ readonly command: {
71
+ readonly type: "string";
72
+ };
73
+ readonly reading: {
74
+ readonly type: "string";
75
+ };
76
+ readonly why: {
77
+ readonly type: "string";
78
+ };
79
+ readonly how: {
80
+ readonly type: "string";
81
+ };
82
+ };
83
+ readonly required: readonly ["outcome", "status"];
84
+ readonly additionalProperties: false;
85
+ };
86
+ };
87
+ /** The outcomes an agent sent, kept leniently: a malformed entry is dropped with a note, never a failed completion. */
88
+ export declare function parseOutcomes(value: unknown, notes?: string[]): RequestedOutcome[] | undefined;
89
+ /**
90
+ * Each outcome against what ran: the newest recorded run of its exact command decides passed or failed by its exit
91
+ * code, whatever the agent claimed; an outcome whose command never ran is agent-reported; a not-checked one says why.
92
+ * `edits` are the times files were edited by the agent; a run followed by an edit, or by a run that saw other files,
93
+ * keeps its result with "Edited since".
94
+ */
95
+ export declare function resolveEvidence(outcomes: readonly RequestedOutcome[], observations: readonly CommandObservation[], edits?: readonly string[], finalRevisions?: ReadonlyMap<string, CommandObservation['revision']>): EvidenceItem[];
96
+ /**
97
+ * What the ledger names about a turn (E7): each outcome it did not verify, said as it stands — not checked, only
98
+ * agent-reported, failed, or passed before later edits.
99
+ */
100
+ export declare function unverified(items: readonly EvidenceItem[] | undefined): string[];
101
+ /**
102
+ * The commit and uncommitted files of `directory`'s repository right now; undefined outside Git. Git runs as the
103
+ * app's other reads of a workspace do: found outside the workspace, with fsmonitor, hooks and the repository's
104
+ * filter drivers off, so reading the revision never runs anything the workspace configured.
105
+ */
106
+ export declare function readRevision(directory: string, signal?: AbortSignal): Promise<CommandObservation['revision']>;
107
+ /** A command or its output as kept: terminal escapes stripped and known secret shapes redacted. */
108
+ export declare function cleanRecorded(text: string): string;
109
+ /** The last 4 KB of a command's output, cut at a line where it can be. */
110
+ export declare function outputTail(output: string): string;
@@ -0,0 +1,195 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { stripVTControlCharacters } from 'node:util';
3
+ import { excludedRoots, trustedGitEnv, trustedGitPath } from './git-summary.js';
4
+ import { redactSecrets } from './secret-redaction.js';
5
+ export const MAX_OUTCOMES = 20;
6
+ /** Commands are kept, and compared, up to this length. */
7
+ export const COMMAND_LIMIT = 8000;
8
+ export const OUTPUT_TAIL_BYTES = 4096;
9
+ const TEXT_LIMIT = 600;
10
+ const DIRTY_LISTED = 20;
11
+ export const OUTCOMES_DESCRIPTION = 'Optional. When the task asked for results that can be checked, list each requested outcome: outcome (plain language), status (passed, failed or not_checked), command (the exact command you ran that shows it, copied as you ran it), reading (your short reading of its result), and for not_checked: why, and how a person can check it. The runtime links each command to its own record of the run; an outcome with no recorded command shows as unverified.';
12
+ /** The JSON schema of `outcomes` in complete_agent. */
13
+ export const OUTCOMES_SCHEMA = {
14
+ type: 'array', maxItems: MAX_OUTCOMES, description: OUTCOMES_DESCRIPTION,
15
+ items: {
16
+ type: 'object',
17
+ properties: {
18
+ outcome: { type: 'string' }, status: { type: 'string', enum: ['passed', 'failed', 'not_checked'] },
19
+ command: { type: 'string' }, reading: { type: 'string' }, why: { type: 'string' }, how: { type: 'string' },
20
+ },
21
+ required: ['outcome', 'status'],
22
+ additionalProperties: false,
23
+ },
24
+ };
25
+ const text = (value, limit = TEXT_LIMIT) => typeof value === 'string' && value.trim() ? value.trim().slice(0, limit) : undefined;
26
+ /** The outcomes an agent sent, kept leniently: a malformed entry is dropped with a note, never a failed completion. */
27
+ export function parseOutcomes(value, notes) {
28
+ if (value === undefined)
29
+ return undefined;
30
+ // Some models send a list as JSON text.
31
+ if (typeof value === 'string') {
32
+ try {
33
+ value = JSON.parse(value);
34
+ notes?.push('outcomes arrived as JSON text and was decoded');
35
+ }
36
+ catch { /* not JSON */ }
37
+ }
38
+ if (!Array.isArray(value)) {
39
+ notes?.push('outcomes was not a list and was ignored');
40
+ return undefined;
41
+ }
42
+ const kept = [];
43
+ let dropped = 0;
44
+ for (const entry of value.slice(0, MAX_OUTCOMES)) {
45
+ const item = entry;
46
+ const outcome = text(item?.outcome, 300);
47
+ if (outcome === undefined) {
48
+ dropped++;
49
+ continue;
50
+ }
51
+ // A status the list does not know (skipped, blocked) is a gap the agent disclosed: kept as not checked.
52
+ const said = typeof item?.status === 'string' ? item.status : '';
53
+ const status = said === 'passed' || said === 'failed' || said === 'not_checked' ? said : 'not_checked';
54
+ const command = text(item?.command, COMMAND_LIMIT), reading = text(item?.reading), how = text(item?.how);
55
+ const why = text(item?.why) ?? (status !== said && said ? `Reported as ${said.slice(0, 40)}.` : undefined);
56
+ kept.push({ outcome, status, ...(command ? { command } : {}), ...(reading ? { reading } : {}), ...(why ? { why } : {}), ...(how ? { how } : {}) });
57
+ }
58
+ if (dropped)
59
+ notes?.push(`${dropped} outcome${dropped === 1 ? ' was' : 's were'} malformed and dropped`);
60
+ return kept.length ? kept : undefined;
61
+ }
62
+ /** Commands compare with their ends trimmed and runs of spaces or tabs between words collapsed; line breaks count. */
63
+ const normalized = (command) => command.slice(0, COMMAND_LIMIT).trim().replace(/[ \t]+/g, ' ').replace(/ ?\r?\n ?/g, '\n');
64
+ /** The last non-empty line of the output, as the row's result. */
65
+ function lastLine(output) {
66
+ const line = output?.split('\n').map(part => part.trim()).filter(Boolean).at(-1);
67
+ return line === undefined ? undefined : line.length > 120 ? `${line.slice(0, 119)}…` : line;
68
+ }
69
+ /**
70
+ * Each outcome against what ran: the newest recorded run of its exact command decides passed or failed by its exit
71
+ * code, whatever the agent claimed; an outcome whose command never ran is agent-reported; a not-checked one says why.
72
+ * `edits` are the times files were edited by the agent; a run followed by an edit, or by a run that saw other files,
73
+ * keeps its result with "Edited since".
74
+ */
75
+ export function resolveEvidence(outcomes, observations, edits = [], finalRevisions = new Map()) {
76
+ return outcomes.map(outcome => {
77
+ const agent = outcome.reading;
78
+ if (outcome.status === 'not_checked') {
79
+ return { criterion: outcome.outcome, state: 'unchecked', result: 'Not checked', ...(outcome.why ? { why: outcome.why } : {}), ...(outcome.how ? { how: outcome.how } : {}), ...(agent ? { agent } : {}) };
80
+ }
81
+ const wanted = outcome.command === undefined ? undefined : normalized(outcome.command);
82
+ const observed = wanted === undefined ? undefined : [...observations].reverse().find(item => normalized(item.command) === wanted && item.endedAt !== undefined);
83
+ if (observed === undefined) {
84
+ return {
85
+ criterion: outcome.outcome, state: 'reported',
86
+ result: outcome.command ? 'Agent-reported · the command it names was not recorded' : 'Agent-reported · no recorded run',
87
+ why: 'The agent reported this, but no run of the command it names was recorded in this turn.',
88
+ ...(agent ? { agent } : {}),
89
+ };
90
+ }
91
+ // A zero exit can hide failures (a pipe into tail, `|| true`): when the agent read a failure, it stays failed.
92
+ const passed = observed.exitCode === 0 && outcome.status !== 'failed';
93
+ const tail = lastLine(observed.output);
94
+ const after = Date.parse(observed.endedAt);
95
+ const known = (revision) => revision !== undefined && revision.inputsUnknown !== true;
96
+ const finalRevision = finalRevisions.get(observed.directory);
97
+ const editedLater = edits.some(at => Date.parse(at) > after)
98
+ // A later command in the same folder that saw other files means the shell changed them.
99
+ || observations.some(item => item.directory === observed.directory && Date.parse(item.startedAt) > after && known(item.revision) && known(observed.revision) && revisionKey(item) !== revisionKey(observed))
100
+ // So does the folder as the turn left it.
101
+ || (known(finalRevision) && known(observed.revision) && revisionKey({ ...observed, revision: finalRevision }) !== revisionKey(observed));
102
+ return {
103
+ criterion: outcome.outcome,
104
+ state: passed ? 'passed' : 'failed',
105
+ result: [tail, observed.exitCode === undefined ? 'did not finish' : `exit ${observed.exitCode}`, observed.exitCode === 0 && !passed ? 'agent read failures' : undefined].filter(Boolean).join(' · '),
106
+ observation: observed,
107
+ ...(agent ? { agent } : {}),
108
+ ...(editedLater ? { stale: 'Edited since' } : {}),
109
+ };
110
+ });
111
+ }
112
+ function revisionKey(item) {
113
+ return `${item.revision?.commit ?? ''}|${(item.revision?.dirty ?? []).join(',')}|${item.revision?.dirtyCount ?? 0}`;
114
+ }
115
+ /**
116
+ * What the ledger names about a turn (E7): each outcome it did not verify, said as it stands — not checked, only
117
+ * agent-reported, failed, or passed before later edits.
118
+ */
119
+ export function unverified(items) {
120
+ const phrase = { unchecked: 'not checked', reported: 'only agent-reported', failed: 'failed' };
121
+ // The most serious first: a failure, then a gap, then a claim, then a pass that edits may have overtaken.
122
+ const rank = (item) => item.state === 'failed' ? 0 : item.state === 'unchecked' ? 1 : item.state === 'reported' ? 2 : 3;
123
+ return [...(items ?? [])].sort((a, b) => rank(a) - rank(b)).flatMap(item => {
124
+ const said = phrase[item.state] ?? (item.stale ? 'edited since its check' : undefined);
125
+ return said === undefined ? [] : [`${item.criterion.replace(/[.\s]+$/, '')} ${said}`];
126
+ });
127
+ }
128
+ const GIT_FLAGS = ['--no-pager', '--no-optional-locks', '-c', 'core.fsmonitor=false', '-c', 'core.hooksPath=', '-c', 'core.quotePath=false', '-c', 'gc.auto=0'];
129
+ const REVISION_TIMEOUT_MS = 3000;
130
+ function run(binary, args, cwd, env, signal) {
131
+ return new Promise(resolve => {
132
+ execFile(binary, args, { cwd, env, windowsHide: true, timeout: REVISION_TIMEOUT_MS, maxBuffer: 4 << 20, ...(signal ? { signal } : {}) }, (error, stdout, stderr) => resolve({ code: error === null ? 0 : typeof error.code === 'number' ? error.code : 1, stdout: String(stdout), stderr: String(stderr) }));
133
+ });
134
+ }
135
+ /**
136
+ * The commit and uncommitted files of `directory`'s repository right now; undefined outside Git. Git runs as the
137
+ * app's other reads of a workspace do: found outside the workspace, with fsmonitor, hooks and the repository's
138
+ * filter drivers off, so reading the revision never runs anything the workspace configured.
139
+ */
140
+ export async function readRevision(directory, signal) {
141
+ const env = { ...trustedGitEnv(directory), GIT_TERMINAL_PROMPT: '0' };
142
+ const binary = trustedGitPath(env, excludedRoots(directory));
143
+ if (binary === undefined)
144
+ return undefined;
145
+ const drivers = await run(binary, [...GIT_FLAGS, 'config', '--null', '--get-regexp', '^filter\\.'], directory, env, signal);
146
+ const names = [...new Set(drivers.stdout.split('\0').map(entry => /^filter\.(.+)\.[^.\n]+\n/.exec(entry)?.[1]).filter((name) => !!name))];
147
+ const neutral = names.flatMap(name => ['-c', `filter.${name}.clean=`, '-c', `filter.${name}.smudge=`, '-c', `filter.${name}.process=`, '-c', `filter.${name}.required=false`]);
148
+ const status = await run(binary, [...GIT_FLAGS, ...neutral, 'status', '--porcelain=v2', '--branch', '-z', '--untracked-files=all'], directory, env, signal);
149
+ if (status.code !== 0) {
150
+ if (/not a git repository/i.test(status.stderr))
151
+ return undefined;
152
+ const head = await run(binary, [...GIT_FLAGS, 'rev-parse', '--verify', '--quiet', 'HEAD'], directory, env, signal);
153
+ if (head.code !== 0 && /not a git repository/i.test(head.stderr))
154
+ return undefined;
155
+ return { ...(head.code === 0 && head.stdout.trim() ? { commit: head.stdout.trim() } : {}), dirty: [], dirtyCount: 0, inputsUnknown: true };
156
+ }
157
+ let commit;
158
+ const files = [];
159
+ const records = status.stdout.split('\0');
160
+ for (let index = 0; index < records.length; index++) {
161
+ const record = records[index];
162
+ if (record.startsWith('# branch.oid ')) {
163
+ const oid = record.slice('# branch.oid '.length).trim();
164
+ if (/^[0-9a-f]{7,64}$/.test(oid))
165
+ commit = oid;
166
+ continue;
167
+ }
168
+ if (record.startsWith('#') || !record)
169
+ continue;
170
+ const fields = record.split(' ');
171
+ if (record[0] === '1')
172
+ files.push(fields.slice(8).join(' '));
173
+ else if (record[0] === '2') {
174
+ files.push(fields.slice(9).join(' '));
175
+ index++;
176
+ }
177
+ else if (record[0] === 'u')
178
+ files.push(fields.slice(10).join(' '));
179
+ else if (record[0] === '?')
180
+ files.push(record.slice(2));
181
+ }
182
+ return { ...(commit ? { commit } : {}), dirty: files.slice(0, DIRTY_LISTED), dirtyCount: files.length };
183
+ }
184
+ /** A command or its output as kept: terminal escapes stripped and known secret shapes redacted. */
185
+ export function cleanRecorded(text) {
186
+ return redactSecrets(stripVTControlCharacters(text));
187
+ }
188
+ /** The last 4 KB of a command's output, cut at a line where it can be. */
189
+ export function outputTail(output) {
190
+ if (output.length <= OUTPUT_TAIL_BYTES)
191
+ return output;
192
+ const tail = output.slice(-OUTPUT_TAIL_BYTES);
193
+ const at = tail.indexOf('\n');
194
+ return at >= 0 && at < 200 ? tail.slice(at + 1) : tail;
195
+ }
@@ -66,6 +66,21 @@ export interface GitHubAppStatus {
66
66
  connection: GitHubConnection | null;
67
67
  installations: GitHubInstallation[];
68
68
  }
69
+ /** A repository the App can reach for the linked GitHub user; `push` is whether that user can push to it. */
70
+ export interface GitHubRepository {
71
+ id: number;
72
+ owner: string;
73
+ name: string;
74
+ private: boolean;
75
+ push: boolean;
76
+ }
77
+ /** `more`: the service left some repositories out for now (a large installation); asking again later lists further. */
78
+ export interface GitHubRepositoriesAnswer {
79
+ enabled: boolean;
80
+ connected: boolean;
81
+ repositories: GitHubRepository[];
82
+ more: boolean;
83
+ }
69
84
  export interface SubscriptionRequest {
70
85
  owner: string;
71
86
  repo: string;
@@ -278,6 +293,8 @@ export interface GitHubAppClient {
278
293
  disconnect(signal?: AbortSignal): Promise<{
279
294
  enabled: boolean;
280
295
  }>;
296
+ /** The repositories a Cloud machine may clone for this account. */
297
+ repositories(signal?: AbortSignal): Promise<GitHubRepositoriesAnswer>;
281
298
  subscribe(engine: string, pullRequests: SubscriptionRequest[], signal?: AbortSignal): Promise<SubscriptionAnswer>;
282
299
  events(engine: string, after: string | undefined, signal?: AbortSignal): Promise<EventsAnswer>;
283
300
  /**
@@ -333,6 +350,8 @@ export declare function accountApiTarget(env?: NodeJS.ProcessEnv): {
333
350
  export declare function parseNotice(value: unknown): GitHubNotice | undefined;
334
351
  /** A notice `parseNotice` read as a `request`, with every field it requires. */
335
352
  export declare const isMentionNotice: (notice: GitHubNotice) => notice is MentionNotice;
353
+ /** The most repositories one list answer is read for (the service sends at most this many). */
354
+ export declare const MAX_REPOSITORIES = 1000;
336
355
  /** The service's own limit on a bot write's body. */
337
356
  export declare const BOT_BODY_BYTES = 16384;
338
357
  /** The first field of a bot write the service would refuse (`400 bad_request`), checked as it checks them; undefined when none. */
@@ -1,6 +1,6 @@
1
1
  import { setTimeout as delay } from 'node:timers/promises';
2
2
  import { AUTH_DEPLOYMENT } from '../auth/deployment.js';
3
- import { GITHUB_OWNER, GITHUB_REPO } from '../github-names.js';
3
+ import { GITHUB_ACCOUNT, GITHUB_OWNER, GITHUB_REPO } from '../github-names.js';
4
4
  import { AuthError } from '../auth/types.js';
5
5
  /**
6
6
  * The engine's client for the account API's GitHub App routes (`design/specs/github-app.md`): the
@@ -224,6 +224,15 @@ function parseRequest(value, base) {
224
224
  commentId, commentKind: commentKind, commentUrl, ...(commentAt === undefined ? {} : { commentAt: commentAt }),
225
225
  };
226
226
  }
227
+ /** The most repositories one list answer is read for (the service sends at most this many). */
228
+ export const MAX_REPOSITORIES = 1000;
229
+ function parseRepository(value) {
230
+ // The owner is read as the service writes it (a managed user's underscore included), not as a pull request URL names one.
231
+ if (!isRecord(value) || !positive(value.id) || typeof value.owner !== 'string' || !GITHUB_ACCOUNT.test(value.owner) || typeof value.name !== 'string' || !REPO.test(value.name))
232
+ return undefined;
233
+ // Private unless the service says otherwise, so a malformed flag never shows a private repository as public.
234
+ return { id: value.id, owner: value.owner, name: value.name, private: value.private !== false, push: value.push === true };
235
+ }
227
236
  function parseStatus(value) {
228
237
  const enabled = value.enabled === true;
229
238
  const status = { enabled, allowed: enabled && value.allowed !== false, connection: null, installations: [] };
@@ -567,6 +576,17 @@ export function createGitHubAppClient(deps) {
567
576
  const answer = await call('DELETE', '/github/connection', undefined, signal, true);
568
577
  return { enabled: answer.enabled !== false };
569
578
  },
579
+ async repositories(signal) {
580
+ const answer = await call('GET', '/github/repositories', undefined, signal);
581
+ if (typeof answer.enabled !== 'boolean')
582
+ throw new GitHubAppError('invalid-answer', 'The repository list carried no enabled flag.');
583
+ if (!answer.enabled)
584
+ return { enabled: false, connected: false, repositories: [], more: false };
585
+ if (!Array.isArray(answer.repositories))
586
+ throw new GitHubAppError('invalid-answer', 'The repository list carried no repositories.');
587
+ const repositories = answer.repositories.slice(0, MAX_REPOSITORIES).map(parseRepository).filter((entry) => entry !== undefined);
588
+ return { enabled: true, connected: answer.connection === true, repositories, more: answer.more === true };
589
+ },
570
590
  async subscribe(engine, pullRequests, signal) {
571
591
  if (!isEngineId(engine))
572
592
  throw new GitHubAppError('invalid-request', 'The engine id is malformed.');
@@ -5,4 +5,11 @@
5
5
  export declare const GITHUB_OWNER_PATTERN = "[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})";
6
6
  export declare const GITHUB_REPO_PATTERN = "(?!\\.\\.?(?![A-Za-z0-9._-]))[A-Za-z0-9._-]{1,100}";
7
7
  export declare const GITHUB_OWNER: RegExp;
8
+ /**
9
+ * An account that owns a repository, as Andorra's GitHub App service names it (`OWNER` in
10
+ * `infra/andorra-auth/github_app.py`): an Enterprise Managed User's `name_shortcode`, with its underscore and its longer
11
+ * length, included. Used where the service's own list is read and acted on (Cloud's repositories), not for a pull
12
+ * request URL. Letters, digits, `_` and `-` only, so it is always one path segment.
13
+ */
14
+ export declare const GITHUB_ACCOUNT: RegExp;
8
15
  export declare const GITHUB_REPO: RegExp;
@@ -5,4 +5,11 @@
5
5
  export const GITHUB_OWNER_PATTERN = '[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})';
6
6
  export const GITHUB_REPO_PATTERN = '(?!\\.\\.?(?![A-Za-z0-9._-]))[A-Za-z0-9._-]{1,100}';
7
7
  export const GITHUB_OWNER = new RegExp(`^${GITHUB_OWNER_PATTERN}$`);
8
+ /**
9
+ * An account that owns a repository, as Andorra's GitHub App service names it (`OWNER` in
10
+ * `infra/andorra-auth/github_app.py`): an Enterprise Managed User's `name_shortcode`, with its underscore and its longer
11
+ * length, included. Used where the service's own list is read and acted on (Cloud's repositories), not for a pull
12
+ * request URL. Letters, digits, `_` and `-` only, so it is always one path segment.
13
+ */
14
+ export const GITHUB_ACCOUNT = /^[A-Za-z0-9](?:[A-Za-z0-9_-]{0,62})$/;
8
15
  export const GITHUB_REPO = new RegExp(`^${GITHUB_REPO_PATTERN}$`);
@@ -10,6 +10,8 @@ export interface GraphPreviewNode {
10
10
  agentRole?: 'orchestrator';
11
11
  provider?: string;
12
12
  model?: string;
13
+ /** The step's own thinking level, when it sets one: a level, or 'auto' for Jev to pick. */
14
+ reasoningEffort?: string;
13
15
  /** Omitted when it is exactly ['completed'], the usual single port, to keep large previews small. */
14
16
  outcomes?: string[];
15
17
  /** An Action's kind, which names it on its card (Run command, Run tests, Git operation). */
@@ -20,6 +20,7 @@ export function graphPreview(graph, revision, modelOf = () => undefined) {
20
20
  ...(node.agentRole === 'orchestrator' ? { agentRole: 'orchestrator' } : {}),
21
21
  ...(node.type === 'agent' && node.provider && !model ? { provider: node.provider } : {}),
22
22
  ...(model ? { model } : {}),
23
+ ...(node.type === 'agent' && node.reasoningEffort ? { reasoningEffort: node.reasoningEffort } : {}),
23
24
  ...(outcomes.length === 1 && outcomes[0] === 'completed' ? {} : { outcomes }),
24
25
  ...(node.type === 'action' && node.action?.kind ? { action: node.action.kind } : {}),
25
26
  ...(node.position && Number.isFinite(node.position.x) && Number.isFinite(node.position.y) ? { position: { x: node.position.x, y: node.position.y } } : {}),
@@ -552,7 +552,7 @@ export async function runGraph(graph, options) {
552
552
  ...options,
553
553
  ...(activation.routedModel ? { modelPinned: true } : {}),
554
554
  adapter: instrument(options.provider, { model: options.model, adapter: options.adapter }).adapter,
555
- ...(options.resolveModel ? { resolveModel: async (provider, model, signal) => instrument(provider, await options.resolveModel(provider, model, signal)) } : {}),
555
+ ...(options.resolveModel ? { resolveModel: async (provider, model, signal, reasoningEffort) => instrument(provider, await options.resolveModel(provider, model, signal, reasoningEffort)) } : {}),
556
556
  ...(options.getLiveModel ? { getLiveModel: async (id, provider, model, signal) => {
557
557
  const live = await options.getLiveModel(id, provider, model, signal);
558
558
  return live ? { ...instrument(live.provider, live), provider: live.provider } : undefined;
@@ -11,7 +11,7 @@ import { createTools } from './tools.js';
11
11
  import { AutomationStore } from './automations.js';
12
12
  import { deleteAgentDefinition, exportAgentDefinition, importAgentDefinition, listAgentDefinitions, readAgentDefinition, saveAgentDefinition, validateAgentDefinition } from './agent-definitions.js';
13
13
  import { discoverModelMetadata, resolveModelContext } from './model-metadata.js';
14
- import { MODEL_LISTING_TIMEOUT_MS, providerLabel, providerModels, recordProviderModel } from './providers.js';
14
+ import { MODEL_LISTING_TIMEOUT_MS, providerLabel, providerModels, recordProviderModel, supportsReasoningEffort } from './providers.js';
15
15
  import { PaidMembershipRequiredError, readGraphMembership } from './membership.js';
16
16
  import { getGraphMembership } from './membership.js';
17
17
  import { FREE_CUSTOM_GRAPH_LIMIT, FREE_GRAPH_NODE_LIMIT, FreeTierLimitError, notePremiumGraphAccount, readGraphQuota, saveFreeTierGraph, savePremiumGraph } from './graph-quota.js';
@@ -186,7 +186,9 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
186
186
  res.writeHead(status, { 'Content-Type': 'application/json; charset=utf-8' });
187
187
  res.end(JSON.stringify(value));
188
188
  };
189
- const providerRegistryPayload = (providers) => providers.map(provider => ({ id: provider.id, model: provider.model, models: provider.models, type: provider.type, baseUrl: provider.baseUrl, label: providerLabel(provider, providers) }));
189
+ const providerRegistryPayload = (providers) => providers.map(provider => ({ id: provider.id, model: provider.model, models: provider.models, type: provider.type, baseUrl: provider.baseUrl, label: providerLabel(provider, providers),
190
+ // The editor offers a node only the thinking levels its model has enabled on this machine.
191
+ thinksAtLevels: supportsReasoningEffort(provider.type), ...(provider.thinkingLevels ? { thinkingLevels: provider.thinkingLevels } : {}) }));
190
192
  const liveEditorState = async () => {
191
193
  const [{ pid: _pid, ...status }, config] = await Promise.all([readActivity(directory), editorConfig(directory)]);
192
194
  return {
@@ -803,7 +803,36 @@ function dismissCanvasHint() {
803
803
  try { localStorage.setItem(HINT_KEY, '1'); } catch { }
804
804
  if (!state.routePick && $('canvas-hint')) $('canvas-hint').hidden = true;
805
805
  }
806
+ const THINKING_LEVELS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
807
+ /** The thinking levels a node's model has enabled here, lowest first; empty when its provider takes no level. */
808
+ function nodeThinkingLevels(node) {
809
+ const provider = state.providers.find(p => idFor(p) === (node.provider || state.defaultProvider));
810
+ if (!provider || typeof provider === 'string' || !provider.thinksAtLevels) return [];
811
+ const entry = provider.thinkingLevels?.[node.model || provider.model];
812
+ const supported = entry?.supported || THINKING_LEVELS;
813
+ const disabled = entry?.disabled || [];
814
+ return THINKING_LEVELS.filter(level => supported.includes(level) && !disabled.includes(level));
815
+ }
816
+ function thinkingSuffix(node) {
817
+ if (node.type !== 'agent' || !node.reasoningEffort) return '';
818
+ return node.reasoningEffort === 'auto' ? 'Auto thinking' : `${node.reasoningEffort} thinking`;
819
+ }
820
+ /** The thinking level control under a node's model: the session's level, Auto, or one of the model's enabled levels. */
821
+ function thinkingLevelField(parent, node) {
822
+ const levels = nodeThinkingLevels(node);
823
+ const current = node.reasoningEffort || '';
824
+ if (!levels.length && !current) return;
825
+ const options = [{ value: '', label: 'Same as session' }, { value: 'auto', label: 'Auto (Jev)' }, ...levels.map(level => ({ value: level, label: level }))];
826
+ if (current && current !== 'auto' && !levels.includes(current)) options.push({ value: current, label: `${current} (not available here)` });
827
+ const control = choice(parent, 'Thinking level', current, options, value => { if (value) node.reasoningEffort = value; else delete node.reasoningEffort; });
828
+ explain(control, 'How hard this step\'s model thinks before it answers. Auto (Jev) picks one of the levels this model has enabled each time the step starts, from how complex and how risky the task is, and keeps it for that run of the step; it needs Jev decisions on for this step, and otherwise keeps the session\'s level. A level that is switched off for this model on the machine running the graph moves to the nearest one that is on.');
829
+ }
806
830
  function nodeModelLabel(node) {
831
+ const model = nodeModelName(node);
832
+ const thinking = thinkingSuffix(node);
833
+ return model && thinking ? `${model} · ${thinking}` : model || thinking;
834
+ }
835
+ function nodeModelName(node) {
807
836
  if (node.model) return node.model;
808
837
  const providerId = node.provider || state.defaultProvider;
809
838
  const provider = state.providers.find(p => idFor(p) === providerId);
@@ -1828,6 +1857,7 @@ function renderInspector() {
1828
1857
  explain(check(general, 'Jev decisions', node.jevEnabled === true, value => { if (value) node.jevEnabled = true; else delete node.jevEnabled; }), 'Off unless ticked. When Jev is on, it assists this agent with routing decisions. The coding model still implements the task; sign-in, quota and runtime permissions apply.');
1829
1858
  const model = panels.model;
1830
1859
  modelFields(model, node, value => {node.provider=value.provider; node.model=value.model;});
1860
+ thinkingLevelField(model, node);
1831
1861
  const conversation = choice(model, 'Conversation', node.contextPolicy?.conversation ?? 'reuse', [{value:'reuse',label:'Reuse with the same provider and model'}, {value:'isolate',label:'Start an isolated conversation'}], value => {node.contextPolicy={...node.contextPolicy,conversation:value};});
1832
1862
  explain(conversation, 'Reuse continues from the preceding Agent with this step\'s instructions and permissions. Different providers or models start fresh. Branches receive separate copies of their shared history. Provider caching and token savings depend on the model service.');
1833
1863
  const skills = choice(model, 'Skill inheritance', node.contextPolicy?.skillInheritance ?? 'inherit', [{value:'inherit',label:'Inherit active graph skills'}, {value:'none',label:'Do not inherit skills'}], value => {node.contextPolicy={...node.contextPolicy,skillInheritance:value};});
@@ -1,5 +1,9 @@
1
1
  import { type JsonSchema, type ValueExpression } from './handoffs.js';
2
+ import { type ReasoningEffort } from './providers.js';
2
3
  export type { JsonSchema, ValueExpression } from './handoffs.js';
4
+ /** A node's thinking level: one of the provider levels, or 'auto' for Jev to pick one each time the node starts. */
5
+ export type NodeReasoningEffort = ReasoningEffort | 'auto';
6
+ export declare function isNodeReasoningEffort(value: unknown): value is NodeReasoningEffort;
3
7
  export interface CapabilityPolicy {
4
8
  filesystem: 'none' | 'read' | 'read-write';
5
9
  shell: 'disabled' | 'read-only' | 'allowed';
@@ -105,6 +109,8 @@ export interface GraphNode {
105
109
  tools?: string[];
106
110
  maxIterations?: number;
107
111
  jevEnabled?: boolean;
112
+ /** The thinking level this node runs at: a fixed level, or 'auto' for Jev to pick one each time the node starts. */
113
+ reasoningEffort?: NodeReasoningEffort;
108
114
  completion?: CompletionPolicy;
109
115
  capabilities?: CapabilityPolicy;
110
116
  contextPolicy?: ContextPolicy;
@@ -6,7 +6,10 @@ import { acquireSaveLock, archiveUnpublishedSnapshot, removeLockedFolder, SaveLo
6
6
  import { validateMappingConstants, validateMappings, validateSchema, validateValue, schemaAt, nodeOutputSchema } from './handoffs.js';
7
7
  import { CANONICAL_CODING_TOOLS, canonicalToolName, canonicalizeToolList, toolNameMatches } from './tool-names.js';
8
8
  import { DEFAULT_AGENT_GRAPH } from './default-graph.js';
9
- import { findProviderById, providerModelId } from './providers.js';
9
+ import { findProviderById, providerModelId, REASONING_EFFORTS } from './providers.js';
10
+ export function isNodeReasoningEffort(value) {
11
+ return value === 'auto' || (typeof value === 'string' && REASONING_EFFORTS.includes(value));
12
+ }
10
13
  export const REVIEW_NODE_OUTCOMES = ['findings', 'clean', 'stopped'];
11
14
  export const REVIEW_NODE_ROUNDS_MAX = 10;
12
15
  export const REVIEW_NODE_INSTRUCTION_BYTES = 2_048;
@@ -625,10 +628,12 @@ function validateGraphInternal(value, options = {}) {
625
628
  const label = `node ${id}`;
626
629
  if (!validId(id) || !record(node) || node.id !== id)
627
630
  fail(`${label} must have a matching safe id`);
628
- if (Object.keys(node).some(k => !['id', 'name', 'type', 'position', 'agentRole', 'maxSubagents', 'executor', 'instruction', 'systemPrompt', 'prompt', 'provider', 'model', 'tools', 'maxIterations', 'completion', 'capabilities', 'contextPolicy', 'inputs', 'inputSchema', 'outputSchema', 'limits', 'retry', 'subagents', 'join', 'condition', 'loop', 'action', 'modifiers', 'jevEnabled', 'review'].includes(k)))
631
+ if (Object.keys(node).some(k => !['id', 'name', 'type', 'position', 'agentRole', 'maxSubagents', 'executor', 'instruction', 'systemPrompt', 'prompt', 'provider', 'model', 'tools', 'maxIterations', 'completion', 'capabilities', 'contextPolicy', 'inputs', 'inputSchema', 'outputSchema', 'limits', 'retry', 'subagents', 'join', 'condition', 'loop', 'action', 'modifiers', 'jevEnabled', 'reasoningEffort', 'review'].includes(k)))
629
632
  fail(`${label}: unsupported node setting`);
630
633
  if (node.jevEnabled !== undefined && (node.type !== 'agent' || typeof node.jevEnabled !== 'boolean'))
631
634
  fail(`${label}: jevEnabled must be a boolean on an Agent node`);
635
+ if (node.reasoningEffort !== undefined && (node.type !== 'agent' || !isNodeReasoningEffort(node.reasoningEffort)))
636
+ fail(`${label}: reasoningEffort must be auto, ${REASONING_EFFORTS.join(', ')} on an Agent node`);
632
637
  if (!['agent', 'end', 'join', 'parallel', 'condition', 'loop', 'action', 'approval', 'review'].includes(node.type))
633
638
  fail(`${label}: unsupported node type`);
634
639
  if (node.review !== undefined && node.type !== 'review')