@khorsheed/dsh-room 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +48 -0
  4. package/README.zh.md +48 -0
  5. package/cordis.patch.yml +6 -0
  6. package/lib/client.js +11481 -0
  7. package/lib/index.js +3231 -0
  8. package/lib/invariant.js +26 -0
  9. package/lib/journal-CuRnWk66.js +435 -0
  10. package/lib/tool.js +350 -0
  11. package/lib/typert.host.d.ts +3 -0
  12. package/lib/typert.host.js +2615 -0
  13. package/lib/typert.remote-client.d.ts +55 -0
  14. package/lib/typert.remote-client.js +1711 -0
  15. package/lib/types/adapter.d.ts +42 -0
  16. package/lib/types/adapter.js +41 -0
  17. package/lib/types/agent-setup.d.ts +141 -0
  18. package/lib/types/agent-setup.js +145 -0
  19. package/lib/types/client/InviteAgentAction.d.ts +13 -0
  20. package/lib/types/client/InviteAgentAction.js +45 -0
  21. package/lib/types/client/InviteDialog.d.ts +90 -0
  22. package/lib/types/client/InviteDialog.js +216 -0
  23. package/lib/types/client/MemberCard.d.ts +33 -0
  24. package/lib/types/client/MemberCard.js +32 -0
  25. package/lib/types/client/MembersView.d.ts +5 -0
  26. package/lib/types/client/MembersView.js +168 -0
  27. package/lib/types/client/RoomComposer.d.ts +21 -0
  28. package/lib/types/client/RoomComposer.js +211 -0
  29. package/lib/types/client/RoomDockCapsules.d.ts +64 -0
  30. package/lib/types/client/RoomDockCapsules.js +277 -0
  31. package/lib/types/client/RoomEventView.d.ts +11 -0
  32. package/lib/types/client/RoomEventView.js +17 -0
  33. package/lib/types/client/RoomModelPicker.d.ts +18 -0
  34. package/lib/types/client/RoomModelPicker.js +134 -0
  35. package/lib/types/client/RoomPlanView.d.ts +17 -0
  36. package/lib/types/client/RoomPlanView.js +88 -0
  37. package/lib/types/client/RoomQueueStrip.d.ts +26 -0
  38. package/lib/types/client/RoomQueueStrip.js +28 -0
  39. package/lib/types/client/RoomRecoveryView.d.ts +11 -0
  40. package/lib/types/client/RoomRecoveryView.js +38 -0
  41. package/lib/types/client/RoomRelayView.d.ts +12 -0
  42. package/lib/types/client/RoomRelayView.js +20 -0
  43. package/lib/types/client/RoomRunView.d.ts +15 -0
  44. package/lib/types/client/RoomRunView.js +50 -0
  45. package/lib/types/client/RoomSpeechView.d.ts +18 -0
  46. package/lib/types/client/RoomSpeechView.js +62 -0
  47. package/lib/types/client/RoomStatsLine.d.ts +61 -0
  48. package/lib/types/client/RoomStatsLine.js +138 -0
  49. package/lib/types/client/RoomTaskLineView.d.ts +13 -0
  50. package/lib/types/client/RoomTaskLineView.js +21 -0
  51. package/lib/types/client/RoomTodoStrip.d.ts +24 -0
  52. package/lib/types/client/RoomTodoStrip.js +64 -0
  53. package/lib/types/client/format.d.ts +31 -0
  54. package/lib/types/client/format.js +48 -0
  55. package/lib/types/client/icons.d.ts +27 -0
  56. package/lib/types/client/icons.js +11 -0
  57. package/lib/types/client/index.d.ts +39 -0
  58. package/lib/types/client/index.js +471 -0
  59. package/lib/types/client/locales.d.ts +422 -0
  60. package/lib/types/client/locales.js +413 -0
  61. package/lib/types/client/member-color.d.ts +13 -0
  62. package/lib/types/client/member-color.js +22 -0
  63. package/lib/types/client/name-pool.d.ts +17 -0
  64. package/lib/types/client/name-pool.js +25 -0
  65. package/lib/types/client/nodes.d.ts +136 -0
  66. package/lib/types/client/nodes.js +212 -0
  67. package/lib/types/client/preset-visibility.d.ts +91 -0
  68. package/lib/types/client/preset-visibility.js +113 -0
  69. package/lib/types/client/request-ids.d.ts +7 -0
  70. package/lib/types/client/request-ids.js +21 -0
  71. package/lib/types/client/room-store.d.ts +137 -0
  72. package/lib/types/client/room-store.js +244 -0
  73. package/lib/types/client/slots.d.ts +319 -0
  74. package/lib/types/client/slots.js +1 -0
  75. package/lib/types/deliveries.d.ts +5 -0
  76. package/lib/types/deliveries.js +20 -0
  77. package/lib/types/dispatch.d.ts +105 -0
  78. package/lib/types/dispatch.js +467 -0
  79. package/lib/types/index.d.ts +301 -0
  80. package/lib/types/index.js +1200 -0
  81. package/lib/types/invariant.d.ts +16 -0
  82. package/lib/types/invariant.js +24 -0
  83. package/lib/types/journal.d.ts +117 -0
  84. package/lib/types/journal.js +434 -0
  85. package/lib/types/plan-service.d.ts +34 -0
  86. package/lib/types/plan-service.js +266 -0
  87. package/lib/types/plan.d.ts +168 -0
  88. package/lib/types/plan.js +494 -0
  89. package/lib/types/tool.d.ts +56 -0
  90. package/lib/types/tool.js +389 -0
  91. package/lib/types/types.d.ts +813 -0
  92. package/lib/types/types.js +1 -0
  93. package/locale/en.json +6 -0
  94. package/locale/zh.json +6 -0
  95. package/package.json +131 -0
@@ -0,0 +1,301 @@
1
+ import { PlanService } from './plan-service.ts';
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ import type { Session } from '@deepseek-ai/dsh-session';
4
+ import type { LocalAgentMemberRun, MemberRoomCommand, MemberMessageOutcome } from '@khorsheed/dsh-local-agent/types';
5
+ import { SessionId } from '@deepseek-ai/dsh-session';
6
+ import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
7
+ import { DispatchEngine } from './dispatch.ts';
8
+ import type { RoomAddTaskRequest, RoomAddTaskResult, RoomCancelRequest, RoomCancelResult, RoomCloseTaskRequest, RoomCloseTaskResult, RoomPrepareMemberRequest, RoomPrepareMemberResult, RoomFailure, RoomSetCoordinatorRequest, RoomSetCoordinatorResult, RoomReconcileDeliveryRequest, RoomReconcileDeliveryResult, RoomGetStateRequest, RoomGetStateResult, RoomInviteRequest, RoomInviteResult, RoomIsRoomRequest, RoomListProvidersRequest, RoomMemberMessage, RoomMemberMessageReceipt, RoomMessageRequest, RoomMessageResult, RoomPostMessageRequest, RoomPostMessageResult, RoomProviderList, RoomRelayResolveRequest, RoomRelayResolveResult, RoomRemoveMemberRequest, RoomRemoveMemberResult, RoomSetGoalRequest, RoomSetGoalResult, RoomState, RoomUpdateMemberRequest, RoomUpdateMemberResult, RoomUpdateTaskRequest, RoomUpdateTaskResult } from './types.ts';
9
+ export type * from './types.ts';
10
+ export { MAIN_AGENT_MEMBER, ROOM_EVENT_TYPES } from './journal.ts';
11
+ declare module '@deepseek-ai/cordis' {
12
+ interface Context {
13
+ /**
14
+ * Room service owned by the room plugin: the Typert Remote gateway AND
15
+ * the in-process service face the local-agent bridge duck-type-calls
16
+ * (`receiveMemberMessage`). TypertRemoteService's Service base provides
17
+ * it under 'room'.
18
+ */
19
+ room: RoomService;
20
+ }
21
+ }
22
+ /** A resolved room session plus its replayed state, or the rejection. */
23
+ type RoomLoad = {
24
+ readonly ok: true;
25
+ readonly session: Session;
26
+ readonly state: RoomState;
27
+ } | {
28
+ readonly ok: false;
29
+ readonly error: RoomFailure;
30
+ };
31
+ /**
32
+ * room Remote service: promotion, roster management, the human @-message
33
+ * intake, the notification gate, the task board, and run cancellation. A
34
+ * room IS a normal session; the journal is its only state. A room is never
35
+ * CREATED apart from a session — inviting an agent into any session promotes
36
+ * it (see ensureRoom; the room-session-promotion proposal).
37
+ */
38
+ export declare class RoomService extends TypertRemoteService {
39
+ static inject: string[];
40
+ /** The dispatch engine executing this service's dispatch records. */
41
+ readonly plans: PlanService;
42
+ readonly engine: DispatchEngine;
43
+ private readonly handoffs;
44
+ /** sessionId → in-flight cold resume (mutations on a cold room dedupe). */
45
+ private readonly resumes;
46
+ /**
47
+ * @param ctx - host context carrying the session store.
48
+ */
49
+ constructor(ctx: Context);
50
+ /** Resolve a LIVE session as a room: presence, marker, replayed state. */
51
+ private load;
52
+ /**
53
+ * Read a session as a room without side effects: the live store first, then
54
+ * a persistence inspection (a cold room after a host restart answers from
55
+ * its durable log; nothing is attached or resumed on a read).
56
+ */
57
+ private loadCold;
58
+ /**
59
+ * Resolve a room for a MUTATION: the session must be live to take appends,
60
+ * and dispatch needs its agent live (the delegation facade resolves the
61
+ * parent through `ctx.agents.get` — live agents only). A cold room is
62
+ * cold-resumed through the agent factory, which republishes session +
63
+ * agent under the preset the log records; resumes dedupe per session.
64
+ */
65
+ private ensureLive;
66
+ /** One cold resume: refuse non-rooms before paying an agent composition. */
67
+ private resumeRoom;
68
+ /**
69
+ * Probe whether a session is a room: replay its event log looking for the
70
+ * `room/created` marker. Side-effect-free: a cold session answers from a
71
+ * persistence inspection, so opening any session never resumes its agent.
72
+ * @param request - session identity.
73
+ * @returns true when the session carries the marker (false for unknown sessions too).
74
+ */
75
+ isRoom(request: RoomIsRoomRequest): Promise<boolean>;
76
+ /**
77
+ * Resolve a session for a room WRITE, promoting it when it isn't a room
78
+ * yet: a live plain session gains the `room/created` identity marker and
79
+ * the main agent's roster seat (the promotion IS the entry model — the
80
+ * room-session-promotion proposal: any session an agent is invited into
81
+ * becomes a room). Idempotent — an existing room passes through untouched,
82
+ * and concurrent promotions converge on the log (the first `room/created`
83
+ * wins identity). A cold EXISTING room resumes through the normal path;
84
+ * a cold PLAIN session cannot be promoted sight-unseen (promotion writes
85
+ * on the live session, and the surfaces that promote — the open session's
86
+ * invite dialog, the room tools running in their own session — always hold
87
+ * it live), so it answers `not-a-room`. NOT a Remote — the surfaces reach
88
+ * it through the write paths (invite/messageMember); public so tests and a
89
+ * future manual "promote" surface share the one entry.
90
+ * @param sessionId - the session to write.
91
+ * @returns the live session plus replayed state, or the rejection.
92
+ */
93
+ ensureRoom(sessionId: SessionId): Promise<RoomLoad>;
94
+ /**
95
+ * List the invitable CLI providers: the local-agent roster with each
96
+ * harness's auth state, plus the delegation-facade verdict (absent facade =
97
+ * CLI members undispatchable; the dialog greys the section instead of
98
+ * failing). Harnesses without a delegation provider are record-only and
99
+ * are not invitable.
100
+ * @param _request - no parameters.
101
+ * @returns the provider list and the facade verdict.
102
+ */
103
+ listProviders(_request: RoomListProvidersRequest): Promise<RoomProviderList>;
104
+ /**
105
+ * Replay the room's journal into the derived state (roster, notification
106
+ * relays, task board, run states).
107
+ * @param request - room session identity.
108
+ * @returns the replayed state, or a rejection from the closed failure union.
109
+ */
110
+ getState(request: RoomGetStateRequest): Promise<RoomGetStateResult>;
111
+ /**
112
+ * Validate, PROMOTE (a plain session becomes a room — see ensureRoom), and
113
+ * journal an invitation: the name must be parseable by the
114
+ * composer @-grammar and unique, the provider non-blank AND a registered
115
+ * delegation provider (the classic slip is the harness name `kimi` where
116
+ * the family registered `kimi-cli` — validated against the roster's
117
+ * `delegationProvider` set, the same probe listProviders serves; a roster-
118
+ * less core skips the check, degrading to the old accept-anything), and
119
+ * (CLI members are undispatchable without it) the local-agent facade must
120
+ * be probed. A first task is journaled as a `room/dispatch` (auto-opening
121
+ * the member's in_progress task) and handed to the engine immediately —
122
+ * the receipt's `pendingFirstTask` means "dispatched". Shared by the
123
+ * Remote surface (`invitedBy: 'human'`) and the room_invite tool
124
+ * (`invitedBy: 'agent'`).
125
+ * @param request - room session, provider, name, optional cwd, instructions and first task.
126
+ * @param invitedBy - the invitation's origin.
127
+ * @returns the invitation receipt, or a rejection.
128
+ */
129
+ inviteMember(request: RoomInviteRequest, invitedBy: 'human' | 'agent', actorChildSessionId?: string): Promise<RoomInviteResult>;
130
+ /**
131
+ * Invite a CLI member (the human path; see inviteMember).
132
+ * @param request - room session, provider, name, optional cwd, instructions and first task.
133
+ * @returns the invitation receipt, or a rejection.
134
+ */
135
+ invite(request: RoomInviteRequest): Promise<RoomInviteResult>;
136
+ /**
137
+ * Update a member's editable fields: rename (validated like an invite name —
138
+ * unique, parseable; the main agent is the room itself and cannot be
139
+ * renamed), role instructions (null or a blank text CLEARS them — later
140
+ * dispatches inject none), the member-level cwd override (null or a
141
+ * blank text clears back to inheriting the room cwd; still roster-recorded
142
+ * only — the delegation facade's per-call cwd override is the family's open
143
+ * R2), and the intended model (null or a blank text clears it back to the
144
+ * harness default; roster-recorded intent — the first dispatch binds it as
145
+ * the facade start's `model` option, and the live member's immediate switch
146
+ * is the client's localAgentGateway `setMemberModel` call, not this one).
147
+ * An instructions edit rides the member's next dispatch as a context
148
+ * update (the CLI session itself is never rewritten); a rename migrates
149
+ * every name-keyed projection at replay (the journal fold moves the roster
150
+ * key, tasks' member/blockedBy, relays' from/to, and the runs key).
151
+ * @param request - room session, member name, and the fields to change.
152
+ * @returns the update receipt (the CURRENT name), or a rejection.
153
+ */
154
+ updateMember(request: RoomUpdateMemberRequest): Promise<RoomUpdateMemberResult>;
155
+ /** Native preparation creates no unrelated conversation turn and leaves the role unchanged. */
156
+ prepareMember(request: RoomPrepareMemberRequest): Promise<RoomPrepareMemberResult>;
157
+ private prepareMemberInRoom;
158
+ /** A human records the known result before releasing a crashed member's queued work. */
159
+ reconcileDelivery(request: RoomReconcileDeliveryRequest): Promise<RoomReconcileDeliveryResult>;
160
+ /** Explicit human role change; state is committed only after readiness and idle checks. */
161
+ setCoordinator(request: RoomSetCoordinatorRequest): Promise<RoomSetCoordinatorResult>;
162
+ /**
163
+ * Remove a member from the roster. An in-flight run is NOT interrupted
164
+ * here — cancel() first when the member is running.
165
+ * @param request - room session, member name.
166
+ * @returns the removal receipt, or a rejection.
167
+ */
168
+ removeMember(request: RoomRemoveMemberRequest): Promise<RoomRemoveMemberResult>;
169
+ /**
170
+ * Post a human @-message into the room: leading `@name` tokens address
171
+ * members, and so does the request's `targets` list (the composer's
172
+ * mention-menu picks — explicit addressing wherever the `@name` sits); the
173
+ * two union before the roster check (a `room/dispatch` journal record,
174
+ * executed by the engine, and one auto-opened in_progress task per target).
175
+ * The human's raw text is
176
+ * FIRST appended as a standard `user/message` (source kind 'user' — the
177
+ * human typed it; the official messageDefinition classifies any other kind
178
+ * as a collapsed context-injection row, not the user bubble), so the words
179
+ * render as the official user bubble and enter the main agent's
180
+ * model-visible history. The append wakes nothing: turns start from
181
+ * prompt/followup calls, never from log appends (the agent is the log's
182
+ * writer, not a watcher). The `room/dispatch` record stays as pure
183
+ * bookkeeping (task board, dispatch cursors, replay) — it no longer drives
184
+ * any chat node. A BARE message is a structured `no-targets` rejection —
185
+ * defense only: the room composer releases bare messages to the official
186
+ * submit path (a normal main-agent turn) and never calls this Remote
187
+ * without addressing.
188
+ * @param request - room session, raw composer text, and the menu-picked addressees.
189
+ * @returns the parse receipt, or a rejection.
190
+ */
191
+ postMessage(request: RoomPostMessageRequest): Promise<RoomPostMessageResult>;
192
+ /**
193
+ * Dispatch one message to one member (host-only — the `room_message` tool's
194
+ * path; the model-facing equivalent of the human's `@member text`). Same
195
+ * dispatch internals as postMessage minus the user/message bubble: the
196
+ * caller is the room's own main agent, so the text must NOT wear the human
197
+ * bubble (source kind 'user' would misattribute it). The dispatch record
198
+ * and the auto-opened in_progress task journal as usual.
199
+ * @param request - room session, addressee, text.
200
+ * @returns the dispatch receipt, or a rejection.
201
+ */
202
+ messageMember(request: RoomMessageRequest, actorChildSessionId?: string): Promise<RoomMessageResult>;
203
+ /** Host-authenticated actor; model tool arguments never provide the room or sender. */
204
+ private isCurrentCoordinator;
205
+ /** Bounded shared room context for native and external model tools; reading never wakes an agent. */
206
+ readRoomContext(sessionId: string): Promise<string>;
207
+ /** Human UI and native/external tools share the same durable transition service. */
208
+ planCommand(request: {
209
+ sessionId: SessionId;
210
+ command: string;
211
+ }): Promise<{
212
+ ok: true;
213
+ } | {
214
+ ok: false;
215
+ message: string;
216
+ }>;
217
+ /** The actor is derived from the calling native agent or authenticated bridge. */
218
+ commandPlan(sessionId: string, command: string, actorChildSessionId?: string): Promise<string>;
219
+ /** Shared backend for external MCP room tools. Not exposed as a browser Remote. */
220
+ receiveMemberCommand(actor: LocalAgentMemberRun, command: MemberRoomCommand): Promise<MemberMessageOutcome>;
221
+ /**
222
+ * The notification gate entry, verbatim-frozen contract for the local-agent
223
+ * family bridge (`ctx.get('room')` + duck-typed call). The call crosses an
224
+ * untyped package boundary, so the message shape is validated at runtime:
225
+ * a malformed message throws (the bridge treats a rejection as "room does
226
+ * not claim this" and delivers directly) instead of poisoning the journal.
227
+ * `from`/`to` arrive as roster names OR member child session ids (the
228
+ * bridge cannot speak names for the sender — only room owns the roster);
229
+ * both are normalized to roster names when resolvable, so the pending card
230
+ * and the delivery text (`{from} 给你的通知: …`) read as names. Phase 1's
231
+ * gate is ALWAYS human confirmation: the relay is journaled pending and
232
+ * the sender receives 'pending-confirm' (never 'sent' — the bridge keeps
233
+ * the member's conclusion honest). A non-room parent session throws.
234
+ * @param request - sender, recipient, content, the shared parent session, provenance.
235
+ * @returns the gate receipt.
236
+ */
237
+ receiveMemberMessage(request: RoomMemberMessage): Promise<RoomMemberMessageReceipt>;
238
+ /**
239
+ * Confirm a pending relay: journal the confirmed edge and dispatch the
240
+ * notification to the recipient as a continuation (`{from} 给你的通知:
241
+ * {content}`); the engine marks the relay sent once the recipient's own
242
+ * session receives the prompt.
243
+ * @param request - room session, relay id.
244
+ * @returns the resolution receipt, or a rejection.
245
+ */
246
+ confirmRelay(request: RoomRelayResolveRequest): Promise<RoomRelayResolveResult>;
247
+ /**
248
+ * Dismiss a pending relay: the notification never reaches anyone.
249
+ * @param request - room session, relay id.
250
+ * @returns the resolution receipt, or a rejection.
251
+ */
252
+ dismissRelay(request: RoomRelayResolveRequest): Promise<RoomRelayResolveResult>;
253
+ /**
254
+ * Add a task to a member's board lane (the human's management entry; @-
255
+ * dispatches auto-open in_progress tasks, this opens a pending one).
256
+ * `blockedBy` names the member the task waits on (display only — it never
257
+ * dispatches anything); it must resolve against the roster.
258
+ * @param request - room session, member, title, optional blockedBy.
259
+ * @returns the new task's id, or a rejection.
260
+ */
261
+ addTask(request: RoomAddTaskRequest): Promise<RoomAddTaskResult>;
262
+ /**
263
+ * Close an open task (done by default, or cancelled). A failed task is
264
+ * still open for closing — that is the human's dismiss path after a
265
+ * failed run (the board's [关闭] passes 'cancelled').
266
+ * @param request - room session, task id, optional closing status.
267
+ * @returns the closed task's id, or a rejection.
268
+ */
269
+ closeTask(request: RoomCloseTaskRequest): Promise<RoomCloseTaskResult>;
270
+ /**
271
+ * Edit an open task's title and/or blockedBy (the `room_task` tool's update
272
+ * action; journaled as `room/task-edited`, status changes stay on
273
+ * closeTask). Host method only — the capsule UI edits nothing but the goal.
274
+ * `blockedBy: null` clears the wait; a string must resolve against the
275
+ * roster. A closed task takes no edits.
276
+ * @param request - room session, task id, and at least one edited field.
277
+ * @returns the edited task's id, or a rejection.
278
+ */
279
+ updateTask(request: RoomUpdateTaskRequest): Promise<RoomUpdateTaskResult>;
280
+ /**
281
+ * Set (or, with a blank text, clear) the room's goal. The goal is one
282
+ * journaled line — the latest `room/goal` event wins; it rides the top of
283
+ * the roster section in every member prompt and drives the dock's goal
284
+ * capsule. Pure display/coordination text: it never dispatches anything.
285
+ * @param request - room session and goal text.
286
+ * @returns the now-current goal (absent after a clear), or a rejection.
287
+ */
288
+ setGoal(request: RoomSetGoalRequest): Promise<RoomSetGoalResult>;
289
+ /**
290
+ * Cancel a member's in-flight run through the local-agent facade. A hit
291
+ * journals the terminal `cancelled` edge immediately (the engine's own
292
+ * settle for that run then no-ops); a miss — no facade, no delegation
293
+ * handle, or nothing in flight — journals nothing and reports
294
+ * `cancelled: false`.
295
+ * @param request - room session, member name.
296
+ * @returns the cancellation receipt, or a rejection.
297
+ */
298
+ cancel(request: RoomCancelRequest): Promise<RoomCancelResult>;
299
+ }
300
+ export default RoomService;
301
+ //# sourceMappingURL=index.d.ts.map