@yankeguo/dsh-devlead 0.2.6 → 0.3.0-rc.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/README.md +15 -4
- package/lib/index.js +336 -67
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,11 +11,22 @@ Session holds it; `off`/`reset` release immediately, archiving or deleting the h
|
|
|
11
11
|
releasable, and a restart/rehydration reconciles historical duplicates and keeps one Session.
|
|
12
12
|
Admission is serialized in-process and scans live projections plus the durable corpus.
|
|
13
13
|
|
|
14
|
+
`sessionQueuedInputs(agent, sessionId, signal?)` projects a live Session's pending inbox inputs
|
|
15
|
+
(id, boundary, source kind/form/sender, bounded text excerpt, enqueue instant from the durable
|
|
16
|
+
`agent/inbox/spliced` log); a cold target reports undefined. `retractQueuedInput(agent, sessionId,
|
|
17
|
+
inputId, signal?)` withdraws one queued input this lead authored (devlead relay with its own
|
|
18
|
+
sender id) through the Host's per-message `inbox.remove`; other producers' inputs are refused,
|
|
19
|
+
an already-gone input is idempotent (`retracted: false`), and the target must be live and not the
|
|
20
|
+
lead itself. `promptSession` accepts `interruptInbox: 'clear-all' | 'keep' | 'clear-own'`
|
|
21
|
+
(default `clear-all`): because the Host stop providers always clear the inbox, retention is a
|
|
22
|
+
snapshot before the stop and a restore of the same identified messages after it, ahead of the
|
|
23
|
+
replacement prompt; the result reports `retainedInputs` when a retention policy ran.
|
|
24
|
+
|
|
14
25
|
`reportProgress(agent, { message, kind?, summary? }, signal?)` lets a watched, non-DevLead Session
|
|
15
26
|
send a one-way report to its unique active lead. It resolves the active lead that watches it through
|
|
16
|
-
the hub's reverse index, validates size/kind, deduplicates identical
|
|
17
|
-
distinct reports per turn (`DEVLEAD_REPORT_RATE_LIMITED`
|
|
18
|
-
`DEVLEAD_NOT_SUPERVISED`. The receipt is `{ report, durable, queued, warning? }`.
|
|
27
|
+
the hub's reverse index, validates size/kind, deduplicates identical kind+message pairs within a turn, enforces four
|
|
28
|
+
distinct non-question reports per turn (`DEVLEAD_REPORT_RATE_LIMITED`; `question` reports are exempt
|
|
29
|
+
from that budget), and otherwise refuses with `DEVLEAD_NOT_SUPERVISED`. The receipt is `{ report, durable, queued, warning? }`.
|
|
19
30
|
|
|
20
31
|
The report is first written to a durable outbox (`devlead_report_outbox` over the optional
|
|
21
32
|
`storageDomain` KV facility), then a `plugin:devlead/report` receipt is appended to the lead's
|
|
@@ -37,7 +48,7 @@ dsh plugin --profile desktop add @yankeguo/dsh-devlead-bundle
|
|
|
37
48
|
|
|
38
49
|
## Requirements
|
|
39
50
|
|
|
40
|
-
- DSH `0.2.2-rc.1`–`0.2.2-rc.
|
|
51
|
+
- DSH `0.2.2-rc.1`–`0.2.2-rc.5` (the package declares `engines.dsh: >=0.2.2-rc.1 <0.3.0`; this checkout's devDependencies pin rc.1 for the oldest-API typecheck).
|
|
41
52
|
- Peer services `agents`, `sessions`, `sessionProjections` (provided by the default `dsh-base`
|
|
42
53
|
composition).
|
|
43
54
|
- Optional, probed at call time: `workspaceRegistry`, `sessionController`, `sessionTitle`,
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __export = (target, all) => {
|
|
|
9
9
|
import { mkdir } from "node:fs/promises";
|
|
10
10
|
import { Service } from "@deepseek-ai/cordis";
|
|
11
11
|
import z2 from "@deepseek-ai/schemastery";
|
|
12
|
-
import { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
|
|
12
|
+
import { MessageId, ReasoningEffortId } from "@deepseek-ai/dsh-llm";
|
|
13
13
|
import { appendPluginRecord as appendPluginRecord2 } from "@deepseek-ai/dsh-session";
|
|
14
14
|
import { SessionId as toSessionId3 } from "@deepseek-ai/dsh-session";
|
|
15
15
|
import {
|
|
@@ -114,8 +114,9 @@ function devLeadReport(input) {
|
|
|
114
114
|
const title = input.senderSessionTitle === void 0 ? void 0 : excerptLine(input.senderSessionTitle, DEVLEAD_ERROR_EXCERPT_MAX);
|
|
115
115
|
const summary = input.summary === void 0 ? void 0 : excerptLine(input.summary, DEVLEAD_REPORT_SUMMARY_MAX);
|
|
116
116
|
const workspaceTitle = input.senderWorkspaceTitle === void 0 ? void 0 : excerptLine(input.senderWorkspaceTitle, DEVLEAD_ERROR_EXCERPT_MAX);
|
|
117
|
+
const turn = Number.isSafeInteger(input.turn) && input.turn >= 0 ? input.turn : 0;
|
|
117
118
|
return {
|
|
118
|
-
id: devLeadReportId(input.senderSessionId,
|
|
119
|
+
id: devLeadReportId(input.senderSessionId, turn, input.kind, message),
|
|
119
120
|
kind: input.kind,
|
|
120
121
|
message,
|
|
121
122
|
...summary === void 0 ? {} : { summary },
|
|
@@ -124,7 +125,7 @@ function devLeadReport(input) {
|
|
|
124
125
|
...input.senderWorkspaceId === void 0 ? {} : { senderWorkspaceId: input.senderWorkspaceId },
|
|
125
126
|
...workspaceTitle === void 0 ? {} : { senderWorkspaceTitle: workspaceTitle },
|
|
126
127
|
leadSessionId: input.leadSessionId,
|
|
127
|
-
turn
|
|
128
|
+
turn,
|
|
128
129
|
at: representableInstant(input.at, Date.now())
|
|
129
130
|
};
|
|
130
131
|
}
|
|
@@ -343,7 +344,7 @@ function assistantExcerpt(blocks) {
|
|
|
343
344
|
return excerptLine(text, DEVLEAD_ERROR_EXCERPT_MAX);
|
|
344
345
|
}
|
|
345
346
|
|
|
346
|
-
// packages/devlead/src/
|
|
347
|
+
// packages/devlead/src/normalize.ts
|
|
347
348
|
function stringField(value) {
|
|
348
349
|
return typeof value === "string" ? value : "";
|
|
349
350
|
}
|
|
@@ -353,6 +354,8 @@ function recordOf(value) {
|
|
|
353
354
|
function itemsOf(value) {
|
|
354
355
|
return Array.isArray(value) ? value : [];
|
|
355
356
|
}
|
|
357
|
+
|
|
358
|
+
// packages/devlead/src/dispatch.ts
|
|
356
359
|
function modelViewOf(value) {
|
|
357
360
|
const record2 = recordOf(value);
|
|
358
361
|
if (record2 === void 0) return void 0;
|
|
@@ -475,6 +478,89 @@ function agentTeamsCapabilityOf(ctx) {
|
|
|
475
478
|
return candidate;
|
|
476
479
|
}
|
|
477
480
|
|
|
481
|
+
// packages/devlead/src/inbox.ts
|
|
482
|
+
import { DEVLEAD_ERROR_EXCERPT_MAX as DEVLEAD_ERROR_EXCERPT_MAX2, DEVLEAD_MESSAGE_KIND as DEVLEAD_MESSAGE_KIND2, excerptLine as excerptLine2 } from "@yankeguo/dsh-devlead-protocol";
|
|
483
|
+
function sourceString(source, key) {
|
|
484
|
+
const value = source[key];
|
|
485
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
486
|
+
}
|
|
487
|
+
function sourceOf(message) {
|
|
488
|
+
const source = message.source;
|
|
489
|
+
return typeof source === "object" && source !== null && !Array.isArray(source) ? source : {};
|
|
490
|
+
}
|
|
491
|
+
function isOwnRelay(message, leadSessionId) {
|
|
492
|
+
const source = sourceOf(message);
|
|
493
|
+
return source.kind === DEVLEAD_MESSAGE_KIND2 && source.form === "relay" && source.senderSessionId === leadSessionId;
|
|
494
|
+
}
|
|
495
|
+
function locatedInputs(agent) {
|
|
496
|
+
return [
|
|
497
|
+
...agent.inbox.nextTurn.map((message) => ({ boundary: "next-turn", message })),
|
|
498
|
+
...agent.inbox.nextStep.map((message) => ({ boundary: "next-step", message }))
|
|
499
|
+
];
|
|
500
|
+
}
|
|
501
|
+
function enqueuedTimes(session, ids) {
|
|
502
|
+
const times = /* @__PURE__ */ new Map();
|
|
503
|
+
if (ids.size === 0) return times;
|
|
504
|
+
const events = session.snapshotEvents();
|
|
505
|
+
for (let index = events.length - 1; index >= 0 && times.size < ids.size; index -= 1) {
|
|
506
|
+
const event = events[index];
|
|
507
|
+
if (event?.type !== "agent/inbox/spliced") continue;
|
|
508
|
+
const inserted = event.data.inserted;
|
|
509
|
+
if (!Array.isArray(inserted)) continue;
|
|
510
|
+
for (const candidate of inserted) {
|
|
511
|
+
const id = candidate?.id;
|
|
512
|
+
if (typeof id === "string" && ids.has(id) && !times.has(id)) times.set(id, event.time);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return times;
|
|
516
|
+
}
|
|
517
|
+
function textExcerpt(message) {
|
|
518
|
+
const blocks = message.content;
|
|
519
|
+
if (!Array.isArray(blocks)) return void 0;
|
|
520
|
+
const text = blocks.filter((block) => typeof block === "object" && block !== null && block.type === "text" && typeof block.text === "string").map((block) => block.text).join(" ");
|
|
521
|
+
return excerptLine2(text, DEVLEAD_ERROR_EXCERPT_MAX2);
|
|
522
|
+
}
|
|
523
|
+
function queuedInputsOf(agent) {
|
|
524
|
+
const located = locatedInputs(agent);
|
|
525
|
+
const times = enqueuedTimes(agent.session, new Set(located.map((entry) => String(entry.message.id))));
|
|
526
|
+
return located.map(({ boundary, message }) => {
|
|
527
|
+
const source = sourceOf(message);
|
|
528
|
+
const id = String(message.id);
|
|
529
|
+
const excerpt = textExcerpt(message);
|
|
530
|
+
const enqueuedAt = times.get(id);
|
|
531
|
+
const sourceForm = sourceString(source, "form");
|
|
532
|
+
const senderSessionId = sourceString(source, "senderSessionId");
|
|
533
|
+
return {
|
|
534
|
+
id,
|
|
535
|
+
boundary,
|
|
536
|
+
sourceKind: sourceString(source, "kind") ?? "unknown",
|
|
537
|
+
...sourceForm === void 0 ? {} : { sourceForm },
|
|
538
|
+
...senderSessionId === void 0 ? {} : { senderSessionId },
|
|
539
|
+
...excerpt === void 0 ? {} : { excerpt },
|
|
540
|
+
...enqueuedAt === void 0 ? {} : { enqueuedAt }
|
|
541
|
+
};
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
function restoreInputs(agent, kept) {
|
|
545
|
+
const pending = new Set(locatedInputs(agent).map((entry) => String(entry.message.id)));
|
|
546
|
+
let restored = 0;
|
|
547
|
+
for (let index = kept.length - 1; index >= 0; index -= 1) {
|
|
548
|
+
const entry = kept[index];
|
|
549
|
+
if (entry === void 0) continue;
|
|
550
|
+
const id = String(entry.message.id);
|
|
551
|
+
if (pending.has(id)) continue;
|
|
552
|
+
agent.inbox.prepend(entry.boundary, entry.message);
|
|
553
|
+
pending.add(id);
|
|
554
|
+
restored += 1;
|
|
555
|
+
}
|
|
556
|
+
return restored;
|
|
557
|
+
}
|
|
558
|
+
function keptInputsOf(agent, leadSessionId, policy) {
|
|
559
|
+
if (policy === "clear-all") return [];
|
|
560
|
+
const located = locatedInputs(agent);
|
|
561
|
+
return policy === "keep" ? located : located.filter((entry) => !isOwnRelay(entry.message, leadSessionId));
|
|
562
|
+
}
|
|
563
|
+
|
|
478
564
|
// node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
479
565
|
var external_exports = {};
|
|
480
566
|
__export(external_exports, {
|
|
@@ -15226,7 +15312,7 @@ var DevLeadReportOutbox = class _DevLeadReportOutbox {
|
|
|
15226
15312
|
import { pluginRecordOf } from "@deepseek-ai/dsh-session";
|
|
15227
15313
|
import {
|
|
15228
15314
|
DEVLEAD_DEFAULT_NOTIFICATION_RETENTION as DEVLEAD_DEFAULT_NOTIFICATION_RETENTION2,
|
|
15229
|
-
DEVLEAD_ERROR_EXCERPT_MAX as
|
|
15315
|
+
DEVLEAD_ERROR_EXCERPT_MAX as DEVLEAD_ERROR_EXCERPT_MAX3,
|
|
15230
15316
|
DEVLEAD_MAX_INSTANT as DEVLEAD_MAX_INSTANT3,
|
|
15231
15317
|
DEVLEAD_MODE_PROJECTION_KEY,
|
|
15232
15318
|
DEVLEAD_MODE_RECORD_TYPE as DEVLEAD_MODE_RECORD_TYPE2,
|
|
@@ -15248,8 +15334,8 @@ function emptyDevLeadProjectionState() {
|
|
|
15248
15334
|
return { enabled: false, sessions: [], notifications: [], reports: [], failure: null };
|
|
15249
15335
|
}
|
|
15250
15336
|
var excerptSchema = external_exports.string().min(1).refine(
|
|
15251
|
-
(value) => value.length <=
|
|
15252
|
-
{ message: `excerpt must be at most ${
|
|
15337
|
+
(value) => value.length <= DEVLEAD_ERROR_EXCERPT_MAX3 * 2 && Array.from(value).length <= DEVLEAD_ERROR_EXCERPT_MAX3,
|
|
15338
|
+
{ message: `excerpt must be at most ${DEVLEAD_ERROR_EXCERPT_MAX3} code points` }
|
|
15253
15339
|
);
|
|
15254
15340
|
var notificationSchema = external_exports.object({
|
|
15255
15341
|
id: external_exports.string().min(1),
|
|
@@ -15625,7 +15711,7 @@ import { appendPluginRecord, pluginRecordOf as pluginRecordOf3 } from "@deepseek
|
|
|
15625
15711
|
import { SessionId as toSessionId } from "@deepseek-ai/dsh-session";
|
|
15626
15712
|
import {
|
|
15627
15713
|
DEVLEAD_DEFAULT_NOTIFICATION_RETENTION as DEVLEAD_DEFAULT_NOTIFICATION_RETENTION3,
|
|
15628
|
-
DEVLEAD_MESSAGE_KIND as
|
|
15714
|
+
DEVLEAD_MESSAGE_KIND as DEVLEAD_MESSAGE_KIND3,
|
|
15629
15715
|
DEVLEAD_MODE_RECORD_TYPE as DEVLEAD_MODE_RECORD_TYPE4,
|
|
15630
15716
|
DEVLEAD_NOTIFICATION_RECORD_TYPE as DEVLEAD_NOTIFICATION_RECORD_TYPE3,
|
|
15631
15717
|
DEVLEAD_REPORT_RECORD_TYPE as DEVLEAD_REPORT_RECORD_TYPE3,
|
|
@@ -15776,9 +15862,8 @@ var DevLeadNotificationHub = class {
|
|
|
15776
15862
|
* @returns whether the report belongs to an indexed watch relationship.
|
|
15777
15863
|
*/
|
|
15778
15864
|
report(report) {
|
|
15779
|
-
|
|
15780
|
-
|
|
15781
|
-
if (runtime === void 0 || !runtime.watched.has(report.senderSessionId)) return false;
|
|
15865
|
+
const runtime = this.reportRuntime(report);
|
|
15866
|
+
if (runtime === void 0) return false;
|
|
15782
15867
|
if (runtime.pendingReports.some((existing) => existing.id === report.id) || runtime.unsavedReports.some((existing) => existing.id === report.id)) return true;
|
|
15783
15868
|
const session = this.ctx.sessions.get(toSessionId(report.leadSessionId));
|
|
15784
15869
|
if (session !== void 0) {
|
|
@@ -15808,12 +15893,8 @@ var DevLeadNotificationHub = class {
|
|
|
15808
15893
|
* @returns whether the lead Session log now carries a flushed receipt.
|
|
15809
15894
|
*/
|
|
15810
15895
|
async persistReport(report) {
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
if (runtime === void 0 || !runtime.watched.has(report.senderSessionId)) return false;
|
|
15814
|
-
if (this.ctx.get("workspaceRegistry")?.archivedSessionIds.some((id) => String(id) === report.leadSessionId) ?? false) {
|
|
15815
|
-
return false;
|
|
15816
|
-
}
|
|
15896
|
+
const runtime = this.reportRuntime(report);
|
|
15897
|
+
if (runtime === void 0) return false;
|
|
15817
15898
|
const session = this.ctx.sessions.get(toSessionId(report.leadSessionId));
|
|
15818
15899
|
if (session === void 0) {
|
|
15819
15900
|
runtime.unsavedReports = [...runtime.unsavedReports, report].slice(-DEVLEAD_REPORT_RETENTION2);
|
|
@@ -15847,6 +15928,23 @@ var DevLeadNotificationHub = class {
|
|
|
15847
15928
|
this.scheduleFlush(runtime);
|
|
15848
15929
|
return true;
|
|
15849
15930
|
}
|
|
15931
|
+
/**
|
|
15932
|
+
* Resolve the lead runtime one report may be queued for: the hub must be
|
|
15933
|
+
* running, the lead indexed and still watching the sender, and the lead not
|
|
15934
|
+
* archived. Shared by the sync queue path and the durable receipt path so
|
|
15935
|
+
* both reject the same relationships.
|
|
15936
|
+
* @param report - report addressed to one lead.
|
|
15937
|
+
* @returns the lead runtime, or undefined when the report must be refused.
|
|
15938
|
+
*/
|
|
15939
|
+
reportRuntime(report) {
|
|
15940
|
+
if (this.stopping) return void 0;
|
|
15941
|
+
const runtime = this.leads.get(report.leadSessionId);
|
|
15942
|
+
if (runtime === void 0 || !runtime.watched.has(report.senderSessionId)) return void 0;
|
|
15943
|
+
if (this.ctx.get("workspaceRegistry")?.archivedSessionIds.some((id) => String(id) === report.leadSessionId) ?? false) {
|
|
15944
|
+
return void 0;
|
|
15945
|
+
}
|
|
15946
|
+
return runtime;
|
|
15947
|
+
}
|
|
15850
15948
|
/**
|
|
15851
15949
|
* Append one report receipt and fire-and-forget its durability checkpoint.
|
|
15852
15950
|
* @param session - attached lead Session log receiving the record.
|
|
@@ -16258,7 +16356,15 @@ var DevLeadNotificationHub = class {
|
|
|
16258
16356
|
}
|
|
16259
16357
|
this.persistUnsaved(agent.session, runtime);
|
|
16260
16358
|
if (runtime.pending.length === 0 && runtime.pendingReports.length === 0) return;
|
|
16261
|
-
|
|
16359
|
+
let queuedNotice = false;
|
|
16360
|
+
try {
|
|
16361
|
+
queuedNotice = this.hasQueuedNotice(agent);
|
|
16362
|
+
} catch (error51) {
|
|
16363
|
+
this.ctx.logger.warn(
|
|
16364
|
+
`devlead: could not inspect the inbox of lead "${runtime.sessionId}" for a queued notice: ${thrownMessage(error51)}`
|
|
16365
|
+
);
|
|
16366
|
+
}
|
|
16367
|
+
if (queuedNotice) {
|
|
16262
16368
|
this.scheduleRetry(runtime);
|
|
16263
16369
|
return;
|
|
16264
16370
|
}
|
|
@@ -16336,7 +16442,7 @@ var DevLeadNotificationHub = class {
|
|
|
16336
16442
|
hasQueuedNotice(agent) {
|
|
16337
16443
|
return [...agent.inbox.nextTurn, ...agent.inbox.nextStep].some((message) => {
|
|
16338
16444
|
const source = message.source;
|
|
16339
|
-
return source
|
|
16445
|
+
return source?.kind === DEVLEAD_MESSAGE_KIND3 && source?.form === "notice";
|
|
16340
16446
|
});
|
|
16341
16447
|
}
|
|
16342
16448
|
/**
|
|
@@ -16401,12 +16507,6 @@ async function persistedSessionsOf(ctx, signal) {
|
|
|
16401
16507
|
}
|
|
16402
16508
|
|
|
16403
16509
|
// packages/devlead/src/presets.ts
|
|
16404
|
-
function recordOf2(value) {
|
|
16405
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
16406
|
-
}
|
|
16407
|
-
function stringField2(value) {
|
|
16408
|
-
return typeof value === "string" ? value : "";
|
|
16409
|
-
}
|
|
16410
16510
|
function agentPresetRosterCapabilityOf(ctx) {
|
|
16411
16511
|
const candidate = ctx.get("agentPresets");
|
|
16412
16512
|
if (typeof candidate !== "object" || candidate === null) return void 0;
|
|
@@ -16418,13 +16518,13 @@ function agentPresetRosterCapabilityOf(ctx) {
|
|
|
16418
16518
|
function devLeadAgentPresetsOf(rows, defaultId) {
|
|
16419
16519
|
const presets = [];
|
|
16420
16520
|
for (const row of rows) {
|
|
16421
|
-
const record2 =
|
|
16521
|
+
const record2 = recordOf(row);
|
|
16422
16522
|
if (record2 === void 0) continue;
|
|
16423
|
-
const id =
|
|
16523
|
+
const id = stringField(record2.id).trim();
|
|
16424
16524
|
if (id.length === 0) continue;
|
|
16425
|
-
const name =
|
|
16426
|
-
const description =
|
|
16427
|
-
const broken =
|
|
16525
|
+
const name = stringField(record2.name).trim();
|
|
16526
|
+
const description = stringField(record2.description).trim();
|
|
16527
|
+
const broken = stringField(record2.broken).trim();
|
|
16428
16528
|
presets.push({
|
|
16429
16529
|
id,
|
|
16430
16530
|
default: id === defaultId,
|
|
@@ -16710,13 +16810,20 @@ async function devLeadSessionViews(deps, ids, withLog, facts) {
|
|
|
16710
16810
|
}
|
|
16711
16811
|
return views;
|
|
16712
16812
|
}
|
|
16813
|
+
function workspaceCandidateLabel(workspace) {
|
|
16814
|
+
return `${workspace.id} (${workspace.path})`;
|
|
16815
|
+
}
|
|
16713
16816
|
async function resolveWorkspaceReference(ctx, reference, signal) {
|
|
16714
16817
|
const registry2 = ctx.get("workspaceRegistry");
|
|
16715
16818
|
if (registry2 === void 0) {
|
|
16716
16819
|
throw new DevLeadError("this Host composes no Workspace registry", "DEVLEAD_WORKSPACE_NOT_FOUND");
|
|
16717
16820
|
}
|
|
16718
16821
|
const trimmed = reference.trim();
|
|
16719
|
-
|
|
16822
|
+
if (trimmed.length === 0) {
|
|
16823
|
+
throw new DevLeadError("a Workspace reference is required", "DEVLEAD_INVALID_INPUT");
|
|
16824
|
+
}
|
|
16825
|
+
const workspaces = registry2.list();
|
|
16826
|
+
const byId = workspaces.find((workspace) => workspace.id === trimmed);
|
|
16720
16827
|
if (byId !== void 0) return byId;
|
|
16721
16828
|
try {
|
|
16722
16829
|
signal?.throwIfAborted();
|
|
@@ -16726,8 +16833,17 @@ async function resolveWorkspaceReference(ctx, reference, signal) {
|
|
|
16726
16833
|
rethrowIfAborted(error51, signal);
|
|
16727
16834
|
}
|
|
16728
16835
|
signal?.throwIfAborted();
|
|
16836
|
+
const byTitle = workspaces.filter((workspace) => workspace.title.trim() === trimmed);
|
|
16837
|
+
const only = byTitle[0];
|
|
16838
|
+
if (only !== void 0 && byTitle.length === 1) return only;
|
|
16839
|
+
if (byTitle.length > 1) {
|
|
16840
|
+
throw new DevLeadError(
|
|
16841
|
+
`Workspace title "${trimmed}" is ambiguous: ${byTitle.length} Workspaces share it: ${byTitle.map(workspaceCandidateLabel).join(", ")}; pass a Workspace id or registered path instead`,
|
|
16842
|
+
"DEVLEAD_WORKSPACE_AMBIGUOUS"
|
|
16843
|
+
);
|
|
16844
|
+
}
|
|
16729
16845
|
throw new DevLeadError(
|
|
16730
|
-
`no Workspace matches "${reference}";
|
|
16846
|
+
`no Workspace matches "${reference}"; pass a Workspace id, a registered directory path, or an exact title from devlead_list_workspaces. If the repository is not registered yet, add it with devlead_use_workspace.`,
|
|
16731
16847
|
"DEVLEAD_WORKSPACE_NOT_FOUND"
|
|
16732
16848
|
);
|
|
16733
16849
|
}
|
|
@@ -16735,12 +16851,10 @@ async function resolveExactSession(deps, reference) {
|
|
|
16735
16851
|
const { ctx } = deps;
|
|
16736
16852
|
const sessionId = toSessionId2(reference);
|
|
16737
16853
|
const live = ctx.agents.get(sessionId) !== void 0;
|
|
16738
|
-
if (deps.watchedSessions.includes(reference)) return { sessionId, live };
|
|
16739
16854
|
const session = ctx.sessions.get(sessionId) ?? ctx.agents.get(sessionId)?.session;
|
|
16740
|
-
if (session !== void 0)
|
|
16741
|
-
|
|
16742
|
-
|
|
16743
|
-
}
|
|
16855
|
+
if (session !== void 0 && session.header.origin === "subagent") return void 0;
|
|
16856
|
+
if (deps.watchedSessions.includes(reference)) return { sessionId, live };
|
|
16857
|
+
if (session !== void 0) return { sessionId, live };
|
|
16744
16858
|
const query = ctx.get("sessionQuery");
|
|
16745
16859
|
if (query === void 0) return void 0;
|
|
16746
16860
|
try {
|
|
@@ -16797,6 +16911,16 @@ var MAX_COLD_LEAD_LOG_READS = 64;
|
|
|
16797
16911
|
var MAX_ACTIVE_SCAN_UNKNOWN_READS = 64;
|
|
16798
16912
|
var REHYDRATION_READINESS_TIMEOUT_MS = 2e3;
|
|
16799
16913
|
var REHYDRATION_READINESS_POLL_MS = 100;
|
|
16914
|
+
var DevLeadInterruptedAdmissionError = class extends DevLeadError {
|
|
16915
|
+
/**
|
|
16916
|
+
* @param message - failure text naming both the admission failure and the
|
|
16917
|
+
* already-committed stop.
|
|
16918
|
+
*/
|
|
16919
|
+
constructor(message) {
|
|
16920
|
+
super(message, "DEVLEAD_SESSION_UNAVAILABLE");
|
|
16921
|
+
this.name = "DevLeadInterruptedAdmissionError";
|
|
16922
|
+
}
|
|
16923
|
+
};
|
|
16800
16924
|
var Config = z2.object({
|
|
16801
16925
|
notificationBatchMs: z2.number().step(1).min(0).max(MAX_TIMER_DELAY_MS).default(400),
|
|
16802
16926
|
maxWatchedSessions: z2.number().step(1).min(1).default(DEVLEAD_DEFAULT_MAX_WATCHED2),
|
|
@@ -16977,7 +17101,7 @@ var DevLeadService = class extends Service {
|
|
|
16977
17101
|
this.disposeRehydrationRetry();
|
|
16978
17102
|
this.outboxInjection?.dispose();
|
|
16979
17103
|
this.outboxInjection = void 0;
|
|
16980
|
-
|
|
17104
|
+
return this.outbox?.close();
|
|
16981
17105
|
};
|
|
16982
17106
|
}.bind(this), "devlead: cold rehydration");
|
|
16983
17107
|
this.ctx.effect(function* () {
|
|
@@ -17506,7 +17630,7 @@ var DevLeadService = class extends Service {
|
|
|
17506
17630
|
* The returned view is the pre-removal snapshot, so the caller can report
|
|
17507
17631
|
* what it closed and which Sessions it accounted to.
|
|
17508
17632
|
* @param agent - exact live lead Agent making the removal.
|
|
17509
|
-
* @param workspace - Workspace id or
|
|
17633
|
+
* @param workspace - Workspace id, registered path, or exact display title.
|
|
17510
17634
|
* @param signal - cancellation checked before the registry write.
|
|
17511
17635
|
* @returns the pre-removal Workspace view and whether a registration was
|
|
17512
17636
|
* removed (`false` when another actor removed it first).
|
|
@@ -17668,6 +17792,74 @@ var DevLeadService = class extends Service {
|
|
|
17668
17792
|
signal?.throwIfAborted();
|
|
17669
17793
|
return await devLeadSessionView(deps, String(resolved.sessionId), true);
|
|
17670
17794
|
}
|
|
17795
|
+
/**
|
|
17796
|
+
* Read the pending inbox inputs of one Session for the detail tool.
|
|
17797
|
+
*
|
|
17798
|
+
* The inbox is driver-owned: only a live Agent has one, so a cold Session
|
|
17799
|
+
* reports undefined (the caller omits the field) rather than an empty list
|
|
17800
|
+
* that would claim "nothing queued" about a log the Host has not folded.
|
|
17801
|
+
* @param agent - exact live lead Agent.
|
|
17802
|
+
* @param sessionId - exact Session identity (already resolved by the caller).
|
|
17803
|
+
* @param signal - cancellation checked before the read.
|
|
17804
|
+
* @returns queued inputs in queue order, or undefined when the target is not live.
|
|
17805
|
+
* @throws {@link DevLeadError} when the caller is not live.
|
|
17806
|
+
*/
|
|
17807
|
+
sessionQueuedInputs(agent, sessionId, signal) {
|
|
17808
|
+
this.assertLive(agent);
|
|
17809
|
+
signal?.throwIfAborted();
|
|
17810
|
+
const target = this.ctx.agents.get(toSessionId3(sessionId));
|
|
17811
|
+
return target === void 0 ? void 0 : queuedInputsOf(target);
|
|
17812
|
+
}
|
|
17813
|
+
/**
|
|
17814
|
+
* Withdraw one queued inbox input this lead Session authored.
|
|
17815
|
+
*
|
|
17816
|
+
* Only the lead's own relay prompts are retractable: a human's queued
|
|
17817
|
+
* instruction is the human's intent, a scheduled wake belongs to the
|
|
17818
|
+
* schedule plugin, and another lead's relay belongs to that lead. The call
|
|
17819
|
+
* is idempotent — an input already consumed or withdrawn reports
|
|
17820
|
+
* `retracted: false`. The target must be live (the inbox is driver-owned)
|
|
17821
|
+
* and cannot be the lead itself.
|
|
17822
|
+
* @param agent - exact live lead Agent.
|
|
17823
|
+
* @param sessionId - target Session reference (id or unique prefix).
|
|
17824
|
+
* @param inputId - Host message identity reported by queuedInputs.
|
|
17825
|
+
* @param signal - cancellation checked before each stage.
|
|
17826
|
+
* @returns the retraction outcome.
|
|
17827
|
+
* @throws {@link DevLeadError} `DEVLEAD_INVALID_INPUT` for a self-addressed
|
|
17828
|
+
* call or an input this lead did not author, `DEVLEAD_SESSION_UNAVAILABLE`
|
|
17829
|
+
* for a cold target, and the usual resolution failures.
|
|
17830
|
+
*/
|
|
17831
|
+
async retractQueuedInput(agent, sessionId, inputId, signal) {
|
|
17832
|
+
this.assertReady(agent);
|
|
17833
|
+
signal?.throwIfAborted();
|
|
17834
|
+
const deps = this.viewDeps(agent, signal);
|
|
17835
|
+
const resolved = await resolveSessionReference(deps, sessionId);
|
|
17836
|
+
signal?.throwIfAborted();
|
|
17837
|
+
const targetId = String(resolved.sessionId);
|
|
17838
|
+
if (targetId === String(agent.id)) {
|
|
17839
|
+
throw new DevLeadError(
|
|
17840
|
+
"a DevLead Session cannot retract inputs from its own inbox; ask the human to manage this Session",
|
|
17841
|
+
"DEVLEAD_INVALID_INPUT"
|
|
17842
|
+
);
|
|
17843
|
+
}
|
|
17844
|
+
const target = this.ctx.agents.get(resolved.sessionId);
|
|
17845
|
+
if (target === void 0) {
|
|
17846
|
+
throw new DevLeadError(
|
|
17847
|
+
`Session "${targetId}" is not live, so its inbox cannot be inspected or retracted; open it first`,
|
|
17848
|
+
"DEVLEAD_SESSION_UNAVAILABLE"
|
|
17849
|
+
);
|
|
17850
|
+
}
|
|
17851
|
+
const pending = [...target.inbox.nextTurn, ...target.inbox.nextStep].find((message) => String(message.id) === inputId);
|
|
17852
|
+
if (pending === void 0) return { sessionId: targetId, inputId, retracted: false };
|
|
17853
|
+
if (!isOwnRelay(pending, String(agent.id))) {
|
|
17854
|
+
throw new DevLeadError(
|
|
17855
|
+
`queued input "${inputId}" was not authored by this DevLead Session; only your own relay prompts can be retracted \u2014 human, scheduled, and other producers' inputs are not yours to remove`,
|
|
17856
|
+
"DEVLEAD_INVALID_INPUT"
|
|
17857
|
+
);
|
|
17858
|
+
}
|
|
17859
|
+
const retracted = target.inbox.remove(MessageId(inputId));
|
|
17860
|
+
if (retracted) await this.flushDurably(target.session, `retraction of input "${inputId}"`);
|
|
17861
|
+
return { sessionId: targetId, inputId, retracted };
|
|
17862
|
+
}
|
|
17671
17863
|
/**
|
|
17672
17864
|
* Create one ordinary Session in a Workspace and optionally prompt it.
|
|
17673
17865
|
*
|
|
@@ -17763,7 +17955,12 @@ var DevLeadService = class extends Service {
|
|
|
17763
17955
|
const prompt = request.prompt?.trim() ?? "";
|
|
17764
17956
|
const prompted = prompt.length > 0;
|
|
17765
17957
|
if (prompted) {
|
|
17766
|
-
await this.admitPrompt(agent, created.sessionId, prompt,
|
|
17958
|
+
await this.admitPrompt(agent, created.sessionId, prompt, {
|
|
17959
|
+
allowResume: false,
|
|
17960
|
+
interrupt: false,
|
|
17961
|
+
interruptInbox: "clear-all",
|
|
17962
|
+
signal
|
|
17963
|
+
});
|
|
17767
17964
|
}
|
|
17768
17965
|
const deps = this.viewDeps(agent, signal);
|
|
17769
17966
|
return {
|
|
@@ -17781,11 +17978,20 @@ var DevLeadService = class extends Service {
|
|
|
17781
17978
|
/**
|
|
17782
17979
|
* Admit one prompt into an existing Session, resuming a cold Session and
|
|
17783
17980
|
* watching it by default.
|
|
17981
|
+
*
|
|
17982
|
+
* `interrupt: true` explicitly replaces the Session's current work: when its
|
|
17983
|
+
* Agent is running, the Host's `workspace/session-stop` providers are asked
|
|
17984
|
+
* to stop the turn (and the subagent/job/schedule work they report) before
|
|
17985
|
+
* the prompt is admitted. The stop is fire-and-forget; the replacement
|
|
17986
|
+
* prompt is queued for the next turn and starts once the aborted turn
|
|
17987
|
+
* converges, so it can never join the cancelling turn. An idle or cold
|
|
17988
|
+
* Session skips the stop entirely.
|
|
17784
17989
|
* @param agent - exact live lead Agent.
|
|
17785
17990
|
* @param sessionId - Session id or unique prefix.
|
|
17786
17991
|
* @param prompt - non-empty prompt text.
|
|
17787
|
-
* @param options -
|
|
17788
|
-
*
|
|
17992
|
+
* @param options - watch policy, interrupt policy, and cancellation checked
|
|
17993
|
+
* between stages. Cancellation after an interrupt was requested does not
|
|
17994
|
+
* roll the stop back; the replacement prompt is admitted with it.
|
|
17789
17995
|
* @returns the admitted prompt receipt.
|
|
17790
17996
|
* @throws {@link DevLeadError} when the Session is missing, archived, or cannot be resumed.
|
|
17791
17997
|
*/
|
|
@@ -17815,11 +18021,16 @@ var DevLeadService = class extends Service {
|
|
|
17815
18021
|
const alreadyWatched = this.strictStateOf(agent.session).sessions.includes(String(resolved.sessionId));
|
|
17816
18022
|
const added = watch && !alreadyWatched;
|
|
17817
18023
|
if (added) await this.setWatching(agent, resolved.sessionId, true, signal);
|
|
17818
|
-
let
|
|
18024
|
+
let admission;
|
|
17819
18025
|
try {
|
|
17820
|
-
|
|
18026
|
+
admission = await this.admitPrompt(agent, resolved.sessionId, text, {
|
|
18027
|
+
allowResume: true,
|
|
18028
|
+
interrupt: options.interrupt ?? false,
|
|
18029
|
+
interruptInbox: options.interruptInbox ?? "clear-all",
|
|
18030
|
+
signal
|
|
18031
|
+
});
|
|
17821
18032
|
} catch (error51) {
|
|
17822
|
-
if (added) {
|
|
18033
|
+
if (added && !(error51 instanceof DevLeadInterruptedAdmissionError)) {
|
|
17823
18034
|
try {
|
|
17824
18035
|
await this.setWatching(agent, resolved.sessionId, false);
|
|
17825
18036
|
} catch (compensateError) {
|
|
@@ -17833,7 +18044,9 @@ var DevLeadService = class extends Service {
|
|
|
17833
18044
|
return {
|
|
17834
18045
|
sessionId: String(resolved.sessionId),
|
|
17835
18046
|
watched: this.strictStateOf(agent.session).sessions.includes(String(resolved.sessionId)),
|
|
17836
|
-
resumed
|
|
18047
|
+
resumed: admission.resumed,
|
|
18048
|
+
interrupted: admission.interrupted,
|
|
18049
|
+
...admission.retainedInputs === void 0 ? {} : { retainedInputs: admission.retainedInputs }
|
|
17837
18050
|
};
|
|
17838
18051
|
}
|
|
17839
18052
|
/**
|
|
@@ -18110,9 +18323,12 @@ var DevLeadService = class extends Service {
|
|
|
18110
18323
|
* for a cold lead by the hub), then the lead is woken through the same
|
|
18111
18324
|
* coalesced notice path as turn notifications. This method returns after the
|
|
18112
18325
|
* receipt/queue decision and never waits for the lead's next turn, so the
|
|
18113
|
-
* reporter is not blocked. Same-message reports in one turn are
|
|
18114
|
-
*
|
|
18115
|
-
*
|
|
18326
|
+
* reporter is not blocked. Same-kind same-message reports in one turn are
|
|
18327
|
+
* idempotent (the same text under a different kind is a new report);
|
|
18328
|
+
* more than {@link DEVLEAD_REPORT_MAX_PER_TURN} distinct non-question reports
|
|
18329
|
+
* in one turn are refused. `question` reports are the answer-seeking channel
|
|
18330
|
+
* used by the watched-Session question router, so they are exempt from that
|
|
18331
|
+
* progress budget.
|
|
18116
18332
|
* @param agent - exact live reporter Agent.
|
|
18117
18333
|
* @param request - report text, kind, and optional summary.
|
|
18118
18334
|
* @param signal - cancellation checked before durable work.
|
|
@@ -18150,7 +18366,7 @@ var DevLeadService = class extends Service {
|
|
|
18150
18366
|
const kind = request.kind ?? "progress";
|
|
18151
18367
|
if (!isDevLeadReportKind2(kind)) {
|
|
18152
18368
|
throw new DevLeadError(
|
|
18153
|
-
`report kind ${JSON.stringify(kind)} is not recognized; use progress, blocked, decision, or fyi`,
|
|
18369
|
+
`report kind ${JSON.stringify(kind)} is not recognized; use progress, blocked, decision, question, or fyi`,
|
|
18154
18370
|
"DEVLEAD_INVALID_INPUT"
|
|
18155
18371
|
);
|
|
18156
18372
|
}
|
|
@@ -18168,11 +18384,13 @@ var DevLeadService = class extends Service {
|
|
|
18168
18384
|
if (previous === void 0 || previous.turn !== turn || previous.leadSessionId !== leadSessionId) {
|
|
18169
18385
|
this.reportState.set(reporterId, state);
|
|
18170
18386
|
}
|
|
18171
|
-
const
|
|
18387
|
+
const dedupKey = `${kind}\0${message}`;
|
|
18388
|
+
const duplicate = state.messages.get(dedupKey);
|
|
18172
18389
|
if (duplicate !== void 0) return duplicate;
|
|
18173
|
-
|
|
18390
|
+
const progressCount = [...state.messages.values()].filter((entry) => entry.report.kind !== "question").length;
|
|
18391
|
+
if (kind !== "question" && progressCount >= DEVLEAD_REPORT_MAX_PER_TURN) {
|
|
18174
18392
|
throw new DevLeadError(
|
|
18175
|
-
`this Session already sent ${DEVLEAD_REPORT_MAX_PER_TURN} reports in turn ${turn}; wait for the next turn or let the DevLead continue`,
|
|
18393
|
+
`this Session already sent ${DEVLEAD_REPORT_MAX_PER_TURN} non-question reports in turn ${turn}; wait for the next turn or let the DevLead continue`,
|
|
18176
18394
|
"DEVLEAD_REPORT_RATE_LIMITED"
|
|
18177
18395
|
);
|
|
18178
18396
|
}
|
|
@@ -18199,7 +18417,7 @@ var DevLeadService = class extends Service {
|
|
|
18199
18417
|
});
|
|
18200
18418
|
signal?.throwIfAborted();
|
|
18201
18419
|
const receipt = await this.deliverReport(report);
|
|
18202
|
-
state.messages.set(
|
|
18420
|
+
state.messages.set(dedupKey, receipt);
|
|
18203
18421
|
if (this.reportState.size > 512) {
|
|
18204
18422
|
const oldest = this.reportState.keys().next().value;
|
|
18205
18423
|
if (oldest !== void 0) this.reportState.delete(oldest);
|
|
@@ -18207,13 +18425,15 @@ var DevLeadService = class extends Service {
|
|
|
18207
18425
|
return receipt;
|
|
18208
18426
|
}
|
|
18209
18427
|
/**
|
|
18210
|
-
* Read the retained mid-turn report digest of one live lead.
|
|
18428
|
+
* Read the retained mid-turn report digest of one live lead. Like
|
|
18429
|
+
* {@link notifications}, this is an audit read: a disabled lead may still
|
|
18430
|
+
* inspect what it retained while the mode was on.
|
|
18211
18431
|
* @param agent - exact live lead Agent.
|
|
18212
18432
|
* @param options - optional newest-row limit, defaulting to 20.
|
|
18213
18433
|
* @returns detached reports, oldest first.
|
|
18214
18434
|
*/
|
|
18215
18435
|
reports(agent, options = {}) {
|
|
18216
|
-
this.
|
|
18436
|
+
this.assertLive(agent);
|
|
18217
18437
|
const state = this.strictStateOf(agent.session);
|
|
18218
18438
|
const limit = options.limit ?? 20;
|
|
18219
18439
|
const effective = Number.isSafeInteger(limit) && limit > 0 ? limit : 20;
|
|
@@ -18391,6 +18611,7 @@ var DevLeadService = class extends Service {
|
|
|
18391
18611
|
const sessionId = String(session.id);
|
|
18392
18612
|
if (seen.has(sessionId)) return;
|
|
18393
18613
|
seen.add(sessionId);
|
|
18614
|
+
if (session.header.origin === "subagent") return;
|
|
18394
18615
|
const state = this.projectionHandle.stateOf(session);
|
|
18395
18616
|
if (state.failure !== null || !state.enabled) return;
|
|
18396
18617
|
const title = this.ctx.get("sessionTitle")?.get(session)?.title;
|
|
@@ -18904,7 +19125,7 @@ var DevLeadService = class extends Service {
|
|
|
18904
19125
|
* Resolve the Workspace one created Session should join: the requested
|
|
18905
19126
|
* reference, or the lead's own directory registered on demand.
|
|
18906
19127
|
* @param agent - exact live lead Agent.
|
|
18907
|
-
* @param reference - requested Workspace id or
|
|
19128
|
+
* @param reference - requested Workspace id, registered path, or exact title.
|
|
18908
19129
|
* @returns the target Workspace.
|
|
18909
19130
|
*/
|
|
18910
19131
|
async createTargetWorkspace(agent, reference) {
|
|
@@ -19048,19 +19269,31 @@ var DevLeadService = class extends Service {
|
|
|
19048
19269
|
}
|
|
19049
19270
|
/**
|
|
19050
19271
|
* Admit one lead-authored prompt into a Session, resuming a cold Session.
|
|
19272
|
+
*
|
|
19273
|
+
* `interrupt` is evaluated only against a live running Agent. The Host's
|
|
19274
|
+
* `workspace/session-stop` providers are the same fan-out archive
|
|
19275
|
+
* `stopActivity` uses; they cancel the turn and stop the Session's reported
|
|
19276
|
+
* subagent/job/schedule work. The stop is fire-and-forget: `followup` is
|
|
19277
|
+
* admitted immediately afterwards, and the Agent reclassifies a wake after
|
|
19278
|
+
* an aborted phase to the next turn and latches it until the aborted
|
|
19279
|
+
* activity converges, so the prompt cannot enter the cancelling turn. No
|
|
19280
|
+
* settlement wait is needed.
|
|
19051
19281
|
* @param leadAgent - exact live lead Agent.
|
|
19052
19282
|
* @param sessionId - target Session identity.
|
|
19053
19283
|
* @param text - non-empty prompt text.
|
|
19054
|
-
* @param
|
|
19055
|
-
*
|
|
19056
|
-
*
|
|
19284
|
+
* @param options - resume policy, interrupt policy, and cancellation checked
|
|
19285
|
+
* before each stage. Once an interrupt is requested, cancellation does not
|
|
19286
|
+
* roll it back; the replacement prompt is admitted with the stop.
|
|
19287
|
+
* @returns whether the Host resumed a cold Session and whether it was asked
|
|
19288
|
+
* to interrupt a running turn.
|
|
19057
19289
|
*/
|
|
19058
|
-
async admitPrompt(leadAgent, sessionId, text,
|
|
19290
|
+
async admitPrompt(leadAgent, sessionId, text, options) {
|
|
19291
|
+
const signal = options.signal;
|
|
19059
19292
|
signal?.throwIfAborted();
|
|
19060
19293
|
let target = this.ctx.agents.get(sessionId);
|
|
19061
19294
|
let resumed = false;
|
|
19062
19295
|
if (target === void 0) {
|
|
19063
|
-
if (!allowResume) {
|
|
19296
|
+
if (!options.allowResume) {
|
|
19064
19297
|
throw new DevLeadError(`Session "${sessionId}" is not live`, "DEVLEAD_SESSION_UNAVAILABLE");
|
|
19065
19298
|
}
|
|
19066
19299
|
const controller = this.ctx.get("sessionController");
|
|
@@ -19090,16 +19323,52 @@ var DevLeadService = class extends Service {
|
|
|
19090
19323
|
signal?.throwIfAborted();
|
|
19091
19324
|
}
|
|
19092
19325
|
signal?.throwIfAborted();
|
|
19326
|
+
let interrupted = false;
|
|
19327
|
+
let retainedInputs;
|
|
19328
|
+
if (options.interrupt && target.status === "running") {
|
|
19329
|
+
interrupted = true;
|
|
19330
|
+
const kept = keptInputsOf(target, String(leadAgent.id), options.interruptInbox);
|
|
19331
|
+
await this.stopSessionActivity(sessionId);
|
|
19332
|
+
if (options.interruptInbox !== "clear-all") {
|
|
19333
|
+
retainedInputs = restoreInputs(target, kept);
|
|
19334
|
+
}
|
|
19335
|
+
}
|
|
19093
19336
|
try {
|
|
19094
19337
|
target.followup(createDevLeadPromptMessage(text, leadAgent));
|
|
19095
19338
|
} catch (error51) {
|
|
19096
|
-
|
|
19097
|
-
|
|
19098
|
-
|
|
19099
|
-
|
|
19339
|
+
const detail = `could not admit a prompt into Session "${sessionId}": ${thrownMessage(error51)}`;
|
|
19340
|
+
if (interrupted) {
|
|
19341
|
+
throw new DevLeadInterruptedAdmissionError(
|
|
19342
|
+
`${detail}; the running work was already asked to stop, so the Session keeps its watch \u2014 retry the prompt`
|
|
19343
|
+
);
|
|
19344
|
+
}
|
|
19345
|
+
throw new DevLeadError(detail, "DEVLEAD_SESSION_UNAVAILABLE");
|
|
19100
19346
|
}
|
|
19101
19347
|
await this.flushDurably(target.session, `prompt into Session "${sessionId}"`);
|
|
19102
|
-
return resumed;
|
|
19348
|
+
return { resumed, interrupted, ...retainedInputs === void 0 ? {} : { retainedInputs } };
|
|
19349
|
+
}
|
|
19350
|
+
/**
|
|
19351
|
+
* Ask every composed `workspace/session-stop` provider to stop one Session's
|
|
19352
|
+
* running work. This is the same fan-out archive `stopActivity` uses, without
|
|
19353
|
+
* the archive write: the Agent registry cancels the running turn, the job
|
|
19354
|
+
* registry kills owned jobs, the subagent runtime cancels running
|
|
19355
|
+
* descendants, and the schedule plugin removes active schedule rows.
|
|
19356
|
+
* Provider failures are logged and never block the replacement prompt; the
|
|
19357
|
+
* cancellation itself is fire-and-forget, so this method does not wait for
|
|
19358
|
+
* the stopped work to settle.
|
|
19359
|
+
* @param sessionId - Session whose running work should stop.
|
|
19360
|
+
*/
|
|
19361
|
+
async stopSessionActivity(sessionId) {
|
|
19362
|
+
try {
|
|
19363
|
+
await this.ctx.parallel("workspace/session-stop", { sessionId });
|
|
19364
|
+
} catch (error51) {
|
|
19365
|
+
const failures = error51 instanceof AggregateError ? error51.errors : [error51];
|
|
19366
|
+
for (const failure of failures) {
|
|
19367
|
+
this.ctx.logger.warn(
|
|
19368
|
+
`devlead: stopping Session "${String(sessionId)}" for prompt interrupt failed: ${thrownMessage(failure)}`
|
|
19369
|
+
);
|
|
19370
|
+
}
|
|
19371
|
+
}
|
|
19103
19372
|
}
|
|
19104
19373
|
/**
|
|
19105
19374
|
* Replace one lead's watch set with one Session added or removed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yankeguo/dsh-devlead",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-rc.1",
|
|
4
4
|
"description": "DevLead mode core service for the DeepSeek Harness: durable per-session mode, Workspace and Session orchestration, watched-session notifications, and the `devLead` Session projection.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@yankeguo/dsh-devlead-protocol": "0.
|
|
46
|
+
"@yankeguo/dsh-devlead-protocol": "0.3.0-rc.1"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"dsh": ">=0.2.2-rc.1 <0.3.0"
|