@andorra-labs/code 0.1.16 → 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-execution.js +11 -8
- package/dist/src/agent-mcp-catalog.js +1 -0
- package/dist/src/agent-mcp.d.ts +3 -0
- package/dist/src/agent-mcp.js +33 -1
- 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 +19 -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 +358 -32
- package/dist/src/app-server.js +2429 -509
- 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-server.js +7 -1
- package/dist/src/browser-ui/tokens.css +1 -1
- package/dist/src/change-authors.d.ts +41 -0
- package/dist/src/change-authors.js +146 -0
- package/dist/src/cli.js +182 -32
- package/dist/src/coding-tools.js +15 -15
- package/dist/src/command-screens.d.ts +6 -0
- package/dist/src/command-screens.js +14 -11
- package/dist/src/commands.d.ts +14 -2
- package/dist/src/compaction-phrases.js +1 -1
- 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/deadline.js +13 -1
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/requestPhrases.js +0 -1
- 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-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 +6 -1
- 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 +2 -1
- package/dist/src/graph-runner.js +64 -3
- package/dist/src/graph-server.js +3 -3
- package/dist/src/graph-sync.js +3 -3
- package/dist/src/graph-ui/app.js +91 -7
- package/dist/src/graph-ui/icons.js +2 -1
- package/dist/src/graph-ui/studio.js +15 -1
- package/dist/src/graph-ui/tokens.css +1 -1
- package/dist/src/graphs.d.ts +34 -1
- package/dist/src/graphs.js +158 -14
- package/dist/src/image-input.d.ts +16 -0
- package/dist/src/image-input.js +41 -0
- package/dist/src/membership.d.ts +10 -0
- package/dist/src/membership.js +19 -4
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +6 -0
- package/dist/src/model-metadata.js +35 -15
- 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/project-registry.d.ts +21 -0
- package/dist/src/project-registry.js +74 -0
- package/dist/src/provider-import.d.ts +0 -12
- package/dist/src/provider-import.js +7 -195
- package/dist/src/providers.d.ts +23 -2
- package/dist/src/providers.js +25 -4
- package/dist/src/pull-request-logs.d.ts +12 -1
- package/dist/src/pull-request-logs.js +14 -3
- package/dist/src/pull-requests.d.ts +327 -7
- package/dist/src/pull-requests.js +429 -51
- package/dist/src/react-runtime.js +1 -1
- package/dist/src/remote/engine-pool.d.ts +88 -4
- package/dist/src/remote/engine-pool.js +366 -89
- 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 +7 -0
- package/dist/src/run-control.js +23 -0
- package/dist/src/run-records.d.ts +7 -2
- package/dist/src/run-records.js +71 -6
- package/dist/src/runtime.d.ts +5 -1
- package/dist/src/runtime.js +10 -2
- 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/telemetry/emitter.d.ts +15 -0
- package/dist/src/telemetry/emitter.js +35 -1
- package/dist/src/telemetry/schema.d.ts +25 -2
- package/dist/src/telemetry/schema.js +52 -4
- package/dist/src/telemetry/surface.d.ts +2 -1
- package/dist/src/telemetry/surface.js +4 -1
- 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/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
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const IMAGE_INPUT_UNSUPPORTED_NOTE = '[Image omitted: this model cannot view images. If the image is a file, inspect it with a script or command instead.]';
|
|
2
|
+
/** Whether `model` may be sent images. Ids are matched as providerModelId matches them: exactly, then case-folded. */
|
|
3
|
+
export function acceptsImages(provider, model) {
|
|
4
|
+
const listed = provider.textOnlyModels;
|
|
5
|
+
if (!Array.isArray(listed) || !listed.length)
|
|
6
|
+
return true;
|
|
7
|
+
if (listed.includes(model))
|
|
8
|
+
return false;
|
|
9
|
+
const folded = model.toLowerCase();
|
|
10
|
+
return !listed.some(item => typeof item === 'string' && item.toLowerCase() === folded);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The messages with every image removed and the note in its place. The input is never changed, so the run's
|
|
14
|
+
* history keeps its images for a later request to a model that accepts them. Returns the same array when no
|
|
15
|
+
* message carries an image.
|
|
16
|
+
*/
|
|
17
|
+
export function withoutImages(messages) {
|
|
18
|
+
if (!messages.some(message => message.images?.length))
|
|
19
|
+
return messages;
|
|
20
|
+
return messages.map(message => {
|
|
21
|
+
if (!message.images?.length)
|
|
22
|
+
return message;
|
|
23
|
+
const { images: _images, ...rest } = message;
|
|
24
|
+
return { ...rest, content: `${message.content}\n${IMAGE_INPUT_UNSUPPORTED_NOTE}` };
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** An adapter that keeps images out of every request for one of the provider's text-only models. */
|
|
28
|
+
export function textOnlyAdapter(adapter, provider) {
|
|
29
|
+
if (!provider.textOnlyModels?.length)
|
|
30
|
+
return adapter;
|
|
31
|
+
return {
|
|
32
|
+
...adapter,
|
|
33
|
+
generate: request => {
|
|
34
|
+
if (acceptsImages(provider, request.model))
|
|
35
|
+
return adapter.generate(request);
|
|
36
|
+
const messages = withoutImages(request.messages);
|
|
37
|
+
return adapter.generate(messages === request.messages ? request : { ...request, messages });
|
|
38
|
+
},
|
|
39
|
+
...(adapter.listModels ? { listModels: signal => adapter.listModels(signal) } : {}),
|
|
40
|
+
};
|
|
41
|
+
}
|
package/dist/src/membership.d.ts
CHANGED
|
@@ -56,6 +56,8 @@ export interface MembershipDependencies {
|
|
|
56
56
|
paid: boolean;
|
|
57
57
|
tier?: string;
|
|
58
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;
|
|
59
61
|
}
|
|
60
62
|
export declare function createMembershipClient(deps: MembershipDependencies): (signal?: AbortSignal, home?: string) => Promise<Membership>;
|
|
61
63
|
export declare const getMembership: (signal?: AbortSignal, home?: string) => Promise<Membership>;
|
|
@@ -78,3 +80,11 @@ export declare function loadAccessibleGraph(id?: string, signal?: AbortSignal, m
|
|
|
78
80
|
allowDeleted?: boolean;
|
|
79
81
|
allowRetired?: boolean;
|
|
80
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,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_AGENT_GRAPH } from './default-graph.js';
|
|
2
|
-
import { DEFAULT_HARNESS,
|
|
2
|
+
import { DEFAULT_HARNESS, builtInGraph, GraphDeletedError, isDeletedGraph, loadGraph, validateGraph } from './graphs.js';
|
|
3
3
|
import { AUTH_REFRESH_BUDGET_MS, AuthError, getAccessToken, getAuthConfiguration, getAuthStatus } from './auth/index.js';
|
|
4
4
|
import { readOfflinePlan, storePlanPass } from './plan-pass.js';
|
|
5
5
|
import { graphStorageDirectory } from './graph-account.js';
|
|
@@ -96,6 +96,7 @@ export function safeAccountEmail(value) {
|
|
|
96
96
|
}
|
|
97
97
|
export { PaidMembershipRequiredError } from './membership-errors.js';
|
|
98
98
|
import { PaidMembershipRequiredError } from './membership-errors.js';
|
|
99
|
+
const LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '[::1]']);
|
|
99
100
|
async function recordPlanConfirmation(answer, home) {
|
|
100
101
|
const directory = home ?? configDirectory();
|
|
101
102
|
const observedAt = new Date().toISOString();
|
|
@@ -113,7 +114,8 @@ export function createMembershipClient(deps) {
|
|
|
113
114
|
return { paid: false };
|
|
114
115
|
bounded = signal ? AbortSignal.any([signal, AbortSignal.timeout(5000)]) : AbortSignal.timeout(5000);
|
|
115
116
|
const base = new URL(deps.apiBaseUrl());
|
|
116
|
-
|
|
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)
|
|
117
119
|
return { paid: false };
|
|
118
120
|
const response = await deps.fetch(`${base.href.replace(/\/+$/, '')}/me`, {
|
|
119
121
|
headers: { Authorization: `Bearer ${token}` }, signal: bounded, redirect: 'error',
|
|
@@ -235,8 +237,9 @@ export async function loadAccessibleGraph(id = 'default', signal, membership = g
|
|
|
235
237
|
}
|
|
236
238
|
if (currentGraphSelection(id) === 'default')
|
|
237
239
|
return structuredClone(SOFTWARE_ENGINEER_HARNESS);
|
|
238
|
-
|
|
239
|
-
|
|
240
|
+
const builtIn = builtInGraph(id);
|
|
241
|
+
if (builtIn)
|
|
242
|
+
return builtIn;
|
|
240
243
|
const access = await membership(signal);
|
|
241
244
|
signal?.throwIfAborted();
|
|
242
245
|
if (!access.paid && access.unavailable)
|
|
@@ -255,3 +258,15 @@ export async function loadAccessibleGraph(id = 'default', signal, membership = g
|
|
|
255
258
|
return graph;
|
|
256
259
|
return bindPortableGraphProviders(graph, await loadConfig());
|
|
257
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))
|
|
@@ -7,5 +7,11 @@ export declare function resolveModelContext(provider: ProviderConfig, model: str
|
|
|
7
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[]>;
|
|
@@ -38,35 +38,53 @@ export function withEvaluationReasoningEffort(snapshot, effort) {
|
|
|
38
38
|
export async function refreshModelContext(provider, signal) {
|
|
39
39
|
const snapshot = configuredModelSnapshot(provider, undefined);
|
|
40
40
|
signal.throwIfAborted();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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;
|
|
49
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.
|
|
50
64
|
// Andorra entries carry the router's windows already (saved from GET /v1/hosted).
|
|
51
|
-
|
|
52
|
-
|
|
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;
|
|
53
68
|
try {
|
|
54
69
|
// The raw listing: a catalog default must not displace a window the user saved.
|
|
55
70
|
const models = await listModelMetadata(snapshot, signal);
|
|
56
71
|
signal.throwIfAborted();
|
|
57
|
-
|
|
58
|
-
if (reported !== undefined)
|
|
59
|
-
snapshot.contextWindow = reported;
|
|
72
|
+
return models;
|
|
60
73
|
}
|
|
61
74
|
catch {
|
|
62
75
|
signal.throwIfAborted();
|
|
76
|
+
return undefined;
|
|
63
77
|
}
|
|
64
|
-
|
|
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) {
|
|
65
84
|
const known = knownClaudeContextWindow(snapshot.model);
|
|
66
85
|
if (known !== undefined)
|
|
67
86
|
snapshot.contextWindow = known;
|
|
68
87
|
}
|
|
69
|
-
return snapshot;
|
|
70
88
|
}
|
|
71
89
|
function object(value) {
|
|
72
90
|
return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
@@ -105,6 +123,8 @@ export async function discoverModelMetadata(provider, signal) {
|
|
|
105
123
|
return provider.type === 'anthropic' ? models.map(model => model.contextWindow === undefined ? withKnownClaudeWindow(model.id) : model) : models;
|
|
106
124
|
}
|
|
107
125
|
async function listModelMetadata(provider, signal) {
|
|
126
|
+
if (provider.type === 'relayed')
|
|
127
|
+
throw new Error('A relayed provider lists its models on your computer.');
|
|
108
128
|
validateConfig({ version: 1, provider: provider.id, providers: [provider] });
|
|
109
129
|
if (provider.type === 'codex')
|
|
110
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
|
+
}
|