@andorra-labs/code 0.1.18 → 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 +347 -45
- 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/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 +23 -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 +3 -1
- package/dist/src/app-server/workspace.js +39 -8
- package/dist/src/app-server.d.ts +50 -25
- package/dist/src/app-server.js +1008 -400
- 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/benchmark-scores.d.ts +88 -0
- package/dist/src/benchmark-scores.js +302 -0
- package/dist/src/bridge/command.js +4 -1
- package/dist/src/bridge/control.js +2 -1
- package/dist/src/bridge/engines.d.ts +2 -0
- package/dist/src/bridge/engines.js +9 -0
- package/dist/src/bridge/host-ops.d.ts +2 -2
- package/dist/src/bridge/host-ops.js +4 -2
- package/dist/src/bridge/host.d.ts +2 -0
- package/dist/src/bridge/host.js +63 -12
- 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/claude-provider.d.ts +1 -0
- package/dist/src/claude-provider.js +77 -36
- package/dist/src/cli.js +235 -58
- package/dist/src/codex-provider.d.ts +1 -0
- package/dist/src/codex-provider.js +43 -7
- package/dist/src/coding-tools.d.ts +1 -0
- package/dist/src/coding-tools.js +19 -5
- package/dist/src/command-screens.d.ts +1 -1
- package/dist/src/command-screens.js +2 -2
- package/dist/src/commands.d.ts +8 -1
- package/dist/src/commands.js +67 -63
- package/dist/src/completion.js +5 -3
- package/dist/src/config.d.ts +14 -3
- package/dist/src/config.js +54 -16
- package/dist/src/context-budget.d.ts +11 -2
- package/dist/src/context-budget.js +23 -2
- 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/DecisionManager.d.ts +5 -0
- package/dist/src/decision/DecisionManager.js +39 -2
- package/dist/src/decision/applyToolMenu.js +6 -2
- package/dist/src/decision/hostedPolicy.js +6 -4
- 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 +2 -1
- package/dist/src/decision/providers/AndorraDecisionProvider.js +17 -7
- package/dist/src/decision/providers/index.js +1 -1
- package/dist/src/decision/toolFamilies.js +1 -1
- package/dist/src/decision/types.d.ts +2 -0
- package/dist/src/efficiency.d.ts +75 -1
- package/dist/src/efficiency.js +114 -3
- 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/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/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-runner.js +19 -13
- 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 +45 -10
- package/dist/src/graph-sync.d.ts +2 -1
- package/dist/src/graph-sync.js +13 -0
- package/dist/src/graph-ui/app.js +19 -8
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graphs.d.ts +17 -1
- package/dist/src/graphs.js +51 -5
- package/dist/src/grok-provider.js +17 -14
- package/dist/src/hardened-runtime.js +7 -4
- 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-metadata.js +3 -7
- 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 +13 -1
- package/dist/src/model-tiers.js +28 -4
- 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.js +42 -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 +3 -9
- package/dist/src/providers.js +181 -146
- 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 +82 -66
- package/dist/src/pull-requests.js +266 -276
- 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 +147 -56
- 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 +85 -18
- 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 +18 -1
- package/dist/src/runtime.js +25 -7
- package/dist/src/session-summary.d.ts +8 -0
- package/dist/src/session-summary.js +34 -0
- package/dist/src/sessions.d.ts +8 -0
- package/dist/src/sessions.js +12 -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/graph-manager/SKILL.md +2 -2
- package/dist/src/skills/bundled/graph-manager/patterns.md +13 -19
- package/dist/src/skills/bundled/provenance.json +2 -2
- 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 +20 -4
- package/dist/src/task-checkout.js +78 -8
- 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/thinking-level-detect.d.ts +3 -1
- package/dist/src/thinking-level-detect.js +8 -3
- package/dist/src/thinking-levels.d.ts +1 -1
- package/dist/src/thinking-levels.js +11 -4
- package/dist/src/timers.d.ts +2 -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/tools.js +67 -22
- package/dist/src/transcript.js +2 -1
- package/dist/src/types.d.ts +14 -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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthError, type AuthConfiguration, type AuthStatus, type CredentialStore } from './types.js';
|
|
1
|
+
import { AuthError, type AuthConfiguration, type AuthStatus, type AuthState, type CredentialStore } from './types.js';
|
|
2
2
|
import { type CredentialJournal } from './store.js';
|
|
3
3
|
export interface OtherSignIn {
|
|
4
4
|
read(): Promise<string | undefined>;
|
|
@@ -14,12 +14,15 @@ export declare class AuthManager {
|
|
|
14
14
|
private readonly store;
|
|
15
15
|
private readonly fetch;
|
|
16
16
|
private readonly keys;
|
|
17
|
+
private readonly lifecycle;
|
|
18
|
+
private readonly identity;
|
|
17
19
|
private readonly journal?;
|
|
18
20
|
private unsaved?;
|
|
19
21
|
private unsavedIsShared;
|
|
20
22
|
private unsavedRetires;
|
|
21
23
|
constructor(options: {
|
|
22
24
|
config: AuthConfiguration;
|
|
25
|
+
home?: string;
|
|
23
26
|
store?: CredentialStore;
|
|
24
27
|
journal?: CredentialJournal;
|
|
25
28
|
fetch?: typeof fetch;
|
|
@@ -69,5 +72,11 @@ export declare class AuthManager {
|
|
|
69
72
|
token: string;
|
|
70
73
|
subject: string;
|
|
71
74
|
}>;
|
|
72
|
-
|
|
75
|
+
/** Necessary auth lifecycle state, not an analytics preference. Outages never manufacture logout. */
|
|
76
|
+
deliberatelySignedOut(signal?: AbortSignal): Promise<boolean>;
|
|
77
|
+
/** No network, preference or recovery writes. Legacy empty stores are known signed out, too. */
|
|
78
|
+
state(signal?: AbortSignal): Promise<AuthState>;
|
|
79
|
+
status(signal?: AbortSignal, options?: {
|
|
80
|
+
readOnly?: boolean;
|
|
81
|
+
}): Promise<AuthStatus>;
|
|
73
82
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { randomBytes, randomUUID, createHash, timingSafeEqual } from 'node:crypto';
|
|
2
|
-
import { resolve } from 'node:path';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
3
4
|
import { createRemoteJWKSet, customFetch, jwtVerify } from 'jose';
|
|
4
5
|
import { AuthError } from './types.js';
|
|
5
6
|
import { createCredentialJournal, createCredentialStore, credentialScope, KeyringAbsentError, KeyringCredentialStore, keyringScopes } from './store.js';
|
|
7
|
+
import { AuthLifecycle } from './lifecycle.js';
|
|
6
8
|
import { withAuthLock } from './lock.js';
|
|
7
9
|
import { browserUnavailableReason, openBrowser, receiveAuthorizationCode } from './callback.js';
|
|
8
10
|
const tokenDigest = (token) => token === undefined ? '' : createHash('sha256').update(token).digest('hex');
|
|
@@ -110,6 +112,8 @@ export class AuthManager {
|
|
|
110
112
|
store;
|
|
111
113
|
fetch;
|
|
112
114
|
keys;
|
|
115
|
+
lifecycle;
|
|
116
|
+
identity;
|
|
113
117
|
journal;
|
|
114
118
|
unsaved;
|
|
115
119
|
unsavedIsShared = false;
|
|
@@ -118,15 +122,20 @@ export class AuthManager {
|
|
|
118
122
|
this.options = options;
|
|
119
123
|
validateAuthConfiguration(options.config);
|
|
120
124
|
this.config = { ...options.config };
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
const defaultHome = process.env.ANDORRACODE_HOME || join(homedir(), '.andorracode');
|
|
126
|
+
const home = options.home ?? defaultHome;
|
|
127
|
+
const environment = resolve(home) === resolve(defaultHome) ? process.env : { ...process.env, ANDORRACODE_HOME: home };
|
|
128
|
+
this.identity = credentialIdentity(this.config, environment);
|
|
129
|
+
this.store = options.store ?? createCredentialStore(this.identity, environment);
|
|
130
|
+
this.lifecycle = new AuthLifecycle(home, credentialScope(this.identity));
|
|
131
|
+
this.journal = options.journal ?? (options.store ? undefined : createCredentialJournal(this.identity, environment));
|
|
123
132
|
this.fetch = options.fetch ?? globalThis.fetch;
|
|
124
133
|
this.keys = createRemoteJWKSet(new URL(`${this.config.issuer}/.well-known/jwks.json`), { timeoutDuration: 5000, [customFetch]: (url, init) => this.fetch(url, init) });
|
|
125
134
|
}
|
|
126
135
|
locked(operation, signal) { return withAuthLock(operation, signal, this.options.lockPort, AUTH_LOCK_WAIT_MS); }
|
|
127
|
-
async read() {
|
|
128
|
-
const text = await this.store.read();
|
|
129
|
-
if (
|
|
136
|
+
async read(forState = false) {
|
|
137
|
+
const text = await (forState && this.store.readForState ? this.store.readForState() : this.store.read());
|
|
138
|
+
if (text === undefined)
|
|
130
139
|
return { version: 1, generation: randomUUID() };
|
|
131
140
|
try {
|
|
132
141
|
const value = JSON.parse(text);
|
|
@@ -275,6 +284,9 @@ export class AuthManager {
|
|
|
275
284
|
}
|
|
276
285
|
replacedToken = current.session?.refreshToken;
|
|
277
286
|
await this.forget();
|
|
287
|
+
// Commit/rollback is settled before retiring logout state. Cleanup failure must not revoke
|
|
288
|
+
// the newly committed token; a stale marker has no authority beside a usable session.
|
|
289
|
+
await this.lifecycle.retire().catch(() => { });
|
|
278
290
|
}, signal);
|
|
279
291
|
}
|
|
280
292
|
catch (error) {
|
|
@@ -317,7 +329,8 @@ export class AuthManager {
|
|
|
317
329
|
throw new AuthError('cancelled', 'Authentication cancelled.');
|
|
318
330
|
const journalled = (await this.journalled())?.session.refreshToken;
|
|
319
331
|
const unsaved = this.unsaved?.session.refreshToken;
|
|
320
|
-
|
|
332
|
+
const generation = randomUUID();
|
|
333
|
+
await this.store.clear(JSON.stringify({ version: 1, generation, deliberateSignOut: true }));
|
|
321
334
|
this.unsaved = undefined;
|
|
322
335
|
let cleanup;
|
|
323
336
|
try {
|
|
@@ -327,11 +340,17 @@ export class AuthManager {
|
|
|
327
340
|
cleanup = error;
|
|
328
341
|
}
|
|
329
342
|
const own = [...new Set([token, previous, journalled, unsaved].filter((value) => Boolean(value)))];
|
|
343
|
+
try {
|
|
344
|
+
await this.lifecycle.recordSignOut(generation);
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
cleanup ??= error;
|
|
348
|
+
}
|
|
330
349
|
if (!options.everywhere)
|
|
331
350
|
return { own, cleanup };
|
|
332
351
|
let others;
|
|
333
352
|
try {
|
|
334
|
-
others = await abortable((this.options.otherSignIns ?? otherKeyringSignIns)(credentialScope(
|
|
353
|
+
others = await abortable((this.options.otherSignIns ?? otherKeyringSignIns)(credentialScope(this.identity)), signal);
|
|
335
354
|
}
|
|
336
355
|
catch (failure) {
|
|
337
356
|
if (signal?.aborted || (failure instanceof AuthError && failure.code === 'cancelled'))
|
|
@@ -467,10 +486,10 @@ export class AuthManager {
|
|
|
467
486
|
await persist(next);
|
|
468
487
|
return next;
|
|
469
488
|
}
|
|
470
|
-
async current(signal) {
|
|
489
|
+
async current(signal, persist = true, forState = false) {
|
|
471
490
|
let stored;
|
|
472
491
|
try {
|
|
473
|
-
stored = await abortable(this.read(), signal);
|
|
492
|
+
stored = await abortable(this.read(forState), signal);
|
|
474
493
|
}
|
|
475
494
|
catch (error) {
|
|
476
495
|
if (signal?.aborted || !(error instanceof AuthError && error.code === 'storage') || !(await this.pending()))
|
|
@@ -480,10 +499,13 @@ export class AuthManager {
|
|
|
480
499
|
if (!pending)
|
|
481
500
|
return stored;
|
|
482
501
|
if (stored && (stored.generation !== pending.generation || tokenDigest(stored.session?.refreshToken) !== pending.replaces)) {
|
|
483
|
-
|
|
502
|
+
if (persist)
|
|
503
|
+
await this.forget();
|
|
484
504
|
return stored;
|
|
485
505
|
}
|
|
486
506
|
const recovered = { version: 1, generation: pending.generation, session: pending.session };
|
|
507
|
+
if (!persist)
|
|
508
|
+
return recovered; // Display-only reads must never repair credential storage.
|
|
487
509
|
try {
|
|
488
510
|
await this.store.write(JSON.stringify(recovered));
|
|
489
511
|
await this.forget();
|
|
@@ -594,7 +616,28 @@ export class AuthManager {
|
|
|
594
616
|
async credential(signal) {
|
|
595
617
|
return this.locked(() => this.tokenAndSubject(signal), signal);
|
|
596
618
|
}
|
|
597
|
-
|
|
598
|
-
|
|
619
|
+
/** Necessary auth lifecycle state, not an analytics preference. Outages never manufacture logout. */
|
|
620
|
+
async deliberatelySignedOut(signal) {
|
|
621
|
+
return this.locked(async () => { const value = await this.current(signal, false, true); return !value.session && (value.deliberateSignOut === true || await abortable(this.lifecycle.signedOut(), signal)); }, signal);
|
|
622
|
+
}
|
|
623
|
+
/** No network, preference or recovery writes. Legacy empty stores are known signed out, too. */
|
|
624
|
+
async state(signal) {
|
|
625
|
+
try {
|
|
626
|
+
return await this.locked(async () => {
|
|
627
|
+
const value = await this.current(signal, false, true);
|
|
628
|
+
if (value.session && value.session.refreshExpiresAt > Date.now())
|
|
629
|
+
return { state: 'signed-in', subject: value.session.subject };
|
|
630
|
+
const deliberate = value.deliberateSignOut === true || await abortable(this.lifecycle.signedOut(), signal);
|
|
631
|
+
return { state: 'signed-out', deliberate };
|
|
632
|
+
}, signal);
|
|
633
|
+
}
|
|
634
|
+
catch (error) {
|
|
635
|
+
if (signal?.aborted || (error instanceof AuthError && error.code === 'cancelled'))
|
|
636
|
+
throw error;
|
|
637
|
+
return { state: 'unavailable' };
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
async status(signal, options = {}) {
|
|
641
|
+
return this.locked(async () => { const session = (await this.current(signal, !options.readOnly)).session; return session && session.refreshExpiresAt > Date.now() ? { signedIn: true, subject: session.subject, expiresAt: session.expiresAt } : { signedIn: false }; }, signal);
|
|
599
642
|
}
|
|
600
643
|
}
|
package/dist/src/auth/index.d.ts
CHANGED
|
@@ -21,4 +21,8 @@ export declare const getCredential: (signal?: AbortSignal) => Promise<{
|
|
|
21
21
|
token: string;
|
|
22
22
|
subject: string;
|
|
23
23
|
}>;
|
|
24
|
-
export declare const
|
|
24
|
+
export declare const wasDeliberatelySignedOut: () => Promise<boolean>;
|
|
25
|
+
export declare const getAuthState: (signal?: AbortSignal, home?: string) => Promise<import("./types.js").AuthState>;
|
|
26
|
+
export declare const getAuthStatus: (signal?: AbortSignal, options?: {
|
|
27
|
+
readOnly?: boolean;
|
|
28
|
+
}) => Promise<import("./types.js").AuthStatus>;
|
package/dist/src/auth/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AUTH_DEPLOYMENT } from './deployment.js';
|
|
2
2
|
import { AuthManager } from './AuthManager.js';
|
|
3
|
+
import { resolve, join } from 'node:path';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
3
5
|
export * from './types.js';
|
|
4
6
|
export { AuthManager, AUTH_REFRESH_BUDGET_MS } from './AuthManager.js';
|
|
5
7
|
export { credentialIdentity } from './AuthManager.js';
|
|
@@ -13,4 +15,9 @@ export const login = (options = {}) => auth().login(options);
|
|
|
13
15
|
export const logout = (signal, options) => auth().logout(signal, options);
|
|
14
16
|
export const getAccessToken = (signal) => auth().getAccessToken(signal);
|
|
15
17
|
export const getCredential = (signal) => auth().credential(signal);
|
|
16
|
-
export const
|
|
18
|
+
export const wasDeliberatelySignedOut = () => auth().deliberatelySignedOut();
|
|
19
|
+
export const getAuthState = (signal, home) => {
|
|
20
|
+
const currentHome = process.env.ANDORRACODE_HOME || join(homedir(), '.andorracode');
|
|
21
|
+
return (!home || resolve(home) === resolve(currentHome) ? auth() : new AuthManager({ config: getAuthConfiguration(), home })).state(signal);
|
|
22
|
+
};
|
|
23
|
+
export const getAuthStatus = (signal, options) => auth().status(signal, options);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Non-secret state, independent of the keyring's deliberately ephemeral token-free envelope.
|
|
2
|
+
* All mutations run inside AuthManager's existing cross-process lifecycle lock. The configured
|
|
3
|
+
* root may itself be a link; entries below it must be private, owned and never links. */
|
|
4
|
+
export declare class AuthLifecycle {
|
|
5
|
+
private readonly home;
|
|
6
|
+
private readonly scope;
|
|
7
|
+
constructor(home: string, scope: string);
|
|
8
|
+
private path;
|
|
9
|
+
private privateOwner;
|
|
10
|
+
signedOut(): Promise<boolean>;
|
|
11
|
+
recordSignOut(generation: string): Promise<void>;
|
|
12
|
+
retire(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { constants } from 'node:fs';
|
|
2
|
+
import { lstat, mkdir, open, rename, unlink } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
import { AuthError } from './types.js';
|
|
6
|
+
/** Non-secret state, independent of the keyring's deliberately ephemeral token-free envelope.
|
|
7
|
+
* All mutations run inside AuthManager's existing cross-process lifecycle lock. The configured
|
|
8
|
+
* root may itself be a link; entries below it must be private, owned and never links. */
|
|
9
|
+
export class AuthLifecycle {
|
|
10
|
+
home;
|
|
11
|
+
scope;
|
|
12
|
+
constructor(home, scope) {
|
|
13
|
+
this.home = home;
|
|
14
|
+
this.scope = scope;
|
|
15
|
+
}
|
|
16
|
+
async path(create = false) {
|
|
17
|
+
if (create)
|
|
18
|
+
await mkdir(this.home, { recursive: true, mode: 0o700 });
|
|
19
|
+
const directory = join(this.home, 'auth');
|
|
20
|
+
if (create)
|
|
21
|
+
await mkdir(directory, { mode: 0o700 }).catch(error => { if (error.code !== 'EEXIST')
|
|
22
|
+
throw error; });
|
|
23
|
+
const info = await lstat(directory);
|
|
24
|
+
if (!info.isDirectory() || info.isSymbolicLink() || !this.privateOwner(info))
|
|
25
|
+
throw new Error('Unsafe auth lifecycle directory');
|
|
26
|
+
return join(directory, `signed-out-${this.scope}.json`);
|
|
27
|
+
}
|
|
28
|
+
privateOwner(info) {
|
|
29
|
+
return process.platform === 'win32' || ((info.mode & 0o077) === 0 && (!process.getuid || info.uid === process.getuid()));
|
|
30
|
+
}
|
|
31
|
+
async signedOut() {
|
|
32
|
+
try {
|
|
33
|
+
const path = await this.path();
|
|
34
|
+
const entry = await lstat(path);
|
|
35
|
+
if (!entry.isFile() || entry.isSymbolicLink())
|
|
36
|
+
throw new Error('Unsafe auth lifecycle entry');
|
|
37
|
+
const file = await open(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
38
|
+
try {
|
|
39
|
+
const info = await file.stat();
|
|
40
|
+
if (!info.isFile() || !this.privateOwner(info) || info.size > 1024)
|
|
41
|
+
throw new Error('Invalid auth lifecycle entry');
|
|
42
|
+
const buffer = Buffer.alloc(1025);
|
|
43
|
+
let bytesRead = 0;
|
|
44
|
+
for (;;) {
|
|
45
|
+
const part = await file.read(buffer, bytesRead, buffer.length - bytesRead, null);
|
|
46
|
+
bytesRead += part.bytesRead;
|
|
47
|
+
if (!part.bytesRead || bytesRead > 1024)
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
if (bytesRead > 1024)
|
|
51
|
+
throw new Error('Invalid auth lifecycle entry');
|
|
52
|
+
const value = JSON.parse(buffer.subarray(0, bytesRead).toString('utf8'));
|
|
53
|
+
if (value.version !== 1 || value.scope !== this.scope || typeof value.generation !== 'string' || !value.generation || value.generation.length > 100 || value.event !== 'signed-out')
|
|
54
|
+
throw new Error('Invalid auth lifecycle entry');
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
await file.close();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (error.code === 'ENOENT')
|
|
63
|
+
return false;
|
|
64
|
+
throw new AuthError('storage', 'Unable to read the non-secret sign-out state. Check the installation auth directory.', { cause: error });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async recordSignOut(generation) {
|
|
68
|
+
let temporary;
|
|
69
|
+
try {
|
|
70
|
+
const path = await this.path(true);
|
|
71
|
+
temporary = `${path}.${randomUUID()}.tmp`;
|
|
72
|
+
const file = await open(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | (constants.O_NOFOLLOW ?? 0), 0o600);
|
|
73
|
+
try {
|
|
74
|
+
await file.writeFile(JSON.stringify({ version: 1, scope: this.scope, generation, event: 'signed-out' }) + '\n');
|
|
75
|
+
await file.sync();
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
await file.close();
|
|
79
|
+
}
|
|
80
|
+
// rename replaces the entry, never its link target. No credentials or account subject here.
|
|
81
|
+
await rename(temporary, path);
|
|
82
|
+
if (process.platform !== 'win32') {
|
|
83
|
+
const directory = await open(join(this.home, 'auth'), constants.O_RDONLY);
|
|
84
|
+
try {
|
|
85
|
+
await directory.sync();
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
await directory.close();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
throw new AuthError('storage', 'Credentials cleared, but the non-secret sign-out state could not be saved. Retry logout.', { cause: error });
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
if (temporary)
|
|
97
|
+
await unlink(temporary).catch(() => { });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async retire() {
|
|
101
|
+
try {
|
|
102
|
+
await unlink(await this.path());
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (error.code !== 'ENOENT')
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
package/dist/src/auth/store.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ export declare class FallbackCredentialStore implements CredentialStore {
|
|
|
65
65
|
private keyringOr;
|
|
66
66
|
private clearReachableKeyring;
|
|
67
67
|
read(): Promise<string | undefined>;
|
|
68
|
+
readForState(): Promise<string | undefined>;
|
|
68
69
|
write(value: string): Promise<void>;
|
|
69
70
|
previous(): Promise<string | undefined>;
|
|
70
71
|
clear(tombstone: string): Promise<void>;
|
package/dist/src/auth/store.js
CHANGED
|
@@ -289,6 +289,18 @@ export class FallbackCredentialStore {
|
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
read() { return this.keyringOr(store => store.read()); }
|
|
292
|
+
async readForState() {
|
|
293
|
+
if (await this.useFile())
|
|
294
|
+
return this.file.read();
|
|
295
|
+
try {
|
|
296
|
+
return await this.keyring.read();
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
if (this.mode !== 'auto' || !this.fallback || !(error instanceof KeyringAbsentError) || error instanceof KeyringUnreachableError)
|
|
300
|
+
throw error;
|
|
301
|
+
return this.file.read();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
292
304
|
write(value) { return this.keyringOr(store => store.write(value)); }
|
|
293
305
|
async previous() {
|
|
294
306
|
const inactive = await this.useFile() ? this.keyring : this.file;
|
package/dist/src/auth/types.d.ts
CHANGED
|
@@ -17,6 +17,16 @@ export interface AuthStatus {
|
|
|
17
17
|
expiresAt?: number;
|
|
18
18
|
storage?: CredentialLocation;
|
|
19
19
|
}
|
|
20
|
+
/** Read-only lifecycle authority. Missing identity is NOT evidence of an empty credential store. */
|
|
21
|
+
export type AuthState = {
|
|
22
|
+
state: 'signed-in';
|
|
23
|
+
subject: string;
|
|
24
|
+
} | {
|
|
25
|
+
state: 'signed-out';
|
|
26
|
+
deliberate: boolean;
|
|
27
|
+
} | {
|
|
28
|
+
state: 'unavailable';
|
|
29
|
+
};
|
|
20
30
|
export declare class AuthError extends Error {
|
|
21
31
|
readonly code: 'configuration' | 'storage' | 'busy' | 'cancelled' | 'callback' | 'network' | 'invalid_token' | 'login_required' | 'superseded';
|
|
22
32
|
constructor(code: 'configuration' | 'storage' | 'busy' | 'cancelled' | 'callback' | 'network' | 'invalid_token' | 'login_required' | 'superseded', message: string, options?: {
|
|
@@ -25,6 +35,8 @@ export declare class AuthError extends Error {
|
|
|
25
35
|
}
|
|
26
36
|
export interface CredentialStore {
|
|
27
37
|
read(): Promise<string | undefined>;
|
|
38
|
+
/** Like read, but a locked/unreachable keyring must not masquerade as an empty fallback file. */
|
|
39
|
+
readForState?(): Promise<string | undefined>;
|
|
28
40
|
write(value: string): Promise<void>;
|
|
29
41
|
clear(tombstone: string): Promise<void>;
|
|
30
42
|
location?(): Promise<CredentialLocation>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import { requireLegalAcceptance } from './legal/gate.js';
|
|
2
3
|
import { fileURLToPath } from 'node:url';
|
|
3
4
|
import { createInterface } from 'node:readline';
|
|
4
5
|
import { resolve } from 'node:path';
|
|
@@ -19,6 +20,7 @@ export function automationRunContext(job) {
|
|
|
19
20
|
}
|
|
20
21
|
export async function executeAutomation(job, signal, directory = configDirectory()) {
|
|
21
22
|
signal.throwIfAborted();
|
|
23
|
+
await requireLegalAcceptance(directory);
|
|
22
24
|
directory = resolve(directory);
|
|
23
25
|
const cli = fileURLToPath(new URL('./cli.js', import.meta.url));
|
|
24
26
|
const child = spawn(process.execPath, [cli, 'app-server', '--stdio'], {
|
|
@@ -140,13 +140,18 @@ export function upgradedAutomationTaskXml(task, directory, node, cli) {
|
|
|
140
140
|
|| win32.basename(oldNode).toLowerCase() !== 'node.exe'
|
|
141
141
|
|| win32.basename(win32.dirname(oldRoot)).toLowerCase() !== 'engine')
|
|
142
142
|
return;
|
|
143
|
+
// When moving to a bundle, only retarget a task from the same Desktop installation.
|
|
144
|
+
const newEngine = win32.dirname(newRoot);
|
|
145
|
+
if (win32.basename(newEngine).toLowerCase() === 'engine'
|
|
146
|
+
&& windowsPath(win32.dirname(oldRoot)) !== windowsPath(newEngine))
|
|
147
|
+
return;
|
|
143
148
|
const oldArgs = [win32.join(oldRoot, 'dist', 'src', 'cli.js'), 'automations', 'serve', '--home', resolve(directory)].map(windowsArgument).join(' ');
|
|
144
149
|
const comparableArgs = (value) => value.replaceAll('\\\\?\\', '').toLowerCase();
|
|
145
150
|
if (comparableArgs(unxml(argumentsFields[0][1])) !== comparableArgs(oldArgs))
|
|
146
151
|
return;
|
|
147
152
|
const args = [cli, 'automations', 'serve', '--home', resolve(directory)].map(windowsArgument).join(' ');
|
|
148
|
-
return task.replace(commands[0][0], `<Command>${xml(node)}</Command>`)
|
|
149
|
-
.replace(argumentsFields[0][0], `<Arguments>${xml(args)}</Arguments>`);
|
|
153
|
+
return task.replace(commands[0][0], () => `<Command>${xml(node)}</Command>`)
|
|
154
|
+
.replace(argumentsFields[0][0], () => `<Arguments>${xml(args)}</Arguments>`);
|
|
150
155
|
}
|
|
151
156
|
export async function reconcileAutomationService(directory = configDirectory(), host = {
|
|
152
157
|
platform: process.platform,
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type ModelScore, type PoolEffort } from './efficiency.js';
|
|
2
|
+
/**
|
|
3
|
+
* Model scores from published benchmarks, for routing. A model's score is the average of three providers'
|
|
4
|
+
* general-purpose scores: the Artificial Analysis Intelligence Index, the LiveBench overall score and the LMArena
|
|
5
|
+
* overall text rating. The three use different scales, so LiveBench and LMArena are first fitted onto the
|
|
6
|
+
* Intelligence Index scale (a straight line through the models both list), which is the scale the routing class
|
|
7
|
+
* scores are written on. Cost is the Intelligence Index cost per task, in US cents.
|
|
8
|
+
*/
|
|
9
|
+
export type BenchmarkId = 'artificial-analysis' | 'livebench' | 'lmarena';
|
|
10
|
+
export declare const BENCHMARK_NAMES: Readonly<Record<BenchmarkId, string>>;
|
|
11
|
+
/** The benchmark whose scale the average is expressed on. Without it there are no scores. */
|
|
12
|
+
export declare const REFERENCE_BENCHMARK: BenchmarkId;
|
|
13
|
+
/** One listed model, at one thinking level when the benchmark names one. */
|
|
14
|
+
export interface BenchmarkEntry {
|
|
15
|
+
key: string;
|
|
16
|
+
effort?: PoolEffort;
|
|
17
|
+
score: number;
|
|
18
|
+
cost?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface Benchmark {
|
|
21
|
+
id: BenchmarkId;
|
|
22
|
+
entries: BenchmarkEntry[];
|
|
23
|
+
}
|
|
24
|
+
/** What one benchmark contributed to a refresh. */
|
|
25
|
+
export interface BenchmarkReport {
|
|
26
|
+
id: BenchmarkId;
|
|
27
|
+
name: string;
|
|
28
|
+
listed: number;
|
|
29
|
+
used: boolean;
|
|
30
|
+
common?: number;
|
|
31
|
+
reason?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface BenchmarkReading {
|
|
34
|
+
benchmarks: Benchmark[];
|
|
35
|
+
failed: BenchmarkReport[];
|
|
36
|
+
}
|
|
37
|
+
export interface BenchmarkSubject {
|
|
38
|
+
provider: string;
|
|
39
|
+
model: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
efforts: readonly PoolEffort[];
|
|
42
|
+
}
|
|
43
|
+
/** A model name as every source can be compared: no provider prefix, no trailing date, letters and digits only. */
|
|
44
|
+
export declare function modelKey(name: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* The model and thinking level in a leaderboard name such as "GPT-6.2 Astra (Xhigh)". A name whose brackets hold
|
|
47
|
+
* anything but a level, a date or a size is another variant of the model and is left out.
|
|
48
|
+
*/
|
|
49
|
+
export declare function listedModel(name: string): {
|
|
50
|
+
key: string;
|
|
51
|
+
effort?: PoolEffort;
|
|
52
|
+
} | undefined;
|
|
53
|
+
/** The models in the Artificial Analysis leaderboard page, which carries its table as data inside the page. */
|
|
54
|
+
export declare function parseArtificialAnalysis(html: string): BenchmarkEntry[];
|
|
55
|
+
/** The models in a LiveBench release table. The overall score is the weighted mean of the categories, as the site computes it. */
|
|
56
|
+
export declare function parseLiveBench(table: string, categories: string, costs?: string): BenchmarkEntry[];
|
|
57
|
+
/** The models in LMArena's leaderboard rows, from the overall category only. */
|
|
58
|
+
export declare function parseLmArena(rows: readonly unknown[]): BenchmarkEntry[];
|
|
59
|
+
/**
|
|
60
|
+
* The straight line that turns a benchmark's scores into reference scores: over the entries both list, it gives the
|
|
61
|
+
* benchmark the reference's mean and spread. (A least-squares line would pull every score toward the middle wherever
|
|
62
|
+
* the two disagree.) Undefined when too few are shared or the two do not rise together.
|
|
63
|
+
*/
|
|
64
|
+
export declare function fitToReference(source: readonly BenchmarkEntry[], reference: readonly BenchmarkEntry[]): {
|
|
65
|
+
slope: number;
|
|
66
|
+
intercept: number;
|
|
67
|
+
common: number;
|
|
68
|
+
} | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Scores for the subjects the benchmarks list, keyed `provider/model`. A model the reference does not price takes its
|
|
71
|
+
* cost from another benchmark, converted to the reference's unit. A model's score is the mean over the
|
|
72
|
+
* benchmarks that list it; a thinking level is scored on its own when at least one benchmark lists that level, and a
|
|
73
|
+
* benchmark that does not list the level contributes its score for the model.
|
|
74
|
+
*/
|
|
75
|
+
export declare function benchmarkScores(subjects: readonly BenchmarkSubject[], benchmarks: readonly Benchmark[]): {
|
|
76
|
+
scores: Record<string, ModelScore>;
|
|
77
|
+
report: BenchmarkReport[];
|
|
78
|
+
};
|
|
79
|
+
export type BenchmarkFetcher = (url: string, init: {
|
|
80
|
+
signal: AbortSignal;
|
|
81
|
+
headers: Record<string, string>;
|
|
82
|
+
}) => Promise<{
|
|
83
|
+
ok: boolean;
|
|
84
|
+
status: number;
|
|
85
|
+
text(): Promise<string>;
|
|
86
|
+
}>;
|
|
87
|
+
/** Read the three benchmarks. One that cannot be read is reported in `failed` and never fails the others. */
|
|
88
|
+
export declare function readBenchmarks(signal: AbortSignal, fetcher?: BenchmarkFetcher): Promise<BenchmarkReading>;
|