@andorra-labs/code 0.1.17 → 0.1.19
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-jev-savings.d.ts +4 -0
- package/dist/src/account-jev-savings.js +92 -0
- package/dist/src/acp-agent.js +2 -2
- package/dist/src/agent-execution.js +441 -53
- package/dist/src/agent-mcp.js +7 -1
- package/dist/src/agent-modifiers.js +5 -7
- package/dist/src/analytics.d.ts +19 -1
- package/dist/src/analytics.js +9 -1
- package/dist/src/andorra/entry.js +15 -6
- package/dist/src/andorra/errors.js +3 -0
- package/dist/src/andorra/hosted.d.ts +8 -0
- package/dist/src/andorra/hosted.js +22 -3
- package/dist/src/andorra/streams.d.ts +49 -0
- package/dist/src/andorra/streams.js +98 -0
- package/dist/src/antigravity-acp.d.ts +28 -0
- package/dist/src/antigravity-acp.js +150 -0
- package/dist/src/antigravity-terminal.d.ts +2 -0
- package/dist/src/antigravity-terminal.js +214 -0
- package/dist/src/app-server/adaptive-routing-settings.d.ts +37 -0
- package/dist/src/app-server/adaptive-routing-settings.js +69 -0
- package/dist/src/app-server/artifact.d.ts +14 -0
- package/dist/src/app-server/artifact.js +46 -0
- package/dist/src/app-server/legal-protocol.d.ts +33 -0
- package/dist/src/app-server/legal-protocol.js +16 -0
- package/dist/src/app-server/protocol.d.ts +34 -3
- package/dist/src/app-server/protocol.js +3 -1
- package/dist/src/app-server/telemetry-protocol.d.ts +53 -0
- package/dist/src/app-server/telemetry-protocol.js +2 -0
- package/dist/src/app-server/telemetry.d.ts +38 -0
- package/dist/src/app-server/telemetry.js +163 -0
- package/dist/src/app-server/workspace.d.ts +21 -0
- package/dist/src/app-server/workspace.js +192 -10
- package/dist/src/app-server.d.ts +82 -26
- package/dist/src/app-server.js +1573 -417
- package/dist/src/attachments.d.ts +10 -0
- package/dist/src/attachments.js +102 -7
- package/dist/src/auth/AuthManager.d.ts +11 -2
- package/dist/src/auth/AuthManager.js +56 -13
- package/dist/src/auth/index.d.ts +5 -1
- package/dist/src/auth/index.js +8 -1
- package/dist/src/auth/lifecycle.d.ts +13 -0
- package/dist/src/auth/lifecycle.js +109 -0
- package/dist/src/auth/store.d.ts +1 -0
- package/dist/src/auth/store.js +12 -0
- package/dist/src/auth/types.d.ts +12 -0
- package/dist/src/automation-runner.js +2 -0
- package/dist/src/automation-service.js +7 -2
- package/dist/src/automation-tool.js +2 -1
- package/dist/src/benchmark-scores.d.ts +88 -0
- package/dist/src/benchmark-scores.js +302 -0
- package/dist/src/bridge/command.js +16 -1
- package/dist/src/bridge/control.d.ts +3 -1
- package/dist/src/bridge/control.js +9 -3
- package/dist/src/bridge/engines.d.ts +2 -0
- package/dist/src/bridge/engines.js +9 -0
- package/dist/src/bridge/github.d.ts +108 -0
- package/dist/src/bridge/github.js +378 -0
- package/dist/src/bridge/host-ops.d.ts +3 -3
- package/dist/src/bridge/host-ops.js +14 -2
- package/dist/src/bridge/host.d.ts +2 -0
- package/dist/src/bridge/host.js +70 -16
- package/dist/src/bridge/protocol.d.ts +1 -0
- package/dist/src/bridge/protocol.js +1 -0
- package/dist/src/browser-panel-tool.d.ts +12 -0
- package/dist/src/browser-panel-tool.js +30 -3
- package/dist/src/browser-runner.js +53 -62
- package/dist/src/browser-server.js +10 -4
- package/dist/src/browser-session.d.ts +14 -0
- package/dist/src/browser-session.js +57 -12
- package/dist/src/browser-view.d.ts +40 -1
- package/dist/src/browser-view.js +163 -9
- package/dist/src/browser-window-style.d.ts +27 -0
- package/dist/src/browser-window-style.js +244 -0
- 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/claude-provider.d.ts +1 -0
- package/dist/src/claude-provider.js +77 -36
- package/dist/src/cli.d.ts +1 -3
- package/dist/src/cli.js +245 -62
- package/dist/src/codex-provider.d.ts +1 -0
- package/dist/src/codex-provider.js +44 -8
- package/dist/src/coding-tools.d.ts +1 -0
- package/dist/src/coding-tools.js +28 -7
- package/dist/src/command-screens.d.ts +1 -1
- package/dist/src/command-screens.js +2 -2
- package/dist/src/commands.d.ts +9 -2
- package/dist/src/commands.js +69 -64
- package/dist/src/completion.js +13 -7
- package/dist/src/config.d.ts +14 -3
- package/dist/src/config.js +57 -17
- package/dist/src/context-budget.d.ts +11 -2
- package/dist/src/context-budget.js +38 -4
- package/dist/src/context-compaction.d.ts +10 -8
- package/dist/src/context-compaction.js +23 -24
- package/dist/src/deadline.js +1 -1
- package/dist/src/decision/DecisionEngine.d.ts +2 -0
- package/dist/src/decision/DecisionManager.d.ts +16 -0
- package/dist/src/decision/DecisionManager.js +75 -2
- package/dist/src/decision/applyTaskKind.d.ts +8 -0
- package/dist/src/decision/applyTaskKind.js +53 -0
- package/dist/src/decision/applyToolMenu.js +6 -2
- package/dist/src/decision/hostedPolicy.js +6 -3
- package/dist/src/decision/optimizationPolicy.d.ts +10 -0
- package/dist/src/decision/optimizationPolicy.js +23 -3
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +4 -1
- package/dist/src/decision/providers/AndorraDecisionProvider.js +29 -7
- package/dist/src/decision/providers/index.js +1 -1
- package/dist/src/decision/taskKind.d.ts +52 -0
- package/dist/src/decision/taskKind.js +76 -0
- package/dist/src/decision/toolFamilies.js +1 -1
- package/dist/src/decision/types.d.ts +3 -1
- package/dist/src/default-graph.js +1 -1
- package/dist/src/efficiency.d.ts +80 -1
- package/dist/src/efficiency.js +119 -4
- 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/extensions.d.ts +2 -0
- package/dist/src/extensions.js +30 -20
- package/dist/src/github-app/agent-writes.d.ts +1 -1
- package/dist/src/github-app/agent-writes.js +1 -1
- package/dist/src/github-app/client.d.ts +19 -0
- package/dist/src/github-app/client.js +21 -1
- package/dist/src/github-app/event-source.d.ts +0 -5
- package/dist/src/github-app/event-source.js +1 -31
- package/dist/src/github-app/metrics.d.ts +2 -5
- package/dist/src/github-app/metrics.js +2 -14
- package/dist/src/github-app/review-loop.d.ts +5 -5
- package/dist/src/github-app/review-loop.js +1 -1
- package/dist/src/github-app/review-node.d.ts +2 -2
- package/dist/src/github-app/triggers.d.ts +3 -3
- package/dist/src/github-names.d.ts +7 -0
- package/dist/src/github-names.js +7 -0
- package/dist/src/glob-search.d.ts +1 -0
- package/dist/src/glob-search.js +3 -0
- package/dist/src/google-provider.d.ts +5 -28
- package/dist/src/google-provider.js +6 -141
- package/dist/src/graph-editor-session.d.ts +1 -0
- package/dist/src/graph-editor-session.js +2 -0
- package/dist/src/graph-health.js +3 -1
- package/dist/src/graph-preview.d.ts +2 -0
- package/dist/src/graph-preview.js +1 -0
- package/dist/src/graph-runner.js +20 -14
- package/dist/src/graph-selection.d.ts +3 -1
- package/dist/src/graph-selection.js +2 -2
- package/dist/src/graph-server.d.ts +8 -1
- package/dist/src/graph-server.js +49 -12
- package/dist/src/graph-sync.d.ts +2 -1
- package/dist/src/graph-sync.js +13 -0
- package/dist/src/graph-ui/app.js +49 -8
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graphs.d.ts +23 -1
- package/dist/src/graphs.js +58 -7
- package/dist/src/grok-provider.js +17 -14
- package/dist/src/hardened-runtime.js +39 -25
- package/dist/src/jev-savings.d.ts +4 -0
- package/dist/src/jev-savings.js +13 -0
- package/dist/src/legal/client.d.ts +25 -0
- package/dist/src/legal/client.js +47 -0
- package/dist/src/legal/command.d.ts +13 -0
- package/dist/src/legal/command.js +98 -0
- package/dist/src/legal/documents.d.ts +2 -0
- package/dist/src/legal/documents.js +14 -0
- package/dist/src/legal/gate.d.ts +13 -0
- package/dist/src/legal/gate.js +96 -0
- package/dist/src/legal/manifest.d.ts +21 -0
- package/dist/src/legal/manifest.js +23 -0
- package/dist/src/legal/receipt.d.ts +13 -0
- package/dist/src/legal/receipt.js +137 -0
- package/dist/src/legal/release.d.ts +27 -0
- package/dist/src/legal/release.js +28 -0
- package/dist/src/managed-sign-in.d.ts +0 -1
- package/dist/src/managed-sign-in.js +0 -13
- package/dist/src/membership.d.ts +27 -1
- package/dist/src/membership.js +139 -7
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.js +3 -7
- package/dist/src/model-override.d.ts +2 -1
- package/dist/src/model-override.js +9 -0
- package/dist/src/model-pool.d.ts +99 -0
- package/dist/src/model-pool.js +136 -0
- package/dist/src/model-relay/local.js +5 -0
- package/dist/src/model-relay/remote.d.ts +2 -0
- package/dist/src/model-relay/remote.js +4 -0
- package/dist/src/model-tiers.d.ts +16 -1
- package/dist/src/model-tiers.js +31 -7
- package/dist/src/opencode-cli-provider.js +59 -56
- package/dist/src/opencode-provider.js +16 -13
- package/dist/src/permissions.d.ts +5 -0
- package/dist/src/permissions.js +7 -0
- package/dist/src/plan-pass.js +2 -1
- package/dist/src/pool-scores.d.ts +45 -0
- package/dist/src/pool-scores.js +40 -0
- package/dist/src/provider-connection.js +3 -17
- package/dist/src/provider-engine.d.ts +13 -1
- package/dist/src/provider-engine.js +116 -12
- package/dist/src/provider-request-error.d.ts +8 -0
- package/dist/src/provider-request-error.js +12 -0
- package/dist/src/provider-settings.d.ts +1 -1
- package/dist/src/provider-settings.js +36 -18
- package/dist/src/provider-turn-deadline.d.ts +39 -0
- package/dist/src/provider-turn-deadline.js +139 -0
- package/dist/src/providers.d.ts +8 -9
- package/dist/src/providers.js +211 -150
- package/dist/src/pull-request-merge.d.ts +1 -8
- package/dist/src/pull-request-merge.js +0 -4
- package/dist/src/pull-requests.d.ts +83 -57
- package/dist/src/pull-requests.js +266 -225
- package/dist/src/qa/runtime/ProcessManager.d.ts +5 -1
- package/dist/src/qa/runtime/ProcessManager.js +9 -3
- package/dist/src/react-runtime.js +245 -71
- package/dist/src/reasoning-probe-cloud.d.ts +10 -0
- package/dist/src/reasoning-probe-cloud.js +209 -0
- package/dist/src/remote/engine-pool.d.ts +3 -0
- package/dist/src/remote/engine-pool.js +88 -21
- package/dist/src/remote/recovery.d.ts +6 -0
- package/dist/src/remote/recovery.js +37 -0
- package/dist/src/run-records.d.ts +13 -3
- package/dist/src/run-records.js +59 -34
- package/dist/src/runtime.d.ts +47 -2
- package/dist/src/runtime.js +33 -7
- package/dist/src/session-summary.d.ts +8 -0
- package/dist/src/session-summary.js +34 -0
- package/dist/src/sessions.d.ts +32 -0
- package/dist/src/sessions.js +65 -3
- package/dist/src/shell.js +6 -0
- package/dist/src/side-panel.js +36 -2
- package/dist/src/sign-in-detection.d.ts +1 -1
- package/dist/src/sign-in-detection.js +4 -10
- package/dist/src/sign-in-offer.js +1 -1
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
- package/dist/src/skills/bundled/graph-manager/SKILL.md +2 -2
- package/dist/src/skills/bundled/graph-manager/patterns.md +13 -19
- package/dist/src/skills/bundled/provenance.json +3 -3
- package/dist/src/subagent-run.js +50 -50
- package/dist/src/subscription-usage.d.ts +50 -0
- package/dist/src/subscription-usage.js +92 -0
- package/dist/src/task-checkout.d.ts +157 -0
- package/dist/src/task-checkout.js +628 -0
- package/dist/src/telemetry/access.d.ts +18 -0
- package/dist/src/telemetry/access.js +43 -0
- package/dist/src/telemetry/aggregate.d.ts +18 -2
- package/dist/src/telemetry/aggregate.js +22 -9
- package/dist/src/telemetry/capture-core.d.ts +33 -14
- package/dist/src/telemetry/capture-core.js +124 -25
- package/dist/src/telemetry/capture.d.ts +3 -2
- package/dist/src/telemetry/capture.js +21 -1
- package/dist/src/telemetry/decision-capture.js +4 -0
- package/dist/src/telemetry/emitter.d.ts +6 -7
- package/dist/src/telemetry/emitter.js +124 -29
- package/dist/src/telemetry/gate.d.ts +41 -2
- package/dist/src/telemetry/gate.js +89 -4
- package/dist/src/telemetry/home.d.ts +1 -0
- package/dist/src/telemetry/home.js +20 -0
- package/dist/src/telemetry/identity.d.ts +6 -3
- package/dist/src/telemetry/identity.js +19 -6
- package/dist/src/telemetry/lifecycle.d.ts +8 -0
- package/dist/src/telemetry/lifecycle.js +76 -0
- package/dist/src/telemetry/outbox.d.ts +13 -8
- package/dist/src/telemetry/outbox.js +68 -12
- package/dist/src/telemetry/permission-command.d.ts +38 -0
- package/dist/src/telemetry/permission-command.js +208 -0
- package/dist/src/telemetry/permission.d.ts +168 -0
- package/dist/src/telemetry/permission.js +662 -0
- package/dist/src/telemetry/record-installation.d.ts +1 -0
- package/dist/src/telemetry/record-installation.js +9 -0
- package/dist/src/telemetry/region-data.d.ts +12 -0
- package/dist/src/telemetry/region-data.js +1314 -0
- package/dist/src/telemetry/region.d.ts +34 -0
- package/dist/src/telemetry/region.js +87 -0
- package/dist/src/telemetry/run-privacy.d.ts +11 -0
- package/dist/src/telemetry/run-privacy.js +165 -0
- package/dist/src/telemetry/schema.d.ts +27 -6
- package/dist/src/telemetry/schema.js +109 -14
- package/dist/src/telemetry/state.d.ts +11 -7
- package/dist/src/telemetry/state.js +39 -6
- package/dist/src/telemetry/surface.d.ts +20 -3
- package/dist/src/telemetry/surface.js +71 -15
- package/dist/src/telemetry/uploader.d.ts +6 -11
- package/dist/src/telemetry/uploader.js +72 -46
- package/dist/src/telemetry/uploads.d.ts +5 -1
- package/dist/src/telemetry/uploads.js +25 -6
- package/dist/src/telemetry/version.d.ts +5 -0
- package/dist/src/telemetry/version.js +34 -0
- package/dist/src/telemetry/workspace.d.ts +4 -1
- package/dist/src/telemetry/workspace.js +18 -3
- package/dist/src/terminal-ui.d.ts +3 -0
- package/dist/src/terminal-ui.js +48 -6
- 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 +13 -0
- package/dist/src/thinking-level-detect.js +52 -0
- package/dist/src/thinking-levels.d.ts +30 -0
- package/dist/src/thinking-levels.js +131 -0
- package/dist/src/timers.d.ts +3 -0
- package/dist/src/todos.d.ts +2 -1
- package/dist/src/todos.js +24 -4
- package/dist/src/tool-argument-coercion.d.ts +7 -0
- package/dist/src/tool-argument-coercion.js +49 -0
- package/dist/src/tool-catalog.d.ts +2 -2
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/tools.js +67 -22
- package/dist/src/transcript.js +3 -2
- package/dist/src/types.d.ts +48 -1
- package/dist/src/update.js +4 -0
- package/dist/src/usage-analytics.d.ts +7 -0
- package/dist/src/usage-analytics.js +85 -13
- package/dist/telemetry-consent-v1 +1 -0
- package/package.json +97 -96
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { codexConnectFor } from './codex-rpc.js';
|
|
2
|
+
/**
|
|
3
|
+
* Subscription usage for pool routing, read from each provider's own client. Nothing here reads another tool's
|
|
4
|
+
* files: a provider with no built-in source simply has no reading, and pool routing treats that as no known limit.
|
|
5
|
+
*/
|
|
6
|
+
/** How long one reading is reused before the provider is asked again. */
|
|
7
|
+
export const USAGE_READING_TTL_MS = 60_000;
|
|
8
|
+
const USAGE_READ_TIMEOUT_MS = 10_000;
|
|
9
|
+
const WEEK_SECONDS = 7 * 86_400;
|
|
10
|
+
function codexWindow(value) {
|
|
11
|
+
if (!value || typeof value !== 'object')
|
|
12
|
+
return undefined;
|
|
13
|
+
const { usedPercent, windowDurationMins, resetsAt } = value;
|
|
14
|
+
if (typeof usedPercent !== 'number' || !Number.isFinite(usedPercent))
|
|
15
|
+
return undefined;
|
|
16
|
+
// Codex reports the reset as seconds since the epoch.
|
|
17
|
+
const reset = typeof resetsAt === 'number' && Number.isFinite(resetsAt) && resetsAt > 0 ? (resetsAt < 100_000_000_000 ? resetsAt * 1000 : resetsAt) : undefined;
|
|
18
|
+
const seconds = typeof windowDurationMins === 'number' && Number.isFinite(windowDurationMins) && windowDurationMins > 0 ? windowDurationMins * 60 : undefined;
|
|
19
|
+
return { usedPercent, ...(reset === undefined ? {} : { resetsAt: reset }), ...(seconds === undefined ? {} : { windowSeconds: seconds }) };
|
|
20
|
+
}
|
|
21
|
+
/** The usage windows in a Codex `account/rateLimits/read` answer. */
|
|
22
|
+
export function codexWindows(rateLimits) {
|
|
23
|
+
if (!rateLimits || typeof rateLimits !== 'object')
|
|
24
|
+
return [];
|
|
25
|
+
const { primary, secondary } = rateLimits;
|
|
26
|
+
return [codexWindow(primary), codexWindow(secondary)].filter((item) => item !== undefined);
|
|
27
|
+
}
|
|
28
|
+
/** Ask the signed-in Codex client for its account's usage windows. */
|
|
29
|
+
export async function readCodexUsage(provider, signal, connect = codexConnectFor(provider)) {
|
|
30
|
+
const rpc = await connect(AbortSignal.any([signal, AbortSignal.timeout(USAGE_READ_TIMEOUT_MS)]));
|
|
31
|
+
try {
|
|
32
|
+
const windows = codexWindows((await rpc.request('account/rateLimits/read', {}))?.rateLimits);
|
|
33
|
+
return windows.length ? windows : undefined;
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
rpc.close();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** The hosted weekly allowance as one usage window. */
|
|
40
|
+
export function hostedWindows(usage) {
|
|
41
|
+
if (!usage || usage.kind !== 'meter' || typeof usage.usedPercent !== 'number' || !Number.isFinite(usage.usedPercent))
|
|
42
|
+
return undefined;
|
|
43
|
+
const reset = typeof usage.resetsAt === 'string' ? Date.parse(usage.resetsAt) : NaN;
|
|
44
|
+
return [{ usedPercent: usage.usedPercent, ...(Number.isFinite(reset) ? { resetsAt: reset, windowSeconds: WEEK_SECONDS } : {}) }];
|
|
45
|
+
}
|
|
46
|
+
/** The provider types whose client can report usage. */
|
|
47
|
+
export const USAGE_SOURCES = { codex: readCodexUsage };
|
|
48
|
+
const sharedCache = new Map();
|
|
49
|
+
/**
|
|
50
|
+
* A reader of usage by provider id. Each provider is asked at most once per `ttlMs`; a read that fails or times out
|
|
51
|
+
* gives no reading for that provider and never fails the caller.
|
|
52
|
+
*/
|
|
53
|
+
export function createUsageReader(providers, options = {}) {
|
|
54
|
+
const sources = options.sources ?? USAGE_SOURCES;
|
|
55
|
+
const cache = options.cache ?? sharedCache;
|
|
56
|
+
const now = options.now ?? Date.now;
|
|
57
|
+
const ttl = options.ttlMs ?? USAGE_READING_TTL_MS;
|
|
58
|
+
return async (signal) => {
|
|
59
|
+
signal.throwIfAborted();
|
|
60
|
+
const readings = {};
|
|
61
|
+
await Promise.all(providers().filter(provider => !options.only || options.only.includes(provider.id)).map(async (provider) => {
|
|
62
|
+
if (provider.type === 'andorra') {
|
|
63
|
+
const hosted = hostedWindows(options.hosted?.());
|
|
64
|
+
if (hosted)
|
|
65
|
+
readings[provider.id] = hosted;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const source = sources[provider.type];
|
|
69
|
+
if (!source)
|
|
70
|
+
return;
|
|
71
|
+
const key = JSON.stringify([provider.type, provider.id, provider.codexAccount ?? null]);
|
|
72
|
+
let entry = cache.get(key);
|
|
73
|
+
if (!entry || now() - entry.at >= ttl) {
|
|
74
|
+
// The read is shared by every run, so it is bounded by its own deadline and not by one run's cancellation.
|
|
75
|
+
entry = { at: now(), windows: Promise.resolve().then(() => source(provider, AbortSignal.timeout(USAGE_READ_TIMEOUT_MS))).catch(() => undefined) };
|
|
76
|
+
cache.set(key, entry);
|
|
77
|
+
}
|
|
78
|
+
const windows = await entry.windows;
|
|
79
|
+
if (windows?.length)
|
|
80
|
+
readings[provider.id] = windows;
|
|
81
|
+
}));
|
|
82
|
+
return readings;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** The usage reader for a configuration's pool: it asks only the providers the pool names. */
|
|
86
|
+
export function poolUsageReader(config, hosted) {
|
|
87
|
+
// With `candidates: all` any configured provider can be chosen, so each one that has a source is asked.
|
|
88
|
+
if (config.efficiency?.adaptiveRouting?.candidates === 'all')
|
|
89
|
+
return createUsageReader(() => config.providers, hosted ? { hosted } : {});
|
|
90
|
+
const only = [...new Set((config.efficiency?.adaptiveRouting?.pool ?? []).map(entry => entry.provider))];
|
|
91
|
+
return createUsageReader(() => config.providers, { only, ...(hosted ? { hosted } : {}) });
|
|
92
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a task works, recorded on its session. A writing task in a Git repository gets its own worktree on a task
|
|
3
|
+
* branch, started from a commit resolved when it began; an explicit choice, a Read Only task or a folder outside Git
|
|
4
|
+
* works in the project's own folder. The session stays filed under its project (`workspace`); this says where its
|
|
5
|
+
* agent, terminal, files, changes and checks run.
|
|
6
|
+
*/
|
|
7
|
+
export interface SessionCheckout {
|
|
8
|
+
kind: 'worktree' | 'checkout' | 'folder';
|
|
9
|
+
/** The folder the task works in: the worktree (plus the project's place inside the repository), or the project folder. */
|
|
10
|
+
path: string;
|
|
11
|
+
/** The machine that holds the folder. */
|
|
12
|
+
host: string;
|
|
13
|
+
/** The task's branch: the worktree's own, or the branch checked out when an in-place task began. */
|
|
14
|
+
branch?: string;
|
|
15
|
+
/** What the task started from, as chosen: `main`, `feature/billing`. */
|
|
16
|
+
baseBranch?: string;
|
|
17
|
+
/** The ref that was resolved: `origin/main`, or the local branch. */
|
|
18
|
+
baseRef?: string;
|
|
19
|
+
baseCommit?: string;
|
|
20
|
+
/** The worktree's top, when the project sits below the repository's top. Defaults to `path`. */
|
|
21
|
+
worktree?: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
/** Set once the lead removed the worktree; the branch may still hold its commits. */
|
|
24
|
+
removedAt?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface TaskStartPoints {
|
|
27
|
+
repository: boolean;
|
|
28
|
+
current?: string;
|
|
29
|
+
/** Uncommitted files (tracked and untracked) in the project's checkout. */
|
|
30
|
+
dirty: number;
|
|
31
|
+
/** The repository's default branch, when one can be found. */
|
|
32
|
+
defaultBranch?: string;
|
|
33
|
+
/** The ref a worktree from the default branch starts at: `origin/main`, or `main` with no remote. */
|
|
34
|
+
defaultRef?: string;
|
|
35
|
+
/** When the remote was last fetched. */
|
|
36
|
+
fetchedAt?: string;
|
|
37
|
+
/** Local branches other than the default and the current one. */
|
|
38
|
+
branches: string[];
|
|
39
|
+
truncated?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface PreparedTaskCheckout {
|
|
42
|
+
checkout: SessionCheckout;
|
|
43
|
+
/** The default branch was refreshed from its remote before the commit was resolved. */
|
|
44
|
+
refreshed?: boolean;
|
|
45
|
+
/** Why it could not be. */
|
|
46
|
+
refreshError?: string;
|
|
47
|
+
/** A retry found this start's worktree already made. */
|
|
48
|
+
reused?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare class TaskCheckoutError extends Error {
|
|
51
|
+
}
|
|
52
|
+
/** The repository's top and where the project folder sits in it; undefined outside a repository. */
|
|
53
|
+
export declare function repositoryOf(root: string): Promise<{
|
|
54
|
+
top: string;
|
|
55
|
+
prefix: string;
|
|
56
|
+
commonDir: string;
|
|
57
|
+
} | undefined>;
|
|
58
|
+
/** What New Task offers to start from in `root`'s repository. */
|
|
59
|
+
export declare function taskStartPoints(root: string): Promise<TaskStartPoints>;
|
|
60
|
+
/** The name a caller picked for a task branch, made a safe slug: lower case, hyphens, at most 40 characters. */
|
|
61
|
+
export declare function taskSlug(text: string): string;
|
|
62
|
+
/** A random 8-character task name (`a92x9dwe`): what a worktree, its `task/<name>` branch and a session start under. */
|
|
63
|
+
export declare function randomTaskName(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Where task worktrees go: `~/worktrees/<project>/<name>`, outside Andorra's home, whose files the permission rules
|
|
66
|
+
* protect from the agent.
|
|
67
|
+
*/
|
|
68
|
+
export declare function worktreesRoot(): string;
|
|
69
|
+
/** The folder a project's task worktrees go in. */
|
|
70
|
+
export declare function worktreesFolder(root: string, under?: string): string;
|
|
71
|
+
/** Forgets a start's preparation, once its task has begun or it was given up. */
|
|
72
|
+
export declare function forgetPrepared(home: string, key: string): Promise<void>;
|
|
73
|
+
/** The prepared checkout a run.start names, checked to belong to `root`'s repository. */
|
|
74
|
+
export declare function takePrepared(home: string, root: string, key: string): Promise<SessionCheckout>;
|
|
75
|
+
/**
|
|
76
|
+
* Makes a writing task's worktree: resolves `base` to a commit (refreshing the default branch from its remote first),
|
|
77
|
+
* then adds a worktree on a new `task/<name>` branch in `~/worktrees/<project>`, where `name` is the random id the
|
|
78
|
+
* caller picked. A collision with an existing branch or folder is rare; a start that hits one draws a fresh random
|
|
79
|
+
* name instead of growing a suffix. The same `key` returns the same worktree while it still stands, so a retried
|
|
80
|
+
* start reuses its preparation.
|
|
81
|
+
*/
|
|
82
|
+
export declare function prepareTaskWorktree(options: {
|
|
83
|
+
home: string;
|
|
84
|
+
root: string;
|
|
85
|
+
base: string;
|
|
86
|
+
slug: string;
|
|
87
|
+
key: string;
|
|
88
|
+
worktrees?: string;
|
|
89
|
+
}): Promise<PreparedTaskCheckout>;
|
|
90
|
+
/** Whether a task branch still carries the automatic name its start gave it (`task/<random id>`). */
|
|
91
|
+
export declare function isAutoTaskBranch(branch: string | undefined): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Renames a task's own branch to the name the model gave the task (`task/fix-login-redirect-loop`), replacing the
|
|
94
|
+
* random id the start created. Only a branch that still carries the automatic name is renamed — a branch a person or
|
|
95
|
+
* the agent already moved is never touched, and neither is one that has a remote upstream, which means it was pushed,
|
|
96
|
+
* perhaps under review. A name that is taken gets a `-2`, `-3`… suffix. Returns the new branch name, or undefined
|
|
97
|
+
* when nothing was renamed.
|
|
98
|
+
*/
|
|
99
|
+
export declare function renameTaskBranch(checkout: SessionCheckout, name: string): Promise<string | undefined>;
|
|
100
|
+
/** Puts a task branch back under its previous name, when a rename succeeded but could not be recorded. */
|
|
101
|
+
export declare function revertTaskBranchRename(checkout: SessionCheckout, from: string, to: string): Promise<void>;
|
|
102
|
+
/** What an in-place task records: the project folder, and the branch and commit it began on. */
|
|
103
|
+
export declare function inPlaceCheckout(root: string): Promise<SessionCheckout>;
|
|
104
|
+
export declare function checkoutTop(checkout: SessionCheckout): string;
|
|
105
|
+
export type CheckoutState = {
|
|
106
|
+
state: 'ok';
|
|
107
|
+
} | {
|
|
108
|
+
state: 'missing' | 'moved' | 'removed' | 'other-host';
|
|
109
|
+
reason: string;
|
|
110
|
+
};
|
|
111
|
+
/** Whether a task's recorded worktree is still where it was, a worktree of `root`'s repository. */
|
|
112
|
+
export declare function checkoutState(checkout: SessionCheckout, root: string): Promise<CheckoutState>;
|
|
113
|
+
/** Adds the worktree back at its recorded place from the task branch, which keeps every commit the task made. */
|
|
114
|
+
export declare function recreateTaskWorktree(checkout: SessionCheckout, root: string): Promise<SessionCheckout>;
|
|
115
|
+
/** Takes a folder the lead picked as the task's moved worktree, once it is on the task branch in the same repository. */
|
|
116
|
+
export declare function locateTaskWorktree(checkout: SessionCheckout, root: string, picked: string): Promise<SessionCheckout>;
|
|
117
|
+
export interface WorktreeRemovalCheck {
|
|
118
|
+
/** Uncommitted and untracked files, which removing deletes. */
|
|
119
|
+
dirty: {
|
|
120
|
+
count: number;
|
|
121
|
+
files: string[];
|
|
122
|
+
};
|
|
123
|
+
/** Files Git ignores (node_modules, .env, build output), which removing deletes too. */
|
|
124
|
+
ignored: {
|
|
125
|
+
count: number;
|
|
126
|
+
files: string[];
|
|
127
|
+
};
|
|
128
|
+
/** Commits on the task branch that no remote branch and not the default branch holds. */
|
|
129
|
+
unmerged: {
|
|
130
|
+
count: number;
|
|
131
|
+
commits: string[];
|
|
132
|
+
};
|
|
133
|
+
/** Processes whose working folder is inside the worktree; undefined where they cannot be listed. */
|
|
134
|
+
processes?: {
|
|
135
|
+
count: number;
|
|
136
|
+
names: string[];
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/** What removing a task's worktree would lose, and what holds it. */
|
|
140
|
+
export declare function inspectWorktreeRemoval(checkout: SessionCheckout, root: string): Promise<WorktreeRemovalCheck>;
|
|
141
|
+
export interface WorktreeRemoval {
|
|
142
|
+
checkout: SessionCheckout;
|
|
143
|
+
branchDeleted: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Removes a task's worktree. Refused while a process works in it, or when it holds uncommitted files the lead was not
|
|
147
|
+
* shown (`expectDirty` is the count they saw). The branch is deleted only when no commit would be lost; otherwise it
|
|
148
|
+
* stays, holding the task's commits.
|
|
149
|
+
*/
|
|
150
|
+
export declare function removeTaskWorktree(checkout: SessionCheckout, root: string, options: {
|
|
151
|
+
expectDirty: number;
|
|
152
|
+
}): Promise<WorktreeRemoval>;
|
|
153
|
+
/** Removes a worktree a start made and never used: only while it is clean and its branch has no commit of its own. */
|
|
154
|
+
export declare function discardPreparedWorktree(home: string, root: string, key: string): Promise<boolean>;
|
|
155
|
+
export declare function validCheckout(value: unknown): value is SessionCheckout;
|
|
156
|
+
/** What the agent is told about a task worktree. */
|
|
157
|
+
export declare function worktreeInstructions(checkout: SessionCheckout | undefined): string;
|