@yankeguo/dsh-tool-devlead 0.1.0 → 0.1.1
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/lib/index.js +47 -26
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
|
5
5
|
|
|
6
6
|
// packages/tool/src/arguments.ts
|
|
7
7
|
import { isAbsolute } from "node:path";
|
|
8
|
+
import { HarnessError } from "@deepseek-ai/dsh-llm";
|
|
8
9
|
var DevLeadToolInputError = class extends Error {
|
|
9
10
|
/** Stable code from the core service's error vocabulary. */
|
|
10
11
|
code = "DEVLEAD_INVALID_INPUT";
|
|
@@ -17,7 +18,9 @@ var DevLeadToolInputError = class extends Error {
|
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
20
|
function requireAgent(agent, tool) {
|
|
20
|
-
if (agent === void 0)
|
|
21
|
+
if (agent === void 0) {
|
|
22
|
+
throw new HarnessError(`${tool} requires a calling Agent`, "DEVLEAD_AGENT_NOT_LIVE");
|
|
23
|
+
}
|
|
21
24
|
return agent;
|
|
22
25
|
}
|
|
23
26
|
function requireSessionRef(value) {
|
|
@@ -73,12 +76,12 @@ function createSessionRequest(args) {
|
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
// packages/tool/src/errors.ts
|
|
76
|
-
import { HarnessError } from "@deepseek-ai/dsh-llm";
|
|
79
|
+
import { HarnessError as HarnessError2 } from "@deepseek-ai/dsh-llm";
|
|
77
80
|
import { isDevLeadError } from "@yankeguo/dsh-devlead";
|
|
78
81
|
function translateToolError(error) {
|
|
79
|
-
if (error instanceof
|
|
80
|
-
if (error instanceof DevLeadToolInputError) return new
|
|
81
|
-
if (isDevLeadError(error)) return new
|
|
82
|
+
if (error instanceof HarnessError2) return error;
|
|
83
|
+
if (error instanceof DevLeadToolInputError) return new HarnessError2(error.message, error.code);
|
|
84
|
+
if (isDevLeadError(error)) return new HarnessError2(error.message, error.code);
|
|
82
85
|
return error;
|
|
83
86
|
}
|
|
84
87
|
async function runTool(body) {
|
|
@@ -95,7 +98,7 @@ var DEVLEAD_POLICY = `DevLead mode is enabled in this session. You are the Dev L
|
|
|
95
98
|
Workflow:
|
|
96
99
|
- List known Workspaces with devlead_list_workspaces. Register a repository directory with devlead_use_workspace using an absolute path; create defaults to true, so a missing directory is created and registering an already-registered path is idempotent.
|
|
97
100
|
- Dispatch work with devlead_create_session: pass workspace (id or registered path; omit it to use this session's directory) and a self-contained prompt, plus an optional title and Agent preset. The new Session is watched by default and runs independently; it does not see this conversation, so restate every fact it needs.
|
|
98
|
-
- Inspect progress with devlead_list_sessions and devlead_get_session.
|
|
101
|
+
- Inspect progress with devlead_list_sessions and devlead_get_session. The listing carries live, running, watched, archived, and lastTurn; the single-Session detail adds lastTransition, lastError, and lastAssistant when the Host can read the log. Read those fields rather than guessing.
|
|
99
102
|
- Continue a Session with devlead_prompt_session: the prompt is admitted as a user message attributed to you, and a cold Session is resumed first. Archived Sessions are rejected.
|
|
100
103
|
- Manage the watch set with devlead_watch_session. Only watched Sessions produce notifications, so unwatch work you no longer need and do not let the set grow without purpose.
|
|
101
104
|
|
|
@@ -106,6 +109,14 @@ Reporting: before you finish a turn, tell the human which Workspaces and Session
|
|
|
106
109
|
Only the human can turn DevLead mode on or off (with /devlead on or /devlead off, or the status strip switch); no tool can enable it, so never try to.`;
|
|
107
110
|
|
|
108
111
|
// packages/tool/src/presentation.ts
|
|
112
|
+
function firstText(...values) {
|
|
113
|
+
for (const value of values) {
|
|
114
|
+
if (value === void 0) continue;
|
|
115
|
+
const trimmed = value.trim();
|
|
116
|
+
if (trimmed.length > 0) return trimmed;
|
|
117
|
+
}
|
|
118
|
+
return void 0;
|
|
119
|
+
}
|
|
109
120
|
function present(title, kind, rawInput) {
|
|
110
121
|
return { card: "generic", title, kind, ...rawInput === void 0 ? {} : { rawInput } };
|
|
111
122
|
}
|
|
@@ -113,23 +124,23 @@ function presentListWorkspacesCall() {
|
|
|
113
124
|
return present("List DevLead workspaces", "search");
|
|
114
125
|
}
|
|
115
126
|
function presentUseWorkspaceCall(args) {
|
|
116
|
-
return present("Register DevLead workspace", "other", args.path);
|
|
127
|
+
return present("Register DevLead workspace", "other", firstText(args.path));
|
|
117
128
|
}
|
|
118
129
|
function presentListSessionsCall(args) {
|
|
119
|
-
return present("List DevLead sessions", "search", args.workspace);
|
|
130
|
+
return present("List DevLead sessions", "search", firstText(args.workspace));
|
|
120
131
|
}
|
|
121
132
|
function presentCreateSessionCall(args) {
|
|
122
|
-
return present("Create DevLead session", "other", args.title
|
|
133
|
+
return present("Create DevLead session", "other", firstText(args.title, args.workspace));
|
|
123
134
|
}
|
|
124
135
|
function presentGetSessionCall(args) {
|
|
125
|
-
return present("Read DevLead session", "read", args.session);
|
|
136
|
+
return present("Read DevLead session", "read", firstText(args.session));
|
|
126
137
|
}
|
|
127
138
|
function presentPromptSessionCall(args) {
|
|
128
|
-
return present("Prompt DevLead session", "other", args.session);
|
|
139
|
+
return present("Prompt DevLead session", "other", firstText(args.session));
|
|
129
140
|
}
|
|
130
141
|
function presentWatchSessionCall(args) {
|
|
131
142
|
const title = args.watching ? "Watch DevLead session" : "Unwatch DevLead session";
|
|
132
|
-
return present(title, "other", args.session);
|
|
143
|
+
return present(title, "other", firstText(args.session));
|
|
133
144
|
}
|
|
134
145
|
function presentNotificationsCall(args) {
|
|
135
146
|
return present("Read DevLead notifications", "read", args.limit);
|
|
@@ -173,11 +184,15 @@ var SESSION_VIEW_SCHEMA = {
|
|
|
173
184
|
workspaceId: { type: "string", description: "Accounting Workspace id, when the Session belongs to one." },
|
|
174
185
|
workspaceTitle: { type: "string", description: "Accounting Workspace title, when the Session belongs to one." },
|
|
175
186
|
cwd: { type: "string", description: "Recorded working directory, when the header carries one." },
|
|
176
|
-
live: {
|
|
187
|
+
live: {
|
|
188
|
+
type: "boolean",
|
|
189
|
+
required: true,
|
|
190
|
+
description: "Whether the Session is live in the Host store, with an Agent or an attached Session."
|
|
191
|
+
},
|
|
177
192
|
running: { type: "boolean", required: true, description: "Whether the Session Agent is inside a turn." },
|
|
178
193
|
watched: { type: "boolean", required: true, description: "Whether this lead watches the Session." },
|
|
179
194
|
archived: { type: "boolean", required: true, description: "Whether the Workspace registry lists the Session as archived." },
|
|
180
|
-
lastTurn: { type: "integer", description: "Latest
|
|
195
|
+
lastTurn: { type: "integer", description: "Latest turn number observed on the Session, when known." },
|
|
181
196
|
pendingInputs: { type: "integer", description: "Pending inbox messages, when the Agent is live." },
|
|
182
197
|
lastTransition: {
|
|
183
198
|
type: "string",
|
|
@@ -205,7 +220,7 @@ var NOTIFICATION_SCHEMA = {
|
|
|
205
220
|
},
|
|
206
221
|
turn: { type: "integer", required: true, description: "1-based turn number that settled." },
|
|
207
222
|
at: { type: "integer", required: true, description: "Epoch milliseconds when the Host observed the transition." },
|
|
208
|
-
error: { type: "string", description: "Compact single-line failure excerpt
|
|
223
|
+
error: { type: "string", description: "Compact single-line failure excerpt when the settled turn failed." },
|
|
209
224
|
summary: { type: "string", description: "Compact excerpt of the latest assistant message before the turn settled." }
|
|
210
225
|
}
|
|
211
226
|
};
|
|
@@ -346,10 +361,10 @@ var name = "tool-devlead";
|
|
|
346
361
|
var inject = ["devLead", "tools", "systemPrompt"];
|
|
347
362
|
var DEFAULT_NOTIFICATIONS_LIMIT = 20;
|
|
348
363
|
var LIST_WORKSPACES_DESCRIPTION = "List every registered DSH Workspace: its title, canonical directory path, live directory status, and the Sessions the registry accounts to it. Use it before registering a new Workspace or dispatching a Session.";
|
|
349
|
-
var USE_WORKSPACE_DESCRIPTION = "Register a repository directory as a DSH Workspace so Sessions can be created in it. The path must be absolute; an already-registered path is reused, and when the directory is missing it is created first unless create is false.";
|
|
350
|
-
var LIST_SESSIONS_DESCRIPTION = "List DSH Sessions this DevLead Session can address
|
|
364
|
+
var USE_WORKSPACE_DESCRIPTION = "Register a repository directory as a DSH Workspace so Sessions can be created in it. The path must be absolute; an already-registered path is reused with its existing title, and when the directory is missing it is created first unless create is false.";
|
|
365
|
+
var LIST_SESSIONS_DESCRIPTION = "List DSH Sessions this DevLead Session can address: whether each is live, running, watched, or archived, plus latest-turn facts when the Host knows them. Watched and running rows come first. Optionally restrict to one Workspace or to the watched set; use devlead_get_session for a log detail with the latest turn outcome and assistant excerpt.";
|
|
351
366
|
var CREATE_SESSION_DESCRIPTION = "Create an ordinary DSH Session in a Workspace and optionally start it with a prompt. The Session is a real Session the human can open and take over, not a subagent. It is watched by default, so this lead is notified when its turns settle.";
|
|
352
|
-
var GET_SESSION_DESCRIPTION = "Read one Session in detail: whether it is live and running, the latest turn number and outcome
|
|
367
|
+
var GET_SESSION_DESCRIPTION = "Read one Session in detail: whether it is live and running, whether it is archived, and, when the Host can read the Session log, the latest turn number and outcome plus the latest error and assistant excerpts. Address it by full id or unique id prefix.";
|
|
353
368
|
var PROMPT_SESSION_DESCRIPTION = "Admit a follow-up prompt into an existing Session, resuming a cold Session first. The prompt is attributed to this DevLead Session. Archived Sessions are rejected. The Session is watched by default.";
|
|
354
369
|
var WATCH_SESSION_DESCRIPTION = "Add one Session to, or remove it from, this DevLead Session's watch set. Only watched Sessions produce wake-up notifications, so unwatch work that no longer needs attention. A Session cannot watch itself.";
|
|
355
370
|
var NOTIFICATIONS_DESCRIPTION = "Read the retained notification digest of this DevLead Session together with the current watch set. Each entry names a watched Session whose turn settled and how it ended. The digest is newest last.";
|
|
@@ -364,7 +379,7 @@ function apply(ctx) {
|
|
|
364
379
|
description: LIST_WORKSPACES_DESCRIPTION,
|
|
365
380
|
parameters: {},
|
|
366
381
|
output: LIST_WORKSPACES_OUTPUT,
|
|
367
|
-
presentCall:
|
|
382
|
+
presentCall: presentListWorkspacesCall,
|
|
368
383
|
execute(_args, exec) {
|
|
369
384
|
return runTool(async () => ({
|
|
370
385
|
workspaces: (await ctx.devLead.listWorkspaces(exec.signal)).map(workspaceValue)
|
|
@@ -382,7 +397,7 @@ function apply(ctx) {
|
|
|
382
397
|
},
|
|
383
398
|
title: {
|
|
384
399
|
type: "string",
|
|
385
|
-
description: "Optional display title for
|
|
400
|
+
description: "Optional display title for a newly registered Workspace; an already-registered path keeps its current title."
|
|
386
401
|
},
|
|
387
402
|
create: {
|
|
388
403
|
type: "boolean",
|
|
@@ -418,7 +433,7 @@ function apply(ctx) {
|
|
|
418
433
|
},
|
|
419
434
|
limit: {
|
|
420
435
|
type: "integer",
|
|
421
|
-
description: "Maximum number of Session rows to return."
|
|
436
|
+
description: "Maximum number of Session rows to return; the Host may return fewer when its listing cap is lower."
|
|
422
437
|
}
|
|
423
438
|
},
|
|
424
439
|
output: LIST_SESSIONS_OUTPUT,
|
|
@@ -431,8 +446,9 @@ function apply(ctx) {
|
|
|
431
446
|
const sessions = await ctx.devLead.listSessions(agent, {
|
|
432
447
|
...workspace === void 0 ? {} : { workspace },
|
|
433
448
|
...args.watched_only === void 0 ? {} : { watchedOnly: args.watched_only },
|
|
434
|
-
...limit === void 0 ? {} : { limit }
|
|
435
|
-
|
|
449
|
+
...limit === void 0 ? {} : { limit },
|
|
450
|
+
signal: exec.signal
|
|
451
|
+
});
|
|
436
452
|
return {
|
|
437
453
|
sessions: sessions.map(sessionValue),
|
|
438
454
|
watched: watchedIds(ctx.devLead.view(agent))
|
|
@@ -470,7 +486,7 @@ function apply(ctx) {
|
|
|
470
486
|
execute(args, exec) {
|
|
471
487
|
return runTool(async () => {
|
|
472
488
|
const agent = requireAgent(exec.agent, "devlead_create_session");
|
|
473
|
-
const created = await ctx.devLead.createSession(agent, createSessionRequest(args));
|
|
489
|
+
const created = await ctx.devLead.createSession(agent, createSessionRequest(args), exec.signal);
|
|
474
490
|
return createdSessionValue(created);
|
|
475
491
|
});
|
|
476
492
|
}
|
|
@@ -523,7 +539,7 @@ function apply(ctx) {
|
|
|
523
539
|
agent,
|
|
524
540
|
requireSessionRef(args.session),
|
|
525
541
|
requirePrompt(args.prompt),
|
|
526
|
-
{ watch: args.watch ?? true }
|
|
542
|
+
{ watch: args.watch ?? true, signal: exec.signal }
|
|
527
543
|
);
|
|
528
544
|
return promptedSessionValue(prompted);
|
|
529
545
|
});
|
|
@@ -549,7 +565,12 @@ function apply(ctx) {
|
|
|
549
565
|
execute(args, exec) {
|
|
550
566
|
return runTool(async () => {
|
|
551
567
|
const agent = requireAgent(exec.agent, "devlead_watch_session");
|
|
552
|
-
const mutation = await ctx.devLead.watchSession(
|
|
568
|
+
const mutation = await ctx.devLead.watchSession(
|
|
569
|
+
agent,
|
|
570
|
+
requireSessionRef(args.session),
|
|
571
|
+
args.watching,
|
|
572
|
+
exec.signal
|
|
573
|
+
);
|
|
553
574
|
return watchMutationValue(mutation);
|
|
554
575
|
});
|
|
555
576
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yankeguo/dsh-tool-devlead",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Model-facing DevLead tools: register and list DSH Workspaces, create and steer ordinary Sessions, read session status, watch state changes, and read the lead's notification feed.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"@deepseek-ai/schemastery": "~3.19.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@yankeguo/dsh-devlead": "0.1.
|
|
26
|
-
"@yankeguo/dsh-devlead-protocol": "0.1.
|
|
25
|
+
"@yankeguo/dsh-devlead": "0.1.1",
|
|
26
|
+
"@yankeguo/dsh-devlead-protocol": "0.1.1"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"dsh": ">=0.2.2-rc.1 <0.3.0"
|