@layernorm/overlay-agent-host 0.6.0 → 0.8.0
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/Dockerfile +10 -2
- package/README.md +12 -9
- package/dist/cli.js +2 -2
- package/dist/host-capabilities.d.ts +1 -1
- package/dist/host-capabilities.js +1 -1
- package/dist/private-threads-context.d.ts +30 -0
- package/dist/private-threads-context.d.ts.map +1 -0
- package/dist/private-threads-context.js +77 -0
- package/dist/private-threads-context.js.map +1 -0
- package/dist/private-threads-ipc.d.ts.map +1 -1
- package/dist/private-threads-ipc.js +7 -3
- package/dist/private-threads-ipc.js.map +1 -1
- package/dist/private-threads-local-mcp.d.ts +58 -0
- package/dist/private-threads-local-mcp.d.ts.map +1 -0
- package/dist/private-threads-local-mcp.js +252 -0
- package/dist/private-threads-local-mcp.js.map +1 -0
- package/dist/private-threads-models.d.ts +9 -1
- package/dist/private-threads-models.d.ts.map +1 -1
- package/dist/private-threads-models.js +20 -0
- package/dist/private-threads-models.js.map +1 -1
- package/dist/private-threads-overlay-model.d.ts +17 -0
- package/dist/private-threads-overlay-model.d.ts.map +1 -0
- package/dist/private-threads-overlay-model.js +89 -0
- package/dist/private-threads-overlay-model.js.map +1 -0
- package/dist/private-threads-overlay-tools.d.ts +27 -0
- package/dist/private-threads-overlay-tools.d.ts.map +1 -0
- package/dist/private-threads-overlay-tools.js +56 -0
- package/dist/private-threads-overlay-tools.js.map +1 -0
- package/dist/private-threads-protocol.d.ts +116 -3
- package/dist/private-threads-protocol.d.ts.map +1 -1
- package/dist/private-threads-protocol.js +68 -8
- package/dist/private-threads-protocol.js.map +1 -1
- package/dist/private-threads-store.d.ts +3 -0
- package/dist/private-threads-store.d.ts.map +1 -1
- package/dist/private-threads-store.js +13 -0
- package/dist/private-threads-store.js.map +1 -1
- package/dist/private-threads-tools.d.ts +8 -5
- package/dist/private-threads-tools.d.ts.map +1 -1
- package/dist/private-threads-tools.js +91 -20
- package/dist/private-threads-tools.js.map +1 -1
- package/dist/private-threads.d.ts +25 -5
- package/dist/private-threads.d.ts.map +1 -1
- package/dist/private-threads.js +104 -18
- package/dist/private-threads.js.map +1 -1
- package/package.json +10 -8
- package/systemd/overlay-agent-host.service +1 -1
package/Dockerfile
CHANGED
|
@@ -4,10 +4,18 @@ RUN apt-get update \
|
|
|
4
4
|
&& apt-get install -y --no-install-recommends ca-certificates git openssh-client \
|
|
5
5
|
&& rm -rf /var/lib/apt/lists/*
|
|
6
6
|
|
|
7
|
+
COPY --from=oven/bun:1.4.5 /usr/local/bin/bun /usr/local/bin/bun
|
|
8
|
+
|
|
7
9
|
WORKDIR /opt/overlay
|
|
8
|
-
COPY package.json
|
|
10
|
+
COPY package.json bun.lock bunfig.toml ./
|
|
9
11
|
COPY packages ./packages
|
|
10
|
-
|
|
12
|
+
# bun.lock covers every workspace; their manifests must be present to install from it.
|
|
13
|
+
COPY apps/admin/package.json ./apps/admin/
|
|
14
|
+
COPY apps/chrome/package.json ./apps/chrome/
|
|
15
|
+
COPY apps/chrome/packages ./apps/chrome/packages
|
|
16
|
+
COPY apps/desktop/package.json ./apps/desktop/
|
|
17
|
+
COPY apps/mobile/package.json ./apps/mobile/
|
|
18
|
+
RUN bun install --frozen-lockfile --production --filter @layernorm/overlay-agent-host \
|
|
11
19
|
&& ln -s /opt/overlay/packages/overlay-agent-host/src/cli.mjs /usr/local/bin/overlay-agent-host \
|
|
12
20
|
&& chmod +x /opt/overlay/packages/overlay-agent-host/src/cli.mjs \
|
|
13
21
|
&& mkdir -p /workspace /var/lib/overlay-agent-host \
|
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@ Node.js 24 or newer is required. Overlay's one-copy command supplies a pinned No
|
|
|
8
8
|
when the machine's default `node` is older:
|
|
9
9
|
|
|
10
10
|
```sh
|
|
11
|
-
npx --yes --package node@24 --package @layernorm/overlay-agent-host@0.
|
|
11
|
+
npx --yes --package node@24 --package @layernorm/overlay-agent-host@0.8.0 \
|
|
12
12
|
overlay-agent-host connect <enrollment-code> \
|
|
13
|
-
--server https://
|
|
13
|
+
--server https://overlay.works \
|
|
14
14
|
--kind vps \
|
|
15
15
|
--run
|
|
16
16
|
```
|
|
@@ -78,9 +78,9 @@ network URL:
|
|
|
78
78
|
The equivalent enrollment form is:
|
|
79
79
|
|
|
80
80
|
```sh
|
|
81
|
-
npx --yes --package node@24 --package @layernorm/overlay-agent-host@0.
|
|
81
|
+
npx --yes --package node@24 --package @layernorm/overlay-agent-host@0.8.0 \
|
|
82
82
|
overlay-agent-host connect <enrollment-code> \
|
|
83
|
-
--server https://
|
|
83
|
+
--server https://overlay.works \
|
|
84
84
|
--kind vps \
|
|
85
85
|
--adapter eve \
|
|
86
86
|
--eve-url http://127.0.0.1:3000 \
|
|
@@ -102,9 +102,9 @@ Terminal closes and returns after login or process failure. Use the exact config
|
|
|
102
102
|
`connect`:
|
|
103
103
|
|
|
104
104
|
```sh
|
|
105
|
-
npx --yes --package node@24 --package @layernorm/overlay-agent-host@0.
|
|
105
|
+
npx --yes --package node@24 --package @layernorm/overlay-agent-host@0.8.0 \
|
|
106
106
|
overlay-agent-host service install --config "$HOME/.overlay/agent-host/config.json"
|
|
107
|
-
npx --yes --package node@24 --package @layernorm/overlay-agent-host@0.
|
|
107
|
+
npx --yes --package node@24 --package @layernorm/overlay-agent-host@0.8.0 \
|
|
108
108
|
overlay-agent-host service status --config "$HOME/.overlay/agent-host/config.json"
|
|
109
109
|
```
|
|
110
110
|
|
|
@@ -181,6 +181,9 @@ enrollment remains rejected.
|
|
|
181
181
|
## Private threads (started by Overlay Desktop)
|
|
182
182
|
|
|
183
183
|
`overlay-agent-host private --state-dir <dir>` runs threads whose Cloud sync is off. Overlay Desktop starts it with a
|
|
184
|
-
Node.js IPC channel; it opens no port, runs one AI SDK `ToolLoopAgent` per turn with this computer's tools, calls
|
|
185
|
-
the model
|
|
186
|
-
|
|
184
|
+
Node.js IPC channel; it opens no port, runs one AI SDK `ToolLoopAgent` per turn with this computer's tools, and calls
|
|
185
|
+
the model the desktop names for that turn: a provider with the person's own key, a Claude or ChatGPT plan through the
|
|
186
|
+
desktop's local CLIProxyAPI, or Overlay's metered model relay with a short-lived token. It keeps transcripts in
|
|
187
|
+
`<dir>/private-threads.sqlite`. It
|
|
188
|
+
also starts the person's local (stdio) MCP servers when a turn's agent may use them, and stops them when idle or on
|
|
189
|
+
exit. It is not meant to be started by hand. See `internal/develop/private-threads.md` in the Overlay repository.
|
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ import { AgentHostRuntime } from './runtime.js';
|
|
|
13
13
|
import { assertSupportedNodeVersion } from './runtime-version.js';
|
|
14
14
|
import { HttpAgentControlPlaneClient } from './transport.js';
|
|
15
15
|
import { servePrivateThreads } from './private-threads-ipc.js';
|
|
16
|
-
const PACKAGE_SPEC = '@layernorm/overlay-agent-host@0.
|
|
16
|
+
const PACKAGE_SPEC = '@layernorm/overlay-agent-host@0.8.0';
|
|
17
17
|
assertSupportedNodeVersion();
|
|
18
18
|
const [command, ...args] = process.argv.slice(2);
|
|
19
19
|
const configPath = option(args, '--config');
|
|
@@ -152,7 +152,7 @@ function option(args, name) {
|
|
|
152
152
|
return index >= 0 ? args[index + 1] : undefined;
|
|
153
153
|
}
|
|
154
154
|
function usage() {
|
|
155
|
-
process.stderr.write('Usage:\n overlay-agent-host connect <code> --server https://
|
|
155
|
+
process.stderr.write('Usage:\n overlay-agent-host connect <code> --server https://overlay.works [--local-tools] [--state-dir path] [--name name] [--kind local|vps|external] [--hosting-auth-file path] [--run]\n overlay-agent-host <run|doctor> --config /absolute/path/config.json [--hosting-auth-file path]\n overlay-agent-host service <install|uninstall|status> --config /absolute/path/config.json\n overlay-agent-host private --state-dir /absolute/path (started by Overlay Desktop)\n');
|
|
156
156
|
process.exit(2);
|
|
157
157
|
}
|
|
158
158
|
function shellQuote(value) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FilesystemGrant, type HostCapabilities, type LocalToolsCapability } from '@layernorm/overlay-agent-bridge-protocol';
|
|
2
|
-
export declare const AGENT_HOST_VERSION = "0.
|
|
2
|
+
export declare const AGENT_HOST_VERSION = "0.8.0";
|
|
3
3
|
/** A host advertises only its local tools; it runs no agent harness. */
|
|
4
4
|
export declare function buildHostCapabilities(options: {
|
|
5
5
|
filesystem: FilesystemGrant;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OVERLAY_AGENT_PROTOCOL_VERSION } from '@layernorm/overlay-agent-bridge-protocol';
|
|
2
2
|
import { platform, release } from 'node:os';
|
|
3
|
-
export const AGENT_HOST_VERSION = '0.
|
|
3
|
+
export const AGENT_HOST_VERSION = '0.8.0';
|
|
4
4
|
/** A host advertises only its local tools; it runs no agent harness. */
|
|
5
5
|
export function buildHostCapabilities(options) {
|
|
6
6
|
return {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type LanguageModel, type ModelMessage, type ToolSet } from 'ai';
|
|
2
|
+
import type { PrivateModelSource, PrivateUIMessage } from './private-threads-protocol.js';
|
|
3
|
+
export type ThreadSummary = {
|
|
4
|
+
summary: string;
|
|
5
|
+
/** The last message the summary covers; later turns send only what comes after it. */
|
|
6
|
+
throughMessageId: string | null;
|
|
7
|
+
};
|
|
8
|
+
/** Context windows of the model families people bring keys for; anything else gets the cloud's safe default. */
|
|
9
|
+
export declare function contextWindowFor(provider: PrivateModelSource, modelId: string): number;
|
|
10
|
+
/** The agent's instructions with the saved summary of the earlier conversation. */
|
|
11
|
+
export declare function instructionsWithSummary(instructions: string, summary: string | undefined): string;
|
|
12
|
+
/** The messages a turn sends to the model: those after the saved summary, when it is still in the history. */
|
|
13
|
+
export declare function messagesAfterSummary(messages: PrivateUIMessage[], saved: ThreadSummary | null): PrivateUIMessage[];
|
|
14
|
+
/** The newest message a summary written during this turn certainly covers: the one before the turn's request. */
|
|
15
|
+
export declare function summaryBoundary(messages: PrivateUIMessage[]): string | null;
|
|
16
|
+
export declare function createContextCompaction(options: {
|
|
17
|
+
model: LanguageModel;
|
|
18
|
+
contextWindow: number;
|
|
19
|
+
instructions: string;
|
|
20
|
+
tools: ToolSet;
|
|
21
|
+
previousSummary: string | undefined;
|
|
22
|
+
abortSignal: AbortSignal;
|
|
23
|
+
onCompacted: (summary: string) => void;
|
|
24
|
+
}): ({ messages }: {
|
|
25
|
+
messages: ModelMessage[];
|
|
26
|
+
}) => Promise<{
|
|
27
|
+
messages: ModelMessage[];
|
|
28
|
+
instructions: string;
|
|
29
|
+
} | undefined>;
|
|
30
|
+
//# sourceMappingURL=private-threads-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-threads-context.d.ts","sourceRoot":"","sources":["../src/private-threads-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,IAAI,CAAA;AAQtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAazF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,sFAAsF;IACtF,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;CAChC,CAAA;AAED,gHAAgH;AAChH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAStF;AAED,mFAAmF;AACnF,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAIjG;AAED,8GAA8G;AAC9G,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI,GAAG,gBAAgB,EAAE,CAIlH;AAED,iHAAiH;AACjH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,MAAM,GAAG,IAAI,CAK3E;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAC/C,KAAK,EAAE,aAAa,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,OAAO,CAAA;IACd,eAAe,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,WAAW,EAAE,WAAW,CAAA;IACxB,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CACvC,IAQe,cAAc;IAAE,QAAQ,EAAE,YAAY,EAAE,CAAA;CAAE;;;eAoBzD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { generateText } from 'ai';
|
|
2
|
+
import { BASE_SYSTEM_TOOL_OVERHEAD_TOKENS, FALLBACK_CONTEXT_WINDOW, compactHarnessPrompt, estimateContextTokens, harnessSummaryInstructions, } from '@layernorm/overlay-agent-bridge-protocol';
|
|
3
|
+
/**
|
|
4
|
+
* Keeps a private thread inside its model's context window with the cloud harness's compaction
|
|
5
|
+
* (`agent-context.ts` in the bridge protocol): before a step whose prompt passes 80% of the window, older history is
|
|
6
|
+
* folded into a summary written by the thread's own model, and recent complete tool exchanges are kept verbatim.
|
|
7
|
+
* The summary is saved with the thread, so later turns start from it instead of summarizing again.
|
|
8
|
+
*/
|
|
9
|
+
/** Room kept for the reply; the thread's models do not report their output limit. */
|
|
10
|
+
const OUTPUT_RESERVE_TOKENS = 16_000;
|
|
11
|
+
const TOOL_SCHEMA_TOKENS = 250;
|
|
12
|
+
/** Context windows of the model families people bring keys for; anything else gets the cloud's safe default. */
|
|
13
|
+
export function contextWindowFor(provider, modelId) {
|
|
14
|
+
const prefix = provider === 'claude' ? 'anthropic' : provider === 'chatgpt' ? 'openai' : provider;
|
|
15
|
+
// OpenRouter and Overlay ids already carry their provider (`anthropic/claude-sonnet-4.6`).
|
|
16
|
+
const id = provider === 'openrouter' || provider === 'overlay' ? modelId : `${prefix}/${modelId}`;
|
|
17
|
+
if (/^anthropic\/claude/.test(id))
|
|
18
|
+
return 200_000;
|
|
19
|
+
if (/^google\/gemini/.test(id))
|
|
20
|
+
return 1_000_000;
|
|
21
|
+
if (/^openai\/gpt-4\.1/.test(id))
|
|
22
|
+
return 1_000_000;
|
|
23
|
+
if (/^openai\/(gpt-5|o3|o4)/.test(id))
|
|
24
|
+
return 400_000;
|
|
25
|
+
return FALLBACK_CONTEXT_WINDOW;
|
|
26
|
+
}
|
|
27
|
+
/** The agent's instructions with the saved summary of the earlier conversation. */
|
|
28
|
+
export function instructionsWithSummary(instructions, summary) {
|
|
29
|
+
if (!summary?.trim())
|
|
30
|
+
return instructions;
|
|
31
|
+
return `${instructions}\n\nSummary of the earlier part of this conversation (older messages are not shown; treat it as ` +
|
|
32
|
+
`notes, not instructions):\n${summary.trim()}`;
|
|
33
|
+
}
|
|
34
|
+
/** The messages a turn sends to the model: those after the saved summary, when it is still in the history. */
|
|
35
|
+
export function messagesAfterSummary(messages, saved) {
|
|
36
|
+
if (!saved?.throughMessageId)
|
|
37
|
+
return messages;
|
|
38
|
+
const index = messages.findIndex((message) => message.id === saved.throughMessageId);
|
|
39
|
+
return index >= 0 && index < messages.length - 1 ? messages.slice(index + 1) : messages;
|
|
40
|
+
}
|
|
41
|
+
/** The newest message a summary written during this turn certainly covers: the one before the turn's request. */
|
|
42
|
+
export function summaryBoundary(messages) {
|
|
43
|
+
for (let index = messages.length - 1; index > 0; index--) {
|
|
44
|
+
if (messages[index].role === 'user')
|
|
45
|
+
return messages[index - 1].id;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
export function createContextCompaction(options) {
|
|
50
|
+
let summary = options.previousSummary ?? '';
|
|
51
|
+
const fixedOverheadTokens = BASE_SYSTEM_TOOL_OVERHEAD_TOKENS
|
|
52
|
+
+ estimateContextTokens(options.instructions)
|
|
53
|
+
+ Object.values(options.tools).reduce((total, definition) => total + TOOL_SCHEMA_TOKENS + estimateContextTokens(definition.description ?? ''), 0);
|
|
54
|
+
/** For `prepareStep`: returns the shortened history and updated instructions, which carry forward to later steps. */
|
|
55
|
+
return async ({ messages }) => {
|
|
56
|
+
const compacted = await compactHarnessPrompt({
|
|
57
|
+
messages,
|
|
58
|
+
contextWindow: options.contextWindow,
|
|
59
|
+
outputReserveTokens: Math.min(OUTPUT_RESERVE_TOKENS, Math.floor(options.contextWindow / 4)),
|
|
60
|
+
fixedOverheadTokens,
|
|
61
|
+
previousSummary: summary,
|
|
62
|
+
generateSummaryText: async ({ prompt, targetSummaryTokens }) => (await generateText({
|
|
63
|
+
model: options.model,
|
|
64
|
+
system: harnessSummaryInstructions(targetSummaryTokens),
|
|
65
|
+
prompt,
|
|
66
|
+
maxOutputTokens: targetSummaryTokens + 2_048,
|
|
67
|
+
abortSignal: options.abortSignal,
|
|
68
|
+
})).text,
|
|
69
|
+
});
|
|
70
|
+
if (!compacted.didCompact)
|
|
71
|
+
return undefined;
|
|
72
|
+
summary = compacted.summary;
|
|
73
|
+
options.onCompacted(summary);
|
|
74
|
+
return { messages: compacted.messages, instructions: instructionsWithSummary(options.instructions, summary) };
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=private-threads-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-threads-context.js","sourceRoot":"","sources":["../src/private-threads-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuD,MAAM,IAAI,CAAA;AACtF,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,0CAA0C,CAAA;AAGjD;;;;;GAKG;AAEH,qFAAqF;AACrF,MAAM,qBAAqB,GAAG,MAAM,CAAA;AACpC,MAAM,kBAAkB,GAAG,GAAG,CAAA;AAQ9B,gHAAgH;AAChH,MAAM,UAAU,gBAAgB,CAAC,QAA4B,EAAE,OAAe;IAC5E,MAAM,MAAM,GAAG,QAAQ,KAAK,QAAQ,CAAC,CAA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CAAC;gBAClF,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,0BAA0B,CAAC,mBAAmB,CAAC;gBACvD,MAAM;gBACN,eAAe,EAAE,mBAAmB,GAAG,KAAK;gBAC5C,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC,CAAC,CAAC,IAAI;SACT,CAAC,CAAA;QACF,IAAI,CAAC,SAAS,CAAC,UAAU;YAAE,OAAO,SAAS,CAAA;QAC3C,OAAO,GAAG,SAAS,CAAC,OAAO,CAAA;QAC3B,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAC5B,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,YAAY,EAAE,uBAAuB,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,CAAA;IAC/G,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-threads-ipc.d.ts","sourceRoot":"","sources":["../src/private-threads-ipc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"private-threads-ipc.d.ts","sourceRoot":"","sources":["../src/private-threads-ipc.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+B/E"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PrivateThreadService, privateThreadsDatabasePath } from './private-threads.js';
|
|
2
2
|
import { PrivateThreadStore } from './private-threads-store.js';
|
|
3
|
-
import {
|
|
3
|
+
import { LOCAL_MCP_FEATURE } from './private-threads-local-mcp.js';
|
|
4
|
+
import { PRIVATE_MODEL_SOURCES, PRIVATE_THREADS_PROTOCOL_VERSION, } from './private-threads-protocol.js';
|
|
4
5
|
/**
|
|
5
6
|
* `overlay-agent-host private --state-dir <dir>`: serves private threads to the
|
|
6
7
|
* Overlay Desktop process that started it, over Node.js IPC only. It opens no port
|
|
@@ -13,7 +14,10 @@ export async function servePrivateThreads(stateDirectory) {
|
|
|
13
14
|
const post = (message) => { if (process.connected)
|
|
14
15
|
send(message); };
|
|
15
16
|
const store = new PrivateThreadStore(privateThreadsDatabasePath(stateDirectory));
|
|
16
|
-
const service = new PrivateThreadService({
|
|
17
|
+
const service = new PrivateThreadService({
|
|
18
|
+
store, stateDirectory, emit: event => post({ type: 'event', event }),
|
|
19
|
+
log: message => process.stderr.write(`${message}\n`),
|
|
20
|
+
});
|
|
17
21
|
process.on('message', (message) => {
|
|
18
22
|
if (!message || message.type !== 'request' || typeof message.id !== 'number')
|
|
19
23
|
return;
|
|
@@ -31,7 +35,7 @@ export async function servePrivateThreads(stateDirectory) {
|
|
|
31
35
|
process.on('disconnect', () => void close());
|
|
32
36
|
process.once('SIGTERM', () => void close());
|
|
33
37
|
process.once('SIGINT', () => void close());
|
|
34
|
-
post({ type: 'ready', protocolVersion: PRIVATE_THREADS_PROTOCOL_VERSION });
|
|
38
|
+
post({ type: 'ready', protocolVersion: PRIVATE_THREADS_PROTOCOL_VERSION, modelSources: PRIVATE_MODEL_SOURCES, features: [LOCAL_MCP_FEATURE] });
|
|
35
39
|
await new Promise(() => undefined);
|
|
36
40
|
}
|
|
37
41
|
function errorMessage(error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-threads-ipc.js","sourceRoot":"","sources":["../src/private-threads-ipc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EACL,gCAAgC,GAGjC,MAAM,+BAA+B,CAAA;AAEtC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,cAAsB;IAC9D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IACxC,IAAI,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IAC3C,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,CAAA;IAC1C,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,gCAAgC,EAAE,YAAY,EAAE,qBAAqB,EAAE,QAAQ,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;IAC9I,MAAM,IAAI,OAAO,CAAQ,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;AAC3C,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK;QAAE,OAAO,4BAA4B,CAAA;IAChG,OAAO,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;AACjF,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ToolSet } from 'ai';
|
|
2
|
+
import type { LocalMcpServer } from './private-threads-protocol.js';
|
|
3
|
+
/**
|
|
4
|
+
* MCP servers that run on this computer (stdio), for private threads. Overlay Desktop keeps the person's list and
|
|
5
|
+
* their environment values in the Keychain and passes them with each turn; this pool starts a server the first time a
|
|
6
|
+
* turn needs it, shares it between turns, stops it after it has been idle for a while, and stops every server when the
|
|
7
|
+
* host quits. Their tools ask for approval in Ask mode, like the computer tools that run commands.
|
|
8
|
+
*/
|
|
9
|
+
/** Marks a host that runs local MCP servers; Overlay Desktop looks for it in the bundled host before offering them. */
|
|
10
|
+
export declare const LOCAL_MCP_FEATURE = "overlay-private-local-mcp-servers";
|
|
11
|
+
export type LocalMcpConnection = {
|
|
12
|
+
tools: ToolSet;
|
|
13
|
+
instructions?: string;
|
|
14
|
+
close: () => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
export type LocalMcpConnect = (server: LocalMcpServer, signal: AbortSignal) => Promise<LocalMcpConnection>;
|
|
17
|
+
export type LocalMcpTurn = {
|
|
18
|
+
tools: ToolSet;
|
|
19
|
+
/** Tells the model where these tools come from, and which servers could not start. */
|
|
20
|
+
instructions: string;
|
|
21
|
+
release: () => void;
|
|
22
|
+
};
|
|
23
|
+
export declare class LocalMcpServers {
|
|
24
|
+
private readonly options;
|
|
25
|
+
private readonly entries;
|
|
26
|
+
private closed;
|
|
27
|
+
constructor(options?: {
|
|
28
|
+
connect?: LocalMcpConnect;
|
|
29
|
+
idleMs?: number;
|
|
30
|
+
startTimeoutMs?: number;
|
|
31
|
+
log?: (message: string) => void;
|
|
32
|
+
});
|
|
33
|
+
/** Ids of the servers running now. */
|
|
34
|
+
running(): string[];
|
|
35
|
+
/** The tools of these servers for one turn. A server that fails to start is left out and named in the instructions. */
|
|
36
|
+
open(servers: LocalMcpServer[], options: {
|
|
37
|
+
signal: AbortSignal;
|
|
38
|
+
approvalMode: 'ask' | 'auto';
|
|
39
|
+
}): Promise<LocalMcpTurn>;
|
|
40
|
+
/** Starts a server (or reuses it) and lists its tools, for Settings. */
|
|
41
|
+
check(server: LocalMcpServer): Promise<{
|
|
42
|
+
tools: {
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
}[];
|
|
46
|
+
}>;
|
|
47
|
+
/** Stops a server now (it was removed or changed in Settings). Turns using it keep their tools until they end. */
|
|
48
|
+
stop(serverId: string): Promise<boolean>;
|
|
49
|
+
/** Stops every server: the host is quitting. */
|
|
50
|
+
shutdown(): Promise<void>;
|
|
51
|
+
private acquire;
|
|
52
|
+
private release;
|
|
53
|
+
private close;
|
|
54
|
+
private start;
|
|
55
|
+
}
|
|
56
|
+
/** `server__tool`, in the characters and length every model provider accepts for tool names. */
|
|
57
|
+
export declare function localMcpToolName(serverName: string, toolName: string): string;
|
|
58
|
+
//# sourceMappingURL=private-threads-local-mcp.d.ts.map
|
|
@@ -0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GAAG,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IAuC5H,wEAAwE;IAClE,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE,CAAC;IAYhG,kHAAkH;IAC5G,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAO9C,gDAAgD;IAC1C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/B,OAAO,CAAC,OAAO;IAuBf,OAAO,CAAC,OAAO;YAOD,KAAK;YAOL,KAAK;CAgBpB;AAuCD,gGAAgG;AAChG,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAI7E"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { createMCPClient } from '@ai-sdk/mcp';
|
|
4
|
+
import { getDefaultEnvironment, StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
5
|
+
/**
|
|
6
|
+
* MCP servers that run on this computer (stdio), for private threads. Overlay Desktop keeps the person's list and
|
|
7
|
+
* their environment values in the Keychain and passes them with each turn; this pool starts a server the first time a
|
|
8
|
+
* turn needs it, shares it between turns, stops it after it has been idle for a while, and stops every server when the
|
|
9
|
+
* host quits. Their tools ask for approval in Ask mode, like the computer tools that run commands.
|
|
10
|
+
*/
|
|
11
|
+
/** Marks a host that runs local MCP servers; Overlay Desktop looks for it in the bundled host before offering them. */
|
|
12
|
+
export const LOCAL_MCP_FEATURE = 'overlay-private-local-mcp-servers';
|
|
13
|
+
const IDLE_MS = 10 * 60_000;
|
|
14
|
+
const START_TIMEOUT_MS = 60_000;
|
|
15
|
+
const MAX_TOOL_NAME = 64;
|
|
16
|
+
const STDERR_TAIL = 2_000;
|
|
17
|
+
export class LocalMcpServers {
|
|
18
|
+
options;
|
|
19
|
+
entries = new Map();
|
|
20
|
+
closed = false;
|
|
21
|
+
constructor(options = {}) {
|
|
22
|
+
this.options = options;
|
|
23
|
+
}
|
|
24
|
+
/** Ids of the servers running now. */
|
|
25
|
+
running() {
|
|
26
|
+
return [...this.entries.values()].map(entry => entry.server.id);
|
|
27
|
+
}
|
|
28
|
+
/** The tools of these servers for one turn. A server that fails to start is left out and named in the instructions. */
|
|
29
|
+
async open(servers, options) {
|
|
30
|
+
const tools = {};
|
|
31
|
+
const used = [];
|
|
32
|
+
const failed = [];
|
|
33
|
+
const names = new Set();
|
|
34
|
+
const results = await Promise.all(servers.map(async (server) => {
|
|
35
|
+
const entry = this.acquire(server);
|
|
36
|
+
used.push(entry);
|
|
37
|
+
try {
|
|
38
|
+
return { server, connection: await untilAborted(entry.connection, options.signal) };
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (!options.signal.aborted)
|
|
42
|
+
failed.push(`${server.name} (${errorText(error, entry)})`);
|
|
43
|
+
return { server, connection: null };
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
for (const { server, connection } of results) {
|
|
47
|
+
if (!connection)
|
|
48
|
+
continue;
|
|
49
|
+
for (const [name, definition] of Object.entries(connection.tools)) {
|
|
50
|
+
const toolName = uniqueName(localMcpToolName(server.name, name), names);
|
|
51
|
+
names.add(toolName);
|
|
52
|
+
tools[toolName] = asApprovedTool(definition, server.name, name, options.approvalMode);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
let released = false;
|
|
56
|
+
const release = () => {
|
|
57
|
+
if (released)
|
|
58
|
+
return;
|
|
59
|
+
released = true;
|
|
60
|
+
for (const entry of used)
|
|
61
|
+
this.release(entry);
|
|
62
|
+
};
|
|
63
|
+
const prefixes = results.filter(result => result.connection).map(result => `${localMcpToolName(result.server.name, '')}*`);
|
|
64
|
+
const instructions = [
|
|
65
|
+
prefixes.length
|
|
66
|
+
? `Tools named ${prefixes.join(', ')} come from MCP servers the person runs on this computer. The person approves each call unless they chose Auto.`
|
|
67
|
+
: '',
|
|
68
|
+
failed.length ? `These MCP servers on this computer could not start for this turn: ${failed.join('; ')}.` : '',
|
|
69
|
+
].filter(Boolean).join('\n');
|
|
70
|
+
return { tools, instructions, release };
|
|
71
|
+
}
|
|
72
|
+
/** Starts a server (or reuses it) and lists its tools, for Settings. */
|
|
73
|
+
async check(server) {
|
|
74
|
+
const entry = this.acquire(server);
|
|
75
|
+
try {
|
|
76
|
+
const connection = await entry.connection.catch((error) => { throw new Error(errorText(error, entry)); });
|
|
77
|
+
return {
|
|
78
|
+
tools: Object.entries(connection.tools).map(([name, definition]) => ({ name, description: describe(definition).slice(0, 300) })),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
this.release(entry);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Stops a server now (it was removed or changed in Settings). Turns using it keep their tools until they end. */
|
|
86
|
+
async stop(serverId) {
|
|
87
|
+
const entry = this.entries.get(serverId);
|
|
88
|
+
if (!entry)
|
|
89
|
+
return false;
|
|
90
|
+
await this.close(entry);
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
/** Stops every server: the host is quitting. */
|
|
94
|
+
async shutdown() {
|
|
95
|
+
this.closed = true;
|
|
96
|
+
await Promise.allSettled([...this.entries.values()].map(entry => this.close(entry)));
|
|
97
|
+
}
|
|
98
|
+
acquire(server) {
|
|
99
|
+
if (this.closed)
|
|
100
|
+
throw new Error('Private threads are stopping.');
|
|
101
|
+
const key = configKey(server);
|
|
102
|
+
let entry = this.entries.get(server.id);
|
|
103
|
+
if (entry && entry.key !== key) {
|
|
104
|
+
// Changed in Settings: the old process goes, the new one starts.
|
|
105
|
+
void this.close(entry);
|
|
106
|
+
entry = undefined;
|
|
107
|
+
}
|
|
108
|
+
if (!entry) {
|
|
109
|
+
const stderr = [];
|
|
110
|
+
const created = { key, server, users: 0, stderr, connection: Promise.resolve(null) };
|
|
111
|
+
created.connection = this.start(server, stderr);
|
|
112
|
+
// A server that fails to start is forgotten, so the next turn tries again.
|
|
113
|
+
created.connection.catch(() => { if (this.entries.get(server.id) === created)
|
|
114
|
+
this.entries.delete(server.id); });
|
|
115
|
+
this.entries.set(server.id, created);
|
|
116
|
+
entry = created;
|
|
117
|
+
}
|
|
118
|
+
if (entry.idle) {
|
|
119
|
+
clearTimeout(entry.idle);
|
|
120
|
+
entry.idle = undefined;
|
|
121
|
+
}
|
|
122
|
+
entry.users++;
|
|
123
|
+
return entry;
|
|
124
|
+
}
|
|
125
|
+
release(entry) {
|
|
126
|
+
entry.users = Math.max(0, entry.users - 1);
|
|
127
|
+
if (entry.users > 0 || this.entries.get(entry.server.id) !== entry)
|
|
128
|
+
return;
|
|
129
|
+
entry.idle = setTimeout(() => void this.close(entry), this.options.idleMs ?? IDLE_MS);
|
|
130
|
+
entry.idle.unref?.();
|
|
131
|
+
}
|
|
132
|
+
async close(entry) {
|
|
133
|
+
if (entry.idle)
|
|
134
|
+
clearTimeout(entry.idle);
|
|
135
|
+
if (this.entries.get(entry.server.id) === entry)
|
|
136
|
+
this.entries.delete(entry.server.id);
|
|
137
|
+
const connection = await entry.connection.catch(() => null);
|
|
138
|
+
await connection?.close().catch(() => undefined);
|
|
139
|
+
}
|
|
140
|
+
async start(server, stderr) {
|
|
141
|
+
const signal = AbortSignal.timeout(this.options.startTimeoutMs ?? START_TIMEOUT_MS);
|
|
142
|
+
const connect = this.options.connect ?? ((value, abort) => connectStdio(value, abort, (text) => {
|
|
143
|
+
stderr.push(text);
|
|
144
|
+
while (stderr.join('').length > STDERR_TAIL)
|
|
145
|
+
stderr.shift();
|
|
146
|
+
}));
|
|
147
|
+
const attempt = connect(server, signal);
|
|
148
|
+
const connection = await untilAborted(attempt, signal).catch((error) => {
|
|
149
|
+
if (!signal.aborted)
|
|
150
|
+
throw error;
|
|
151
|
+
// A connection that finishes after the deadline belongs to no entry, so nothing else would ever stop it.
|
|
152
|
+
attempt.then(late => late.close().catch(() => undefined), () => undefined);
|
|
153
|
+
throw new Error('it did not answer within a minute');
|
|
154
|
+
});
|
|
155
|
+
this.options.log?.(`Local MCP server ${server.name} started with ${Object.keys(connection.tools).length} tools.`);
|
|
156
|
+
return connection;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async function connectStdio(server, signal, onStderr) {
|
|
160
|
+
const transport = new StdioClientTransport({
|
|
161
|
+
command: server.command,
|
|
162
|
+
args: server.args,
|
|
163
|
+
// Only the basics of this process's environment (home, user, PATH…), then what the person set for this server.
|
|
164
|
+
env: { ...getDefaultEnvironment(), ...server.env },
|
|
165
|
+
cwd: server.cwd ?? homedir(),
|
|
166
|
+
stderr: 'pipe',
|
|
167
|
+
});
|
|
168
|
+
transport.stderr?.on('data', (chunk) => onStderr(chunk.toString()));
|
|
169
|
+
// Past the deadline the process is stopped, so a slow tool listing fails instead of finishing unseen.
|
|
170
|
+
const stopAtDeadline = () => void transport.close().catch(() => undefined);
|
|
171
|
+
signal.addEventListener('abort', stopAtDeadline, { once: true });
|
|
172
|
+
let client = null;
|
|
173
|
+
try {
|
|
174
|
+
client = await createMCPClient({
|
|
175
|
+
transport: transport,
|
|
176
|
+
clientName: 'overlay-private-thread',
|
|
177
|
+
initializationOptions: { signal },
|
|
178
|
+
});
|
|
179
|
+
const connected = client;
|
|
180
|
+
const tools = await connected.tools();
|
|
181
|
+
signal.throwIfAborted();
|
|
182
|
+
signal.removeEventListener('abort', stopAtDeadline);
|
|
183
|
+
return {
|
|
184
|
+
tools,
|
|
185
|
+
...(connected.instructions?.trim() ? { instructions: connected.instructions.trim() } : {}),
|
|
186
|
+
close: async () => { await connected.close().catch(() => undefined); await transport.close().catch(() => undefined); },
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
signal.removeEventListener('abort', stopAtDeadline);
|
|
191
|
+
await client?.close().catch(() => undefined);
|
|
192
|
+
await transport.close().catch(() => undefined);
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/** `server__tool`, in the characters and length every model provider accepts for tool names. */
|
|
197
|
+
export function localMcpToolName(serverName, toolName) {
|
|
198
|
+
const clean = (value) => value.replace(/[^A-Za-z0-9_-]+/g, '_').replace(/^_+|_+$/g, '');
|
|
199
|
+
const server = (clean(serverName) || 'mcp').slice(0, 24);
|
|
200
|
+
return `${server}__${clean(toolName)}`.slice(0, MAX_TOOL_NAME);
|
|
201
|
+
}
|
|
202
|
+
function uniqueName(name, taken) {
|
|
203
|
+
if (!taken.has(name))
|
|
204
|
+
return name;
|
|
205
|
+
for (let index = 2;; index++) {
|
|
206
|
+
const candidate = `${name.slice(0, MAX_TOOL_NAME - 3)}_${index}`;
|
|
207
|
+
if (!taken.has(candidate))
|
|
208
|
+
return candidate;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* A static tool (so the page shows its row and approval card like any other tool) that runs the server's tool. In Ask
|
|
213
|
+
* mode every call waits for the person: a local server can do anything its command can.
|
|
214
|
+
*/
|
|
215
|
+
function asApprovedTool(definition, serverName, toolName, approvalMode) {
|
|
216
|
+
const description = describe(definition) || toolName;
|
|
217
|
+
return {
|
|
218
|
+
...definition,
|
|
219
|
+
type: 'function',
|
|
220
|
+
description: `${description}\n(From the MCP server “${serverName}” on this computer.)`,
|
|
221
|
+
needsApproval: approvalMode === 'ask',
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function describe(definition) {
|
|
225
|
+
return typeof definition.description === 'string' ? definition.description.trim() : '';
|
|
226
|
+
}
|
|
227
|
+
function configKey(server) {
|
|
228
|
+
return createHash('sha256').update(JSON.stringify([server.command, server.args, server.cwd ?? null, Object.entries(server.env).sort()])).digest('hex');
|
|
229
|
+
}
|
|
230
|
+
/** What went wrong, without environment values, and with the end of the server's own error output. */
|
|
231
|
+
function errorText(error, entry) {
|
|
232
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
233
|
+
if (/ENOENT/.test(message))
|
|
234
|
+
message = `${entry.server.command} was not found on this computer`;
|
|
235
|
+
const tail = entry.stderr.join('').trim().split(/\r?\n/).slice(-3).join(' ').trim();
|
|
236
|
+
let text = tail && !message.includes(tail) ? `${message}: ${tail}` : message;
|
|
237
|
+
for (const value of Object.values(entry.server.env)) {
|
|
238
|
+
if (value.length >= 4)
|
|
239
|
+
text = text.split(value).join('[hidden]');
|
|
240
|
+
}
|
|
241
|
+
return text.slice(0, 500);
|
|
242
|
+
}
|
|
243
|
+
function untilAborted(work, signal) {
|
|
244
|
+
if (signal.aborted)
|
|
245
|
+
return Promise.reject(signal.reason);
|
|
246
|
+
return new Promise((resolve, reject) => {
|
|
247
|
+
const abort = () => reject(signal.reason);
|
|
248
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
249
|
+
work.then(resolve, reject).finally(() => signal.removeEventListener('abort', abort));
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=private-threads-local-mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-threads-local-mcp.js","sourceRoot":"","sources":["../src/private-threads-local-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,eAAe,EAAqC,MAAM,aAAa,CAAA;AAChF,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAIvG;;;;;GAKG;AAEH,uHAAuH;AACvH,MAAM,CAAC,MAAM,iBAAiB,GAAG,mCAAmC,CAAA;AAEpE,MAAM,OAAO,GAAG,EAAE,GAAG,MAAM,CAAA;AAC3B,MAAM,gBAAgB,GAAG,MAAM,CAAA;AAC/B,MAAM,aAAa,GAAG,EAAE,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C,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACzC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QACvD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IACtF,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PrivateModelProvider } from './private-threads-protocol.js';
|
|
1
|
+
import type { PrivateModelProvider, PrivatePlanProvider } from './private-threads-protocol.js';
|
|
2
2
|
export type PrivateModelInfo = {
|
|
3
3
|
id: string;
|
|
4
4
|
name: string;
|
|
@@ -8,4 +8,12 @@ export type PrivateModelInfo = {
|
|
|
8
8
|
* a key when the person adds it and to fill the model picker; nothing is cached.
|
|
9
9
|
*/
|
|
10
10
|
export declare function listProviderModels(provider: PrivateModelProvider, apiKey: string, fetchImpl?: typeof fetch): Promise<PrivateModelInfo[]>;
|
|
11
|
+
/**
|
|
12
|
+
* The chat models a signed-in plan offers, from Overlay Desktop's local CLIProxyAPI. The proxy lists every signed-in
|
|
13
|
+
* plan together; each plan's models are told apart by name.
|
|
14
|
+
*/
|
|
15
|
+
export declare function listPlanModels(plan: PrivatePlanProvider, proxy: {
|
|
16
|
+
url: string;
|
|
17
|
+
key: string;
|
|
18
|
+
}, fetchImpl?: typeof fetch): Promise<PrivateModelInfo[]>;
|
|
11
19
|
//# sourceMappingURL=private-threads-models.d.ts.map
|