@linxin666/dsh-client-ui-task-board 0.4.20 → 0.4.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1619,12 +1619,13 @@ function executionSummaryOf(events, startedAt) {
1619
1619
  function normalizeExecutionSummary(value) {
1620
1620
  if (typeof value !== "object" || value === null) return void 0;
1621
1621
  const row = value;
1622
- if (typeof row.text !== "string" || typeof row.seq !== "number" || !Number.isFinite(row.seq)) return void 0;
1622
+ if (typeof row.text !== "string") return void 0;
1623
+ if (row.seq !== void 0 && (typeof row.seq !== "number" || !Number.isFinite(row.seq))) return void 0;
1623
1624
  const text = row.text.trim();
1624
1625
  if (text === "") return void 0;
1625
1626
  return {
1626
1627
  text: truncateExecutionSummary(text),
1627
- seq: row.seq
1628
+ ...row.seq === void 0 ? {} : { seq: row.seq }
1628
1629
  };
1629
1630
  }
1630
1631
  /** Marker replacing every sensitive match. */
@@ -2019,7 +2020,9 @@ function parseLedger(raw) {
2019
2020
  ownError: typeof execution.ownError === "string" ? execution.ownError : void 0,
2020
2021
  summary: normalizeExecutionSummary(execution.summary),
2021
2022
  rework: normalizeExecutionRework(execution.rework),
2022
- external: execution.external === true ? true : void 0
2023
+ external: execution.external === true ? true : void 0,
2024
+ errorCode: typeof execution.errorCode === "string" && execution.errorCode !== "" ? execution.errorCode : void 0,
2025
+ retryHint: typeof execution.retryHint === "string" && execution.retryHint !== "" ? execution.retryHint : void 0
2023
2026
  }));
2024
2027
  task.workspaceId = normalizeTargetId(row.workspaceId);
2025
2028
  task.mode = normalizeTargetId(row.mode);
@@ -3266,7 +3269,11 @@ function parseEnvelopeAction(value) {
3266
3269
  "taskId",
3267
3270
  "result",
3268
3271
  "initiatedBy",
3269
- "summary"
3272
+ "summary",
3273
+ "executionId",
3274
+ "startedAt",
3275
+ "errorCode",
3276
+ "retryHint"
3270
3277
  ])) return void 0;
3271
3278
  if (taskId === void 0) return void 0;
3272
3279
  if (action.result !== "succeeded" && action.result !== "failed") return void 0;
@@ -3275,6 +3282,11 @@ function parseEnvelopeAction(value) {
3275
3282
  if (initiatedBy === "" || initiatedBy.length > 200) return void 0;
3276
3283
  if (action.summary !== void 0 && typeof action.summary !== "string") return void 0;
3277
3284
  const summary = typeof action.summary === "string" ? action.summary.trim().slice(0, EXTERNAL_SUMMARY_MAX_LENGTH) : "";
3285
+ if (action.executionId !== void 0 && (typeof action.executionId !== "string" || action.executionId === "" || action.executionId.length > 128)) return void 0;
3286
+ if (action.startedAt !== void 0 && (typeof action.startedAt !== "number" || !Number.isFinite(action.startedAt) || action.startedAt < 0)) return void 0;
3287
+ for (const key of ["errorCode", "retryHint"]) if (action[key] !== void 0 && typeof action[key] !== "string") return void 0;
3288
+ const errorCode = typeof action.errorCode === "string" ? action.errorCode.trim().slice(0, 64) : "";
3289
+ const retryHint = typeof action.retryHint === "string" ? action.retryHint.trim().slice(0, EXTERNAL_SUMMARY_MAX_LENGTH) : "";
3278
3290
  return {
3279
3291
  requestId: envelope.requestId,
3280
3292
  action: {
@@ -3282,7 +3294,11 @@ function parseEnvelopeAction(value) {
3282
3294
  taskId,
3283
3295
  result: action.result,
3284
3296
  initiatedBy,
3285
- ...summary === "" ? {} : { summary }
3297
+ ...summary === "" ? {} : { summary },
3298
+ ...action.executionId === void 0 ? {} : { executionId: action.executionId },
3299
+ ...action.startedAt === void 0 ? {} : { startedAt: action.startedAt },
3300
+ ...errorCode === "" ? {} : { errorCode },
3301
+ ...retryHint === "" ? {} : { retryHint }
3286
3302
  }
3287
3303
  };
3288
3304
  }
@@ -4349,13 +4365,18 @@ var HostTaskLedger = class {
4349
4365
  if (task === void 0) throw new Error("task not found");
4350
4366
  if (task.archivedAt !== void 0) throw new Error("archived task is read-only");
4351
4367
  if (hasOpenExecution(task)) throw new Error("running task cannot receive an external outcome");
4368
+ if (action.executionId !== void 0 && task.executions.some((entry) => entry.id === action.executionId)) throw new Error("execution id already recorded");
4369
+ const succeeded = action.result === "succeeded";
4352
4370
  const execution = {
4353
- id: crypto.randomUUID(),
4371
+ id: action.executionId ?? crypto.randomUUID(),
4354
4372
  sessionId: void 0,
4355
- startedAt: now,
4373
+ startedAt: action.startedAt === void 0 ? now : Math.min(action.startedAt, now),
4356
4374
  endedAt: now,
4357
4375
  result: action.result,
4358
- error: action.summary,
4376
+ error: succeeded ? void 0 : action.summary,
4377
+ ...succeeded || action.errorCode === void 0 ? {} : { errorCode: action.errorCode },
4378
+ ...succeeded || action.retryHint === void 0 ? {} : { retryHint: action.retryHint },
4379
+ ...succeeded && action.summary !== void 0 ? { summary: { text: action.summary } } : {},
4359
4380
  initiatedBy: action.initiatedBy,
4360
4381
  external: true
4361
4382
  };
@@ -4539,6 +4560,13 @@ var HostTaskLedger = class {
4539
4560
  committed: false
4540
4561
  };
4541
4562
  const decision = this.launchGate?.(participant, { trigger });
4563
+ if (decision?.kind === "refuse") {
4564
+ if (progress !== void 0) return {
4565
+ runs: [],
4566
+ committed: false
4567
+ };
4568
+ throw new Error(`${decision.code}: ${decision.reason}`);
4569
+ }
4542
4570
  if (decision?.kind === "external") {
4543
4571
  let handed = before.map((task) => task.id === participant.id ? withStatus(participant, "running", now) : task);
4544
4572
  if (progress !== void 0) handed = applyScheduleProgress(handed, root.id, progress, now);
@@ -6738,6 +6766,18 @@ function launchDecision(answer, warn) {
6738
6766
  }
6739
6767
  const kind = answer.kind;
6740
6768
  if (kind === "external") return { kind: "external" };
6769
+ if (kind === "refuse") {
6770
+ const { code, reason } = answer;
6771
+ if (typeof code !== "string" || !/^[a-z][a-z0-9-]*$/.test(code) || typeof reason !== "string" || reason.trim() === "") {
6772
+ warn("returned a malformed refusal");
6773
+ return;
6774
+ }
6775
+ return {
6776
+ kind: "refuse",
6777
+ code,
6778
+ reason: reason.trim()
6779
+ };
6780
+ }
6741
6781
  if (kind !== "local") {
6742
6782
  warn("returned an unknown decision kind");
6743
6783
  return;
@@ -6915,6 +6955,31 @@ var TaskBoardExtensionRegistry = class {
6915
6955
  }
6916
6956
  }
6917
6957
  }
6958
+ /**
6959
+ * What the running providers say about one card, keyed by extension id.
6960
+ * Isolated per provider: a throw drops that provider's entry only.
6961
+ */
6962
+ describeTask(task) {
6963
+ return this.describe((entry) => entry.extension.describeTask?.(task));
6964
+ }
6965
+ /** The run handle a running provider holds for one card, keyed by extension id. */
6966
+ describeRun(taskId) {
6967
+ return this.describe((entry) => entry.extension.describeRun?.(taskId));
6968
+ }
6969
+ describe(read) {
6970
+ if (this.disposed) return void 0;
6971
+ const result = {};
6972
+ for (const entry of this.entries.values()) {
6973
+ if (!entry.active) continue;
6974
+ try {
6975
+ const view = read(entry);
6976
+ if (typeof view === "object" && view !== null && !Array.isArray(view)) result[entry.extension.id] = view;
6977
+ } catch (error) {
6978
+ this.logger.error(`[dsh-task-board] extension "${entry.extension.id}" description failed`, error);
6979
+ }
6980
+ }
6981
+ return Object.keys(result).length === 0 ? void 0 : result;
6982
+ }
6918
6983
  /** Published summaries of currently running providers, keyed by extension id. */
6919
6984
  published() {
6920
6985
  const result = {};
@@ -7592,6 +7657,14 @@ var TaskBoardHostService = class {
7592
7657
  registerExtension(extension) {
7593
7658
  return this.extensions.registerExtension(extension);
7594
7659
  }
7660
+ /** What running providers say about one card, for the model-facing tools. */
7661
+ describeTask(task) {
7662
+ return this.extensions.describeTask(task);
7663
+ }
7664
+ /** The run handle a running provider holds for one card, for `task_board_run`. */
7665
+ describeRun(taskId) {
7666
+ return this.extensions.describeRun(taskId);
7667
+ }
7595
7668
  /**
7596
7669
  * The host model catalog the settings card's model and reasoning-level
7597
7670
  * choices come from.
@@ -8475,6 +8548,24 @@ async function parseTaskDraft(llm, request, signal) {
8475
8548
  }
8476
8549
  //#endregion
8477
8550
  //#region src/host/agent-tools.ts
8551
+ /**
8552
+ * The one provider view a card carries, with its extension id as `provider`.
8553
+ * A provider that says `localPermission: false` marks a card the board's
8554
+ * session permission gate does not govern (it runs outside this Host).
8555
+ */
8556
+ function remoteView(views) {
8557
+ if (views === void 0) return void 0;
8558
+ const [id, view] = Object.entries(views)[0] ?? [];
8559
+ if (id === void 0 || view === void 0) return void 0;
8560
+ const { localPermission, ...rest } = view;
8561
+ return {
8562
+ view: {
8563
+ provider: id,
8564
+ ...rest
8565
+ },
8566
+ localPermission: localPermission !== false
8567
+ };
8568
+ }
8478
8569
  /** Registered tool names, in registration order. */
8479
8570
  const TASK_BOARD_TOOL_NAMES = [
8480
8571
  "task_board_list",
@@ -8550,7 +8641,10 @@ function executionView(execution) {
8550
8641
  startedAt: execution.startedAt,
8551
8642
  ...execution.endedAt === void 0 ? {} : { endedAt: execution.endedAt },
8552
8643
  ...execution.result === void 0 ? {} : { result: execution.result },
8644
+ ...execution.summary === void 0 ? {} : { summary: execution.summary.text },
8553
8645
  ...execution.error === void 0 ? {} : { error: execution.error },
8646
+ ...execution.errorCode === void 0 ? {} : { errorCode: execution.errorCode },
8647
+ ...execution.retryHint === void 0 ? {} : { retryHint: execution.retryHint },
8554
8648
  ...execution.initiatedBy === void 0 ? {} : { initiatedBy: execution.initiatedBy },
8555
8649
  ...execution.external === true ? { external: true } : {},
8556
8650
  ...execution.runGroupId === void 0 ? {} : { cascade: true },
@@ -8565,8 +8659,9 @@ function executionView(execution) {
8565
8659
  * targets, schedule, and the latest run. The prompt body rides only
8566
8660
  * task_board_get, so a fifty-task list stays readable.
8567
8661
  */
8568
- function taskSummary(task, tasks, sessionDefault) {
8662
+ function taskSummary(task, tasks, sessionDefault, host) {
8569
8663
  const latest = task.executions.at(-1);
8664
+ const remote = remoteView(host?.describeTask?.(task));
8570
8665
  const subtaskCount = directSubtasks(tasks, task.id).length;
8571
8666
  return {
8572
8667
  id: task.id,
@@ -8587,7 +8682,8 @@ function taskSummary(task, tasks, sessionDefault) {
8587
8682
  ...task.schedule === void 0 ? {} : { schedule: scheduleView(task.schedule) },
8588
8683
  ...task.freeze === void 0 ? {} : { continuationCard: true },
8589
8684
  ...task.permissionConfirmedAt === void 0 ? {} : { permissionConfirmedAt: task.permissionConfirmedAt },
8590
- ...requiresPermissionConfirmation(task, sessionDefault ?? "read-only") ? { permissionPending: true } : {},
8685
+ ...remote?.localPermission !== false && requiresPermissionConfirmation(task, sessionDefault ?? "read-only") ? { permissionPending: true } : {},
8686
+ ...remote === void 0 ? {} : { remote: remote.view },
8591
8687
  executionCount: task.executions.length,
8592
8688
  ...latest === void 0 ? {} : { latestExecution: executionView(latest) },
8593
8689
  createdAt: task.createdAt,
@@ -8595,10 +8691,10 @@ function taskSummary(task, tasks, sessionDefault) {
8595
8691
  };
8596
8692
  }
8597
8693
  /** One task's full detail: content, lineage, schedule, and recent runs. */
8598
- function taskDetail(task, tasks, sessionDefault) {
8694
+ function taskDetail(task, tasks, sessionDefault, host) {
8599
8695
  const parent = task.parentId === void 0 ? void 0 : tasks.find((item) => item.id === task.parentId);
8600
8696
  return {
8601
- ...taskSummary(task, tasks, sessionDefault),
8697
+ ...taskSummary(task, tasks, sessionDefault, host),
8602
8698
  prompt: task.prompt,
8603
8699
  depth: taskDepth(tasks, task.id),
8604
8700
  ...parent === void 0 ? {} : { parent: {
@@ -8621,7 +8717,7 @@ function taskDetail(task, tasks, sessionDefault) {
8621
8717
  references: task.handover.references,
8622
8718
  bundledAt: task.handover.bundledAt
8623
8719
  } },
8624
- subtasks: directSubtasks(tasks, task.id).map((child) => taskSummary(child, tasks, sessionDefault)),
8720
+ subtasks: directSubtasks(tasks, task.id).map((child) => taskSummary(child, tasks, sessionDefault, host)),
8625
8721
  executions: task.executions.slice(-10).map(executionView)
8626
8722
  };
8627
8723
  }
@@ -8630,6 +8726,18 @@ function openedExecutions(before, after) {
8630
8726
  const known = new Set(before.map((execution) => execution.id));
8631
8727
  return after.filter((execution) => !known.has(execution.id));
8632
8728
  }
8729
+ /** The identifiers of a run handle, lifted to the top level of the run output. */
8730
+ function liftHandle(handle) {
8731
+ const lifted = {};
8732
+ for (const key of [
8733
+ "executionId",
8734
+ "runId",
8735
+ "logPath",
8736
+ "target",
8737
+ "estimatedDurationMs"
8738
+ ]) if (handle[key] !== void 0) lifted[key] = handle[key];
8739
+ return lifted;
8740
+ }
8633
8741
  /** Board summary attached to task_board_list. */
8634
8742
  function boardView(snapshot, maxSubtaskDepth) {
8635
8743
  const counts = {
@@ -8706,7 +8814,7 @@ function buildSetParentTool(host) {
8706
8814
  if (task === void 0) return refused("task-not-found", "no task with id " + args.taskId);
8707
8815
  return json({
8708
8816
  ok: true,
8709
- task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission)
8817
+ task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission, host)
8710
8818
  });
8711
8819
  } catch (error) {
8712
8820
  return refused("refused", messageOf(error));
@@ -8722,6 +8830,7 @@ function buildRunTool(host) {
8722
8830
  "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.",
8723
8831
  "Clicking a subtask runs that subtask as its own root, again without opening anything for its descendants.",
8724
8832
  "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.",
8833
+ "A card whose run a provider takes over (for example a card pinned to a remote host) answers with that run handle at the top level - executionId, runId, logPath, target, estimatedDurationMs - and a note naming the call that blocks until it settles; a second run request against a card that already has a run in flight is refused with a stable code instead of overwriting it.",
8725
8834
  "Executions consume real API quota. Sessions are created asynchronously, so read their ids and outcomes back with task_board_get."
8726
8835
  ].join(" "),
8727
8836
  parameters: {
@@ -8756,15 +8865,23 @@ function buildRunTool(host) {
8756
8865
  }));
8757
8866
  });
8758
8867
  const root = snapshot.tasks.find((task) => task.id === args.taskId);
8868
+ const handle = remoteView(host.describeRun?.(String(args.taskId)))?.view;
8869
+ const waitHint = typeof handle?.next === "string" ? handle.next : void 0;
8759
8870
  return json({
8760
8871
  ok: true,
8761
8872
  started,
8762
- ...root === void 0 ? {} : { task: taskSummary(root, snapshot.tasks, snapshot.sessionDefaultPermission) },
8763
- note: "Executions run asynchronously; call task_board_get to read session ids and the settled outcome."
8873
+ ...handle === void 0 ? {} : {
8874
+ run: handle,
8875
+ ...liftHandle(handle)
8876
+ },
8877
+ ...root === void 0 ? {} : { task: taskSummary(root, snapshot.tasks, snapshot.sessionDefaultPermission, host) },
8878
+ note: waitHint ?? "Executions run asynchronously; call task_board_get to read session ids and the settled outcome."
8764
8879
  });
8765
8880
  } catch (error) {
8766
8881
  const message = messageOf(error);
8767
- return refused(message.startsWith("confirmation-required") ? "confirmation-required" : "refused", message);
8882
+ if (message.startsWith("confirmation-required")) return refused("confirmation-required", message);
8883
+ const coded = /^([a-z][a-z0-9-]*): ([\s\S]+)$/.exec(message);
8884
+ return coded === null ? refused("refused", message) : refused(coded[1], coded[2]);
8768
8885
  }
8769
8886
  }
8770
8887
  });
@@ -8842,7 +8959,7 @@ function buildManageTool(host) {
8842
8959
  return json({
8843
8960
  ok: true,
8844
8961
  action: args.action,
8845
- ...task === void 0 ? {} : { task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission) },
8962
+ ...task === void 0 ? {} : { task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission, host) },
8846
8963
  note: "The outcome is recorded as its own execution, so the terminal column and the run history agree. Read it back with task_board_get."
8847
8964
  });
8848
8965
  } catch (error) {
@@ -8906,7 +9023,7 @@ function buildManageTool(host) {
8906
9023
  return json({
8907
9024
  ok: true,
8908
9025
  action: args.action,
8909
- task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission)
9026
+ task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission, host)
8910
9027
  });
8911
9028
  } catch (error) {
8912
9029
  return refused("refused", messageOf(error));
@@ -8983,7 +9100,7 @@ function buildScheduleTool(host) {
8983
9100
  return json({
8984
9101
  ok: true,
8985
9102
  schedule: task.schedule === void 0 ? null : scheduleView(task.schedule),
8986
- task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission)
9103
+ task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission, host)
8987
9104
  });
8988
9105
  } catch (error) {
8989
9106
  return refused("refused", messageOf(error));
@@ -8997,7 +9114,7 @@ function buildListTool(host) {
8997
9114
  description: [
8998
9115
  "List tasks on the DSH task board (the Host-authoritative ledger behind the Web GUI task board).",
8999
9116
  "Filters: status column, parentId (direct subtasks), rootsOnly, tag, free-text query, and archived inclusion.",
9000
- "Returns each task id, title, column, parent/subtask link, execution targets, schedule and latest run outcome, plus the board summary (revision, time zone, subtask depth limit, session-default permission).",
9117
+ "Returns each task id, title, column, parent/subtask link, execution targets, schedule and latest run outcome (a card a provider runs remotely also carries a `remote` summary: host, agent, mode, whether a follow-up is possible), plus the board summary (revision, time zone, subtask depth limit, session-default permission).",
9001
9118
  "Use task_board_get for one task in full, task_board_create to add work, and task_board_run to execute it."
9002
9119
  ].join(" "),
9003
9120
  parameters: {
@@ -9067,7 +9184,7 @@ function buildListTool(host) {
9067
9184
  board: boardView(snapshot, snapshot.maxSubtaskDepth ?? 1),
9068
9185
  total: matched.length,
9069
9186
  count: Math.min(matched.length, limit),
9070
- tasks: matched.slice(0, limit).map((task) => taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission))
9187
+ tasks: matched.slice(0, limit).map((task) => taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission, host))
9071
9188
  });
9072
9189
  }
9073
9190
  });
@@ -9096,7 +9213,7 @@ function buildGetTool(host) {
9096
9213
  if (task === void 0) return refused("task-not-found", "no task with id " + args.taskId);
9097
9214
  return json({
9098
9215
  ok: true,
9099
- task: taskDetail(task, snapshot.tasks, snapshot.sessionDefaultPermission)
9216
+ task: taskDetail(task, snapshot.tasks, snapshot.sessionDefaultPermission, host)
9100
9217
  });
9101
9218
  }
9102
9219
  });
@@ -9244,7 +9361,7 @@ function buildCreateTool(host) {
9244
9361
  if (task === void 0) return refused("create-failed", "the Host did not confirm the new task");
9245
9362
  return json({
9246
9363
  ok: true,
9247
- task: taskDetail(task, snapshot.tasks, snapshot.sessionDefaultPermission)
9364
+ task: taskDetail(task, snapshot.tasks, snapshot.sessionDefaultPermission, host)
9248
9365
  });
9249
9366
  } catch (error) {
9250
9367
  return refused("refused", messageOf(error));
@@ -9362,7 +9479,7 @@ function buildUpdateTool(host) {
9362
9479
  if (task === void 0) return refused("task-not-found", "no task with id " + args.taskId);
9363
9480
  return json({
9364
9481
  ok: true,
9365
- task: taskDetail(task, snapshot.tasks, snapshot.sessionDefaultPermission)
9482
+ task: taskDetail(task, snapshot.tasks, snapshot.sessionDefaultPermission, host)
9366
9483
  });
9367
9484
  } catch (error) {
9368
9485
  return refused("refused", messageOf(error));
@@ -245,6 +245,17 @@ export type TaskBoardLaunchDecision =
245
245
  */
246
246
  | {
247
247
  kind: 'external';
248
+ }
249
+ /**
250
+ * The provider refuses this run. The board opens nothing, writes nothing and
251
+ * answers the caller with `code: reason`, so a second run request against a
252
+ * card the provider already holds is an explicit refusal rather than a
253
+ * silent overwrite. A scheduled occurrence is skipped instead of thrown.
254
+ */
255
+ | {
256
+ kind: 'refuse';
257
+ code: string;
258
+ reason: string;
248
259
  };
249
260
  /**
250
261
  * Decide whether one launch belongs to the provider, and how it runs.
@@ -355,6 +366,20 @@ export interface TaskBoardExtension {
355
366
  stop?(): void;
356
367
  /** Route one dispatched action; the returned value goes back to the dispatcher. */
357
368
  handleAction?(request: TaskBoardExtensionActionRequest): unknown | Promise<unknown>;
369
+ /**
370
+ * Model-facing summary of one card this provider owns, merged into the card
371
+ * the `task_board_get` / `task_board_list` tools return under `remote`. An
372
+ * object may carry `localPermission: false` to say the board's local session
373
+ * permission gate does not apply to the card, which drops `permissionPending`
374
+ * from the tool output. Optional: the API version stays 1.
375
+ */
376
+ describeTask?(task: TaskRecord): Record<string, unknown> | undefined;
377
+ /**
378
+ * The handle of the run the provider took over for `taskId`, read right after
379
+ * `task_board_run` so the caller gets identifiers instead of an empty list.
380
+ * Optional on the same terms as {@link TaskBoardExtension.describeTask}.
381
+ */
382
+ describeRun?(taskId: string): Record<string, unknown> | undefined;
358
383
  }
359
384
  /** Board mirror an extension's browser half observes. */
360
385
  export interface TaskBoardClientMirror {
@@ -24,8 +24,11 @@ export type ExecutionOutcome = 'succeeded' | 'failed' | 'cancelled';
24
24
  export interface ExecutionSummary {
25
25
  /** Last assistant message text of the run, bounded by {@link EXECUTION_SUMMARY_LIMIT}. */
26
26
  text: string;
27
- /** Seq of the session event that text came from; absent text has no seq either. */
28
- seq: number;
27
+ /**
28
+ * Seq of the session event that text came from. Absent on an external run's
29
+ * conclusion, which was never read out of a Host session.
30
+ */
31
+ seq?: number;
29
32
  }
30
33
  /**
31
34
  * Upper bound of one recorded summary, in characters. The ledger stores a
@@ -62,8 +65,16 @@ export interface ExecutionRecord {
62
65
  endedAt: number | undefined;
63
66
  /** Outcome once settled. */
64
67
  result: ExecutionOutcome | undefined;
65
- /** Human failure text when the run failed (prompt rejection or agent error). */
68
+ /**
69
+ * Human failure text when the run failed (prompt rejection or agent error).
70
+ * Only a failure writes it: an external run's success conclusion rides
71
+ * {@link ExecutionRecord.summary}.
72
+ */
66
73
  error: string | undefined;
74
+ /** Stable machine-readable failure code a provider reported with the verdict. */
75
+ errorCode?: string;
76
+ /** One line telling the caller whether and how to retry a failed external run. */
77
+ retryHint?: string;
67
78
  /**
68
79
  * Session id of the DSH session that issued the run/rerun action (issue #6
69
80
  * audit origin). Client-asserted, not a trust boundary; absent when the run
@@ -1,4 +1,5 @@
1
1
  import { type ToolDefinition } from '@deepseek-ai/dsh-tools';
2
+ import { type TaskRecord } from '../core/tasks.ts';
2
3
  import type { TaskBoardAction, TaskBoardSnapshot } from '../protocol.ts';
3
4
  import type { TaskBoardLaunchTrigger } from '../core/extension.ts';
4
5
  /**
@@ -14,6 +15,10 @@ export interface TaskBoardToolHost {
14
15
  * a provider's launch handler can tell an agent's run from a person's.
15
16
  */
16
17
  apply(requestId: string, action: TaskBoardAction, initiator?: string, trigger?: TaskBoardLaunchTrigger): TaskBoardSnapshot | Promise<TaskBoardSnapshot>;
18
+ /** What running providers say about one card, keyed by extension id (optional). */
19
+ describeTask?(task: TaskRecord): Record<string, Record<string, unknown>> | undefined;
20
+ /** The run handle a provider holds for one card, keyed by extension id (optional). */
21
+ describeRun?(taskId: string): Record<string, Record<string, unknown>> | undefined;
17
22
  }
18
23
  /** Registered tool names, in registration order. */
19
24
  export declare const TASK_BOARD_TOOL_NAMES: readonly ["task_board_list", "task_board_get", "task_board_create", "task_board_update", "task_board_set_parent", "task_board_run", "task_board_manage", "task_board_schedule"];
@@ -119,6 +119,14 @@ export declare class TaskBoardExtensionRegistry {
119
119
  * @returns the first decision a running provider made, or undefined.
120
120
  */
121
121
  interceptLaunch(task: TaskRecord, context: TaskBoardLaunchContext): TaskBoardLaunchDecision | undefined;
122
+ /**
123
+ * What the running providers say about one card, keyed by extension id.
124
+ * Isolated per provider: a throw drops that provider's entry only.
125
+ */
126
+ describeTask(task: TaskRecord): Record<string, Record<string, unknown>> | undefined;
127
+ /** The run handle a running provider holds for one card, keyed by extension id. */
128
+ describeRun(taskId: string): Record<string, Record<string, unknown>> | undefined;
129
+ private describe;
122
130
  /** Published summaries of currently running providers, keyed by extension id. */
123
131
  published(): Record<string, TaskBoardExtensionPayload>;
124
132
  /** Fan a status change out to every running provider, isolated per callback. */
@@ -6,7 +6,7 @@ import { type TaskBoardAction, type TaskBoardEventPayload, type TaskBoardSnapsho
6
6
  import type { CardDefaults } from './core/card-defaults.ts';
7
7
  import { TaskBoardExtensionRegistry, type TaskBoardExtensionLogger } from './host/extension-registry.ts';
8
8
  import type { TaskBoardExtension, TaskBoardLaunchTrigger } from './core/extension.ts';
9
- import { type ScheduleMode } from './core/tasks.ts';
9
+ import { type ScheduleMode, type TaskRecord } from './core/tasks.ts';
10
10
  import type { ModelCatalogView } from './core/model-catalog.ts';
11
11
  import type { TaskPermission } from './core/handover.ts';
12
12
  import { type ModelInfoResolver, type TaskBoardAttachmentStore } from './host/attachments.ts';
@@ -204,6 +204,10 @@ export declare class TaskBoardHostService {
204
204
  * disposer releases it (its stored data stays).
205
205
  */
206
206
  registerExtension(extension: TaskBoardExtension): () => void;
207
+ /** What running providers say about one card, for the model-facing tools. */
208
+ describeTask(task: TaskRecord): Record<string, Record<string, unknown>> | undefined;
209
+ /** The run handle a running provider holds for one card, for `task_board_run`. */
210
+ describeRun(taskId: string): Record<string, Record<string, unknown>> | undefined;
207
211
  /**
208
212
  * The host model catalog the settings card's model and reasoning-level
209
213
  * choices come from.
@@ -187,7 +187,16 @@ export type TaskBoardAction = {
187
187
  taskId: string;
188
188
  result: 'succeeded' | 'failed';
189
189
  initiatedBy: string;
190
+ /** Success: stored as the execution summary. Failure: stored as the error text. */
190
191
  summary?: string;
192
+ /** Id the execution record takes, so a handle returned at launch stays valid. */
193
+ executionId?: string;
194
+ /** Instant the outside run started (ms epoch); the record starts there instead of at settlement. */
195
+ startedAt?: number;
196
+ /** Failure only: stable machine-readable code. */
197
+ errorCode?: string;
198
+ /** Failure only: one line on whether and how to retry. */
199
+ retryHint?: string;
191
200
  } | {
192
201
  kind: 'set-schedule';
193
202
  taskId: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-client-ui-task-board",
3
3
  "description": "Host-authoritative task board for the DSH Web GUI with real session execution, Host cron scheduling, and optional cross-platform idle-sleep protection; mounted without DSH source changes.",
4
- "version": "0.4.20",
4
+ "version": "0.4.21",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",
@@ -62,7 +62,10 @@ function ExecutionRow({ execution, timeZone, onOpen }: {
62
62
  // it prints verbatim, in the neutral secondary style the row's other metadata
63
63
  // uses. A failed or cancelled one still reads as the error it is, and so does
64
64
  // every text a Host-run execution recorded.
65
+ // New records keep that conclusion on `summary`; the error-field reading stays
66
+ // for the succeeded external records written before the two were separated.
65
67
  const recordedConclusion = external && result === 'succeeded'
68
+ const conclusion = execution.summary?.text
66
69
  return (
67
70
  <li
68
71
  className={css.executionRow}
@@ -101,6 +104,9 @@ function ExecutionRow({ execution, timeZone, onOpen }: {
101
104
  {t('detail.execution.initiator', { session: execution.initiatedBy })}
102
105
  </span>
103
106
  )}
107
+ {conclusion !== undefined && (
108
+ <span className={css.executionTimes}>{conclusion}</span>
109
+ )}
104
110
  {execution.error !== undefined && execution.error !== '' && (
105
111
  <span className={recordedConclusion ? css.executionTimes : css.executionError}>
106
112
  {recordedConclusion ? execution.error : failureText(execution.error)}
@@ -89,8 +89,9 @@ export function executionSummaryOf(events: readonly SummaryEvent[], startedAt: n
89
89
  export function normalizeExecutionSummary(value: unknown): ExecutionSummary | undefined {
90
90
  if (typeof value !== 'object' || value === null) return undefined
91
91
  const row = value as Record<string, unknown>
92
- if (typeof row.text !== 'string' || typeof row.seq !== 'number' || !Number.isFinite(row.seq)) return undefined
92
+ if (typeof row.text !== 'string') return undefined
93
+ if (row.seq !== undefined && (typeof row.seq !== 'number' || !Number.isFinite(row.seq))) return undefined
93
94
  const text = row.text.trim()
94
95
  if (text === '') return undefined
95
- return { text: truncateExecutionSummary(text), seq: row.seq }
96
+ return { text: truncateExecutionSummary(text), ...(row.seq === undefined ? {} : { seq: row.seq }) }
96
97
  }
@@ -316,6 +316,13 @@ export type TaskBoardLaunchDecision =
316
316
  * `record-external-outcome` action once its own run settles.
317
317
  */
318
318
  | { kind: 'external' }
319
+ /**
320
+ * The provider refuses this run. The board opens nothing, writes nothing and
321
+ * answers the caller with `code: reason`, so a second run request against a
322
+ * card the provider already holds is an explicit refusal rather than a
323
+ * silent overwrite. A scheduled occurrence is skipped instead of thrown.
324
+ */
325
+ | { kind: 'refuse'; code: string; reason: string }
319
326
 
320
327
  /**
321
328
  * Decide whether one launch belongs to the provider, and how it runs.
@@ -437,6 +444,20 @@ export interface TaskBoardExtension {
437
444
  stop?(): void
438
445
  /** Route one dispatched action; the returned value goes back to the dispatcher. */
439
446
  handleAction?(request: TaskBoardExtensionActionRequest): unknown | Promise<unknown>
447
+ /**
448
+ * Model-facing summary of one card this provider owns, merged into the card
449
+ * the `task_board_get` / `task_board_list` tools return under `remote`. An
450
+ * object may carry `localPermission: false` to say the board's local session
451
+ * permission gate does not apply to the card, which drops `permissionPending`
452
+ * from the tool output. Optional: the API version stays 1.
453
+ */
454
+ describeTask?(task: TaskRecord): Record<string, unknown> | undefined
455
+ /**
456
+ * The handle of the run the provider took over for `taskId`, read right after
457
+ * `task_board_run` so the caller gets identifiers instead of an empty list.
458
+ * Optional on the same terms as {@link TaskBoardExtension.describeTask}.
459
+ */
460
+ describeRun?(taskId: string): Record<string, unknown> | undefined
440
461
  }
441
462
 
442
463
  /** Board mirror an extension's browser half observes. */
package/src/core/store.ts CHANGED
@@ -280,6 +280,8 @@ export function parseLedger(raw: string | null): TaskRecord[] {
280
280
  // is what the history is for, and only its instructions are unrecoverable.
281
281
  rework: normalizeExecutionRework(execution.rework),
282
282
  external: execution.external === true ? true : undefined,
283
+ errorCode: typeof execution.errorCode === 'string' && execution.errorCode !== '' ? execution.errorCode : undefined,
284
+ retryHint: typeof execution.retryHint === 'string' && execution.retryHint !== '' ? execution.retryHint : undefined,
283
285
  }))
284
286
  // Execution targets are normalized like the schedule: blank strings
285
287
  // clear the pin and unknown permission strings from a future version
package/src/core/tasks.ts CHANGED
@@ -27,8 +27,11 @@ export type ExecutionOutcome = 'succeeded' | 'failed' | 'cancelled'
27
27
  export interface ExecutionSummary {
28
28
  /** Last assistant message text of the run, bounded by {@link EXECUTION_SUMMARY_LIMIT}. */
29
29
  text: string
30
- /** Seq of the session event that text came from; absent text has no seq either. */
31
- seq: number
30
+ /**
31
+ * Seq of the session event that text came from. Absent on an external run's
32
+ * conclusion, which was never read out of a Host session.
33
+ */
34
+ seq?: number
32
35
  }
33
36
 
34
37
  /**
@@ -75,8 +78,16 @@ export interface ExecutionRecord {
75
78
  endedAt: number | undefined
76
79
  /** Outcome once settled. */
77
80
  result: ExecutionOutcome | undefined
78
- /** Human failure text when the run failed (prompt rejection or agent error). */
81
+ /**
82
+ * Human failure text when the run failed (prompt rejection or agent error).
83
+ * Only a failure writes it: an external run's success conclusion rides
84
+ * {@link ExecutionRecord.summary}.
85
+ */
79
86
  error: string | undefined
87
+ /** Stable machine-readable failure code a provider reported with the verdict. */
88
+ errorCode?: string
89
+ /** One line telling the caller whether and how to retry a failed external run. */
90
+ retryHint?: string
80
91
  /**
81
92
  * Session id of the DSH session that issued the run/rerun action (issue #6
82
93
  * audit origin). Client-asserted, not a trust boundary; absent when the run