@linkshell/wire 0.2.1 → 0.2.3
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/README.md +1 -1
- package/dist/computer-preview.d.ts +35 -0
- package/dist/computer-preview.js +51 -0
- package/dist/computer-preview.js.map +1 -0
- package/dist/goal.d.ts +66 -0
- package/dist/goal.js +19 -0
- package/dist/goal.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/model.d.ts +302 -32
- package/dist/model.js +37 -0
- package/dist/model.js.map +1 -1
- package/dist/relay.d.ts +2 -2
- package/dist/rpc.d.ts +4358 -856
- package/dist/rpc.js +41 -1
- package/dist/rpc.js.map +1 -1
- package/dist/updates.d.ts +2287 -668
- package/dist/updates.js +16 -1
- package/dist/updates.js.map +1 -1
- package/dist/workflow.d.ts +187 -0
- package/dist/workflow.js +35 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +2 -2
- package/src/computer-preview.ts +49 -0
- package/src/goal.ts +22 -0
- package/src/index.ts +3 -0
- package/src/model.ts +41 -0
- package/src/rpc.ts +41 -0
- package/src/updates.ts +16 -1
- package/src/workflow.ts +44 -0
package/dist/updates.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { sessionGoalSchema } from "./goal.js";
|
|
3
|
+
import { backgroundTaskSchema, permissionOptionSchema, questionAnswerSchema, questionSchema, sessionDriverSchema, sessionStateSchema, toolKindSchema } from "./model.js";
|
|
4
|
+
import { workflowAgentStateSchema, workflowSchema } from "./workflow.js";
|
|
3
5
|
// Session updates mirror ACP's `SessionUpdate` shapes (discriminated by
|
|
4
6
|
// `sessionUpdate`) so one renderer works for every agent. LinkShell-specific
|
|
5
7
|
// updates use the `ls_` prefix.
|
|
@@ -58,6 +60,10 @@ export const toolDetailSchema = z.discriminatedUnion("type", [
|
|
|
58
60
|
/** The sub-agent's role or type, e.g. "Explore". */
|
|
59
61
|
agentType: z.string().optional(),
|
|
60
62
|
model: z.string().optional(),
|
|
63
|
+
/** Agent outcome when a tool's coarse completed/failed state is insufficient. */
|
|
64
|
+
state: workflowAgentStateSchema.optional(),
|
|
65
|
+
/** A Claude workflow is a background run containing its own agents. Counts are observed, not a predicted total. */
|
|
66
|
+
workflow: workflowSchema.optional(),
|
|
61
67
|
}),
|
|
62
68
|
z.object({ type: z.literal("skill"), name: z.string(), description: z.string().optional() }),
|
|
63
69
|
z.object({ type: z.literal("web_search"), query: z.string().optional() }),
|
|
@@ -129,6 +135,10 @@ export const sessionUpdateSchema = z.discriminatedUnion("sessionUpdate", [
|
|
|
129
135
|
sessionUpdate: z.literal("plan"),
|
|
130
136
|
entries: z.array(planEntrySchema),
|
|
131
137
|
}),
|
|
138
|
+
z.object({
|
|
139
|
+
sessionUpdate: z.literal("ls_goal"),
|
|
140
|
+
goal: sessionGoalSchema.nullable(),
|
|
141
|
+
}),
|
|
132
142
|
z.object({
|
|
133
143
|
sessionUpdate: z.literal("available_commands_update"),
|
|
134
144
|
availableCommands: z.array(z.object({ name: z.string(), description: z.string(), hint: z.string().optional() })),
|
|
@@ -203,6 +213,11 @@ export const sessionUpdateSchema = z.discriminatedUnion("sessionUpdate", [
|
|
|
203
213
|
sessionUpdate: z.literal("ls_status"),
|
|
204
214
|
state: sessionStateSchema,
|
|
205
215
|
}),
|
|
216
|
+
/** A background task as it is now (the whole record each time: the latest for its id holds). */
|
|
217
|
+
z.object({
|
|
218
|
+
sessionUpdate: z.literal("ls_task"),
|
|
219
|
+
task: backgroundTaskSchema,
|
|
220
|
+
}),
|
|
206
221
|
z.object({
|
|
207
222
|
sessionUpdate: z.literal("ls_error"),
|
|
208
223
|
code: z.string(),
|
package/dist/updates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updates.js","sourceRoot":"","sources":["../src/updates.ts"],"names":[],"mappings":"AAAA,OAAO,E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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"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const workflowStateSchema: z.ZodEnum<["running", "paused", "completed", "failed", "stopped"]>;
|
|
3
|
+
export type WorkflowState = z.infer<typeof workflowStateSchema>;
|
|
4
|
+
export declare const workflowAgentStateSchema: z.ZodEnum<["pending", "running", "paused", "completed", "failed", "stopped", "unknown"]>;
|
|
5
|
+
export type WorkflowAgentState = z.infer<typeof workflowAgentStateSchema>;
|
|
6
|
+
export declare const workflowAgentSchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
/** Present only after the host has imported this agent's transcript. */
|
|
9
|
+
toolCallId: z.ZodOptional<z.ZodString>;
|
|
10
|
+
title: z.ZodString;
|
|
11
|
+
state: z.ZodEnum<["pending", "running", "paused", "completed", "failed", "stopped", "unknown"]>;
|
|
12
|
+
phaseId: z.ZodOptional<z.ZodString>;
|
|
13
|
+
model: z.ZodOptional<z.ZodString>;
|
|
14
|
+
tokens: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
toolCalls: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
endedAt: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
result: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
id: string;
|
|
22
|
+
title: string;
|
|
23
|
+
state: "unknown" | "paused" | "running" | "completed" | "failed" | "stopped" | "pending";
|
|
24
|
+
toolCallId?: string | undefined;
|
|
25
|
+
phaseId?: string | undefined;
|
|
26
|
+
model?: string | undefined;
|
|
27
|
+
tokens?: number | undefined;
|
|
28
|
+
toolCalls?: number | undefined;
|
|
29
|
+
durationMs?: number | undefined;
|
|
30
|
+
startedAt?: number | undefined;
|
|
31
|
+
endedAt?: number | undefined;
|
|
32
|
+
result?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
id: string;
|
|
35
|
+
title: string;
|
|
36
|
+
state: "unknown" | "paused" | "running" | "completed" | "failed" | "stopped" | "pending";
|
|
37
|
+
toolCallId?: string | undefined;
|
|
38
|
+
phaseId?: string | undefined;
|
|
39
|
+
model?: string | undefined;
|
|
40
|
+
tokens?: number | undefined;
|
|
41
|
+
toolCalls?: number | undefined;
|
|
42
|
+
durationMs?: number | undefined;
|
|
43
|
+
startedAt?: number | undefined;
|
|
44
|
+
endedAt?: number | undefined;
|
|
45
|
+
result?: string | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
export type WorkflowAgent = z.infer<typeof workflowAgentSchema>;
|
|
48
|
+
export declare const workflowPhaseSchema: z.ZodObject<{
|
|
49
|
+
id: z.ZodString;
|
|
50
|
+
title: z.ZodString;
|
|
51
|
+
order: z.ZodNumber;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
id: string;
|
|
54
|
+
title: string;
|
|
55
|
+
order: number;
|
|
56
|
+
}, {
|
|
57
|
+
id: string;
|
|
58
|
+
title: string;
|
|
59
|
+
order: number;
|
|
60
|
+
}>;
|
|
61
|
+
export type WorkflowPhase = z.infer<typeof workflowPhaseSchema>;
|
|
62
|
+
/** A complete run snapshot, independent of the loaded conversation window. */
|
|
63
|
+
export declare const workflowSchema: z.ZodObject<{
|
|
64
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
65
|
+
name: z.ZodOptional<z.ZodString>;
|
|
66
|
+
state: z.ZodOptional<z.ZodEnum<["running", "paused", "completed", "failed", "stopped"]>>;
|
|
67
|
+
/** Observed counts: a dynamic script may start more agents later. */
|
|
68
|
+
started: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
completed: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
tokens: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
endedAt: z.ZodOptional<z.ZodNumber>;
|
|
74
|
+
phases: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
75
|
+
id: z.ZodString;
|
|
76
|
+
title: z.ZodString;
|
|
77
|
+
order: z.ZodNumber;
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
id: string;
|
|
80
|
+
title: string;
|
|
81
|
+
order: number;
|
|
82
|
+
}, {
|
|
83
|
+
id: string;
|
|
84
|
+
title: string;
|
|
85
|
+
order: number;
|
|
86
|
+
}>, "many">>;
|
|
87
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
88
|
+
id: z.ZodString;
|
|
89
|
+
/** Present only after the host has imported this agent's transcript. */
|
|
90
|
+
toolCallId: z.ZodOptional<z.ZodString>;
|
|
91
|
+
title: z.ZodString;
|
|
92
|
+
state: z.ZodEnum<["pending", "running", "paused", "completed", "failed", "stopped", "unknown"]>;
|
|
93
|
+
phaseId: z.ZodOptional<z.ZodString>;
|
|
94
|
+
model: z.ZodOptional<z.ZodString>;
|
|
95
|
+
tokens: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
toolCalls: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
endedAt: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
result: z.ZodOptional<z.ZodString>;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
id: string;
|
|
103
|
+
title: string;
|
|
104
|
+
state: "unknown" | "paused" | "running" | "completed" | "failed" | "stopped" | "pending";
|
|
105
|
+
toolCallId?: string | undefined;
|
|
106
|
+
phaseId?: string | undefined;
|
|
107
|
+
model?: string | undefined;
|
|
108
|
+
tokens?: number | undefined;
|
|
109
|
+
toolCalls?: number | undefined;
|
|
110
|
+
durationMs?: number | undefined;
|
|
111
|
+
startedAt?: number | undefined;
|
|
112
|
+
endedAt?: number | undefined;
|
|
113
|
+
result?: string | undefined;
|
|
114
|
+
}, {
|
|
115
|
+
id: string;
|
|
116
|
+
title: string;
|
|
117
|
+
state: "unknown" | "paused" | "running" | "completed" | "failed" | "stopped" | "pending";
|
|
118
|
+
toolCallId?: string | undefined;
|
|
119
|
+
phaseId?: string | undefined;
|
|
120
|
+
model?: string | undefined;
|
|
121
|
+
tokens?: number | undefined;
|
|
122
|
+
toolCalls?: number | undefined;
|
|
123
|
+
durationMs?: number | undefined;
|
|
124
|
+
startedAt?: number | undefined;
|
|
125
|
+
endedAt?: number | undefined;
|
|
126
|
+
result?: string | undefined;
|
|
127
|
+
}>, "many">>;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
completed?: number | undefined;
|
|
130
|
+
state?: "paused" | "running" | "completed" | "failed" | "stopped" | undefined;
|
|
131
|
+
tokens?: number | undefined;
|
|
132
|
+
durationMs?: number | undefined;
|
|
133
|
+
startedAt?: number | undefined;
|
|
134
|
+
endedAt?: number | undefined;
|
|
135
|
+
runId?: string | undefined;
|
|
136
|
+
name?: string | undefined;
|
|
137
|
+
started?: number | undefined;
|
|
138
|
+
phases?: {
|
|
139
|
+
id: string;
|
|
140
|
+
title: string;
|
|
141
|
+
order: number;
|
|
142
|
+
}[] | undefined;
|
|
143
|
+
agents?: {
|
|
144
|
+
id: string;
|
|
145
|
+
title: string;
|
|
146
|
+
state: "unknown" | "paused" | "running" | "completed" | "failed" | "stopped" | "pending";
|
|
147
|
+
toolCallId?: string | undefined;
|
|
148
|
+
phaseId?: string | undefined;
|
|
149
|
+
model?: string | undefined;
|
|
150
|
+
tokens?: number | undefined;
|
|
151
|
+
toolCalls?: number | undefined;
|
|
152
|
+
durationMs?: number | undefined;
|
|
153
|
+
startedAt?: number | undefined;
|
|
154
|
+
endedAt?: number | undefined;
|
|
155
|
+
result?: string | undefined;
|
|
156
|
+
}[] | undefined;
|
|
157
|
+
}, {
|
|
158
|
+
completed?: number | undefined;
|
|
159
|
+
state?: "paused" | "running" | "completed" | "failed" | "stopped" | undefined;
|
|
160
|
+
tokens?: number | undefined;
|
|
161
|
+
durationMs?: number | undefined;
|
|
162
|
+
startedAt?: number | undefined;
|
|
163
|
+
endedAt?: number | undefined;
|
|
164
|
+
runId?: string | undefined;
|
|
165
|
+
name?: string | undefined;
|
|
166
|
+
started?: number | undefined;
|
|
167
|
+
phases?: {
|
|
168
|
+
id: string;
|
|
169
|
+
title: string;
|
|
170
|
+
order: number;
|
|
171
|
+
}[] | undefined;
|
|
172
|
+
agents?: {
|
|
173
|
+
id: string;
|
|
174
|
+
title: string;
|
|
175
|
+
state: "unknown" | "paused" | "running" | "completed" | "failed" | "stopped" | "pending";
|
|
176
|
+
toolCallId?: string | undefined;
|
|
177
|
+
phaseId?: string | undefined;
|
|
178
|
+
model?: string | undefined;
|
|
179
|
+
tokens?: number | undefined;
|
|
180
|
+
toolCalls?: number | undefined;
|
|
181
|
+
durationMs?: number | undefined;
|
|
182
|
+
startedAt?: number | undefined;
|
|
183
|
+
endedAt?: number | undefined;
|
|
184
|
+
result?: string | undefined;
|
|
185
|
+
}[] | undefined;
|
|
186
|
+
}>;
|
|
187
|
+
export type Workflow = z.infer<typeof workflowSchema>;
|
package/dist/workflow.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const workflowStateSchema = z.enum(["running", "paused", "completed", "failed", "stopped"]);
|
|
3
|
+
export const workflowAgentStateSchema = z.enum(["pending", "running", "paused", "completed", "failed", "stopped", "unknown"]);
|
|
4
|
+
export const workflowAgentSchema = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
/** Present only after the host has imported this agent's transcript. */
|
|
7
|
+
toolCallId: z.string().optional(),
|
|
8
|
+
title: z.string(),
|
|
9
|
+
state: workflowAgentStateSchema,
|
|
10
|
+
phaseId: z.string().optional(),
|
|
11
|
+
model: z.string().optional(),
|
|
12
|
+
tokens: z.number().nonnegative().optional(),
|
|
13
|
+
toolCalls: z.number().int().nonnegative().optional(),
|
|
14
|
+
durationMs: z.number().nonnegative().optional(),
|
|
15
|
+
startedAt: z.number().optional(),
|
|
16
|
+
endedAt: z.number().optional(),
|
|
17
|
+
result: z.string().optional(),
|
|
18
|
+
});
|
|
19
|
+
export const workflowPhaseSchema = z.object({ id: z.string(), title: z.string(), order: z.number() });
|
|
20
|
+
/** A complete run snapshot, independent of the loaded conversation window. */
|
|
21
|
+
export const workflowSchema = z.object({
|
|
22
|
+
runId: z.string().optional(),
|
|
23
|
+
name: z.string().optional(),
|
|
24
|
+
state: workflowStateSchema.optional(),
|
|
25
|
+
/** Observed counts: a dynamic script may start more agents later. */
|
|
26
|
+
started: z.number().int().nonnegative().optional(),
|
|
27
|
+
completed: z.number().int().nonnegative().optional(),
|
|
28
|
+
tokens: z.number().nonnegative().optional(),
|
|
29
|
+
durationMs: z.number().nonnegative().optional(),
|
|
30
|
+
startedAt: z.number().optional(),
|
|
31
|
+
endedAt: z.number().optional(),
|
|
32
|
+
phases: z.array(workflowPhaseSchema).optional(),
|
|
33
|
+
agents: z.array(workflowAgentSchema).optional(),
|
|
34
|
+
});
|
|
35
|
+
//#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1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linkshell/wire",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Wire protocol for LinkShell v2: session model, JSON-RPC methods, end-to-end encryption and the relay client.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"build": "tsc -p tsconfig.json",
|
|
45
|
+
"build": "rm -rf dist *.tsbuildinfo && tsc -p tsconfig.json",
|
|
46
46
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
47
47
|
"test": "vitest run"
|
|
48
48
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const PREVIEW_MAX_BYTES = 48 * 1024;
|
|
4
|
+
export const previewFrameSchema = z.object({
|
|
5
|
+
id: z.string().regex(/^[a-f0-9]{64}$/),
|
|
6
|
+
target: z.string().max(1024),
|
|
7
|
+
capturedAt: z.number().finite().nonnegative(),
|
|
8
|
+
width: z.number().int().positive().max(2048),
|
|
9
|
+
height: z.number().int().positive().max(2048),
|
|
10
|
+
mimeType: z.literal("image/webp"),
|
|
11
|
+
});
|
|
12
|
+
export type PreviewFrameInfo = z.infer<typeof previewFrameSchema>;
|
|
13
|
+
export interface PreviewFrame extends PreviewFrameInfo { bytes: Uint8Array }
|
|
14
|
+
|
|
15
|
+
/** Length-prefixed metadata and image bytes, inside an authenticated proxy stream. */
|
|
16
|
+
export function encodePreviewFrame(frame: PreviewFrame): Uint8Array {
|
|
17
|
+
const { bytes, ...info } = frame;
|
|
18
|
+
const metadata = new TextEncoder().encode(JSON.stringify(previewFrameSchema.parse(info)));
|
|
19
|
+
if (bytes.length > PREVIEW_MAX_BYTES) throw new Error("preview image too large");
|
|
20
|
+
const packet = new Uint8Array(8 + metadata.length + bytes.length);
|
|
21
|
+
const header = new DataView(packet.buffer);
|
|
22
|
+
header.setUint32(0, metadata.length);
|
|
23
|
+
header.setUint32(4, bytes.length);
|
|
24
|
+
packet.set(metadata, 8);
|
|
25
|
+
packet.set(bytes, 8 + metadata.length);
|
|
26
|
+
return packet;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Handles split TCP/data-channel chunks without accepting unbounded allocations. */
|
|
30
|
+
export class PreviewFrameDecoder {
|
|
31
|
+
private held = new Uint8Array(0);
|
|
32
|
+
push(chunk: Uint8Array): PreviewFrame[] {
|
|
33
|
+
if (this.held.length + chunk.length > PREVIEW_MAX_BYTES + 4104) throw new Error("preview buffer too large");
|
|
34
|
+
const next = new Uint8Array(this.held.length + chunk.length);
|
|
35
|
+
next.set(this.held); next.set(chunk, this.held.length); this.held = next;
|
|
36
|
+
const frames: PreviewFrame[] = [];
|
|
37
|
+
while (this.held.length >= 8) {
|
|
38
|
+
const header = new DataView(this.held.buffer, this.held.byteOffset);
|
|
39
|
+
const meta = header.getUint32(0), size = header.getUint32(4);
|
|
40
|
+
if (meta > 4096 || size > PREVIEW_MAX_BYTES || !meta || !size) throw new Error("invalid preview frame");
|
|
41
|
+
const total = 8 + meta + size;
|
|
42
|
+
if (this.held.length < total) break;
|
|
43
|
+
const info = previewFrameSchema.parse(JSON.parse(new TextDecoder().decode(this.held.subarray(8, 8 + meta))));
|
|
44
|
+
frames.push({ ...info, bytes: this.held.slice(8 + meta, total) });
|
|
45
|
+
this.held = this.held.slice(total);
|
|
46
|
+
}
|
|
47
|
+
return frames;
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/goal.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
/** Native agent state, not inferred from prose or a completed turn. */
|
|
4
|
+
export const sessionGoalSchema = z.object({
|
|
5
|
+
objective: z.string(),
|
|
6
|
+
status: z.enum(["active", "paused", "blocked", "usageLimited", "budgetLimited", "complete"]),
|
|
7
|
+
tokenBudget: z.number().nonnegative().nullable().optional(),
|
|
8
|
+
tokensUsed: z.number().nonnegative().optional(),
|
|
9
|
+
timeUsedSeconds: z.number().nonnegative().optional(),
|
|
10
|
+
iterations: z.number().int().nonnegative().optional(),
|
|
11
|
+
lastReason: z.string().nullable().optional(),
|
|
12
|
+
});
|
|
13
|
+
export type SessionGoal = z.infer<typeof sessionGoalSchema>;
|
|
14
|
+
|
|
15
|
+
export const goalChangeSchema = z.discriminatedUnion("action", [
|
|
16
|
+
z.object({ action: z.literal("get") }),
|
|
17
|
+
z.object({ action: z.literal("set"), objective: z.string().trim().min(1).max(4000), tokenBudget: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional() }),
|
|
18
|
+
z.object({ action: z.literal("pause") }),
|
|
19
|
+
z.object({ action: z.literal("resume") }),
|
|
20
|
+
z.object({ action: z.literal("clear") }),
|
|
21
|
+
]);
|
|
22
|
+
export type GoalChange = z.infer<typeof goalChangeSchema>;
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./model.js";
|
|
2
|
+
export * from "./goal.js";
|
|
2
3
|
export * from "./updates.js";
|
|
4
|
+
export * from "./workflow.js";
|
|
3
5
|
export * from "./rpc.js";
|
|
4
6
|
export * from "./peer.js";
|
|
5
7
|
export * from "./shell.js";
|
|
@@ -7,3 +9,4 @@ export * from "./crypto.js";
|
|
|
7
9
|
export * from "./relay.js";
|
|
8
10
|
export * from "./relay-client.js";
|
|
9
11
|
export * from "./direct.js";
|
|
12
|
+
export * from "./computer-preview.js";
|
package/src/model.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { workflowAgentStateSchema, workflowSchema } from "./workflow.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* How far LinkShell can take a given agent. The UI renders capabilities from
|
|
@@ -149,6 +150,7 @@ export type QueuedMessage = z.infer<typeof queuedMessageSchema>;
|
|
|
149
150
|
/** A sub-agent a session started: the tool call it runs under, and how it is doing. */
|
|
150
151
|
export const subagentInfoSchema = z.object({
|
|
151
152
|
toolCallId: z.string(),
|
|
153
|
+
parentToolCallId: z.string().optional(),
|
|
152
154
|
/** What it was asked to do. */
|
|
153
155
|
task: z.string(),
|
|
154
156
|
/** Its role or type, e.g. "Explore". */
|
|
@@ -157,9 +159,46 @@ export const subagentInfoSchema = z.object({
|
|
|
157
159
|
failed: z.boolean().optional(),
|
|
158
160
|
startedAt: z.number(),
|
|
159
161
|
endedAt: z.number().optional(),
|
|
162
|
+
state: workflowAgentStateSchema.optional(),
|
|
163
|
+
workflow: workflowSchema.optional(),
|
|
164
|
+
/** Orders list snapshots against events arriving while the request is in flight. */
|
|
165
|
+
lastSeq: z.number().int().nonnegative().optional(),
|
|
160
166
|
});
|
|
161
167
|
export type SubagentInfo = z.infer<typeof subagentInfoSchema>;
|
|
162
168
|
|
|
169
|
+
/**
|
|
170
|
+
* A command the agent left running after its call returned (a background
|
|
171
|
+
* shell, a dev server, a watcher). Sub-agents and workflows are not tasks:
|
|
172
|
+
* they have their own records (`SubagentInfo`).
|
|
173
|
+
*/
|
|
174
|
+
export const backgroundTaskStateSchema = z.enum(["running", "completed", "failed", "stopped", "unknown"]);
|
|
175
|
+
export type BackgroundTaskState = z.infer<typeof backgroundTaskStateSchema>;
|
|
176
|
+
|
|
177
|
+
export const backgroundTaskSchema = z.object({
|
|
178
|
+
/** The agent's own id for it. */
|
|
179
|
+
id: z.string(),
|
|
180
|
+
/** shell: a command; monitor: a command whose output the agent is told about as it comes. */
|
|
181
|
+
kind: z.enum(["shell", "monitor"]),
|
|
182
|
+
/** The tool call that started it. */
|
|
183
|
+
toolCallId: z.string().optional(),
|
|
184
|
+
title: z.string(),
|
|
185
|
+
command: z.string().optional(),
|
|
186
|
+
/** `unknown`: it was running when the host lost track of it (its agent quit without saying how it ended). */
|
|
187
|
+
state: backgroundTaskStateSchema,
|
|
188
|
+
startedAt: z.number(),
|
|
189
|
+
endedAt: z.number().optional(),
|
|
190
|
+
/** How it ended, or the latest thing it reported, as the agent says it. */
|
|
191
|
+
summary: z.string().optional(),
|
|
192
|
+
exitCode: z.number().int().optional(),
|
|
193
|
+
/** Its output can be read (`sessions.taskOutput`). */
|
|
194
|
+
output: z.boolean().optional(),
|
|
195
|
+
/** It can be stopped from here (`sessions.stopTask`). */
|
|
196
|
+
canStop: z.boolean().optional(),
|
|
197
|
+
/** Orders list snapshots against events arriving while the request is in flight. */
|
|
198
|
+
lastSeq: z.number().int().nonnegative().optional(),
|
|
199
|
+
});
|
|
200
|
+
export type BackgroundTask = z.infer<typeof backgroundTaskSchema>;
|
|
201
|
+
|
|
163
202
|
export const sessionSummarySchema = z.object({
|
|
164
203
|
/** `${agent}:${nativeId}` — stable across daemon restarts and rediscovery. */
|
|
165
204
|
id: z.string().min(1),
|
|
@@ -192,6 +231,8 @@ export const sessionSummarySchema = z.object({
|
|
|
192
231
|
worktree: z.object({ branch: z.string(), source: z.string() }).optional(),
|
|
193
232
|
/** Live only, for sessions that started sub-agents: how many, and how many are working now (`sessions.subagents` lists them). */
|
|
194
233
|
subagents: z.object({ total: z.number().int(), running: z.number().int() }).optional(),
|
|
234
|
+
/** Live only, for sessions that left commands running: how many, and how many still run (`sessions.tasks` lists them). */
|
|
235
|
+
tasks: z.object({ total: z.number().int(), running: z.number().int() }).optional(),
|
|
195
236
|
});
|
|
196
237
|
export type SessionSummary = z.infer<typeof sessionSummarySchema>;
|
|
197
238
|
|
package/src/rpc.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { goalChangeSchema, sessionGoalSchema } from "./goal.js";
|
|
2
3
|
import {
|
|
4
|
+
backgroundTaskSchema,
|
|
3
5
|
gatewayStatusSchema,
|
|
4
6
|
machineInfoSchema,
|
|
5
7
|
portInfoSchema,
|
|
@@ -159,6 +161,40 @@ export const methods = {
|
|
|
159
161
|
params: z.object({ sessionId: z.string().min(1), toolCallId: z.string().min(1), lazyImages: z.boolean().optional() }),
|
|
160
162
|
result: z.object({ events: z.array(sessionEventSchema) }),
|
|
161
163
|
},
|
|
164
|
+
/** The commands this session left running in the background, and the ones that have ended; newest first. */
|
|
165
|
+
"sessions.tasks": {
|
|
166
|
+
params: z.object({ sessionId: z.string().min(1) }),
|
|
167
|
+
result: z.object({ tasks: z.array(backgroundTaskSchema) }),
|
|
168
|
+
},
|
|
169
|
+
/**
|
|
170
|
+
* A background task's output, a piece at a time from the end: the text
|
|
171
|
+
* before byte `before` (default: the end), at most `limit` bytes. `start` is
|
|
172
|
+
* where that text begins (0: the beginning); `size` is the whole output's.
|
|
173
|
+
*/
|
|
174
|
+
"sessions.taskOutput": {
|
|
175
|
+
params: z.object({
|
|
176
|
+
sessionId: z.string().min(1),
|
|
177
|
+
taskId: z.string().min(1),
|
|
178
|
+
before: z.number().int().nonnegative().optional(),
|
|
179
|
+
limit: z.number().int().positive().max(256 * 1024).optional(),
|
|
180
|
+
}),
|
|
181
|
+
result: z.object({ text: z.string(), start: z.number().int().nonnegative(), size: z.number().int().nonnegative() }),
|
|
182
|
+
},
|
|
183
|
+
/** Stops one background task, leaving the session's turn and its other tasks alone. */
|
|
184
|
+
"sessions.stopTask": {
|
|
185
|
+
params: z.object({ sessionId: z.string().min(1), taskId: z.string().min(1) }),
|
|
186
|
+
result: empty,
|
|
187
|
+
},
|
|
188
|
+
/** Opens a read-only computer-use preview through the existing bulk-stream transport. */
|
|
189
|
+
"sessions.preview": {
|
|
190
|
+
params: z.object({ sessionId: z.string().min(1), direct: z.boolean().optional() }),
|
|
191
|
+
result: z.object({ port: z.number().int().positive(), token: z.string() }),
|
|
192
|
+
},
|
|
193
|
+
/** Explicit local user action; normal frame updates never reopen a dismissed preview. */
|
|
194
|
+
"desktop.preview.show": {
|
|
195
|
+
params: z.object({ sessionId: z.string().min(1) }),
|
|
196
|
+
result: empty,
|
|
197
|
+
},
|
|
162
198
|
/** The picture behind a `linkshell-event:` uri. */
|
|
163
199
|
"sessions.image": {
|
|
164
200
|
params: z.object({ sessionId: z.string().min(1), uri: z.string().min(1) }),
|
|
@@ -206,6 +242,10 @@ export const methods = {
|
|
|
206
242
|
params: z.object({ sessionId: z.string().min(1), requestId: z.string().min(1), answers: z.array(questionAnswerSchema).max(50) }),
|
|
207
243
|
result: empty,
|
|
208
244
|
},
|
|
245
|
+
"sessions.goal": {
|
|
246
|
+
params: z.object({ sessionId: z.string(), change: goalChangeSchema }),
|
|
247
|
+
result: z.object({ goal: sessionGoalSchema.nullable() }),
|
|
248
|
+
},
|
|
209
249
|
"sessions.setConfig": {
|
|
210
250
|
params: z.object({
|
|
211
251
|
sessionId: z.string().min(1),
|
|
@@ -541,6 +581,7 @@ export const notifications = {
|
|
|
541
581
|
"session.summary": z.object({ session: sessionSummarySchema }),
|
|
542
582
|
/** A session was deleted (from any device, or natively by the agent). */
|
|
543
583
|
"session.removed": z.object({ sessionId: z.string() }),
|
|
584
|
+
"session.preview.show": z.object({ sessionId: z.string() }),
|
|
544
585
|
/** To a desktop shim: a device is taking over; exit the native UI, then call desktop.yielded. */
|
|
545
586
|
"desktop.yield": z.object({ sessionId: z.string() }),
|
|
546
587
|
/** To a desktop shim: progress from the remote driver, to show in the terminal. */
|
package/src/updates.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { sessionGoalSchema } from "./goal.js";
|
|
3
|
+
import { backgroundTaskSchema, permissionOptionSchema, questionAnswerSchema, questionSchema, sessionDriverSchema, sessionStateSchema, toolKindSchema } from "./model.js";
|
|
4
|
+
import { workflowAgentStateSchema, workflowSchema } from "./workflow.js";
|
|
3
5
|
|
|
4
6
|
// Session updates mirror ACP's `SessionUpdate` shapes (discriminated by
|
|
5
7
|
// `sessionUpdate`) so one renderer works for every agent. LinkShell-specific
|
|
@@ -68,6 +70,10 @@ export const toolDetailSchema = z.discriminatedUnion("type", [
|
|
|
68
70
|
/** The sub-agent's role or type, e.g. "Explore". */
|
|
69
71
|
agentType: z.string().optional(),
|
|
70
72
|
model: z.string().optional(),
|
|
73
|
+
/** Agent outcome when a tool's coarse completed/failed state is insufficient. */
|
|
74
|
+
state: workflowAgentStateSchema.optional(),
|
|
75
|
+
/** A Claude workflow is a background run containing its own agents. Counts are observed, not a predicted total. */
|
|
76
|
+
workflow: workflowSchema.optional(),
|
|
71
77
|
}),
|
|
72
78
|
z.object({ type: z.literal("skill"), name: z.string(), description: z.string().optional() }),
|
|
73
79
|
z.object({ type: z.literal("web_search"), query: z.string().optional() }),
|
|
@@ -147,6 +153,10 @@ export const sessionUpdateSchema = z.discriminatedUnion("sessionUpdate", [
|
|
|
147
153
|
sessionUpdate: z.literal("plan"),
|
|
148
154
|
entries: z.array(planEntrySchema),
|
|
149
155
|
}),
|
|
156
|
+
z.object({
|
|
157
|
+
sessionUpdate: z.literal("ls_goal"),
|
|
158
|
+
goal: sessionGoalSchema.nullable(),
|
|
159
|
+
}),
|
|
150
160
|
z.object({
|
|
151
161
|
sessionUpdate: z.literal("available_commands_update"),
|
|
152
162
|
availableCommands: z.array(
|
|
@@ -223,6 +233,11 @@ export const sessionUpdateSchema = z.discriminatedUnion("sessionUpdate", [
|
|
|
223
233
|
sessionUpdate: z.literal("ls_status"),
|
|
224
234
|
state: sessionStateSchema,
|
|
225
235
|
}),
|
|
236
|
+
/** A background task as it is now (the whole record each time: the latest for its id holds). */
|
|
237
|
+
z.object({
|
|
238
|
+
sessionUpdate: z.literal("ls_task"),
|
|
239
|
+
task: backgroundTaskSchema,
|
|
240
|
+
}),
|
|
226
241
|
z.object({
|
|
227
242
|
sessionUpdate: z.literal("ls_error"),
|
|
228
243
|
code: z.string(),
|
package/src/workflow.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const workflowStateSchema = z.enum(["running", "paused", "completed", "failed", "stopped"]);
|
|
4
|
+
export type WorkflowState = z.infer<typeof workflowStateSchema>;
|
|
5
|
+
|
|
6
|
+
export const workflowAgentStateSchema = z.enum(["pending", "running", "paused", "completed", "failed", "stopped", "unknown"]);
|
|
7
|
+
export type WorkflowAgentState = z.infer<typeof workflowAgentStateSchema>;
|
|
8
|
+
|
|
9
|
+
export const workflowAgentSchema = z.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
/** Present only after the host has imported this agent's transcript. */
|
|
12
|
+
toolCallId: z.string().optional(),
|
|
13
|
+
title: z.string(),
|
|
14
|
+
state: workflowAgentStateSchema,
|
|
15
|
+
phaseId: z.string().optional(),
|
|
16
|
+
model: z.string().optional(),
|
|
17
|
+
tokens: z.number().nonnegative().optional(),
|
|
18
|
+
toolCalls: z.number().int().nonnegative().optional(),
|
|
19
|
+
durationMs: z.number().nonnegative().optional(),
|
|
20
|
+
startedAt: z.number().optional(),
|
|
21
|
+
endedAt: z.number().optional(),
|
|
22
|
+
result: z.string().optional(),
|
|
23
|
+
});
|
|
24
|
+
export type WorkflowAgent = z.infer<typeof workflowAgentSchema>;
|
|
25
|
+
|
|
26
|
+
export const workflowPhaseSchema = z.object({ id: z.string(), title: z.string(), order: z.number() });
|
|
27
|
+
export type WorkflowPhase = z.infer<typeof workflowPhaseSchema>;
|
|
28
|
+
|
|
29
|
+
/** A complete run snapshot, independent of the loaded conversation window. */
|
|
30
|
+
export const workflowSchema = z.object({
|
|
31
|
+
runId: z.string().optional(),
|
|
32
|
+
name: z.string().optional(),
|
|
33
|
+
state: workflowStateSchema.optional(),
|
|
34
|
+
/** Observed counts: a dynamic script may start more agents later. */
|
|
35
|
+
started: z.number().int().nonnegative().optional(),
|
|
36
|
+
completed: z.number().int().nonnegative().optional(),
|
|
37
|
+
tokens: z.number().nonnegative().optional(),
|
|
38
|
+
durationMs: z.number().nonnegative().optional(),
|
|
39
|
+
startedAt: z.number().optional(),
|
|
40
|
+
endedAt: z.number().optional(),
|
|
41
|
+
phases: z.array(workflowPhaseSchema).optional(),
|
|
42
|
+
agents: z.array(workflowAgentSchema).optional(),
|
|
43
|
+
});
|
|
44
|
+
export type Workflow = z.infer<typeof workflowSchema>;
|