@andorra-labs/code 0.1.13 → 0.1.15
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 +4 -1
- package/dist/src/acp-agent.d.ts +54 -0
- package/dist/src/acp-agent.js +991 -0
- package/dist/src/agent-execution.js +304 -140
- package/dist/src/agent-mcp-catalog.js +2 -0
- package/dist/src/agent-mcp.d.ts +2 -0
- package/dist/src/agent-mcp.js +86 -4
- package/dist/src/andorra/endpoint.d.ts +7 -0
- package/dist/src/andorra/endpoint.js +46 -0
- package/dist/src/andorra/entry.d.ts +21 -0
- package/dist/src/andorra/entry.js +118 -0
- package/dist/src/andorra/errors.d.ts +2 -0
- package/dist/src/andorra/errors.js +39 -0
- package/dist/src/andorra/hosted.d.ts +55 -0
- package/dist/src/andorra/hosted.js +130 -0
- package/dist/src/andorra/monitor.d.ts +151 -0
- package/dist/src/andorra/monitor.js +393 -0
- package/dist/src/andorra/notices.d.ts +16 -0
- package/dist/src/andorra/notices.js +38 -0
- package/dist/src/andorra/opt-in.d.ts +58 -0
- package/dist/src/andorra/opt-in.js +112 -0
- package/dist/src/andorra/request-watch.d.ts +6 -0
- package/dist/src/andorra/request-watch.js +10 -0
- package/dist/src/andorra/state.d.ts +86 -0
- package/dist/src/andorra/state.js +238 -0
- package/dist/src/andorra/terminal.d.ts +70 -0
- package/dist/src/andorra/terminal.js +125 -0
- package/dist/src/andorra/usage-format.d.ts +9 -0
- package/dist/src/andorra/usage-format.js +19 -0
- package/dist/src/anthropic-credentials.js +9 -1
- package/dist/src/app-server/protocol.d.ts +10 -2
- package/dist/src/app-server/protocol.js +1 -1
- package/dist/src/app-server/workspace.d.ts +1 -0
- package/dist/src/app-server/workspace.js +141 -10
- package/dist/src/app-server.d.ts +35 -0
- package/dist/src/app-server.js +377 -124
- package/dist/src/auth/AuthManager.d.ts +9 -0
- package/dist/src/auth/AuthManager.js +164 -24
- package/dist/src/auth/deployment.d.ts +1 -0
- package/dist/src/auth/deployment.js +1 -0
- package/dist/src/auth/index.d.ts +1 -1
- package/dist/src/auth/index.js +1 -1
- package/dist/src/auth/store.d.ts +26 -0
- package/dist/src/auth/store.js +34 -1
- package/dist/src/browser-bridge.d.ts +1 -0
- package/dist/src/browser-bridge.js +5 -2
- package/dist/src/browser-external-app.d.ts +27 -0
- package/dist/src/browser-external-app.js +60 -0
- package/dist/src/browser-panel-tool.d.ts +6 -0
- package/dist/src/browser-panel-tool.js +36 -0
- package/dist/src/browser-runner.js +1 -1
- package/dist/src/browser-server.d.ts +5 -0
- package/dist/src/browser-server.js +27 -3
- package/dist/src/browser-stealth.d.ts +19 -1
- package/dist/src/browser-stealth.js +23 -3
- package/dist/src/browser-ui/tokens.css +4 -4
- package/dist/src/browser-view.d.ts +81 -0
- package/dist/src/browser-view.js +289 -18
- package/dist/src/bug-report.d.ts +81 -0
- package/dist/src/bug-report.js +235 -0
- package/dist/src/claude-provider.d.ts +2 -1
- package/dist/src/claude-provider.js +10 -8
- package/dist/src/cli-sign-in.d.ts +3 -1
- package/dist/src/cli-sign-in.js +4 -1
- package/dist/src/cli.js +205 -58
- package/dist/src/coding-tools.js +7 -7
- package/dist/src/command-screens.d.ts +26 -3
- package/dist/src/command-screens.js +323 -85
- package/dist/src/commands.d.ts +7 -1
- package/dist/src/commands.js +79 -27
- package/dist/src/completion-gates.d.ts +22 -0
- package/dist/src/completion-gates.js +11 -0
- package/dist/src/config.d.ts +11 -1
- package/dist/src/config.js +134 -3
- package/dist/src/dashboard-view.d.ts +2 -0
- package/dist/src/dashboard-view.js +11 -2
- package/dist/src/decision/PreparedSteps.js +1 -1
- package/dist/src/decision/applyToolMenu.js +1 -1
- package/dist/src/decision/toolFamilies.js +1 -1
- package/dist/src/decision/types.d.ts +1 -0
- package/dist/src/google-provider.d.ts +31 -0
- package/dist/src/google-provider.js +153 -0
- package/dist/src/graph-health.d.ts +11 -0
- package/dist/src/graph-health.js +36 -4
- package/dist/src/graph-manager-chat.d.ts +33 -0
- package/dist/src/graph-manager-chat.js +165 -6
- package/dist/src/graph-runner.js +27 -0
- package/dist/src/graph-selection.js +2 -1
- package/dist/src/graph-sync.d.ts +1 -0
- package/dist/src/graph-sync.js +93 -34
- package/dist/src/graph-tool.d.ts +2 -0
- package/dist/src/graph-tool.js +2 -2
- package/dist/src/graph-ui/app.js +92 -10
- package/dist/src/graph-ui/edge-router.js +121 -53
- package/dist/src/graph-ui/manager.js +40 -5
- package/dist/src/graph-ui/style.css +5 -2
- package/dist/src/graph-ui/tokens.css +4 -4
- package/dist/src/graph-visibility.d.ts +31 -0
- package/dist/src/graph-visibility.js +102 -0
- package/dist/src/graphs.js +1 -3
- package/dist/src/hardened-runtime.js +1 -1
- package/dist/src/live-model.d.ts +24 -0
- package/dist/src/live-model.js +37 -0
- package/dist/src/managed-sign-in.d.ts +1 -0
- package/dist/src/managed-sign-in.js +13 -0
- package/dist/src/membership-errors.d.ts +2 -0
- package/dist/src/membership-errors.js +6 -2
- package/dist/src/membership.d.ts +13 -2
- package/dist/src/membership.js +39 -8
- package/dist/src/model-context-windows.d.ts +2 -0
- package/dist/src/model-context-windows.js +24 -0
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +1 -0
- package/dist/src/model-metadata.js +47 -3
- package/dist/src/paged-transcript.d.ts +2 -0
- package/dist/src/paged-transcript.js +16 -0
- package/dist/src/palette.d.ts +1 -0
- package/dist/src/palette.js +1 -1
- package/dist/src/permissions.js +17 -4
- package/dist/src/provider-connection.js +32 -0
- package/dist/src/provider-engine.d.ts +5 -0
- package/dist/src/provider-engine.js +3 -3
- package/dist/src/provider-import.js +3 -1
- package/dist/src/provider-settings.d.ts +16 -1
- package/dist/src/provider-settings.js +50 -22
- package/dist/src/providers.d.ts +29 -3
- package/dist/src/providers.js +100 -18
- package/dist/src/react-runtime.js +33 -12
- package/dist/src/read-document-tool.d.ts +2 -0
- package/dist/src/read-document-tool.js +6 -6
- package/dist/src/remote/engine-pool.js +31 -6
- package/dist/src/run-control.d.ts +2 -2
- package/dist/src/run-control.js +9 -6
- package/dist/src/runtime-environment.d.ts +1 -0
- package/dist/src/runtime-environment.js +13 -0
- package/dist/src/runtime.d.ts +2 -0
- package/dist/src/runtime.js +2 -1
- package/dist/src/save-lock.js +14 -7
- package/dist/src/session-title.d.ts +3 -0
- package/dist/src/session-title.js +5 -2
- package/dist/src/sessions.d.ts +1 -0
- package/dist/src/sessions.js +4 -2
- package/dist/src/sign-in-detection.d.ts +1 -1
- package/dist/src/sign-in-detection.js +10 -3
- 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 +80 -0
- package/dist/src/skills/bundled/graph-manager/SKILL.md +9 -1
- package/dist/src/skills/bundled/graph-manager/errors.md +2 -1
- package/dist/src/skills/bundled/provenance.json +743 -738
- package/dist/src/skills/runtime-skills.js +1 -0
- package/dist/src/subagent-run.d.ts +2 -0
- package/dist/src/subagent-run.js +14 -3
- package/dist/src/telemetry/schema.d.ts +1 -1
- package/dist/src/telemetry/schema.js +2 -2
- package/dist/src/telemetry/uploader.d.ts +7 -1
- package/dist/src/telemetry/uploader.js +11 -2
- package/dist/src/terminal-links.d.ts +16 -0
- package/dist/src/terminal-links.js +113 -0
- package/dist/src/terminal-ui.d.ts +29 -1
- package/dist/src/terminal-ui.js +113 -24
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/trajectory.js +6 -1
- package/dist/src/transcript.d.ts +2 -0
- package/dist/src/transcript.js +5 -1
- package/dist/src/types.d.ts +5 -0
- package/dist/src/workspace-instructions.js +1 -1
- package/package.json +13 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function usageTone(usedPercent) {
|
|
2
|
+
return usedPercent >= 100 ? 'full' : usedPercent >= 80 ? 'warn' : 'ok';
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* The last minute of the allowance week in the local time zone (or `timeZone`), such as `Sun 11:59 PM`: the
|
|
6
|
+
* router's reset instant is the first minute of the next week, so one minute before it is the week's last.
|
|
7
|
+
* An instant that cannot be read gives an empty string.
|
|
8
|
+
*/
|
|
9
|
+
export function formatWeekReset(resetsAt, timeZone) {
|
|
10
|
+
const at = Date.parse(resetsAt);
|
|
11
|
+
if (!Number.isFinite(at))
|
|
12
|
+
return '';
|
|
13
|
+
const parts = new Intl.DateTimeFormat('en-US', { weekday: 'short', hour: 'numeric', minute: '2-digit', ...(timeZone === undefined ? {} : { timeZone }) })
|
|
14
|
+
.formatToParts(new Date(at - 60_000));
|
|
15
|
+
const weekday = parts.find(part => part.type === 'weekday')?.value ?? '';
|
|
16
|
+
// From the hour on, so the separator after the weekday is not kept; some ICU builds put a narrow space before AM/PM.
|
|
17
|
+
const time = parts.slice(parts.findIndex(part => part.type === 'hour')).map(part => part.value).join('').replace(/\s+/gu, ' ').trim();
|
|
18
|
+
return `${weekday} ${time}`;
|
|
19
|
+
}
|
|
@@ -2,7 +2,8 @@ import { readFile } from 'node:fs/promises';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { resolveCredentialsFromConfig } from '@anthropic-ai/sdk/lib/credentials';
|
|
4
4
|
import { configDirectory } from './config.js';
|
|
5
|
-
import { resolveProviderApiKey } from './providers.js';
|
|
5
|
+
import { assertProviderCredentials, resolveProviderApiKey } from './providers.js';
|
|
6
|
+
import { andorraAccessToken, ANDORRA_SIGN_IN_MESSAGE } from './andorra/endpoint.js';
|
|
6
7
|
export const ANTHROPIC_CONSOLE_BASE_URL = 'https://api.anthropic.com/v1';
|
|
7
8
|
const OAUTH_BETA = 'oauth-2025-04-20';
|
|
8
9
|
const PROFILE = 'default';
|
|
@@ -39,6 +40,13 @@ export function signInRequired(providerId) {
|
|
|
39
40
|
}
|
|
40
41
|
const REFRESH_FAILED = 'Your Claude Console sign-in expired or could not be refreshed. Sign in again.';
|
|
41
42
|
export async function providerAuthHeaders(provider, options = {}) {
|
|
43
|
+
if (provider.type === 'andorra') {
|
|
44
|
+
assertProviderCredentials(provider);
|
|
45
|
+
const token = await andorraAccessToken(options.signal);
|
|
46
|
+
if (!token)
|
|
47
|
+
throw new Error(ANDORRA_SIGN_IN_MESSAGE);
|
|
48
|
+
return { authorization: `Bearer ${token}` };
|
|
49
|
+
}
|
|
42
50
|
const anthropic = provider.type === 'anthropic';
|
|
43
51
|
const headers = anthropic ? { 'anthropic-version': '2023-06-01' } : {};
|
|
44
52
|
if (provider.anthropicAuth !== 'console') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const APP_SERVER_PROTOCOL_VERSION = 2;
|
|
2
|
-
export declare const APP_SERVER_CAPABILITIES: readonly ["run.start.runPermissions", "automations", "providers.models", "providers.test", "providers.test.model", "providers.streamIdleTimeout", "providers.modelContextWindows", "providers.name", "providers.claude", "providers.claudeAuth", "providers.grok", "providers.opencode", "providers.auth.submit", "providers.opencodeGo", "providers.discover.draft", "providers.detectSignIns", "providers.codexAuth", "providers.codexAuth.logout", "providers.codexAccounts", "providers.anthropicConsole", "run.resume.direction", "run.resume.model", "run.steer", "run.overrideAllNodes", "run.setModel", "run.setModel.node", "run.setPermissions", "run.start.continueSession", "run.start.entryHistory", "remote.owner.projects", "remote.workspaces.probe", "remote.engine.relay", "remote.hosting.device.grant", "extensions.manage", "extensions.resources", "skills.invoke", "mcp.manage", "mcp.edit", "mcp.status", "runs.files", "sessions.files", "account.profile", "sessions.stats", "sessions.usage", "config.analytics", "config.analytics.planGate", "sessions.trajectory", "config.externalSubagent", "config.codeIntel", "config.decisions", "browser.view", "attachments.read", "config.general", "sessions.pullRequest", "browser.view.go", "config.browser", "config.webSearch", "background.tasks", "workspace.warm", "browser.cookies.firefox", "browser.extensions", "sessions.compact", "sessions.goal", "sessions.changes", "run.current"];
|
|
2
|
+
export declare const APP_SERVER_CAPABILITIES: readonly ["run.start.runPermissions", "automations", "providers.models", "providers.test", "providers.test.model", "providers.streamIdleTimeout", "providers.modelContextWindows", "providers.name", "providers.claude", "providers.claudeAuth", "providers.grok", "providers.google", "providers.opencode", "providers.auth.submit", "providers.opencodeGo", "providers.discover.draft", "providers.detectSignIns", "providers.codexAuth", "providers.codexAuth.logout", "providers.codexAccounts", "providers.anthropicConsole", "run.resume.direction", "run.resume.model", "run.steer", "run.overrideAllNodes", "run.setModel", "run.setModel.node", "run.setPermissions", "run.start.continueSession", "run.start.entryHistory", "remote.owner.projects", "remote.workspaces.probe", "remote.engine.relay", "remote.hosting.device.grant", "extensions.manage", "extensions.resources", "skills.invoke", "mcp.manage", "mcp.edit", "mcp.status", "runs.files", "sessions.files", "account.profile", "sessions.stats", "sessions.usage", "config.analytics", "config.analytics.planGate", "sessions.trajectory", "config.externalSubagent", "config.codeIntel", "config.decisions", "browser.view", "attachments.read", "config.general", "sessions.pullRequest", "browser.view.go", "config.browser", "config.webSearch", "background.tasks", "workspace.warm", "browser.cookies.firefox", "browser.extensions", "sessions.compact", "sessions.goal", "sessions.changes", "run.current", "sessions.jev", "providers.andorra", "graphs.visibility"];
|
|
3
3
|
export interface AppServerRequest {
|
|
4
4
|
id: number | string;
|
|
5
5
|
method: string;
|
|
@@ -67,12 +67,18 @@ export interface AppServerProviderAuth {
|
|
|
67
67
|
}
|
|
68
68
|
export interface AppServerProvider {
|
|
69
69
|
id: string;
|
|
70
|
-
type: 'openai-compatible' | 'anthropic' | 'codex' | 'claude' | 'opencode-go' | 'grok' | 'opencode';
|
|
70
|
+
type: 'openai-compatible' | 'anthropic' | 'codex' | 'claude' | 'opencode-go' | 'grok' | 'opencode' | 'google' | 'andorra';
|
|
71
71
|
baseUrl: string;
|
|
72
72
|
model: string;
|
|
73
73
|
apiKeyEnv?: string;
|
|
74
74
|
models?: string[];
|
|
75
75
|
modelContextWindows?: Record<string, number>;
|
|
76
|
+
/** Andorra only: model id -> the router's display name. Labels only; ids stay the identity. */
|
|
77
|
+
modelNames?: Record<string, string>;
|
|
78
|
+
/** Andorra only: model id -> its size in billions of parameters, where the router states one. */
|
|
79
|
+
modelParameters?: Record<string, number>;
|
|
80
|
+
/** Andorra only: the model ids served free of the weekly allowance. */
|
|
81
|
+
freeModels?: string[];
|
|
76
82
|
hasApiKey: boolean;
|
|
77
83
|
apiKeyRevision?: string;
|
|
78
84
|
contextWindow?: number;
|
|
@@ -161,6 +167,7 @@ export interface AppServerAccount {
|
|
|
161
167
|
dailyDecisionLimit?: number;
|
|
162
168
|
dailyDecisionUsed?: number;
|
|
163
169
|
fairUse?: boolean;
|
|
170
|
+
unlimited?: boolean;
|
|
164
171
|
windowDays?: number;
|
|
165
172
|
windowDecisionLimit?: number;
|
|
166
173
|
windowDecisionUsed?: number;
|
|
@@ -305,6 +312,7 @@ export interface AppServerSessionSummary {
|
|
|
305
312
|
turns: number;
|
|
306
313
|
lastTask?: string;
|
|
307
314
|
archived?: boolean;
|
|
315
|
+
jevEnabled?: boolean;
|
|
308
316
|
lastTurnStatus?: AppServerTurnStatus;
|
|
309
317
|
timers?: AppServerTimerState[];
|
|
310
318
|
usage: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const APP_SERVER_PROTOCOL_VERSION = 2;
|
|
2
|
-
export const APP_SERVER_CAPABILITIES = ['run.start.runPermissions', 'automations', 'providers.models', 'providers.test', 'providers.test.model', 'providers.streamIdleTimeout', 'providers.modelContextWindows', 'providers.name', 'providers.claude', 'providers.claudeAuth', 'providers.grok', 'providers.opencode', 'providers.auth.submit', 'providers.opencodeGo', 'providers.discover.draft', 'providers.detectSignIns', 'providers.codexAuth', 'providers.codexAuth.logout', 'providers.codexAccounts', 'providers.anthropicConsole', 'run.resume.direction', 'run.resume.model', 'run.steer', 'run.overrideAllNodes', 'run.setModel', 'run.setModel.node', 'run.setPermissions', 'run.start.continueSession', 'run.start.entryHistory', 'remote.owner.projects', 'remote.workspaces.probe', 'remote.engine.relay', 'remote.hosting.device.grant', 'extensions.manage', 'extensions.resources', 'skills.invoke', 'mcp.manage', 'mcp.edit', 'mcp.status', 'runs.files', 'sessions.files', 'account.profile', 'sessions.stats', 'sessions.usage', 'config.analytics', 'config.analytics.planGate', 'sessions.trajectory', 'config.externalSubagent', 'config.codeIntel', 'config.decisions', 'browser.view', 'attachments.read', 'config.general', 'sessions.pullRequest', 'browser.view.go', 'config.browser', 'config.webSearch', 'background.tasks', 'workspace.warm', 'browser.cookies.firefox', 'browser.extensions', 'sessions.compact', 'sessions.goal', 'sessions.changes', 'run.current'];
|
|
2
|
+
export const APP_SERVER_CAPABILITIES = ['run.start.runPermissions', 'automations', 'providers.models', 'providers.test', 'providers.test.model', 'providers.streamIdleTimeout', 'providers.modelContextWindows', 'providers.name', 'providers.claude', 'providers.claudeAuth', 'providers.grok', 'providers.google', 'providers.opencode', 'providers.auth.submit', 'providers.opencodeGo', 'providers.discover.draft', 'providers.detectSignIns', 'providers.codexAuth', 'providers.codexAuth.logout', 'providers.codexAccounts', 'providers.anthropicConsole', 'run.resume.direction', 'run.resume.model', 'run.steer', 'run.overrideAllNodes', 'run.setModel', 'run.setModel.node', 'run.setPermissions', 'run.start.continueSession', 'run.start.entryHistory', 'remote.owner.projects', 'remote.workspaces.probe', 'remote.engine.relay', 'remote.hosting.device.grant', 'extensions.manage', 'extensions.resources', 'skills.invoke', 'mcp.manage', 'mcp.edit', 'mcp.status', 'runs.files', 'sessions.files', 'account.profile', 'sessions.stats', 'sessions.usage', 'config.analytics', 'config.analytics.planGate', 'sessions.trajectory', 'config.externalSubagent', 'config.codeIntel', 'config.decisions', 'browser.view', 'attachments.read', 'config.general', 'sessions.pullRequest', 'browser.view.go', 'config.browser', 'config.webSearch', 'background.tasks', 'workspace.warm', 'browser.cookies.firefox', 'browser.extensions', 'sessions.compact', 'sessions.goal', 'sessions.changes', 'run.current', 'sessions.jev', 'providers.andorra', 'graphs.visibility'];
|
|
@@ -47,6 +47,7 @@ export declare function readRun(directory: string, id: unknown): Promise<{
|
|
|
47
47
|
result: unknown;
|
|
48
48
|
events: unknown[];
|
|
49
49
|
truncated: boolean;
|
|
50
|
+
outline?: unknown[];
|
|
50
51
|
}>;
|
|
51
52
|
export declare function runRecordFile(directory: string, id: unknown): Promise<{
|
|
52
53
|
path: string;
|
|
@@ -457,38 +457,169 @@ async function readJournalTail(path, limit) {
|
|
|
457
457
|
if (byte === 0x0a)
|
|
458
458
|
newlines += 1;
|
|
459
459
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
if (position > 0)
|
|
463
|
-
|
|
464
|
-
|
|
460
|
+
let buffer = Buffer.concat(blocks);
|
|
461
|
+
let start = position;
|
|
462
|
+
if (position > 0) {
|
|
463
|
+
// The first line read is only the end of a line that began earlier, so it belongs to the head.
|
|
464
|
+
const cut = buffer.indexOf(0x0a);
|
|
465
|
+
const skip = cut < 0 ? buffer.length : cut + 1;
|
|
466
|
+
buffer = buffer.subarray(skip);
|
|
467
|
+
start += skip;
|
|
468
|
+
}
|
|
469
|
+
return { lines: buffer.toString('utf8').split('\n'), start, truncated: position > 0 || newlines > limit };
|
|
465
470
|
}
|
|
466
471
|
catch (error) {
|
|
467
472
|
if (error.code !== 'ENOENT')
|
|
468
473
|
throw error;
|
|
469
|
-
return { lines: [], truncated: false };
|
|
474
|
+
return { lines: [], start: 0, truncated: false };
|
|
470
475
|
}
|
|
471
476
|
finally {
|
|
472
477
|
await handle?.close().catch(() => { });
|
|
473
478
|
}
|
|
474
479
|
}
|
|
480
|
+
// Events that say which graph nodes and subagents ran. A long run's journal is read from its tail,
|
|
481
|
+
// and without these the desktop's Graph list loses every node and subagent that started before the
|
|
482
|
+
// newest events: a long run's entry node went missing that way.
|
|
483
|
+
const OUTLINE_TYPES = [
|
|
484
|
+
'graph.started', 'graph.node.started', 'graph.node.completed', 'graph.finalization.resumed', 'graph.completed', 'graph.stopped',
|
|
485
|
+
'graph.todos.updated', 'graph.widgets.updated', 'subagent.started', 'subagent.completed', 'subagent.change',
|
|
486
|
+
];
|
|
487
|
+
// Journal lines are written as {"type":"…",…}, so a line is matched on its opening bytes.
|
|
488
|
+
const OUTLINE_PREFIXES = OUTLINE_TYPES.map(type => Buffer.from(`{"type":"${type}"`));
|
|
489
|
+
const OUTLINE_PREFIX_BYTES = Math.max(...OUTLINE_PREFIXES.map(prefix => prefix.length));
|
|
490
|
+
// Only the newest of these matters to a reader, so the outline holds one of each. They are never
|
|
491
|
+
// evicted, so the run's graph.started survives however many events follow it.
|
|
492
|
+
const OUTLINE_LATEST_ONLY = new Set(['graph.started', 'graph.todos.updated', 'graph.widgets.updated']);
|
|
493
|
+
// Bounds on what the outline holds while it is collected. Measured on real journals, the largest
|
|
494
|
+
// outline line was 118 KB and the largest whole outline 229 KB.
|
|
495
|
+
const OUTLINE_MAX_LINE_BYTES = 256 * 1024;
|
|
496
|
+
const OUTLINE_MAX_BYTES = 4 * 1024 * 1024;
|
|
497
|
+
const OUTLINE_MAX_EVENTS = 20_000;
|
|
498
|
+
// The outline type a line opens with, or undefined when it is not an outline event.
|
|
499
|
+
function outlineType(opening) {
|
|
500
|
+
const index = OUTLINE_PREFIXES.findIndex(prefix => opening.length >= prefix.length && opening.subarray(0, prefix.length).equals(prefix));
|
|
501
|
+
return index < 0 ? undefined : OUTLINE_TYPES[index];
|
|
502
|
+
}
|
|
503
|
+
// Holds outline lines in journal order within the bounds above, evicting the oldest first, so
|
|
504
|
+
// peak memory stays bounded however long the journal is.
|
|
505
|
+
class OutlineCollector {
|
|
506
|
+
sequence = 0;
|
|
507
|
+
recent = [];
|
|
508
|
+
first = 0;
|
|
509
|
+
bytes = 0;
|
|
510
|
+
latest = new Map();
|
|
511
|
+
add(type, line, bytes) {
|
|
512
|
+
if (bytes > OUTLINE_MAX_LINE_BYTES)
|
|
513
|
+
return;
|
|
514
|
+
this.sequence += 1;
|
|
515
|
+
if (OUTLINE_LATEST_ONLY.has(type)) {
|
|
516
|
+
this.latest.set(type, { sequence: this.sequence, line });
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
this.recent.push({ sequence: this.sequence, line, bytes });
|
|
520
|
+
this.bytes += bytes;
|
|
521
|
+
while (this.recent.length - this.first > OUTLINE_MAX_EVENTS || this.bytes > OUTLINE_MAX_BYTES) {
|
|
522
|
+
this.bytes -= this.recent[this.first].bytes;
|
|
523
|
+
this.first += 1;
|
|
524
|
+
}
|
|
525
|
+
if (this.first > OUTLINE_MAX_EVENTS) {
|
|
526
|
+
this.recent = this.recent.slice(this.first);
|
|
527
|
+
this.first = 0;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
events() {
|
|
531
|
+
const entries = [...this.recent.slice(this.first), ...this.latest.values()].sort((a, b) => a.sequence - b.sequence);
|
|
532
|
+
const events = [];
|
|
533
|
+
for (const entry of entries) {
|
|
534
|
+
try {
|
|
535
|
+
events.push(JSON.parse(entry.line));
|
|
536
|
+
}
|
|
537
|
+
catch {
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return events;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
// Reads the journal bytes before the tail into the collector. Every other line is skipped once its
|
|
545
|
+
// opening bytes are seen, so bulky tool and model output is never decoded or held.
|
|
546
|
+
async function readJournalOutline(path, end, collector) {
|
|
547
|
+
if (end <= 0)
|
|
548
|
+
return;
|
|
549
|
+
let carry = [];
|
|
550
|
+
let carryBytes = 0;
|
|
551
|
+
let type;
|
|
552
|
+
const settle = (head) => {
|
|
553
|
+
if (type !== undefined)
|
|
554
|
+
return;
|
|
555
|
+
const opening = carryBytes > 0 ? Buffer.concat([...carry, head]).subarray(0, OUTLINE_PREFIX_BYTES) : head.subarray(0, OUTLINE_PREFIX_BYTES);
|
|
556
|
+
if (opening.length >= OUTLINE_PREFIX_BYTES)
|
|
557
|
+
type = outlineType(opening) ?? null;
|
|
558
|
+
};
|
|
559
|
+
for await (const chunk of createReadStream(path, { start: 0, end: end - 1, highWaterMark: JOURNAL_TAIL_BLOCK_BYTES })) {
|
|
560
|
+
const block = chunk;
|
|
561
|
+
let from = 0;
|
|
562
|
+
for (let cut = block.indexOf(0x0a, from); cut >= 0; cut = block.indexOf(0x0a, from)) {
|
|
563
|
+
const piece = block.subarray(from, cut);
|
|
564
|
+
settle(piece);
|
|
565
|
+
if (type !== null) {
|
|
566
|
+
const line = carryBytes > 0 ? Buffer.concat([...carry, piece]) : piece;
|
|
567
|
+
const matched = type ?? outlineType(line);
|
|
568
|
+
if (matched !== undefined)
|
|
569
|
+
collector.add(matched, line.toString('utf8'), line.length);
|
|
570
|
+
}
|
|
571
|
+
carry = [];
|
|
572
|
+
carryBytes = 0;
|
|
573
|
+
type = undefined;
|
|
574
|
+
from = cut + 1;
|
|
575
|
+
}
|
|
576
|
+
const rest = block.subarray(from);
|
|
577
|
+
if (rest.length === 0)
|
|
578
|
+
continue;
|
|
579
|
+
settle(rest);
|
|
580
|
+
if (type === null)
|
|
581
|
+
continue;
|
|
582
|
+
carry.push(Buffer.from(rest));
|
|
583
|
+
carryBytes += rest.length;
|
|
584
|
+
if (carryBytes > OUTLINE_MAX_LINE_BYTES) {
|
|
585
|
+
carry = [];
|
|
586
|
+
carryBytes = 0;
|
|
587
|
+
type = null;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
// `events` is the newest part of the journal. When older events were left out, `outline` carries
|
|
592
|
+
// the graph, node and subagent events among them, in journal order, so a reader can still tell
|
|
593
|
+
// which nodes and subagents ran.
|
|
475
594
|
export async function readRun(directory, id) {
|
|
476
595
|
const path = runRecordPath(directory, id, 'json');
|
|
477
596
|
const result = JSON.parse(await readFile(path, 'utf8'));
|
|
478
597
|
const journal = runRecordPath(directory, id, 'jsonl');
|
|
479
|
-
const { lines, truncated } = await readJournalTail(journal, MAX_RUN_EVENTS);
|
|
480
|
-
const
|
|
598
|
+
const { lines, start, truncated } = await readJournalTail(journal, MAX_RUN_EVENTS);
|
|
599
|
+
const parsed = [];
|
|
481
600
|
for (const line of lines) {
|
|
482
601
|
if (!line.trim())
|
|
483
602
|
continue;
|
|
484
603
|
try {
|
|
485
|
-
|
|
604
|
+
parsed.push({ line, event: JSON.parse(line) });
|
|
486
605
|
}
|
|
487
606
|
catch {
|
|
488
607
|
continue;
|
|
489
608
|
}
|
|
490
609
|
}
|
|
491
|
-
|
|
610
|
+
const dropped = parsed.slice(0, Math.max(0, parsed.length - MAX_RUN_EVENTS));
|
|
611
|
+
const events = parsed.slice(dropped.length).map(entry => entry.event);
|
|
612
|
+
if (!truncated)
|
|
613
|
+
return { result, events, truncated };
|
|
614
|
+
const collector = new OutlineCollector();
|
|
615
|
+
await readJournalOutline(journal, start, collector);
|
|
616
|
+
for (const { line } of dropped) {
|
|
617
|
+
const type = outlineType(Buffer.from(line.slice(0, OUTLINE_PREFIX_BYTES)));
|
|
618
|
+
if (type !== undefined)
|
|
619
|
+
collector.add(type, line, Buffer.byteLength(line));
|
|
620
|
+
}
|
|
621
|
+
const outline = collector.events();
|
|
622
|
+
return { result, events, truncated, ...(outline.length > 0 ? { outline } : {}) };
|
|
492
623
|
}
|
|
493
624
|
export async function runRecordFile(directory, id) {
|
|
494
625
|
const path = resolve(runRecordPath(directory, id, 'json'));
|
package/dist/src/app-server.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { type GhRunner } from './pull-requests.js';
|
|
|
13
13
|
import { type Completion, type RunResult } from './runtime.js';
|
|
14
14
|
import { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceManager.js';
|
|
15
15
|
import { type AppServerErrorCode } from './app-server/protocol.js';
|
|
16
|
+
import { type HostedMonitorOptions } from './andorra/monitor.js';
|
|
16
17
|
declare class AppServerError extends Error {
|
|
17
18
|
readonly code: AppServerErrorCode;
|
|
18
19
|
constructor(code: AppServerErrorCode, message: string);
|
|
@@ -38,11 +39,14 @@ export interface AppServerOptions {
|
|
|
38
39
|
managedSignIn?: {
|
|
39
40
|
claude?: ManagedSignInService;
|
|
40
41
|
grok?: ManagedSignInService;
|
|
42
|
+
google?: ManagedSignInService;
|
|
41
43
|
opencode?: OpenCodeSignInService;
|
|
42
44
|
};
|
|
43
45
|
signInProbes?: Partial<SignInProbes>;
|
|
44
46
|
gh?: GhRunner;
|
|
45
47
|
pullRequestPollMs?: number;
|
|
48
|
+
hostedCheck?: HostedMonitorOptions['check'];
|
|
49
|
+
hostedNow?: () => number;
|
|
46
50
|
}
|
|
47
51
|
export declare class AppServer {
|
|
48
52
|
private automationCheck?;
|
|
@@ -62,6 +66,7 @@ export declare class AppServer {
|
|
|
62
66
|
private readonly anthropicAuth;
|
|
63
67
|
private readonly claudeSignIn;
|
|
64
68
|
private readonly grokSignIn;
|
|
69
|
+
private readonly googleSignIn;
|
|
65
70
|
private readonly openCodeSignIn;
|
|
66
71
|
private readonly signInProbes;
|
|
67
72
|
private readonly detectedSignIns;
|
|
@@ -73,6 +78,7 @@ export declare class AppServer {
|
|
|
73
78
|
private readonly reviewWaiters;
|
|
74
79
|
private readonly reviewWaitsStarting;
|
|
75
80
|
private readonly graphSync;
|
|
81
|
+
private readonly stopGraphVisibilityWatch;
|
|
76
82
|
private readonly terminals;
|
|
77
83
|
private readonly backgroundTasks;
|
|
78
84
|
private stopBackgroundWatch;
|
|
@@ -104,6 +110,7 @@ export declare class AppServer {
|
|
|
104
110
|
private readonly slotWrites;
|
|
105
111
|
private runTask?;
|
|
106
112
|
private readonly titleReleases;
|
|
113
|
+
private readonly titleAnswered;
|
|
107
114
|
private readonly sessionTitles;
|
|
108
115
|
private workGeneration;
|
|
109
116
|
private readonly operations;
|
|
@@ -119,6 +126,8 @@ export declare class AppServer {
|
|
|
119
126
|
private remoteOps;
|
|
120
127
|
private closed;
|
|
121
128
|
private emitsStopped;
|
|
129
|
+
private readonly hosted;
|
|
130
|
+
private hostedStarted;
|
|
122
131
|
private telemetrySettle;
|
|
123
132
|
onStop?: () => void;
|
|
124
133
|
constructor(options: AppServerOptions & {
|
|
@@ -132,6 +141,23 @@ export declare class AppServer {
|
|
|
132
141
|
private emit;
|
|
133
142
|
private log;
|
|
134
143
|
ready(): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Keeps the Andorra entry current from an enabled answer. A missing entry is created only when the user added
|
|
146
|
+
* Andorra: that decision is read inside this engine's queue of config writes and inside the cross-process
|
|
147
|
+
* config lock, so an add or a removal recorded just before, here or in another process, is the one that counts.
|
|
148
|
+
*/
|
|
149
|
+
private applyHostedEntry;
|
|
150
|
+
/**
|
|
151
|
+
* What clients are told about Andorra: its availability, whether it can be added, and, while it is offered and
|
|
152
|
+
* the user has not removed it, the entry to LIST: a provider view built from the hosted answer that is not in
|
|
153
|
+
* the saved config (`listed`). A client shows it as an ordinary provider and saves it with `andorra.add` the
|
|
154
|
+
* first time the user picks it. `usage`, when known, is what to show for the hosted models (HostedMonitor.usage).
|
|
155
|
+
*/
|
|
156
|
+
private hostedStatus;
|
|
157
|
+
/** The user removed the listed, never-saved Andorra: it is no longer listed (Add Provider still offers it). */
|
|
158
|
+
private hideListedEntry;
|
|
159
|
+
/** Saves the Andorra provider because the user asked for it; with `select`, it becomes the active provider in the same write. */
|
|
160
|
+
private addHostedEntry;
|
|
135
161
|
private reapSessions;
|
|
136
162
|
private autoArchiveSessions;
|
|
137
163
|
private currentRun;
|
|
@@ -178,6 +204,8 @@ export declare class AppServer {
|
|
|
178
204
|
private sessionStats;
|
|
179
205
|
private signIn;
|
|
180
206
|
private signOut;
|
|
207
|
+
/** Signing in or out changes what Andorra offers this account: ask now instead of at the next interval. */
|
|
208
|
+
private checkHostedAfterAccountChange;
|
|
181
209
|
private publishAccount;
|
|
182
210
|
private trajectoryIdOf;
|
|
183
211
|
private readSession;
|
|
@@ -194,6 +222,7 @@ export declare class AppServer {
|
|
|
194
222
|
private projectIdFor;
|
|
195
223
|
private createSession;
|
|
196
224
|
private renameSession;
|
|
225
|
+
private setSessionJev;
|
|
197
226
|
private setSessionGoal;
|
|
198
227
|
private emitSessionGoal;
|
|
199
228
|
private compactSession;
|
|
@@ -222,6 +251,7 @@ export declare class AppServer {
|
|
|
222
251
|
private approvePlan;
|
|
223
252
|
private saveRunPermissions;
|
|
224
253
|
private syncCodeIntelPermissions;
|
|
254
|
+
/** `sessionId`: the session whose run will talk to this adapter; a run passes its own, known before `this.run` is set. */
|
|
225
255
|
private resolveModel;
|
|
226
256
|
private analyticsConfigView;
|
|
227
257
|
private resolveProvider;
|
|
@@ -245,6 +275,11 @@ export declare class AppServer {
|
|
|
245
275
|
private graphDirectory;
|
|
246
276
|
private currentAccountIsConfirmed;
|
|
247
277
|
private listGraphs;
|
|
278
|
+
/** The caller names the account it read; a change made for an account that is no longer signed in is refused. */
|
|
279
|
+
private visibilitySubject;
|
|
280
|
+
private visibilityPaths;
|
|
281
|
+
private setGraphVisibilityMethod;
|
|
282
|
+
private importGraphVisibilityMethod;
|
|
248
283
|
private exportAgent;
|
|
249
284
|
private getGraph;
|
|
250
285
|
private selectGraph;
|