@andorra-labs/code 0.1.15 → 0.1.17
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/acp-agent.d.ts +6 -0
- package/dist/src/acp-agent.js +15 -4
- package/dist/src/agent-definitions.js +29 -6
- package/dist/src/agent-execution.js +15 -10
- package/dist/src/agent-mcp-catalog.js +1 -0
- package/dist/src/agent-mcp.d.ts +4 -1
- package/dist/src/agent-mcp.js +46 -10
- package/dist/src/andorra/entry.d.ts +10 -0
- package/dist/src/andorra/entry.js +18 -4
- package/dist/src/andorra/hosted.d.ts +2 -1
- package/dist/src/andorra/hosted.js +2 -1
- package/dist/src/andorra/notices.d.ts +5 -0
- package/dist/src/andorra/notices.js +7 -0
- package/dist/src/andorra/state.d.ts +3 -2
- package/dist/src/andorra/state.js +4 -4
- package/dist/src/andorra/terminal.js +7 -2
- package/dist/src/anthropic-credentials.js +2 -0
- package/dist/src/app-server/error.d.ts +5 -0
- package/dist/src/app-server/error.js +7 -0
- package/dist/src/app-server/protocol.d.ts +22 -44
- package/dist/src/app-server/protocol.js +5 -1
- package/dist/src/app-server/workspace.d.ts +89 -0
- package/dist/src/app-server/workspace.js +457 -11
- package/dist/src/app-server.d.ts +465 -32
- package/dist/src/app-server.js +3308 -517
- package/dist/src/auth/deployment.js +2 -2
- package/dist/src/bridge/cloud.d.ts +27 -0
- package/dist/src/bridge/cloud.js +187 -0
- package/dist/src/bridge/command.d.ts +30 -0
- package/dist/src/bridge/command.js +347 -0
- package/dist/src/bridge/control.d.ts +68 -0
- package/dist/src/bridge/control.js +233 -0
- package/dist/src/bridge/engines.d.ts +90 -0
- package/dist/src/bridge/engines.js +601 -0
- package/dist/src/bridge/host-ops.d.ts +9 -0
- package/dist/src/bridge/host-ops.js +129 -0
- package/dist/src/bridge/host.d.ts +47 -0
- package/dist/src/bridge/host.js +540 -0
- package/dist/src/bridge/link.d.ts +38 -0
- package/dist/src/bridge/link.js +508 -0
- package/dist/src/bridge/login-link.d.ts +29 -0
- package/dist/src/bridge/login-link.js +54 -0
- package/dist/src/bridge/protocol.d.ts +136 -0
- package/dist/src/bridge/protocol.js +11 -0
- package/dist/src/bridge/store.d.ts +12 -0
- package/dist/src/bridge/store.js +61 -0
- package/dist/src/bridge/wording.d.ts +6 -0
- package/dist/src/bridge/wording.js +10 -0
- package/dist/src/browser-runner.js +1 -0
- package/dist/src/browser-server.js +7 -1
- package/dist/src/browser-ui/style.css +3 -3
- package/dist/src/browser-ui/tokens.css +28 -17
- package/dist/src/change-authors.d.ts +41 -0
- package/dist/src/change-authors.js +146 -0
- package/dist/src/claude-provider.js +3 -1
- package/dist/src/cli.js +202 -38
- package/dist/src/codex-errors.js +4 -1
- package/dist/src/coding-tools.js +15 -15
- package/dist/src/command-screens.d.ts +6 -0
- package/dist/src/command-screens.js +19 -14
- package/dist/src/commands.d.ts +14 -1
- package/dist/src/compaction-phrases.d.ts +4 -0
- package/dist/src/compaction-phrases.js +20 -0
- package/dist/src/completion.js +82 -5
- package/dist/src/config.d.ts +71 -3
- package/dist/src/config.js +202 -77
- package/dist/src/context-compaction.js +2 -1
- package/dist/src/deadline.js +13 -1
- package/dist/src/decision/DecisionManager.js +3 -2
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/requestPhrases.d.ts +4 -0
- package/dist/src/decision/requestPhrases.js +22 -0
- package/dist/src/default-graph.js +1 -1
- package/dist/src/file-diff.d.ts +4 -0
- package/dist/src/file-diff.js +2 -1
- package/dist/src/github-app/agent-writes.d.ts +102 -0
- package/dist/src/github-app/agent-writes.js +320 -0
- package/dist/src/github-app/client.d.ts +349 -0
- package/dist/src/github-app/client.js +810 -0
- package/dist/src/github-app/event-source.d.ts +208 -0
- package/dist/src/github-app/event-source.js +684 -0
- package/dist/src/github-app/metrics.d.ts +32 -0
- package/dist/src/github-app/metrics.js +49 -0
- package/dist/src/github-app/review-loop.d.ts +274 -0
- package/dist/src/github-app/review-loop.js +1177 -0
- package/dist/src/github-app/review-node.d.ts +81 -0
- package/dist/src/github-app/review-node.js +205 -0
- package/dist/src/github-app/review-post.d.ts +73 -0
- package/dist/src/github-app/review-post.js +139 -0
- package/dist/src/github-app/review-text.d.ts +107 -0
- package/dist/src/github-app/review-text.js +1133 -0
- package/dist/src/github-app/review-threads.d.ts +47 -0
- package/dist/src/github-app/review-threads.js +107 -0
- package/dist/src/github-app/reviewer.d.ts +121 -0
- package/dist/src/github-app/reviewer.js +598 -0
- package/dist/src/github-app/store.d.ts +59 -0
- package/dist/src/github-app/store.js +148 -0
- package/dist/src/github-app/triggers.d.ts +141 -0
- package/dist/src/github-app/triggers.js +441 -0
- package/dist/src/github-inbox.d.ts +55 -0
- package/dist/src/github-inbox.js +153 -0
- package/dist/src/github-names.d.ts +8 -0
- package/dist/src/github-names.js +8 -0
- package/dist/src/glob-search.d.ts +61 -0
- package/dist/src/glob-search.js +180 -0
- package/dist/src/graph-health.js +13 -4
- package/dist/src/graph-manager-chat.js +1 -1
- package/dist/src/graph-preview.d.ts +46 -0
- package/dist/src/graph-preview.js +55 -0
- package/dist/src/graph-provider-portability.js +34 -11
- package/dist/src/graph-quota.d.ts +29 -2
- package/dist/src/graph-quota.js +68 -10
- package/dist/src/graph-runner.js +88 -10
- package/dist/src/graph-server.d.ts +1 -1
- package/dist/src/graph-server.js +11 -9
- package/dist/src/graph-sync.js +3 -3
- package/dist/src/graph-ui/app.js +201 -40
- package/dist/src/graph-ui/controls.css +1 -0
- package/dist/src/graph-ui/embed.js +2 -2
- package/dist/src/graph-ui/icons.js +3 -1
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graph-ui/manager.css +1 -1
- package/dist/src/graph-ui/manager.js +2 -2
- package/dist/src/graph-ui/sidebar.js +30 -0
- package/dist/src/graph-ui/studio-canvas.js +26 -13
- package/dist/src/graph-ui/studio.css +15 -7
- package/dist/src/graph-ui/studio.js +26 -5
- package/dist/src/graph-ui/style.css +77 -45
- package/dist/src/graph-ui/theme.js +3 -36
- package/dist/src/graph-ui/tokens.css +28 -20
- package/dist/src/graphs.d.ts +34 -1
- package/dist/src/graphs.js +162 -17
- package/dist/src/image-input.d.ts +16 -0
- package/dist/src/image-input.js +41 -0
- package/dist/src/membership.d.ts +30 -1
- package/dist/src/membership.js +48 -8
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +7 -1
- package/dist/src/model-metadata.js +39 -17
- package/dist/src/model-relay/local.d.ts +116 -0
- package/dist/src/model-relay/local.js +468 -0
- package/dist/src/model-relay/remote.d.ts +129 -0
- package/dist/src/model-relay/remote.js +252 -0
- package/dist/src/model-relay/runs.d.ts +34 -0
- package/dist/src/model-relay/runs.js +146 -0
- package/dist/src/model-relay/wire.d.ts +5 -0
- package/dist/src/model-relay/wire.js +5 -0
- package/dist/src/plan-pass.d.ts +59 -0
- package/dist/src/plan-pass.js +165 -0
- package/dist/src/project-registry.d.ts +21 -0
- package/dist/src/project-registry.js +74 -0
- package/dist/src/provider-engine.js +3 -0
- package/dist/src/provider-import.d.ts +0 -12
- package/dist/src/provider-import.js +7 -195
- package/dist/src/providers.d.ts +40 -2
- package/dist/src/providers.js +93 -23
- package/dist/src/pull-request-checks.d.ts +26 -0
- package/dist/src/pull-request-checks.js +56 -0
- package/dist/src/pull-request-conversation.d.ts +134 -0
- package/dist/src/pull-request-conversation.js +221 -0
- package/dist/src/pull-request-create.d.ts +175 -0
- package/dist/src/pull-request-create.js +392 -0
- package/dist/src/pull-request-details.d.ts +242 -0
- package/dist/src/pull-request-details.js +614 -0
- package/dist/src/pull-request-edit.d.ts +23 -0
- package/dist/src/pull-request-edit.js +91 -0
- package/dist/src/pull-request-logs.d.ts +87 -0
- package/dist/src/pull-request-logs.js +183 -0
- package/dist/src/pull-request-merge.d.ts +112 -0
- package/dist/src/pull-request-merge.js +258 -0
- package/dist/src/pull-request-review.d.ts +137 -0
- package/dist/src/pull-request-review.js +401 -0
- package/dist/src/pull-requests.d.ts +369 -8
- package/dist/src/pull-requests.js +524 -55
- package/dist/src/react-runtime.js +38 -5
- package/dist/src/remote/engine-pool.d.ts +88 -4
- package/dist/src/remote/engine-pool.js +379 -90
- package/dist/src/remote/roots.d.ts +19 -0
- package/dist/src/remote/roots.js +45 -7
- package/dist/src/remote/types.d.ts +0 -44
- package/dist/src/run-control.d.ts +17 -0
- package/dist/src/run-control.js +47 -0
- package/dist/src/run-progress.d.ts +10 -0
- package/dist/src/run-progress.js +122 -0
- package/dist/src/run-records.d.ts +7 -2
- package/dist/src/run-records.js +71 -6
- package/dist/src/runtime.d.ts +9 -1
- package/dist/src/runtime.js +24 -4
- package/dist/src/session-changes.d.ts +35 -0
- package/dist/src/session-changes.js +194 -6
- package/dist/src/session-monitor.js +2 -1
- package/dist/src/session-reaper.d.ts +1 -1
- package/dist/src/session-reaper.js +6 -1
- package/dist/src/session-summary.d.ts +2 -1
- package/dist/src/session-summary.js +2 -1
- package/dist/src/sessions.d.ts +11 -1
- package/dist/src/sessions.js +17 -4
- package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
- package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
- package/dist/src/skills/bundled/provenance.json +2 -2
- package/dist/src/skills/runtime-skills.js +1 -1
- package/dist/src/subagent-run.js +1 -0
- package/dist/src/telemetry/capture-core.d.ts +17 -0
- package/dist/src/telemetry/capture-core.js +59 -1
- package/dist/src/telemetry/classify.d.ts +3 -1
- package/dist/src/telemetry/classify.js +37 -0
- package/dist/src/telemetry/emitter.d.ts +17 -0
- package/dist/src/telemetry/emitter.js +76 -5
- package/dist/src/telemetry/schema.d.ts +47 -2
- package/dist/src/telemetry/schema.js +120 -5
- package/dist/src/telemetry/surface.d.ts +3 -1
- package/dist/src/telemetry/surface.js +4 -1
- package/dist/src/telemetry/uploader.d.ts +6 -1
- package/dist/src/telemetry/uploader.js +22 -3
- package/dist/src/terminal-ui.d.ts +1 -0
- package/dist/src/terminal-ui.js +10 -3
- package/dist/src/test-edit-guard.d.ts +7 -0
- package/dist/src/test-edit-guard.js +49 -1
- package/dist/src/timers.d.ts +2 -0
- package/dist/src/tools.js +59 -9
- package/dist/src/transcript.js +8 -2
- package/dist/src/types.d.ts +7 -0
- package/dist/src/usage-analytics.js +18 -10
- package/package.json +6 -1
- package/dist/src/remote/cert.d.ts +0 -11
- package/dist/src/remote/cert.js +0 -87
- package/dist/src/remote/client.d.ts +0 -119
- package/dist/src/remote/client.js +0 -544
- package/dist/src/remote/command.d.ts +0 -4
- package/dist/src/remote/command.js +0 -194
- package/dist/src/remote/errors.d.ts +0 -11
- package/dist/src/remote/errors.js +0 -14
- package/dist/src/remote/network.d.ts +0 -22
- package/dist/src/remote/network.js +0 -102
- package/dist/src/remote/pairing.d.ts +0 -63
- package/dist/src/remote/pairing.js +0 -299
- package/dist/src/remote/pem.d.ts +0 -2
- package/dist/src/remote/pem.js +0 -7
- package/dist/src/remote/serve.d.ts +0 -68
- package/dist/src/remote/serve.js +0 -244
- package/dist/src/remote/server.d.ts +0 -21
- package/dist/src/remote/server.js +0 -406
package/dist/src/membership.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Graph } from './graphs.js';
|
|
2
|
+
import { readOfflinePlan } from './plan-pass.js';
|
|
2
3
|
import type { TelemetryPlan } from './telemetry/schema.js';
|
|
3
4
|
export declare const SOFTWARE_ENGINEER_HARNESS: Graph;
|
|
4
5
|
export declare const RETIRED_ANDORRA_SELECTION = ":andorra";
|
|
@@ -31,6 +32,8 @@ export interface Membership {
|
|
|
31
32
|
windowDecisionResetsAt?: string;
|
|
32
33
|
/** Uncapped Paid account: no daily, window or global cap applies. The service answers `unlimited: true` and omits every allowance field. */
|
|
33
34
|
unlimited?: boolean;
|
|
35
|
+
/** The plan comes from a stored, signed pass because the account service could not be reached. */
|
|
36
|
+
offline?: true;
|
|
34
37
|
billingUrl?: string;
|
|
35
38
|
}
|
|
36
39
|
export declare function membershipPlanLabel(tier: MembershipTier | undefined, paid: boolean): string;
|
|
@@ -48,14 +51,40 @@ export interface MembershipDependencies {
|
|
|
48
51
|
apiBaseUrl(): string;
|
|
49
52
|
fetch: typeof globalThis.fetch;
|
|
50
53
|
recordPlan?: (answer: PlanConfirmation, home?: string) => Promise<void>;
|
|
54
|
+
/** Keeps the signed pass an answer carried, for use while the service is unreachable. */
|
|
55
|
+
storePass?: (pass: unknown, subject: string, home: string, serverTime: number | undefined, plan: {
|
|
56
|
+
paid: boolean;
|
|
57
|
+
tier?: string;
|
|
58
|
+
}) => Promise<unknown>;
|
|
59
|
+
/** Loopback `http:` is allowed only for the GitHub App's test-mode account API (a local fake); everything else must be `https:`. */
|
|
60
|
+
allowLoopbackHttp?: boolean;
|
|
51
61
|
}
|
|
52
62
|
export declare function createMembershipClient(deps: MembershipDependencies): (signal?: AbortSignal, home?: string) => Promise<Membership>;
|
|
53
63
|
export declare const getMembership: (signal?: AbortSignal, home?: string) => Promise<Membership>;
|
|
64
|
+
/**
|
|
65
|
+
* The plan check for custom graphs. It is `getMembership`, except that when the account service
|
|
66
|
+
* cannot be reached a stored pass for the signed-in account stands in for the answer until the pass
|
|
67
|
+
* lapses. Hosted services still need the network; this only decides which graphs may be used.
|
|
68
|
+
*/
|
|
69
|
+
export declare function createGraphMembership(deps: {
|
|
70
|
+
membership: (signal?: AbortSignal, home?: string) => Promise<Membership>;
|
|
71
|
+
subject: () => Promise<string | undefined>;
|
|
72
|
+
readPlan?: typeof readOfflinePlan;
|
|
73
|
+
}): (signal?: AbortSignal, home?: string) => Promise<Membership>;
|
|
74
|
+
export declare const getGraphMembership: (signal?: AbortSignal, home?: string) => Promise<Membership>;
|
|
54
75
|
export declare function requirePaidMembership(signal?: AbortSignal): Promise<void>;
|
|
55
76
|
export declare function requireGraphMembership(signal?: AbortSignal): Promise<void>;
|
|
56
77
|
export declare function readGraphMembership(signal?: AbortSignal): Promise<Membership>;
|
|
57
|
-
export declare function loadAccessibleGraph(id?: string, signal?: AbortSignal, membership?: (signal?: AbortSignal
|
|
78
|
+
export declare function loadAccessibleGraph(id?: string, signal?: AbortSignal, membership?: (signal?: AbortSignal) => Promise<Membership>, options?: {
|
|
58
79
|
bindProviders?: boolean;
|
|
59
80
|
allowDeleted?: boolean;
|
|
60
81
|
allowRetired?: boolean;
|
|
61
82
|
}): Promise<Graph>;
|
|
83
|
+
/**
|
|
84
|
+
* The graph a desktop sent with a relayed run. It is checked as a stored graph is and used for that run only:
|
|
85
|
+
* it is never written to disk, and no plan is asked for, because the desktop that sent it already holds it.
|
|
86
|
+
* Its nodes are bound to the relayed providers by the caller.
|
|
87
|
+
*/
|
|
88
|
+
export declare function relayedGraph(value: unknown, options?: {
|
|
89
|
+
allowDeleted?: boolean;
|
|
90
|
+
}): Graph;
|
package/dist/src/membership.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { DEFAULT_AGENT_GRAPH } from './default-graph.js';
|
|
2
|
-
import { DEFAULT_HARNESS,
|
|
3
|
-
import { AUTH_REFRESH_BUDGET_MS, AuthError, getAccessToken, getAuthConfiguration } from './auth/index.js';
|
|
2
|
+
import { DEFAULT_HARNESS, builtInGraph, GraphDeletedError, isDeletedGraph, loadGraph, validateGraph } from './graphs.js';
|
|
3
|
+
import { AUTH_REFRESH_BUDGET_MS, AuthError, getAccessToken, getAuthConfiguration, getAuthStatus } from './auth/index.js';
|
|
4
|
+
import { readOfflinePlan, storePlanPass } from './plan-pass.js';
|
|
4
5
|
import { graphStorageDirectory } from './graph-account.js';
|
|
5
6
|
import { configDirectory, loadConfig } from './config.js';
|
|
6
7
|
import { analyticsPlanFromMembership, resolveAnalyticsConfig } from './analytics.js';
|
|
7
8
|
import { recordConfirmedPlan } from './telemetry/state.js';
|
|
8
9
|
import { telemetryDirectory } from './telemetry/identity.js';
|
|
9
10
|
import { bindPortableGraphProviders } from './graph-provider-portability.js';
|
|
10
|
-
import { loadFreeTierGraph } from './graph-quota.js';
|
|
11
|
+
import { loadFreeTierGraph, notePremiumGraphAccount } from './graph-quota.js';
|
|
11
12
|
export const SOFTWARE_ENGINEER_HARNESS = {
|
|
12
13
|
schemaVersion: 2, id: 'software-engineer', name: DEFAULT_AGENT_GRAPH.name, revision: 1, entry: DEFAULT_AGENT_GRAPH.entry,
|
|
13
14
|
nodes: structuredClone(DEFAULT_AGENT_GRAPH.nodes), edges: structuredClone(DEFAULT_AGENT_GRAPH.edges),
|
|
@@ -95,6 +96,7 @@ export function safeAccountEmail(value) {
|
|
|
95
96
|
}
|
|
96
97
|
export { PaidMembershipRequiredError } from './membership-errors.js';
|
|
97
98
|
import { PaidMembershipRequiredError } from './membership-errors.js';
|
|
99
|
+
const LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '[::1]']);
|
|
98
100
|
async function recordPlanConfirmation(answer, home) {
|
|
99
101
|
const directory = home ?? configDirectory();
|
|
100
102
|
const observedAt = new Date().toISOString();
|
|
@@ -112,7 +114,8 @@ export function createMembershipClient(deps) {
|
|
|
112
114
|
return { paid: false };
|
|
113
115
|
bounded = signal ? AbortSignal.any([signal, AbortSignal.timeout(5000)]) : AbortSignal.timeout(5000);
|
|
114
116
|
const base = new URL(deps.apiBaseUrl());
|
|
115
|
-
|
|
117
|
+
const loopback = deps.allowLoopbackHttp === true && base.protocol === 'http:' && LOOPBACK_HOSTS.has(base.hostname);
|
|
118
|
+
if ((base.protocol !== 'https:' && !loopback) || base.username || base.password || base.search || base.hash)
|
|
116
119
|
return { paid: false };
|
|
117
120
|
const response = await deps.fetch(`${base.href.replace(/\/+$/, '')}/me`, {
|
|
118
121
|
headers: { Authorization: `Bearer ${token}` }, signal: bounded, redirect: 'error',
|
|
@@ -158,6 +161,8 @@ export function createMembershipClient(deps) {
|
|
|
158
161
|
? result.tier : undefined;
|
|
159
162
|
const observedAt = new Date().toISOString();
|
|
160
163
|
await (deps.recordPlan ?? recordPlanConfirmation)({ subject: result.subject, tier: analyticsPlanFromMembership(tier, result.paid), observedAt }, home).catch(() => { });
|
|
164
|
+
const served = Date.parse(response.headers?.get?.('date') ?? '');
|
|
165
|
+
await (deps.storePass ?? ((pass, subject, directory, serverTime, plan) => storePlanPass(pass, subject, directory, { serverTime, plan })))(result.pass, result.subject, home ?? configDirectory(), Number.isFinite(served) ? served : undefined, { paid: result.paid, ...(tier ? { tier } : {}) }).catch(() => { });
|
|
161
166
|
const windowed = windowFields(result);
|
|
162
167
|
const unlimited = typeof result.unlimited === 'boolean' ? result.unlimited : undefined;
|
|
163
168
|
const lifetime = Number.isSafeInteger(result.decisionsSinceRollout) && result.decisionsSinceRollout >= 0
|
|
@@ -187,6 +192,26 @@ export const getMembership = createMembershipClient({
|
|
|
187
192
|
accessToken: getAccessToken, apiBaseUrl: () => getAuthConfiguration().apiBaseUrl,
|
|
188
193
|
fetch: (...args) => globalThis.fetch(...args),
|
|
189
194
|
});
|
|
195
|
+
/**
|
|
196
|
+
* The plan check for custom graphs. It is `getMembership`, except that when the account service
|
|
197
|
+
* cannot be reached a stored pass for the signed-in account stands in for the answer until the pass
|
|
198
|
+
* lapses. Hosted services still need the network; this only decides which graphs may be used.
|
|
199
|
+
*/
|
|
200
|
+
export function createGraphMembership(deps) {
|
|
201
|
+
return async (signal, home) => {
|
|
202
|
+
const access = await deps.membership(signal, home);
|
|
203
|
+
if (!access.unavailable)
|
|
204
|
+
return access;
|
|
205
|
+
signal?.throwIfAborted();
|
|
206
|
+
const subject = await deps.subject().catch(() => undefined);
|
|
207
|
+
const plan = await (deps.readPlan ?? readOfflinePlan)(subject, home ?? configDirectory()).catch(() => undefined);
|
|
208
|
+
return plan ? { paid: plan.paid, tier: plan.tier, subject: plan.subject, offline: true } : access;
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
export const getGraphMembership = createGraphMembership({
|
|
212
|
+
membership: (signal, home) => getMembership(signal, home),
|
|
213
|
+
subject: async () => (await getAuthStatus()).subject,
|
|
214
|
+
});
|
|
190
215
|
export async function requirePaidMembership(signal) {
|
|
191
216
|
const access = await getMembership(signal);
|
|
192
217
|
if (!access.paid)
|
|
@@ -196,12 +221,12 @@ export async function requireGraphMembership(signal) {
|
|
|
196
221
|
await readGraphMembership(signal);
|
|
197
222
|
}
|
|
198
223
|
export async function readGraphMembership(signal) {
|
|
199
|
-
const access = await
|
|
224
|
+
const access = await getGraphMembership(signal);
|
|
200
225
|
if (!access.paid && !access.subject)
|
|
201
226
|
throw PaidMembershipRequiredError.for(access);
|
|
202
227
|
return access;
|
|
203
228
|
}
|
|
204
|
-
export async function loadAccessibleGraph(id = 'default', signal, membership =
|
|
229
|
+
export async function loadAccessibleGraph(id = 'default', signal, membership = getGraphMembership, options = {}) {
|
|
205
230
|
signal?.throwIfAborted();
|
|
206
231
|
if (id === RETIRED_ANDORRA_SELECTION && options.allowRetired) {
|
|
207
232
|
const access = await membership(signal);
|
|
@@ -212,8 +237,9 @@ export async function loadAccessibleGraph(id = 'default', signal, membership = g
|
|
|
212
237
|
}
|
|
213
238
|
if (currentGraphSelection(id) === 'default')
|
|
214
239
|
return structuredClone(SOFTWARE_ENGINEER_HARNESS);
|
|
215
|
-
|
|
216
|
-
|
|
240
|
+
const builtIn = builtInGraph(id);
|
|
241
|
+
if (builtIn)
|
|
242
|
+
return builtIn;
|
|
217
243
|
const access = await membership(signal);
|
|
218
244
|
signal?.throwIfAborted();
|
|
219
245
|
if (!access.paid && access.unavailable)
|
|
@@ -223,6 +249,8 @@ export async function loadAccessibleGraph(id = 'default', signal, membership = g
|
|
|
223
249
|
if (!/^[A-Za-z0-9-]{1,128}$/.test(access.subject))
|
|
224
250
|
throw new PaidMembershipRequiredError();
|
|
225
251
|
const directory = await graphStorageDirectory(undefined, access.subject);
|
|
252
|
+
if (access.paid)
|
|
253
|
+
await notePremiumGraphAccount(directory);
|
|
226
254
|
const graph = access.paid ? await loadGraph(id, undefined, directory) : await loadFreeTierGraph(id, directory);
|
|
227
255
|
if (!options.allowDeleted && isDeletedGraph(graph))
|
|
228
256
|
throw new GraphDeletedError(graph.name);
|
|
@@ -230,3 +258,15 @@ export async function loadAccessibleGraph(id = 'default', signal, membership = g
|
|
|
230
258
|
return graph;
|
|
231
259
|
return bindPortableGraphProviders(graph, await loadConfig());
|
|
232
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* The graph a desktop sent with a relayed run. It is checked as a stored graph is and used for that run only:
|
|
263
|
+
* it is never written to disk, and no plan is asked for, because the desktop that sent it already holds it.
|
|
264
|
+
* Its nodes are bound to the relayed providers by the caller.
|
|
265
|
+
*/
|
|
266
|
+
export function relayedGraph(value, options = {}) {
|
|
267
|
+
const graph = validateGraph(value);
|
|
268
|
+
// A deleted graph's definition says so (metadata.deletedAt): a new start refuses it, a resume of a run that used it may go on.
|
|
269
|
+
if (!options.allowDeleted && isDeletedGraph(graph))
|
|
270
|
+
throw new GraphDeletedError(graph.name);
|
|
271
|
+
return graph;
|
|
272
|
+
}
|
|
@@ -4,7 +4,7 @@ import { join } from 'node:path';
|
|
|
4
4
|
export const MODEL_HEALTH_TTL_MS = 10 * 60_000;
|
|
5
5
|
const REFRESH_INTERVAL_MS = 60_000;
|
|
6
6
|
const FILE = 'model-health.json';
|
|
7
|
-
const DESCRIPTIVE_FIELDS = new Set(['model', 'models', 'modelContextWindows', 'modelNames', 'modelParameters', 'freeModels', 'contextWindow', 'reasoningEffort']);
|
|
7
|
+
const DESCRIPTIVE_FIELDS = new Set(['model', 'models', 'modelContextWindows', 'modelNames', 'modelParameters', 'freeModels', 'textOnlyModels', 'contextWindow', 'reasoningEffort']);
|
|
8
8
|
export function modelHealthKey(provider, model) {
|
|
9
9
|
const reach = Object.fromEntries(Object.entries(provider)
|
|
10
10
|
.filter(([name]) => !DESCRIPTIVE_FIELDS.has(name))
|
|
@@ -4,8 +4,14 @@ export interface ModelMetadata {
|
|
|
4
4
|
contextWindow?: number;
|
|
5
5
|
}
|
|
6
6
|
export declare function resolveModelContext(provider: ProviderConfig, model: string | undefined, signal: AbortSignal): Promise<ProviderConfig>;
|
|
7
|
-
export declare function configuredModelSnapshot(provider: ProviderConfig,
|
|
7
|
+
export declare function configuredModelSnapshot(provider: ProviderConfig, requested: string | undefined): ProviderConfig;
|
|
8
8
|
export declare function withEvaluationReasoningEffort(snapshot: ProviderConfig, effort: string | undefined): ProviderConfig;
|
|
9
9
|
export declare function refreshModelContext(provider: ProviderConfig, signal: AbortSignal): Promise<ProviderConfig>;
|
|
10
|
+
/**
|
|
11
|
+
* The effective context window of each of `models` on `provider`, resolved as `refreshModelContext` resolves one
|
|
12
|
+
* (a window the model server reports, else a saved one, else a known one) with a single listing of the provider.
|
|
13
|
+
* A model whose window is not known is left out.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveModelContextWindows(provider: ProviderConfig, models: readonly string[], signal: AbortSignal): Promise<Record<string, number>>;
|
|
10
16
|
/** What the provider lists, with Andorra-known Claude windows filled in where the listing gives none. */
|
|
11
17
|
export declare function discoverModelMetadata(provider: ProviderConfig, signal: AbortSignal): Promise<ModelMetadata[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { configuredContextWindow, deadlinePhrase, MODEL_LISTING_TIMEOUT_MS } from './providers.js';
|
|
1
|
+
import { configuredContextWindow, deadlinePhrase, MODEL_LISTING_TIMEOUT_MS, providerModelId } from './providers.js';
|
|
2
2
|
import { providerAuthHeaders } from './anthropic-credentials.js';
|
|
3
3
|
import { validateConfig } from './config.js';
|
|
4
4
|
import { readOpenCodeModels } from './opencode-catalog.js';
|
|
@@ -14,7 +14,9 @@ import { createHostedClient } from './andorra/hosted.js';
|
|
|
14
14
|
export async function resolveModelContext(provider, model, signal) {
|
|
15
15
|
return refreshModelContext(configuredModelSnapshot(provider, model), signal);
|
|
16
16
|
}
|
|
17
|
-
export function configuredModelSnapshot(provider,
|
|
17
|
+
export function configuredModelSnapshot(provider, requested) {
|
|
18
|
+
// A model the provider lists in another case is requested in the provider's own spelling.
|
|
19
|
+
const model = requested === undefined ? undefined : providerModelId(provider, requested) ?? requested;
|
|
18
20
|
const snapshot = { ...provider };
|
|
19
21
|
if (model !== undefined && model !== snapshot.model) {
|
|
20
22
|
snapshot.model = model;
|
|
@@ -36,35 +38,53 @@ export function withEvaluationReasoningEffort(snapshot, effort) {
|
|
|
36
38
|
export async function refreshModelContext(provider, signal) {
|
|
37
39
|
const snapshot = configuredModelSnapshot(provider, undefined);
|
|
38
40
|
signal.throwIfAborted();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
completeContextWindow(snapshot, await readListing(snapshot, signal));
|
|
42
|
+
return snapshot;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The effective context window of each of `models` on `provider`, resolved as `refreshModelContext` resolves one
|
|
46
|
+
* (a window the model server reports, else a saved one, else a known one) with a single listing of the provider.
|
|
47
|
+
* A model whose window is not known is left out.
|
|
48
|
+
*/
|
|
49
|
+
export async function resolveModelContextWindows(provider, models, signal) {
|
|
50
|
+
signal.throwIfAborted();
|
|
51
|
+
const listing = await readListing(configuredModelSnapshot(provider, undefined), signal);
|
|
52
|
+
const windows = {};
|
|
53
|
+
for (const model of models) {
|
|
54
|
+
const snapshot = configuredModelSnapshot(provider, model);
|
|
55
|
+
completeContextWindow(snapshot, listing);
|
|
56
|
+
if (snapshot.contextWindow !== undefined)
|
|
57
|
+
windows[model] = snapshot.contextWindow;
|
|
47
58
|
}
|
|
59
|
+
return windows;
|
|
60
|
+
}
|
|
61
|
+
/** The provider's raw model listing, or undefined for a provider that is not listed for windows or whose listing failed. */
|
|
62
|
+
async function readListing(snapshot, signal) {
|
|
63
|
+
// The Claude CLI's catalog carries no windows; asking it would only cost a process spawn.
|
|
48
64
|
// Andorra entries carry the router's windows already (saved from GET /v1/hosted).
|
|
49
|
-
|
|
50
|
-
|
|
65
|
+
// A relayed entry carries the desktop's windows; its model cannot be listed from here.
|
|
66
|
+
if (['claude', 'codex', 'grok', 'google', 'andorra', 'relayed'].includes(snapshot.type))
|
|
67
|
+
return undefined;
|
|
51
68
|
try {
|
|
52
69
|
// The raw listing: a catalog default must not displace a window the user saved.
|
|
53
70
|
const models = await listModelMetadata(snapshot, signal);
|
|
54
71
|
signal.throwIfAborted();
|
|
55
|
-
|
|
56
|
-
if (reported !== undefined)
|
|
57
|
-
snapshot.contextWindow = reported;
|
|
72
|
+
return models;
|
|
58
73
|
}
|
|
59
74
|
catch {
|
|
60
75
|
signal.throwIfAborted();
|
|
76
|
+
return undefined;
|
|
61
77
|
}
|
|
62
|
-
|
|
78
|
+
}
|
|
79
|
+
function completeContextWindow(snapshot, listing) {
|
|
80
|
+
const reported = listing?.find(model => model.id === snapshot.model)?.contextWindow;
|
|
81
|
+
if (reported !== undefined)
|
|
82
|
+
snapshot.contextWindow = reported;
|
|
83
|
+
if ((snapshot.type === 'claude' || snapshot.type === 'anthropic') && snapshot.contextWindow === undefined) {
|
|
63
84
|
const known = knownClaudeContextWindow(snapshot.model);
|
|
64
85
|
if (known !== undefined)
|
|
65
86
|
snapshot.contextWindow = known;
|
|
66
87
|
}
|
|
67
|
-
return snapshot;
|
|
68
88
|
}
|
|
69
89
|
function object(value) {
|
|
70
90
|
return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
@@ -103,6 +123,8 @@ export async function discoverModelMetadata(provider, signal) {
|
|
|
103
123
|
return provider.type === 'anthropic' ? models.map(model => model.contextWindow === undefined ? withKnownClaudeWindow(model.id) : model) : models;
|
|
104
124
|
}
|
|
105
125
|
async function listModelMetadata(provider, signal) {
|
|
126
|
+
if (provider.type === 'relayed')
|
|
127
|
+
throw new Error('A relayed provider lists its models on your computer.');
|
|
106
128
|
validateConfig({ version: 1, provider: provider.id, providers: [provider] });
|
|
107
129
|
if (provider.type === 'codex')
|
|
108
130
|
return (await readCodexCatalog(signal, codexConnectFor(provider))).models.map(id => ({ id }));
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { type ProviderConfig } from '../providers.js';
|
|
2
|
+
import type { EngineFrame } from '../bridge/protocol.js';
|
|
3
|
+
import type { ModelAdapter } from '../types.js';
|
|
4
|
+
/** At most this many relayed requests of one machine are in hand at once, generating or waiting to be delivered; another is left for a later announce. */
|
|
5
|
+
export declare const LOCAL_RELAY_CONCURRENCY = 5;
|
|
6
|
+
/** While a request is generating, the machine hears that it is alive this often, so it keeps the claim. */
|
|
7
|
+
export declare const LOCAL_RELAY_ALIVE_MS = 15000;
|
|
8
|
+
/** Reasoning deltas are sent at most once per this interval. */
|
|
9
|
+
export declare const LOCAL_RELAY_REASONING_BATCH_MS = 100;
|
|
10
|
+
/** A finished result that could not be sent is tried again this often... */
|
|
11
|
+
export declare const LOCAL_RELAY_RESULT_RETRY_MS = 5000;
|
|
12
|
+
/** ...and kept for this long, waiting for the link or for the machine to announce the request again. */
|
|
13
|
+
export declare const LOCAL_RELAY_RESULT_HOLD_MS = 600000;
|
|
14
|
+
/**
|
|
15
|
+
* A request this computer ignored because it does not offer the provider or model asked for, still announced unclaimed
|
|
16
|
+
* this long after, is claimed and declined: another desktop of the account that offers it had that long to take it.
|
|
17
|
+
*/
|
|
18
|
+
export declare const LOCAL_RELAY_DECLINE_MS = 60000;
|
|
19
|
+
/**
|
|
20
|
+
* The models a provider offers a linked machine: its default and its listed models. The relay block names exactly
|
|
21
|
+
* these, and a request for any other model is not answered.
|
|
22
|
+
*/
|
|
23
|
+
export declare function relayedModelIds(provider: ProviderConfig): string[];
|
|
24
|
+
/** `via` names the link a call went through, so a claim's later calls can be sent through the same one. */
|
|
25
|
+
export type RelaySendAnswer = {
|
|
26
|
+
result?: unknown;
|
|
27
|
+
error?: {
|
|
28
|
+
code: string;
|
|
29
|
+
message: string;
|
|
30
|
+
};
|
|
31
|
+
via?: string;
|
|
32
|
+
};
|
|
33
|
+
export interface LocalModelRelayDeps {
|
|
34
|
+
providers(): Promise<ProviderConfig[]>;
|
|
35
|
+
/** The signed-in account's subject, read once per announce and handed to the two checks below. */
|
|
36
|
+
subject(): Promise<string | undefined>;
|
|
37
|
+
/** Whether `env` may use this computer's models at all: allowed here for `subject`, on its account, not being removed. */
|
|
38
|
+
allowed(env: string, subject: string | undefined): Promise<boolean>;
|
|
39
|
+
/** Whether this computer started or resumed `runId` on `env` for `subject`: only those runs' requests are answered. */
|
|
40
|
+
startedHere(env: string, runId: string, subject: string | undefined): Promise<boolean>;
|
|
41
|
+
createAdapter(provider: ProviderConfig, options: {
|
|
42
|
+
sessionId?: string;
|
|
43
|
+
}): ModelAdapter;
|
|
44
|
+
/**
|
|
45
|
+
* A model.relay call to `env`'s engine. Without `via` it goes through any link that is up and the answer names it;
|
|
46
|
+
* with `via` only through that link, and a link that is gone answers as a link that is down.
|
|
47
|
+
*/
|
|
48
|
+
send(env: string, engine: string, method: string, params: Record<string, unknown>, via?: string): Promise<RelaySendAnswer>;
|
|
49
|
+
log(line: string): void;
|
|
50
|
+
now?: () => number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The desktop engine's half of the model relay: a linked machine's `model.relay.request` is claimed, generated with
|
|
54
|
+
* this computer's own provider, and answered with `model.relay.result`. Only machines the user allowed are answered,
|
|
55
|
+
* only for runs this computer started or resumed there, and nothing but the provider id and the model call itself
|
|
56
|
+
* comes from the machine. The announce carries no payload: it arrives in the answer to the claim.
|
|
57
|
+
*/
|
|
58
|
+
export declare class LocalModelRelay {
|
|
59
|
+
private readonly deps;
|
|
60
|
+
private readonly work;
|
|
61
|
+
private readonly ignoredLogged;
|
|
62
|
+
/**
|
|
63
|
+
* Requests this computer ignored because it does not offer their provider or model, by machine and id: when it
|
|
64
|
+
* first ignored each, and when it last saw it announced.
|
|
65
|
+
*/
|
|
66
|
+
private readonly declining;
|
|
67
|
+
/** The last announce of each request ignored because its run was not known here yet, so it can be taken once it is. */
|
|
68
|
+
private readonly unknownRun;
|
|
69
|
+
private closed;
|
|
70
|
+
constructor(deps: LocalModelRelayDeps);
|
|
71
|
+
/** Takes a `model.relay.*` frame; true when the frame was one (it is the engine's, not the window's). */
|
|
72
|
+
handle(env: string, frame: EngineFrame): boolean;
|
|
73
|
+
/** Stops every request of `env`: its link ended for good, or it is no longer allowed. */
|
|
74
|
+
dropEnvironment(env: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* This computer has just started or resumed `runId` on `env`: a request of it announced before that was known is
|
|
77
|
+
* taken now rather than at its next announce.
|
|
78
|
+
*/
|
|
79
|
+
reconsider(env: string, runId: string): void;
|
|
80
|
+
/** Stops every machine's requests: the account changed. */
|
|
81
|
+
dropAll(): void;
|
|
82
|
+
close(): void;
|
|
83
|
+
private now;
|
|
84
|
+
private key;
|
|
85
|
+
/** `env`'s requests in hand: generating, or answered and waiting to be delivered. */
|
|
86
|
+
private inHand;
|
|
87
|
+
private onRequest;
|
|
88
|
+
private onCancel;
|
|
89
|
+
private ignored;
|
|
90
|
+
private live;
|
|
91
|
+
/**
|
|
92
|
+
* Whether a request this computer does not offer has waited long enough for another desktop to take it. The first
|
|
93
|
+
* time it is seen the clock starts; every announce after that keeps it remembered.
|
|
94
|
+
*/
|
|
95
|
+
private declineDue;
|
|
96
|
+
private start;
|
|
97
|
+
/** Claims a request this computer no longer offers and answers that it does not, with no model call. */
|
|
98
|
+
private rememberUnknownRun;
|
|
99
|
+
private decline;
|
|
100
|
+
/** Holds `outcome` for delivery, for at most LOCAL_RELAY_RESULT_HOLD_MS, and sends it. */
|
|
101
|
+
private answer;
|
|
102
|
+
private generate;
|
|
103
|
+
/** Sends a progress call; one that fails (the link is down) is let go, and generation goes on. */
|
|
104
|
+
private progress;
|
|
105
|
+
private reason;
|
|
106
|
+
private scheduleReasoning;
|
|
107
|
+
/** Generation is over: the last batched reasoning goes out first, then the timers that served it stop. */
|
|
108
|
+
private finishGenerating;
|
|
109
|
+
/**
|
|
110
|
+
* Sends the answer. Delivered or refused by the machine, the work is done with it, except that a refusal leaves the
|
|
111
|
+
* answer held for a re-announce; a link that is down keeps it and tries again every 5 s until the hold expires.
|
|
112
|
+
*/
|
|
113
|
+
private deliver;
|
|
114
|
+
private reclaim;
|
|
115
|
+
private end;
|
|
116
|
+
}
|