@nexus-code/remote-protocol 0.1.0 → 0.2.0
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 +5 -1
- package/dist/rpc.d.ts +4275 -216
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +657 -11
- package/dist/rpc.js.map +1 -1
- package/dist/sealed.d.ts +37 -5
- package/dist/sealed.d.ts.map +1 -1
- package/dist/sealed.js +34 -5
- package/dist/sealed.js.map +1 -1
- package/dist/view.d.ts +440 -0
- package/dist/view.d.ts.map +1 -1
- package/dist/view.js +73 -0
- package/dist/view.js.map +1 -1
- package/package.json +1 -1
- package/src/rpc.ts +695 -10
- package/src/sealed.ts +35 -5
- package/src/view.ts +83 -0
package/src/sealed.ts
CHANGED
|
@@ -15,6 +15,13 @@ import { RpcMessageSchema } from "./rpc.js";
|
|
|
15
15
|
/** The version of what is sealed; a device tells it in its hello. */
|
|
16
16
|
export const PROTOCOL_VERSION = 1;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* This package's version, which a device tells in its hello (`schema`):
|
|
20
|
+
* the methods a device serves are those of its version, so another can
|
|
21
|
+
* leave out what an older one does not have. Kept equal to package.json's.
|
|
22
|
+
*/
|
|
23
|
+
export const SCHEMA_VERSION = "0.2.0";
|
|
24
|
+
|
|
18
25
|
/** The HKDF info that makes the room key from the account key. */
|
|
19
26
|
export const ROOM_KEY_INFO = "nexus-remote/room-key/v1";
|
|
20
27
|
|
|
@@ -32,14 +39,27 @@ export function aadOf(frame: { from: DeviceId; to: string; seq: number; kid: num
|
|
|
32
39
|
* side asks only for what is listed; a newer device lists more.
|
|
33
40
|
*/
|
|
34
41
|
export const CAPABILITIES = [
|
|
35
|
-
/** sessions.list and
|
|
42
|
+
/** sessions.list and sessions.watch, profiles.list. */
|
|
36
43
|
"sessions",
|
|
37
|
-
/** chat.read and chat.watch. */
|
|
44
|
+
/** Reading a chat: chat.read and chat.watch, its settings, commands, panel, images, tool calls; history.list. */
|
|
38
45
|
"chat.read",
|
|
39
|
-
/** chat
|
|
46
|
+
/** Acting in a chat: sending, answering, stopping, settings, commands, opening, resuming, renaming, closing. */
|
|
40
47
|
"chat.control",
|
|
41
|
-
/** terminal.read: a terminal's screen, as text. */
|
|
48
|
+
/** terminal.read and terminal.watch: a terminal's screen, as text. */
|
|
42
49
|
"terminal.read",
|
|
50
|
+
/** Typing into a terminal, opening, renaming and closing one. */
|
|
51
|
+
"terminal.control",
|
|
52
|
+
/** files.list and files.read, in a workspace's folders. */
|
|
53
|
+
"files",
|
|
54
|
+
/** git.status, git.diff and git.log of a workspace. */
|
|
55
|
+
"git",
|
|
56
|
+
/**
|
|
57
|
+
* Takes agents' requests (`from`: nexus on another device) to act in its
|
|
58
|
+
* chats and terminals, as the user set it (Settings › Remote: ask or
|
|
59
|
+
* allow). Without it, a request with `from` is refused, whatever
|
|
60
|
+
* chat.control and terminal.control say: those are for people.
|
|
61
|
+
*/
|
|
62
|
+
"agents",
|
|
43
63
|
] as const;
|
|
44
64
|
export const CapabilitySchema = z.string();
|
|
45
65
|
export type Capability = (typeof CAPABILITIES)[number];
|
|
@@ -57,8 +77,18 @@ export const HelloSchema = z.object({
|
|
|
57
77
|
name: z.string(),
|
|
58
78
|
platform: z.string(),
|
|
59
79
|
}),
|
|
60
|
-
app: z.object({
|
|
80
|
+
app: z.object({
|
|
81
|
+
name: z.string(),
|
|
82
|
+
version: z.string(),
|
|
83
|
+
/** The app's color theme now, by its id ("github-dark"): a phone may follow it. */
|
|
84
|
+
theme: z.string().optional(),
|
|
85
|
+
}),
|
|
61
86
|
serves: z.array(CapabilitySchema),
|
|
87
|
+
/**
|
|
88
|
+
* The protocol package's version it speaks (SCHEMA_VERSION, "0.2.0");
|
|
89
|
+
* absent before 0.2.0. A method it does not have is answered MethodNotFound.
|
|
90
|
+
*/
|
|
91
|
+
schema: z.string().max(40).optional(),
|
|
62
92
|
/** Whether it wants the hello of devices already there: true as it joins. */
|
|
63
93
|
reply: z.boolean(),
|
|
64
94
|
});
|
package/src/view.ts
CHANGED
|
@@ -56,6 +56,18 @@ export const NoticeItemSchema = z.object({
|
|
|
56
56
|
at,
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Where an agent that sent a message can be answered: its tab, on the
|
|
61
|
+
* device `deviceId` (absent: the device this chat runs on). `nexus chat
|
|
62
|
+
* send` takes it as it is.
|
|
63
|
+
*/
|
|
64
|
+
export const ReplyAddressSchema = z.object({
|
|
65
|
+
deviceId: z.string().optional(),
|
|
66
|
+
workspaceId: z.string(),
|
|
67
|
+
tabId: z.string(),
|
|
68
|
+
});
|
|
69
|
+
export type ReplyAddress = z.infer<typeof ReplyAddressSchema>;
|
|
70
|
+
|
|
59
71
|
/** A message the program took that the user did not write: another session's, a channel's. */
|
|
60
72
|
export const ReceivedItemSchema = z.object({
|
|
61
73
|
kind: z.literal("received"),
|
|
@@ -64,6 +76,10 @@ export const ReceivedItemSchema = z.object({
|
|
|
64
76
|
kind: z.string(),
|
|
65
77
|
name: z.string().optional(),
|
|
66
78
|
agent: z.string().optional(),
|
|
79
|
+
/** Sent from another device of the account: which one, as it names itself. */
|
|
80
|
+
device: z.object({ id: z.string(), name: z.string() }).optional(),
|
|
81
|
+
/** Where the sender takes an answer. */
|
|
82
|
+
replyTo: ReplyAddressSchema.optional(),
|
|
67
83
|
}),
|
|
68
84
|
text: z.string(),
|
|
69
85
|
at,
|
|
@@ -159,6 +175,12 @@ export const ViewPermissionSchema = z.object({
|
|
|
159
175
|
agentId: z.string().optional(),
|
|
160
176
|
/** The call as the card previews it, when the input alone does not tell it. */
|
|
161
177
|
preview: ViewToolCallSchema.optional(),
|
|
178
|
+
/**
|
|
179
|
+
* What "always allow" would add, one choice each, in the serving
|
|
180
|
+
* device's words ("Allow Bash(npm test:*) in this folder"): chat.answer
|
|
181
|
+
* picks them by index.
|
|
182
|
+
*/
|
|
183
|
+
suggestions: z.array(z.object({ label: z.string() })).optional(),
|
|
162
184
|
});
|
|
163
185
|
export type ViewPermission = z.infer<typeof ViewPermissionSchema>;
|
|
164
186
|
|
|
@@ -212,3 +234,64 @@ export const ChatStatusSchema = z.object({
|
|
|
212
234
|
permissions: z.array(ViewPermissionSchema),
|
|
213
235
|
});
|
|
214
236
|
export type ChatStatus = z.infer<typeof ChatStatusSchema>;
|
|
237
|
+
|
|
238
|
+
/** One step of the agent's to-do list. */
|
|
239
|
+
export const ViewTodoSchema = z.object({
|
|
240
|
+
content: z.string(),
|
|
241
|
+
/** pending, in_progress or completed. */
|
|
242
|
+
status: z.string(),
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
/** A subagent the turn called (an Agent tool call). */
|
|
246
|
+
export const ViewAgentRowSchema = z.object({
|
|
247
|
+
toolUseId: z.string(),
|
|
248
|
+
description: z.string(),
|
|
249
|
+
/** running, completed, failed or stopped. */
|
|
250
|
+
status: z.string(),
|
|
251
|
+
startedAt: z.number().optional(),
|
|
252
|
+
endedAt: z.number().optional(),
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
/** A goal the chat works toward (/goal), and where it stands. */
|
|
256
|
+
export const ViewGoalSchema = z.object({
|
|
257
|
+
condition: z.string(),
|
|
258
|
+
/** active, paused, met or failed. */
|
|
259
|
+
status: z.string(),
|
|
260
|
+
setAt: z.number().optional(),
|
|
261
|
+
/** How many checks found it unmet so far. */
|
|
262
|
+
checks: z.number().int().nonnegative(),
|
|
263
|
+
/** Once it ended: why. */
|
|
264
|
+
reason: z.string().optional(),
|
|
265
|
+
});
|
|
266
|
+
export type ViewGoal = z.infer<typeof ViewGoalSchema>;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* What the chat's side panel shows beside the conversation: the to-do
|
|
270
|
+
* list, the tasks and subagents, the files it changed, the context it
|
|
271
|
+
* fills, what it cost, and its goal.
|
|
272
|
+
*/
|
|
273
|
+
export const ChatPanelSchema = z.object({
|
|
274
|
+
todos: z.array(ViewTodoSchema),
|
|
275
|
+
/** Background runs and the like, by the program's task ids (chat.stopTask stops one). */
|
|
276
|
+
tasks: z.array(ViewTaskSchema),
|
|
277
|
+
agents: z.array(ViewAgentRowSchema),
|
|
278
|
+
changedFiles: z.array(
|
|
279
|
+
z.object({
|
|
280
|
+
/** Absolute, on the serving device, as the chat's tool calls name it. */
|
|
281
|
+
path: z.string(),
|
|
282
|
+
added: z.number().int().nonnegative().optional(),
|
|
283
|
+
removed: z.number().int().nonnegative().optional(),
|
|
284
|
+
}),
|
|
285
|
+
),
|
|
286
|
+
/** The context window: tokens in it, and how many it takes; null before the program said. */
|
|
287
|
+
context: z
|
|
288
|
+
.object({
|
|
289
|
+
usedTokens: z.number().int().nonnegative(),
|
|
290
|
+
maxTokens: z.number().int().positive(),
|
|
291
|
+
})
|
|
292
|
+
.nullable(),
|
|
293
|
+
/** What the conversation cost so far, in US dollars, when the program tells it. */
|
|
294
|
+
costUsd: z.number().nonnegative().optional(),
|
|
295
|
+
goal: ViewGoalSchema.nullable(),
|
|
296
|
+
});
|
|
297
|
+
export type ChatPanel = z.infer<typeof ChatPanelSchema>;
|