@andorra-labs/code 0.1.4 → 0.1.6
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/account-presentation.js +3 -3
- package/dist/src/agent-execution.d.ts +2 -0
- package/dist/src/agent-execution.js +126 -20
- package/dist/src/agent-mcp.d.ts +18 -1
- package/dist/src/agent-mcp.js +103 -8
- package/dist/src/app-server/protocol.d.ts +33 -3
- package/dist/src/app-server/protocol.js +14 -1
- package/dist/src/app-server/workspace.d.ts +1 -0
- package/dist/src/app-server/workspace.js +7 -1
- package/dist/src/app-server.d.ts +115 -41
- package/dist/src/app-server.js +1229 -219
- package/dist/src/automation-runner.d.ts +9 -0
- package/dist/src/automation-runner.js +22 -1
- package/dist/src/automation-tool.js +8 -1
- package/dist/src/automations.js +1 -1
- package/dist/src/browser-captcha-tool.d.ts +54 -0
- package/dist/src/browser-captcha-tool.js +374 -0
- package/dist/src/browser-panel-tool.d.ts +7 -0
- package/dist/src/browser-panel-tool.js +74 -3
- package/dist/src/browser-runner.js +19 -4
- package/dist/src/browser-server.js +21 -1
- package/dist/src/browser-session.d.ts +16 -0
- package/dist/src/browser-session.js +35 -0
- package/dist/src/browser-ui/app.js +193 -3
- package/dist/src/browser-ui/style.css +15 -1
- package/dist/src/browser-view.d.ts +72 -4
- package/dist/src/browser-view.js +229 -17
- package/dist/src/capabilities.js +13 -2
- package/dist/src/capsolver.d.ts +60 -0
- package/dist/src/capsolver.js +101 -0
- package/dist/src/claude-provider.d.ts +6 -0
- package/dist/src/claude-provider.js +34 -3
- package/dist/src/cli-executable.d.ts +33 -0
- package/dist/src/cli-executable.js +64 -0
- package/dist/src/cli-process.d.ts +47 -0
- package/dist/src/cli-process.js +113 -0
- package/dist/src/cli-sign-in.d.ts +68 -0
- package/dist/src/cli-sign-in.js +224 -0
- package/dist/src/cli.js +54 -23
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +1 -1
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +5 -5
- package/dist/src/coding-tools.js +44 -5
- package/dist/src/command-output-tap.d.ts +16 -0
- package/dist/src/command-output-tap.js +45 -0
- package/dist/src/command-screens.js +3 -3
- package/dist/src/commands.d.ts +10 -1
- package/dist/src/commands.js +7 -7
- package/dist/src/completion.d.ts +23 -5
- package/dist/src/completion.js +334 -17
- package/dist/src/config.d.ts +13 -0
- package/dist/src/config.js +28 -2
- package/dist/src/deadline.js +6 -0
- package/dist/src/extensions.d.ts +1 -0
- package/dist/src/extensions.js +16 -3
- package/dist/src/graph-provider-portability.js +2 -2
- package/dist/src/graph-quota.d.ts +1 -1
- package/dist/src/graph-quota.js +1 -1
- package/dist/src/graph-runner.js +35 -21
- package/dist/src/graph-selection.d.ts +6 -0
- package/dist/src/graph-selection.js +10 -0
- package/dist/src/graph-server.d.ts +7 -0
- package/dist/src/graph-server.js +61 -3
- package/dist/src/graph-sync.d.ts +50 -0
- package/dist/src/graph-sync.js +383 -12
- package/dist/src/graph-ui/app.js +61 -8
- package/dist/src/graph-ui/icons.js +1 -0
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graph-ui/skill-picker.js +242 -0
- package/dist/src/graph-ui/style.css +19 -0
- package/dist/src/graphs.d.ts +46 -4
- package/dist/src/graphs.js +152 -27
- package/dist/src/grok-provider.d.ts +50 -0
- package/dist/src/grok-provider.js +186 -0
- package/dist/src/handoffs.d.ts +13 -0
- package/dist/src/handoffs.js +31 -1
- package/dist/src/managed-sign-in.d.ts +38 -0
- package/dist/src/managed-sign-in.js +169 -0
- package/dist/src/markdown.d.ts +5 -0
- package/dist/src/markdown.js +5 -2
- package/dist/src/mcp.js +11 -0
- package/dist/src/membership.d.ts +8 -1
- package/dist/src/membership.js +15 -5
- package/dist/src/model-metadata.js +14 -2
- package/dist/src/model-override.d.ts +10 -0
- package/dist/src/model-override.js +20 -0
- package/dist/src/opencode-cli-provider.d.ts +122 -0
- package/dist/src/opencode-cli-provider.js +415 -0
- package/dist/src/opencode-provider.js +23 -8
- package/dist/src/palette.d.ts +2 -0
- package/dist/src/palette.js +2 -0
- package/dist/src/permissions.d.ts +19 -1
- package/dist/src/permissions.js +30 -1
- package/dist/src/powershell-pool.d.ts +2 -2
- package/dist/src/powershell-pool.js +18 -5
- package/dist/src/provider-connection.js +36 -0
- package/dist/src/provider-engine.d.ts +2 -1
- package/dist/src/provider-engine.js +64 -13
- package/dist/src/provider-import.js +6 -1
- package/dist/src/provider-settings.js +22 -3
- package/dist/src/providers.d.ts +12 -1
- package/dist/src/providers.js +27 -8
- package/dist/src/pull-requests.d.ts +111 -17
- package/dist/src/pull-requests.js +308 -76
- package/dist/src/qa/qa-authorize.js +9 -1
- package/dist/src/react-runtime.js +76 -5
- package/dist/src/remote/engine-pool.js +1 -1
- package/dist/src/run-progress.js +6 -1
- package/dist/src/run-records.d.ts +133 -27
- package/dist/src/run-records.js +320 -40
- package/dist/src/runtime.d.ts +38 -1
- package/dist/src/runtime.js +27 -4
- package/dist/src/save-lock.d.ts +11 -0
- package/dist/src/save-lock.js +29 -2
- package/dist/src/sessions.js +4 -1
- package/dist/src/shell.js +4 -1
- package/dist/src/side-panel.d.ts +1 -1
- package/dist/src/side-panel.js +1 -1
- package/dist/src/skill-commands.d.ts +2 -0
- package/dist/src/skill-commands.js +2 -0
- package/dist/src/skills/bundled/create-agent/SKILL.md +81 -0
- package/dist/src/skills/bundled/create-skill/SKILL.md +81 -0
- package/dist/src/skills/bundled/doctor/SKILL.md +43 -0
- package/dist/src/skills/bundled/graph-manager/SKILL.md +97 -0
- package/dist/src/skills/bundled/graph-manager/errors.md +38 -0
- package/dist/src/skills/bundled/graph-manager/patterns.md +78 -0
- package/dist/src/skills/bundled/manage-mcp/SKILL.md +75 -0
- package/dist/src/skills/bundled/manage-mcp/probe.md +165 -0
- package/dist/src/skills/bundled/manage-skills/SKILL.md +67 -0
- package/dist/src/skills/bundled/provenance.json +50 -0
- package/dist/src/skills/bundled/write-instructions/SKILL.md +42 -0
- package/dist/src/skills/invocable-skills.d.ts +41 -0
- package/dist/src/skills/invocable-skills.js +49 -0
- package/dist/src/skills/prompt-skills.d.ts +1 -0
- package/dist/src/skills/prompt-skills.js +33 -0
- package/dist/src/skills/runtime-skills.d.ts +4 -0
- package/dist/src/skills/runtime-skills.js +21 -0
- package/dist/src/structured-step.d.ts +55 -0
- package/dist/src/structured-step.js +85 -0
- package/dist/src/subagent-run.d.ts +1 -1
- package/dist/src/subagent-run.js +29 -33
- package/dist/src/telemetry/schema.d.ts +2 -2
- package/dist/src/telemetry/schema.js +3 -2
- package/dist/src/terminal-ui.d.ts +29 -0
- package/dist/src/terminal-ui.js +112 -28
- package/dist/src/timers.d.ts +21 -2
- package/dist/src/timers.js +12 -4
- package/dist/src/tool-names.d.ts +18 -0
- package/dist/src/tool-names.js +26 -0
- package/dist/src/tools.js +45 -11
- package/dist/src/trajectory.js +32 -12
- package/dist/src/types.d.ts +23 -0
- package/dist/src/update.d.ts +26 -16
- package/dist/src/update.js +232 -275
- package/docs/agents/install-for-agents.md +15 -24
- package/docs/agents/mcp-server.md +13 -1
- package/docs/agents/subagent-mode.md +7 -4
- package/docs/concepts/security.md +2 -0
- package/docs/getting-started/README.md +14 -6
- package/docs/getting-started/configure-providers.md +29 -2
- package/docs/guides/README.md +1 -1
- package/docs/guides/browser.md +12 -0
- package/docs/guides/desktop-app.md +45 -9
- package/docs/guides/graph-builder.md +8 -0
- package/docs/guides/update.md +37 -16
- package/docs/reference/cli.md +1 -1
- package/docs/reference/config.md +2 -2
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +125 -0
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +7 -0
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +206 -0
- package/package.json +1 -1
- package/tests/permissions-test-plan.md +2 -1
package/dist/src/timers.d.ts
CHANGED
|
@@ -59,6 +59,11 @@ export interface WakeCarry {
|
|
|
59
59
|
input?: Record<string, unknown>;
|
|
60
60
|
state?: Record<string, unknown>;
|
|
61
61
|
}
|
|
62
|
+
/** Which attempt, and which node of its graph, armed a wake. */
|
|
63
|
+
export interface WakeOrigin {
|
|
64
|
+
runId: string;
|
|
65
|
+
nodeId: string;
|
|
66
|
+
}
|
|
62
67
|
export interface ArmedTimer {
|
|
63
68
|
id: string;
|
|
64
69
|
/** The prompt delivered when the timer fires, exactly as the agent submitted it. */
|
|
@@ -76,6 +81,16 @@ export interface ArmedTimer {
|
|
|
76
81
|
owner?: string;
|
|
77
82
|
/** What the run that armed this wake was started with, so its delivery can start the same kind of run. */
|
|
78
83
|
carry?: WakeCarry;
|
|
84
|
+
/**
|
|
85
|
+
* The attempt and graph node that armed this wake, when a graph node armed it.
|
|
86
|
+
*
|
|
87
|
+
* A wake is the arming node's own reminder about the work it was doing, so it is delivered back to that
|
|
88
|
+
* work: into the node while its run is still going, or as a continuation of the attempt from that node's
|
|
89
|
+
* checkpoint once the attempt stopped. It is never a new task that enters the graph at its entry node.
|
|
90
|
+
* A wake without it - armed by a surface that runs no graph node, or held from before the field existed -
|
|
91
|
+
* is delivered the way such wakes always were.
|
|
92
|
+
*/
|
|
93
|
+
origin?: WakeOrigin;
|
|
79
94
|
/**
|
|
80
95
|
* Earliest epoch milliseconds at which a drain may take this wake, set when a delivery hands it back.
|
|
81
96
|
*
|
|
@@ -118,11 +133,15 @@ export declare class TimerRegistry {
|
|
|
118
133
|
* wait it is still waiting on — and, for an engine, that it still owns the wake the run has not yet carried.
|
|
119
134
|
*/
|
|
120
135
|
list(owner?: string): ArmedTimer[];
|
|
136
|
+
/** One armed wake by id, whether or not a delivery holds it. */
|
|
137
|
+
get(id: string): ArmedTimer | undefined;
|
|
121
138
|
/** A wake in hand: taken for delivery, and still owed until {@link settle} or {@link restore} says otherwise. */
|
|
122
139
|
private held;
|
|
140
|
+
/** Whether a delivery has taken this wake and not yet said what became of it. */
|
|
141
|
+
isHeld(id: string): boolean;
|
|
123
142
|
/** The earliest epoch milliseconds at which a drain may take this wake again. */
|
|
124
143
|
private nextTakeAt;
|
|
125
|
-
arm(seconds: number, prompt: string, owner?: string, carry?: WakeCarry): ArmedTimer;
|
|
144
|
+
arm(seconds: number, prompt: string, owner?: string, carry?: WakeCarry, origin?: WakeOrigin): ArmedTimer;
|
|
126
145
|
/**
|
|
127
146
|
* Arm (or re-arm) the one wake-up for a timer.
|
|
128
147
|
*
|
|
@@ -147,7 +166,7 @@ export declare class TimerRegistry {
|
|
|
147
166
|
* answers for a session the moment its deadline passes and the run only later, this is the difference between
|
|
148
167
|
* a reload finding the wake it must keep routing to that engine, and a reload concluding nothing is owed.
|
|
149
168
|
*/
|
|
150
|
-
takeDueOne(now?: number, owner?: string): ArmedTimer | undefined;
|
|
169
|
+
takeDueOne(now?: number, owner?: string, accept?: (timer: ArmedTimer) => boolean): ArmedTimer | undefined;
|
|
151
170
|
/**
|
|
152
171
|
* Say a taken wake has been delivered or spent: it is no longer owed, and no longer waits.
|
|
153
172
|
*
|
package/dist/src/timers.js
CHANGED
|
@@ -73,15 +73,23 @@ export class TimerRegistry {
|
|
|
73
73
|
return (owner === undefined ? waiting : waiting.filter(timer => timer.owner === owner))
|
|
74
74
|
.sort((left, right) => left.fireAt - right.fireAt);
|
|
75
75
|
}
|
|
76
|
+
/** One armed wake by id, whether or not a delivery holds it. */
|
|
77
|
+
get(id) {
|
|
78
|
+
return this.armed.get(id)?.timer;
|
|
79
|
+
}
|
|
76
80
|
/** A wake in hand: taken for delivery, and still owed until {@link settle} or {@link restore} says otherwise. */
|
|
77
81
|
held(timer) {
|
|
78
82
|
return this.armed.get(timer.id)?.held === true;
|
|
79
83
|
}
|
|
84
|
+
/** Whether a delivery has taken this wake and not yet said what became of it. */
|
|
85
|
+
isHeld(id) {
|
|
86
|
+
return this.armed.get(id)?.held === true;
|
|
87
|
+
}
|
|
80
88
|
/** The earliest epoch milliseconds at which a drain may take this wake again. */
|
|
81
89
|
nextTakeAt(timer) {
|
|
82
90
|
return Math.max(timer.fireAt, timer.notBefore ?? 0);
|
|
83
91
|
}
|
|
84
|
-
arm(seconds, prompt, owner, carry) {
|
|
92
|
+
arm(seconds, prompt, owner, carry, origin) {
|
|
85
93
|
if (typeof seconds !== 'number' || !Number.isSafeInteger(seconds) || seconds < MIN_TIMER_SECONDS || seconds > MAX_TIMER_SECONDS) {
|
|
86
94
|
throw new Error(`seconds must be an integer from ${MIN_TIMER_SECONDS} to ${MAX_TIMER_SECONDS}`);
|
|
87
95
|
}
|
|
@@ -94,7 +102,7 @@ export class TimerRegistry {
|
|
|
94
102
|
// Cloned, because the run keeps working with the objects it handed here: a wake must not see a scope that
|
|
95
103
|
// its arming run mutated after the prompt was armed.
|
|
96
104
|
const stored = carry === undefined || Object.keys(carry).length === 0 ? undefined : structuredClone(carry);
|
|
97
|
-
const timer = { id: randomUUID(), prompt: prompt.trim(), seconds, fireAt: Date.now() + seconds * 1_000, ...(owner === undefined ? {} : { owner }), ...(stored === undefined ? {} : { carry: stored }) };
|
|
105
|
+
const timer = { id: randomUUID(), prompt: prompt.trim(), seconds, fireAt: Date.now() + seconds * 1_000, ...(owner === undefined ? {} : { owner }), ...(stored === undefined ? {} : { carry: stored }), ...(origin === undefined ? {} : { origin: { runId: origin.runId, nodeId: origin.nodeId } }) };
|
|
98
106
|
const entry = { timer };
|
|
99
107
|
this.schedule(timer, entry, seconds * 1_000);
|
|
100
108
|
this.armed.set(timer.id, entry);
|
|
@@ -135,8 +143,8 @@ export class TimerRegistry {
|
|
|
135
143
|
* answers for a session the moment its deadline passes and the run only later, this is the difference between
|
|
136
144
|
* a reload finding the wake it must keep routing to that engine, and a reload concluding nothing is owed.
|
|
137
145
|
*/
|
|
138
|
-
takeDueOne(now = Date.now(), owner) {
|
|
139
|
-
const next = this.list(owner).find(timer => this.nextTakeAt(timer) <= now && !this.held(timer));
|
|
146
|
+
takeDueOne(now = Date.now(), owner, accept) {
|
|
147
|
+
const next = this.list(owner).find(timer => this.nextTakeAt(timer) <= now && !this.held(timer) && (accept === undefined || accept(timer)));
|
|
140
148
|
if (next === undefined)
|
|
141
149
|
return undefined;
|
|
142
150
|
const entry = this.armed.get(next.id);
|
package/dist/src/tool-names.d.ts
CHANGED
|
@@ -11,6 +11,24 @@ export declare function canonicalCodingToolName(name: string): CanonicalCodingTo
|
|
|
11
11
|
export declare function canonicalToolName(name: string): string;
|
|
12
12
|
export declare function toolNameMatches(configured: string, actual: string): boolean;
|
|
13
13
|
export declare function canonicalizeToolList(names: readonly string[] | undefined): string[] | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Rewrites the tool names one provider request sees and restores Andorra's names on everything
|
|
16
|
+
* that comes back. Canonical Andorra tool names use dots (`qa.fast`, `browser.panel`), while
|
|
17
|
+
* strict providers validate `function.name` against `^[a-zA-Z0-9_-]+$` and reject the whole
|
|
18
|
+
* request with an HTTP 400. The provider-side names are a pure transport encoding: journals,
|
|
19
|
+
* the executor and the desktop keep the canonical spellings.
|
|
20
|
+
*/
|
|
21
|
+
export interface ProviderToolNameCodec {
|
|
22
|
+
encode(name: string): string;
|
|
23
|
+
decode(name: string): string;
|
|
24
|
+
}
|
|
25
|
+
/** Encode a request's tool list for the provider and pair it with the matching name codec. */
|
|
26
|
+
export declare function encodeProviderToolNames<T extends {
|
|
27
|
+
name: string;
|
|
28
|
+
}>(tools: readonly T[]): {
|
|
29
|
+
tools: T[];
|
|
30
|
+
codec: ProviderToolNameCodec;
|
|
31
|
+
};
|
|
14
32
|
export declare const LEGACY_CODING_TOOL_NAMES: readonly string[];
|
|
15
33
|
/** Translate historical Pi/Andorra tool arguments into the canonical coding-tool contract. */
|
|
16
34
|
export declare function adaptLegacyCodingToolArguments(name: string, args: Record<string, unknown>): Record<string, unknown>;
|
package/dist/src/tool-names.js
CHANGED
|
@@ -32,6 +32,32 @@ export function canonicalizeToolList(names) {
|
|
|
32
32
|
return undefined;
|
|
33
33
|
return [...new Set(names.map(canonicalToolName))];
|
|
34
34
|
}
|
|
35
|
+
/** Characters provider tool-name validators (OpenAI-compatible endpoints, Messages API) reject. */
|
|
36
|
+
const UNSAFE_TOOL_NAME_CHARS = /[^a-zA-Z0-9_-]/g;
|
|
37
|
+
/** Encode a request's tool list for the provider and pair it with the matching name codec. */
|
|
38
|
+
export function encodeProviderToolNames(tools) {
|
|
39
|
+
const byEncoded = new Map();
|
|
40
|
+
const byOriginal = new Map();
|
|
41
|
+
const sanitized = (name) => name.replace(UNSAFE_TOOL_NAME_CHARS, '_');
|
|
42
|
+
const list = tools.map(tool => {
|
|
43
|
+
const base = sanitized(tool.name);
|
|
44
|
+
let encoded = base;
|
|
45
|
+
for (let n = 2; byEncoded.has(encoded); n++)
|
|
46
|
+
encoded = `${base}_${n}`;
|
|
47
|
+
byEncoded.set(encoded, tool.name);
|
|
48
|
+
byOriginal.set(tool.name, encoded);
|
|
49
|
+
return { ...tool, name: encoded };
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
tools: list,
|
|
53
|
+
codec: {
|
|
54
|
+
// History can hold calls for tools this request no longer advertises; those still must
|
|
55
|
+
// not carry rejected characters, even though their response aliases cannot be decoded.
|
|
56
|
+
encode: name => byOriginal.get(name) ?? sanitized(name),
|
|
57
|
+
decode: name => byEncoded.get(name) ?? name,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
35
61
|
export const LEGACY_CODING_TOOL_NAMES = Object.freeze(Object.keys(ALIASES).filter(name => !CANONICAL_CODING_TOOLS.includes(name)));
|
|
36
62
|
function escapeRegexLiteral(value) {
|
|
37
63
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
package/dist/src/tools.js
CHANGED
|
@@ -2,10 +2,11 @@ import { open, opendir, realpath, stat, lstat, mkdir, rename, unlink } from 'nod
|
|
|
2
2
|
import { constants } from 'node:fs';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import { permissionMode, protectedPermissionRoots, assertLocalFilePath, inspectLocalFileResolution as inspectFileResolution, canonicalProtectedRoots as fileProtectedRoots } from './permissions.js';
|
|
5
|
+
import { permissionMode, protectedPermissionRoots, assertLocalFilePath, inspectLocalFileResolution as inspectFileResolution, canonicalProtectedRoots as fileProtectedRoots, PLAN_MODE_MUTATION_ERROR } from './permissions.js';
|
|
6
6
|
import { createCodingTools } from './coding-tools.js';
|
|
7
7
|
import { createQaTools } from './qa/index.js';
|
|
8
8
|
import { createBrowserSessionTool } from './browser-session.js';
|
|
9
|
+
import { createSolveCaptchaTool } from './browser-captcha-tool.js';
|
|
9
10
|
import { createAutomationTool } from './automation-tool.js';
|
|
10
11
|
import { andorraCreateWriteTool } from '../vendor/engine/runtime/coding-agent/core/tools/write.js';
|
|
11
12
|
import { andorraWithFileMutationQueue } from '../vendor/engine/runtime/coding-agent/core/tools/file-mutation-queue.js';
|
|
@@ -145,12 +146,16 @@ async function read(context, name) {
|
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
function assertMutationPermission(context) {
|
|
148
|
-
if (!context.pinFilePaths && !context.fileMutationApproval?.explicit && permissionMode(context) === 'read-only')
|
|
149
|
+
if (!context.pinFilePaths && !context.fileMutationApproval?.explicit && (permissionMode(context) === 'read-only' || permissionMode(context) === 'plan'))
|
|
149
150
|
throw new Error('Permission denied: file mutation grant was revoked');
|
|
150
151
|
}
|
|
151
152
|
async function mutationPermission(context, name) {
|
|
152
153
|
if (context.pinFilePaths || context.fileMutationApproval?.explicit)
|
|
153
154
|
return;
|
|
155
|
+
// Plan mode refuses mutations outright: an approval prompt would ask the user to pre-approve an
|
|
156
|
+
// edit no plan has been shown for, which is exactly what the mode exists to prevent.
|
|
157
|
+
if (permissionMode(context) === 'plan')
|
|
158
|
+
throw new Error(PLAN_MODE_MUTATION_ERROR);
|
|
154
159
|
if (permissionMode(context) === 'read-only')
|
|
155
160
|
await authorize('Write', { path: name, warning: 'Read Only requires approval for this file mutation.' }, context);
|
|
156
161
|
}
|
|
@@ -215,20 +220,34 @@ async function atomicWrite(context, name, content, expectedContent) {
|
|
|
215
220
|
}
|
|
216
221
|
export async function authorize(name, args, context) {
|
|
217
222
|
context.signal.throwIfAborted();
|
|
223
|
+
const fileMutationName = ['write_file', 'edit_file', 'Write', 'Edit', 'write', 'edit'].includes(name);
|
|
224
|
+
// File writes, unsandboxed QA and MCP execution cannot use an ordinary tool approval
|
|
225
|
+
// in place of presenting a plan. Recheck after every await: a pending approval can
|
|
226
|
+
// be settled by a live permission switch into Plan mode.
|
|
227
|
+
// Solving a captcha spends CapSolver credit and writes into a page, so it waits for the plan too.
|
|
228
|
+
const planRestricted = fileMutationName || name.startsWith('qa.') || name === 'browser.solve_captcha' || (name.startsWith('mcp_') && name !== 'mcp_connect');
|
|
229
|
+
const assertPlanAllowed = () => {
|
|
230
|
+
if (planRestricted && permissionMode(context) === 'plan')
|
|
231
|
+
throw new Error(PLAN_MODE_MUTATION_ERROR);
|
|
232
|
+
};
|
|
233
|
+
assertPlanAllowed();
|
|
218
234
|
if (context.pinFilePaths)
|
|
219
235
|
return;
|
|
220
|
-
const mutation =
|
|
236
|
+
const mutation = fileMutationName && !args.resolvedPath;
|
|
221
237
|
const automatic = () => mutation && ['ask-for-approval', 'approve-for-me'].includes(permissionMode(context) ?? '');
|
|
222
238
|
const liveMode = () => automatic() ? 'workspace-policy' : permissionMode(context) === 'full-access' ? 'yolo' : context.approvalMode ?? 'interactive';
|
|
223
239
|
while (true) {
|
|
224
240
|
context.signal.throwIfAborted();
|
|
241
|
+
assertPlanAllowed();
|
|
225
242
|
await context.onApprovalEvent?.('node.tool.approval.requested', { name, arguments: args, mode: liveMode() });
|
|
226
243
|
// Both audit hooks may yield while the user changes live permissions.
|
|
244
|
+
assertPlanAllowed();
|
|
227
245
|
let mode = liveMode();
|
|
228
246
|
let answer = false;
|
|
229
247
|
while (mode === 'interactive') {
|
|
230
248
|
answer = await context.approve(name, args, context.userSignal ?? context.signal);
|
|
231
249
|
context.signal.throwIfAborted();
|
|
250
|
+
assertPlanAllowed();
|
|
232
251
|
if (answer !== 'policy-changed')
|
|
233
252
|
break;
|
|
234
253
|
mode = liveMode();
|
|
@@ -240,9 +259,11 @@ export async function authorize(name, args, context) {
|
|
|
240
259
|
if (!approved)
|
|
241
260
|
throw new Error('Permission denied');
|
|
242
261
|
context.signal.throwIfAborted();
|
|
262
|
+
assertPlanAllowed();
|
|
243
263
|
// Only explicit user approval survives a mode change. Reacquire automatic
|
|
244
264
|
// grants through the live policy before returning control to the operation.
|
|
245
265
|
if (!policyGrant || liveMode() === mode) {
|
|
266
|
+
assertPlanAllowed();
|
|
246
267
|
if (mutation && context.fileMutationApproval)
|
|
247
268
|
context.fileMutationApproval.explicit = !policyGrant;
|
|
248
269
|
return;
|
|
@@ -456,12 +477,22 @@ function qaPermissionTool(tool) {
|
|
|
456
477
|
return { ...tool, execute: async (args, context) => {
|
|
457
478
|
const selected = permissionMode(context);
|
|
458
479
|
const readOnlyTerminal = tool.name === 'qa.terminal' && ['read', 'status', 'wait', 'resize'].includes(String(args.action));
|
|
480
|
+
// Host execution under plan mode is a change no plan has been approved for: an approved QA
|
|
481
|
+
// grant spawns an unsandboxed process whose commands can write the workspace, so the call is
|
|
482
|
+
// refused with the plan guidance rather than prompted. Reading a terminal that already exists
|
|
483
|
+
// changes nothing and stays available.
|
|
484
|
+
const assertPlanAllowed = () => {
|
|
485
|
+
if (!readOnlyTerminal && permissionMode(context) === 'plan')
|
|
486
|
+
throw new Error(PLAN_MODE_MUTATION_ERROR);
|
|
487
|
+
};
|
|
488
|
+
assertPlanAllowed();
|
|
459
489
|
if (selected && !readOnlyTerminal) {
|
|
460
490
|
let explicitlyApproved = false;
|
|
461
491
|
do {
|
|
462
492
|
await authorize(tool.name, { ...args, warning: 'UNSANDBOXED QA: this tool call can access the entire host filesystem and network.' }, {
|
|
463
493
|
...context, approve: async (...approval) => {
|
|
464
494
|
const allowed = await context.approve(...approval);
|
|
495
|
+
assertPlanAllowed();
|
|
465
496
|
if (allowed === true)
|
|
466
497
|
explicitlyApproved = true;
|
|
467
498
|
return allowed;
|
|
@@ -469,10 +500,13 @@ function qaPermissionTool(tool) {
|
|
|
469
500
|
});
|
|
470
501
|
// Decision-event delivery can also yield to a live-mode downgrade.
|
|
471
502
|
// An automatic Full Access decision never becomes a scoped user grant.
|
|
503
|
+
assertPlanAllowed();
|
|
472
504
|
} while (!explicitlyApproved && permissionMode(context) !== 'full-access');
|
|
473
505
|
if (explicitlyApproved)
|
|
474
506
|
context = { ...context, qaHostApproved: true };
|
|
475
507
|
}
|
|
508
|
+
// Never dispatch an unsandboxed QA operation on a grant from before Plan was selected.
|
|
509
|
+
assertPlanAllowed();
|
|
476
510
|
return tool.execute(args, context);
|
|
477
511
|
} };
|
|
478
512
|
}
|
|
@@ -602,7 +636,7 @@ export function createTools() {
|
|
|
602
636
|
return `Updated ${name}`;
|
|
603
637
|
});
|
|
604
638
|
}),
|
|
605
|
-
tool('set_timer', 'Arm a self-wake timer. After the delay your prompt is delivered back to you as a
|
|
639
|
+
tool('set_timer', 'Arm a self-wake timer. Only call this when the user explicitly asked you to set a timer, a reminder, or to check back after a delay. Never arm one on your own initiative, for example to wait on a test run, a build, or other background work you started: wait on that work with the tool that runs it, or report its state and stop. After the delay your prompt is delivered back to you as a reminder (marked [Timer]) for the work you are doing now. While you are still working it arrives at your next turn boundary. If your run stops before you finish (out of budget, failed, or interrupted), the reminder continues that run from where you left off. It is dropped, never started as a new task, once you have finished your work, the run has finished, the user stopped it, or a newer turn replaced it. In the terminal CLI, a session that is idle takes it as its next prompt. Timers are held in the running session only: they fire at most once, they are lost when the process exits, and they are unavailable where no session can deliver a follow-up prompt.', {
|
|
606
640
|
prompt: property('The message delivered to you when the timer fires'),
|
|
607
641
|
seconds: { type: 'integer', minimum: 1, maximum: 86_400, description: 'Delay before delivery, in seconds (1 to 86400)' },
|
|
608
642
|
}, ['prompt', 'seconds'], async (args, context) => {
|
|
@@ -610,18 +644,17 @@ export function createTools() {
|
|
|
610
644
|
throw new Error('set_timer is unavailable in this session; no session surface can deliver a follow-up prompt here.');
|
|
611
645
|
if (typeof args.seconds !== 'number' || !Number.isSafeInteger(args.seconds))
|
|
612
646
|
throw new Error('seconds must be an integer');
|
|
613
|
-
const timer = context.timers.arm(args.seconds, string(args, 'prompt'), context.sessionScope, context.wakeCarry);
|
|
647
|
+
const timer = context.timers.arm(args.seconds, string(args, 'prompt'), context.sessionScope, context.wakeCarry, context.wakeOrigin);
|
|
614
648
|
// Recorded for the run that made it: a wake is this turn's promise, and a turn that fails to be saved has
|
|
615
649
|
// only its own to lose.
|
|
616
650
|
context.wakesArmed?.push(timer.id);
|
|
617
651
|
return `Timer ${timer.id.slice(0, 8)} armed: your prompt will be delivered in ${args.seconds} second${args.seconds === 1 ? '' : 's'}, at ${new Date(timer.fireAt).toISOString()}. It fires once.`;
|
|
618
652
|
}),
|
|
619
|
-
{ ...tool('pull_request', 'Show or change the pull request this session tracks in the desktop Plan card. A PR you open with `gh pr create` is attached automatically; use attach for one opened another way. update changes its settings when the user asks: mergeWhenReady enables GitHub auto-merge (gh pr merge --auto), draft converts to a draft or marks it ready, autoFix wakes you with a prompt when new review comments arrive
|
|
653
|
+
{ ...tool('pull_request', 'Show or change the pull request this session tracks in the desktop Plan card. A PR you open with `gh pr create` is attached automatically; use attach for one opened another way. update changes its settings when the user asks: mergeWhenReady enables GitHub auto-merge (gh pr merge --auto), draft converts to a draft or marks it ready, autoFix wakes you with a prompt when new review comments arrive and switches itself off once the PR is merged or closed. dismiss removes it from the card. Only change a setting the user asked you to change.', {
|
|
620
654
|
action: { type: 'string', enum: ['status', 'attach', 'update', 'dismiss'], description: 'status shows the tracked PR; attach starts tracking url; update changes settings; dismiss stops tracking' },
|
|
621
655
|
url: property('The GitHub pull request URL (attach only)'),
|
|
622
|
-
autoFix: { type: 'boolean', description: 'Wake this session when new review comments arrive' },
|
|
656
|
+
autoFix: { type: 'boolean', description: 'Wake this session when new review comments arrive, until the PR is merged or closed' },
|
|
623
657
|
mergeWhenReady: { type: 'boolean', description: 'GitHub auto-merge once checks and reviews pass' },
|
|
624
|
-
autoArchive: { type: 'boolean', description: 'Archive this session when the PR is merged or closed' },
|
|
625
658
|
draft: { type: 'boolean', description: 'true converts to a draft, false marks it ready for review' },
|
|
626
659
|
}, ['action'], async (args, context) => {
|
|
627
660
|
const control = context.pullRequests;
|
|
@@ -629,10 +662,10 @@ export function createTools() {
|
|
|
629
662
|
throw new Error('pull_request is unavailable here; no session tracks a pull request for this run.');
|
|
630
663
|
const settings = pullRequestSettings(args);
|
|
631
664
|
// A setting is a change on GitHub (auto-merge, draft) or to what the engine will do unattended (Auto-fix
|
|
632
|
-
// runs
|
|
665
|
+
// runs), so it goes through the run's approval like any other host operation; a full-access
|
|
633
666
|
// run approves it by policy. Reading the PR and dismissing it change neither.
|
|
634
667
|
const approve = () => approveOperation(context, 'pull_request', { ...args, warning: 'Changes the pull request on GitHub, or what Andorra does on its own when the PR changes.' });
|
|
635
|
-
const describe = (pr) => `${pr.url} (${pr.state})${pr.title ? ` "${pr.title}"` : ''}: autoFix ${pr.autoFix ? 'on' : 'off'}, mergeWhenReady ${pr.mergeWhenReady ? 'on' : 'off'}
|
|
668
|
+
const describe = (pr) => `${pr.url} (${pr.state})${pr.title ? ` "${pr.title}"` : ''}: autoFix ${pr.autoFix ? 'on' : 'off'}, mergeWhenReady ${pr.mergeWhenReady ? 'on' : 'off'}`;
|
|
636
669
|
switch (args.action) {
|
|
637
670
|
case 'status': {
|
|
638
671
|
const pr = await control.status();
|
|
@@ -646,7 +679,7 @@ export function createTools() {
|
|
|
646
679
|
}
|
|
647
680
|
case 'update': {
|
|
648
681
|
if (!Object.keys(settings).length)
|
|
649
|
-
throw new Error('update needs at least one of autoFix, mergeWhenReady,
|
|
682
|
+
throw new Error('update needs at least one of autoFix, mergeWhenReady, draft');
|
|
650
683
|
await approve();
|
|
651
684
|
return `Updated ${describe(await control.update(settings))}`;
|
|
652
685
|
}
|
|
@@ -659,5 +692,6 @@ export function createTools() {
|
|
|
659
692
|
...createCodingTools({ safePath, read, atomicWrite, authorize, files, fileLimit: FILE_LIMIT }),
|
|
660
693
|
...createQaTools().map(qaPermissionTool),
|
|
661
694
|
createBrowserSessionTool(authorize),
|
|
695
|
+
createSolveCaptchaTool(authorize),
|
|
662
696
|
].map(filePermissionTool);
|
|
663
697
|
}
|
package/dist/src/trajectory.js
CHANGED
|
@@ -6,6 +6,29 @@ import { isDeepStrictEqual } from 'node:util';
|
|
|
6
6
|
import { redactSecrets } from './memory/redaction.js';
|
|
7
7
|
import { browserEventArguments, isBrowserToolName } from './browser-session.js';
|
|
8
8
|
const credentialKey = /(?:api[_-]?key|token|secret|password|passwd|authorization|cookie|credential|private[_-]?key)/i;
|
|
9
|
+
/** `MAX_OUTPUT_TOKENS` and the like hold counts, as the `*Tokens` record keys below do. */
|
|
10
|
+
const tokenCountKey = /tokens$/i;
|
|
11
|
+
/**
|
|
12
|
+
* Values that switch a setting on or off, or mark a credential as absent, rather than hold
|
|
13
|
+
* one: Chromium reads `GOOGLE_API_KEY=no`, local model servers accept `OPENAI_API_KEY=EMPTY`.
|
|
14
|
+
* No source treats them as secrets; redacting them rewrote ordinary words in every record.
|
|
15
|
+
*/
|
|
16
|
+
const flagValues = new Set(['y', 'n', 'yes', 'no', 'true', 'false', 'on', 'off', '0', '1',
|
|
17
|
+
'none', 'null', 'nil', 'undefined', 'unset', 'empty', 'disabled', 'enabled', 'dummy', 'placeholder']);
|
|
18
|
+
/**
|
|
19
|
+
* The shortest environment or configured value treated as a secret. A credential-named value
|
|
20
|
+
* shorter than this is a flag or a placeholder; substituting it can neither hide it (the
|
|
21
|
+
* surrounding text gives a word-length value away) nor avoid matching unrelated text.
|
|
22
|
+
* Browser inputs have no floor: what a model types into a page can be a short PIN.
|
|
23
|
+
*/
|
|
24
|
+
const MIN_CONFIGURED_SECRET_LENGTH = 4;
|
|
25
|
+
/** A flag, a placeholder, or text with no letter or digit (a typed space, bare punctuation). */
|
|
26
|
+
function isFlagValue(value) {
|
|
27
|
+
return flagValues.has(value.trim().toLowerCase()) || !/[\p{L}\p{N}]/u.test(value);
|
|
28
|
+
}
|
|
29
|
+
function configuredSecrets(values) {
|
|
30
|
+
return values.filter(value => value.trim().length >= MIN_CONFIGURED_SECRET_LENGTH && !isFlagValue(value));
|
|
31
|
+
}
|
|
9
32
|
const privateReasoningKey = /^(?:reasoningContent|reasoning_content|reasoning|thinking|signature|thinkingSignature|providerContinuation)$/i;
|
|
10
33
|
const MAX_STRUCTURE_DEPTH = 64;
|
|
11
34
|
const STRUCTURE_LIMIT = '[REDACTED: structure exceeds sanitization limit]';
|
|
@@ -92,16 +115,18 @@ export async function createSessionTrajectory(options = {}) {
|
|
|
92
115
|
const modulePath = await realpath(fileURLToPath(import.meta.url));
|
|
93
116
|
const directory = options.directory ?? join(resolve(dirname(modulePath), '..', '..'), '.andorracode', 'trajectories');
|
|
94
117
|
const path = join(directory, `${sessionId}.jsonl`);
|
|
95
|
-
let secrets = [...new Set([
|
|
96
|
-
...Object.entries(process.env).filter(([key]) => credentialKey.test(key)).map(([, value]) => value ?? ''),
|
|
118
|
+
let secrets = [...new Set(configuredSecrets([
|
|
119
|
+
...Object.entries(process.env).filter(([key]) => credentialKey.test(key) && !tokenCountKey.test(key)).map(([, value]) => value ?? ''),
|
|
97
120
|
...(options.secrets ?? []),
|
|
98
|
-
]
|
|
121
|
+
]))].sort((a, b) => b.length - a.length);
|
|
99
122
|
// Browser inputs are private even when they are too short for the ambient
|
|
100
123
|
// credential heuristics. Keep them local to this conversation, never global.
|
|
124
|
+
// A flag-like answer ("no", "0") is still removed from the recorded call by
|
|
125
|
+
// the argument projection; only its echoes in other text are left alone.
|
|
101
126
|
const browserSecrets = new Set();
|
|
102
127
|
const browserInputSecrets = new Set();
|
|
103
128
|
function rememberBrowserSecret(value) {
|
|
104
|
-
if (!value || browserInputSecrets.has(value))
|
|
129
|
+
if (!value || isFlagValue(value) || browserInputSecrets.has(value))
|
|
105
130
|
return;
|
|
106
131
|
browserInputSecrets.add(value);
|
|
107
132
|
// A model can quote an input inside prose/code fences, where whole-string
|
|
@@ -278,13 +303,8 @@ export async function createSessionTrajectory(options = {}) {
|
|
|
278
303
|
return redactBrowserSecrets(serializeSanitizedJson(value, parsed, sanitize(parsed, jsonDepth + 1, structureDepth + 1)));
|
|
279
304
|
}
|
|
280
305
|
let text = redactBrowserSecrets(value);
|
|
281
|
-
for (const secret of secrets)
|
|
282
|
-
|
|
283
|
-
if (secret.length < 4)
|
|
284
|
-
text = text.replace(new RegExp(`(?<![A-Za-z0-9_])${secret.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![A-Za-z0-9_])`, 'g'), '[REDACTED]');
|
|
285
|
-
else
|
|
286
|
-
text = text.split(secret).join('[REDACTED]');
|
|
287
|
-
}
|
|
306
|
+
for (const secret of secrets)
|
|
307
|
+
text = text.split(secret).join('[REDACTED]');
|
|
288
308
|
return redactSecrets(text).text;
|
|
289
309
|
}
|
|
290
310
|
if (value && typeof value === 'object') {
|
|
@@ -387,7 +407,7 @@ export async function createSessionTrajectory(options = {}) {
|
|
|
387
407
|
return {
|
|
388
408
|
sessionId, path,
|
|
389
409
|
sanitize,
|
|
390
|
-
addSecrets(values) { secrets = [...new Set([...secrets, ...values
|
|
410
|
+
addSecrets(values) { secrets = [...new Set([...secrets, ...configuredSecrets(values)])].sort((a, b) => b.length - a.length); },
|
|
391
411
|
recordEvent: event => record('runtime.event', { event }),
|
|
392
412
|
record: (type, data) => record(type, data),
|
|
393
413
|
flush: () => pending,
|
package/dist/src/types.d.ts
CHANGED
|
@@ -48,6 +48,10 @@ export interface Usage {
|
|
|
48
48
|
cacheRead?: number;
|
|
49
49
|
cacheWrite?: number;
|
|
50
50
|
decodeMs?: number;
|
|
51
|
+
/** Input tokens on local model requests that explicitly reported cache reads (including zero). */
|
|
52
|
+
localCacheInputTokens?: number;
|
|
53
|
+
/** Cache-read tokens for those same local requests, summed across local model switches. */
|
|
54
|
+
localCacheReadTokens?: number;
|
|
51
55
|
}
|
|
52
56
|
export interface ToolSchema {
|
|
53
57
|
name: string;
|
|
@@ -172,9 +176,21 @@ export interface ToolContext {
|
|
|
172
176
|
approve: (name: string, args: Record<string, unknown>, signal: AbortSignal) => Promise<boolean | 'policy-changed'>;
|
|
173
177
|
/** Runtime-owned clarification channel; undefined answers decline the current intake. */
|
|
174
178
|
askUser?: (question: string, signal: AbortSignal, choices?: readonly string[]) => Promise<string | undefined>;
|
|
179
|
+
/**
|
|
180
|
+
* Runtime-owned plan approval: flips the run out of plan mode once the user approves, without
|
|
181
|
+
* touching the saved workspace default, and answers the mode the run continues in. Absent on
|
|
182
|
+
* surfaces with no live permission control, where presenting a plan cannot proceed.
|
|
183
|
+
*/
|
|
184
|
+
approvePlan?: () => Promise<import('./permissions.js').PermissionMode>;
|
|
175
185
|
onApprovalEvent?: (type: string, data: Record<string, unknown>) => void | Promise<void>;
|
|
176
186
|
/** Browser lifecycle observations, scoped to the current coding session, never a tool-supplied identity. */
|
|
177
187
|
onBrowserEvent?: (type: string, data: Record<string, unknown>) => void | Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Live output from a command tool that is still running: the runtime forwards it to the
|
|
190
|
+
* transcript as throttled `node.tool.output` events, so a running call's row shows what the
|
|
191
|
+
* command has printed. Display-only; the call's own observation remains the authoritative record.
|
|
192
|
+
*/
|
|
193
|
+
onCommandOutput?: (chunk: string) => void;
|
|
178
194
|
/**
|
|
179
195
|
* Called by the file permission wrapper once a mutation's path has been authorized and
|
|
180
196
|
* canonicalized, immediately before the tool executes.
|
|
@@ -194,6 +210,13 @@ export interface ToolContext {
|
|
|
194
210
|
* effort or scope. Surfaces with no run of their own leave it unset.
|
|
195
211
|
*/
|
|
196
212
|
wakeCarry?: import('./timers.js').WakeCarry;
|
|
213
|
+
/**
|
|
214
|
+
* The attempt and graph node a wake armed from this context belongs to, set by the agent node executor.
|
|
215
|
+
*
|
|
216
|
+
* A wake is delivered back to the work of the node that armed it - never as a new task that starts the
|
|
217
|
+
* graph over - so the node is part of the wake. A subagent's context inherits its host node's.
|
|
218
|
+
*/
|
|
219
|
+
wakeOrigin?: import('./timers.js').WakeOrigin;
|
|
197
220
|
/**
|
|
198
221
|
* Filled in with the id of every wake this run arms, so a run can tell its own wakes from the session's.
|
|
199
222
|
*
|
package/dist/src/update.d.ts
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/** The package `andorra update` installs. */
|
|
2
|
+
export declare const PACKAGE_NAME = "@andorra-labs/code";
|
|
3
|
+
export interface RunOptions {
|
|
4
|
+
/** Show the command's output while it runs instead of only capturing it; npm install uses this. */
|
|
5
|
+
stream?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type UpdateRunner = (program: string, args: string[], cwd: string, options?: RunOptions) => Promise<string>;
|
|
8
|
+
/** Outcome of deciding whether the installed package can be replaced in place. */
|
|
3
9
|
export interface LockProbe {
|
|
4
10
|
state: 'clear' | 'locked' | 'unknown';
|
|
5
|
-
/** The file or directory
|
|
11
|
+
/** The file or directory that could not be replaced, when the probe identified one. */
|
|
6
12
|
path?: string;
|
|
7
13
|
detail: string;
|
|
8
14
|
}
|
|
9
|
-
export type ReinstallProbe = (
|
|
15
|
+
export type ReinstallProbe = (packageRoot: string) => Promise<LockProbe>;
|
|
10
16
|
export interface UpdateOptions {
|
|
11
17
|
/** Injectable only for embedding/tests; the CLI uses this module's installed location. */
|
|
12
18
|
moduleUrl?: string | URL;
|
|
13
19
|
run?: UpdateRunner;
|
|
14
|
-
/** Injectable only for tests; the CLI probes the real
|
|
20
|
+
/** Injectable only for tests; the CLI probes the real package by renaming within it. */
|
|
15
21
|
probe?: ReinstallProbe;
|
|
16
|
-
/** Injectable only for tests; the CLI waits between bounded
|
|
22
|
+
/** Injectable only for tests; the CLI waits between bounded install attempts. */
|
|
17
23
|
sleep?: (ms: number) => Promise<void>;
|
|
18
24
|
/** Replace an existing updater lock even when its recorded process still appears to run. */
|
|
19
25
|
breakLock?: boolean;
|
|
@@ -21,16 +27,11 @@ export interface UpdateOptions {
|
|
|
21
27
|
isRunning?: (pid: number) => boolean;
|
|
22
28
|
/** Receives progress notes the caller should show, such as a reclaimed stale lock. */
|
|
23
29
|
notify?: (message: string) => void;
|
|
30
|
+
/** Injectable only for tests; the CLI keeps its lock in the Andorra home directory. */
|
|
31
|
+
lockDirectory?: string;
|
|
32
|
+
/** Injectable only for tests; the CLI runs the npm that ships beside the Node.js running it. */
|
|
33
|
+
npm?: string;
|
|
24
34
|
}
|
|
25
|
-
/**
|
|
26
|
-
* True when the installed tree is provably complete for the lockfile the checkout carries: both the
|
|
27
|
-
* root lockfile and npm's own hidden lockfile parse, every package npm recorded still matches the
|
|
28
|
-
* version and hash the root lockfile pins, and every direct dependency the package declares is
|
|
29
|
-
* present. The hidden lockfile is written only by a completed install, and it omits the root entry,
|
|
30
|
-
* so a legitimate tree has one fewer entry than the lockfile — it is never compared by count, and it
|
|
31
|
-
* is never trusted on its own, because a failed install can leave a stale one behind.
|
|
32
|
-
*/
|
|
33
|
-
export declare function dependenciesSatisfied(checkout: string): Promise<boolean>;
|
|
34
35
|
export interface UpdateLockOptions {
|
|
35
36
|
breakLock?: boolean;
|
|
36
37
|
isRunning?: (pid: number) => boolean;
|
|
@@ -44,5 +45,14 @@ export interface UpdateLockOptions {
|
|
|
44
45
|
* a process id can be reused.
|
|
45
46
|
*/
|
|
46
47
|
export declare function acquireUpdateLock(lockPath: string, options?: UpdateLockOptions): Promise<string>;
|
|
47
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Replace the global npm installation this command runs from with the latest npm release.
|
|
50
|
+
*
|
|
51
|
+
* Only a global npm installation is updated. A source checkout — one that `npm link` exposes as the
|
|
52
|
+
* global command, or one started directly — is refused without changing anything, and so is any
|
|
53
|
+
* other copy (a project's own dependency, the desktop client's engine): each is updated the way it
|
|
54
|
+
* was installed. The release is resolved from the `latest` dist-tag once and installed by its exact
|
|
55
|
+
* version, so a tag that moves mid-update cannot install something other than what was reported,
|
|
56
|
+
* and a tag that points below the installed version is never followed down.
|
|
57
|
+
*/
|
|
48
58
|
export declare function updateInstallation(options?: UpdateOptions): Promise<string>;
|