@linkshell/wire 0.2.21 → 0.2.22

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/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,8 +74,9 @@ 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 = 1;
79
+ export const HOST_PROTOCOL = 2;
78
80
 
79
81
  const empty = z.object({}).passthrough();
80
82
 
@@ -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
@@ -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({ type: z.literal("mcp"), server: z.string(), tool: z.string() }),
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. */