@uxnan/shared 0.0.1-alpha.20260627
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 +96 -0
- package/dist/src/agents/agent-adapter.d.ts +78 -0
- package/dist/src/agents/agent-adapter.js +2 -0
- package/dist/src/agents/agent-adapter.js.map +1 -0
- package/dist/src/agents/agent-capabilities.d.ts +106 -0
- package/dist/src/agents/agent-capabilities.js +7 -0
- package/dist/src/agents/agent-capabilities.js.map +1 -0
- package/dist/src/agents/agent-config.d.ts +17 -0
- package/dist/src/agents/agent-config.js +2 -0
- package/dist/src/agents/agent-config.js.map +1 -0
- package/dist/src/constants.d.ts +30 -0
- package/dist/src/constants.js +31 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/e2ee/envelope.d.ts +17 -0
- package/dist/src/e2ee/envelope.js +7 -0
- package/dist/src/e2ee/envelope.js.map +1 -0
- package/dist/src/e2ee/handshake.d.ts +82 -0
- package/dist/src/e2ee/handshake.js +14 -0
- package/dist/src/e2ee/handshake.js.map +1 -0
- package/dist/src/e2ee/pairing-payload.d.ts +44 -0
- package/dist/src/e2ee/pairing-payload.js +82 -0
- package/dist/src/e2ee/pairing-payload.js.map +1 -0
- package/dist/src/index.d.ts +25 -0
- package/dist/src/index.js +32 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/jsonrpc/envelope.d.ts +39 -0
- package/dist/src/jsonrpc/envelope.js +36 -0
- package/dist/src/jsonrpc/envelope.js.map +1 -0
- package/dist/src/jsonrpc/errors.d.ts +43 -0
- package/dist/src/jsonrpc/errors.js +73 -0
- package/dist/src/jsonrpc/errors.js.map +1 -0
- package/dist/src/jsonrpc/method-registry.d.ts +7 -0
- package/dist/src/jsonrpc/method-registry.js +79 -0
- package/dist/src/jsonrpc/method-registry.js.map +1 -0
- package/dist/src/jsonrpc/methods.d.ts +526 -0
- package/dist/src/jsonrpc/methods.js +2 -0
- package/dist/src/jsonrpc/methods.js.map +1 -0
- package/dist/src/jsonrpc/notifications.d.ts +85 -0
- package/dist/src/jsonrpc/notifications.js +19 -0
- package/dist/src/jsonrpc/notifications.js.map +1 -0
- package/dist/src/models/approval.d.ts +37 -0
- package/dist/src/models/approval.js +12 -0
- package/dist/src/models/approval.js.map +1 -0
- package/dist/src/models/git.d.ts +191 -0
- package/dist/src/models/git.js +8 -0
- package/dist/src/models/git.js.map +1 -0
- package/dist/src/models/project.d.ts +22 -0
- package/dist/src/models/project.js +5 -0
- package/dist/src/models/project.js.map +1 -0
- package/dist/src/models/session.d.ts +28 -0
- package/dist/src/models/session.js +7 -0
- package/dist/src/models/session.js.map +1 -0
- package/dist/src/models/thread.d.ts +104 -0
- package/dist/src/models/thread.js +8 -0
- package/dist/src/models/thread.js.map +1 -0
- package/dist/src/models/workspace.d.ts +133 -0
- package/dist/src/models/workspace.js +7 -0
- package/dist/src/models/workspace.js.map +1 -0
- package/dist/src/notifications/push-payload.d.ts +23 -0
- package/dist/src/notifications/push-payload.js +7 -0
- package/dist/src/notifications/push-payload.js.map +1 -0
- package/dist/src/validators/json-schema/schemas.d.ts +13 -0
- package/dist/src/validators/json-schema/schemas.js +82 -0
- package/dist/src/validators/json-schema/schemas.js.map +1 -0
- package/dist/src/validators/validate.d.ts +20 -0
- package/dist/src/validators/validate.js +46 -0
- package/dist/src/validators/validate.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed registry of all JSON-RPC methods the mobile app can invoke and the
|
|
3
|
+
* bridge must implement.
|
|
4
|
+
*
|
|
5
|
+
* Source: architecture/02b-contracts-and-requirements.md and
|
|
6
|
+
* uxnandesktop/architecture/02e-bridge-integration.md §4.4.
|
|
7
|
+
*/
|
|
8
|
+
import type { AccessMode, Thread, ThreadList, Turn, TurnList } from '../models/thread.js';
|
|
9
|
+
import type { GitBranchList, GitBranchResult, GitCommitDetails, GitCommitResult, GitCommitShowParams, GitDiff, GitLogParams, GitLogResult, GitPrResult, GitPullResult, GitPushResult, GitRepoStatus, GitWorktreeResult } from '../models/git.js';
|
|
10
|
+
import type { ApplyResult, BrowseResult, Checkpoint, CheckpointDiff, FileContent, ImageContent, PatchChange, TurnAttachment, WorkspaceExistsResult, WorkspaceListing } from '../models/workspace.js';
|
|
11
|
+
import type { AuthStatus, Project } from '../models/project.js';
|
|
12
|
+
import type { ApprovalResponse } from '../models/approval.js';
|
|
13
|
+
import type { BridgeStatus, ConnectedPhone, TrustedDevice } from '../models/session.js';
|
|
14
|
+
import type { PairingPayload } from '../e2ee/pairing-payload.js';
|
|
15
|
+
import type { AgentDescriptor, AgentId, AgentModel } from '../agents/agent-capabilities.js';
|
|
16
|
+
import type { PushPlatform } from '../notifications/push-payload.js';
|
|
17
|
+
export interface ListThreadsParams {
|
|
18
|
+
projectId?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface StartThreadParams {
|
|
21
|
+
projectId: string;
|
|
22
|
+
title?: string;
|
|
23
|
+
/** Agent to drive the thread (defaults to the bridge's configured default). */
|
|
24
|
+
agentId?: AgentId;
|
|
25
|
+
/** Model the agent should use (e.g. `provider/model`). */
|
|
26
|
+
model?: string;
|
|
27
|
+
/** Working directory override; defaults to the project's cwd. */
|
|
28
|
+
cwd?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ForkParams {
|
|
31
|
+
threadId: string;
|
|
32
|
+
newBranch?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface TurnListParams {
|
|
35
|
+
threadId: string;
|
|
36
|
+
cursor?: string;
|
|
37
|
+
limit?: number;
|
|
38
|
+
/**
|
|
39
|
+
* When true, return the newest `limit` turns (the last page) regardless of
|
|
40
|
+
* `cursor`. Lets a client open a long thread at its most recent messages and
|
|
41
|
+
* page backward from there using `total`.
|
|
42
|
+
*/
|
|
43
|
+
fromEnd?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface TurnSendParams {
|
|
46
|
+
threadId: string;
|
|
47
|
+
/**
|
|
48
|
+
* User prompt text. Optional when `attachments` (an image-only message) is
|
|
49
|
+
* present; otherwise required and non-empty. The bridge rejects a turn with
|
|
50
|
+
* neither text nor attachments.
|
|
51
|
+
*/
|
|
52
|
+
text?: string;
|
|
53
|
+
service?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Legacy flat reasoning-effort field. Still honored; new clients should send
|
|
56
|
+
* the value under `options` (keyed by the advertised knob, e.g. `reasoning`).
|
|
57
|
+
*/
|
|
58
|
+
effort?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Chosen per-model run-option values, keyed by `AgentModelOption.key` (the
|
|
61
|
+
* knobs advertised on the thread's model via `agent/models`). The bridge maps
|
|
62
|
+
* each into the agent CLI's real flag; unknown keys are ignored.
|
|
63
|
+
*/
|
|
64
|
+
options?: Record<string, string | boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Inline image attachments for this turn. The bridge materializes each to a
|
|
67
|
+
* temp file and references it in the prompt so any file/vision-capable agent
|
|
68
|
+
* CLI can open it. An image-only message (empty `text`) is allowed.
|
|
69
|
+
*/
|
|
70
|
+
attachments?: TurnAttachment[];
|
|
71
|
+
/**
|
|
72
|
+
* Reply to a pending approval the agent requested (no new turn is created).
|
|
73
|
+
* The bridge routes the decision to the agent adapter. When present, `text`
|
|
74
|
+
* is not required.
|
|
75
|
+
*/
|
|
76
|
+
approvalResponse?: ApprovalResponse;
|
|
77
|
+
}
|
|
78
|
+
export interface ThreadSetModelParams {
|
|
79
|
+
threadId: string;
|
|
80
|
+
model: string;
|
|
81
|
+
}
|
|
82
|
+
export interface ThreadRenameParams {
|
|
83
|
+
threadId: string;
|
|
84
|
+
/** New, non-empty title for the thread. */
|
|
85
|
+
title: string;
|
|
86
|
+
}
|
|
87
|
+
export interface ThreadSetAccessModeParams {
|
|
88
|
+
threadId: string;
|
|
89
|
+
/** The per-thread access (approval) mode to persist. */
|
|
90
|
+
mode: AccessMode;
|
|
91
|
+
}
|
|
92
|
+
export interface TurnSendResult {
|
|
93
|
+
turnId: string;
|
|
94
|
+
}
|
|
95
|
+
export interface GitCommitParams {
|
|
96
|
+
cwd: string;
|
|
97
|
+
message: string;
|
|
98
|
+
/**
|
|
99
|
+
* Repository-relative paths to stage before committing. When omitted or
|
|
100
|
+
* empty the whole working tree is staged (`git add -A`), preserving the
|
|
101
|
+
* previous behaviour. Any co-author trailer is already part of `message`.
|
|
102
|
+
*/
|
|
103
|
+
paths?: string[];
|
|
104
|
+
}
|
|
105
|
+
export interface GitPathsParams {
|
|
106
|
+
cwd: string;
|
|
107
|
+
/** Repository-relative paths to act on. */
|
|
108
|
+
paths: string[];
|
|
109
|
+
}
|
|
110
|
+
export interface GitDiffParams {
|
|
111
|
+
cwd: string;
|
|
112
|
+
/** When set, returns the diff for this single file (handles untracked). */
|
|
113
|
+
path?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface GitPrParams {
|
|
116
|
+
cwd: string;
|
|
117
|
+
title: string;
|
|
118
|
+
body?: string;
|
|
119
|
+
/** Base branch for the PR (defaults to the host's default branch). */
|
|
120
|
+
base?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Head branch the PR is opened from (defaults to the current branch). The
|
|
123
|
+
* bridge pushes it to the remote before opening the PR.
|
|
124
|
+
*/
|
|
125
|
+
head?: string;
|
|
126
|
+
}
|
|
127
|
+
export interface GitPushParams {
|
|
128
|
+
cwd: string;
|
|
129
|
+
remote: string;
|
|
130
|
+
branch: string;
|
|
131
|
+
}
|
|
132
|
+
export interface GitPullParams {
|
|
133
|
+
cwd: string;
|
|
134
|
+
remote?: string;
|
|
135
|
+
branch?: string;
|
|
136
|
+
}
|
|
137
|
+
export interface GitCheckoutParams {
|
|
138
|
+
cwd: string;
|
|
139
|
+
branch: string;
|
|
140
|
+
}
|
|
141
|
+
export interface GitSwitchBranchParams {
|
|
142
|
+
cwd: string;
|
|
143
|
+
/** The branch to switch to. */
|
|
144
|
+
target: string;
|
|
145
|
+
/**
|
|
146
|
+
* When true the working-tree changes follow you to the target; when false
|
|
147
|
+
* they stay on the current branch (stashed, restored on return).
|
|
148
|
+
*/
|
|
149
|
+
carryChanges: boolean;
|
|
150
|
+
}
|
|
151
|
+
export interface GitBranchParams {
|
|
152
|
+
cwd: string;
|
|
153
|
+
name: string;
|
|
154
|
+
}
|
|
155
|
+
export interface GitWorktreeParams {
|
|
156
|
+
cwd: string;
|
|
157
|
+
branch: string;
|
|
158
|
+
path: string;
|
|
159
|
+
managed?: boolean;
|
|
160
|
+
}
|
|
161
|
+
export interface GitRevertParams {
|
|
162
|
+
cwd: string;
|
|
163
|
+
/** Commit-ish to revert (e.g. `HEAD`, a sha). Creates a new revert commit. */
|
|
164
|
+
commit: string;
|
|
165
|
+
}
|
|
166
|
+
export interface GitDeleteBranchParams {
|
|
167
|
+
cwd: string;
|
|
168
|
+
branch: string;
|
|
169
|
+
/**
|
|
170
|
+
* When false, git refuses to delete a branch not fully merged (`-d`); true
|
|
171
|
+
* forces it (`-D`). The phone should retry with `force: true` only after an
|
|
172
|
+
* explicit user confirmation.
|
|
173
|
+
*/
|
|
174
|
+
force: boolean;
|
|
175
|
+
}
|
|
176
|
+
export interface GitRemoveWorktreeParams {
|
|
177
|
+
cwd: string;
|
|
178
|
+
/** The worktree's path to remove. */
|
|
179
|
+
path: string;
|
|
180
|
+
/**
|
|
181
|
+
* When false, git refuses to remove a worktree with uncommitted/untracked
|
|
182
|
+
* changes; true forces it. Confirm with the user before forcing.
|
|
183
|
+
*/
|
|
184
|
+
force: boolean;
|
|
185
|
+
}
|
|
186
|
+
export interface WorkspaceExistsParams {
|
|
187
|
+
/** Absolute directory to probe (a thread's `cwd`). */
|
|
188
|
+
cwd: string;
|
|
189
|
+
}
|
|
190
|
+
export interface BrowseDirsParams {
|
|
191
|
+
/** Which configured root to browse (defaults to the first when omitted). */
|
|
192
|
+
rootId?: string;
|
|
193
|
+
/** Path relative to the root (`''` or omitted = the root itself). */
|
|
194
|
+
path?: string;
|
|
195
|
+
}
|
|
196
|
+
export interface CheckpointParams {
|
|
197
|
+
cwd: string;
|
|
198
|
+
threadId?: string;
|
|
199
|
+
label?: string;
|
|
200
|
+
}
|
|
201
|
+
export interface PatchParams {
|
|
202
|
+
cwd: string;
|
|
203
|
+
changes: PatchChange[];
|
|
204
|
+
}
|
|
205
|
+
export interface AgentListResult {
|
|
206
|
+
agents: AgentDescriptor[];
|
|
207
|
+
}
|
|
208
|
+
export interface AgentModelsParams {
|
|
209
|
+
agentId: AgentId;
|
|
210
|
+
}
|
|
211
|
+
export interface AgentModelsResult {
|
|
212
|
+
/** Models the agent can use, with presentation metadata, as reported by its CLI. */
|
|
213
|
+
models: AgentModel[];
|
|
214
|
+
}
|
|
215
|
+
/** What the phone wants to be notified about (background push). */
|
|
216
|
+
export interface NotificationPreferences {
|
|
217
|
+
/** Push when an agent turn completes. */
|
|
218
|
+
turnCompleted: boolean;
|
|
219
|
+
/** Push when an agent turn errors. */
|
|
220
|
+
turnError: boolean;
|
|
221
|
+
}
|
|
222
|
+
export interface RegisterNotificationsParams {
|
|
223
|
+
/** FCM (Android) or APNs (iOS) device token. */
|
|
224
|
+
pushToken: string;
|
|
225
|
+
platform: PushPlatform;
|
|
226
|
+
preferences?: NotificationPreferences;
|
|
227
|
+
}
|
|
228
|
+
export interface RegisterNotificationsResult {
|
|
229
|
+
/** Whether the bridge accepted (and forwarded to the relay) the token. */
|
|
230
|
+
registered: boolean;
|
|
231
|
+
}
|
|
232
|
+
export interface UpdateNotificationsParams {
|
|
233
|
+
preferences: NotificationPreferences;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Maps each method name to its `params` and `result` types. Use with
|
|
237
|
+
* {@link JsonRpcMethodName} for end-to-end type-safety on both peers.
|
|
238
|
+
*/
|
|
239
|
+
export interface JsonRpcMethodRegistry {
|
|
240
|
+
'thread/list': {
|
|
241
|
+
params: ListThreadsParams;
|
|
242
|
+
result: ThreadList;
|
|
243
|
+
};
|
|
244
|
+
'thread/read': {
|
|
245
|
+
params: {
|
|
246
|
+
threadId: string;
|
|
247
|
+
};
|
|
248
|
+
result: Thread;
|
|
249
|
+
};
|
|
250
|
+
'thread/start': {
|
|
251
|
+
params: StartThreadParams;
|
|
252
|
+
result: Thread;
|
|
253
|
+
};
|
|
254
|
+
'thread/resume': {
|
|
255
|
+
params: {
|
|
256
|
+
threadId: string;
|
|
257
|
+
};
|
|
258
|
+
result: void;
|
|
259
|
+
};
|
|
260
|
+
'thread/fork': {
|
|
261
|
+
params: ForkParams;
|
|
262
|
+
result: Thread;
|
|
263
|
+
};
|
|
264
|
+
'thread/setModel': {
|
|
265
|
+
params: ThreadSetModelParams;
|
|
266
|
+
result: void;
|
|
267
|
+
};
|
|
268
|
+
'thread/rename': {
|
|
269
|
+
params: ThreadRenameParams;
|
|
270
|
+
result: Thread;
|
|
271
|
+
};
|
|
272
|
+
'thread/setAccessMode': {
|
|
273
|
+
params: ThreadSetAccessModeParams;
|
|
274
|
+
result: Thread;
|
|
275
|
+
};
|
|
276
|
+
'thread/archive': {
|
|
277
|
+
params: {
|
|
278
|
+
threadId: string;
|
|
279
|
+
};
|
|
280
|
+
result: Thread;
|
|
281
|
+
};
|
|
282
|
+
'thread/unarchive': {
|
|
283
|
+
params: {
|
|
284
|
+
threadId: string;
|
|
285
|
+
};
|
|
286
|
+
result: Thread;
|
|
287
|
+
};
|
|
288
|
+
'thread/delete': {
|
|
289
|
+
params: {
|
|
290
|
+
threadId: string;
|
|
291
|
+
};
|
|
292
|
+
result: void;
|
|
293
|
+
};
|
|
294
|
+
'turn/list': {
|
|
295
|
+
params: TurnListParams;
|
|
296
|
+
result: TurnList;
|
|
297
|
+
};
|
|
298
|
+
'turn/read': {
|
|
299
|
+
params: {
|
|
300
|
+
turnId: string;
|
|
301
|
+
};
|
|
302
|
+
result: Turn;
|
|
303
|
+
};
|
|
304
|
+
'turn/send': {
|
|
305
|
+
params: TurnSendParams;
|
|
306
|
+
result: TurnSendResult;
|
|
307
|
+
};
|
|
308
|
+
'turn/cancel': {
|
|
309
|
+
params: {
|
|
310
|
+
threadId: string;
|
|
311
|
+
turnId: string;
|
|
312
|
+
};
|
|
313
|
+
result: void;
|
|
314
|
+
};
|
|
315
|
+
'git/status': {
|
|
316
|
+
params: {
|
|
317
|
+
cwd: string;
|
|
318
|
+
};
|
|
319
|
+
result: GitRepoStatus;
|
|
320
|
+
};
|
|
321
|
+
'git/diff': {
|
|
322
|
+
params: GitDiffParams;
|
|
323
|
+
result: GitDiff;
|
|
324
|
+
};
|
|
325
|
+
'git/commit': {
|
|
326
|
+
params: GitCommitParams;
|
|
327
|
+
result: GitCommitResult;
|
|
328
|
+
};
|
|
329
|
+
'git/push': {
|
|
330
|
+
params: GitPushParams;
|
|
331
|
+
result: GitPushResult;
|
|
332
|
+
};
|
|
333
|
+
'git/pull': {
|
|
334
|
+
params: GitPullParams;
|
|
335
|
+
result: GitPullResult;
|
|
336
|
+
};
|
|
337
|
+
'git/checkout': {
|
|
338
|
+
params: GitCheckoutParams;
|
|
339
|
+
result: void;
|
|
340
|
+
};
|
|
341
|
+
'git/createBranch': {
|
|
342
|
+
params: GitBranchParams;
|
|
343
|
+
result: GitBranchResult;
|
|
344
|
+
};
|
|
345
|
+
'git/createWorktree': {
|
|
346
|
+
params: GitWorktreeParams;
|
|
347
|
+
result: GitWorktreeResult;
|
|
348
|
+
};
|
|
349
|
+
'git/stage': {
|
|
350
|
+
params: GitPathsParams;
|
|
351
|
+
result: void;
|
|
352
|
+
};
|
|
353
|
+
'git/unstage': {
|
|
354
|
+
params: GitPathsParams;
|
|
355
|
+
result: void;
|
|
356
|
+
};
|
|
357
|
+
'git/discard': {
|
|
358
|
+
params: GitPathsParams;
|
|
359
|
+
result: void;
|
|
360
|
+
};
|
|
361
|
+
'git/createPr': {
|
|
362
|
+
params: GitPrParams;
|
|
363
|
+
result: GitPrResult;
|
|
364
|
+
};
|
|
365
|
+
'git/undoCommit': {
|
|
366
|
+
params: {
|
|
367
|
+
cwd: string;
|
|
368
|
+
};
|
|
369
|
+
result: void;
|
|
370
|
+
};
|
|
371
|
+
'git/branches': {
|
|
372
|
+
params: {
|
|
373
|
+
cwd: string;
|
|
374
|
+
};
|
|
375
|
+
result: GitBranchList;
|
|
376
|
+
};
|
|
377
|
+
'git/switchBranch': {
|
|
378
|
+
params: GitSwitchBranchParams;
|
|
379
|
+
result: void;
|
|
380
|
+
};
|
|
381
|
+
'git/revert': {
|
|
382
|
+
params: GitRevertParams;
|
|
383
|
+
result: void;
|
|
384
|
+
};
|
|
385
|
+
'git/deleteBranch': {
|
|
386
|
+
params: GitDeleteBranchParams;
|
|
387
|
+
result: void;
|
|
388
|
+
};
|
|
389
|
+
'git/removeWorktree': {
|
|
390
|
+
params: GitRemoveWorktreeParams;
|
|
391
|
+
result: void;
|
|
392
|
+
};
|
|
393
|
+
'git/log': {
|
|
394
|
+
params: GitLogParams;
|
|
395
|
+
result: GitLogResult;
|
|
396
|
+
};
|
|
397
|
+
'git/commitShow': {
|
|
398
|
+
params: GitCommitShowParams;
|
|
399
|
+
result: GitCommitDetails;
|
|
400
|
+
};
|
|
401
|
+
'workspace/readFile': {
|
|
402
|
+
params: {
|
|
403
|
+
cwd: string;
|
|
404
|
+
path: string;
|
|
405
|
+
};
|
|
406
|
+
result: FileContent;
|
|
407
|
+
};
|
|
408
|
+
'workspace/readImage': {
|
|
409
|
+
params: {
|
|
410
|
+
cwd: string;
|
|
411
|
+
path: string;
|
|
412
|
+
};
|
|
413
|
+
result: ImageContent;
|
|
414
|
+
};
|
|
415
|
+
'workspace/list': {
|
|
416
|
+
params: {
|
|
417
|
+
cwd: string;
|
|
418
|
+
};
|
|
419
|
+
result: WorkspaceListing;
|
|
420
|
+
};
|
|
421
|
+
'workspace/browseDirs': {
|
|
422
|
+
params: BrowseDirsParams;
|
|
423
|
+
result: BrowseResult;
|
|
424
|
+
};
|
|
425
|
+
'workspace/checkpoint': {
|
|
426
|
+
params: CheckpointParams;
|
|
427
|
+
result: Checkpoint;
|
|
428
|
+
};
|
|
429
|
+
'workspace/diffCheckpoint': {
|
|
430
|
+
params: {
|
|
431
|
+
id: string;
|
|
432
|
+
};
|
|
433
|
+
result: CheckpointDiff;
|
|
434
|
+
};
|
|
435
|
+
'workspace/applyCheckpoint': {
|
|
436
|
+
params: {
|
|
437
|
+
id: string;
|
|
438
|
+
};
|
|
439
|
+
result: void;
|
|
440
|
+
};
|
|
441
|
+
'workspace/applyPatch': {
|
|
442
|
+
params: PatchParams;
|
|
443
|
+
result: ApplyResult;
|
|
444
|
+
};
|
|
445
|
+
'workspace/exists': {
|
|
446
|
+
params: WorkspaceExistsParams;
|
|
447
|
+
result: WorkspaceExistsResult;
|
|
448
|
+
};
|
|
449
|
+
'project/list': {
|
|
450
|
+
params: void;
|
|
451
|
+
result: Project[];
|
|
452
|
+
};
|
|
453
|
+
'project/resolve': {
|
|
454
|
+
params: {
|
|
455
|
+
cwd: string;
|
|
456
|
+
};
|
|
457
|
+
result: Project;
|
|
458
|
+
};
|
|
459
|
+
'agent/list': {
|
|
460
|
+
params: void;
|
|
461
|
+
result: AgentListResult;
|
|
462
|
+
};
|
|
463
|
+
'agent/models': {
|
|
464
|
+
params: AgentModelsParams;
|
|
465
|
+
result: AgentModelsResult;
|
|
466
|
+
};
|
|
467
|
+
'auth/status': {
|
|
468
|
+
params: {
|
|
469
|
+
agentId: AgentId;
|
|
470
|
+
};
|
|
471
|
+
result: AuthStatus;
|
|
472
|
+
};
|
|
473
|
+
'auth/login': {
|
|
474
|
+
params: {
|
|
475
|
+
provider: string;
|
|
476
|
+
};
|
|
477
|
+
result: void;
|
|
478
|
+
};
|
|
479
|
+
'auth/logout': {
|
|
480
|
+
params: void;
|
|
481
|
+
result: void;
|
|
482
|
+
};
|
|
483
|
+
'notifications/register': {
|
|
484
|
+
params: RegisterNotificationsParams;
|
|
485
|
+
result: RegisterNotificationsResult;
|
|
486
|
+
};
|
|
487
|
+
'notifications/update': {
|
|
488
|
+
params: UpdateNotificationsParams;
|
|
489
|
+
result: void;
|
|
490
|
+
};
|
|
491
|
+
'notifications/unregister': {
|
|
492
|
+
params: void;
|
|
493
|
+
result: void;
|
|
494
|
+
};
|
|
495
|
+
'bridge/status': {
|
|
496
|
+
params: void;
|
|
497
|
+
result: BridgeStatus;
|
|
498
|
+
};
|
|
499
|
+
'bridge/generatePairingQr': {
|
|
500
|
+
params: void;
|
|
501
|
+
result: PairingPayload;
|
|
502
|
+
};
|
|
503
|
+
'bridge/connectedPhones': {
|
|
504
|
+
params: void;
|
|
505
|
+
result: ConnectedPhone[];
|
|
506
|
+
};
|
|
507
|
+
'bridge/disconnectPhone': {
|
|
508
|
+
params: {
|
|
509
|
+
deviceId: string;
|
|
510
|
+
};
|
|
511
|
+
result: void;
|
|
512
|
+
};
|
|
513
|
+
'bridge/trustedDevices': {
|
|
514
|
+
params: void;
|
|
515
|
+
result: TrustedDevice[];
|
|
516
|
+
};
|
|
517
|
+
'bridge/removeTrustedDevice': {
|
|
518
|
+
params: {
|
|
519
|
+
deviceId: string;
|
|
520
|
+
};
|
|
521
|
+
result: void;
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
export type JsonRpcMethodName = keyof JsonRpcMethodRegistry;
|
|
525
|
+
export type MethodParams<M extends JsonRpcMethodName> = JsonRpcMethodRegistry[M]['params'];
|
|
526
|
+
export type MethodResult<M extends JsonRpcMethodName> = JsonRpcMethodRegistry[M]['result'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../../src/jsonrpc/methods.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge → phone streaming notifications (JSON-RPC notifications, no `id`).
|
|
3
|
+
*
|
|
4
|
+
* Source: architecture/02b-contracts-and-requirements.md (streaming events).
|
|
5
|
+
*/
|
|
6
|
+
export declare const StreamNotification: {
|
|
7
|
+
readonly TurnStarted: "stream/turn/started";
|
|
8
|
+
readonly MessageDelta: "stream/message/delta";
|
|
9
|
+
/** A chunk of the agent's reasoning / "thinking" for this turn (`data.delta`). */
|
|
10
|
+
readonly ThinkingDelta: "stream/thinking/delta";
|
|
11
|
+
/** A structured content block (command/diff/tool) the agent produced this turn. */
|
|
12
|
+
readonly ContentBlock: "stream/content/block";
|
|
13
|
+
readonly TurnCompleted: "stream/turn/completed";
|
|
14
|
+
readonly TurnError: "stream/turn/error";
|
|
15
|
+
readonly TurnAborted: "stream/turn/aborted";
|
|
16
|
+
/** The agent resolved an alias (e.g. `opus`) to a concrete model id for this turn. */
|
|
17
|
+
readonly ModelResolved: "stream/model/resolved";
|
|
18
|
+
};
|
|
19
|
+
export type StreamNotification = (typeof StreamNotification)[keyof typeof StreamNotification];
|
|
20
|
+
export interface TurnStartedParams {
|
|
21
|
+
threadId: string;
|
|
22
|
+
turnId: string;
|
|
23
|
+
}
|
|
24
|
+
export interface MessageDeltaParams {
|
|
25
|
+
threadId: string;
|
|
26
|
+
turnId: string;
|
|
27
|
+
messageId: string;
|
|
28
|
+
delta: string;
|
|
29
|
+
}
|
|
30
|
+
/** A chunk of the agent's reasoning ("thinking") for a turn. */
|
|
31
|
+
export interface ThinkingDeltaParams {
|
|
32
|
+
threadId: string;
|
|
33
|
+
turnId: string;
|
|
34
|
+
messageId: string;
|
|
35
|
+
delta: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A structured content block (a serialized MessageContent: `command_execution`,
|
|
39
|
+
* `diff`, `tool`, …) the agent produced during a turn. The phone decodes
|
|
40
|
+
* `content` straight into a MessageContent and folds it into the streaming
|
|
41
|
+
* message (Work log / Changed files).
|
|
42
|
+
*/
|
|
43
|
+
export interface ContentBlockParams {
|
|
44
|
+
threadId: string;
|
|
45
|
+
turnId: string;
|
|
46
|
+
messageId: string;
|
|
47
|
+
content: unknown;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Token usage for a completed turn, as reported by the agent's CLI.
|
|
51
|
+
* `tokens` is the context the conversation now occupies (≈ the latest turn's
|
|
52
|
+
* input + the output it produced). `contextWindow` is the model's limit when
|
|
53
|
+
* known (Claude tiers); omitted when the CLI doesn't expose it (Codex), in
|
|
54
|
+
* which case the phone shows the raw token count instead of a percentage.
|
|
55
|
+
*/
|
|
56
|
+
export interface TurnUsage {
|
|
57
|
+
tokens: number;
|
|
58
|
+
contextWindow?: number;
|
|
59
|
+
}
|
|
60
|
+
export interface TurnCompletedParams {
|
|
61
|
+
threadId: string;
|
|
62
|
+
turnId: string;
|
|
63
|
+
messageId: string;
|
|
64
|
+
text: string;
|
|
65
|
+
/** Token usage for this turn, when the agent reported it. */
|
|
66
|
+
usage?: TurnUsage;
|
|
67
|
+
}
|
|
68
|
+
export interface TurnErrorParams {
|
|
69
|
+
threadId: string;
|
|
70
|
+
turnId: string;
|
|
71
|
+
error: {
|
|
72
|
+
code: number;
|
|
73
|
+
message: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export interface TurnAbortedParams {
|
|
77
|
+
threadId: string;
|
|
78
|
+
turnId: string;
|
|
79
|
+
}
|
|
80
|
+
export interface ModelResolvedParams {
|
|
81
|
+
threadId: string;
|
|
82
|
+
turnId: string;
|
|
83
|
+
/** Concrete model id the agent resolved for this turn (e.g. `claude-opus-4-8`). */
|
|
84
|
+
model: string;
|
|
85
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge → phone streaming notifications (JSON-RPC notifications, no `id`).
|
|
3
|
+
*
|
|
4
|
+
* Source: architecture/02b-contracts-and-requirements.md (streaming events).
|
|
5
|
+
*/
|
|
6
|
+
export const StreamNotification = {
|
|
7
|
+
TurnStarted: 'stream/turn/started',
|
|
8
|
+
MessageDelta: 'stream/message/delta',
|
|
9
|
+
/** A chunk of the agent's reasoning / "thinking" for this turn (`data.delta`). */
|
|
10
|
+
ThinkingDelta: 'stream/thinking/delta',
|
|
11
|
+
/** A structured content block (command/diff/tool) the agent produced this turn. */
|
|
12
|
+
ContentBlock: 'stream/content/block',
|
|
13
|
+
TurnCompleted: 'stream/turn/completed',
|
|
14
|
+
TurnError: 'stream/turn/error',
|
|
15
|
+
TurnAborted: 'stream/turn/aborted',
|
|
16
|
+
/** The agent resolved an alias (e.g. `opus`) to a concrete model id for this turn. */
|
|
17
|
+
ModelResolved: 'stream/model/resolved',
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/jsonrpc/notifications.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,WAAW,EAAE,qBAAqB;IAClC,YAAY,EAAE,sBAAsB;IACpC,kFAAkF;IAClF,aAAa,EAAE,uBAAuB;IACtC,mFAAmF;IACnF,YAAY,EAAE,sBAAsB;IACpC,aAAa,EAAE,uBAAuB;IACtC,SAAS,EAAE,mBAAmB;IAC9B,WAAW,EAAE,qBAAqB;IAClC,sFAAsF;IACtF,aAAa,EAAE,uBAAuB;CAC9B,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive approval contracts.
|
|
3
|
+
*
|
|
4
|
+
* An agent that needs the user to authorize an action emits an `approval`
|
|
5
|
+
* content block (on `stream/content/block`); the phone renders an interactive
|
|
6
|
+
* card and replies via `turn/send { approvalResponse }`. The bridge routes the
|
|
7
|
+
* decision back to the agent adapter.
|
|
8
|
+
*
|
|
9
|
+
* Source: architecture/02a-system-architecture.md §6.2.
|
|
10
|
+
*/
|
|
11
|
+
/** Risk level the agent assigns to an action awaiting approval. */
|
|
12
|
+
export type ApprovalRisk = 'low' | 'medium' | 'high' | 'unknown';
|
|
13
|
+
/** The user's decision for a pending approval. */
|
|
14
|
+
export type ApprovalDecision = 'approve' | 'reject' | 'approveSession';
|
|
15
|
+
/** The user's reply to a pending approval, carried on `turn/send`. */
|
|
16
|
+
export interface ApprovalResponse {
|
|
17
|
+
/** The id from the approval request the user is answering. */
|
|
18
|
+
approvalId: string;
|
|
19
|
+
/** Allow once, deny, or allow for the rest of the session. */
|
|
20
|
+
decision: ApprovalDecision;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Payload of an `approval` content block. The phone decodes this straight into
|
|
24
|
+
* its interactive approval card (it is also tolerant of a nested
|
|
25
|
+
* `{ type:'approval', request:{...} }` form).
|
|
26
|
+
*/
|
|
27
|
+
export interface ApprovalRequestBlock {
|
|
28
|
+
type: 'approval';
|
|
29
|
+
/** Bridge id the phone echoes back in `approvalResponse.approvalId`. */
|
|
30
|
+
approvalId: string;
|
|
31
|
+
/** Human description of what the agent wants to do. */
|
|
32
|
+
action: string;
|
|
33
|
+
/** Risk level (defaults to `unknown` on the phone if omitted). */
|
|
34
|
+
risk?: ApprovalRisk;
|
|
35
|
+
/** Optional extra detail (e.g. the command or affected paths). */
|
|
36
|
+
detail?: string;
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive approval contracts.
|
|
3
|
+
*
|
|
4
|
+
* An agent that needs the user to authorize an action emits an `approval`
|
|
5
|
+
* content block (on `stream/content/block`); the phone renders an interactive
|
|
6
|
+
* card and replies via `turn/send { approvalResponse }`. The bridge routes the
|
|
7
|
+
* decision back to the agent adapter.
|
|
8
|
+
*
|
|
9
|
+
* Source: architecture/02a-system-architecture.md §6.2.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=approval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval.js","sourceRoot":"","sources":["../../../src/models/approval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|