@linkshell/wire 0.2.21 → 0.2.23
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/acp.d.ts +68 -430
- package/dist/acp.js +5 -5
- package/dist/acp.js.map +1 -1
- package/dist/async-questions.d.ts +2 -10
- package/dist/computer-preview.d.ts +1 -15
- package/dist/computer-preview.js +1 -1
- package/dist/computer-preview.js.map +1 -1
- package/dist/content.d.ts +211 -376
- package/dist/content.js +4 -4
- package/dist/content.js.map +1 -1
- package/dist/editor.d.ts +48 -592
- package/dist/envelopes.d.ts +53 -0
- package/dist/envelopes.js +263 -0
- package/dist/envelopes.js.map +1 -0
- package/dist/goal.d.ts +15 -48
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/live-activity.d.ts +83 -212
- package/dist/live-activity.js +1 -1
- package/dist/live-activity.js.map +1 -1
- package/dist/model.d.ts +466 -2289
- package/dist/model.js +24 -0
- package/dist/model.js.map +1 -1
- package/dist/relay.d.ts +41 -267
- package/dist/relay.js +1 -1
- package/dist/relay.js.map +1 -1
- package/dist/rpc-mcp.d.ts +84 -0
- package/dist/rpc-mcp.js +78 -0
- package/dist/rpc-mcp.js.map +1 -0
- package/dist/rpc.d.ts +6983 -31165
- package/dist/rpc.js +35 -7
- package/dist/rpc.js.map +1 -1
- package/dist/side.d.ts +13 -61
- package/dist/updates.d.ts +1827 -6736
- package/dist/updates.js +14 -1
- package/dist/updates.js.map +1 -1
- package/dist/usage.d.ts +17 -195
- package/dist/watch.d.ts +223 -1141
- package/dist/workflow.d.ts +46 -139
- package/package.json +2 -2
- package/src/acp.ts +5 -5
- package/src/computer-preview.ts +1 -1
- package/src/content.ts +5 -5
- package/src/envelopes.ts +288 -0
- package/src/index.ts +2 -0
- package/src/live-activity.ts +1 -1
- package/src/model.ts +24 -0
- package/src/relay.ts +1 -1
- package/src/rpc-mcp.ts +81 -0
- package/src/rpc.ts +35 -7
- package/src/updates.ts +15 -1
package/src/rpc-mcp.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { mcpAppDisplayModeSchema } from "./updates.js";
|
|
3
|
+
|
|
4
|
+
// MCP Apps: an MCP tool can declare a page of its own (a `ui://` HTML
|
|
5
|
+
// resource) that the client shows in a sandboxed frame, and that page can call
|
|
6
|
+
// its server's tools back. Codex sessions only: Codex is the agent that tells
|
|
7
|
+
// the host which tools have pages and lets a client read and call them. Other
|
|
8
|
+
// agents' sessions are refused with `not_supported`; a Codex that isn't
|
|
9
|
+
// running with `agent_unavailable`. Hosts older than these methods answer
|
|
10
|
+
// "method not found".
|
|
11
|
+
|
|
12
|
+
/** A tool Codex offers as an app of the thread (what its "插件和 MCP" menu lists). */
|
|
13
|
+
export const mcpAppSchema = z.object({
|
|
14
|
+
server: z.string(),
|
|
15
|
+
tool: z.string(),
|
|
16
|
+
/** The plugin's or connector's name where there is one, else the tool's. */
|
|
17
|
+
title: z.string(),
|
|
18
|
+
description: z.string().optional(),
|
|
19
|
+
/** Always `ui://…`. */
|
|
20
|
+
resourceUri: z.string(),
|
|
21
|
+
/** Where Codex offers it (`openai/ui.entrypoints[].type`): always includes "thread". */
|
|
22
|
+
entrypoints: z.array(z.string()),
|
|
23
|
+
/** Who may call the tool (`ui.visibility`: "model", "app"); absent: both. */
|
|
24
|
+
visibility: z.array(z.string()).optional(),
|
|
25
|
+
displayMode: mcpAppDisplayModeSchema.optional(),
|
|
26
|
+
/** The Codex connector (server `codex_apps`): `mcp.call` needs it there. */
|
|
27
|
+
connector: z.string().optional(),
|
|
28
|
+
});
|
|
29
|
+
export type McpApp = z.infer<typeof mcpAppSchema>;
|
|
30
|
+
|
|
31
|
+
export const mcpMethods = {
|
|
32
|
+
/** The apps the session's Codex can open in the thread. */
|
|
33
|
+
"mcp.apps": {
|
|
34
|
+
params: z.object({ sessionId: z.string().min(1) }),
|
|
35
|
+
result: z.object({ apps: z.array(mcpAppSchema) }),
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* A page's HTML (its first content), as the MCP server gives it. Only `ui://`
|
|
39
|
+
* URIs (`invalid_params` otherwise); one over 4 MB is refused (`too_large`).
|
|
40
|
+
* `meta` is the content's `_meta`: CSP domains, display modes, border.
|
|
41
|
+
*/
|
|
42
|
+
"mcp.resource": {
|
|
43
|
+
params: z.object({
|
|
44
|
+
sessionId: z.string().min(1),
|
|
45
|
+
server: z.string().min(1),
|
|
46
|
+
uri: z.string().min(1),
|
|
47
|
+
/** The page's connector (`detail.app.connector`, `McpApp.connector`), for server `codex_apps`. */
|
|
48
|
+
connector: z.string().optional(),
|
|
49
|
+
}),
|
|
50
|
+
result: z.object({
|
|
51
|
+
mimeType: z.string().optional(),
|
|
52
|
+
text: z.string().optional(),
|
|
53
|
+
blob: z.string().optional(),
|
|
54
|
+
meta: z.unknown().optional(),
|
|
55
|
+
}),
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* A page calls one of its server's tools, in the session's thread. Refused
|
|
59
|
+
* (`forbidden`) for a server without a page, a tool the page may not call
|
|
60
|
+
* (`ui.visibility` without "app", `openai/fileParams`), or, on `codex_apps`, a
|
|
61
|
+
* tool of another connector than `connector` (required there:
|
|
62
|
+
* `invalid_params` without it); `not_found` for a tool the server doesn't
|
|
63
|
+
* have. Codex's own failure is `agent_error`; a tool that ran and failed is
|
|
64
|
+
* `isError` in the result.
|
|
65
|
+
*/
|
|
66
|
+
"mcp.call": {
|
|
67
|
+
params: z.object({
|
|
68
|
+
sessionId: z.string().min(1),
|
|
69
|
+
server: z.string().min(1),
|
|
70
|
+
tool: z.string().min(1),
|
|
71
|
+
arguments: z.record(z.string(), z.unknown()).optional(),
|
|
72
|
+
connector: z.string().optional(),
|
|
73
|
+
}),
|
|
74
|
+
result: z.object({
|
|
75
|
+
content: z.array(z.unknown()),
|
|
76
|
+
structuredContent: z.unknown().optional(),
|
|
77
|
+
isError: z.boolean().optional(),
|
|
78
|
+
meta: z.unknown().optional(),
|
|
79
|
+
}),
|
|
80
|
+
},
|
|
81
|
+
} as const;
|
package/src/rpc.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
} from "./model.js";
|
|
23
23
|
import { contentBlockSchema, sessionEventSchema, sessionNoticeSchema } from "./updates.js";
|
|
24
24
|
import { sideChatSchema } from "./side.js";
|
|
25
|
+
import { mcpMethods } from "./rpc-mcp.js";
|
|
25
26
|
|
|
26
27
|
// ── JSON-RPC 2.0 framing ─────────────────────────────────────────────
|
|
27
28
|
|
|
@@ -73,10 +74,11 @@ export const RPC_APP_ERROR = -32000;
|
|
|
73
74
|
* methods or notifications an app may rely on, so an app can tell the
|
|
74
75
|
* computer is older than itself and say so (an absent revision is 0).
|
|
75
76
|
* 1: side conversations (`sessions.side`), `machine.info.protocol` itself.
|
|
77
|
+
* 2: session terminals (`terminals.create` `sessionId`, `TerminalInfo.sessionId`).
|
|
76
78
|
*/
|
|
77
|
-
export const HOST_PROTOCOL =
|
|
79
|
+
export const HOST_PROTOCOL = 2;
|
|
78
80
|
|
|
79
|
-
const empty = z.
|
|
81
|
+
const empty = z.looseObject({});
|
|
80
82
|
|
|
81
83
|
export const directoryEntrySchema = z.object({
|
|
82
84
|
name: z.string(),
|
|
@@ -109,7 +111,7 @@ const acpMethods = {
|
|
|
109
111
|
result: empty,
|
|
110
112
|
},
|
|
111
113
|
"agents.providers": {
|
|
112
|
-
params: z.object({ agent: z.string().min(1), operation: z.enum(["list", "set", "disable"]), config: z.object({ providerId: z.string(), apiType: z.string().optional(), baseUrl: z.
|
|
114
|
+
params: z.object({ agent: z.string().min(1), operation: z.enum(["list", "set", "disable"]), config: z.object({ providerId: z.string(), apiType: z.string().optional(), baseUrl: z.url().optional(), headers: z.record(z.string(), z.string()).optional() }).optional() }),
|
|
113
115
|
result: z.object({ providers: z.array(acpProviderSchema) }),
|
|
114
116
|
},
|
|
115
117
|
"agents.custom": {
|
|
@@ -149,12 +151,36 @@ const coreMethods = {
|
|
|
149
151
|
nextBefore: z.number().optional(),
|
|
150
152
|
}),
|
|
151
153
|
},
|
|
154
|
+
/**
|
|
155
|
+
* The models a new session of `agent` can start on, for choosing one before
|
|
156
|
+
* there is a session (whose own list comes later, in its `ls_config`).
|
|
157
|
+
* `current` is the one the agent takes when `sessions.create` names none:
|
|
158
|
+
* its own default, which a new session keeps unless another is picked.
|
|
159
|
+
* Agents that tell their models only to a session give what they said in
|
|
160
|
+
* the latest one opened on this computer; never asked by starting one, so
|
|
161
|
+
* empty until there has been one (`current` too may be missing then).
|
|
162
|
+
* With an empty list `sessions.create` takes no model. Hosts older than
|
|
163
|
+
* this method answer "method not found".
|
|
164
|
+
*/
|
|
165
|
+
"agents.models": {
|
|
166
|
+
params: z.object({
|
|
167
|
+
agent: z.string().min(1),
|
|
168
|
+
/** Where the session will work: an agent's project settings can choose another model. */
|
|
169
|
+
cwd: z.string().optional(),
|
|
170
|
+
}),
|
|
171
|
+
result: z.object({
|
|
172
|
+
/** As a session's model option lists them (`group`: the heading some agents put models under). */
|
|
173
|
+
models: z.array(z.object({ value: z.string(), name: z.string(), description: z.string().optional(), group: z.string().optional() })),
|
|
174
|
+
current: z.string().optional(),
|
|
175
|
+
}),
|
|
176
|
+
},
|
|
152
177
|
"sessions.create": {
|
|
153
178
|
params: z.object({
|
|
154
179
|
agent: z.string().min(1),
|
|
155
180
|
cwd: z.string().min(1),
|
|
156
181
|
prompt: z.array(contentBlockSchema).optional(),
|
|
157
182
|
clientMessageId: z.string().optional(),
|
|
183
|
+
/** One of `agents.models`' values; absent: the agent's own default. */
|
|
158
184
|
model: z.string().optional(),
|
|
159
185
|
/**
|
|
160
186
|
* Start in a new git worktree of `cwd`'s repository (its own branch, from
|
|
@@ -408,12 +434,12 @@ const coreMethods = {
|
|
|
408
434
|
args: z.array(z.string()).default([]),
|
|
409
435
|
/** The terminal's working directory and environment. */
|
|
410
436
|
cwd: z.string().optional(),
|
|
411
|
-
env: z.record(z.string()).optional(),
|
|
437
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
412
438
|
}),
|
|
413
439
|
result: z.object({
|
|
414
440
|
command: z.string(),
|
|
415
441
|
args: z.array(z.string()),
|
|
416
|
-
env: z.record(z.string()).optional(),
|
|
442
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
417
443
|
/** Set for handoff agents: the session this terminal now drives. */
|
|
418
444
|
sessionId: z.string().optional(),
|
|
419
445
|
}),
|
|
@@ -429,7 +455,7 @@ const coreMethods = {
|
|
|
429
455
|
result: z.object({
|
|
430
456
|
command: z.string(),
|
|
431
457
|
args: z.array(z.string()),
|
|
432
|
-
env: z.record(z.string()).optional(),
|
|
458
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
433
459
|
}),
|
|
434
460
|
},
|
|
435
461
|
// ── Gateway: reach this computer from anywhere ──
|
|
@@ -566,6 +592,8 @@ const coreMethods = {
|
|
|
566
592
|
"terminals.create": {
|
|
567
593
|
params: z.object({
|
|
568
594
|
cwd: z.string().optional(),
|
|
595
|
+
/** Open it for this session, in its directory unless `cwd` says otherwise (see `TerminalInfo.sessionId`). */
|
|
596
|
+
sessionId: z.string().optional(),
|
|
569
597
|
/** Run this in the shell right away (the shell stays open after it). */
|
|
570
598
|
command: z.string().max(4000).optional(),
|
|
571
599
|
cols: z.number().int().min(10).max(1000).default(80),
|
|
@@ -700,7 +728,7 @@ const coreMethods = {
|
|
|
700
728
|
},
|
|
701
729
|
} as const;
|
|
702
730
|
|
|
703
|
-
export const methods: typeof coreMethods & typeof acpMethods = { ...coreMethods, ...acpMethods };
|
|
731
|
+
export const methods: typeof coreMethods & typeof acpMethods & typeof mcpMethods = { ...coreMethods, ...acpMethods, ...mcpMethods };
|
|
704
732
|
|
|
705
733
|
export type MethodName = keyof typeof methods;
|
|
706
734
|
export type MethodParams<M extends MethodName> = z.input<(typeof methods)[M]["params"]>;
|
package/src/updates.ts
CHANGED
|
@@ -21,8 +21,22 @@ export type ToolCallLocation = z.infer<typeof toolCallLocationSchema>;
|
|
|
21
21
|
* Host drivers fill it from each agent's own tool names; clients render it the
|
|
22
22
|
* same way for every agent and fall back to `title` + `kind` without it.
|
|
23
23
|
*/
|
|
24
|
+
export const mcpAppDisplayModeSchema = z.enum(["inline", "fullscreen"]);
|
|
25
|
+
|
|
24
26
|
export const toolDetailSchema = z.discriminatedUnion("type", [
|
|
25
|
-
z.object({
|
|
27
|
+
z.object({
|
|
28
|
+
type: z.literal("mcp"),
|
|
29
|
+
server: z.string(),
|
|
30
|
+
tool: z.string(),
|
|
31
|
+
/**
|
|
32
|
+
* The tool has a page of its own (an MCP App), which `mcp.resource` reads.
|
|
33
|
+
* Codex sessions only. It may arrive in a later `tool_call_update` than the
|
|
34
|
+
* call's card, when the host had to look the tool up first. `connector`:
|
|
35
|
+
* the Codex connector (server `codex_apps`) the page belongs to, which
|
|
36
|
+
* `mcp.call` needs for that server.
|
|
37
|
+
*/
|
|
38
|
+
app: z.object({ resourceUri: z.string(), displayMode: mcpAppDisplayModeSchema.optional(), connector: z.string().optional() }).optional(),
|
|
39
|
+
}),
|
|
26
40
|
z.object({
|
|
27
41
|
type: z.literal("subagent"),
|
|
28
42
|
/** spawn starts a sub-agent (its work nests under this call); the rest talk to one. */
|