@linkshell/host 0.4.69 → 0.4.70
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/host/src/drivers/acp/antigravity.d.ts +13 -0
- package/dist/host/src/drivers/acp/antigravity.js +13 -0
- package/dist/host/src/drivers/acp/antigravity.js.map +1 -1
- package/dist/host/src/drivers/acp/driver.d.ts +14 -1
- package/dist/host/src/drivers/acp/driver.js +45 -3
- package/dist/host/src/drivers/acp/driver.js.map +1 -1
- package/dist/host/src/drivers/acp/mapper.d.ts +2 -0
- package/dist/host/src/drivers/acp/mapper.js +6 -1
- package/dist/host/src/drivers/acp/mapper.js.map +1 -1
- package/dist/host/src/drivers/claude/app-sessions.d.ts +58 -0
- package/dist/host/src/drivers/claude/app-sessions.js +183 -0
- package/dist/host/src/drivers/claude/app-sessions.js.map +1 -0
- package/dist/host/src/drivers/claude/driver.d.ts +22 -1
- package/dist/host/src/drivers/claude/driver.js +95 -10
- package/dist/host/src/drivers/claude/driver.js.map +1 -1
- package/dist/host/src/drivers/claude/holders.d.ts +3 -1
- package/dist/host/src/drivers/claude/holders.js +4 -0
- package/dist/host/src/drivers/claude/holders.js.map +1 -1
- package/dist/host/src/drivers/claude/routing.d.ts +19 -0
- package/dist/host/src/drivers/claude/routing.js +145 -0
- package/dist/host/src/drivers/claude/routing.js.map +1 -0
- package/dist/host/src/drivers/claude/transcript.d.ts +10 -0
- package/dist/host/src/drivers/claude/transcript.js +97 -22
- package/dist/host/src/drivers/claude/transcript.js.map +1 -1
- package/dist/host/src/drivers/codex/driver.d.ts +15 -0
- package/dist/host/src/drivers/codex/driver.js +47 -9
- package/dist/host/src/drivers/codex/driver.js.map +1 -1
- package/dist/host/src/drivers/codex/mapper.d.ts +41 -7
- package/dist/host/src/drivers/codex/mapper.js +167 -26
- package/dist/host/src/drivers/codex/mapper.js.map +1 -1
- package/dist/host/src/drivers/codex/mcp-apps.d.ts +69 -0
- package/dist/host/src/drivers/codex/mcp-apps.js +340 -0
- package/dist/host/src/drivers/codex/mcp-apps.js.map +1 -0
- package/dist/host/src/drivers/codex/settings.d.ts +13 -0
- package/dist/host/src/drivers/codex/settings.js +22 -6
- package/dist/host/src/drivers/codex/settings.js.map +1 -1
- package/dist/host/src/drivers/types.d.ts +50 -1
- package/dist/host/src/hub.d.ts +33 -1
- package/dist/host/src/hub.js +157 -13
- package/dist/host/src/hub.js.map +1 -1
- package/dist/host/src/rpc/mcp.d.ts +8 -0
- package/dist/host/src/rpc/mcp.js +33 -0
- package/dist/host/src/rpc/mcp.js.map +1 -0
- package/dist/host/src/rpc/server.js +16 -2
- package/dist/host/src/rpc/server.js.map +1 -1
- package/dist/host/src/store.d.ts +7 -0
- package/dist/host/src/store.js +27 -3
- package/dist/host/src/store.js.map +1 -1
- package/dist/host/src/terminals.d.ts +6 -0
- package/dist/host/src/terminals.js +29 -2
- package/dist/host/src/terminals.js.map +1 -1
- package/dist/host/src/usage.d.ts +5 -0
- package/dist/host/src/usage.js +10 -2
- package/dist/host/src/usage.js.map +1 -1
- package/dist/host/tsconfig.tsbuildinfo +1 -1
- package/dist/wire/src/envelopes.d.ts +53 -0
- package/dist/wire/src/envelopes.js +251 -0
- package/dist/wire/src/envelopes.js.map +1 -0
- package/dist/wire/src/index.d.ts +2 -0
- package/dist/wire/src/index.js +2 -0
- package/dist/wire/src/index.js.map +1 -1
- package/dist/wire/src/model.d.ts +32 -0
- package/dist/wire/src/model.js +24 -0
- package/dist/wire/src/model.js.map +1 -1
- package/dist/wire/src/rpc-mcp.d.ts +199 -0
- package/dist/wire/src/rpc-mcp.js +78 -0
- package/dist/wire/src/rpc-mcp.js.map +1 -0
- package/dist/wire/src/rpc.d.ts +494 -4
- package/dist/wire/src/rpc.js +30 -2
- package/dist/wire/src/rpc.js.map +1 -1
- package/dist/wire/src/updates.d.ts +211 -0
- package/dist/wire/src/updates.js +14 -1
- package/dist/wire/src/updates.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type McpApp, type MethodParams, type MethodResult, type ToolDetail } from "@linkshell/wire";
|
|
2
|
+
import type { McpAppsSupport } from "../types.js";
|
|
3
|
+
import { type McpToolLookup } from "./mapper.js";
|
|
4
|
+
export interface CodexMcpAppsOptions {
|
|
5
|
+
/** A request to the app-server; with `threadId`, to the server that thread is loaded in. */
|
|
6
|
+
request<T>(method: string, params: unknown, threadId?: string): Promise<T>;
|
|
7
|
+
/** Whether a thread is joined here, held by a Codex that takes no other clients, or neither. */
|
|
8
|
+
reach(threadId: string): "joined" | "held" | "unloaded";
|
|
9
|
+
/** A call's page turned out only once its tool had been looked up, after its card went out. */
|
|
10
|
+
lateDetail(threadId: string, toolCallId: string, detail: Extract<ToolDetail, {
|
|
11
|
+
type: "mcp";
|
|
12
|
+
}>): void;
|
|
13
|
+
log(message: string): void;
|
|
14
|
+
refreshCooldownMs?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare class CodexMcpApps implements McpAppsSupport {
|
|
17
|
+
private readonly options;
|
|
18
|
+
private servers;
|
|
19
|
+
private loadedAt?;
|
|
20
|
+
/** When the list was last asked for, read or not: misses wait out the cooldown from then. */
|
|
21
|
+
private triedAt?;
|
|
22
|
+
private loading?;
|
|
23
|
+
private timer?;
|
|
24
|
+
private readonly missed;
|
|
25
|
+
/**
|
|
26
|
+
* Tools a read didn't find for a call (uninstalled since): history is mapped
|
|
27
|
+
* again and again (a thread read from disk, every few seconds), and each time
|
|
28
|
+
* would have the list read again. Found again by any later read.
|
|
29
|
+
*/
|
|
30
|
+
private readonly absent;
|
|
31
|
+
/** Plugins' display names by id, as last read. */
|
|
32
|
+
private plugins;
|
|
33
|
+
private pluginsAskedAt?;
|
|
34
|
+
private pluginsReading?;
|
|
35
|
+
private pluginsAnswered;
|
|
36
|
+
private readonly cooldown;
|
|
37
|
+
constructor(options: CodexMcpAppsOptions);
|
|
38
|
+
/**
|
|
39
|
+
* Looks up the tools of a thread's calls. A tool that isn't known has the
|
|
40
|
+
* list read again, and a page found then reaches the call's card late.
|
|
41
|
+
*/
|
|
42
|
+
lookup(threadId: string): McpToolLookup;
|
|
43
|
+
apps(_nativeId: string): Promise<McpApp[]>;
|
|
44
|
+
resource(nativeId: string, request: Omit<MethodParams<"mcp.resource">, "sessionId">): Promise<MethodResult<"mcp.resource">>;
|
|
45
|
+
call(nativeId: string, request: Omit<MethodParams<"mcp.call">, "sessionId">): Promise<MethodResult<"mcp.call">>;
|
|
46
|
+
stop(): void;
|
|
47
|
+
/**
|
|
48
|
+
* A tool by the name a call or a page gives it. `codex_apps` lists its tools
|
|
49
|
+
* under their connector's namespace (`figma.generate_deck`), which a call or
|
|
50
|
+
* a page may leave out.
|
|
51
|
+
*/
|
|
52
|
+
private find;
|
|
53
|
+
private hasPage;
|
|
54
|
+
private miss;
|
|
55
|
+
private schedule;
|
|
56
|
+
/** Reads every server's tools again. Concurrent callers share one read. */
|
|
57
|
+
private load;
|
|
58
|
+
private read;
|
|
59
|
+
/** Sends the pages found for the calls that were waiting; drops the ones the list was read for and that still aren't known. */
|
|
60
|
+
private settle;
|
|
61
|
+
/**
|
|
62
|
+
* Plugins' display names by id: what was last read, or what a read answers
|
|
63
|
+
* shortly. A read that takes longer goes on for the next list; until then
|
|
64
|
+
* titles fall back to the tools' own.
|
|
65
|
+
*/
|
|
66
|
+
private pluginNames;
|
|
67
|
+
/** A Codex request, its failures said in the user's words. */
|
|
68
|
+
private codex;
|
|
69
|
+
}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { RpcError } from "@linkshell/wire";
|
|
2
|
+
import { connectorOf, descriptorPage, isPageUri, itemHasPage, mcpPage } from "./mapper.js";
|
|
3
|
+
const str = (value) => (typeof value === "string" ? value : undefined);
|
|
4
|
+
const obj = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
5
|
+
const arr = (value) => (Array.isArray(value) ? value : []);
|
|
6
|
+
/** Where Codex's connectors (Figma, GitHub, …) are served from: one server, each connector's tools under its own namespace. */
|
|
7
|
+
const CONNECTORS = "codex_apps";
|
|
8
|
+
/** A page is a few hundred KB; this keeps a runaway resource off the tunnel. */
|
|
9
|
+
const MAX_RESOURCE = 4 * 1024 * 1024;
|
|
10
|
+
/** The list is ~1 MB from Codex's connectors alone: not re-read for every unknown tool. */
|
|
11
|
+
const REFRESH_COOLDOWN_MS = 30_000;
|
|
12
|
+
/** How old a list `mcp.apps` answers from: someone opening the menu may just have installed a plugin. */
|
|
13
|
+
const APPS_MAX_AGE_MS = 30_000;
|
|
14
|
+
const MAX_PENDING = 200;
|
|
15
|
+
const MAX_PAGES = 20;
|
|
16
|
+
/** `plugin/installed` waits on remote marketplaces (30 s when one doesn't answer): the list doesn't wait longer than this for it. */
|
|
17
|
+
const PLUGIN_WAIT_MS = 1500;
|
|
18
|
+
const PLUGIN_MAX_AGE_MS = 5 * 60_000;
|
|
19
|
+
export class CodexMcpApps {
|
|
20
|
+
options;
|
|
21
|
+
servers = new Map();
|
|
22
|
+
loadedAt;
|
|
23
|
+
/** When the list was last asked for, read or not: misses wait out the cooldown from then. */
|
|
24
|
+
triedAt;
|
|
25
|
+
loading;
|
|
26
|
+
timer;
|
|
27
|
+
missed = new Map();
|
|
28
|
+
/**
|
|
29
|
+
* Tools a read didn't find for a call (uninstalled since): history is mapped
|
|
30
|
+
* again and again (a thread read from disk, every few seconds), and each time
|
|
31
|
+
* would have the list read again. Found again by any later read.
|
|
32
|
+
*/
|
|
33
|
+
absent = new Set();
|
|
34
|
+
/** Plugins' display names by id, as last read. */
|
|
35
|
+
plugins = new Map();
|
|
36
|
+
pluginsAskedAt;
|
|
37
|
+
pluginsReading;
|
|
38
|
+
pluginsAnswered = false;
|
|
39
|
+
cooldown;
|
|
40
|
+
constructor(options) {
|
|
41
|
+
this.options = options;
|
|
42
|
+
this.cooldown = options.refreshCooldownMs ?? REFRESH_COOLDOWN_MS;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Looks up the tools of a thread's calls. A tool that isn't known has the
|
|
46
|
+
* list read again, and a page found then reaches the call's card late.
|
|
47
|
+
*/
|
|
48
|
+
lookup(threadId) {
|
|
49
|
+
return (item) => {
|
|
50
|
+
const server = str(item.server);
|
|
51
|
+
const tool = str(item.tool);
|
|
52
|
+
if (!server || !tool)
|
|
53
|
+
return undefined;
|
|
54
|
+
const found = this.find(server, tool, str(obj(item.appContext)?.connectorId));
|
|
55
|
+
if (found || itemHasPage(item) || this.absent.has(`${server}\n${tool}`))
|
|
56
|
+
return found;
|
|
57
|
+
const id = str(item.id);
|
|
58
|
+
if (id)
|
|
59
|
+
this.miss(threadId, id, item);
|
|
60
|
+
return undefined;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async apps(_nativeId) {
|
|
64
|
+
if (this.loadedAt === undefined || Date.now() - this.loadedAt > APPS_MAX_AGE_MS)
|
|
65
|
+
await this.load();
|
|
66
|
+
const plugins = await this.pluginNames();
|
|
67
|
+
const apps = [];
|
|
68
|
+
for (const [serverName, server] of this.servers) {
|
|
69
|
+
for (const tool of server.tools.values()) {
|
|
70
|
+
const meta = tool._meta;
|
|
71
|
+
const entrypoints = arr(obj(meta?.["openai/ui"])?.entrypoints).flatMap((entry) => str(obj(entry)?.type) ?? []);
|
|
72
|
+
const app = descriptorPage(meta);
|
|
73
|
+
if (!app || !entrypoints.includes("thread"))
|
|
74
|
+
continue;
|
|
75
|
+
const visibility = obj(meta?.ui)?.visibility;
|
|
76
|
+
apps.push({
|
|
77
|
+
server: serverName,
|
|
78
|
+
tool: tool.name,
|
|
79
|
+
// "StupidMirror" says more than "show_screen".
|
|
80
|
+
title: str(meta?.connector_name) ?? (server.pluginId ? plugins.get(server.pluginId) : undefined) ?? tool.title ?? server.title ?? tool.name,
|
|
81
|
+
...(tool.description ? { description: tool.description } : {}),
|
|
82
|
+
resourceUri: app.resourceUri,
|
|
83
|
+
entrypoints,
|
|
84
|
+
...(Array.isArray(visibility) ? { visibility: visibility.filter((entry) => typeof entry === "string") } : {}),
|
|
85
|
+
...(app.displayMode ? { displayMode: app.displayMode } : {}),
|
|
86
|
+
...(app.connector ? { connector: app.connector } : {}),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return apps;
|
|
91
|
+
}
|
|
92
|
+
async resource(nativeId, request) {
|
|
93
|
+
if (!isPageUri(request.uri))
|
|
94
|
+
throw RpcError.app("invalid_params", "只能读取插件页面(ui:// 开头的地址)");
|
|
95
|
+
// The thread's own MCP connection, where there is one to reach; Codex reads a page without it too.
|
|
96
|
+
const threadId = this.options.reach(nativeId) === "joined" ? nativeId : undefined;
|
|
97
|
+
const result = await this.codex("mcpServer/resource/read", { ...(threadId ? { threadId } : {}), server: request.server, uri: request.uri, ...(request.connector ? { connectorId: request.connector } : {}) }, threadId, "读取插件页面");
|
|
98
|
+
const first = obj(arr(result.contents)[0]);
|
|
99
|
+
if (!first)
|
|
100
|
+
throw RpcError.app("not_found", "插件没有给出这个页面");
|
|
101
|
+
const text = str(first.text);
|
|
102
|
+
const blob = str(first.blob);
|
|
103
|
+
const size = (text?.length ?? 0) + (blob?.length ?? 0);
|
|
104
|
+
if (size > MAX_RESOURCE)
|
|
105
|
+
throw RpcError.app("too_large", `插件页面有 ${(size / 1024 / 1024).toFixed(1)} MB,超过了 ${MAX_RESOURCE / 1024 / 1024} MB 的上限`);
|
|
106
|
+
return {
|
|
107
|
+
...(str(first.mimeType) ? { mimeType: str(first.mimeType) } : {}),
|
|
108
|
+
...(text !== undefined ? { text } : {}),
|
|
109
|
+
...(blob !== undefined ? { blob } : {}),
|
|
110
|
+
...(first._meta !== undefined ? { meta: first._meta } : {}),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
async call(nativeId, request) {
|
|
114
|
+
if (this.options.reach(nativeId) === "held") {
|
|
115
|
+
throw RpcError.app("not_supported", "这个会话开在电脑的另一个 Codex 里,插件页面不能从这里调用工具");
|
|
116
|
+
}
|
|
117
|
+
const { server, tool, connector } = request;
|
|
118
|
+
if (server === CONNECTORS && !connector)
|
|
119
|
+
throw RpcError.app("invalid_params", "调用 codex_apps 的工具要说明是哪个插件(connector)");
|
|
120
|
+
let descriptor = this.find(server, tool, connector);
|
|
121
|
+
// A tool installed since the list was read: read it again, once.
|
|
122
|
+
if (!descriptor) {
|
|
123
|
+
await this.load();
|
|
124
|
+
descriptor = this.find(server, tool, connector);
|
|
125
|
+
}
|
|
126
|
+
if (!descriptor)
|
|
127
|
+
throw RpcError.app("not_found", `MCP 服务 ${server} 没有工具 ${tool}`);
|
|
128
|
+
const meta = descriptor._meta;
|
|
129
|
+
// Least privilege: a page may call its own server's tools, and only a server that has pages has them.
|
|
130
|
+
if (!this.hasPage(server, connector))
|
|
131
|
+
throw RpcError.app("forbidden", `MCP 服务 ${server} 没有插件页面,不能从页面调用它的工具`);
|
|
132
|
+
if (server === CONNECTORS && connectorOf(meta) !== connector)
|
|
133
|
+
throw RpcError.app("forbidden", "这个工具属于另一个插件,当前页面不能调用");
|
|
134
|
+
if (meta?.["openai/fileParams"] !== undefined)
|
|
135
|
+
throw RpcError.app("forbidden", "这个工具要读写电脑上的文件,插件页面不能直接调用");
|
|
136
|
+
const visibility = obj(meta?.ui)?.visibility;
|
|
137
|
+
if (Array.isArray(visibility) && !visibility.includes("app"))
|
|
138
|
+
throw RpcError.app("forbidden", "这个工具只给 Codex 自己调用,插件页面不能调用");
|
|
139
|
+
const result = await this.codex("mcpServer/tool/call",
|
|
140
|
+
// The name as the server lists it: a `codex_apps` page may leave out its connector's namespace.
|
|
141
|
+
{ threadId: nativeId, server, tool: descriptor.name, ...(request.arguments ? { arguments: request.arguments } : {}) }, nativeId, "调用插件工具");
|
|
142
|
+
return {
|
|
143
|
+
content: arr(result.content),
|
|
144
|
+
...(result.structuredContent != null ? { structuredContent: result.structuredContent } : {}),
|
|
145
|
+
...(typeof result.isError === "boolean" ? { isError: result.isError } : {}),
|
|
146
|
+
...(result._meta != null ? { meta: result._meta } : {}),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
stop() {
|
|
150
|
+
clearTimeout(this.timer);
|
|
151
|
+
this.timer = undefined;
|
|
152
|
+
this.missed.clear();
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* A tool by the name a call or a page gives it. `codex_apps` lists its tools
|
|
156
|
+
* under their connector's namespace (`figma.generate_deck`), which a call or
|
|
157
|
+
* a page may leave out.
|
|
158
|
+
*/
|
|
159
|
+
find(server, tool, connector) {
|
|
160
|
+
const tools = this.servers.get(server)?.tools;
|
|
161
|
+
if (!tools)
|
|
162
|
+
return undefined;
|
|
163
|
+
const exact = tools.get(tool);
|
|
164
|
+
if (exact && (!connector || server !== CONNECTORS || connectorOf(exact._meta) === connector))
|
|
165
|
+
return exact;
|
|
166
|
+
let match;
|
|
167
|
+
for (const [name, descriptor] of tools) {
|
|
168
|
+
if (!name.endsWith(`.${tool}`) || (connector && connectorOf(descriptor._meta) !== connector))
|
|
169
|
+
continue;
|
|
170
|
+
// Two connectors' tools of the same name: which one was meant isn't known.
|
|
171
|
+
if (match)
|
|
172
|
+
return undefined;
|
|
173
|
+
match = descriptor;
|
|
174
|
+
}
|
|
175
|
+
return match ?? exact;
|
|
176
|
+
}
|
|
177
|
+
hasPage(server, connector) {
|
|
178
|
+
for (const tool of this.servers.get(server)?.tools.values() ?? []) {
|
|
179
|
+
if ((server !== CONNECTORS || connectorOf(tool._meta) === connector) && descriptorPage(tool._meta))
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
miss(threadId, toolCallId, item) {
|
|
185
|
+
// What finding its page needs, not the whole result.
|
|
186
|
+
const result = obj(item.result);
|
|
187
|
+
this.missed.delete(toolCallId);
|
|
188
|
+
this.missed.set(toolCallId, {
|
|
189
|
+
threadId,
|
|
190
|
+
item: { id: toolCallId, server: item.server, tool: item.tool, appContext: item.appContext, mcpAppUi: item.mcpAppUi, mcpAppResourceUri: item.mcpAppResourceUri, ...(result ? { result: { _meta: result._meta } } : {}) },
|
|
191
|
+
});
|
|
192
|
+
if (this.missed.size > MAX_PENDING)
|
|
193
|
+
this.missed.delete(this.missed.keys().next().value);
|
|
194
|
+
this.schedule();
|
|
195
|
+
}
|
|
196
|
+
schedule() {
|
|
197
|
+
if (this.loading || this.timer || this.missed.size === 0)
|
|
198
|
+
return;
|
|
199
|
+
const wait = this.triedAt === undefined ? 0 : Math.max(0, this.triedAt + this.cooldown - Date.now());
|
|
200
|
+
this.timer = setTimeout(() => {
|
|
201
|
+
this.timer = undefined;
|
|
202
|
+
void this.load().catch(() => { });
|
|
203
|
+
}, wait);
|
|
204
|
+
this.timer.unref?.();
|
|
205
|
+
}
|
|
206
|
+
/** Reads every server's tools again. Concurrent callers share one read. */
|
|
207
|
+
load() {
|
|
208
|
+
if (this.loading)
|
|
209
|
+
return this.loading;
|
|
210
|
+
const asked = new Set(this.missed.keys());
|
|
211
|
+
this.triedAt = Date.now();
|
|
212
|
+
this.loading = this.read()
|
|
213
|
+
.then((servers) => {
|
|
214
|
+
this.servers = servers;
|
|
215
|
+
this.loadedAt = Date.now();
|
|
216
|
+
this.settle(asked);
|
|
217
|
+
})
|
|
218
|
+
.catch((error) => {
|
|
219
|
+
// (An older Codex without the list fails every time: the calls it was read for get no page.)
|
|
220
|
+
for (const toolCallId of asked)
|
|
221
|
+
this.missed.delete(toolCallId);
|
|
222
|
+
this.options.log(`[codex] couldn't list MCP tools: ${error instanceof Error ? error.message : String(error)}`);
|
|
223
|
+
throw error;
|
|
224
|
+
})
|
|
225
|
+
.finally(() => {
|
|
226
|
+
this.loading = undefined;
|
|
227
|
+
// Calls that came in while the list was being read may name tools it predates.
|
|
228
|
+
this.schedule();
|
|
229
|
+
});
|
|
230
|
+
return this.loading;
|
|
231
|
+
}
|
|
232
|
+
async read() {
|
|
233
|
+
const servers = new Map();
|
|
234
|
+
let cursor;
|
|
235
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
236
|
+
const result = await this.codex("mcpServerStatus/list",
|
|
237
|
+
// Tools and their metadata are enough; resources would add every server's inventory.
|
|
238
|
+
{ detail: "toolsAndAuthOnly", limit: 100, ...(cursor ? { cursor } : {}) }, undefined, "列出 MCP 工具");
|
|
239
|
+
for (const raw of arr(result.data)) {
|
|
240
|
+
const entry = obj(raw);
|
|
241
|
+
const name = str(entry?.name);
|
|
242
|
+
if (!entry || !name)
|
|
243
|
+
continue;
|
|
244
|
+
const tools = new Map();
|
|
245
|
+
for (const [key, value] of Object.entries(obj(entry.tools) ?? {})) {
|
|
246
|
+
const tool = obj(value);
|
|
247
|
+
if (!tool)
|
|
248
|
+
continue;
|
|
249
|
+
// Only what pages need: the input schemas are most of the megabyte.
|
|
250
|
+
tools.set(key, {
|
|
251
|
+
name: str(tool.name) ?? key,
|
|
252
|
+
...(str(tool.title) ? { title: str(tool.title) } : {}),
|
|
253
|
+
...(str(tool.description) ? { description: str(tool.description) } : {}),
|
|
254
|
+
...(obj(tool._meta) ? { _meta: obj(tool._meta) } : {}),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
servers.set(name, { pluginId: str(entry.pluginId), title: str(obj(entry.serverInfo)?.title), tools });
|
|
258
|
+
}
|
|
259
|
+
cursor = str(result.nextCursor);
|
|
260
|
+
if (!cursor)
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
return servers;
|
|
264
|
+
}
|
|
265
|
+
/** Sends the pages found for the calls that were waiting; drops the ones the list was read for and that still aren't known. */
|
|
266
|
+
settle(asked) {
|
|
267
|
+
for (const [toolCallId, missed] of [...this.missed]) {
|
|
268
|
+
const server = str(missed.item.server);
|
|
269
|
+
const tool = str(missed.item.tool);
|
|
270
|
+
const descriptor = server && tool ? this.find(server, tool, str(obj(missed.item.appContext)?.connectorId)) : undefined;
|
|
271
|
+
if (!descriptor && !asked.has(toolCallId))
|
|
272
|
+
continue;
|
|
273
|
+
this.missed.delete(toolCallId);
|
|
274
|
+
if (!descriptor) {
|
|
275
|
+
this.absent.add(`${server}\n${tool}`);
|
|
276
|
+
if (this.absent.size > MAX_PENDING)
|
|
277
|
+
this.absent.delete(this.absent.values().next().value);
|
|
278
|
+
}
|
|
279
|
+
const app = descriptor ? mcpPage(missed.item, () => descriptor) : undefined;
|
|
280
|
+
if (app)
|
|
281
|
+
this.options.lateDetail(missed.threadId, toolCallId, { type: "mcp", server: server, tool: tool, app });
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Plugins' display names by id: what was last read, or what a read answers
|
|
286
|
+
* shortly. A read that takes longer goes on for the next list; until then
|
|
287
|
+
* titles fall back to the tools' own.
|
|
288
|
+
*/
|
|
289
|
+
async pluginNames() {
|
|
290
|
+
if (!this.pluginsReading && (this.pluginsAskedAt === undefined || Date.now() - this.pluginsAskedAt > PLUGIN_MAX_AGE_MS)) {
|
|
291
|
+
this.pluginsAskedAt = Date.now();
|
|
292
|
+
this.pluginsReading = this.options
|
|
293
|
+
.request("plugin/installed", {})
|
|
294
|
+
.then((result) => {
|
|
295
|
+
const names = new Map();
|
|
296
|
+
for (const marketplace of arr(result.marketplaces)) {
|
|
297
|
+
for (const raw of arr(obj(marketplace)?.plugins)) {
|
|
298
|
+
const plugin = obj(raw);
|
|
299
|
+
const id = str(plugin?.id);
|
|
300
|
+
const name = str(obj(plugin?.interface)?.displayName);
|
|
301
|
+
if (id && name)
|
|
302
|
+
names.set(id, name);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
// A marketplace that didn't answer this time still had its plugins' names.
|
|
306
|
+
this.plugins = new Map([...this.plugins, ...names]);
|
|
307
|
+
this.pluginsAnswered = true;
|
|
308
|
+
})
|
|
309
|
+
.catch(() => {
|
|
310
|
+
// An older Codex without it: titles stay the tools' own.
|
|
311
|
+
})
|
|
312
|
+
.finally(() => {
|
|
313
|
+
this.pluginsReading = undefined;
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
// Names read before are good enough while they are read again.
|
|
317
|
+
if (this.pluginsReading && !this.pluginsAnswered) {
|
|
318
|
+
let timer;
|
|
319
|
+
await Promise.race([this.pluginsReading, new Promise((resolve) => (timer = setTimeout(resolve, PLUGIN_WAIT_MS)))]);
|
|
320
|
+
clearTimeout(timer);
|
|
321
|
+
}
|
|
322
|
+
return this.plugins;
|
|
323
|
+
}
|
|
324
|
+
/** A Codex request, its failures said in the user's words. */
|
|
325
|
+
async codex(method, params, threadId, what) {
|
|
326
|
+
try {
|
|
327
|
+
return await this.options.request(method, params, threadId);
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
if (error instanceof RpcError && error.appCode === "agent_unavailable")
|
|
331
|
+
throw RpcError.app("agent_unavailable", "电脑上的 Codex 现在没有运行");
|
|
332
|
+
if (error instanceof RpcError && error.appCode === "timeout")
|
|
333
|
+
throw RpcError.app("timeout", `Codex ${what}超时`);
|
|
334
|
+
if (error instanceof RpcError && error.appCode)
|
|
335
|
+
throw error;
|
|
336
|
+
throw RpcError.app("agent_error", `Codex 没能${what}:${error instanceof Error ? error.message : String(error)}`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
//# sourceMappingURL=mcp-apps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-apps.js","sourceRoot":"","sources":["../../../../../src/drivers/codex/mcp-apps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsE,MAAM,iBAAiB,CAAC;AAE/G,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAA8C,MAAM,aAAa,CAAC;AASvI,MAAM,GAAG,GAAG,CAAC,KAAc,EAAsB,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACpG,MAAM,GAAG,GAAG,CAAC,KAAc,EAAoB,EAAE,CAC/C,KAAK,IAAI,O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,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACnH,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,8DAA8D;IACtD,KAAK,CAAC,KAAK,CAAI,MAAc,EAAE,MAAe,EAAE,QAA4B,EAAE,IAAY;QAChG,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAI,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QACjE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,QAAQ,IAAI,KAAK,CAAC,OAAO,KAAK,mBAAmB;gBAAE,MAAM,QAAQ,CAAC,GAAG,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAC;YACrI,IAAI,KAAK,YAAY,QAAQ,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;gBAAE,MAAM,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,IAAI,IAAI,CAAC,CAAC;YAC/G,IAAI,KAAK,YAAY,QAAQ,IAAI,KAAK,CAAC,OAAO;gBAAE,MAAM,KAAK,CAAC;YAC5D,MAAM,QAAQ,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,IAAI,IAAI,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -54,6 +54,19 @@ export declare function effective(settings: CodexSettings, overrides: CodexOverr
|
|
|
54
54
|
effort: string | undefined;
|
|
55
55
|
permissions: string | undefined;
|
|
56
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* What a new thread can be started on (`agents.models`): the same list a
|
|
59
|
+
* thread's model option shows, and `configured` (config.toml's model) or else
|
|
60
|
+
* Codex's default as the one `thread/start` without a model would use.
|
|
61
|
+
*/
|
|
62
|
+
export declare function newThreadModels(models: CodexModel[], configured: string | undefined): {
|
|
63
|
+
models: {
|
|
64
|
+
value: string;
|
|
65
|
+
name: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
}[];
|
|
68
|
+
current?: string;
|
|
69
|
+
};
|
|
57
70
|
export declare function configOptions(settings: CodexSettings, overrides: CodexOverrides, models: CodexModel[]): SessionConfigOption[];
|
|
58
71
|
/** `turn/start` parameters for the pending overrides. `current` is what the thread runs with (a mode names its model). */
|
|
59
72
|
export declare function turnOverrides(overrides: CodexOverrides, current?: {
|
|
@@ -73,16 +73,32 @@ export function effective(settings, overrides, models) {
|
|
|
73
73
|
const permissions = overrides.permissions ?? presetOf(settings);
|
|
74
74
|
return { model, info, effort, permissions };
|
|
75
75
|
}
|
|
76
|
+
/** The models to choose from while `current` is in use: hidden ones only when it is one, and `current` even if Codex doesn't list it. */
|
|
77
|
+
function modelValues(models, current) {
|
|
78
|
+
const visible = models.filter((m) => !m.hidden || m.model === current);
|
|
79
|
+
if (!current || visible.length === 0)
|
|
80
|
+
return [];
|
|
81
|
+
const values = visible.map((m) => ({ value: m.model, name: m.displayName || m.model, description: m.description || undefined }));
|
|
82
|
+
if (!values.some((v) => v.value === current))
|
|
83
|
+
values.unshift({ value: current, name: current, description: undefined });
|
|
84
|
+
return values;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* What a new thread can be started on (`agents.models`): the same list a
|
|
88
|
+
* thread's model option shows, and `configured` (config.toml's model) or else
|
|
89
|
+
* Codex's default as the one `thread/start` without a model would use.
|
|
90
|
+
*/
|
|
91
|
+
export function newThreadModels(models, configured) {
|
|
92
|
+
const { model } = effective({ model: configured }, {}, models);
|
|
93
|
+
const values = modelValues(models, model);
|
|
94
|
+
return values.length > 0 ? { models: values, current: model } : { models: [] };
|
|
95
|
+
}
|
|
76
96
|
export function configOptions(settings, overrides, models) {
|
|
77
97
|
const { model, info, effort, permissions } = effective(settings, overrides, models);
|
|
78
98
|
const options = [];
|
|
79
|
-
const
|
|
80
|
-
if (model &&
|
|
81
|
-
const values = visible.map((m) => ({ value: m.model, name: m.displayName || m.model, description: m.description || undefined }));
|
|
82
|
-
if (!values.some((v) => v.value === model))
|
|
83
|
-
values.unshift({ value: model, name: model, description: undefined });
|
|
99
|
+
const values = modelValues(models, model);
|
|
100
|
+
if (model && values.length > 0)
|
|
84
101
|
options.push({ id: "model", name: "Model", category: "model", current: model, values });
|
|
85
|
-
}
|
|
86
102
|
const efforts = info?.supportedReasoningEfforts ?? [];
|
|
87
103
|
if (effort && efforts.length > 1) {
|
|
88
104
|
options.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../../../src/drivers/codex/settings.ts"],"names":[],"mappings":"AAmCA,4CAA4C;AAC5C,MAAM,CAAC,MAAM,kBAAkB,GAMzB;IACJ;QACE,EAAE,EAAE,WAAW;QACf,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,yDAAyD;QACtE,cAAc,EAAE,YAAY;QAC5B,aAAa,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE;KAC1D;IACD;QACE,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,qEAAqE;QAClF,cAAc,EAAE,YAAY;QAC5B,aAAa,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE;KACvI;IACD;QACE,EAAE,EAAE,aAAa;QACjB,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,wCAAwC;QACrD,cAAc,EAAE,OAAO;QACvB,aAAa,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;KAC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E,IAAI,EAAE;SAC3G,CAAC;IACJ,CAAC;IACD,IAAI,SAAS,CAAC,KAAK;QAAE,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;IACpD,IAAI,SAAS,CAAC,MAAM;QAAE,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IACvD,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,WAAW,CAAC,CAAC;IAC9E,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;QAC9C,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentAuth, AsyncQuestion, GoalChange, SessionGoal, AgentCapabilities, AgentTier, BackgroundTask, ContentBlock, QueuedMessage, QuestionAnswer, SessionState, SessionUpdate, SessionNotice, AcpAgentSettings, AcpFeatures, AcpProvider, PendingPermissionSummary, EditorRequest, EditorResult } from "@linkshell/wire";
|
|
1
|
+
import type { AgentAuth, AsyncQuestion, GoalChange, SessionGoal, AgentCapabilities, AgentTier, BackgroundTask, ContentBlock, QueuedMessage, QuestionAnswer, SessionState, SessionUpdate, SessionNotice, AcpAgentSettings, AcpFeatures, AcpProvider, PendingPermissionSummary, EditorRequest, EditorResult, MethodParams, MethodResult } from "@linkshell/wire";
|
|
2
2
|
import type { PreviewInput } from "../computer-preview.js";
|
|
3
3
|
import type { DriverBehavior } from "./behavior.js";
|
|
4
4
|
/** A session the agent knows about, however it was created. */
|
|
@@ -14,6 +14,17 @@ export interface DiscoveredSession {
|
|
|
14
14
|
/** When supplied, the agent's own archive state is authoritative. */
|
|
15
15
|
archived?: boolean;
|
|
16
16
|
asyncQuestions?: AsyncQuestion[];
|
|
17
|
+
/** The native id of the session (of the same agent) this one was forked from, when the agent records it. Kept by the host once seen. */
|
|
18
|
+
forkedFrom?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Where a session came from, as native ids of the same agent, most likely first (the host takes the first it has). */
|
|
21
|
+
export interface SessionLineage {
|
|
22
|
+
/** The session that started this one. */
|
|
23
|
+
parent?: string[];
|
|
24
|
+
/** The session this one was forked from. */
|
|
25
|
+
forkedFrom?: string[];
|
|
26
|
+
/** The id an app of the agent's knows the session by (the Claude app's `local_…`). */
|
|
27
|
+
appId?: string;
|
|
17
28
|
}
|
|
18
29
|
/**
|
|
19
30
|
* One completed item of native history (a message, a tool call, …) expressed as
|
|
@@ -78,6 +89,8 @@ export interface DriverHost {
|
|
|
78
89
|
queue(agent: string, nativeId: string, items: QueuedMessage[]): void;
|
|
79
90
|
/** The agent deleted a session itself (e.g. from its own UI). */
|
|
80
91
|
removed(agent: string, nativeId: string): void;
|
|
92
|
+
/** What `lineage` or `appArchive` says of these sessions changed (the agent's records did): the host takes it in and tells clients. */
|
|
93
|
+
nativeRecordsChanged?(agent: string, nativeIds: string[]): void;
|
|
81
94
|
/** The background tasks the host has on record for the session (from `ls_task` updates), to reconcile with what the agent says now. */
|
|
82
95
|
tasks(agent: string, nativeId: string): BackgroundTask[];
|
|
83
96
|
/** The terminal currently driving a handoff session, if any. */
|
|
@@ -87,6 +100,11 @@ export interface DriverHost {
|
|
|
87
100
|
get(key: string): string | undefined;
|
|
88
101
|
set(key: string, value: string): void;
|
|
89
102
|
};
|
|
103
|
+
/** Durable values for the agent as a whole, not one session (survive host restarts). */
|
|
104
|
+
agentState?(agent: string): {
|
|
105
|
+
get(key: string): string | undefined;
|
|
106
|
+
set(key: string, value: string): void;
|
|
107
|
+
};
|
|
90
108
|
log(message: string): void;
|
|
91
109
|
}
|
|
92
110
|
export interface AttachContext {
|
|
@@ -135,6 +153,12 @@ export interface LaunchSpec {
|
|
|
135
153
|
args: string[];
|
|
136
154
|
env?: Record<string, string>;
|
|
137
155
|
}
|
|
156
|
+
/** A session's MCP Apps, by the session's native id (see `mcp.*` in the wire). */
|
|
157
|
+
export interface McpAppsSupport {
|
|
158
|
+
apps(nativeId: string): Promise<MethodResult<"mcp.apps">["apps"]>;
|
|
159
|
+
resource(nativeId: string, request: Omit<MethodParams<"mcp.resource">, "sessionId">): Promise<MethodResult<"mcp.resource">>;
|
|
160
|
+
call(nativeId: string, request: Omit<MethodParams<"mcp.call">, "sessionId">): Promise<MethodResult<"mcp.call">>;
|
|
161
|
+
}
|
|
138
162
|
export interface AgentDriver {
|
|
139
163
|
readonly id: string;
|
|
140
164
|
readonly label: string;
|
|
@@ -168,6 +192,8 @@ export interface AgentDriver {
|
|
|
168
192
|
baseUrl?: string;
|
|
169
193
|
headers?: Record<string, string>;
|
|
170
194
|
}): Promise<AcpProvider[]>;
|
|
195
|
+
/** MCP tools with pages of their own (`mcp.*`); only Codex offers them. */
|
|
196
|
+
readonly mcpApps?: McpAppsSupport;
|
|
171
197
|
listSessions(limit: number): Promise<DiscoveredSession[]>;
|
|
172
198
|
/** Native archives, including sessions that disappeared from recent discovery. Never implies deletion. */
|
|
173
199
|
archivedSessions?(): Promise<string[]>;
|
|
@@ -175,6 +201,29 @@ export interface AgentDriver {
|
|
|
175
201
|
sessionExists?(nativeId: string, cwd: string): boolean;
|
|
176
202
|
/** Missing native history can be hidden reversibly; an unreadable store is not proof of deletion. */
|
|
177
203
|
nativeSessionAvailability?(nativeId: string, cwd: string): "available" | "missing" | "unknown";
|
|
204
|
+
/**
|
|
205
|
+
* Where a session came from, by records the agent keeps outside the
|
|
206
|
+
* session (the Claude desktop app's). Asked for every summary sent, so it
|
|
207
|
+
* answers from memory; `nativeRecordsChanged` says when an answer changes.
|
|
208
|
+
*/
|
|
209
|
+
lineage?(nativeId: string): SessionLineage | undefined;
|
|
210
|
+
/**
|
|
211
|
+
* Whether an app of the agent's that LinkShell can only read (the Claude
|
|
212
|
+
* desktop app) has the session archived, and the latest time it can have
|
|
213
|
+
* changed. Undefined when that app doesn't have the session, or isn't read
|
|
214
|
+
* yet. From memory, like `lineage`; the host merges it with its own flag.
|
|
215
|
+
*/
|
|
216
|
+
appArchive?(nativeId: string): {
|
|
217
|
+
archived: boolean;
|
|
218
|
+
at: number;
|
|
219
|
+
} | undefined;
|
|
220
|
+
/**
|
|
221
|
+
* The models a new session could start on, and the one it starts on when
|
|
222
|
+
* `createSession` is given none (`cwd`: where it would work). Only what the
|
|
223
|
+
* driver can say without starting a session or a turn; absent, or an empty
|
|
224
|
+
* list, where it can't.
|
|
225
|
+
*/
|
|
226
|
+
listModels?(cwd?: string): Promise<MethodResult<"agents.models">>;
|
|
178
227
|
createSession(options: {
|
|
179
228
|
cwd: string;
|
|
180
229
|
model?: string;
|