@linkshell/wire 0.1.3 → 0.2.1
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/direct.d.ts +22 -0
- package/dist/direct.js +37 -0
- package/dist/direct.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model.d.ts +287 -6
- package/dist/model.js +33 -0
- package/dist/model.js.map +1 -1
- package/dist/rpc.d.ts +2373 -637
- package/dist/rpc.js +48 -3
- package/dist/rpc.js.map +1 -1
- package/dist/updates.d.ts +871 -515
- package/dist/updates.js +11 -1
- package/dist/updates.js.map +1 -1
- package/package.json +1 -1
- package/src/direct.ts +44 -0
- package/src/index.ts +1 -0
- package/src/model.ts +37 -0
- package/src/rpc.ts +48 -2
- package/src/updates.ts +11 -1
package/dist/updates.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { permissionOptionSchema, sessionDriverSchema, sessionStateSchema, toolKindSchema } from "./model.js";
|
|
2
|
+
import { permissionOptionSchema, questionAnswerSchema, questionSchema, sessionDriverSchema, sessionStateSchema, toolKindSchema } from "./model.js";
|
|
3
3
|
// Session updates mirror ACP's `SessionUpdate` shapes (discriminated by
|
|
4
4
|
// `sessionUpdate`) so one renderer works for every agent. LinkShell-specific
|
|
5
5
|
// updates use the `ls_` prefix.
|
|
@@ -64,6 +64,8 @@ export const toolDetailSchema = z.discriminatedUnion("type", [
|
|
|
64
64
|
z.object({ type: z.literal("image_generation"), prompt: z.string().optional() }),
|
|
65
65
|
z.object({ type: z.literal("compaction") }),
|
|
66
66
|
z.object({ type: z.literal("review"), phase: z.enum(["started", "finished"]) }),
|
|
67
|
+
/** The agent asked the user something (the first question, when there were several). */
|
|
68
|
+
z.object({ type: z.literal("question"), text: z.string(), more: z.number().int().optional() }),
|
|
67
69
|
]);
|
|
68
70
|
export const planEntrySchema = z.object({
|
|
69
71
|
content: z.string(),
|
|
@@ -178,11 +180,19 @@ export const sessionUpdateSchema = z.discriminatedUnion("sessionUpdate", [
|
|
|
178
180
|
title: z.string(),
|
|
179
181
|
detail: z.string().optional(),
|
|
180
182
|
options: z.array(permissionOptionSchema).min(1),
|
|
183
|
+
/**
|
|
184
|
+
* The agent is asking the user something: answer with `sessions.answer`.
|
|
185
|
+
* `options` then hold what else can be done (skip the questions, stop),
|
|
186
|
+
* which is also all an app that predates questions can offer.
|
|
187
|
+
*/
|
|
188
|
+
questions: z.array(questionSchema).optional(),
|
|
181
189
|
}),
|
|
182
190
|
z.object({
|
|
183
191
|
sessionUpdate: z.literal("ls_permission_resolved"),
|
|
184
192
|
requestId: z.string(),
|
|
185
193
|
optionId: z.string().optional(),
|
|
194
|
+
/** How questions were answered, for the record. */
|
|
195
|
+
answers: z.array(questionAnswerSchema).optional(),
|
|
186
196
|
}),
|
|
187
197
|
z.object({
|
|
188
198
|
sessionUpdate: z.literal("ls_driver"),
|
package/dist/updates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updates.js","sourceRoot":"","sources":["../src/updates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"updates.js","sourceRoot":"","sources":["../src/updates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,cAAc,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEnJ,wEAAwE;AACxE,6EAA6E;AAC7E,gCAAgC;AAEhC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;I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AAC,QAAQ,EAAE;KAChC,CAAC;IACF,CAAC,CAAC,MAAM,CAAC;QACP,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;QACrC,KAAK,EAAE,kBAAkB;KAC1B,CAAC;IACF,CAAC,CAAC,MAAM,CAAC;QACP,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;QACpC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC5B,CAAC;CACH,CAAC,CAAC;AAIH,sDAAsD;AACtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAChC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,MAAM,EAAE,mBAAmB;CAC5B,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/direct.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// The direct channel: bulk streams (the screen, port previews) go from the
|
|
2
|
+
// computer to the device peer to peer, over a WebRTC data channel, instead of
|
|
3
|
+
// through the gateway. The offer and answer travel over the end-to-end
|
|
4
|
+
// encrypted RPC channel, so the gateway can neither read them nor stand in for
|
|
5
|
+
// either side; it carries only what little sets the connection up. When no
|
|
6
|
+
// direct path can be made, the streams stay on the RPC channel as before.
|
|
7
|
+
|
|
8
|
+
/** The data channel both sides use. */
|
|
9
|
+
export const DIRECT_LABEL = "linkshell-bulk";
|
|
10
|
+
|
|
11
|
+
/** The most stream bytes in one message: every WebRTC stack takes this size. */
|
|
12
|
+
export const DIRECT_CHUNK = 16 * 1024;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* STUN servers used when a host names none: they only tell each side its
|
|
16
|
+
* public address. (Several, because none of them is reachable everywhere.)
|
|
17
|
+
*/
|
|
18
|
+
export const DEFAULT_ICE_SERVERS = ["stun:stun.cloudflare.com:3478", "stun:stun.chat.bilibili.com:3478", "stun:stun.l.google.com:19302"];
|
|
19
|
+
|
|
20
|
+
export type DirectFrame =
|
|
21
|
+
| { type: "data"; stream: number; data: Uint8Array }
|
|
22
|
+
/** The sender's end of the stream is finished (`error`: why, when it broke). */
|
|
23
|
+
| { type: "close"; stream: number; error?: string };
|
|
24
|
+
|
|
25
|
+
const DATA = 1;
|
|
26
|
+
const CLOSE = 2;
|
|
27
|
+
|
|
28
|
+
export function encodeDirectFrame(frame: DirectFrame): Uint8Array {
|
|
29
|
+
const payload = frame.type === "data" ? frame.data : new TextEncoder().encode(frame.error ?? "");
|
|
30
|
+
const bytes = new Uint8Array(5 + payload.length);
|
|
31
|
+
bytes[0] = frame.type === "data" ? DATA : CLOSE;
|
|
32
|
+
new DataView(bytes.buffer).setUint32(1, frame.stream);
|
|
33
|
+
bytes.set(payload, 5);
|
|
34
|
+
return bytes;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function decodeDirectFrame(bytes: Uint8Array): DirectFrame | undefined {
|
|
38
|
+
if (bytes.length < 5) return undefined;
|
|
39
|
+
const stream = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getUint32(1);
|
|
40
|
+
const payload = bytes.subarray(5);
|
|
41
|
+
if (bytes[0] === DATA) return { type: "data", stream, data: payload };
|
|
42
|
+
if (bytes[0] === CLOSE) return { type: "close", stream, error: payload.length ? new TextDecoder().decode(payload) : undefined };
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
package/src/index.ts
CHANGED
package/src/model.ts
CHANGED
|
@@ -97,12 +97,44 @@ export const sessionActivitySchema = z.object({
|
|
|
97
97
|
export type SessionActivity = z.infer<typeof sessionActivitySchema>;
|
|
98
98
|
|
|
99
99
|
/** The oldest unanswered permission request, so lists can offer approval inline. Live only. */
|
|
100
|
+
/**
|
|
101
|
+
* Something the agent asks the user rather than asks permission for: a choice
|
|
102
|
+
* among options, several of them, or something to type (Claude's
|
|
103
|
+
* AskUserQuestion, Codex's request_user_input, an MCP server's form).
|
|
104
|
+
*/
|
|
105
|
+
export const questionSchema = z.object({
|
|
106
|
+
id: z.string(),
|
|
107
|
+
/** A short label for the question ("Auth method"). */
|
|
108
|
+
header: z.string().optional(),
|
|
109
|
+
text: z.string(),
|
|
110
|
+
/** `choice`: one of `options`; `choices`: any number of them; `text`: typed. */
|
|
111
|
+
kind: z.enum(["choice", "choices", "text"]),
|
|
112
|
+
options: z.array(z.object({ value: z.string(), label: z.string(), description: z.string().optional() })).optional(),
|
|
113
|
+
/** With options: an answer of the user's own can be typed instead of, or beside, a pick. */
|
|
114
|
+
other: z.boolean().optional(),
|
|
115
|
+
/** What is typed shouldn't be shown (a token). */
|
|
116
|
+
secret: z.boolean().optional(),
|
|
117
|
+
required: z.boolean().optional(),
|
|
118
|
+
});
|
|
119
|
+
export type Question = z.infer<typeof questionSchema>;
|
|
120
|
+
|
|
121
|
+
export const questionAnswerSchema = z.object({
|
|
122
|
+
id: z.string(),
|
|
123
|
+
/** The values picked (`choice`: at most one), or what was typed for a `text` question. */
|
|
124
|
+
values: z.array(z.string().max(20_000)).max(50),
|
|
125
|
+
/** The user's own answer beside the options. */
|
|
126
|
+
other: z.string().max(20_000).optional(),
|
|
127
|
+
});
|
|
128
|
+
export type QuestionAnswer = z.infer<typeof questionAnswerSchema>;
|
|
129
|
+
|
|
100
130
|
export const pendingPermissionSchema = z.object({
|
|
101
131
|
requestId: z.string(),
|
|
102
132
|
toolCallId: z.string().optional(),
|
|
103
133
|
title: z.string(),
|
|
104
134
|
detail: z.string().optional(),
|
|
105
135
|
options: z.array(permissionOptionSchema).min(1),
|
|
136
|
+
/** Set when this is a question to answer (`sessions.answer`) rather than a permission to give. */
|
|
137
|
+
questions: z.array(questionSchema).optional(),
|
|
106
138
|
});
|
|
107
139
|
export type PendingPermissionSummary = z.infer<typeof pendingPermissionSchema>;
|
|
108
140
|
|
|
@@ -221,6 +253,11 @@ export const machineInfoSchema = z.object({
|
|
|
221
253
|
/** The host user's home directory, so apps can show paths as `~/…`. */
|
|
222
254
|
home: z.string().optional(),
|
|
223
255
|
agents: z.array(agentInfoSchema),
|
|
256
|
+
/**
|
|
257
|
+
* The host can send bulk streams peer to peer (`direct.offer`); `iceServers`
|
|
258
|
+
* are the STUN servers both sides use to find a path.
|
|
259
|
+
*/
|
|
260
|
+
direct: z.object({ iceServers: z.array(z.string()) }).optional(),
|
|
224
261
|
});
|
|
225
262
|
export type MachineInfo = z.infer<typeof machineInfoSchema>;
|
|
226
263
|
|
package/src/rpc.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
subagentInfoSchema,
|
|
11
11
|
gitInfoSchema,
|
|
12
12
|
worktreeEntrySchema,
|
|
13
|
+
questionAnswerSchema,
|
|
13
14
|
} from "./model.js";
|
|
14
15
|
import { contentBlockSchema, sessionEventSchema } from "./updates.js";
|
|
15
16
|
|
|
@@ -196,6 +197,15 @@ export const methods = {
|
|
|
196
197
|
}),
|
|
197
198
|
result: empty,
|
|
198
199
|
},
|
|
200
|
+
/**
|
|
201
|
+
* Answers the questions of a pending request (an `ls_permission` with
|
|
202
|
+
* `questions`). Skipping or stopping instead is `sessions.permission` with
|
|
203
|
+
* one of the request's options.
|
|
204
|
+
*/
|
|
205
|
+
"sessions.answer": {
|
|
206
|
+
params: z.object({ sessionId: z.string().min(1), requestId: z.string().min(1), answers: z.array(questionAnswerSchema).max(50) }),
|
|
207
|
+
result: empty,
|
|
208
|
+
},
|
|
199
209
|
"sessions.setConfig": {
|
|
200
210
|
params: z.object({
|
|
201
211
|
sessionId: z.string().min(1),
|
|
@@ -448,8 +458,23 @@ export const methods = {
|
|
|
448
458
|
* host's bytes arrive as `proxy.data`; the stream ends with `proxy.closed`.
|
|
449
459
|
*/
|
|
450
460
|
"proxy.open": {
|
|
451
|
-
params: z.object({
|
|
452
|
-
|
|
461
|
+
params: z.object({
|
|
462
|
+
port: z.number().int().min(1).max(65535),
|
|
463
|
+
/** Carry the stream on the direct channel, if this connection has one open. */
|
|
464
|
+
direct: z.boolean().optional(),
|
|
465
|
+
}),
|
|
466
|
+
/** `channel`: the stream's number on the direct channel, when it goes there instead of over `proxy.*`. */
|
|
467
|
+
result: z.object({ streamId: z.string(), channel: z.number().int().nonnegative().optional() }),
|
|
468
|
+
},
|
|
469
|
+
/**
|
|
470
|
+
* Sets up the direct channel (see `direct.ts`): the device's WebRTC offer,
|
|
471
|
+
* holding the `linkshell-bulk` data channel, answered by the host. Each side
|
|
472
|
+
* has gathered its addresses before sending. A new offer replaces the
|
|
473
|
+
* connection made by an earlier one.
|
|
474
|
+
*/
|
|
475
|
+
"direct.offer": {
|
|
476
|
+
params: z.object({ sdp: z.string().min(1).max(200_000) }),
|
|
477
|
+
result: z.object({ sdp: z.string() }),
|
|
453
478
|
},
|
|
454
479
|
/**
|
|
455
480
|
* Starts the host's screen viewer: a page plus H.264 stream on a loopback
|
|
@@ -463,6 +488,27 @@ export const methods = {
|
|
|
463
488
|
displays: z.array(z.object({ index: z.number().int(), name: z.string() })),
|
|
464
489
|
}),
|
|
465
490
|
},
|
|
491
|
+
/**
|
|
492
|
+
* Whether this computer's screen can be watched and controlled: the capture
|
|
493
|
+
* program, and the two permissions the system gives to an app by name. With
|
|
494
|
+
* `ask`, the system puts its own question for the first one missing and opens
|
|
495
|
+
* its settings page there, on the computer.
|
|
496
|
+
*/
|
|
497
|
+
"screen.access": {
|
|
498
|
+
params: z.object({ ask: z.boolean().optional() }),
|
|
499
|
+
result: z.object({
|
|
500
|
+
/** This kind of computer can show its screen at all. */
|
|
501
|
+
supported: z.boolean(),
|
|
502
|
+
ffmpeg: z.boolean(),
|
|
503
|
+
/** May record the screen / post pointer and key events; null where that isn't known. */
|
|
504
|
+
recording: z.boolean().nullable(),
|
|
505
|
+
control: z.boolean().nullable(),
|
|
506
|
+
/** The app the system lists for these permissions: the one to allow. */
|
|
507
|
+
app: z.string().optional(),
|
|
508
|
+
/** Why the answer is missing, or what stands in the way besides the permissions. */
|
|
509
|
+
problem: z.string().optional(),
|
|
510
|
+
}),
|
|
511
|
+
},
|
|
466
512
|
/** Bytes to the host's end of a stream (base64). */
|
|
467
513
|
"proxy.write": {
|
|
468
514
|
params: z.object({ streamId: z.string().min(1), data: z.string().max(2_000_000) }),
|
package/src/updates.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { permissionOptionSchema, sessionDriverSchema, sessionStateSchema, toolKindSchema } from "./model.js";
|
|
2
|
+
import { permissionOptionSchema, questionAnswerSchema, questionSchema, sessionDriverSchema, sessionStateSchema, toolKindSchema } from "./model.js";
|
|
3
3
|
|
|
4
4
|
// Session updates mirror ACP's `SessionUpdate` shapes (discriminated by
|
|
5
5
|
// `sessionUpdate`) so one renderer works for every agent. LinkShell-specific
|
|
@@ -74,6 +74,8 @@ export const toolDetailSchema = z.discriminatedUnion("type", [
|
|
|
74
74
|
z.object({ type: z.literal("image_generation"), prompt: z.string().optional() }),
|
|
75
75
|
z.object({ type: z.literal("compaction") }),
|
|
76
76
|
z.object({ type: z.literal("review"), phase: z.enum(["started", "finished"]) }),
|
|
77
|
+
/** The agent asked the user something (the first question, when there were several). */
|
|
78
|
+
z.object({ type: z.literal("question"), text: z.string(), more: z.number().int().optional() }),
|
|
77
79
|
]);
|
|
78
80
|
export type ToolDetail = z.infer<typeof toolDetailSchema>;
|
|
79
81
|
|
|
@@ -198,11 +200,19 @@ export const sessionUpdateSchema = z.discriminatedUnion("sessionUpdate", [
|
|
|
198
200
|
title: z.string(),
|
|
199
201
|
detail: z.string().optional(),
|
|
200
202
|
options: z.array(permissionOptionSchema).min(1),
|
|
203
|
+
/**
|
|
204
|
+
* The agent is asking the user something: answer with `sessions.answer`.
|
|
205
|
+
* `options` then hold what else can be done (skip the questions, stop),
|
|
206
|
+
* which is also all an app that predates questions can offer.
|
|
207
|
+
*/
|
|
208
|
+
questions: z.array(questionSchema).optional(),
|
|
201
209
|
}),
|
|
202
210
|
z.object({
|
|
203
211
|
sessionUpdate: z.literal("ls_permission_resolved"),
|
|
204
212
|
requestId: z.string(),
|
|
205
213
|
optionId: z.string().optional(),
|
|
214
|
+
/** How questions were answered, for the record. */
|
|
215
|
+
answers: z.array(questionAnswerSchema).optional(),
|
|
206
216
|
}),
|
|
207
217
|
z.object({
|
|
208
218
|
sessionUpdate: z.literal("ls_driver"),
|