@deep-podder/dsh-remote-mobile 0.0.0-stage → 0.0.6
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/LICENSE +21 -0
- package/PROTOCOL.md +627 -0
- package/README.md +315 -2
- package/SECURITY.md +207 -0
- package/auth.js +290 -0
- package/bridge.js +3167 -0
- package/client.js +692 -0
- package/cordis.patch.yml +7 -0
- package/docs/api-notes-v2.md +978 -0
- package/docs/api-notes.md +583 -0
- package/docs/screenshots/chat-light.png +0 -0
- package/docs/screenshots/commands-dark.png +0 -0
- package/docs/screenshots/pairing-light.png +0 -0
- package/docs/screenshots/sessions-light.png +0 -0
- package/docs/verification.md +92 -0
- package/icon.svg +14 -0
- package/index.js +108 -0
- package/locale/en.json +29 -0
- package/mobile/README.md +1281 -0
- package/mobile/app.js +10835 -0
- package/mobile/favicon.svg +6 -0
- package/mobile/icons/apple-touch-icon.png +0 -0
- package/mobile/icons/icon-192.png +0 -0
- package/mobile/icons/icon-512.png +0 -0
- package/mobile/icons/icon-maskable-512.png +0 -0
- package/mobile/index.html +377 -0
- package/mobile/manifest.webmanifest +40 -0
- package/mobile/mock-server.js +2800 -0
- package/mobile/styles.css +4698 -0
- package/mobile/sw.js +396 -0
- package/package.json +74 -4
- package/push.js +531 -0
- package/qr.js +49 -0
- package/server.js +2648 -0
- package/vendor/LICENSE +25 -0
- package/vendor/qrcode.js +2302 -0
|
@@ -0,0 +1,978 @@
|
|
|
1
|
+
# dsh-remote-mobile v2 — verified Host API notes
|
|
2
|
+
|
|
3
|
+
Research date: 2026-11-09. Target: installed **DeepSeek Harness 0.2.2-rc.1** (Desktop asar build).
|
|
4
|
+
Status: research notes; the v2 surface described here is implemented in `bridge.js` /
|
|
5
|
+
`PROTOCOL.md` as of v15. Items flagged **UNVERIFIED** were not conclusively probed.
|
|
6
|
+
|
|
7
|
+
> Superseded in one place (v20): the notes below recommend a phone command **allowlist**
|
|
8
|
+
> (list only `compact`). The shipped bridge instead reads the live Agent's command registry and
|
|
9
|
+
> mirrors the desktop palette, keeping only `/export` and the policy-changing `/permission`
|
|
10
|
+
> desktop-only (see `PROTOCOL.md`). The allowlist discussion is kept as historical research.
|
|
11
|
+
|
|
12
|
+
## How this was verified
|
|
13
|
+
|
|
14
|
+
1. **Cordis Inspect (Host)** — `Service.listService` with **no input** returns the live
|
|
15
|
+
capability directory (≈250 services with method signatures). Passing an `input`
|
|
16
|
+
object (`{"service": "sessionController"}`) is currently rejected by the inspect
|
|
17
|
+
transport with `"input" must be an object`, so the per-service "exact contract"
|
|
18
|
+
mode could not be used. The no-input directory was captured and used for the live
|
|
19
|
+
signature inventory; all *type* declarations come from source #2.
|
|
20
|
+
2. **Generated declaration catalog** — `dsh-tool-cordis/lib/types/api-catalog.js`
|
|
21
|
+
(1206 unique declarations, generated from the real `.d.ts`). This is the same
|
|
22
|
+
catalog that backs Cordis Inspect's detail mode. Extracted with a Node asar reader
|
|
23
|
+
(the shipped `.d.ts` files themselves are absent from the install).
|
|
24
|
+
3. **Compiled implementation** — each package's `lib/types/*.js` / `lib/index.js`,
|
|
25
|
+
which retains JSDoc and the real logic (validation, error codes, ordering).
|
|
26
|
+
4. **Desktop configuration** — bundled `cordis.patch.yml` files for resolved values
|
|
27
|
+
(e.g. `maxTitleBytes: 80`).
|
|
28
|
+
|
|
29
|
+
No live Host mutation was attempted: everything below is a read-only source finding.
|
|
30
|
+
Items that would need a live integration probe are flagged **UNVERIFIED**.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Cross-cutting model (read first)
|
|
35
|
+
|
|
36
|
+
| Capability class | Needs | Examples |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| **Cold-safe** (works on persisted sessions, no Agent resume) | `ctx.sessionQuery` / projection cache | `sessionController.list/search/events/projections`, `subagents.listChildren`, `workspaceRegistry.*` |
|
|
39
|
+
| **Live-only** (requires an attached `Agent` or in-memory `Session`) | `ctx.agents.get(id)` / resolved Agent | `sessionController.cancel/updateQueue/resolveAgent`, `commands.list/execute`, `approval.setPolicy`, `tokenMeter.measure/contextPressure`, `workspaceChanges.summary/diff`, `agentTeams.*` |
|
|
40
|
+
| **Resumes a cold session as a side effect** | `sessionController.resolveAgent` | `prompt`, `rename`, `selectModel`, `selectPreset`, `cancel` (attached-only) |
|
|
41
|
+
|
|
42
|
+
`SessionSummary.agentAvailable` (true iff `ctx.agents.get(id)?.session === session`)
|
|
43
|
+
tells the phone whether live-only actions are currently possible. Our bridge v1 already
|
|
44
|
+
exposes `running`; v2 should add `agentAvailable` so the SPA can hide live-only
|
|
45
|
+
controls instead of failing them.
|
|
46
|
+
|
|
47
|
+
`ctx.sessionController` methods are Typert `@Remote` services but are plain async
|
|
48
|
+
methods callable from a Host plugin. Methods that take a `signal` call
|
|
49
|
+
`signal.throwIfAborted()` unconditionally, so a real `AbortSignal` is required.
|
|
50
|
+
`principalOf(ctx.invocation)` is `undefined` outside a Remote call, so Host calls are
|
|
51
|
+
treated as the owner and `remoteAccess.allows(...)` returns true.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 1. `sessionController.modelCatalog()` — models, reasoning effort, `selectModel`
|
|
56
|
+
|
|
57
|
+
### Signatures (live inspect + catalog)
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
// dsh-api-session-controller
|
|
61
|
+
@Remote('modelCatalog') modelCatalog(): Promise<ModelCatalog>
|
|
62
|
+
@Remote('selectModel') selectModel(request: SessionSelectModelRequest): Promise<SessionSelectModelValue>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
interface ModelCatalog {
|
|
67
|
+
readonly default: ModelSelection; // deployment default (agentDefaultModel)
|
|
68
|
+
readonly routableProviders: readonly string[];
|
|
69
|
+
readonly groups: readonly ModelProviderGroup[];
|
|
70
|
+
readonly failures: readonly ModelCatalogFailure[]; // per-provider isolation, NOT shown as models
|
|
71
|
+
}
|
|
72
|
+
interface ModelProviderGroup { readonly id: string; readonly name: string; readonly models: readonly ModelCatalogModel[] }
|
|
73
|
+
interface ModelCatalogModel {
|
|
74
|
+
readonly id: string;
|
|
75
|
+
readonly name: string;
|
|
76
|
+
readonly description?: string;
|
|
77
|
+
readonly reasoning?: { efforts: readonly { id: string; name: string; description?: string }[];
|
|
78
|
+
defaultEffort?: string };
|
|
79
|
+
readonly badge?: LlmModelBadge;
|
|
80
|
+
}
|
|
81
|
+
interface ModelCatalogFailure { readonly id: string; readonly name: string; readonly message: string }
|
|
82
|
+
interface ModelSelection { provider: string; model: string; reasoningEffort?: ReasoningEffortId } // effort is an opaque branded string
|
|
83
|
+
interface SessionSelectModelRequest extends ModelSelection { readonly sessionId: SessionId }
|
|
84
|
+
interface SessionSelectModelValue { readonly selected: ModelSelection }
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`ModelSelection` is not a standalone catalog declaration; its exact fields are pinned by
|
|
88
|
+
`selectModel` usage (`commands.js`) and `model-selection.js` (`toSelection`): `provider`,
|
|
89
|
+
`model`, optional `reasoningEffort` (omit = provider/adapter default).
|
|
90
|
+
|
|
91
|
+
### Reasoning efforts
|
|
92
|
+
|
|
93
|
+
- **Yes.** Every routable model may carry `reasoning.efforts[]` with stable `id`, display
|
|
94
|
+
`name` and optional `description`, plus optional `defaultEffort`.
|
|
95
|
+
- If `reasoning` is absent → the model exposes no effort control.
|
|
96
|
+
- If `reasoning.defaultEffort` is absent → the UI adds an explicit **“Provider default”**
|
|
97
|
+
choice whose value is “omit `reasoningEffort`”.
|
|
98
|
+
- If `defaultEffort` is present → that effort is the effective default and the UI does
|
|
99
|
+
**not** add a provider-default entry (`dsh-client-ui-model-selection/lib/client.js`,
|
|
100
|
+
`effortChoices` / `effortLabel`).
|
|
101
|
+
|
|
102
|
+
### How the desktop picks an effort (verified in `dsh-client-ui-model-selection`)
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
sessions.selectModel({ sessionId, provider: selection.provider, model: selection.model,
|
|
106
|
+
...selection.reasoningEffort === undefined ? {} : { reasoningEffort: selection.reasoningEffort } })
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- Current = `modelSelectionProjection.next ?? catalog.default`.
|
|
110
|
+
- Displayed effort = `current.reasoningEffort ?? reasoning.defaultEffort` (name lookup in
|
|
111
|
+
`efforts[]`; falls back to the raw id; “Provider default” when nothing is set).
|
|
112
|
+
- Model choices are pre-built with `reasoningEffort: model.reasoning?.defaultEffort` when
|
|
113
|
+
a default exists; picking an effort re-submits the same route with that effort.
|
|
114
|
+
|
|
115
|
+
### `selectModel` behavior (live-only; resumes cold)
|
|
116
|
+
|
|
117
|
+
1. `resolveAgent(sessionId)` — cold session is resumed.
|
|
118
|
+
2. `requireModel` → `ctx.llm.listProviders()` + `ctx.llm.listModels(provider)` availability.
|
|
119
|
+
3. Builds `{provider, model, reasoningEffort?}` (any `reasoningEffort` is branded, not
|
|
120
|
+
validated by the brander), then `await ctx.llm.resolveCallConfig(selected)`.
|
|
121
|
+
4. `agent.model.select(selected)` → appends durable `model/selection` event (idempotent
|
|
122
|
+
when unchanged) — this drives the `modelSelection` projection.
|
|
123
|
+
5. `ctx.agentDefaultModel.saveSelection(selected)` in the background (writes profile
|
|
124
|
+
config via `configEditor`; failures are logged, not surfaced).
|
|
125
|
+
6. Returns `{ selected }`. Any validation failure is remapped to
|
|
126
|
+
`RemoteError('session/model-unavailable', message, {provider, model})`.
|
|
127
|
+
|
|
128
|
+
**Effort validation** happens inside `llm.resolveCallConfig`/`prepareCall` against the
|
|
129
|
+
resolved adapter; a wrong effort id therefore surfaces as **`session/model-unavailable`**
|
|
130
|
+
(no dedicated code). **UNVERIFIED:** the exact adapter-side check text.
|
|
131
|
+
|
|
132
|
+
### Reading the current effort for a session
|
|
133
|
+
|
|
134
|
+
- **Cold-safe:** `sessionController.projections({sessionId}, signal)` →
|
|
135
|
+
`values.modelSelection` = `{ lastUsed: ModelSelection|null, next: ModelSelection|null }`
|
|
136
|
+
(`next` = pending choice ?? lastUsed). Effective effort =
|
|
137
|
+
`(next ?? lastUsed)?.reasoningEffort ?? catalogModel.reasoning.defaultEffort`.
|
|
138
|
+
`modelSelection` is a *summary* projection, so it is also in `list()` rows.
|
|
139
|
+
- **Live:** `ctx.agents.get(id)?.model.current()` returns `{provider, model, reasoningEffort?}`
|
|
140
|
+
where a recorded selection wins and falls back to `agent.options` (provider/model/effort
|
|
141
|
+
supplied at creation).
|
|
142
|
+
- A durable `request/header` event records what the request actually used:
|
|
143
|
+
`data.header.config` (may include `reasoningEffort`) and
|
|
144
|
+
`data.header.adapterDefaults.reasoningEffort === true` means the adapter defaulted it
|
|
145
|
+
(so it should be displayed as “provider default”, not as a selected effort).
|
|
146
|
+
|
|
147
|
+
### Gotchas
|
|
148
|
+
|
|
149
|
+
- `modelCatalog()` groups only **routable** providers; a provider that throws appears only
|
|
150
|
+
in `failures[]`. A model can be absent from the picker while the provider is configured.
|
|
151
|
+
- The catalog does **not** expose `inputModalities`; to decide whether a model accepts
|
|
152
|
+
images (item 9) use `ctx.llm.resolveModelInfo(provider, model)` and check
|
|
153
|
+
`inputModalities?.includes('image')` (catalog `LlmModelInfo.inputModalities`).
|
|
154
|
+
- `selectModel` also changes the **deployment default** (background save), matching the
|
|
155
|
+
desktop’s behaviour. A phone model change is therefore persistent across sessions.
|
|
156
|
+
|
|
157
|
+
### Recommended frames
|
|
158
|
+
|
|
159
|
+
`models` already exists; extend each catalog entry:
|
|
160
|
+
`{ provider, model, label, reasoning: { efforts:[{id,name,description?}], defaultEffort? } | null }`
|
|
161
|
+
and `current: {provider, model, reasoningEffort, effectiveEffort, effortLabel}`.
|
|
162
|
+
Add `model.select` accepting `reasoningEffort: string|null` (null = provider default).
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 2. `sessionController.rename` / `fork`
|
|
167
|
+
|
|
168
|
+
### Rename
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
@Remote('rename') rename(request: SessionRenameRequest): Promise<SessionRenameValue>
|
|
172
|
+
interface SessionRenameRequest { readonly sessionId: SessionId; readonly title: string }
|
|
173
|
+
interface SessionRenameValue { readonly title: string; readonly seq: number }
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
- **Resumes cold sessions**: `commands.rename` calls `resolveAgent(sessionId)` first, so a
|
|
177
|
+
persisted session is opened, then `ctx.sessionTitle.rename(agent.session, request.title)`.
|
|
178
|
+
- **Title validation/normalization** (`dsh-session-title`): strips OSC/CSI/ESC control
|
|
179
|
+
sequences, control characters and bidi directional controls, collapses all whitespace to
|
|
180
|
+
single spaces, trims, then truncates to `maxTitleBytes` **UTF-8 bytes without splitting a
|
|
181
|
+
code point**. Empty result → `RemoteError('session/title-invalid', 'session title must
|
|
182
|
+
contain visible characters', {sessionId})`.
|
|
183
|
+
- **Limit is deployment config**: `maxTitleBytes` (required config). The shipped desktop
|
|
184
|
+
composition (`dsh-base/cordis.patch.yml`) sets `maxTitleBytes: 80`, `fallbackMaxWords: 5`,
|
|
185
|
+
`fallbackMaxBytes: 40`. Treat **80 UTF-8 bytes** as the phone limit; longer titles are
|
|
186
|
+
silently truncated (not rejected).
|
|
187
|
+
- Appends durable `session/title` with `{title, messageSeqs: [], source: {kind:'user'}}`,
|
|
188
|
+
updates the `title` projection, and returns the accepted title + event seq.
|
|
189
|
+
A user rename pins the title (supersedes automatic generation).
|
|
190
|
+
- Errors: `session/title-invalid` (empty), `session/not-found`, `session/agent-busy`
|
|
191
|
+
(subagent ownership), `gateway/internal`.
|
|
192
|
+
|
|
193
|
+
### Fork
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
@Remote('fork') async fork(request: SessionForkRequest): Promise<SessionForkValue>
|
|
197
|
+
interface SessionForkRequest { readonly sessionId: SessionId; readonly atSeq?: number; readonly allowMigration?: boolean }
|
|
198
|
+
interface SessionForkValue { readonly sessionId: SessionId }
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
- **What it forks:** an exact event prefix of the source log (inclusive `atSeq`). Omitted
|
|
202
|
+
`atSeq` = latest completed-turn prefix (`turn/end` plus trailing standalone events before
|
|
203
|
+
the next `turn/start`/appended user message/inbox splice). No completed turn →
|
|
204
|
+
`RemoteError('session/fork-unavailable', 'session "…" has no completed turn to fork from')`.
|
|
205
|
+
Invalid `atSeq` (not an existing seq) → `session/fork-unavailable`.
|
|
206
|
+
- **Cold source is fine:** the controller reads via `ctx.sessionQuery.observeSession`, so a
|
|
207
|
+
persisted session forks without activation. An open cut (source mid-turn) gets synthetic
|
|
208
|
+
fork closers.
|
|
209
|
+
- **Migration nuance:** if the source is *not live* and its stored format is
|
|
210
|
+
`migration-required`, `allowMigration: false` rejects **before** forking with
|
|
211
|
+
`RemoteError('session/migration-required', 'Open the source Session to complete migration before forking')`.
|
|
212
|
+
Omitted/`true` lets the read path migrate.
|
|
213
|
+
- **Child characteristics:** new id `session-<uuid>`; `cwd` inherited from the source header
|
|
214
|
+
(omitted if the source has none — a cwd-less fork is a corner case; **UNVERIFIED** whether
|
|
215
|
+
the loop accepts a cwd-less Agent); seeded with the source prefix
|
|
216
|
+
(`buildForkSeed`, `inheritedEventCount`, `isSeeded: true`); `agentPreset` inherited from
|
|
217
|
+
the source’s *current* preset; attached to the source’s workspace when the source belongs
|
|
218
|
+
to one. It is an **independent conversation** (not `origin:'subagent'`, no
|
|
219
|
+
`parentSession`), and archiving the source does not archive the fork.
|
|
220
|
+
- **Appears in `list()`?** Yes — a normally persisted top-level session
|
|
221
|
+
(`sessionController.list()` reads `sessionQuery.listSessions`, which includes live and
|
|
222
|
+
persisted sessions). The desktop client also inserts a local `blank:true` placeholder
|
|
223
|
+
until the refreshed summary arrives.
|
|
224
|
+
- Errors: `session/not-found`, `session/fork-unavailable`, `session/migration-required`,
|
|
225
|
+
`subagent/…` (address validation), `session/workspace-attach-failed`, `gateway/internal`.
|
|
226
|
+
|
|
227
|
+
### Recommended frames
|
|
228
|
+
|
|
229
|
+
`session.rename {sessionId,title}` → `session.updated {session}`; `session.fork {sessionId,
|
|
230
|
+
atSeq?}` → `session.forked {sessionId, sourceSessionId}` plus a refreshed `sessions` list
|
|
231
|
+
(the fork is a normal session). If exposing `atSeq`, validate `0 <= atSeq <= lastSeq` client-side
|
|
232
|
+
and expect `session/fork-unavailable` otherwise.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## 3. `sessionController.search`
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
@Remote('search') async search(request: SessionSearchRequest, signal: AbortSignal): Promise<SessionSearchValue>
|
|
240
|
+
interface SessionSearchValue { readonly items: readonly SessionSearchItem[]; readonly hasMore: boolean }
|
|
241
|
+
interface SessionSearchItem { readonly sessionId: SessionId; readonly snippet: string }
|
|
242
|
+
// SessionSearchRequest is not in the catalog; the controller only reads `request.query`
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
- **Request:** the controller passes `request.query` only
|
|
246
|
+
(`this.listState.search(request.query, signal)`); extra fields are ignored. Query is
|
|
247
|
+
trimmed; empty → `gateway/bad-request`; >500 UTF-16 chars or containing NUL →
|
|
248
|
+
`gateway/bad-request`.
|
|
249
|
+
- **What is searched:** literal message *content*, not titles. The provider call uses
|
|
250
|
+
`eventFilters: [{kind:'type', values:['user/message','assistant/message']},
|
|
251
|
+
{kind:'surface', values:['current']}]` — only the current model-visible surface, so
|
|
252
|
+
messages removed by surface replacement/compaction do not match. Case sensitivity and
|
|
253
|
+
tokenization are provider-defined (`dsh-session-query-sqlite`); **UNVERIFIED** (treat as
|
|
254
|
+
literal substring/FTS and let the UI show the snippet).
|
|
255
|
+
- **Cold-safe:** no Agent resume, no projection requirement. Requires `sessionQuery` to be
|
|
256
|
+
mounted; otherwise `gateway/internal` “session search is unavailable: this deployment does
|
|
257
|
+
not mount @deepseek-ai/dsh-session-query”.
|
|
258
|
+
- **Pagination/limits:** the controller internally pages the provider, deduplicates by
|
|
259
|
+
session (best match per session), caps at `SESSION_SEARCH_RESULT_LIMIT = 20` sessions,
|
|
260
|
+
truncates each snippet to `SESSION_SEARCH_SNIPPET_MAX_CODE_POINTS = 240` code points, and
|
|
261
|
+
returns `hasMore` = “there were more hits before `remoteAccess` filtering”. **No cursor
|
|
262
|
+
or offset is exposed by `sessionController.search`** (the underlying
|
|
263
|
+
`SessionSearchRequest` has `query/filters?/limit?/cursor?`, but the controller does not
|
|
264
|
+
forward them). V1 phone search is therefore “top 20 sessions + hasMore”.
|
|
265
|
+
- Errors: `gateway/bad-request` (query), `gateway/internal` (provider failure);
|
|
266
|
+
cancellation → `gateway/cancelled`.
|
|
267
|
+
|
|
268
|
+
### Recommended frame
|
|
269
|
+
|
|
270
|
+
`search.query {query}` → `search.results {query, items:[{sessionId,snippet}], hasMore}`.
|
|
271
|
+
Add `session.search` to the SPA with a debounce; no pagination until v3 (to page, the bridge
|
|
272
|
+
would have to call `ctx.sessionQuery.searchSessions` directly and stitch `cursor`).
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## 4. Queue: `state().queue`, `pendingInput`, `updateQueue`, prompt modes
|
|
277
|
+
|
|
278
|
+
### Signatures
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
@Remote state(request: SessionStateRequest, signal: AbortSignal): Promise<SessionState>
|
|
282
|
+
@Remote('updateQueue') updateQueue(request: SessionUpdateQueueRequest): Promise<SessionUpdateQueueValue>
|
|
283
|
+
@Remote('prompt') async prompt(request: SessionPromptRequest, signal: AbortSignal): Promise<SessionPromptValue>
|
|
284
|
+
|
|
285
|
+
interface SessionState {
|
|
286
|
+
readonly cursor: number;
|
|
287
|
+
readonly active: boolean; // false = cold/no attached Agent
|
|
288
|
+
readonly running: boolean;
|
|
289
|
+
readonly queue: readonly SessionQueuedItem[] | null; // null while inactive
|
|
290
|
+
readonly pendingInput: readonly ('approval'|'question'|'other')[];
|
|
291
|
+
}
|
|
292
|
+
interface SessionQueuedItem {
|
|
293
|
+
readonly id: MessageId;
|
|
294
|
+
readonly placement: 'queued' | 'steering' | 'context';
|
|
295
|
+
readonly rpcId?: SessionRequestId;
|
|
296
|
+
readonly content: readonly JsonValue[]; // content blocks: {type:'text',text} / image / file
|
|
297
|
+
}
|
|
298
|
+
interface SessionUpdateQueueRequest {
|
|
299
|
+
readonly sessionId: SessionId;
|
|
300
|
+
readonly itemId: MessageId;
|
|
301
|
+
readonly action: QueueAction;
|
|
302
|
+
}
|
|
303
|
+
type QueueAction =
|
|
304
|
+
| { readonly kind: 'edit'; readonly content: readonly TextBlock[] } // text blocks only, non-whitespace required
|
|
305
|
+
| { readonly kind: 'remove' }
|
|
306
|
+
| { readonly kind: 'steer' };
|
|
307
|
+
interface SessionUpdateQueueValue { readonly accepted: true }
|
|
308
|
+
interface SessionPromptRequest {
|
|
309
|
+
readonly requestId: SessionRequestId; // idempotency key (duplicate ids are ignored)
|
|
310
|
+
readonly sessionId: SessionId;
|
|
311
|
+
readonly mode: 'queue' | 'steer';
|
|
312
|
+
readonly content: readonly PromptContentPart[];
|
|
313
|
+
readonly clientTimeZone?: string;
|
|
314
|
+
}
|
|
315
|
+
interface SessionPromptValue { readonly accepted: true }
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Queue semantics (verified in `commands.js` / `state/controller.js`):
|
|
319
|
+
|
|
320
|
+
- `queue` = `[...agent.inbox.nextTurn.map(placement 'queued'), ...agent.inbox.nextStep.map(
|
|
321
|
+
source.kind==='user' ? 'steering' : 'context')]`; each carries `id`, optional `rpcId`
|
|
322
|
+
(prompt request id) and the original content blocks.
|
|
323
|
+
- **`pendingInput`** is derived from `ctx.typertGateway.getPendingRemoteEvents()` and
|
|
324
|
+
reports `'approval'` (approval/request), `'question'` (user-questions/request) or
|
|
325
|
+
`'other'`. It is *not* the queue; a running turn blocked on approval usually has
|
|
326
|
+
`pendingInput: ['approval']`.
|
|
327
|
+
- **Queue items are in-memory** until the loop claims them at the start of the next
|
|
328
|
+
turn/step. Only then do they become durable `user/message` events with
|
|
329
|
+
`surfaceOp:'append'`. Consequence: the phone’s history will not show a queued prompt
|
|
330
|
+
until it is admitted; `state().queue` is the only read.
|
|
331
|
+
- The durable trace of inbox mutations is `agent/inbox/spliced`:
|
|
332
|
+
`{ target: 'next-turn'|'next-step', start, removedCount?, inserted: Message[], outcome? }`
|
|
333
|
+
(each inserted entry is a full Message, so `id`/`content`/`source.rpcId` are recoverable).
|
|
334
|
+
Our bridge can forward these as queue-change pushes without polling `state()`.
|
|
335
|
+
- **No reorder action exists.** Only edit / remove / steer. Edit accepts **text blocks
|
|
336
|
+
only** (`content.some(b => b.type !== 'text')` → `session/attachment-invalid`
|
|
337
|
+
`QUEUE_EDIT_NON_TEXT`); empty text → `gateway/bad-request`. Edit/remove locate the item in
|
|
338
|
+
`nextTurn` or `nextStep`; not found → `session/queue-item-not-found`. Steer requires the
|
|
339
|
+
item to be in `next-turn` **and** `agent.status === 'running'`, else
|
|
340
|
+
`session/steer-unavailable`. Remove retires the prompt’s upload receipts for its `rpcId`.
|
|
341
|
+
`updateQueue` resolves a cold session first; if it cannot, `session/queue-item-not-found`.
|
|
342
|
+
- **Prompt modes:** `mode:'queue'` → `agent.followup(message)` (next-turn queue);
|
|
343
|
+
`mode:'steer'` → `agent.steer(message)` (nearest next-step injection; requires a running
|
|
344
|
+
turn — otherwise `session/agent-busy`). Duplicate `requestId` (same `rpcId` in inbox or
|
|
345
|
+
durable log) returns `{accepted:true}` without enqueueing again. `hasPromptContent` rejects
|
|
346
|
+
whitespace-only content. Image parts are admitted first (item 9).
|
|
347
|
+
|
|
348
|
+
### Gotchas
|
|
349
|
+
|
|
350
|
+
- `state()` is live-only in effect: for a cold session `queue` is `null` and `active:false`;
|
|
351
|
+
do not attempt `updateQueue` on it (it would resume/queue-fail).
|
|
352
|
+
- `queued` items have `id` values that are Message ids, **not** durable session seqs; keep
|
|
353
|
+
them as opaque ids.
|
|
354
|
+
- Queue edits do not touch the model transcript; the phone must re-read `state()` (or handle
|
|
355
|
+
our pushed `queue.changed`) after edit/remove/steer.
|
|
356
|
+
- `pendingInput` can contain `'approval'` while an approval card is pending; don’t use it as
|
|
357
|
+
a running flag (`running` is separate).
|
|
358
|
+
|
|
359
|
+
### Recommended frames
|
|
360
|
+
|
|
361
|
+
`queue.list {sessionId}` → `queue {sessionId, items:[{id, placement, rpcId?, text}], pendingInput:[...]}`
|
|
362
|
+
(server-side flatten text blocks); `queue.update {sessionId, itemId, action:{kind:'edit',text}|{kind:'remove'}|{kind:'steer'}}`;
|
|
363
|
+
push `queue.changed {sessionId, items}` from `state()` refresh and/or `agent/inbox/spliced`.
|
|
364
|
+
Extend `prompt` with `mode: 'queue'|'steer'` (default queue) and reuse `requestId`.
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
## 5. Workspace pin / archive
|
|
369
|
+
|
|
370
|
+
### Signatures (live inspect)
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
// ctx.workspaceController (dsh-api-workspace-controller)
|
|
374
|
+
@Remote('archiveSession') archiveSession(request: WorkspaceArchiveSessionRequest): Promise<WorkspaceArchiveValue>
|
|
375
|
+
@Remote('unarchiveSession') unarchiveSession(request: WorkspaceUnarchiveSessionRequest): Promise<WorkspaceArchiveValue>
|
|
376
|
+
@Remote('pinSession') pinSession(request: WorkspacePinSessionRequest): Promise<WorkspacePinValue>
|
|
377
|
+
@Remote('unpinSession') unpinSession(request: WorkspaceUnpinSessionRequest): Promise<WorkspacePinValue>
|
|
378
|
+
@Remote({mode:'stream'}) async *follow(signal): AsyncIterable<WorkspaceFollowFrame>
|
|
379
|
+
|
|
380
|
+
interface WorkspaceArchiveSessionRequest { readonly sessionId: SessionId; readonly stopActivity?: boolean }
|
|
381
|
+
interface WorkspaceArchiveValue { readonly archivedSessionIds: readonly SessionId[] }
|
|
382
|
+
interface WorkspacePinSessionRequest { readonly sessionId: SessionId }
|
|
383
|
+
interface WorkspacePinValue { readonly pinnedSessionIds: readonly SessionId[] }
|
|
384
|
+
|
|
385
|
+
type WorkspaceFollowFrame =
|
|
386
|
+
| { readonly type:'baseline'; readonly value: WorkspaceBaseline }
|
|
387
|
+
| { readonly type:'replace'; readonly value: WorkspaceBaseline }
|
|
388
|
+
| { readonly type:'upsert'; readonly workspace: WorkspaceView }
|
|
389
|
+
| { readonly type:'remove'; readonly workspaceId: WorkspaceId }
|
|
390
|
+
| { readonly type:'order'; readonly workspaceIds: readonly WorkspaceId[] }
|
|
391
|
+
| { readonly type:'archived'; readonly archivedSessionIds: readonly SessionId[] }
|
|
392
|
+
| { readonly type:'pinned'; readonly pinnedSessionIds: readonly SessionId[] };
|
|
393
|
+
|
|
394
|
+
interface WorkspaceBaseline {
|
|
395
|
+
readonly items: readonly WorkspaceView[];
|
|
396
|
+
readonly archivedSessionIds: readonly SessionId[];
|
|
397
|
+
readonly pinnedSessionIds: readonly SessionId[];
|
|
398
|
+
}
|
|
399
|
+
interface WorkspaceView {
|
|
400
|
+
readonly workspaceId: WorkspaceId; readonly path: string; // absolute host path — strip on the phone
|
|
401
|
+
readonly title: string; readonly sessionIds: readonly SessionId[];
|
|
402
|
+
readonly createdAt: string; readonly updatedAt: string;
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
Registry semantics (`dsh-workspace/lib/types/index.js`):
|
|
407
|
+
|
|
408
|
+
- Sets are **registry-global** (not per-workspace): `workspaceRegistry.archivedSessionIds`
|
|
409
|
+
and `workspaceRegistry.pinnedSessionIds` getters expose them to Host plugins directly
|
|
410
|
+
(no Remote call needed; no signal).
|
|
411
|
+
- **Archive**: session must exist live **or in persistence** (else `WorkspaceUnknownSessionError`);
|
|
412
|
+
without `stopActivity`, the `workspace/session-activity` waterfall is asked and any reported
|
|
413
|
+
activity rejects with `WorkspaceActiveSessionError`; with `stopActivity:true` the archive is
|
|
414
|
+
written first and `workspace/session-stop` providers then stop work (agent turn, jobs,
|
|
415
|
+
subagents, schedules); archiving **drops the pin** in the same write (mutually exclusive);
|
|
416
|
+
already archived = no-op. Workspace accounting (`sessionIds` order) is untouched, so
|
|
417
|
+
unarchiving restores position. Unarchive never checks existence; not archived = no-op.
|
|
418
|
+
- **Pin**: session must exist and **must not be archived** (else
|
|
419
|
+
`WorkspaceArchivedSessionPinError`); prepends to the pin list (most recent first); already
|
|
420
|
+
pinned = no-op.
|
|
421
|
+
- Archive gate: an archived session (and subagent descendants) cannot run a model step —
|
|
422
|
+
the controller plugin listens on `agent/pre-step` and rejects; the turn ends `blocked`
|
|
423
|
+
without a model request. **Unarchiving lifts the gate for the whole lineage.** Therefore a
|
|
424
|
+
prompt sent to an archived session is accepted into the queue but never runs; the phone
|
|
425
|
+
should disable send when archived (or auto-unarchive).
|
|
426
|
+
|
|
427
|
+
### Do archived sessions disappear from `sessionController.list()`?
|
|
428
|
+
|
|
429
|
+
**No.** `list()` = `ctx.sessionQuery.listSessions()` (all live + persisted) filtered only by
|
|
430
|
+
`remoteAccess.allows()`; there is no archive filter in the controller or session query.
|
|
431
|
+
The desktop hides archived rows client-side from `WorkspaceBaseline.archivedSessionIds`.
|
|
432
|
+
The phone bridge must apply the same filter, from:
|
|
433
|
+
- `ctx.workspaceRegistry.archivedSessionIds` / `.pinnedSessionIds` (Host-contract getters,
|
|
434
|
+
cheapest, synchronous), or
|
|
435
|
+
- `ctx.workspaceController.follow(signal)` frames (baseline + `archived`/`pinned` increments).
|
|
436
|
+
|
|
437
|
+
`WorkspaceView.path` is an absolute host filesystem path: **never send it to the phone**
|
|
438
|
+
(v1 rule). The `title` is safe.
|
|
439
|
+
|
|
440
|
+
### Gotchas
|
|
441
|
+
|
|
442
|
+
- No `signal` parameter on the four mutations; they are serialized internally
|
|
443
|
+
(`enqueueOperation`) against other registry writes.
|
|
444
|
+
- `stopActivity` is destructive: it stops a running turn/job. Never default it on the phone
|
|
445
|
+
without a confirm.
|
|
446
|
+
- If the deployment mounts no workspace controller/registry (workspace feature disabled),
|
|
447
|
+
archive/pin are unavailable; the bridge must degrade (report `archived:false`,
|
|
448
|
+
`pinned:false`, hide controls).
|
|
449
|
+
- Archiving also affects workspace grouping in the desktop sidebar; the phone only needs
|
|
450
|
+
the flags.
|
|
451
|
+
- Pinning and archiving are mutually exclusive; an archive silently unpins.
|
|
452
|
+
|
|
453
|
+
### Recommended frames
|
|
454
|
+
|
|
455
|
+
Add to `sessions` / session object: `pinned:boolean`, `archived:boolean` (from registry
|
|
456
|
+
sets). Add `workspace.state` (baseline sets) and `session.pin|unpin|archive|unarchive`
|
|
457
|
+
commands mirrored to all devices, echoing the returned id arrays. Keep paths server-side.
|
|
458
|
+
|
|
459
|
+
---
|
|
460
|
+
|
|
461
|
+
## 6. `workspaceChanges.summary` / `diff`
|
|
462
|
+
|
|
463
|
+
### Signatures (live inspect + catalog)
|
|
464
|
+
|
|
465
|
+
```ts
|
|
466
|
+
// ctx.workspaceChanges (dsh-workspace-changes)
|
|
467
|
+
summary(sessionId: SessionId, seq: number): WorkspaceChangesSummary | undefined
|
|
468
|
+
diff(sessionId: SessionId, seq: number, index: number, signal: AbortSignal): Promise<WorkspaceFileDiff | undefined>
|
|
469
|
+
|
|
470
|
+
interface WorkspaceChangesSummary {
|
|
471
|
+
turn: number;
|
|
472
|
+
cwd: string; // absolute — strip on the phone
|
|
473
|
+
files: WorkspaceChangedFile[]; // kept files (<= maxFiles)
|
|
474
|
+
total: number; // full changed count before the maxFiles cap
|
|
475
|
+
added: number; deleted: number;
|
|
476
|
+
snapshot?: { before: string; after: string }; // opaque snapshot ids, omit from phone
|
|
477
|
+
}
|
|
478
|
+
interface WorkspaceChangedFile {
|
|
479
|
+
path: string; // relative inside cwd, absolute elsewhere — strip/display
|
|
480
|
+
display: string; // slash path, may be `~/...`; safe-ish but may reveal home
|
|
481
|
+
added: number; deleted: number; binary?: true; oversized?: true;
|
|
482
|
+
}
|
|
483
|
+
type WorkspaceFileDiff =
|
|
484
|
+
| { kind:'text'; path; display; before: boolean; after: boolean;
|
|
485
|
+
hunks: { oldStart:number; oldLines:number; newStart:number; newLines:number; lines:string[] }[];
|
|
486
|
+
coarse: boolean }
|
|
487
|
+
| { kind:'binary'; path; display }
|
|
488
|
+
| { kind:'oversized'; path; display };
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### Semantics
|
|
492
|
+
|
|
493
|
+
- `seq` is the **Session event sequence of the `workspace/changes` event**, not a turn or
|
|
494
|
+
file index. The event itself carries only `{turn}`; the summary is held in Host memory by
|
|
495
|
+
the recorder, keyed by that seq. The client discovers seqs by scanning session history for
|
|
496
|
+
`workspace/changes` events (desktop deliverables UI does exactly this: `changesSummaryUrl(
|
|
497
|
+
sessionId, seq)`).
|
|
498
|
+
- `index` is the **original index in `summary.files`** (the array after the `maxFiles` cap).
|
|
499
|
+
Any file in the capped array works; out-of-range or unknown seq → `undefined`.
|
|
500
|
+
- **Live-process only:** the recorder exists for **live Sessions of this Host process**;
|
|
501
|
+
`session/disposed` deletes its record (`forget`). A cold session, or a session this Host
|
|
502
|
+
never recorded (e.g. another process wrote the event), returns `undefined`. The durable
|
|
503
|
+
event survives but the summary does not.
|
|
504
|
+
- `diff` returns a refusal-kind record (`kind:'binary'` / `kind:'oversized'`) instead of
|
|
505
|
+
hunks for uncomparable files; `kind:'text'` carries unified-style hunks whose `lines[]`
|
|
506
|
+
entries are `+added`, `-deleted`, or context lines (no `@@` headers). `coarse:true` means
|
|
507
|
+
the line diff exceeded `diffTimeoutMs` and one whole-file hunk was produced.
|
|
508
|
+
- Limits (defaults in `dsh-workspace-changes` Config — deployment may override):
|
|
509
|
+
`timeoutMs 30000`, `outputMaxBytes 8 MiB`, `maxFiles 500`, `maxFileBytes 2 MiB`,
|
|
510
|
+
`diffTimeoutMs 100`.
|
|
511
|
+
- `summary` is synchronous; `diff` is async and **throws** when a snapshot read fails while
|
|
512
|
+
the recorder lives. Both return `undefined` for unknown coordinates.
|
|
513
|
+
- No pagination; a summary is bounded by `maxFiles`/`maxFileBytes`, a diff by these caps +
|
|
514
|
+
the coarse fallback.
|
|
515
|
+
|
|
516
|
+
### Recommended frames
|
|
517
|
+
|
|
518
|
+
`changes.list {sessionId, limit}` → `{items:[{seq, turn, total, added, deleted, files:[{display,path?,added,deleted,binary?,oversized?}]}]}`
|
|
519
|
+
(derive seq/turn from history `workspace/changes` events; keep `cwd` server-side).
|
|
520
|
+
`changes.diff {sessionId, seq, index}` → `{kind, display, hunks|reason, coarse}`. Cache
|
|
521
|
+
per (session,seq) and evict on session dispose. Expect `undefined` for cold sessions — show
|
|
522
|
+
“diff unavailable (session not live)”.
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
## 7. Token meter / context pressure
|
|
527
|
+
|
|
528
|
+
### Signatures (live inspect + catalog)
|
|
529
|
+
|
|
530
|
+
```ts
|
|
531
|
+
// ctx.tokenMeter
|
|
532
|
+
contextPressure(session: Session): Pick<ContextPressureProjection, 'pressureTokens' | 'contextWindow'>
|
|
533
|
+
measure(session: Session, requestHeader?: EpochHeader): TokenMeasurement
|
|
534
|
+
estimateMessage(message: Message): number
|
|
535
|
+
|
|
536
|
+
interface ContextPressureProjection { pressureTokens?: number; projectedTokens?: number; contextWindow?: number }
|
|
537
|
+
interface TokenMeasurement {
|
|
538
|
+
readonly logRevision: SessionLogOffset;
|
|
539
|
+
readonly baseline: { kind:'none'; tokens:0 }
|
|
540
|
+
| { kind:'estimated'; tokens:number }
|
|
541
|
+
| { kind:'usage'; tokens:number; usage: Readonly<TokenUsage> };
|
|
542
|
+
readonly surfaceDeltaTokens: number;
|
|
543
|
+
readonly totalTokens: number;
|
|
544
|
+
readonly surfaceTokens: number;
|
|
545
|
+
readonly nodes: readonly { seq: SessionSeq; tokens: number; heuristicTokens: number }[];
|
|
546
|
+
}
|
|
547
|
+
interface TokenUsage { inputTokens; outputTokens; totalTokens?; cacheReadTokens?; cacheWriteTokens?; reasoningTokens?: number }
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
### How to obtain the `Session` object it needs
|
|
551
|
+
|
|
552
|
+
- `sessionController`/`sessionQuery` expose **no** cold `Session` object. `tokenMeter.*`
|
|
553
|
+
takes a live in-memory `Session`:
|
|
554
|
+
- `ctx.sessions.get(sessionId)` (attached only), or
|
|
555
|
+
- `ctx.agents.get(sessionId)?.session` (live Agent), or resume first with
|
|
556
|
+
`ctx.sessionController.resolveAgent(sessionId)` and use `result.agent.session`.
|
|
557
|
+
- `ctx.sessions.prepare(id, options)` exists but is an internal persistence primitive
|
|
558
|
+
(creates an unprepared Session); **not recommended** for cold reads — **UNVERIFIED**.
|
|
559
|
+
- **Cold-safe alternative:** the `contextPressure` projection has a wire view
|
|
560
|
+
(`usage-projection.js`), `summary:false`:
|
|
561
|
+
`sessionController.projections({sessionId})` → `values.contextPressure =
|
|
562
|
+
{ contextWindow?, pressureTokens?, projectedTokens? }`. The projection fold runs from the
|
|
563
|
+
session log (`projectionMode:'all'`), so it works for cold sessions without activation.
|
|
564
|
+
Semantics: `pressureTokens` = provider prompt-side tokens from the latest usage sample;
|
|
565
|
+
`contextWindow` = latest `request/context.contextWindow`;
|
|
566
|
+
`projectedTokens = max(0, pressureTokens + surfaceTokens - sampledSurfaceTokens)`.
|
|
567
|
+
|
|
568
|
+
### Is `measure` suitable for a phone meter?
|
|
569
|
+
|
|
570
|
+
- Yes, for live sessions: `totalTokens` (baseline + surface delta) vs `contextPressure().contextWindow`
|
|
571
|
+
is exactly a used/limit meter; `baseline.kind` tells you whether the number is provider
|
|
572
|
+
usage (`'usage'`) or an estimator (`'estimated'`/`'none'`) — display it honestly.
|
|
573
|
+
- `measure` is heavier (walks the current surface nodes), and the second argument is an
|
|
574
|
+
optional `EpochHeader` to price against a specific request configuration. For a phone
|
|
575
|
+
status line, prefer the projections:
|
|
576
|
+
- used: `contextPressure.projectedTokens ?? pressureTokens ?? 0`
|
|
577
|
+
- limit: `contextPressure.contextWindow`
|
|
578
|
+
- cumulative spend buckets: `values.tokenUsage` (projection wire view returns
|
|
579
|
+
`state.totals`, TokenUsage-like buckets) — useful for “tokens used this session”, but
|
|
580
|
+
it is provider usage, not a limit.
|
|
581
|
+
- **`tokenMeasurement` projection is Host-only** (no wire view); `measure()` is the only
|
|
582
|
+
way to get per-node detail.
|
|
583
|
+
|
|
584
|
+
### Gotchas
|
|
585
|
+
|
|
586
|
+
- `pressureTokens` is **prompt-side only** and advances only when the next request reports
|
|
587
|
+
usage; it does not move during a streaming turn. A “context full” meter should use
|
|
588
|
+
`projectedTokens`.
|
|
589
|
+
- Cold sessions: no `measure`, but projections work; if the projection cache/log lacks
|
|
590
|
+
`request/context` (e.g. never ran a turn) fields are absent — display “unknown”, not 0.
|
|
591
|
+
- Resuming a cold session (`resolveAgent`) just to read the meter is expensive (loads the
|
|
592
|
+
Agent/preset); use projections instead.
|
|
593
|
+
|
|
594
|
+
### Recommended frames
|
|
595
|
+
|
|
596
|
+
`context.get {sessionId}` → `{pressureTokens?, projectedTokens?, contextWindow?, basis:'usage'|'estimated'|'unknown', tokenUsage?:{input,output,cacheRead?,cacheWrite?,reasoning?}}`.
|
|
597
|
+
Push `context.changed {sessionId, ...}` after `turn/end`, `assistant/message` and
|
|
598
|
+
`request/context` events (or poll on demand). SPA renders a ratio bar + “estimated” badge.
|
|
599
|
+
|
|
600
|
+
---
|
|
601
|
+
|
|
602
|
+
## 8. `commands.list` / `commands.execute`
|
|
603
|
+
|
|
604
|
+
### Signatures (live inspect + catalog)
|
|
605
|
+
|
|
606
|
+
```ts
|
|
607
|
+
// ctx.commands (dsh-commands)
|
|
608
|
+
@Remote list(agent: Agent): readonly CommandDescriptor[]
|
|
609
|
+
find(agent: Agent, name: string): CommandDefinition | undefined
|
|
610
|
+
@Remote async execute(
|
|
611
|
+
agent: Agent, line: string, submittedAttachments: readonly CommandSubmitAttachment[], signal: AbortSignal,
|
|
612
|
+
): Promise<CommandExecution | undefined>
|
|
613
|
+
|
|
614
|
+
interface CommandDescriptor { definitionId?: CommandDefinitionId; name: string; description: string;
|
|
615
|
+
input?: { hint: string; attachments?: boolean } }
|
|
616
|
+
interface CommandExecution { commandId: CommandId; result: CommandResult }
|
|
617
|
+
type CommandResult = { kind:'success'; text?: string; sourceEventSeq?: SessionSeq }
|
|
618
|
+
| { kind:'error'; text: string }
|
|
619
|
+
type CommandSubmitAttachment = ({ type:'image' } & { mediaType: ImageMediaType; data: string; name?: string })
|
|
620
|
+
| { type:'file'; receiptId: string };
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
### Requirements and safety
|
|
624
|
+
|
|
625
|
+
- **Requires a live Agent.** Both methods take an `Agent` and resolve commands through the
|
|
626
|
+
Agent’s scoped Cordis layers (`view(agent)`), so the Agent must be in the registry; typert’s
|
|
627
|
+
`agent` lookup is `ctx.agents.get(id)` and does **not** resume. For a cold session, the
|
|
628
|
+
bridge must `resolveAgent(sessionId)` first (this activates the session) and then call
|
|
629
|
+
`commands.list(agent)`/`execute(agent, …)`. There is no cold command listing.
|
|
630
|
+
- **No Host-side safety/remote flag.** `CommandDescriptor` has only name/description/input.
|
|
631
|
+
Commands are registered globally or per-Agent scope; the desktop’s command palette uses
|
|
632
|
+
the same list. The installed build registers e.g. `compact` (“Compact older conversation
|
|
633
|
+
history”, `dsh-command-compact`) plus preset/agent-scoped commands and client-side
|
|
634
|
+
consumer commands. Some are destructive to context; **the phone must ship an allowlist**
|
|
635
|
+
(recommend v2: list-only + `compact` behind a confirm, or omit commands entirely until a
|
|
636
|
+
curation decision).
|
|
637
|
+
- **Execution results map back into the session as durable events**, not as model messages:
|
|
638
|
+
- `command/run` `{ commandId, name, args?, source:{kind:'user'} }` appended before the
|
|
639
|
+
handler; `args` is the raw input after the command name unless `recordInput === false`.
|
|
640
|
+
- `command/done` `{ commandId, kind:'success'|'error', text?, sourceEventSeq? }` appended
|
|
641
|
+
after settlement (thrown/aborted handler → `kind:'error'`).
|
|
642
|
+
- Both are **log-only** appends: no turn wraps them, they are not on the message surface.
|
|
643
|
+
The phone history should render them as new `command` items (or `system`), pairing by
|
|
644
|
+
`commandId`; `sourceEventSeq` points at a produced event (e.g. compaction checkpoint) and
|
|
645
|
+
is metadata, not a message.
|
|
646
|
+
- Admission misses (malformed line, unknown name) return `undefined` and log nothing;
|
|
647
|
+
the composer shows an immediate error. Handler errors become `CommandResult{kind:'error'}`.
|
|
648
|
+
- Attachment admission is enforced inside `execute` before the handler: attachments only if
|
|
649
|
+
`input.attachments === true`, absent attachment store → error result, image limits →
|
|
650
|
+
error result (`CommandResult`, not a throw). `signal.aborted` before dispatch throws.
|
|
651
|
+
- Proposed-but-unrun lines do not enter model context.
|
|
652
|
+
|
|
653
|
+
### Gotchas
|
|
654
|
+
|
|
655
|
+
- The `Agent` parameter comes from the Remote lookup; a **Host plugin** should call
|
|
656
|
+
`ctx.commands.list(agent)` directly with a resolved live agent (same object identity
|
|
657
|
+
matters for scoped layering: use `ctx.agents.get(id)` after `resolveAgent`).
|
|
658
|
+
- Executing a command may itself run a compaction that rewrites the surface; treat history
|
|
659
|
+
as stale and refresh after `command/done`.
|
|
660
|
+
- `commands.list` output differs per Agent scope/preset — not a global catalog.
|
|
661
|
+
|
|
662
|
+
### Recommended frames
|
|
663
|
+
|
|
664
|
+
`commands.list {sessionId}` → `commands {items:[{name,description,hint?,attachments?}], available:boolean}`
|
|
665
|
+
(filtered by the bridge allowlist; `available:false` when the session is cold and resume is
|
|
666
|
+
not desired). `commands.execute {sessionId,line,requestId?}` → `command.result
|
|
667
|
+
{commandId,name,kind,text?,sourceEventSeq?}`; push `command.started/done` frames from the
|
|
668
|
+
`command/run`/`command/done` session events. Add `command` HistoryItem kind (`id:
|
|
669
|
+
command:<commandId>`) so reloads render the same flow node.
|
|
670
|
+
|
|
671
|
+
---
|
|
672
|
+
|
|
673
|
+
## 9. Attachments and the image path
|
|
674
|
+
|
|
675
|
+
### Exact content-part shapes
|
|
676
|
+
|
|
677
|
+
```ts
|
|
678
|
+
// Browser-safe prompt part (dsh-cordis-client-runner PromptContentPart):
|
|
679
|
+
type PromptContentPart =
|
|
680
|
+
| { readonly type:'text'; readonly text:string }
|
|
681
|
+
| { readonly type:'image'; readonly mediaType: 'image/png'|'image/jpeg'|'image/webp'|'image/gif';
|
|
682
|
+
readonly data: string /* canonical base64 */; readonly name?: string }
|
|
683
|
+
| { readonly type:'file'; readonly receiptId: string };
|
|
684
|
+
|
|
685
|
+
// Admitted/durable content (AdmittedPromptContentPart):
|
|
686
|
+
| { type:'text'; text }
|
|
687
|
+
| { type:'image'; attachment: ImageAttachmentRef }
|
|
688
|
+
| { type:'file'; attachment: FileAttachmentRef }
|
|
689
|
+
|
|
690
|
+
interface ImageAttachmentRef {
|
|
691
|
+
attachmentId: AttachmentId; // content-addressed `sha256:<hex>`; never a path/URL
|
|
692
|
+
mediaType: ImageMediaType; bytes: number; width: number; height: number;
|
|
693
|
+
name?: string; originalDimensions?: { width:number; height:number };
|
|
694
|
+
}
|
|
695
|
+
interface ImageBlock { type:'image'; attachment: ImageAttachmentRef; offloaded?: true }
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
`sessionController.prompt` runs: `resolvePromptFileReceipts(content)` (turns `{type:'file',
|
|
699
|
+
receiptId}` into the staged attachment — which may be an image) → `attachments.admitPromptContent`
|
|
700
|
+
(encodes/admits encoded image parts and passes stored images through) → `createUserMessage`
|
|
701
|
+
→ image-capability check against the current model. So **both** of these work:
|
|
702
|
+
|
|
703
|
+
1. **Inline encoded image (no pre-upload):**
|
|
704
|
+
`{type:'image', mediaType, data: <canonical base64>, name?}` in `prompt.content` — the
|
|
705
|
+
attachment store saves it (`admitEncodedImages`), returns a durable `ImageAttachmentRef`,
|
|
706
|
+
and the message contains an `ImageBlock`.
|
|
707
|
+
2. **Staged upload receipt (desktop-style, streams bytes to the Host):**
|
|
708
|
+
`ctx.fileUploads.uploadImageStream({ sessionId, data: AsyncIterable<Uint8Array>, mediaType, signal?, name? })`
|
|
709
|
+
→ `{ receiptId, image: ImageAttachmentRef }`; then `prompt.content` contains
|
|
710
|
+
`{type:'file', receiptId}`. The controller replaces it with the staged image; `bindPrompt`
|
|
711
|
+
pins the receipt to the `requestId` until the accepted `user/message` (matching
|
|
712
|
+
`source.rpcId`) is observed, then the receipt is retired. Unknown/foreign/expired receipt
|
|
713
|
+
→ `session/attachment-invalid` (`FILE_NOT_STAGED`).
|
|
714
|
+
For files use `uploadStream` (same shape) or `ctx.fileUploads.upload(agent, {data:
|
|
715
|
+
canonicalBase64, name?})` (Remote variant).
|
|
716
|
+
|
|
717
|
+
`saveImage({data:Uint8Array, mediaType, name?})` stores directly without a receipt and
|
|
718
|
+
returns an `ImageAttachmentRef`; a stored-image part (`{type:'image', attachment, encodedBytes}`
|
|
719
|
+
in the admission type) also passes through. Use receipts or inline base64 for prompts;
|
|
720
|
+
`saveImage` is useful when you already hold bytes and want a ref before composing content.
|
|
721
|
+
|
|
722
|
+
### Limits
|
|
723
|
+
|
|
724
|
+
`ctx.attachments.imageLimits` (`ImageAttachmentLimits`):
|
|
725
|
+
|
|
726
|
+
```ts
|
|
727
|
+
{ maxImageBytes, maxImagesPerMessage, maxMessageImageBytes, maxImagePixels, maxImageDimension,
|
|
728
|
+
mediaTypes: readonly ImageMediaType[] }
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
- `maxImagesPerMessage` default **20**; `maxImageBytes` default **52_428_800 (50 MiB)**;
|
|
732
|
+
other defaults are constants in `dsh-attachment-local` that were not resolved here
|
|
733
|
+
(**UNVERIFIED** — read the live object at runtime). `mediaTypes` is deployment-filtered;
|
|
734
|
+
declaring an unsupported type → `session/attachment-invalid` `UNSUPPORTED_IMAGE_TYPE`.
|
|
735
|
+
- `uploadImageStream` reads at most `min(maxImageBytes, maxMessageImageBytes)` and fails with
|
|
736
|
+
`IMAGE_TOO_LARGE`; admission validates count/aggregate bytes (`TOO_MANY_IMAGES`,
|
|
737
|
+
`IMAGES_TOO_LARGE`), detects the real media type (`IMAGE_TYPE_MISMATCH`), enforces
|
|
738
|
+
pixel/dimension limits, and normalizes (downscales) before storing; `originalDimensions`
|
|
739
|
+
records a downscale.
|
|
740
|
+
- Cold-safe way to read limits: `sessionController.projections({sessionId})` →
|
|
741
|
+
`values.imageLimits` (projection wire view is `summary:false`, so it is absent from list
|
|
742
|
+
rows but present in full projections).
|
|
743
|
+
|
|
744
|
+
### Reading an image back for a phone preview
|
|
745
|
+
|
|
746
|
+
- `sessionController.attachment({ sessionId, attachment: ImageAttachmentRef })` →
|
|
747
|
+
`{ attachment, data: <base64> }` (does not check session existence; reads the store).
|
|
748
|
+
- `ctx.attachments.readImage(ref, signal)` → `StoredImageAttachment { ref, data: Uint8Array }`
|
|
749
|
+
(Host-path convenience). `readImageRequest(ref, target, signal)` derives provider-request
|
|
750
|
+
images (not needed for a UI preview).
|
|
751
|
+
- Sources of refs for the SPA: durable message content blocks (`user/message`,
|
|
752
|
+
`assistant/message`) contain `ImageBlock` with `attachment`; v2 history mapping should
|
|
753
|
+
emit `attachments:[{attachmentId,mediaType,bytes,width,height,name?}]` instead of trying to
|
|
754
|
+
inline bytes. Preview = `attachment.get {attachmentId}` → base64 (cache client-side by id,
|
|
755
|
+
content-addressed and immutable).
|
|
756
|
+
|
|
757
|
+
### Recommended changes to our bridge
|
|
758
|
+
|
|
759
|
+
- Replace the v1 “append file paths as text” behaviour with content parts.
|
|
760
|
+
- `prompt` request extension: `content` parts `[{type:'text',text},{type:'image',mediaType,data}]`
|
|
761
|
+
or a two-step `upload.image` frame that returns `{receiptId, image}` then a prompt with
|
|
762
|
+
`{type:'file',receiptId}`. Inline base64 is simpler for a phone (no receipt lifecycle), but
|
|
763
|
+
costs ~33% payload; prefer streaming upload for photos and inline for small screenshots.
|
|
764
|
+
- `history` items gain `attachments[]`; `attachment.get` returns base64 with a size cap.
|
|
765
|
+
- `image.limits` frame for the SPA picker (from projections or `ctx.attachments.imageLimits`).
|
|
766
|
+
- Check `llm.resolveModelInfo(provider, model).inputModalities.includes('image')` before
|
|
767
|
+
showing the photo button; otherwise the prompt fails with `session/attachment-invalid`.
|
|
768
|
+
|
|
769
|
+
**UNVERIFIED:** which of inline-base64 vs staged-receipt the current desktop chat composer
|
|
770
|
+
uses end-to-end (the bundled client uploads via the Host streaming route and returns
|
|
771
|
+
`receiptId`; the exact prompt-content assembly is inside a bundled client module and was not
|
|
772
|
+
traced). Both shapes are accepted by the Host runtime; probe once with a real session.
|
|
773
|
+
|
|
774
|
+
---
|
|
775
|
+
|
|
776
|
+
## 10. `approval/request` payload, outcomes, policy
|
|
777
|
+
|
|
778
|
+
### Payload
|
|
779
|
+
|
|
780
|
+
```ts
|
|
781
|
+
interface ApprovalRequestEvent {
|
|
782
|
+
readonly agent: Agent;
|
|
783
|
+
readonly toolName: string;
|
|
784
|
+
readonly callId?: ToolCallId;
|
|
785
|
+
readonly reason?: string; // model-facing explanation
|
|
786
|
+
readonly displayReason?: { readonly en: string; readonly [locale: string]: string }; // localized UI text
|
|
787
|
+
readonly signal?: AbortSignal;
|
|
788
|
+
}
|
|
789
|
+
type ApprovalOutcome = 'allowed-once' | 'rejected' | 'cancelled' | 'unavailable';
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
- **No tool arguments / command text / diff preview.** The waterfall payload carries only
|
|
793
|
+
tool name, optional call id, reason, localized display reason and the abort signal.
|
|
794
|
+
`dsh-tools/lib/pipeline.js` builds it as `{agent, toolName, callId, reason?, displayReason?,
|
|
795
|
+
signal}` from a tool’s `PreToolDecision.ask`. `displayReason` is a localization map (pick
|
|
796
|
+
`en` on the phone) supplied by the asking tool (e.g. the sandbox escalation wording).
|
|
797
|
+
- **To enrich an approval card**, correlate `callId` with the durable `tool/call` event
|
|
798
|
+
(`data.arguments` is the raw JSON string) — either from our live `onTool` cache (v1 already
|
|
799
|
+
keeps `toolStarts`) or by scanning the recent history page. The arguments may contain the
|
|
800
|
+
command/path; `reason`/`displayReason` are the only model/UI text the Host supplies.
|
|
801
|
+
Diff previews are impossible at ask time (the tool has not run); only the tool’s args.
|
|
802
|
+
- The service appends a durable audit pair: `approval/asked` `{id, toolName, callId?, reason?}`
|
|
803
|
+
and `approval/decided` `{id, outcome}` (turn-enclosed). The `id` is generated inside
|
|
804
|
+
`ApprovalService.request` and is **not** in the waterfall payload; our bridge-owned
|
|
805
|
+
`requestId` remains necessary. The pair can be observed via `session/event` if an audit id
|
|
806
|
+
is wanted.
|
|
807
|
+
- A request outside an open turn throws (the service requires `turnOpen`); a missing answerer
|
|
808
|
+
fails closed with `'unavailable'`; a throwing answerer is contained to `'unavailable'`;
|
|
809
|
+
rogue returns are normalized to `'unavailable'`.
|
|
810
|
+
|
|
811
|
+
### Outcomes / “always allow”
|
|
812
|
+
|
|
813
|
+
- Exactly four outcomes; **`allowed-once` is the only grant**. There is **no
|
|
814
|
+
allow-for-session / always-allow outcome**, no persistent grant and no “remember” API.
|
|
815
|
+
- `ApprovalPolicy = 'ask' | 'never'` only. `approval.setPolicy(agent, policy)` requires a
|
|
816
|
+
**live** Agent, appends durable `approval/policy` and injects a model-visible notice
|
|
817
|
+
(`user/message` with `source.kind:'user-approval'`); `overrideOf(session)` returns the
|
|
818
|
+
session’s logged policy or `undefined`; effective policy = `overrideOf ?? config.policy ??
|
|
819
|
+
'ask'`; `approvalState` projection = `{policy, turnOpen}`. `'never'` auto-rejects **before**
|
|
820
|
+
any answerer runs — it is the opposite of an allow-always switch. Do **not** offer “always
|
|
821
|
+
allow” on the phone in v2; only allow-once / reject. `setPolicy` should only be exposed (if
|
|
822
|
+
at all) as an explicit, clearly labelled security setting on the desktop.
|
|
823
|
+
- Approval routing in v15 is **exclusive to the connected phone**: when a phone client is
|
|
824
|
+
connected the bridge answers the waterfall and does not call `next()`; with no phone it
|
|
825
|
+
delegates to the desktop answerer. Earlier v1 builds raced `next()` concurrently, which
|
|
826
|
+
left a duplicate desktop prompt behind when the phone answered first; that design was
|
|
827
|
+
replaced once the plugin-rendered desktop dock could answer from the same pending list.
|
|
828
|
+
Signal abort → `'cancelled'`; no expiry; first answer wins.
|
|
829
|
+
|
|
830
|
+
### Recommended frames
|
|
831
|
+
|
|
832
|
+
Keep `approval.request`; add optional `argsPreview` / `args` (bounded/sanitized) and an
|
|
833
|
+
`audit` id if the phone needs it. Show `displayReason` (localized) as the card body and
|
|
834
|
+
`reason` as secondary text. Do not add allow-always. Push `approval.resolved` for every
|
|
835
|
+
decision (phone or desktop) with `by: 'phone' | 'desktop'` so the other surface clears its
|
|
836
|
+
card; the bridge implements this via the answering-origin map.
|
|
837
|
+
|
|
838
|
+
---
|
|
839
|
+
|
|
840
|
+
## 11. Subagents / Agent Teams (low priority quick note)
|
|
841
|
+
|
|
842
|
+
```ts
|
|
843
|
+
// ctx.subagents (dsh-subagent) — cold-safe reads
|
|
844
|
+
listChildren(parentSessionId: SessionId, signal?: AbortSignal): Promise<SubagentCatalogEntry[]>
|
|
845
|
+
listDescendants(rootSessionId: SessionId, signal?: AbortSignal): Promise<(SubagentCatalogEntry & {parentId; depth})[]>
|
|
846
|
+
|
|
847
|
+
type SubagentCatalogEntry = { id: SessionId; createdAt: number; label?: string } &
|
|
848
|
+
({ mode:'one-shot'; label? } | { mode:'external'; label? } | { mode:'continuable'; label:string } | { mode:'unknown'; label? })
|
|
849
|
+
|
|
850
|
+
// ctx.agentTeams (dsh-experimental-agent-team) — live Agent required
|
|
851
|
+
membership(agent): TeamMembership; listMembers(agent): TeamMemberView[];
|
|
852
|
+
listTasks(caller): TeamTaskView[]; getTask(caller,id); waitForChange(caller,timeoutMs,signal)
|
|
853
|
+
spawnTeammate/sendMessage/createTask/updateTask/interrupt (writes; do not expose on the phone in v2)
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
- `subagents.listChildren` reads the parent’s `subagentCatalog` projection via
|
|
857
|
+
`sessionQuery.observeSession` — **cold-safe**, no Agent resume, but requires the
|
|
858
|
+
`sessionQuery` service and the registered projection (else `SubagentError
|
|
859
|
+
SUBAGENT_CONTROL_QUERY_UNAVAILABLE` / `SUBAGENT_CONTROL_PROJECTIONS_UNAVAILABLE`).
|
|
860
|
+
`listDescendants` walks catalogs with parent/depth and branch diagnostics.
|
|
861
|
+
- `agentTeams.*` takes an **exact live Agent** as the authority credential (Lead or teammate)
|
|
862
|
+
— no cold path; `membership(agent)` throws for a non-member. Read-only phone view (members
|
|
863
|
+
+ tasks) is feasible for a live lead session by resolving it first; writes (spawn/send/
|
|
864
|
+
interrupt/updateTask) are consequential and should stay desktop-only.
|
|
865
|
+
- `TeamMemberView`: `{id,name,role:'lead'|'teammate',status:'running'|'inactive'|'provisioning'|'failed',
|
|
866
|
+
description?,provider?,context?:'fresh'|'fork',model?,diagnostics:string[]}`.
|
|
867
|
+
`TeamTaskView`: `{id,revision,subject,description,status,blockedBy,writeScopes,ownerName?,ready,writeScopeWarnings}`.
|
|
868
|
+
- **Feature verdict:** a phone “teammates/tasks” read-only tab is feasible (poll
|
|
869
|
+
`agentTeams.listMembers/listTasks` while the lead is live, plus `subagents.listChildren` for
|
|
870
|
+
child sessions). Real-time push needs `waitForChange` (10 min max per call) or team
|
|
871
|
+
projections; defer to v3. No blocker, low value.
|
|
872
|
+
|
|
873
|
+
---
|
|
874
|
+
|
|
875
|
+
## Ranked risks (5 riskiest unknowns)
|
|
876
|
+
|
|
877
|
+
1. **Live-vs-cold capability split is pervasive.** `commands.*`, `tokenMeter.measure/
|
|
878
|
+
contextPressure`, `approval.setPolicy`, `agentTeams.*`, `workspaceChanges.summary/diff`
|
|
879
|
+
all need a live Agent/in-memory Session/recorder; only list/search/events/projections/
|
|
880
|
+
subagents are cold-safe. If the SPA assumes uniform availability it will show dead
|
|
881
|
+
controls and confusing errors. Mitigation: add `agentAvailable` to sessions and hide
|
|
882
|
+
live-only actions; use projections for the context meter.
|
|
883
|
+
2. **Image prompt shape is not yet end-to-end verified.** Inline `{type:'image', mediaType,
|
|
884
|
+
data(base64)}` and staged `{type:'file', receiptId}` are both accepted by the runtime
|
|
885
|
+
(code-verified), but which one the desktop chat uses and what the Typert Remote schema
|
|
886
|
+
accepts from our own bridge calls for `prompt.content` is **UNVERIFIED**. Probe with one
|
|
887
|
+
real image before shipping; plan a receipt fallback if inline base64 is rejected.
|
|
888
|
+
3. **Archived sessions still appear in `sessionController.list()`.** Archive state lives in
|
|
889
|
+
the workspace registry (`archivedSessionIds`/`pinnedSessionIds`) and is broadcast only via
|
|
890
|
+
`workspaceController.follow`; our bridge must read the registry getters (or follow) and
|
|
891
|
+
filter. If the deployment disables the workspace feature, archive/pin and the
|
|
892
|
+
filter are unavailable — degrade explicitly. Also, prompting an archived session queues
|
|
893
|
+
then ends `blocked` (no error), so the phone needs an “archived — unarchive first” guard.
|
|
894
|
+
4. **Commands are unguarded and some are destructive.** There is no Host “remote-safe” flag;
|
|
895
|
+
executing `/compact` (or preset-scoped commands) from a phone can rewrite context. Ship an
|
|
896
|
+
explicit allowlist (or don't ship command execution in v2) and require live-session
|
|
897
|
+
activation.
|
|
898
|
+
5. **Approval cards cannot show args/diff from the payload, and there is no allow-always.**
|
|
899
|
+
Enrichment depends on correlating `callId` with `tool/call` arguments (lost across bridge
|
|
900
|
+
restarts unless re-read from history), and the only outcomes are allow-once/reject/
|
|
901
|
+
cancelled/unavailable with a binary `ask|never` policy. Don’t promise “remember this
|
|
902
|
+
approval” UX.
|
|
903
|
+
|
|
904
|
+
### Feature blockers (plainly)
|
|
905
|
+
|
|
906
|
+
- No blocker for items 1–5 as read/limited-write features.
|
|
907
|
+
- Item 6 (`workspaceChanges`) is **live-process only** — a phone showing “changed files” for
|
|
908
|
+
a cold session will see nothing; historical events are still in history if we later parse
|
|
909
|
+
them, but summaries/diffs are not reconstructable from disk by the plugin.
|
|
910
|
+
- Item 7’s `measure()` is **live-only**; the cold path is projections only (sufficient for a
|
|
911
|
+
meter).
|
|
912
|
+
- Item 8 execution is **live-only** and unsafe without an allowlist.
|
|
913
|
+
- Item 10 “always allow” is **not possible**; only per-request decisions.
|
|
914
|
+
|
|
915
|
+
---
|
|
916
|
+
|
|
917
|
+
## Recommended frame additions by batch
|
|
918
|
+
|
|
919
|
+
**Batch A — session lifecycle (rename/fork/search/pin-archive flags)**
|
|
920
|
+
`session.rename`, `session.fork`, `search.query` → `search.results`;
|
|
921
|
+
session object gains `pinned`, `archived`, `agentAvailable`; push `workspace.state`
|
|
922
|
+
(`archivedSessionIds`, `pinnedSessionIds`).
|
|
923
|
+
|
|
924
|
+
**Batch B — queued input & steering**
|
|
925
|
+
`queue.list`, `queue.update` (`edit`/`remove`/`steer`), push `queue.changed`;
|
|
926
|
+
`prompt` gains `mode:'queue'|'steer'`.
|
|
927
|
+
|
|
928
|
+
**Batch C — workspace changes**
|
|
929
|
+
`changes.list {sessionId}` (from `workspace/changes` history events),
|
|
930
|
+
`changes.diff {sessionId,seq,index}`; cap payloads; `diff unavailable` for cold sessions.
|
|
931
|
+
|
|
932
|
+
**Batch D — context meter**
|
|
933
|
+
`context.get`/`context.changed` with `projectedTokens`, `contextWindow`, `pressureTokens`,
|
|
934
|
+
`basis`, `tokenUsage`.
|
|
935
|
+
|
|
936
|
+
**Batch E — commands (allowlisted)**
|
|
937
|
+
`commands.list`, `commands.execute`; HistoryItem `kind:'command'`
|
|
938
|
+
(`command/run`+`command/done` pairing by commandId).
|
|
939
|
+
|
|
940
|
+
**Batch F — first-class images**
|
|
941
|
+
`prompt.content` image parts (or `upload.image` → `{receiptId,image}`);
|
|
942
|
+
`history` items `attachments:[{attachmentId,mediaType,bytes,width,height,name?}]`;
|
|
943
|
+
`attachment.get {attachmentId}` → base64 preview; `image.limits` frame.
|
|
944
|
+
|
|
945
|
+
**Batch G — approvals v2 (cards only)**
|
|
946
|
+
Extend `approval.request` with bounded `argsPreview`/`args` (from `tool/call` by `callId`)
|
|
947
|
+
and optional audit id; keep allow-once/reject only.
|
|
948
|
+
|
|
949
|
+
---
|
|
950
|
+
|
|
951
|
+
## Appendix — exact method inventory used here (Cordis Inspect, Host)
|
|
952
|
+
|
|
953
|
+
- `sessionController`: `list`, `search`, `create`, `selectModel`, `modelCatalog`, `rename`,
|
|
954
|
+
`fork`, `prompt`, `attachment`, `updateQueue`, `cancel`, `events`, `observeEvent`,
|
|
955
|
+
`observeProjections`, `state`, `observeState`, `wait`, `follow`, `projections`, `control`,
|
|
956
|
+
`resolveAgent`.
|
|
957
|
+
- `workspaceController`: `create`, `initializeDefault`, `rename`, `delete`, `insertBefore`,
|
|
958
|
+
`insertSessionBefore`, `archiveSession`, `unarchiveSession`, `pinSession`, `unpinSession`,
|
|
959
|
+
`follow`.
|
|
960
|
+
- `workspaceChanges`: `summary`, `diff`.
|
|
961
|
+
- `tokenMeter`: `contextPressure`, `measure`, `estimateMessage`.
|
|
962
|
+
- `commands`: `register`, `registerFileReceiptResolver`, `list`, `find`, `execute`.
|
|
963
|
+
- `attachments`: `imageLimits` (getter), `validateImage`, `saveImages`, `admitPromptContent`,
|
|
964
|
+
`admitEncodedFile`, `saveImage`, `readImage`, `saveFile`, `saveFileStream`,
|
|
965
|
+
`readFileStream`, `readImageRequest`, `imageHostPath`, `fileHostPath`.
|
|
966
|
+
- `fileUploads`: `upload`, `uploadStream`, `uploadImageStream`, `resolve`, `bindPrompt`,
|
|
967
|
+
`retirePrompt`, `registerAgentResolver`.
|
|
968
|
+
- `approval`: `setPolicy`, `request`, `overrideOf`.
|
|
969
|
+
- `subagents`: `listChildren`, `listDescendants`, `prompt`, `interruptByParent`, …
|
|
970
|
+
- `agentTeams`: `membership`, `listMembers`, `listTasks`, `getTask`, `waitForChange`,
|
|
971
|
+
`spawnTeammate`, `sendMessage`, `createTask`, `updateTask`, `interrupt`.
|
|
972
|
+
|
|
973
|
+
Events used or recommended: `approval/request` (waterfall),
|
|
974
|
+
`agent/assistant-stream`, `agent/status`, `agent/error`, `session/event` (incl.
|
|
975
|
+
`command/run`, `command/done`, `agent/inbox/spliced`, `workspace/changes`, `session/title`,
|
|
976
|
+
`model/selection`, `approval/asked`, `approval/decided`), `agent/created`, `agent/disposed`,
|
|
977
|
+
`session/created`, `session/disposed`, `workspace/session-activity` /
|
|
978
|
+
`workspace/session-stop` (registry waterfall/hooks, not needed by us).
|