@linxin666/dsh-client-ui-task-board 0.4.8 → 0.4.10

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 (64) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +28 -22
  3. package/README.zh.md +28 -22
  4. package/lib/client.js +1435 -682
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +356 -366
  7. package/lib/types/client/PluginSettingsCard.d.ts +21 -0
  8. package/lib/types/client/TaskBoardSettingsCard.d.ts +7 -0
  9. package/lib/types/client/board/ExecutionLog.d.ts +16 -0
  10. package/lib/types/client/board/TaskForm.d.ts +4 -0
  11. package/lib/types/client/board/VerificationReport.d.ts +2 -15
  12. package/lib/types/client/body-mutations.d.ts +45 -0
  13. package/lib/types/client/locales.d.ts +42 -6
  14. package/lib/types/client/suppress-schedule-row.d.ts +86 -0
  15. package/lib/types/core/controller.d.ts +1 -1
  16. package/lib/types/core/subtask.d.ts +59 -49
  17. package/lib/types/core/tasks.d.ts +5 -8
  18. package/lib/types/core/use-cases/task-update.d.ts +1 -1
  19. package/lib/types/core/workspace-target.d.ts +23 -3
  20. package/lib/types/host/launch-admission.d.ts +8 -9
  21. package/lib/types/host-ledger.d.ts +72 -48
  22. package/lib/types/host-routes.d.ts +49 -0
  23. package/lib/types/host-runner.d.ts +20 -10
  24. package/lib/types/host-service.d.ts +7 -50
  25. package/lib/types/index.d.ts +61 -63
  26. package/lib/types/loopback.d.ts +21 -0
  27. package/lib/types/protocol.d.ts +0 -5
  28. package/lib/types/tool-surface.d.ts +1 -0
  29. package/package.json +25 -25
  30. package/src/client/CardDefaultPresetField.tsx +1 -1
  31. package/src/client/PluginSettingsCard.tsx +78 -18
  32. package/src/client/TaskBoardSettingsCard.tsx +68 -25
  33. package/src/client/board/ExecutionLog.tsx +140 -0
  34. package/src/client/board/LinkSubtaskModal.tsx +1 -9
  35. package/src/client/board/NewTaskModal.tsx +2 -11
  36. package/src/client/board/TaskCard.tsx +45 -23
  37. package/src/client/board/TaskDetail.tsx +407 -261
  38. package/src/client/board/TaskForm.tsx +19 -4
  39. package/src/client/board/VerificationReport.tsx +143 -104
  40. package/src/client/board/task-markdown.module.css +11 -8
  41. package/src/client/board-settings.module.css +35 -7
  42. package/src/client/board.module.css +855 -115
  43. package/src/client/body-mutations.ts +133 -0
  44. package/src/client/index.ts +10 -0
  45. package/src/client/locales.ts +97 -24
  46. package/src/client/settings-card.module.css +71 -10
  47. package/src/client/suppress-schedule-row.ts +198 -0
  48. package/src/core/controller.ts +1 -3
  49. package/src/core/subtask.ts +81 -76
  50. package/src/core/tasks.ts +5 -9
  51. package/src/core/use-cases/task-update.ts +1 -3
  52. package/src/core/workspace-target.ts +27 -3
  53. package/src/host/agent-tools.ts +14 -15
  54. package/src/host/launch-admission.ts +8 -9
  55. package/src/host-ledger.ts +158 -125
  56. package/src/host-routes.ts +65 -2
  57. package/src/host-runner.ts +53 -28
  58. package/src/host-service.ts +42 -127
  59. package/src/index.ts +84 -106
  60. package/src/loopback.ts +32 -0
  61. package/src/protocol.ts +2 -9
  62. package/src/tool-surface.ts +1 -0
  63. package/lib/types/client/board/team-run-promotion.d.ts +0 -26
  64. package/src/client/board/team-run-promotion.ts +0 -39
package/lib/index.js CHANGED
@@ -890,7 +890,6 @@ function createTask(input, now, id) {
890
890
  model: normalizeTargetId(input.model),
891
891
  reasoningEffort: normalizeTargetId(input.reasoningEffort),
892
892
  reuseSession: input.reuseSession === true ? true : void 0,
893
- teamRun: input.teamRun === true ? true : void 0,
894
893
  goalRun: input.goalRun === true ? true : void 0,
895
894
  skipVerification: input.skipVerification === true ? true : void 0,
896
895
  ...input.freeze === void 0 ? {} : { freeze: freezeOf(input.freeze, now) },
@@ -1151,47 +1150,71 @@ function checkParentLink(tasks, childId, parentId, maxSubtaskDepth, lineage) {
1151
1150
  return { ok: true };
1152
1151
  }
1153
1152
  /**
1154
- * The tasks one run request opens executions for: the requested task first,
1155
- * then its on-board descendants within the configured depth. This is the
1156
- * SHAPE of a cascade — every walk that must see the whole tree (settlement,
1157
- * archive/restore, the running lock) reads it. The run path filters it with
1158
- * {@link joinsCascadeRun}: archived tasks never run, a participant that already
1159
- * has an open execution is skipped by the caller, which cannot start it twice,
1160
- * and a finished descendant is left alone.
1153
+ * The tasks one run request opens executions for: the requested card ALONE.
1154
+ *
1155
+ * Running a card never expands into its subtask tree. The card's own session
1156
+ * reads its subtasks through the board tools and dispatches subagents itself,
1157
+ * so a parent run opens exactly one session. Clicking a subtask runs that
1158
+ * subtask as its own root, again without expanding its own descendants. The
1159
+ * lineage queries around this one answer questions about the tree the card's
1160
+ * agent works with (who is still outstanding, what a historical run group
1161
+ * still holds open) — never who gets a session from the Host.
1162
+ * @param tasks - the ledger.
1163
+ * @param rootId - the task the run request named.
1164
+ * @returns the one card this run opens an execution for, or [] when unknown.
1161
1165
  */
1162
- function cascadeTargets(tasks, rootId, maxSubtaskDepth) {
1166
+ function cascadeTargets(tasks, rootId) {
1163
1167
  const root = tasks.find((task) => task.id === rootId);
1164
- if (root === void 0) return [];
1165
- return [root, ...descendantTasks(tasks, rootId, maxSubtaskDepth)];
1168
+ return root === void 0 ? [] : [root];
1166
1169
  }
1167
1170
  /**
1168
- * Whether a cascade member takes part in a new run.
1169
- *
1170
- * The task the user ran is always a member: the request names that card, and
1171
- * the operator asked for it to run whatever its column says. A descendant does
1172
- * not join once it sits in the `done` column — its work is finished, so running
1173
- * the parent again is a run of the parent, never a second execution of work
1174
- * that is already done. The rule keys on the column alone, so it covers both a
1175
- * subtask that ran and one an operator moved to done by hand, and it holds for
1176
- * every trigger: a manual run, a re-run, and a due occurrence of a schedule.
1177
- * A card whose own schedule is enabled settles back into `todo`, so a scheduled
1178
- * subtask stays a participant; to make a finished one run again, move it back
1179
- * to `todo` or run it on its own.
1180
- * @param task - the candidate member.
1181
- * @param rootId - the task the run request named.
1182
- * @returns false when this member is left alone by the run.
1171
+ * A task together with every descendant within the configured depth: the
1172
+ * subtree a lineage gate (archive, restore, force-close) has to walk.
1173
+ */
1174
+ function subtreeTasks(tasks, id, maxSubtaskDepth) {
1175
+ const root = tasks.find((task) => task.id === id);
1176
+ return root === void 0 ? [] : [root, ...descendantTasks(tasks, id, maxSubtaskDepth)];
1177
+ }
1178
+ /**
1179
+ * Whether a card still has work outstanding: anything outside the `done`
1180
+ * column. It keys on the column alone, so it covers both a subtask that ran
1181
+ * and one an operator moved to done by hand.
1182
+ */
1183
+ function isOutstanding(task) {
1184
+ return task.status !== "done";
1185
+ }
1186
+ /**
1187
+ * The descendants of a card that still have work outstanding, in breadth-first
1188
+ * order: the cards its own session is expected to dispatch. An archived
1189
+ * descendant is off the board and cannot be dispatched, so it is not listed.
1183
1190
  */
1184
- function joinsCascadeRun(task, rootId) {
1185
- return task.id === rootId || task.status !== "done";
1191
+ function outstandingDescendants(tasks, rootId, maxSubtaskDepth) {
1192
+ return descendantTasks(tasks, rootId, maxSubtaskDepth).filter((task) => task.archivedAt === void 0 && isOutstanding(task));
1186
1193
  }
1194
+ /**
1195
+ * Whether any descendant of this card still sits outside the `done` column.
1196
+ * This is the ONE decision behind both the forced agent preset and the dispatch
1197
+ * section of the execution prompt: a card whose tree still holds work runs as
1198
+ * the autonomous dispatcher.
1199
+ */
1200
+ function hasOutstandingDescendants(tasks, rootId, maxSubtaskDepth) {
1201
+ return outstandingDescendants(tasks, rootId, maxSubtaskDepth).length > 0;
1202
+ }
1203
+ /**
1204
+ * Agent preset a run with unfinished subtasks is forced under. The id comes
1205
+ * from packages/dsh-liangshen (its own `LIANGSHEN_PRESET_ID`); the force is
1206
+ * applied at launch and never written into a card's `mode` field.
1207
+ */
1208
+ const LIANGSHEN_PRESET_ID = "liangshen";
1187
1209
  /** The open execution of a task inside a run group, if it still exists. */
1188
1210
  function openGroupExecution(task, runGroupId) {
1189
1211
  return task.executions.find((execution) => execution.runGroupId === runGroupId && execution.endedAt === void 0);
1190
1212
  }
1191
1213
  /**
1192
1214
  * The direct subtasks of parentTaskId whose execution in this run group is
1193
- * still open: the parent remaining waiters. The parent may settle once this
1194
- * list is empty and its own outcome is known.
1215
+ * still open: the parent's remaining waiters. A stored multi-member group (a
1216
+ * run the Host opened before it stopped spreading one run across a subtree)
1217
+ * folds once this list is empty and the parent's own outcome is known.
1195
1218
  */
1196
1219
  function pendingCascadeChildren(tasks, parentTaskId, runGroupId) {
1197
1220
  const pending = [];
@@ -1206,9 +1229,9 @@ function pendingCascadeChildren(tasks, parentTaskId, runGroupId) {
1206
1229
  return pending;
1207
1230
  }
1208
1231
  /**
1209
- * Fold a cascade parent own outcome and its children outcomes into one
1210
- * verdict: failure dominates, then cancellation, then success. The error text
1211
- * is the first failure, falling back to the first cancellation.
1232
+ * Fold a stored run-group parent's own outcome and its children's outcomes into
1233
+ * one verdict: failure dominates, then cancellation, then success. The error
1234
+ * text is the first failure, falling back to the first cancellation.
1212
1235
  */
1213
1236
  function combineCascadeOutcome(entries) {
1214
1237
  let result = "succeeded";
@@ -1250,47 +1273,6 @@ function effectiveTaskPermission(task) {
1250
1273
  * elevated card is runnable while a subtask's own unconfirmed binding stays
1251
1274
  * gated.
1252
1275
  */
1253
- /**
1254
- * The immutable teammate name for one team-mode member. Teammate names are
1255
- * lower-kebab-case and must stay unique for the lifetime of the Team: the
1256
- * run-group token separates two runs of the same tree, and the member
1257
- * discriminator separates two members of one run that reduce to the same slug.
1258
- *
1259
- * The discriminator is not cosmetic. A title with no ASCII word characters (a
1260
- * CJK title, for example) carries no slug at all, so every such title of one
1261
- * run group collides on the generic prefix; Agent Teams answers every member
1262
- * after the first with `teammate name "..." was already used in this Team`,
1263
- * and those subtasks never start. Two ASCII titles that share a slug
1264
- * (`AI 强度预测` next to `AI 配比优化`) collide the same way.
1265
- * @param title - the member task's title.
1266
- * @param token - the run group id (the task id when no group is recorded).
1267
- * @param memberId - the member task's id, which makes the name unique in the run.
1268
- * @returns the teammate name handed to the Agent Teams service.
1269
- */
1270
- function teammateName(title, token, memberId) {
1271
- const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32).replace(/-+$/g, "");
1272
- const suffix = token.replace(/[^a-z0-9]/gi, "").slice(0, 8).toLowerCase();
1273
- const member = memberId === void 0 || memberId === "" ? void 0 : stableTag(memberId);
1274
- return [
1275
- slug === "" ? "subtask" : slug,
1276
- member,
1277
- suffix === "" ? "run" : suffix
1278
- ].filter((part) => part !== void 0).join("-");
1279
- }
1280
- /**
1281
- * A stable 4-hex tag for one member id. The name is derived twice for the same
1282
- * member — once for the Lead's prompt and once for the spawn request — so the
1283
- * tag must be a pure function of the id, never of a clock or a counter. FNV-1a
1284
- * keeps it dependency-free in `core/`, which both halves compile.
1285
- */
1286
- function stableTag(value) {
1287
- let hash = 2166136261;
1288
- for (let index = 0; index < value.length; index += 1) {
1289
- hash ^= value.charCodeAt(index);
1290
- hash = Math.imul(hash, 16777619) >>> 0;
1291
- }
1292
- return hash.toString(16).padStart(8, "0").slice(0, 4);
1293
- }
1294
1276
  function resolveExecutionTargets(task, tasks, maxSubtaskDepth = 3) {
1295
1277
  if (task.parentId === void 0) return task;
1296
1278
  const chain = [task, ...ancestorChain(tasks, task).slice(0, maxSubtaskDepth)];
@@ -1568,16 +1550,6 @@ function exceedsSessionDefault(permission, sessionDefault) {
1568
1550
  return (PERMISSION_RANK.get(permission) ?? -1) > (PERMISSION_RANK.get(sessionDefault) ?? -1);
1569
1551
  }
1570
1552
  /**
1571
- * Whether a session running at `holder` already carries `permission`: the
1572
- * permission is absent, or its rank does not exceed the holder's. A teammate
1573
- * inherits the Lead session's permission and cannot be narrowed below it, so a
1574
- * subtask's own pin is carried by a team run exactly when this holds, and a pin
1575
- * it does not carry would be silently dropped instead.
1576
- */
1577
- function permissionCarriedBy(holder, permission) {
1578
- return !exceedsSessionDefault(permission, holder);
1579
- }
1580
- /**
1581
1553
  * The confirmation-gate predicate: an elevated permission without a human
1582
1554
  * confirmation stamp. Manual run/rerun and cron must refuse such a card.
1583
1555
  */
@@ -3548,7 +3520,6 @@ function applyUpdateTask(tasks, id, patch, now) {
3548
3520
  if ("tags" in patch) next.tags = tagsPatch == null ? void 0 : normalizeTags(tagsPatch);
3549
3521
  if ("permission" in patch && patch.permission !== void 0 && patch.permission !== task.permission || "handover" in patch) next.permissionConfirmedAt = void 0;
3550
3522
  if ("reuseSession" in patch) next.reuseSession = patch.reuseSession === true ? true : void 0;
3551
- if ("teamRun" in patch) next.teamRun = patch.teamRun === true ? true : void 0;
3552
3523
  if ("goalRun" in patch) next.goalRun = patch.goalRun === true ? true : void 0;
3553
3524
  if ("skipVerification" in patch) next.skipVerification = patch.skipVerification === true ? true : void 0;
3554
3525
  if (workspaceId !== void 0 || "workspaceId" in patch) next.workspaceId = workspaceId;
@@ -3748,7 +3719,6 @@ function createInput(value) {
3748
3719
  "reasoningEffort",
3749
3720
  "applyCardDefaults",
3750
3721
  "reuseSession",
3751
- "teamRun",
3752
3722
  "goalRun",
3753
3723
  "skipVerification",
3754
3724
  "tags",
@@ -3759,7 +3729,6 @@ function createInput(value) {
3759
3729
  if (!optionalString(input.workspaceId) || !optionalString(input.mode) || !optionalString(input.model) || !optionalString(input.reasoningEffort)) return false;
3760
3730
  if (input.applyCardDefaults !== void 0 && typeof input.applyCardDefaults !== "boolean") return false;
3761
3731
  if (input.reuseSession !== void 0 && typeof input.reuseSession !== "boolean") return false;
3762
- if (input.teamRun !== void 0 && typeof input.teamRun !== "boolean") return false;
3763
3732
  if (input.goalRun !== void 0 && typeof input.goalRun !== "boolean") return false;
3764
3733
  if (input.skipVerification !== void 0 && typeof input.skipVerification !== "boolean") return false;
3765
3734
  if (input.permission !== void 0 && !isTaskPermission(input.permission)) return false;
@@ -3800,13 +3769,11 @@ function updatePatch(value) {
3800
3769
  "model",
3801
3770
  "reasoningEffort",
3802
3771
  "reuseSession",
3803
- "teamRun",
3804
3772
  "goalRun",
3805
3773
  "skipVerification",
3806
3774
  "tags"
3807
3775
  ])) return false;
3808
3776
  if (patch.reuseSession !== void 0 && patch.reuseSession !== null && typeof patch.reuseSession !== "boolean") return false;
3809
- if (patch.teamRun !== void 0 && patch.teamRun !== null && typeof patch.teamRun !== "boolean") return false;
3810
3777
  if (patch.goalRun !== void 0 && patch.goalRun !== null && typeof patch.goalRun !== "boolean") return false;
3811
3778
  if (patch.skipVerification !== void 0 && patch.skipVerification !== null && typeof patch.skipVerification !== "boolean") return false;
3812
3779
  for (const key of [
@@ -4065,11 +4032,16 @@ function parseEnvelopeAction(value) {
4065
4032
  //#region src/host-ledger.ts
4066
4033
  /** Human-facing text for a refused binding, per surface. */
4067
4034
  function bindingRefusalMessage(refusal, sessionDefault, surface) {
4068
- if (refusal.kind === "subtask-pin") return `team run cannot honor the permission binding of subtask "${refusal.title}": a teammate runs inside the Lead session and inherits its permission, which that pin exceeds; clear the card's permission or run the tree without Agent Team`;
4069
4035
  if (surface === "schedule") return `task "${refusal.title}" has an unconfirmed above-default permission`;
4070
4036
  if (refusal.kind === "root") return `confirmation-required: the effective permission is above the session default (${sessionDefault}); confirm the card's permission binding first`;
4071
4037
  return `confirmation-required: subtask "${refusal.title}" inherits an above-default permission; confirm that card's permission binding first`;
4072
4038
  }
4039
+ /**
4040
+ * Prefix of the `initiatedBy` an inherited descendant verdict carries. The Host
4041
+ * recorded it on the run card's behalf (see `inheritVerdictForDescendants`), not
4042
+ * an outside agent that reported its own work.
4043
+ */
4044
+ const PARENT_RUN_INITIATOR_PREFIX = "parent-run:";
4073
4045
  const MAX_REQUEST_CACHE = 256;
4074
4046
  function timeZone() {
4075
4047
  return resolveHostTimeZone();
@@ -4325,7 +4297,7 @@ function mergeTask(a, b) {
4325
4297
  * missing, cyclic, or names an archived parent while the child is on board is
4326
4298
  * dropped (the task becomes a root) instead of dropping the task. A chain
4327
4299
  * deeper than the current `maxSubtaskDepth` is deliberately KEPT: the limit
4328
- * gates new links, it never deletes a stored one, and every cascade walk is
4300
+ * gates new links, it never deletes a stored one, and every lineage walk is
4329
4301
  * bounded by the limit anyway. The Host is the only writer of these links, so
4330
4302
  * this is a last-resort guard against a hand-edited or imported document.
4331
4303
  */
@@ -4595,10 +4567,10 @@ var HostTaskLedger = class {
4595
4567
  }
4596
4568
  }
4597
4569
  /**
4598
- * Open the cascade one due schedule triggers: an empty array means nothing
4599
- * ran (already running, or a participant whose elevated permission is still
4600
- * unconfirmed, a one-shot whose instant was missed, or an exhausted budget),
4601
- * and the rule's own state says which.
4570
+ * Open the one run a due schedule triggers: an empty array means nothing ran
4571
+ * (already running, a card whose elevated permission is still unconfirmed, a
4572
+ * one-shot whose instant was missed, or an exhausted budget), and the rule's
4573
+ * own state says which.
4602
4574
  *
4603
4575
  * The run budget is enforced HERE, inside the single ledger writer: a rule
4604
4576
  * whose counter already reached its cap is stopped instead of opened, so no
@@ -4635,7 +4607,7 @@ var HostTaskLedger = class {
4635
4607
  this.skipOccurrence(taskId, "limit", triggeredAt);
4636
4608
  return [];
4637
4609
  }
4638
- if (schedule.mode === "once") return this.startCascade(task, triggeredAt, void 0, false, {
4610
+ if (schedule.mode === "once") return this.startRun(task, triggeredAt, void 0, false, {
4639
4611
  consumed: 1,
4640
4612
  lastTriggeredAt: triggeredAt,
4641
4613
  endedReason: "fired"
@@ -4651,7 +4623,7 @@ var HostTaskLedger = class {
4651
4623
  const consumed = schedule.runCount + 1;
4652
4624
  const budget = scheduleRunBudget(schedule);
4653
4625
  const spent = budget !== void 0 && consumed >= budget;
4654
- return this.startCascade(task, triggeredAt, void 0, false, {
4626
+ return this.startRun(task, triggeredAt, void 0, false, {
4655
4627
  consumed: 1,
4656
4628
  nextRunAt: spent ? void 0 : next,
4657
4629
  lastTriggeredAt: triggeredAt,
@@ -4708,8 +4680,8 @@ var HostTaskLedger = class {
4708
4680
  * failed without creating a session (see
4709
4681
  * {@link applyScheduleRefund}). Called by the service on the failed-launch
4710
4682
  * path only; a manual run and a launch that did reach a session are never
4711
- * refunded. A no-op for a task with no rule, so a failed cascade member does
4712
- * not touch anything.
4683
+ * refunded. A no-op for a task with no rule, so a failed run does not touch
4684
+ * anything.
4713
4685
  * @param taskId - the task whose occurrence is being refunded.
4714
4686
  * @param now - clock instant (ms epoch).
4715
4687
  */
@@ -4775,10 +4747,12 @@ var HostTaskLedger = class {
4775
4747
  this.commit(false);
4776
4748
  }
4777
4749
  /**
4778
- * Settle one execution. A cascade participant first records its OWN outcome
4779
- * and only finalizes once every child execution in its run group has
4780
- * settled, so a parent card leaves 'running' with the whole tree's verdict
4781
- * rather than its own turn alone.
4750
+ * Settle one execution. A NEW run is a single-member group, so it settles on
4751
+ * its own turn. A run group the Host opened before it stopped spreading one
4752
+ * run across a subtree is folded here instead: a stored participant records
4753
+ * its OWN outcome and only finalizes once every child execution in its group
4754
+ * has settled, so a parent card leaves 'running' with the whole group's
4755
+ * verdict rather than its own turn alone.
4782
4756
  *
4783
4757
  * `summary` is what the run left behind (see `ExecutionSummary`), passed in
4784
4758
  * by whichever reader observed the session. It is informational: a caller
@@ -4811,8 +4785,74 @@ var HostTaskLedger = class {
4811
4785
  }
4812
4786
  if (task.teamRun === true && this.closeTeamMembers(taskId, groupId, execution.ownResult ?? outcome, execution.ownError ?? error, now)) changed = true;
4813
4787
  if (this.settleCascade(taskId, groupId, now)) changed = true;
4788
+ if (this.inheritVerdictForDescendants(taskId, executionId, groupId, now)) changed = true;
4814
4789
  if (changed) this.commit();
4815
4790
  }
4791
+ /**
4792
+ * Record the run's verdict on the outstanding descendants its root was asked
4793
+ * to dispatch.
4794
+ *
4795
+ * A card with unfinished subtasks runs as an autonomous dispatcher: its
4796
+ * session reads the subtasks, dispatches them with subagents, and is asked to
4797
+ * write their conclusions back with
4798
+ * `task_board_manage({action:'record-external-outcome'})` before it finishes.
4799
+ * A run that never wrote one back would leave those cards parked with no
4800
+ * record of what the parent decided about them, so once the RUN CARD's
4801
+ * execution reached a decisive terminal record, every outstanding descendant
4802
+ * this run opened no execution for inherits that verdict as an external
4803
+ * record.
4804
+ *
4805
+ * Idempotent by construction: a card that already carries an execution in
4806
+ * this run group (the fold owns it), an open execution (it is running on its
4807
+ * own), or a terminal record stamped after this run started (the dispatching
4808
+ * agent's own backfill, or an earlier pass of this one) is left alone. Only a
4809
+ * decisive verdict is inherited: a cancelled run judged nothing about the
4810
+ * subtasks, and a subtask already in the done column has nothing left to
4811
+ * inherit.
4812
+ * @param taskId - the card whose execution just settled.
4813
+ * @param executionId - that execution.
4814
+ * @param groupId - its run group.
4815
+ * @param now - clock instant (ms epoch).
4816
+ * @returns whether the document changed.
4817
+ */
4818
+ inheritVerdictForDescendants(taskId, executionId, groupId, now) {
4819
+ const root = this.document.tasks.find((item) => item.id === taskId);
4820
+ if (root === void 0) return false;
4821
+ const execution = root.executions.find((entry) => entry.id === executionId);
4822
+ if (execution?.endedAt === void 0 || execution.result === void 0) return false;
4823
+ if (execution.result !== "succeeded" && execution.result !== "failed") return false;
4824
+ const verdict = execution.result;
4825
+ if (ancestorChain(this.document.tasks, root).some((ancestor) => ancestor.executions.some((entry) => entry.runGroupId === groupId))) return false;
4826
+ const descendants = new Set(outstandingDescendants(this.document.tasks, root.id, this.maxSubtaskDepth).map((task) => task.id));
4827
+ if (descendants.size === 0) return false;
4828
+ const note = `本次执行由父卡「${root.title}」统一判定,本卡未单独开会话执行;结论继承自父卡运行`;
4829
+ let changed = false;
4830
+ this.document.tasks = this.document.tasks.map((task) => {
4831
+ if (!descendants.has(task.id)) return task;
4832
+ if (task.executions.some((entry) => entry.runGroupId === groupId)) return task;
4833
+ if (task.executions.some((entry) => entry.endedAt === void 0)) return task;
4834
+ if (task.executions.some((entry) => entry.endedAt !== void 0 && entry.startedAt >= execution.startedAt)) return task;
4835
+ changed = true;
4836
+ const inherited = {
4837
+ id: crypto.randomUUID(),
4838
+ sessionId: void 0,
4839
+ startedAt: now,
4840
+ endedAt: now,
4841
+ result: verdict,
4842
+ error: note,
4843
+ initiatedBy: PARENT_RUN_INITIATOR_PREFIX + root.id,
4844
+ external: true,
4845
+ runGroupId: groupId
4846
+ };
4847
+ return {
4848
+ ...task,
4849
+ status: settledStatus(task, verdict),
4850
+ updatedAt: now,
4851
+ executions: retainRecentExecutions([...task.executions, inherited])
4852
+ };
4853
+ });
4854
+ return changed;
4855
+ }
4816
4856
  attachSession(taskId, executionId, sessionId) {
4817
4857
  const now = this.now();
4818
4858
  if (this.document.tasks.find((item) => item.id === taskId)?.executions.find((entry) => entry.id === executionId)?.endedAt !== void 0) return;
@@ -4947,7 +4987,7 @@ var HostTaskLedger = class {
4947
4987
  if (task.archivedAt !== void 0) throw new Error("archived task is read-only");
4948
4988
  if (!task.executions.some((entry) => entry.endedAt === void 0)) throw new Error("task has no open execution");
4949
4989
  const reason = "execution closed manually by " + (initiator === void 0 || initiator === "" ? "the operator" : initiator) + ": no verdict was recorded";
4950
- for (const member of cascadeTargets(this.document.tasks, action.taskId, this.maxSubtaskDepth)) for (const execution of member.executions) {
4990
+ for (const member of subtreeTasks(this.document.tasks, action.taskId, this.maxSubtaskDepth)) for (const execution of member.executions) {
4951
4991
  if (execution.endedAt !== void 0) continue;
4952
4992
  this.document.tasks = this.document.tasks.map((item) => item.id !== member.id ? item : settleExecution(item, execution.id, "cancelled", now, reason));
4953
4993
  }
@@ -5018,7 +5058,7 @@ var HostTaskLedger = class {
5018
5058
  if (task === void 0 || hasOpenExecution(task)) throw new Error("task is already running or missing");
5019
5059
  const refusal = this.bindingRefusal(task);
5020
5060
  if (refusal !== void 0) throw new Error(bindingRefusalMessage(refusal, this.sessionDefaultPermission, "run"));
5021
- runs = this.startCascade(task, now, initiator, action.kind === "rerun");
5061
+ runs = this.startRun(task, now, initiator, action.kind === "rerun");
5022
5062
  break;
5023
5063
  }
5024
5064
  default: throw new Error(`unknown task board action kind: ${String(action.kind)}`);
@@ -5047,100 +5087,68 @@ var HostTaskLedger = class {
5047
5087
  /**
5048
5088
  * The binding that makes a run illegal, if any.
5049
5089
  *
5050
- * A plain cascade launches one session per participant, so every participant
5051
- * carries its own resolved binding and each one gates the run. A team run
5052
- * launches only the Lead session: the Lead's binding gates it, and a
5053
- * teammate inherits that session's permission, so a subtask's OWN pin is
5054
- * refused exactly when the Lead session does not already carry it — the
5055
- * teammate could never be given that authority, and dropping the pin
5056
- * silently would misreport the work (an inherited binding is the Lead's own
5057
- * and stays allowed once the Lead is confirmed).
5090
+ * Only the card being run gets a session, so only ITS resolved binding gates
5091
+ * the run: a subtask's own elevated permission is that subtask's gate when the
5092
+ * subtask is run, and no longer blocks its parent from running.
5058
5093
  * @param root - the task being run.
5059
5094
  * @returns the first refusal, or undefined when the run may start.
5060
5095
  */
5061
5096
  bindingRefusal(root) {
5062
- const participants = this.cascadeParticipants(root.id);
5063
- if (root.teamRun === true) {
5064
- const lead = participants.find((participant) => participant.id === root.id);
5065
- if (lead !== void 0 && requiresPermissionConfirmation(lead, this.sessionDefaultPermission)) return {
5066
- kind: "root",
5067
- title: lead.title
5068
- };
5069
- const leadPermission = effectivePermission(lead ?? root) ?? this.sessionDefaultPermission;
5070
- const pinned = participants.find((participant) => {
5071
- if (participant.id === root.id) return false;
5072
- const raw = this.document.tasks.find((task) => task.id === participant.id);
5073
- return raw !== void 0 && !permissionCarriedBy(leadPermission, effectivePermission(raw));
5074
- });
5075
- return pinned === void 0 ? void 0 : {
5076
- kind: "subtask-pin",
5077
- title: pinned.title
5078
- };
5079
- }
5080
- const unconfirmed = participants.find((participant) => requiresPermissionConfirmation(participant, this.sessionDefaultPermission));
5081
- if (unconfirmed === void 0) return void 0;
5097
+ if (!requiresPermissionConfirmation(resolveExecutionTargets(root, this.document.tasks, this.maxSubtaskDepth), this.sessionDefaultPermission)) return void 0;
5082
5098
  return {
5083
- kind: unconfirmed.id === root.id ? "root" : "inherited",
5084
- title: unconfirmed.title
5099
+ kind: root.parentId === void 0 ? "root" : "inherited",
5100
+ title: root.title
5085
5101
  };
5086
5102
  }
5087
- /**
5088
- * The tasks a cascade from `rootId` would actually open executions for, with
5089
- * their effective execution targets resolved. Archived members never run, and
5090
- * a member that already has an open execution is skipped (a task cannot run
5091
- * twice), so the result is the participant set the launch will use.
5092
- */
5093
- cascadeParticipants(rootId) {
5094
- return cascadeTargets(this.document.tasks, rootId, this.maxSubtaskDepth).map((participant) => resolveExecutionTargets(participant, this.document.tasks, this.maxSubtaskDepth)).filter((participant) => participant.archivedAt === void 0 && !hasOpenExecution(participant));
5095
- }
5096
5103
  /** Whether a task or any of its subtasks still has an open execution. */
5097
5104
  subtreeHasOpenExecution(id) {
5098
- return cascadeTargets(this.document.tasks, id, this.maxSubtaskDepth).some((task) => hasOpenExecution(task));
5105
+ return subtreeTasks(this.document.tasks, id, this.maxSubtaskDepth).some((task) => hasOpenExecution(task));
5106
+ }
5107
+ /** The descendants of a card that still hold work, as the launch prompt names them. */
5108
+ outstandingDescendants(taskId) {
5109
+ return outstandingDescendants(this.document.tasks, taskId, this.maxSubtaskDepth);
5110
+ }
5111
+ /** Whether a card still has a subtask outside the done column. */
5112
+ hasOutstandingDescendants(taskId) {
5113
+ return hasOutstandingDescendants(this.document.tasks, taskId, this.maxSubtaskDepth);
5099
5114
  }
5100
5115
  /**
5101
- * Open one execution per cascade participant that still has work (the
5102
- * requested task and its on-board descendants, within the depth limit) under
5103
- * a single run group, and commit the ledger once. A descendant in 'done' is
5104
- * not a participant ({@link joinsCascadeRun}). The returned runs are ordered
5105
- * root-first, so the Host launches the parent before its subtasks.
5116
+ * Open ONE execution for the requested card, under a fresh run group, and
5117
+ * commit the ledger once. The group stays single-member on purpose: a run
5118
+ * never opens a session for a subtask (that card's own agent dispatches
5119
+ * subagents inside this session), and the group id is what later lets the
5120
+ * settlement fold a HISTORICAL multi-member group it opened before this
5121
+ * behavior changed.
5106
5122
  * @param root - the task the user ran.
5107
5123
  * @param now - clock instant (ms epoch).
5108
5124
  * @param initiator - the DSH session that asked for the run (audit only).
5109
5125
  * @param rerun - true to reset the root to 'todo' before starting it.
5110
5126
  * @param progress - when set, this run was a due occurrence and the root's
5111
5127
  * rule is advanced (counter, next target, stop/skip record) in the same
5112
- * atomic commit that opened the executions.
5128
+ * atomic commit that opened the execution.
5113
5129
  */
5114
- startCascade(root, now, initiator, rerun = false, progress) {
5130
+ startRun(root, now, initiator, rerun = false, progress) {
5115
5131
  const before = this.document.tasks;
5132
+ const [participant] = cascadeTargets(before, root.id);
5133
+ if (participant === void 0 || participant.archivedAt !== void 0) return [];
5134
+ if (hasOpenExecution(participant)) return [];
5116
5135
  const groupId = crypto.randomUUID();
5117
- const team = root.teamRun === true;
5118
- const started = /* @__PURE__ */ new Map();
5119
- const runs = [];
5120
- for (const task of cascadeTargets(before, root.id, this.maxSubtaskDepth)) {
5121
- if (task.archivedAt !== void 0) continue;
5122
- if (!joinsCascadeRun(task, root.id)) continue;
5123
- if (hasOpenExecution(task)) continue;
5124
- const opened = startExecution(rerun && task.id === root.id ? withStatus(task, "todo", now) : task, now, crypto.randomUUID(), initiator, groupId);
5125
- started.set(task.id, opened.task);
5126
- runs.push({
5127
- task: resolveExecutionTargets(opened.task, before, this.maxSubtaskDepth),
5128
- execution: opened.execution,
5129
- ...team && task.id !== root.id ? { dispatch: "teammate" } : {}
5130
- });
5131
- }
5132
- if (runs.length === 0) return [];
5133
- let tasks = before.map((task) => started.get(task.id) ?? task);
5136
+ const opened = startExecution(rerun ? withStatus(participant, "todo", now) : participant, now, crypto.randomUUID(), initiator, groupId);
5137
+ let tasks = before.map((task) => task.id === participant.id ? opened.task : task);
5134
5138
  if (progress !== void 0) tasks = applyScheduleProgress(tasks, root.id, progress, now);
5135
5139
  this.document.tasks = [...tasks];
5136
5140
  this.commit();
5137
- return runs;
5141
+ return [{
5142
+ task: resolveExecutionTargets(opened.task, before, this.maxSubtaskDepth),
5143
+ execution: opened.execution
5144
+ }];
5138
5145
  }
5139
5146
  /**
5140
- * Finalize every cascade parent that is ready, walking from `taskId` up the
5141
- * lineage: a member settles once its own outcome is recorded and none of its
5142
- * group children is still open, and its verdict folds those children in
5143
- * (failure dominates, then cancellation).
5147
+ * Finalize every stored run-group parent that is ready, walking from `taskId`
5148
+ * up the lineage: a member settles once its own outcome is recorded and none
5149
+ * of its group children is still open, and its verdict folds those children in
5150
+ * (failure dominates, then cancellation). A single-member group — every run
5151
+ * this Host opens now — settles on its own turn exactly as any plain run does.
5144
5152
  */
5145
5153
  settleCascade(taskId, groupId, now) {
5146
5154
  let changed = false;
@@ -5178,11 +5186,12 @@ var HostTaskLedger = class {
5178
5186
  * members are all settled. The Host poll calls this on every tick, so a run
5179
5187
  * can no longer be left in the running column by a settle nobody observed:
5180
5188
  *
5181
- * - A team run is governed by its Lead. Once the Lead's own outcome is
5189
+ * - A stored team run is governed by its Lead. Once the Lead's own outcome is
5182
5190
  * recorded, its still-open members are settled with that verdict. A
5183
5191
  * teammate is a durable member of the Team and may never report a turn of
5184
- * its own, and without this the whole lineage waits on it forever.
5185
- * - A cascade parent whose members are all settled is finalized here even
5192
+ * its own, and without this the whole lineage waits on it forever. New runs
5193
+ * never start a team, so this only closes a group the ledger already holds.
5194
+ * - A stored group parent whose members are all settled is finalized here even
5186
5195
  * when the settle that completed the tree happened in another process, or
5187
5196
  * was interrupted between its child write and its parent write.
5188
5197
  *
@@ -5672,6 +5681,18 @@ function mostRecentWorkspaceId(items) {
5672
5681
  }
5673
5682
  return best?.id ?? items[0]?.id;
5674
5683
  }
5684
+ /**
5685
+ * The failure text the Host records when a card names no workspace and the
5686
+ * deployment has none to resolve it to: the run is refused before any session
5687
+ * exists instead of letting `session.create` fall back to the Host process
5688
+ * working directory (the desktop app's profile directory), which is never the
5689
+ * project the user meant.
5690
+ *
5691
+ * A finished sentence rather than a code: the ledger stores it as the
5692
+ * execution's failure text, which the agent tools serve to a model and which
5693
+ * any client prints verbatim. It names the fix, not the mechanism.
5694
+ */
5695
+ const MISSING_WORKSPACE_REASON = "this card pins no workspace; choose a workspace on the card before running";
5675
5696
  //#endregion
5676
5697
  //#region src/core/reasoning-effort.ts
5677
5698
  /** Trim one optional effort: blank text means "not set", like every other pinned target. */
@@ -5837,19 +5858,17 @@ function escapeProvenanceDelimiter(value) {
5837
5858
  return value.replaceAll("来源声明 开始", "来源声明·开始").replaceAll("来源声明 结束", "来源声明·结束");
5838
5859
  }
5839
5860
  /**
5840
- * The execution-shape section: what else this run opens. A plain cascade opens
5841
- * one independent session per member; a team run starts every other member as a
5842
- * teammate inside THIS session, so the prompt names the Team tools instead.
5861
+ * The dispatch section: this run is the card's own session, and the card still
5862
+ * has unfinished subtasks. The Host opens no session for them, so the prompt
5863
+ * states what the session must do itself — read each card, dispatch subagents
5864
+ * in dependency order, and write the conclusions back before finishing. A card
5865
+ * with no outstanding descendant gets no section at all.
5843
5866
  */
5844
- function peerPromptPreamble(context) {
5845
- const peers = context.peers ?? [];
5846
- if (peers.length === 0) return void 0;
5847
- if (context.team === true) {
5848
- const lines = peers.map((peer) => `- ${escapeProvenanceDelimiter(peer.title)}(teammate: ${peer.name ?? teammateName(peer.title, peer.id, peer.id)})`);
5849
- return `本任务是 Agent Team 的 Lead:本次运行不额外开启独立会话,以下 ${peers.length} 个子任务成员已在本会话中作为 teammate 启动。用 list_agents / send_message / wait_agent 协调它们,用任务看板工具读写它们在看板上的卡片:\n${lines.join("\n")}`;
5850
- }
5851
- const lines = peers.map((peer) => `- ${escapeProvenanceDelimiter(peer.title)}(任务 ${peer.id})`);
5852
- return `本次运行同时并发开启 ${peers.length} 个独立 DSH 会话执行下列子任务成员(可用 task_board_* 工具查看它们的进度):\n${lines.join("\n")}`;
5867
+ function dispatchPromptPreamble(context) {
5868
+ const descendants = context.descendants ?? [];
5869
+ if (descendants.length === 0) return void 0;
5870
+ const lines = descendants.map((descendant) => `- ${escapeProvenanceDelimiter(descendant.title)}(任务 ${descendant.id},状态 ${descendant.status})`);
5871
+ return `本卡还有 ${descendants.length} 个未完成的子任务,本次执行不会为它们额外开启会话,由你在本会话内自行派发:\n${lines.join("\n")}\n先用 task_board_get 读取每张子卡的内容与执行目标,再用 subagent 按依赖顺序派发(互不依赖的可以并发),完工前用 task_board_manage({action:'record-external-outcome', result, initiatedBy, summary}) 一次性回填各子卡的结论。`;
5853
5872
  }
5854
5873
  /**
5855
5874
  * The scheduled-run section: this execution was triggered by the card's
@@ -5880,7 +5899,7 @@ function promptText(task, context = {}) {
5880
5899
  tagPromptPreamble(task),
5881
5900
  handoverPreamble,
5882
5901
  schedulePromptPreamble(context),
5883
- peerPromptPreamble(context)
5902
+ dispatchPromptPreamble(context)
5884
5903
  ].filter((part) => part !== void 0);
5885
5904
  const preamble = preambles.length === 0 ? void 0 : preambles.join("\n\n");
5886
5905
  const freeze = task.freeze;
@@ -6032,13 +6051,14 @@ var HostExecutionRunner = class HostExecutionRunner {
6032
6051
  */
6033
6052
  async launch(task, options = {}) {
6034
6053
  const workspaceId = task.handover?.workspaceId ?? task.workspaceId ?? this.recentWorkspaceId();
6035
- const mode = task.handover?.mode ?? task.mode;
6054
+ const mode = options.agentPreset ?? task.handover?.mode ?? task.mode;
6036
6055
  const permission = task.handover?.permission ?? task.permission;
6037
6056
  if (workspaceId !== void 0 && this.workspaceRegistry !== void 0) {
6038
6057
  if (!this.workspaceRegistry.list().some((item) => item.id === workspaceId)) throw new Error("workspace not found: " + workspaceId);
6039
6058
  }
6040
6059
  if (mode !== void 0) {
6041
6060
  const preset = (await this.invoke("agentPresets", "list", {})).presets?.find((item) => item.id === mode);
6061
+ if (preset === void 0 && options.agentPreset !== void 0) throw new Error("agent preset not found: " + mode + " (a card with unfinished subtasks runs under the liangshen preset, which this deployment does not serve)");
6042
6062
  if (preset === void 0) throw new Error("agent preset not found: " + mode);
6043
6063
  if (preset.broken !== void 0) throw new Error("agent preset is unavailable: " + preset.broken);
6044
6064
  }
@@ -6053,8 +6073,9 @@ var HostExecutionRunner = class HostExecutionRunner {
6053
6073
  }
6054
6074
  return reused;
6055
6075
  }
6076
+ if (workspaceId === void 0) throw new Error(MISSING_WORKSPACE_REASON);
6056
6077
  const sessionId = (await this.invoke("session", "create", {
6057
- ...workspaceId === void 0 ? {} : { workspaceId },
6078
+ workspaceId,
6058
6079
  ...mode === void 0 ? {} : { agentPreset: mode }
6059
6080
  })).sessionId;
6060
6081
  options.onSession?.(sessionId);
@@ -7328,7 +7349,6 @@ var TaskBoardHostService = class {
7328
7349
  preventIdleSleep = false;
7329
7350
  verificationSettings;
7330
7351
  verificationCatalog;
7331
- team;
7332
7352
  timers;
7333
7353
  /** Live reader of the global native-/goal switch; frozen per execution. */
7334
7354
  goalRunEnabled;
@@ -7367,7 +7387,6 @@ var TaskBoardHostService = class {
7367
7387
  });
7368
7388
  this.runner = new HostExecutionRunner(gateway, options.commandDispatcher, options.workspaceRegistry, void 0, options.ownerPeer);
7369
7389
  this.workspaceRegistry = options.workspaceRegistry;
7370
- this.team = options.team;
7371
7390
  this.timers = options.timers ?? PROCESS_TIMERS;
7372
7391
  this.power = options.power ?? new PowerInhibitor();
7373
7392
  this.now = options.now ?? Date.now;
@@ -7462,7 +7481,6 @@ var TaskBoardHostService = class {
7462
7481
  power: this.power.snapshot(),
7463
7482
  sessionDefaultPermission: this.ledger.sessionDefaultPermission,
7464
7483
  maxSubtaskDepth: this.ledger.maxSubtaskDepth,
7465
- teamRunAvailable: this.team !== void 0,
7466
7484
  goalRunEnabled: this.goalRunEnabled(),
7467
7485
  ...cardDefaults === void 0 ? {} : { cardDefaults },
7468
7486
  ...Object.keys(published).length === 0 ? {} : { extensions: published }
@@ -7554,9 +7572,6 @@ var TaskBoardHostService = class {
7554
7572
  */
7555
7573
  applyBoardAction(requestId, action, initiator) {
7556
7574
  const before = this.statusMap();
7557
- if (this.team === void 0 && (action.kind === "run" || action.kind === "rerun")) {
7558
- if (this.ledger.state().tasks.find((item) => item.id === action.taskId)?.teamRun === true) throw new Error("Agent Teams is unavailable in this deployment");
7559
- }
7560
7575
  if (action.kind === "run" || action.kind === "rerun") this.assertSpendCap();
7561
7576
  const result = this.ledger.applyRequest(requestId, this.withInheritedWorkspace(action, initiator), initiator);
7562
7577
  if (result.runs !== void 0) this.dispatchRuns(result.runs);
@@ -7629,20 +7644,19 @@ var TaskBoardHostService = class {
7629
7644
  this.ledger.dispose();
7630
7645
  this.listeners.clear();
7631
7646
  }
7632
- async launch(opened, others = [], schedule, freezeContract) {
7647
+ async launch(opened, schedule, freezeContract) {
7633
7648
  /** The session this launch attached to the execution, once it exists. */
7634
7649
  let attached;
7635
7650
  try {
7636
- const team = opened.task.teamRun === true;
7637
- const reuseSessionId = team ? void 0 : await this.reuseSessionFor(opened.task);
7638
- const peers = others.length === 0 ? void 0 : others.map((other) => ({
7639
- id: other.task.id,
7640
- title: other.task.title,
7641
- ...team ? { name: teammateName(other.task.title, other.execution.runGroupId ?? other.task.id, other.task.id) } : {}
7642
- }));
7643
- const promptContext = peers === void 0 && schedule === void 0 ? void 0 : {
7644
- ...peers === void 0 ? {} : { peers },
7645
- ...team ? { team: true } : {},
7651
+ const forcedPreset = this.ledger.hasOutstandingDescendants(opened.task.id) ? LIANGSHEN_PRESET_ID : void 0;
7652
+ const descendants = forcedPreset === void 0 ? [] : this.ledger.outstandingDescendants(opened.task.id);
7653
+ const reuseSessionId = forcedPreset === void 0 ? await this.reuseSessionFor(opened.task) : void 0;
7654
+ const promptContext = descendants.length === 0 && schedule === void 0 ? void 0 : {
7655
+ ...descendants.length === 0 ? {} : { descendants: descendants.map((descendant) => ({
7656
+ id: descendant.id,
7657
+ title: descendant.title,
7658
+ status: descendant.status
7659
+ })) },
7646
7660
  ...schedule === void 0 ? {} : { schedule }
7647
7661
  };
7648
7662
  const { settings, globalGoalEnabled, catalog } = await (freezeContract ?? (() => this.freezeRunContract()))();
@@ -7656,11 +7670,12 @@ var TaskBoardHostService = class {
7656
7670
  const initial = {
7657
7671
  contract,
7658
7672
  attempts: [],
7659
- applicability: team ? "team-member" : !contract.enabled ? skippedBy : notArmed
7673
+ applicability: !contract.enabled ? skippedBy : notArmed
7660
7674
  };
7661
7675
  this.ledger.setVerification(opened.task.id, opened.execution.id, initial);
7662
7676
  const sessionId = await this.runner.launch(opened.task, {
7663
7677
  ...reuseSessionId === void 0 ? {} : { reuseSessionId },
7678
+ ...forcedPreset === void 0 ? {} : { agentPreset: forcedPreset },
7664
7679
  ...promptContext === void 0 ? {} : { promptContext },
7665
7680
  goalEnabled,
7666
7681
  catalog,
@@ -7669,11 +7684,10 @@ var TaskBoardHostService = class {
7669
7684
  this.ledger.attachSession(opened.task.id, opened.execution.id, id);
7670
7685
  },
7671
7686
  onGoalArmed: (armed) => {
7672
- this.setApplicability(opened.task.id, opened.execution.id, team ? "team-member" : !contract.enabled ? skippedBy : armed ? "enforced" : notArmed);
7687
+ this.setApplicability(opened.task.id, opened.execution.id, !contract.enabled ? skippedBy : armed ? "enforced" : notArmed);
7673
7688
  }
7674
7689
  });
7675
7690
  if (attached === void 0) this.ledger.attachSession(opened.task.id, opened.execution.id, sessionId);
7676
- if (team) for (const teammate of others) this.scheduleTeammate(teammate, sessionId);
7677
7691
  } catch (error) {
7678
7692
  const launchedSession = error instanceof SessionLaunchError ? error.sessionId : void 0;
7679
7693
  if (launchedSession !== void 0) this.ledger.attachSession(opened.task.id, opened.execution.id, launchedSession);
@@ -7719,40 +7733,6 @@ var TaskBoardHostService = class {
7719
7733
  this.ledger.refundScheduledOccurrence(taskId, this.now());
7720
7734
  this.refreshSchedule();
7721
7735
  }
7722
- scheduleTeammate(opened, leadSessionId) {
7723
- this.enqueueLaunch(opened, () => this.spawnTeammate(opened, leadSessionId).catch((error) => {
7724
- safeConsoleError("[dsh-task-board] teammate spawn settlement failed", error);
7725
- }));
7726
- }
7727
- /**
7728
- * Spawn one teammate inside the Lead session and attach the teammate's
7729
- * session to the subtask execution, so the existing session monitor settles
7730
- * it from the teammate's own turn like any other execution. A spawn that
7731
- * fails settles the subtask as failed immediately, which then folds into the
7732
- * Lead's cascade verdict.
7733
- */
7734
- async spawnTeammate(opened, leadSessionId) {
7735
- const team = this.team;
7736
- if (team === void 0) {
7737
- this.settleAndNotify(opened.task.id, opened.execution.id, "failed", "Agent Teams is unavailable in this deployment");
7738
- return;
7739
- }
7740
- try {
7741
- const member = await team.spawn({
7742
- leadSessionId,
7743
- name: teammateName(opened.task.title, opened.execution.runGroupId ?? opened.task.id, opened.task.id),
7744
- description: opened.task.title,
7745
- prompt: promptText(opened.task)
7746
- });
7747
- if (member.sessionId === void 0 || member.sessionId === "") {
7748
- this.settleAndNotify(opened.task.id, opened.execution.id, "failed", member.error ?? "teammate provisioning failed");
7749
- return;
7750
- }
7751
- this.ledger.attachSession(opened.task.id, opened.execution.id, member.sessionId);
7752
- } catch (error) {
7753
- this.settleAndNotify(opened.task.id, opened.execution.id, "failed", error instanceof Error ? error.message : String(error));
7754
- }
7755
- }
7756
7736
  /**
7757
7737
  * One roster pass, and whether it could read the session tree.
7758
7738
  *
@@ -7855,19 +7835,13 @@ var TaskBoardHostService = class {
7855
7835
  * each streak is logged, so the Host log names the session.
7856
7836
  */
7857
7837
  settleAndNotify(taskId, executionId, outcome, error, summary) {
7858
- const before = this.ledger.getTask(taskId);
7859
- if (before?.executions.find((entry) => entry.id === executionId)?.endedAt !== void 0) {
7838
+ if (this.ledger.getTask(taskId)?.executions.find((entry) => entry.id === executionId)?.endedAt !== void 0) {
7860
7839
  this.ledger.settle(taskId, executionId, outcome, error, summary);
7861
7840
  return;
7862
7841
  }
7863
- const previousStatus = before?.status;
7842
+ const statuses = this.statusMap();
7864
7843
  this.ledger.settle(taskId, executionId, outcome, error, summary);
7865
- const task = this.ledger.getTask(taskId);
7866
- if (task !== void 0 && previousStatus !== void 0 && previousStatus !== task.status) this.extensions.emitStatusChanged({
7867
- taskId,
7868
- status: task.status,
7869
- previous: previousStatus
7870
- });
7844
+ this.emitStatusChanges(statuses);
7871
7845
  this.extensions.emitExecutionSettled({
7872
7846
  taskId,
7873
7847
  executionId,
@@ -8007,26 +7981,18 @@ var TaskBoardHostService = class {
8007
7981
  return this.ledger.armedScheduleCount();
8008
7982
  }
8009
7983
  /**
8010
- * Launch one run set. The root goes first and receives the run shape in its
8011
- * prompt (which members this run opens, and how they run); every plain-cascade
8012
- * member then launches on its own so one refused participant cannot hold the
8013
- * others back. A team run's members are spawned inside the root's Lead
8014
- * session instead, once that session exists.
7984
+ * Launch the one run a run request opened. A run request names one card and
7985
+ * opens one execution for it; the card's own session dispatches its subtasks
7986
+ * as subagents, so nothing else is enqueued here.
8015
7987
  *
8016
- * Every launch of one run set goes through the admission queue, which admits
8017
- * at most `runLaunchWidth` of them at a time — the whole subtree still opens,
8018
- * members just enter the running column in batches. Order inside the group is
8019
- * the order they are enqueued here, so the root's session always exists before
8020
- * any member's, and one member's launch settling (or failing) is what admits
8021
- * the next. All members share the one contract this group freezes.
7988
+ * The launch still goes through the admission queue, which admits at most
7989
+ * `runLaunchWidth` launches at a time — that bound now applies across
7990
+ * concurrent runs rather than across the members of one run.
8022
7991
  */
8023
7992
  dispatchRuns(runs, schedule) {
8024
- if (runs.length === 0) return;
8025
- const root = runs.find((run) => run.dispatch !== "teammate") ?? runs[0];
8026
- const others = runs.filter((run) => run !== root);
8027
- const freezeContract = this.contractFreezerForRunGroup();
8028
- this.scheduleLaunch(root, others, schedule, freezeContract);
8029
- for (const run of others) if (run.dispatch !== "teammate") this.scheduleLaunch(run, [], schedule, freezeContract);
7993
+ const root = runs[0];
7994
+ if (root === void 0) return;
7995
+ this.scheduleLaunch(root, schedule, this.contractFreezerForRunGroup());
8030
7996
  }
8031
7997
  /**
8032
7998
  * Move one execution's applicability without touching its frozen contract or
@@ -8040,8 +8006,8 @@ var TaskBoardHostService = class {
8040
8006
  applicability
8041
8007
  });
8042
8008
  }
8043
- scheduleLaunch(opened, others = [], schedule, freezeContract) {
8044
- this.enqueueLaunch(opened, () => this.launch(opened, others, schedule, freezeContract).catch((error) => {
8009
+ scheduleLaunch(opened, schedule, freezeContract) {
8010
+ this.enqueueLaunch(opened, () => this.launch(opened, schedule, freezeContract).catch((error) => {
8045
8011
  safeConsoleError("[dsh-task-board] execution launch settlement failed", error);
8046
8012
  }), schedule);
8047
8013
  }
@@ -8645,7 +8611,7 @@ function buildSetParentTool(host) {
8645
8611
  description: [
8646
8612
  "Attach an existing task under a parent (making it a subtask) or detach it back to the root board by setting its parentId.",
8647
8613
  "Pass an empty parentId to detach.",
8648
- "The Host refuses the link when the parent is unknown or archived, when the moved task is one of its own descendants, when the resulting depth exceeds the deployment subtask limit (default one level, maximum three), or while the task has an unsettled execution (its link may still be a running cascade parent pointer).",
8614
+ "The Host refuses the link when the parent is unknown or archived, when the moved task is one of its own descendants, when the resulting depth exceeds the deployment subtask limit (default one level, maximum three), or while the task has an unsettled execution (its link may still be a stored run group parent pointer).",
8649
8615
  "Running a task opens one run group over its subtree concurrently and leaves a subtask that already sits in the done column alone; a parent card settles only after its own turn and every direct subtask it opened have settled."
8650
8616
  ].join(" "),
8651
8617
  parameters: {
@@ -8688,17 +8654,16 @@ function buildRunTool(host) {
8688
8654
  name: "task_board_run",
8689
8655
  description: [
8690
8656
  "Run a task on the board now, or re-run a settled one.",
8691
- "Running a task also runs its whole subtask tree CONCURRENTLY: the Host opens one real DSH session per member under one run group, each replaying its card pinned workspace, agent preset, permission and model; a subtask that does not pin them inherits its nearest ancestor.",
8692
- "The parent card stays in the running column until its own turn and every direct subtask have settled, and it fails when any member failed; one failing subtask never stops the others.",
8657
+ "Running a card opens ONE session for that card: no session is opened for its subtasks, and the card agent dispatches them itself with subagent. A card whose subtasks are still unfinished runs under the liangshen agent preset and is told which cards to pick up.",
8658
+ "Clicking a subtask runs that subtask as its own root, again without opening anything for its descendants.",
8693
8659
  "A card whose effective permission is above the deployment session default is refused with confirmation-required until a HUMAN confirms the binding in the board UI; this tool cannot confirm it.",
8694
- "A card whose task carries teamRun instead starts ONE Team Lead session and the Host spawns a teammate per subtask inside it, so those cards run as an Agent Team rather than as independent sessions; that mode needs the deployment Agent Teams service and is refused when it is missing.",
8695
8660
  "Executions consume real API quota. Sessions are created asynchronously, so read their ids and outcomes back with task_board_get."
8696
8661
  ].join(" "),
8697
8662
  parameters: {
8698
8663
  taskId: {
8699
8664
  type: "string",
8700
8665
  required: true,
8701
- description: "The task to run; running a root task runs its whole subtree, minus the subtasks that are already in the done column."
8666
+ description: "The task to run; only this card gets a session, its unfinished subtasks are dispatched by that session own agent."
8702
8667
  },
8703
8668
  rerun: {
8704
8669
  type: "boolean",
@@ -8730,7 +8695,7 @@ function buildRunTool(host) {
8730
8695
  ok: true,
8731
8696
  started,
8732
8697
  ...root === void 0 ? {} : { task: taskSummary(root, snapshot.tasks, snapshot.sessionDefaultPermission) },
8733
- note: "Executions run asynchronously; call task_board_get to read session ids and the settled outcome. The parent settles only after its own turn and every direct subtask settle."
8698
+ note: "Executions run asynchronously; call task_board_get to read session ids and the settled outcome."
8734
8699
  });
8735
8700
  } catch (error) {
8736
8701
  const message = messageOf(error);
@@ -8746,7 +8711,7 @@ function buildManageTool(host) {
8746
8711
  "Move, archive, restore, delete, or settle one task board card.",
8747
8712
  "move-backlog, move-todo, move-running, move-done and move-failed are the manual column moves and cover every column; a card the runner is executing (one with an open execution) cannot be moved.",
8748
8713
  "A manual move writes the card column only and never fabricates an execution record, so the card reports a declaration rather than evidence of a run: done/failed declare work finished (or failed) outside a Host-run execution — human work, an external system, a decision made elsewhere — and running says the work is under way without a tracked session. Use task_board_run when the work should actually run in a session here.",
8749
- "record-external-outcome is the record-backed version of move-done and move-failed: use it when YOU, or another agent outside this Host, actually finished or failed the card with your own model, so the terminal column and the run history both derive from one execution record. It takes result (succeeded or failed) and initiatedBy (who completed it, for example your own agent name) plus an optional summary, and it is refused while the card still has an open execution: the Host stays the only authority over a run it is executing. It cannot record running or cancelled — those remain Host-only.",
8714
+ "record-external-outcome is the record-backed version of move-done and move-failed: use it when YOU, or another agent outside this Host, actually finished or failed the card with your own model, so the terminal column and the run history both derive from one execution record. It takes result (succeeded or failed) and initiatedBy (who completed it, for example your own agent name) plus an optional summary, and it is refused while the card still has an open execution: the Host stays the only authority over a run it is executing. It cannot record running or cancelled — those remain Host-only. A parent card that dispatched its subtasks uses it once, at the end, to backfill every subtask card with the conclusion it reached; the Host records an inherited verdict on a subtask the parent never wrote back, so the write-back is what keeps each subtask conclusion its own.",
8750
8715
  "settle force-closes the open execution of a card the board can no longer observe (a stuck running card) and records it cancelled with the caller as the reason, so the card returns to the todo column and can be run again.",
8751
8716
  "reset-verification clears the acceptance anomalies (timeouts, authentication failures, an unresolvable judge route, or an attempt the time budget ended) recorded on a card open execution, so the next update_goal(action: complete) runs a fresh acceptance. It is refused unless that execution really carries such anomalies, it never clears a quality verdict, and a spent anomaly budget otherwise HOLDS the card open instead of failing it: tell the user the acceptance environment is unusable and that this action is how they clear it once they have fixed it.",
8752
8717
  "archive takes the whole subtask tree off the board and is refused while any member has an unsettled execution; restore brings the task, its ancestors and its subtree back; delete removes one card and is refused while it still has subtasks (detach or delete them first) or while it runs.",
@@ -8897,7 +8862,7 @@ function buildScheduleTool(host) {
8897
8862
  "Arm, change, or disarm a task scheduled runs. Two kinds of plan exist: a recurring 5-field cron rule (day-of-month and day-of-week follow Vixie semantics: both restricted means OR, otherwise AND), and a one-shot that runs once at a future instant.",
8898
8863
  "For a one-shot pass mode \"once\" with at (the planned instant, ms since epoch UTC). For a recurring rule pass mode \"cron\" (or omit mode) with a cron expression, optionally capped by maxRuns (a positive whole number of scheduled executions; omit for unlimited, pass 0 to clear a cap).",
8899
8864
  "The wall clock is read in the rule stored IANA time zone; omit timeZone to use the Host zone reported by task_board_list/task_board_get. DST gaps are skipped and an ambiguous fall-back time fires once, at the earlier instant.",
8900
- "A due scheduled task runs the same cascade a manual run does, so a root task runs its whole subtask tree minus the subtasks already in the done column.",
8865
+ "A due scheduled task runs exactly what a manual run of that card does: one session for the card, never one per subtask.",
8901
8866
  "The scheduler counts executions it actually starts; once a rule reaches its run budget it stops itself in the ledger, and a manual run never consumes the budget. A schedule whose tree contains an unconfirmed above-default permission is refused and does not consume the budget; the reason is reported in the list board summary as schedulerError.",
8902
8867
  "Missed occurrences during Host downtime are skipped, never queued (a one-shot whose instant passed while the Host was down is stopped as missed); a task that is already running skips its occurrence without consuming the budget."
8903
8868
  ].join(" "),
@@ -9051,7 +9016,11 @@ function buildListTool(host) {
9051
9016
  function buildGetTool(host) {
9052
9017
  return defineTool({
9053
9018
  name: "task_board_get",
9054
- description: ["Read one task board card in full: prompt, description, labels, column, parent link, direct subtasks, execution targets, schedule, permission gate state, and the last ten execution attempts with their session ids and outcomes.", "Use it before running or editing a card, and after a run to read the settled outcome."].join(" "),
9019
+ description: [
9020
+ "Read one task board card in full: prompt, description, labels, column, parent link, direct subtasks, execution targets, schedule, permission gate state, and the last ten execution attempts with their session ids and outcomes.",
9021
+ "Use it before running or editing a card, after a run to read the settled outcome, and to read each subtask card before dispatching it with subagent.",
9022
+ "A card written before team runs were retired may still report teamRun: true; the field is history and never changes how the Host runs the card."
9023
+ ].join(" "),
9055
9024
  parameters: { taskId: {
9056
9025
  type: "string",
9057
9026
  required: true,
@@ -9125,10 +9094,6 @@ function buildCreateTool(host) {
9125
9094
  type: "boolean",
9126
9095
  description: "Continue later runs in the previous execution session instead of a fresh conversation."
9127
9096
  },
9128
- teamRun: {
9129
- type: "boolean",
9130
- description: "Run this task as an Agent Team: running it starts one Team Lead session and the Host spawns a teammate per subtask inside it. Omit or false for one independent session per member. Refused when the deployment serves no Agent Teams service."
9131
- },
9132
9097
  goalRun: {
9133
9098
  type: "boolean",
9134
9099
  description: "Start each run with dsh built-in /goal so the session keeps working continuation rounds until the goal completes. Off by default: omit (or pass false) for a single plain turn, and pass true to opt this card in. It only takes effect while the deployment global native /goal switch is on."
@@ -9209,7 +9174,6 @@ function buildCreateTool(host) {
9209
9174
  ...args.reasoningEffort === void 0 || args.reasoningEffort === "" ? {} : { reasoningEffort: args.reasoningEffort },
9210
9175
  applyCardDefaults: true,
9211
9176
  ...args.reuseSession === true ? { reuseSession: true } : {},
9212
- ...args.teamRun === true ? { teamRun: true } : {},
9213
9177
  ...args.goalRun === true ? { goalRun: true } : {},
9214
9178
  ...args.skipVerification === true ? { skipVerification: true } : {},
9215
9179
  ...tags.length === 0 ? {} : { tags },
@@ -9296,10 +9260,6 @@ function buildUpdateTool(host) {
9296
9260
  type: "boolean",
9297
9261
  description: "Continue later runs in the previous execution session."
9298
9262
  },
9299
- teamRun: {
9300
- type: "boolean",
9301
- description: "Switches this task between a plain cascade (one session per member) and an Agent Team run (Lead session plus a teammate per subtask)."
9302
- },
9303
9263
  goalRun: {
9304
9264
  type: "boolean",
9305
9265
  description: "Whether each run starts with dsh built-in /goal (default false, one plain turn). Pass true to opt this card in, or false to return it to the default."
@@ -9343,7 +9303,6 @@ function buildUpdateTool(host) {
9343
9303
  if (has(args, "reasoningEffort") && typeof args.reasoningEffort === "string") patch.reasoningEffort = args.reasoningEffort;
9344
9304
  if (has(args, "permission") && typeof args.permission === "string") patch.permission = args.permission === "" ? void 0 : args.permission;
9345
9305
  if (has(args, "reuseSession")) patch.reuseSession = args.reuseSession === true;
9346
- if (has(args, "teamRun")) patch.teamRun = args.teamRun === true;
9347
9306
  if (has(args, "goalRun")) patch.goalRun = args.goalRun === true ? true : false;
9348
9307
  if (has(args, "skipVerification")) patch.skipVerification = args.skipVerification === true ? true : false;
9349
9308
  if (has(args, "tags")) {
@@ -9405,7 +9364,8 @@ function buildUpdateTool(host) {
9405
9364
  */
9406
9365
  const PLUGIN_TOOL_SECTION_ORDERS = {
9407
9366
  ssh: 150,
9408
- "task-board": 200
9367
+ "task-board": 200,
9368
+ agents: 220
9409
9369
  };
9410
9370
  /**
9411
9371
  * Build a section provider that renders \`text\` only while at least one of
@@ -9511,6 +9471,32 @@ function isLoopbackRequest(request) {
9511
9471
  return false;
9512
9472
  }
9513
9473
  }
9474
+ /**
9475
+ * Whether a forwarded request landed on this machine's loopback upstream: a
9476
+ * forwarding header (the proxy's own stamp), a loopback socket address (the
9477
+ * proxy dials 127.0.0.1:<port>), and a loopback Host header (the proxy rewrote
9478
+ * the authority to its upstream literal).
9479
+ *
9480
+ * This is a fact about the route, not a trust decision. A public request to a
9481
+ * tunnel satisfies all three by construction, because the proxy is the client
9482
+ * of this process: only a caller that operates the proxy can decide it stands
9483
+ * for the browser, which is why every consumer keeps this behind an explicit
9484
+ * default-off switch and its own browser markers. isLoopbackRequest is
9485
+ * unchanged and still refuses a forwarded request (issue #1906).
9486
+ * @param request - node HTTP request.
9487
+ * @returns true when a forwarding header, a loopback socket, and a loopback Host all hold.
9488
+ */
9489
+ function isForwardedLoopbackRequest(request) {
9490
+ if (!isProxiedRequest(request)) return false;
9491
+ if (!isLoopbackAddress(request.socket.remoteAddress)) return false;
9492
+ const host = request.headers.host;
9493
+ if (typeof host !== "string") return false;
9494
+ try {
9495
+ return isLoopbackHostname(new URL("http://" + host).hostname);
9496
+ } catch {
9497
+ return false;
9498
+ }
9499
+ }
9514
9500
  //#endregion
9515
9501
  //#region src/host-routes.ts
9516
9502
  const ACTION_LIMIT = 64 * 1024;
@@ -9545,7 +9531,9 @@ function resolveAccess(access) {
9545
9531
  if (trustedProxyHosts.size > 0 && (access.proxyToken === void 0 || access.proxyToken === "")) throw new Error("task-board: authenticated proxy hosts require a non-empty proxy token");
9546
9532
  return {
9547
9533
  trustedProxyHosts,
9548
- ...access.proxyToken === void 0 ? {} : { proxyToken: access.proxyToken }
9534
+ trustForwardedProxy: access.trustForwardedProxy ?? (() => false),
9535
+ ...access.proxyToken === void 0 ? {} : { proxyToken: access.proxyToken },
9536
+ ...access.connection === void 0 ? {} : { connection: access.connection }
9549
9537
  };
9550
9538
  }
9551
9539
  /**
@@ -9615,10 +9603,29 @@ function matchesToken(candidate, expected) {
9615
9603
  * tripwire, the socket/Host/origin-equality checks carry the authority).
9616
9604
  * Authenticated proxies must be explicitly allowlisted and replace the
9617
9605
  * internal token header after their own authentication step.
9606
+ *
9607
+ * A third party's proxy cannot inject that token, so a deployment whose own
9608
+ * tunnel dials the loopback upstream (issue #1918) can instead turn on
9609
+ * trustForwardedProxy: a forwarded request that landed on this machine
9610
+ * (loopback socket AND loopback Host) is then admitted on the same browser
9611
+ * marker alone. The switch defaults off, so an unconfigured board keeps
9612
+ * refusing every forwarded request (issue #1906).
9613
+ *
9614
+ * A deployment behind a reverse proxy or ingress that DSH itself serves
9615
+ * (`--trusted-host`, TLS terminated at the edge) is admitted by the Host's
9616
+ * `connection` service instead: a request whose Host/Origin fence and signed
9617
+ * browser session it accepts needs no board-specific allowlist, which is why
9618
+ * the check runs first when the service is mounted (issue #1930). The fence
9619
+ * below stays untouched as the fallback, so a deployment without the service,
9620
+ * and every direct client the service does not admit, keeps exactly the
9621
+ * pre-existing decision.
9618
9622
  */
9619
9623
  function isTrustedTaskBoardRequest(req, access) {
9624
+ const connection = access.connection?.();
9625
+ if (connection !== void 0 && connection.requestRejection(req) === void 0) return true;
9620
9626
  if (!browserSameOriginMarker(req)) return false;
9621
9627
  if (isLoopbackRequest(req)) return true;
9628
+ if (access.trustForwardedProxy() && req.headers["sec-fetch-site"] !== "cross-site" && isForwardedLoopbackRequest(req)) return true;
9622
9629
  if (!isLoopbackAddress(req.socket.remoteAddress)) return false;
9623
9630
  const host = req.headers.host;
9624
9631
  if (typeof host !== "string") return false;
@@ -10928,23 +10935,18 @@ const inject = [
10928
10935
  ];
10929
10936
  /** Model-facing announcement: plugin presence, capabilities, and limits. */
10930
10937
  const TASK_BOARD_GUIDANCE = "本机已安装 dsh-task-board 插件(DSH Web GUI 的任务看板):侧边栏「任务看板」入口;在 dsh-web 插件全家桶仓库(packages/dsh-task-board)统一维护,经聚合包 web-ui-all 一键安装。能力:多列看板管理任务;Host 权威账本;关闭浏览器后仍由 Host 执行和结算;任务可钉住工作区、agent 预设和权限;任务可建子任务(深度上限可配 1..3,默认 1 层,子任务不能再带子任务),执行父任务会并发执行其子任务树,子任务可单独覆盖权限与模型;另注册 task_board_* agent 工具(list/get/create/update/set_parent/run/manage/schedule),任何会话都可直接读写看板、子任务与定时计划,但运行任务会真实执行并消耗额度,高于会话默认权限的绑定仍必须由用户在 GUI 人工确认(工具刻意不提供确认能力);支持 Host 本地时区的 5 段 cron,错过的触发点不补跑;可选且默认关闭的空闲系统睡眠保护允许屏幕熄灭,但不承诺拦截合盖、手动睡眠、休眠、关机或唤醒已睡眠机器。执行消耗 API 额度。用户提到「任务看板 / 看板 / 定时任务」时即指本插件,请据此协作。若你同时用 todo_write 维护会话顶部的可见计划列表,最终回复前必须再次调用 todo_write 收尾:没有剩余工作时不要保留 in_progress,已完成的最后一步要标为 completed。";
10931
- /**
10932
- * Continuable-subagent provider for fresh teammates, matching the Agent Teams
10933
- * tool plugin's own `freshProvider` default.
10934
- */
10935
- const DEFAULT_TEAM_PROVIDER = "spawn";
10936
10938
  const Config = z.object({
10937
10939
  announceToAgent: z.boolean().default(false).volatile(),
10938
10940
  enabled: z.boolean().default(true).volatile(),
10939
10941
  preventIdleSleep: z.boolean().default(false).volatile(),
10940
10942
  trustedProxyHosts: z.array(z.string()).default([]),
10941
10943
  proxyTokenEnv: z.string().min(1).default(DEFAULT_PROXY_TOKEN_ENV),
10944
+ trustForwardedProxy: z.boolean().default(false).volatile(),
10942
10945
  sessionDefaultPermission: z.union(TASK_PERMISSIONS),
10943
10946
  maxSubtaskDepth: z.number().min(1).max(3).default(1).volatile(),
10944
10947
  sessionPollSeconds: z.number().min(1).max(300).default(5).volatile(),
10945
10948
  runLaunchWidth: z.number().min(1).max(16).default(3).volatile(),
10946
10949
  spendBudgetTokens: z.number().min(0).default(0).volatile(),
10947
- teamProvider: z.string().min(1).default(DEFAULT_TEAM_PROVIDER),
10948
10950
  goalRunEnabled: z.boolean().default(false).volatile(),
10949
10951
  cardDefaultMode: z.string().default("").volatile(),
10950
10952
  cardDefaultPermission: z.union([...TASK_PERMISSIONS, ""]).default("").volatile(),
@@ -10980,19 +10982,64 @@ function readConfigField(field, fallback) {
10980
10982
  if (typeof field === "object" && field !== null && typeof field.get === "function") return field.get();
10981
10983
  return field;
10982
10984
  }
10983
- /** Resolve proxy access without ever placing the token value in plugin config. */
10985
+ /**
10986
+ * Resolve proxy access without ever placing the token value in plugin config.
10987
+ *
10988
+ * The forwarded-proxy switch travels as a reader rather than a value: it is
10989
+ * schema-volatile, so the fence must read it when a request arrives instead of
10990
+ * when the routes are registered.
10991
+ * @param config - the resolved plugin config.
10992
+ * @param env - environment holding the proxy token value.
10993
+ * @returns the route access handed to {@link makeTaskBoardRoutes}.
10994
+ */
10984
10995
  function resolveProxyAccess(config, env = process.env) {
10996
+ const trustForwardedProxy = () => readConfigField(config?.trustForwardedProxy, false);
10985
10997
  const trustedProxyHosts = config?.trustedProxyHosts ?? [];
10986
- if (trustedProxyHosts.length === 0) return { trustedProxyHosts };
10998
+ if (trustedProxyHosts.length === 0) return {
10999
+ trustedProxyHosts,
11000
+ trustForwardedProxy
11001
+ };
10987
11002
  const proxyTokenEnv = config?.proxyTokenEnv ?? "DSH_TASK_BOARD_PROXY_TOKEN";
10988
11003
  if (proxyTokenEnv.trim() === "") throw new Error("task-board: proxyTokenEnv must not be empty");
10989
11004
  const proxyToken = env[proxyTokenEnv];
10990
11005
  if (proxyToken === void 0 || proxyToken === "") throw new Error(`task-board: trustedProxyHosts requires a non-empty ${proxyTokenEnv} environment variable`);
10991
11006
  return {
10992
11007
  trustedProxyHosts,
10993
- proxyToken
11008
+ proxyToken,
11009
+ trustForwardedProxy
10994
11010
  };
10995
11011
  }
11012
+ /**
11013
+ /**
11014
+ * Schema default for the forwarded-proxy switch, re-read for hand-built
11015
+ * contexts. Deliberately false: a deployment that never configured it keeps
11016
+ * refusing every forwarded request, which is the #1906 fence.
11017
+ */
11018
+ const DEFAULT_TRUST_FORWARDED_PROXY = false;
11019
+ /**
11020
+ * Resolve the composition's optional `connection` service.
11021
+ *
11022
+ * The service is the Host's own browser-session authority: it fronts every
11023
+ * `/api` request with the Host/Origin fence and the signed `dsh-auth-*` cookie,
11024
+ * which is what a deployment behind a reverse proxy or ingress validates on the
11025
+ * same authority the GUI is served from. The board bridges it instead of
11026
+ * repeating that check, so a proxy request the Host already authenticated is
11027
+ * admitted without a board-specific host allowlist (issue #1930). It is
11028
+ * deliberately resolved like the agent-tool registry rather than injected:
11029
+ * a composition that serves no connection keeps mounting the board on the
11030
+ * pre-existing loopback fence, and one that mounts the service later is picked
11031
+ * up on the next request because the fence asks this resolver each time.
11032
+ * @param ctx - the plugin context.
11033
+ * @returns the trust face, or undefined when this deployment serves none.
11034
+ */
11035
+ function resolveConnectionTrust(ctx) {
11036
+ try {
11037
+ const connection = ctx.get("connection");
11038
+ return connection !== void 0 && typeof connection.requestRejection === "function" ? connection : void 0;
11039
+ } catch {
11040
+ return;
11041
+ }
11042
+ }
10996
11043
  /** The lookup half of a resolved registry, when it exposes one. */
10997
11044
  function lookupOf(registry) {
10998
11045
  return registry !== void 0 && typeof registry.get === "function" ? { get: registry.get.bind(registry) } : void 0;
@@ -11058,65 +11105,6 @@ function resolveHostDefaultPermission(ctx) {
11058
11105
  }
11059
11106
  }
11060
11107
  /**
11061
- * How long one teammate may take to reach its durable active or failed edge.
11062
- * Agent Teams provisioning normally resolves in seconds; the bound exists so a
11063
- * hung spawn settles the subtask instead of holding the cascade open forever.
11064
- */
11065
- const TEAMMATE_PROVISION_TIMEOUT_MS = 6e5;
11066
- /**
11067
- * Resolve the optional Agent Teams service. Like the tool registry and the llm
11068
- * runtime, it is deliberately not injected: a deployment without Agent Teams
11069
- * must still mount the whole board and only lose team-mode runs.
11070
- * @param ctx - the plugin context.
11071
- * @returns the service, or undefined when this deployment serves none.
11072
- */
11073
- function resolveAgentTeams(ctx) {
11074
- try {
11075
- const teams = ctx.get("agentTeams");
11076
- return teams !== void 0 && typeof teams.spawnTeammate === "function" ? teams : void 0;
11077
- } catch {
11078
- return;
11079
- }
11080
- }
11081
- /**
11082
- * Build the team dispatcher: the run's Lead session spawns one teammate per
11083
- * subtask through the Agent Teams service, and the teammate's session id is
11084
- * attached to that subtask's execution so the ordinary session monitor settles
11085
- * it. Returns undefined when the deployment serves no Agent Teams service or
11086
- * no live-agent registry, which makes a team run fail closed.
11087
- * @param ctx - the plugin context.
11088
- * @param provider - the continuable-subagent provider for fresh teammates.
11089
- * @returns the dispatcher, or undefined when team runs cannot be served.
11090
- */
11091
- function buildTeamDispatcher(ctx, provider) {
11092
- const teams = resolveAgentTeams(ctx);
11093
- if (teams === void 0) return void 0;
11094
- if (typeof ctx.agents?.get !== "function") return void 0;
11095
- return { async spawn(input) {
11096
- const lead = ctx.agents.get(input.leadSessionId);
11097
- if (lead === void 0) return { error: `lead session ${input.leadSessionId} is not live` };
11098
- try {
11099
- const member = (await teams.spawnTeammate(lead, {
11100
- name: input.name,
11101
- description: input.description,
11102
- prompt: [{
11103
- type: "text",
11104
- text: input.prompt
11105
- }],
11106
- context: "fresh",
11107
- provider,
11108
- signal: AbortSignal.timeout(TEAMMATE_PROVISION_TIMEOUT_MS)
11109
- }))?.member;
11110
- if (member === void 0) return { error: "Agent Teams returned no teammate" };
11111
- if (member.phase === "failed") return { error: member.error ?? "teammate provisioning failed" };
11112
- if (typeof member.id !== "string" || member.id === "") return { error: "Agent Teams returned no teammate session" };
11113
- return { sessionId: member.id };
11114
- } catch (error) {
11115
- return { error: `teammate provisioning failed: ${error instanceof Error ? error.message : String(error)}` };
11116
- }
11117
- } };
11118
- }
11119
- /**
11120
11108
  * Read the optional `llm` service. The board deliberately does not inject it:
11121
11109
  * a deployment without a model must still mount the board, and the parse route
11122
11110
  * answers a typed failure instead of the plugin failing to load (issue #1540).
@@ -11272,7 +11260,6 @@ function applyImpl(ctx, config) {
11272
11260
  verificationSettings,
11273
11261
  verificationCatalog,
11274
11262
  timers: resolveHostTimers(ctx),
11275
- team: buildTeamDispatcher(ctx, config?.teamProvider ?? "spawn"),
11276
11263
  commandDispatcher: { async execute(sessionId, line, signal) {
11277
11264
  const agent = await resolveExecutionAgent(ctx, sessionId);
11278
11265
  return (await ctx.commands.execute(agent, line, [], signal))?.result;
@@ -11352,7 +11339,10 @@ function applyImpl(ctx, config) {
11352
11339
  handle.dispose();
11353
11340
  });
11354
11341
  }
11355
- const routes = makeTaskBoardRoutes(host, resolveProxyAccess(config), { parseTask: async (request, signal) => {
11342
+ const routes = makeTaskBoardRoutes(host, {
11343
+ ...resolveProxyAccess(config),
11344
+ connection: () => resolveConnectionTrust(ctx)
11345
+ }, { parseTask: async (request, signal) => {
11356
11346
  const llm = resolveLlmRuntime(ctx);
11357
11347
  if (llm === void 0) throw new TaskParseError("no-model", "this deployment serves no llm service");
11358
11348
  return await parseTaskDraft(llm, request, signal);
@@ -11402,4 +11392,4 @@ function applyImpl(ctx, config) {
11402
11392
  sync();
11403
11393
  }
11404
11394
  //#endregion
11405
- export { Config, DEFAULT_GOAL_RUN, DEFAULT_GOAL_VERIFICATION, DEFAULT_PROXY_TOKEN_ENV, DEFAULT_TEAM_PROVIDER, TASK_BOARD_GUIDANCE, apply, buildTeamDispatcher, inject, readConfigField, resolveAgentTeams, resolveExecutionAgent, resolveHostDefaultPermission, resolveHostTimers, resolveLlmRuntime, resolveProxyAccess, resolveSessionController, resolveToolRegistry };
11395
+ export { Config, DEFAULT_GOAL_RUN, DEFAULT_GOAL_VERIFICATION, DEFAULT_PROXY_TOKEN_ENV, DEFAULT_TRUST_FORWARDED_PROXY, TASK_BOARD_GUIDANCE, apply, inject, readConfigField, resolveConnectionTrust, resolveExecutionAgent, resolveHostDefaultPermission, resolveHostTimers, resolveLlmRuntime, resolveProxyAccess, resolveSessionController, resolveToolRegistry };