@khorsheed/dsh-room 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/README.en.md +29 -62
- package/README.i18n.yaml +2 -2
- package/README.md +28 -61
- package/lib/client.js +13097 -4182
- package/lib/index.js +4045 -730
- package/lib/journal-B4FOGO6S.js +482 -0
- package/lib/journal-Rid9AAnD.js +485 -0
- package/lib/tool.js +112 -166
- package/lib/typert.host.js +2031 -374
- package/lib/typert.remote-client.d.ts +34 -10
- package/lib/typert.remote-client.js +1599 -210
- package/lib/types/agent-setup.d.ts +1 -1
- package/lib/types/client/InviteAgentAction.js +4 -16
- package/lib/types/client/InviteDialog.d.ts +28 -6
- package/lib/types/client/InviteDialog.js +76 -12
- package/lib/types/client/MemberCard.d.ts +5 -1
- package/lib/types/client/MemberCard.js +4 -4
- package/lib/types/client/MembersView.d.ts +1 -1
- package/lib/types/client/MembersView.js +58 -22
- package/lib/types/client/RemoveMemberConfirm.d.ts +40 -0
- package/lib/types/client/RemoveMemberConfirm.js +85 -0
- package/lib/types/client/RoomApprovalView.d.ts +11 -0
- package/lib/types/client/RoomApprovalView.js +28 -0
- package/lib/types/client/RoomComposer.d.ts +1 -1
- package/lib/types/client/RoomComposer.js +195 -29
- package/lib/types/client/RoomDecisionView.d.ts +22 -0
- package/lib/types/client/RoomDecisionView.js +35 -0
- package/lib/types/client/RoomHelpView.d.ts +17 -0
- package/lib/types/client/RoomHelpView.js +56 -0
- package/lib/types/client/RoomInboxView.d.ts +10 -0
- package/lib/types/client/RoomInboxView.js +14 -0
- package/lib/types/client/RoomQuestionView.d.ts +13 -0
- package/lib/types/client/RoomQuestionView.js +61 -0
- package/lib/types/client/RoomRelayView.js +1 -1
- package/lib/types/client/RoomRunView.d.ts +3 -1
- package/lib/types/client/RoomRunView.js +12 -5
- package/lib/types/client/RoomSettingsView.d.ts +19 -0
- package/lib/types/client/RoomSettingsView.js +30 -0
- package/lib/types/client/RoomSpeechView.d.ts +22 -8
- package/lib/types/client/RoomSpeechView.js +94 -11
- package/lib/types/client/RoomStatsLine.d.ts +26 -5
- package/lib/types/client/RoomStatsLine.js +53 -7
- package/lib/types/client/RoomTaskCapsule.d.ts +19 -0
- package/lib/types/client/RoomTaskCapsule.js +37 -0
- package/lib/types/client/TasksTab.d.ts +41 -0
- package/lib/types/client/TasksTab.js +43 -0
- package/lib/types/client/TasksView.d.ts +44 -0
- package/lib/types/client/TasksView.js +149 -0
- package/lib/types/client/TeamView.d.ts +33 -0
- package/lib/types/client/TeamView.js +210 -0
- package/lib/types/client/at-menu.d.ts +127 -0
- package/lib/types/client/at-menu.js +173 -0
- package/lib/types/client/draft-chips.d.ts +67 -0
- package/lib/types/client/draft-chips.js +95 -0
- package/lib/types/client/executions.d.ts +0 -30
- package/lib/types/client/executions.js +4 -34
- package/lib/types/client/icons-local.d.ts +25 -0
- package/lib/types/client/icons-local.js +10 -0
- package/lib/types/client/icons.d.ts +2 -1
- package/lib/types/client/icons.js +1 -0
- package/lib/types/client/index.js +276 -72
- package/lib/types/client/locales.d.ts +482 -52
- package/lib/types/client/locales.js +490 -60
- package/lib/types/client/nodes.d.ts +112 -17
- package/lib/types/client/nodes.js +197 -26
- package/lib/types/client/slots.d.ts +117 -47
- package/lib/types/client/task-tag.d.ts +32 -0
- package/lib/types/client/task-tag.js +33 -0
- package/lib/types/client/tasks.d.ts +50 -0
- package/lib/types/client/tasks.js +82 -0
- package/lib/types/client/team.d.ts +73 -0
- package/lib/types/client/team.js +187 -0
- package/lib/types/decisions.d.ts +49 -0
- package/lib/types/decisions.js +101 -0
- package/lib/types/deliveries.d.ts +17 -1
- package/lib/types/deliveries.js +82 -6
- package/lib/types/dispatch.d.ts +92 -4
- package/lib/types/dispatch.js +477 -109
- package/lib/types/help.d.ts +137 -0
- package/lib/types/help.js +216 -0
- package/lib/types/helps.d.ts +26 -0
- package/lib/types/helps.js +47 -0
- package/lib/types/index.d.ts +292 -52
- package/lib/types/index.js +1415 -199
- package/lib/types/jobs.d.ts +22 -0
- package/lib/types/jobs.js +77 -0
- package/lib/types/journal.d.ts +17 -27
- package/lib/types/journal.js +120 -43
- package/lib/types/messaging.d.ts +65 -0
- package/lib/types/messaging.js +160 -0
- package/lib/types/plan-service.js +7 -1
- package/lib/types/report-gate.d.ts +81 -0
- package/lib/types/report-gate.js +89 -0
- package/lib/types/tool-definition.d.ts +43 -20
- package/lib/types/tool-definition.js +145 -212
- package/lib/types/tool.d.ts +2 -2
- package/lib/types/tool.js +3 -2
- package/lib/types/types.d.ts +755 -78
- package/locale/zh.json +1 -1
- package/package.json +3 -3
- package/lib/types/client/RoomActivityDock.d.ts +0 -19
- package/lib/types/client/RoomActivityDock.js +0 -105
- package/lib/types/client/RoomDockCapsules.d.ts +0 -64
- package/lib/types/client/RoomDockCapsules.js +0 -277
- package/lib/types/client/RoomPlanTab.d.ts +0 -15
- package/lib/types/client/RoomPlanTab.js +0 -13
- package/lib/types/client/RoomTaskLineView.d.ts +0 -13
- package/lib/types/client/RoomTaskLineView.js +0 -21
package/lib/tool.js
CHANGED
|
@@ -1,37 +1,6 @@
|
|
|
1
|
-
import { i as isRoomLog, r as coordinatorMember } from "./journal-BWL3-i0s.js";
|
|
2
1
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
3
2
|
//#region lib/types/tool-definition.js
|
|
4
3
|
/**
|
|
5
|
-
* The room's model-facing tool DEFINITIONS, `room_invite`, `room_task`, and
|
|
6
|
-
* `room_message`: the main
|
|
7
|
-
* agent's paths into the room it belongs to. `room_invite` and
|
|
8
|
-
* `room_message` PROMOTE: calling them in a plain session turns it into a
|
|
9
|
-
* room (ensureRoom) instead of rejecting. `room_task` stays gated at execute
|
|
10
|
-
* time — the calling agent's session must be a room (the journal carries
|
|
11
|
-
* `room/created`); anywhere else the tool answers with readable error text
|
|
12
|
-
* instead of throwing, so the model can see the rejection and self-correct.
|
|
13
|
-
* `room_invite` lands in the same invite path as the human dialog
|
|
14
|
-
* (`invitedBy: 'agent'`), producing an identical member record; `room_task`
|
|
15
|
-
* writes the SHARED task board through the very host functions the capsule UI
|
|
16
|
-
* uses (addTask/closeTask, plus the tool-only updateTask), so an agent-written
|
|
17
|
-
* task is indistinguishable from a human-added one; `room_message` dispatches
|
|
18
|
-
* a message to a member through the same engine path as the human's
|
|
19
|
-
* `@member text`, minus the user bubble (the caller is the room's own agent).
|
|
20
|
-
*
|
|
21
|
-
* Since the tool-row split (M4') the core never REGISTERS these tools: the
|
|
22
|
-
* factories are consumed by the package's `./tool` subpath row
|
|
23
|
-
* ({@link file://./tool.ts}), which mounts them inside agent-preset
|
|
24
|
-
* compositions (session-granted, never at the profile root). The definitions
|
|
25
|
-
* are therefore returned UNTAGGED — the registering row applies its own
|
|
26
|
-
* tool-origin tag (AGENTS.md § Tool origin tagging — the owner is whichever
|
|
27
|
-
* package mounts the row).
|
|
28
|
-
*
|
|
29
|
-
* Internal module: not on the package's exports map (consumers reach it only
|
|
30
|
-
* through `./src/*`).
|
|
31
|
-
*
|
|
32
|
-
* @module @khorsheed/dsh-room
|
|
33
|
-
*/
|
|
34
|
-
/**
|
|
35
4
|
* Build the room_invite tool definition bound to the room service.
|
|
36
5
|
* @param backend - the room service.
|
|
37
6
|
* @returns a registry-ready tool definition.
|
|
@@ -39,30 +8,42 @@ import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
|
39
8
|
function roomInviteTool(backend) {
|
|
40
9
|
return defineTool({
|
|
41
10
|
name: "room_invite",
|
|
42
|
-
description: "Invite a CLI agent member into the current session (any session works — inviting promotes it into a room: the multi-agent group conversation surface wakes up on it). The member becomes @-addressable by the human and by other members: pick a short unique name (no whitespace, no \"@\", e.g. ada/bill/cathy) — it is the addressing name, decoupled from the provider so two instances of one provider can coexist; prefer a function-style name (e.g. design-review / restart-test) when the member has a standing role, so the human and the other members can tell what it is for.
|
|
11
|
+
description: "Invite a CLI agent member into the current session (any session works — inviting promotes it into a room: the multi-agent group conversation surface wakes up on it). The member becomes @-addressable by the human and by other members: pick a short unique name (no whitespace, no \"@\", e.g. ada/bill/cathy) — it is the addressing name, decoupled from the provider so two instances of one provider can coexist; prefer a function-style name (e.g. design-review / restart-test) when the member has a standing role, so the human and the other members can tell what it is for. Give a short public role (what everyone else sees) and private instructions: the instructions are the member's own briefing, prepended to its first dispatch and persisted in its own CLI session from then on. Give a firstTask to put the member to work immediately, or omit it to have the member join idle. A member keeps its own CLI session and accumulates context across rounds, so prefer inviting over a one-shot subagent_* delegation whenever the work expects follow-ups with the same agent — reserve one-shot delegations for self-contained tasks with no continuation. room_read lists the invitable providers and modes (it works before the session is a room too); the provider may be its id or the harness name (e.g. claude-code).",
|
|
43
12
|
parameters: {
|
|
44
13
|
provider: {
|
|
45
14
|
type: "string",
|
|
46
15
|
required: true,
|
|
47
|
-
description: "The
|
|
16
|
+
description: "The CLI to invite: a provider id from room_read, or the harness name / display name (claude-code, Claude Code, codex, kimi). An unknown one is rejected with the available ids."
|
|
48
17
|
},
|
|
49
18
|
name: {
|
|
50
19
|
type: "string",
|
|
51
20
|
required: true,
|
|
52
21
|
description: "The member's @-addressing name: unique in this room, no whitespace, no \"@\"."
|
|
53
22
|
},
|
|
23
|
+
role: {
|
|
24
|
+
type: "string",
|
|
25
|
+
description: "Short public role (≤30 chars, e.g. 代码审查 / 实现 / 测试): what the other members and the human see. Keep it a phrase; details go in instructions."
|
|
26
|
+
},
|
|
54
27
|
instructions: {
|
|
55
28
|
type: "string",
|
|
56
29
|
required: true,
|
|
57
|
-
description: "The member's
|
|
30
|
+
description: "The member's private instructions (responsibilities, constraints, output expectations). Only this member ever reads them."
|
|
58
31
|
},
|
|
59
32
|
firstTask: {
|
|
60
33
|
type: "string",
|
|
61
|
-
description: "Optional first task, dispatched to the member as soon as it joins."
|
|
34
|
+
description: "Optional first task, dispatched to the member as soon as it joins. Its result is reported back to you automatically — do not sleep or poll room_read for it."
|
|
35
|
+
},
|
|
36
|
+
note: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "Optional: what you will wait for before acting on the first task's result (e.g. \"wait until every invited member greeted\"). The room uses it to decide when to hand you the report."
|
|
62
39
|
},
|
|
63
40
|
cwd: {
|
|
64
41
|
type: "string",
|
|
65
42
|
description: "Optional working directory for the member (empty: inherits the room session's cwd)."
|
|
43
|
+
},
|
|
44
|
+
mode: {
|
|
45
|
+
type: "string",
|
|
46
|
+
description: "The member's dsh mode: a host agent preset id (e.g. dsh-gamedev, dsh-video). The member can then call that mode's plugin tools (and sees its skills) besides its own CLI tools. Omit it to keep this room's own mode — the usual choice; pass the mode the human asked for when they named one, or \"none\" for a member with only its own CLI tools. An unknown id is rejected with the available ids."
|
|
66
47
|
}
|
|
67
48
|
},
|
|
68
49
|
output: {
|
|
@@ -88,139 +69,23 @@ function roomInviteTool(backend) {
|
|
|
88
69
|
provider: args.provider,
|
|
89
70
|
name: args.name,
|
|
90
71
|
instructions: args.instructions,
|
|
72
|
+
...args.role === void 0 ? {} : { role: args.role },
|
|
91
73
|
...args.firstTask === void 0 ? {} : { firstTask: args.firstTask },
|
|
92
|
-
...args.
|
|
74
|
+
...args.note === void 0 ? {} : { note: args.note },
|
|
75
|
+
...args.cwd === void 0 ? {} : { cwd: args.cwd },
|
|
76
|
+
...args.mode === void 0 || args.mode.trim() === "" ? { inheritPreset: true } : args.mode.trim() === "none" ? {} : { preset: args.mode.trim() }
|
|
93
77
|
}, "agent");
|
|
94
78
|
if (!result.ok) {
|
|
95
|
-
const hint = result.error.code === "duplicate-name" ? " Pick a different name and retry." : result.error.code === "invalid-name" ? " Names must be non-empty and free of whitespace and \"@\"; retry with a valid name." : result.error.code === "local-agent-unavailable" ? " The local-agent delegation facade is not mounted; CLI members cannot join right now." : result.error.code === "unknown-provider" ? ` Unknown delegation provider "${result.error.provider}" (it must be the family's delegation provider id, not the harness's display name). Available: ${result.error.available.length === 0 ? "none (no harness with a delegation provider is registered)" : result.error.available.join(", ")}. Retry with one of the available providers.` : "";
|
|
79
|
+
const hint = result.error.code === "duplicate-name" ? " Pick a different name and retry." : result.error.code === "invalid-name" ? " Names must be non-empty and free of whitespace and \"@\"; retry with a valid name." : result.error.code === "role-too-long" ? " The role must be at most 30 characters; shorten it and move details into instructions." : result.error.code === "local-agent-unavailable" ? " The local-agent delegation facade is not mounted; CLI members cannot join right now." : result.error.code === "unknown-provider" ? ` Unknown delegation provider "${result.error.provider}" (it must be the family's delegation provider id, not the harness's display name). Available: ${result.error.available.length === 0 ? "none (no harness with a delegation provider is registered)" : result.error.available.join(", ")}. Retry with one of the available providers.` : result.error.code === "unknown-preset" ? ` Unknown mode "${result.error.preset}". Available: ${result.error.available.join(", ") || "none"}; or "none" for no mode.` : "";
|
|
96
80
|
return { text: `Could not invite "${args.name}": ${result.error.code}.${hint}` };
|
|
97
81
|
}
|
|
98
|
-
return { text: result.value.pendingFirstTask ? `Member ${result.value.name} joined the room and its first task was dispatched
|
|
82
|
+
return { text: result.value.pendingFirstTask ? `Member ${result.value.name} joined the room and its first task was dispatched.${modeNote(result.value.preset)}` : `Member ${result.value.name} joined the room (idle; @-address it to dispatch work).${modeNote(result.value.preset)}` };
|
|
99
83
|
}
|
|
100
84
|
});
|
|
101
85
|
}
|
|
102
|
-
/**
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
* opens is a public commitment indistinguishable from a human-added one.
|
|
106
|
-
* @param backend - the room service.
|
|
107
|
-
* @returns a registry-ready tool definition.
|
|
108
|
-
*/
|
|
109
|
-
function roomTaskTool(backend) {
|
|
110
|
-
return defineTool({
|
|
111
|
-
name: "room_task",
|
|
112
|
-
description: "Manage the current room's SHARED task board (only usable inside a room session). This board is public — every room member and the human sees these tasks, so writing here is a public commitment the room coordinates around; for your private work plan use your own todo tool instead. Actions: \"add\" (title + member — the roster name owning the task, use room_read to find your own or another member's name; optional blockedBy names the member the task waits on, display only) opens a pending task and returns its id; \"close\" (taskId) marks an open task done; \"update\" (taskId + a new title and/or blockedBy — null clears the wait) edits an open task. Errors answer with the roster or the open-task list so you can retry with a valid member name or task id.",
|
|
113
|
-
parameters: {
|
|
114
|
-
action: {
|
|
115
|
-
type: "string",
|
|
116
|
-
enum: [
|
|
117
|
-
"add",
|
|
118
|
-
"close",
|
|
119
|
-
"update"
|
|
120
|
-
],
|
|
121
|
-
required: true,
|
|
122
|
-
description: "add: open a task (title + member). close: mark a task done (taskId). update: edit title/blockedBy (taskId)."
|
|
123
|
-
},
|
|
124
|
-
title: {
|
|
125
|
-
type: "string",
|
|
126
|
-
description: "Task title. Required for add; optional new title for update."
|
|
127
|
-
},
|
|
128
|
-
member: {
|
|
129
|
-
type: "string",
|
|
130
|
-
description: "The roster name owning the task (required for add; read room_read for current names)."
|
|
131
|
-
},
|
|
132
|
-
taskId: {
|
|
133
|
-
type: "string",
|
|
134
|
-
description: "The task id (required for close/update; add's success text returns the new id)."
|
|
135
|
-
},
|
|
136
|
-
blockedBy: {
|
|
137
|
-
oneOf: [{ type: "string" }, { type: "null" }],
|
|
138
|
-
description: "The member this task waits on (must be on the roster; display only, never an automatic dispatch). Optional on add; on update, a string re-targets the wait and null clears it."
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
output: {
|
|
142
|
-
schema: {
|
|
143
|
-
type: "object",
|
|
144
|
-
additionalProperties: false,
|
|
145
|
-
properties: { text: {
|
|
146
|
-
type: "string",
|
|
147
|
-
required: true
|
|
148
|
-
} }
|
|
149
|
-
},
|
|
150
|
-
render: (_args, value) => [{
|
|
151
|
-
type: "text",
|
|
152
|
-
text: value.text
|
|
153
|
-
}]
|
|
154
|
-
},
|
|
155
|
-
isConcurrencySafe: () => true,
|
|
156
|
-
async execute(args, exec) {
|
|
157
|
-
const agent = exec.agent;
|
|
158
|
-
if (agent === void 0) return { text: "room_task requires a calling agent (exec.agent was undefined)." };
|
|
159
|
-
if (!isRoomLog(agent.session.snapshotEvents())) return { text: "The current session is not a room; room_task is only usable inside a room session." };
|
|
160
|
-
const sessionId = agent.session.id;
|
|
161
|
-
const ownership = await backend.getState({ sessionId });
|
|
162
|
-
if (ownership.ok && coordinatorMember(ownership.value)?.kind !== "main-agent") return { text: "Only the current coordinator may manage the shared room task board." };
|
|
163
|
-
/** The self-correcting roster suffix: the legal member names, for member-not-found. */
|
|
164
|
-
const rosterHint = async () => {
|
|
165
|
-
const state = await backend.getState({ sessionId });
|
|
166
|
-
if (!state.ok) return "";
|
|
167
|
-
const names = state.value.members.map((member) => member.name);
|
|
168
|
-
return names.length === 0 ? "" : ` The room roster is: ${names.join(", ")}. Retry with one of these names.`;
|
|
169
|
-
};
|
|
170
|
-
/** The self-correcting board suffix: the open tasks (id — title), for task-not-found. */
|
|
171
|
-
const openTasksHint = async () => {
|
|
172
|
-
const state = await backend.getState({ sessionId });
|
|
173
|
-
if (!state.ok) return "";
|
|
174
|
-
const open = state.value.tasks.filter((task) => task.status === "pending" || task.status === "in_progress");
|
|
175
|
-
if (open.length === 0) return " The board has no open tasks right now.";
|
|
176
|
-
return ` Open tasks: ${open.map((task) => `${task.id} — "${task.title}" (${task.member}, ${task.status})`).join("; ")}. Retry with one of these ids.`;
|
|
177
|
-
};
|
|
178
|
-
const failureText = async (code) => {
|
|
179
|
-
switch (code) {
|
|
180
|
-
case "member-not-found": return `Unknown member.${await rosterHint()}`;
|
|
181
|
-
case "empty-text": return "The title must be non-blank; retry with a real title.";
|
|
182
|
-
case "task-not-found": return `No task with that id.${await openTasksHint()}`;
|
|
183
|
-
case "task-closed": return "That task is already closed (done/cancelled); closed tasks take no further changes.";
|
|
184
|
-
case "nothing-to-update": return "update needs at least one field to change: a new title and/or blockedBy (null clears the wait).";
|
|
185
|
-
default: return `The room rejected the write (${code}).`;
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
switch (args.action) {
|
|
189
|
-
case "add": {
|
|
190
|
-
if (args.title === void 0 || args.member === void 0) return { text: "room_task add requires both title and member (the roster name owning the task; read room_read for current names)." };
|
|
191
|
-
if (args.blockedBy === null) return { text: "add takes no null blockedBy — simply omit blockedBy for an unblocked task." };
|
|
192
|
-
const result = await backend.addTask({
|
|
193
|
-
sessionId,
|
|
194
|
-
member: args.member,
|
|
195
|
-
title: args.title,
|
|
196
|
-
...args.blockedBy === void 0 ? {} : { blockedBy: args.blockedBy }
|
|
197
|
-
});
|
|
198
|
-
if (!result.ok) return { text: `Could not add the task: ${result.error.code}. ${await failureText(result.error.code)}` };
|
|
199
|
-
return { text: `Task "${args.title}" is now on ${args.member}'s lane of the shared room board (id: ${result.value.id}) — visible to every member and the human. Keep the id to update or close the task later.` };
|
|
200
|
-
}
|
|
201
|
-
case "close": {
|
|
202
|
-
if (args.taskId === void 0) return { text: `room_task close requires taskId.${await openTasksHint()}` };
|
|
203
|
-
const result = await backend.closeTask({
|
|
204
|
-
sessionId,
|
|
205
|
-
taskId: args.taskId
|
|
206
|
-
});
|
|
207
|
-
if (!result.ok) return { text: `Could not close the task: ${result.error.code}. ${await failureText(result.error.code)}` };
|
|
208
|
-
return { text: `Task ${result.value.id} is done — the shared board shows it closed.` };
|
|
209
|
-
}
|
|
210
|
-
case "update": {
|
|
211
|
-
if (args.taskId === void 0) return { text: `room_task update requires taskId.${await openTasksHint()}` };
|
|
212
|
-
const result = await backend.updateTask({
|
|
213
|
-
sessionId,
|
|
214
|
-
taskId: args.taskId,
|
|
215
|
-
...args.title === void 0 ? {} : { title: args.title },
|
|
216
|
-
...args.blockedBy === void 0 ? {} : { blockedBy: args.blockedBy }
|
|
217
|
-
});
|
|
218
|
-
if (!result.ok) return { text: `Could not update the task: ${result.error.code}. ${await failureText(result.error.code)}` };
|
|
219
|
-
return { text: `Task ${result.value.id} updated on the shared room board.` };
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
});
|
|
86
|
+
/** The invite receipt's mode line, so the caller can tell the human which mode the member runs. */
|
|
87
|
+
function modeNote(preset) {
|
|
88
|
+
return preset === void 0 ? " Mode: none (its own CLI tools only)." : ` Mode: ${preset}.`;
|
|
224
89
|
}
|
|
225
90
|
/**
|
|
226
91
|
* Build the room_message tool definition bound to the room service: the main
|
|
@@ -233,7 +98,7 @@ function roomTaskTool(backend) {
|
|
|
233
98
|
function roomMessageTool(backend) {
|
|
234
99
|
return defineTool({
|
|
235
100
|
name: "room_message",
|
|
236
|
-
description: "
|
|
101
|
+
description: "Send a message to another member of the current room (works in any session — it promotes the session into a room if it is not one yet). A member is an independent session: the message runs asynchronously in its own session. kind \"task\" (default) hands it work — its final reply is reported back to you automatically, quoting the message id, so do not poll; kind \"notify\" is an FYI that is never reported back. After sending, end your turn: never sleep or poll for the result (room_read included) — the report arrives on its own. Writing \"@name\" in a reply reaches nobody; only this tool does. Pass inReplyTo with a message id (e.g. m12) when answering one. The member argument is a roster name (read room_read for current names); an unknown name is rejected with the live roster, so retry with one of those.",
|
|
237
102
|
parameters: {
|
|
238
103
|
member: {
|
|
239
104
|
type: "string",
|
|
@@ -243,7 +108,24 @@ function roomMessageTool(backend) {
|
|
|
243
108
|
text: {
|
|
244
109
|
type: "string",
|
|
245
110
|
required: true,
|
|
246
|
-
description: "The message text the member receives
|
|
111
|
+
description: "The message text the member receives."
|
|
112
|
+
},
|
|
113
|
+
kind: {
|
|
114
|
+
type: "string",
|
|
115
|
+
enum: ["task", "notify"],
|
|
116
|
+
description: "task (default): its reply is reported back to you. notify: FYI, no report."
|
|
117
|
+
},
|
|
118
|
+
inReplyTo: {
|
|
119
|
+
type: "string",
|
|
120
|
+
description: "Optional id of the message this answers (e.g. m12)."
|
|
121
|
+
},
|
|
122
|
+
task: {
|
|
123
|
+
type: "string",
|
|
124
|
+
description: "Optional: which task this belongs to — \"new\" or a task number from room_read (e.g. \"2\"). Use it when the human's latest message was filed under the wrong task: it re-files that message too. Omit to stay in the current task."
|
|
125
|
+
},
|
|
126
|
+
note: {
|
|
127
|
+
type: "string",
|
|
128
|
+
description: "Optional: what you will wait for before acting on this result, in your own words (e.g. \"wait until all three greeted, then tell the user once\" / \"hand it to claude for review as soon as it is done\"). The room uses it to decide when to hand you the report."
|
|
247
129
|
}
|
|
248
130
|
},
|
|
249
131
|
output: {
|
|
@@ -268,7 +150,11 @@ function roomMessageTool(backend) {
|
|
|
268
150
|
const result = await backend.messageMember({
|
|
269
151
|
sessionId,
|
|
270
152
|
member: args.member,
|
|
271
|
-
text: args.text
|
|
153
|
+
text: args.text,
|
|
154
|
+
...args.kind === void 0 ? {} : { kind: args.kind },
|
|
155
|
+
...args.inReplyTo === void 0 ? {} : { inReplyTo: args.inReplyTo },
|
|
156
|
+
...args.note === void 0 ? {} : { note: args.note },
|
|
157
|
+
...args.task === void 0 ? {} : { task: args.task }
|
|
272
158
|
});
|
|
273
159
|
if (!result.ok) {
|
|
274
160
|
if (result.error.code === "member-not-found") {
|
|
@@ -277,10 +163,14 @@ function roomMessageTool(backend) {
|
|
|
277
163
|
const hint = names.length === 0 ? "" : ` The room roster is: ${names.join(", ")}. Retry with one of these names.`;
|
|
278
164
|
return { text: `Could not message "${args.member}": unknown member.${hint}` };
|
|
279
165
|
}
|
|
166
|
+
if (result.error.code === "self-message") return { text: "You cannot message yourself; pick another member." };
|
|
167
|
+
if (result.error.code === "unknown-task") return { text: `No task "${args.task}" in this room; pass "new" or a task number from room_read.` };
|
|
280
168
|
if (result.error.code === "empty-text") return { text: "The message text must be non-blank; retry with real content." };
|
|
281
169
|
return { text: `Could not message "${args.member}": ${result.error.code}.` };
|
|
282
170
|
}
|
|
283
|
-
|
|
171
|
+
const value = result.value;
|
|
172
|
+
if (value.held !== void 0) return { text: value.held === "paused" ? `Held: the room is paused; the message to ${value.member} is delivered when the human resumes it.` : value.held === "hop-limit" ? `Held: this chain of messages reached the room's hop limit; the human decides whether ${value.member} gets it.` : `Held: the room asks the human to confirm member messages; ${value.member} gets it once confirmed.` };
|
|
173
|
+
return { text: args.kind === "notify" ? `Sent ${value.messageId} to ${value.member} as an FYI; no report will come back.` : `Sent ${value.messageId} to ${value.member}. It runs asynchronously; its final reply comes back to you automatically as a report citing this id. Do not sleep, wait, or poll room_read for it — end your turn; the human already sees the member's reply in the room, so do not repeat it when the report arrives.` };
|
|
284
174
|
}
|
|
285
175
|
});
|
|
286
176
|
}
|
|
@@ -288,7 +178,7 @@ function roomMessageTool(backend) {
|
|
|
288
178
|
function roomReadTool(backend) {
|
|
289
179
|
return defineTool({
|
|
290
180
|
name: "room_read",
|
|
291
|
-
description: "Read the current room roster, coordinator, deliveries, recent outcomes and available harness providers. Reading does not wake any member.",
|
|
181
|
+
description: "Read the current room: roster with each member's role, the coordinator, the tasks with their numbers (for the task parameter), deliveries, recent outcomes and available harness providers. In a session that is not a room yet it returns the invitable providers and modes instead. Reading does not wake any member. Use it to look around, not to wait for a result — reports arrive on their own.",
|
|
292
182
|
parameters: {},
|
|
293
183
|
output: {
|
|
294
184
|
schema: {
|
|
@@ -350,6 +240,62 @@ function roomPlanTool(backend) {
|
|
|
350
240
|
}
|
|
351
241
|
});
|
|
352
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Build the room_help tool definition bound to the room service.
|
|
245
|
+
* @param backend - the room service.
|
|
246
|
+
* @returns a registry-ready tool definition.
|
|
247
|
+
*/
|
|
248
|
+
function roomHelpTool(backend) {
|
|
249
|
+
return defineTool({
|
|
250
|
+
name: "room_help",
|
|
251
|
+
description: "Ask another session — outside this room — for help: typically the session that built the thing you are stuck on, which still has the whole context. The helper keeps working in its own session (if it is busy, your request waits in its queue) and its final answer plus a short handoff comes back to you on its own, so end your turn after asking; never poll. Name the session by its title, its id, or the @ mention the human wrote. A session that is another room hands the request to its coordinator, or to the member you name (a mention labelled 「成员(房间)」 names one). The first ask of a session the human did not @ in this room waits for the human's approval. To answer the helper's question or ask it more, call again with the help id and no session.",
|
|
252
|
+
parameters: {
|
|
253
|
+
session: {
|
|
254
|
+
type: "string",
|
|
255
|
+
description: "The session to ask (title, id, or @ mention). Omit when continuing a thread with help."
|
|
256
|
+
},
|
|
257
|
+
member: {
|
|
258
|
+
type: "string",
|
|
259
|
+
description: "When the session is another room: the member of that room to ask. Omit to let its coordinator decide."
|
|
260
|
+
},
|
|
261
|
+
help: {
|
|
262
|
+
type: "string",
|
|
263
|
+
description: "The help id of an existing thread, to answer its question or follow up."
|
|
264
|
+
},
|
|
265
|
+
text: {
|
|
266
|
+
type: "string",
|
|
267
|
+
required: true,
|
|
268
|
+
description: "What you need, self-contained: the helper does not see this room. Include the error, what you tried, where things are."
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
output: {
|
|
272
|
+
schema: {
|
|
273
|
+
type: "object",
|
|
274
|
+
additionalProperties: false,
|
|
275
|
+
properties: { text: {
|
|
276
|
+
type: "string",
|
|
277
|
+
required: true
|
|
278
|
+
} }
|
|
279
|
+
},
|
|
280
|
+
render: (_args, value) => [{
|
|
281
|
+
type: "text",
|
|
282
|
+
text: value.text
|
|
283
|
+
}]
|
|
284
|
+
},
|
|
285
|
+
isConcurrencySafe: () => true,
|
|
286
|
+
async execute(args, exec) {
|
|
287
|
+
const agent = exec.agent;
|
|
288
|
+
if (agent === void 0) return { text: "room_help requires a calling agent (exec.agent was undefined)." };
|
|
289
|
+
return { text: await backend.askHelp({
|
|
290
|
+
sessionId: agent.session.id,
|
|
291
|
+
text: args.text,
|
|
292
|
+
...args.session === void 0 ? {} : { session: args.session },
|
|
293
|
+
...args.member === void 0 ? {} : { member: args.member },
|
|
294
|
+
...args.help === void 0 ? {} : { help: args.help }
|
|
295
|
+
}, agent) };
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
353
299
|
//#endregion
|
|
354
300
|
//#region lib/types/tool.js
|
|
355
301
|
const PACKAGE_NAME = "@khorsheed/dsh-room";
|
|
@@ -394,8 +340,8 @@ function apply(ctx) {
|
|
|
394
340
|
if (typeof service.commandPlan === "function") toolsCtx.effect(() => toolsCtx.tools.register(definePluginTool(roomPlanTool(service))), "room-tool: room_plan tool");
|
|
395
341
|
if (typeof service.readRoomContext === "function") toolsCtx.effect(() => toolsCtx.tools.register(definePluginTool(roomReadTool(service))), "room-tool: room_read tool");
|
|
396
342
|
toolsCtx.effect(() => toolsCtx.tools.register(definePluginTool(roomInviteTool(service))), "room-tool: room_invite tool");
|
|
397
|
-
toolsCtx.effect(() => toolsCtx.tools.register(definePluginTool(roomTaskTool(service))), "room-tool: room_task tool");
|
|
398
343
|
toolsCtx.effect(() => toolsCtx.tools.register(definePluginTool(roomMessageTool(service))), "room-tool: room_message tool");
|
|
344
|
+
if (typeof service.askHelp === "function") toolsCtx.effect(() => toolsCtx.tools.register(definePluginTool(roomHelpTool(service))), "room-tool: room_help tool");
|
|
399
345
|
});
|
|
400
346
|
}
|
|
401
347
|
//#endregion
|