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

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
@@ -1200,7 +1200,9 @@ function startExecution(task, now, executionId, initiatedBy, runGroupId, rework)
1200
1200
  ...task.freeze === void 0 ? {} : {
1201
1201
  frozenAt: task.freeze.frozenAt,
1202
1202
  ...task.freeze.frozenBy === void 0 ? {} : { frozenBy: task.freeze.frozenBy }
1203
- }
1203
+ },
1204
+ promptSnapshot: task.prompt,
1205
+ titleSnapshot: task.title
1204
1206
  };
1205
1207
  return {
1206
1208
  task: {
@@ -1619,12 +1621,13 @@ function executionSummaryOf(events, startedAt) {
1619
1621
  function normalizeExecutionSummary(value) {
1620
1622
  if (typeof value !== "object" || value === null) return void 0;
1621
1623
  const row = value;
1622
- if (typeof row.text !== "string" || typeof row.seq !== "number" || !Number.isFinite(row.seq)) return void 0;
1624
+ if (typeof row.text !== "string") return void 0;
1625
+ if (row.seq !== void 0 && (typeof row.seq !== "number" || !Number.isFinite(row.seq))) return void 0;
1623
1626
  const text = row.text.trim();
1624
1627
  if (text === "") return void 0;
1625
1628
  return {
1626
1629
  text: truncateExecutionSummary(text),
1627
- seq: row.seq
1630
+ ...row.seq === void 0 ? {} : { seq: row.seq }
1628
1631
  };
1629
1632
  }
1630
1633
  /** Marker replacing every sensitive match. */
@@ -1854,6 +1857,8 @@ function isTaskRecordShape(value) {
1854
1857
  if (entry.initiatedBy !== void 0 && typeof entry.initiatedBy !== "string") return false;
1855
1858
  if (entry.frozenBy !== void 0 && typeof entry.frozenBy !== "string") return false;
1856
1859
  if (entry.frozenAt !== void 0 && typeof entry.frozenAt !== "number") return false;
1860
+ if (entry.promptSnapshot !== void 0 && typeof entry.promptSnapshot !== "string") return false;
1861
+ if (entry.titleSnapshot !== void 0 && typeof entry.titleSnapshot !== "string") return false;
1857
1862
  if (entry.external !== void 0 && typeof entry.external !== "boolean") return false;
1858
1863
  }
1859
1864
  return true;
@@ -2019,7 +2024,9 @@ function parseLedger(raw) {
2019
2024
  ownError: typeof execution.ownError === "string" ? execution.ownError : void 0,
2020
2025
  summary: normalizeExecutionSummary(execution.summary),
2021
2026
  rework: normalizeExecutionRework(execution.rework),
2022
- external: execution.external === true ? true : void 0
2027
+ external: execution.external === true ? true : void 0,
2028
+ errorCode: typeof execution.errorCode === "string" && execution.errorCode !== "" ? execution.errorCode : void 0,
2029
+ retryHint: typeof execution.retryHint === "string" && execution.retryHint !== "" ? execution.retryHint : void 0
2023
2030
  }));
2024
2031
  task.workspaceId = normalizeTargetId(row.workspaceId);
2025
2032
  task.mode = normalizeTargetId(row.mode);
@@ -2724,26 +2731,23 @@ function applyDeleteTag(tasks, name, now) {
2724
2731
  * back to the runtime default); an unknown permission string is ignored so
2725
2732
  * stale UI can never persist a value the execution service rejects.
2726
2733
  */
2727
- /** The fields that edit the task's content (what the user reads and what the
2728
- * next execution sends). Unlike the execution targets they stay editable only
2729
- * while the task has never started executing — after the first run the
2730
- * recorded prompt is the record of what actually ran, so it becomes read-only.
2734
+ /**
2735
+ * The fields that freeze with the first run. Split by what keeps them honest:
2736
+ *
2737
+ * - The CONTENT fields stay editable between runs because every execution
2738
+ * record captures the prompt/title snapshot it was opened with (see
2739
+ * `startExecution`), so a post-run edit changes only the next run, never
2740
+ * the audit trail.
2741
+ * - The ATTACHMENTS freeze at the first run and stay frozen: they are binary
2742
+ * references the record does not snapshot, and a card whose first run
2743
+ * already consumed an image keeps that image — the record of what ran
2744
+ * stays what it was. `canEditTaskAttachments` owns that boundary.
2731
2745
  */
2732
2746
  const TASK_CONTENT_FIELDS = [
2733
2747
  "title",
2734
2748
  "description",
2735
2749
  "prompt"
2736
2750
  ];
2737
- /**
2738
- * The fields that freeze with the card content: the text the card says AND
2739
- * the attachments it carries.
2740
- *
2741
- * The attachments freeze with the content because they ARE part of what the
2742
- * card hands to its execution: a card whose first run already consumed an
2743
- * image keeps that image, and the record of what ran stays what it was. An
2744
- * executed or archived card therefore refuses an attachment change exactly
2745
- * as it refuses a prompt change.
2746
- */
2747
2751
  const TASK_FROZEN_FIELDS = [...TASK_CONTENT_FIELDS, "attachments"];
2748
2752
  /** Whether an update patch touches any task-content field. */
2749
2753
  function hasContentPatch(patch) {
@@ -2751,12 +2755,25 @@ function hasContentPatch(patch) {
2751
2755
  }
2752
2756
  /**
2753
2757
  * Whether a task's content may still be edited: the task must be on-board
2754
- * (not archived) and must never have started executing. Fail-closed: a task
2755
- * with any execution record — running, settled, or cancelled before launch —
2756
- * keeps its content fixed. The run, not the column, is the trigger: a card
2757
- * parked in 'running' by hand has nothing recorded yet and stays editable.
2758
+ * (not archived) and must not have an open execution. Settled history does
2759
+ * NOT lock the card: new execution records carry the prompt/title snapshot
2760
+ * they were opened with (`promptSnapshot`/`titleSnapshot`), so a
2761
+ * post-run edit changes only the next run, never the audit trail. The run,
2762
+ * not the column, stays the trigger: a card parked in 'running' by hand has
2763
+ * nothing recorded yet and stays editable, and a card mid-run is locked
2764
+ * until its execution settles.
2758
2765
  */
2759
2766
  function canEditTaskContent(task) {
2767
+ return task.archivedAt === void 0 && !hasOpenExecution(task);
2768
+ }
2769
+ /**
2770
+ * Whether a task's attachments may still be edited: unlike the content
2771
+ * fields, attachments are NOT captured on the execution record, so they keep
2772
+ * the historical boundary — editable until the first run opens, frozen for
2773
+ * every executed or archived card afterwards. The record of what ran keeps
2774
+ * referencing exactly what ran.
2775
+ */
2776
+ function canEditTaskAttachments(task) {
2760
2777
  return task.archivedAt === void 0 && task.executions.length === 0;
2761
2778
  }
2762
2779
  /** Keep an unknown permission string from entering the ledger. */
@@ -2912,6 +2929,8 @@ function validImportedKnownFields(value) {
2912
2929
  if (execution.external !== void 0 && typeof execution.external !== "boolean") return false;
2913
2930
  if (execution.frozenBy !== void 0 && typeof execution.frozenBy !== "string") return false;
2914
2931
  if (execution.frozenAt !== void 0 && typeof execution.frozenAt !== "number") return false;
2932
+ if (execution.promptSnapshot !== void 0 && typeof execution.promptSnapshot !== "string") return false;
2933
+ if (execution.titleSnapshot !== void 0 && typeof execution.titleSnapshot !== "string") return false;
2915
2934
  }
2916
2935
  }
2917
2936
  return true;
@@ -2939,7 +2958,9 @@ function importedTask(value) {
2939
2958
  ...execution.initiatedBy === void 0 ? {} : { initiatedBy: execution.initiatedBy },
2940
2959
  ...execution.external === true ? { external: true } : {},
2941
2960
  ...execution.frozenAt === void 0 ? {} : { frozenAt: execution.frozenAt },
2942
- ...execution.frozenBy === void 0 ? {} : { frozenBy: execution.frozenBy }
2961
+ ...execution.frozenBy === void 0 ? {} : { frozenBy: execution.frozenBy },
2962
+ ...execution.promptSnapshot === void 0 ? {} : { promptSnapshot: execution.promptSnapshot },
2963
+ ...execution.titleSnapshot === void 0 ? {} : { titleSnapshot: execution.titleSnapshot }
2943
2964
  })),
2944
2965
  ...task.schedule === void 0 ? {} : { schedule: { ...task.schedule } },
2945
2966
  ...task.parentId === void 0 ? {} : { parentId: task.parentId },
@@ -3266,7 +3287,11 @@ function parseEnvelopeAction(value) {
3266
3287
  "taskId",
3267
3288
  "result",
3268
3289
  "initiatedBy",
3269
- "summary"
3290
+ "summary",
3291
+ "executionId",
3292
+ "startedAt",
3293
+ "errorCode",
3294
+ "retryHint"
3270
3295
  ])) return void 0;
3271
3296
  if (taskId === void 0) return void 0;
3272
3297
  if (action.result !== "succeeded" && action.result !== "failed") return void 0;
@@ -3275,6 +3300,11 @@ function parseEnvelopeAction(value) {
3275
3300
  if (initiatedBy === "" || initiatedBy.length > 200) return void 0;
3276
3301
  if (action.summary !== void 0 && typeof action.summary !== "string") return void 0;
3277
3302
  const summary = typeof action.summary === "string" ? action.summary.trim().slice(0, EXTERNAL_SUMMARY_MAX_LENGTH) : "";
3303
+ if (action.executionId !== void 0 && (typeof action.executionId !== "string" || action.executionId === "" || action.executionId.length > 128)) return void 0;
3304
+ if (action.startedAt !== void 0 && (typeof action.startedAt !== "number" || !Number.isFinite(action.startedAt) || action.startedAt < 0)) return void 0;
3305
+ for (const key of ["errorCode", "retryHint"]) if (action[key] !== void 0 && typeof action[key] !== "string") return void 0;
3306
+ const errorCode = typeof action.errorCode === "string" ? action.errorCode.trim().slice(0, 64) : "";
3307
+ const retryHint = typeof action.retryHint === "string" ? action.retryHint.trim().slice(0, EXTERNAL_SUMMARY_MAX_LENGTH) : "";
3278
3308
  return {
3279
3309
  requestId: envelope.requestId,
3280
3310
  action: {
@@ -3282,7 +3312,11 @@ function parseEnvelopeAction(value) {
3282
3312
  taskId,
3283
3313
  result: action.result,
3284
3314
  initiatedBy,
3285
- ...summary === "" ? {} : { summary }
3315
+ ...summary === "" ? {} : { summary },
3316
+ ...action.executionId === void 0 ? {} : { executionId: action.executionId },
3317
+ ...action.startedAt === void 0 ? {} : { startedAt: action.startedAt },
3318
+ ...errorCode === "" ? {} : { errorCode },
3319
+ ...retryHint === "" ? {} : { retryHint }
3286
3320
  }
3287
3321
  };
3288
3322
  }
@@ -4302,6 +4336,7 @@ var HostTaskLedger = class {
4302
4336
  const task = this.document.tasks.find((task) => task.id === action.taskId);
4303
4337
  if (task === void 0) throw new Error("task not found");
4304
4338
  if (task.archivedAt !== void 0) throw new Error("archived task is read-only");
4339
+ if ("attachments" in action.patch && !canEditTaskAttachments(task)) throw new Error("task has already been executed");
4305
4340
  if (hasContentPatch(action.patch) && !canEditTaskContent(task)) throw new Error("task has already been executed");
4306
4341
  if ("title" in action.patch && action.patch.title?.trim() === "") throw new Error("title is required");
4307
4342
  const patch = action.patch.freeze === null || action.patch.freeze === void 0 || initiator === void 0 || initiator === "" ? action.patch : {
@@ -4349,13 +4384,18 @@ var HostTaskLedger = class {
4349
4384
  if (task === void 0) throw new Error("task not found");
4350
4385
  if (task.archivedAt !== void 0) throw new Error("archived task is read-only");
4351
4386
  if (hasOpenExecution(task)) throw new Error("running task cannot receive an external outcome");
4387
+ if (action.executionId !== void 0 && task.executions.some((entry) => entry.id === action.executionId)) throw new Error("execution id already recorded");
4388
+ const succeeded = action.result === "succeeded";
4352
4389
  const execution = {
4353
- id: crypto.randomUUID(),
4390
+ id: action.executionId ?? crypto.randomUUID(),
4354
4391
  sessionId: void 0,
4355
- startedAt: now,
4392
+ startedAt: action.startedAt === void 0 ? now : Math.min(action.startedAt, now),
4356
4393
  endedAt: now,
4357
4394
  result: action.result,
4358
- error: action.summary,
4395
+ error: succeeded ? void 0 : action.summary,
4396
+ ...succeeded || action.errorCode === void 0 ? {} : { errorCode: action.errorCode },
4397
+ ...succeeded || action.retryHint === void 0 ? {} : { retryHint: action.retryHint },
4398
+ ...succeeded && action.summary !== void 0 ? { summary: { text: action.summary } } : {},
4359
4399
  initiatedBy: action.initiatedBy,
4360
4400
  external: true
4361
4401
  };
@@ -4539,6 +4579,13 @@ var HostTaskLedger = class {
4539
4579
  committed: false
4540
4580
  };
4541
4581
  const decision = this.launchGate?.(participant, { trigger });
4582
+ if (decision?.kind === "refuse") {
4583
+ if (progress !== void 0) return {
4584
+ runs: [],
4585
+ committed: false
4586
+ };
4587
+ throw new Error(`${decision.code}: ${decision.reason}`);
4588
+ }
4542
4589
  if (decision?.kind === "external") {
4543
4590
  let handed = before.map((task) => task.id === participant.id ? withStatus(participant, "running", now) : task);
4544
4591
  if (progress !== void 0) handed = applyScheduleProgress(handed, root.id, progress, now);
@@ -6738,6 +6785,18 @@ function launchDecision(answer, warn) {
6738
6785
  }
6739
6786
  const kind = answer.kind;
6740
6787
  if (kind === "external") return { kind: "external" };
6788
+ if (kind === "refuse") {
6789
+ const { code, reason } = answer;
6790
+ if (typeof code !== "string" || !/^[a-z][a-z0-9-]*$/.test(code) || typeof reason !== "string" || reason.trim() === "") {
6791
+ warn("returned a malformed refusal");
6792
+ return;
6793
+ }
6794
+ return {
6795
+ kind: "refuse",
6796
+ code,
6797
+ reason: reason.trim()
6798
+ };
6799
+ }
6741
6800
  if (kind !== "local") {
6742
6801
  warn("returned an unknown decision kind");
6743
6802
  return;
@@ -6915,6 +6974,31 @@ var TaskBoardExtensionRegistry = class {
6915
6974
  }
6916
6975
  }
6917
6976
  }
6977
+ /**
6978
+ * What the running providers say about one card, keyed by extension id.
6979
+ * Isolated per provider: a throw drops that provider's entry only.
6980
+ */
6981
+ describeTask(task) {
6982
+ return this.describe((entry) => entry.extension.describeTask?.(task));
6983
+ }
6984
+ /** The run handle a running provider holds for one card, keyed by extension id. */
6985
+ describeRun(taskId) {
6986
+ return this.describe((entry) => entry.extension.describeRun?.(taskId));
6987
+ }
6988
+ describe(read) {
6989
+ if (this.disposed) return void 0;
6990
+ const result = {};
6991
+ for (const entry of this.entries.values()) {
6992
+ if (!entry.active) continue;
6993
+ try {
6994
+ const view = read(entry);
6995
+ if (typeof view === "object" && view !== null && !Array.isArray(view)) result[entry.extension.id] = view;
6996
+ } catch (error) {
6997
+ this.logger.error(`[dsh-task-board] extension "${entry.extension.id}" description failed`, error);
6998
+ }
6999
+ }
7000
+ return Object.keys(result).length === 0 ? void 0 : result;
7001
+ }
6918
7002
  /** Published summaries of currently running providers, keyed by extension id. */
6919
7003
  published() {
6920
7004
  const result = {};
@@ -7592,6 +7676,14 @@ var TaskBoardHostService = class {
7592
7676
  registerExtension(extension) {
7593
7677
  return this.extensions.registerExtension(extension);
7594
7678
  }
7679
+ /** What running providers say about one card, for the model-facing tools. */
7680
+ describeTask(task) {
7681
+ return this.extensions.describeTask(task);
7682
+ }
7683
+ /** The run handle a running provider holds for one card, for `task_board_run`. */
7684
+ describeRun(taskId) {
7685
+ return this.extensions.describeRun(taskId);
7686
+ }
7595
7687
  /**
7596
7688
  * The host model catalog the settings card's model and reasoning-level
7597
7689
  * choices come from.
@@ -8475,6 +8567,24 @@ async function parseTaskDraft(llm, request, signal) {
8475
8567
  }
8476
8568
  //#endregion
8477
8569
  //#region src/host/agent-tools.ts
8570
+ /**
8571
+ * The one provider view a card carries, with its extension id as `provider`.
8572
+ * A provider that says `localPermission: false` marks a card the board's
8573
+ * session permission gate does not govern (it runs outside this Host).
8574
+ */
8575
+ function remoteView(views) {
8576
+ if (views === void 0) return void 0;
8577
+ const [id, view] = Object.entries(views)[0] ?? [];
8578
+ if (id === void 0 || view === void 0) return void 0;
8579
+ const { localPermission, ...rest } = view;
8580
+ return {
8581
+ view: {
8582
+ provider: id,
8583
+ ...rest
8584
+ },
8585
+ localPermission: localPermission !== false
8586
+ };
8587
+ }
8478
8588
  /** Registered tool names, in registration order. */
8479
8589
  const TASK_BOARD_TOOL_NAMES = [
8480
8590
  "task_board_list",
@@ -8550,7 +8660,10 @@ function executionView(execution) {
8550
8660
  startedAt: execution.startedAt,
8551
8661
  ...execution.endedAt === void 0 ? {} : { endedAt: execution.endedAt },
8552
8662
  ...execution.result === void 0 ? {} : { result: execution.result },
8663
+ ...execution.summary === void 0 ? {} : { summary: execution.summary.text },
8553
8664
  ...execution.error === void 0 ? {} : { error: execution.error },
8665
+ ...execution.errorCode === void 0 ? {} : { errorCode: execution.errorCode },
8666
+ ...execution.retryHint === void 0 ? {} : { retryHint: execution.retryHint },
8554
8667
  ...execution.initiatedBy === void 0 ? {} : { initiatedBy: execution.initiatedBy },
8555
8668
  ...execution.external === true ? { external: true } : {},
8556
8669
  ...execution.runGroupId === void 0 ? {} : { cascade: true },
@@ -8565,8 +8678,9 @@ function executionView(execution) {
8565
8678
  * targets, schedule, and the latest run. The prompt body rides only
8566
8679
  * task_board_get, so a fifty-task list stays readable.
8567
8680
  */
8568
- function taskSummary(task, tasks, sessionDefault) {
8681
+ function taskSummary(task, tasks, sessionDefault, host) {
8569
8682
  const latest = task.executions.at(-1);
8683
+ const remote = remoteView(host?.describeTask?.(task));
8570
8684
  const subtaskCount = directSubtasks(tasks, task.id).length;
8571
8685
  return {
8572
8686
  id: task.id,
@@ -8587,7 +8701,8 @@ function taskSummary(task, tasks, sessionDefault) {
8587
8701
  ...task.schedule === void 0 ? {} : { schedule: scheduleView(task.schedule) },
8588
8702
  ...task.freeze === void 0 ? {} : { continuationCard: true },
8589
8703
  ...task.permissionConfirmedAt === void 0 ? {} : { permissionConfirmedAt: task.permissionConfirmedAt },
8590
- ...requiresPermissionConfirmation(task, sessionDefault ?? "read-only") ? { permissionPending: true } : {},
8704
+ ...remote?.localPermission !== false && requiresPermissionConfirmation(task, sessionDefault ?? "read-only") ? { permissionPending: true } : {},
8705
+ ...remote === void 0 ? {} : { remote: remote.view },
8591
8706
  executionCount: task.executions.length,
8592
8707
  ...latest === void 0 ? {} : { latestExecution: executionView(latest) },
8593
8708
  createdAt: task.createdAt,
@@ -8595,10 +8710,10 @@ function taskSummary(task, tasks, sessionDefault) {
8595
8710
  };
8596
8711
  }
8597
8712
  /** One task's full detail: content, lineage, schedule, and recent runs. */
8598
- function taskDetail(task, tasks, sessionDefault) {
8713
+ function taskDetail(task, tasks, sessionDefault, host) {
8599
8714
  const parent = task.parentId === void 0 ? void 0 : tasks.find((item) => item.id === task.parentId);
8600
8715
  return {
8601
- ...taskSummary(task, tasks, sessionDefault),
8716
+ ...taskSummary(task, tasks, sessionDefault, host),
8602
8717
  prompt: task.prompt,
8603
8718
  depth: taskDepth(tasks, task.id),
8604
8719
  ...parent === void 0 ? {} : { parent: {
@@ -8621,7 +8736,7 @@ function taskDetail(task, tasks, sessionDefault) {
8621
8736
  references: task.handover.references,
8622
8737
  bundledAt: task.handover.bundledAt
8623
8738
  } },
8624
- subtasks: directSubtasks(tasks, task.id).map((child) => taskSummary(child, tasks, sessionDefault)),
8739
+ subtasks: directSubtasks(tasks, task.id).map((child) => taskSummary(child, tasks, sessionDefault, host)),
8625
8740
  executions: task.executions.slice(-10).map(executionView)
8626
8741
  };
8627
8742
  }
@@ -8630,6 +8745,18 @@ function openedExecutions(before, after) {
8630
8745
  const known = new Set(before.map((execution) => execution.id));
8631
8746
  return after.filter((execution) => !known.has(execution.id));
8632
8747
  }
8748
+ /** The identifiers of a run handle, lifted to the top level of the run output. */
8749
+ function liftHandle(handle) {
8750
+ const lifted = {};
8751
+ for (const key of [
8752
+ "executionId",
8753
+ "runId",
8754
+ "logPath",
8755
+ "target",
8756
+ "estimatedDurationMs"
8757
+ ]) if (handle[key] !== void 0) lifted[key] = handle[key];
8758
+ return lifted;
8759
+ }
8633
8760
  /** Board summary attached to task_board_list. */
8634
8761
  function boardView(snapshot, maxSubtaskDepth) {
8635
8762
  const counts = {
@@ -8706,7 +8833,7 @@ function buildSetParentTool(host) {
8706
8833
  if (task === void 0) return refused("task-not-found", "no task with id " + args.taskId);
8707
8834
  return json({
8708
8835
  ok: true,
8709
- task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission)
8836
+ task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission, host)
8710
8837
  });
8711
8838
  } catch (error) {
8712
8839
  return refused("refused", messageOf(error));
@@ -8722,6 +8849,7 @@ function buildRunTool(host) {
8722
8849
  "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
8850
  "Clicking a subtask runs that subtask as its own root, again without opening anything for its descendants.",
8724
8851
  "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.",
8852
+ "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
8853
  "Executions consume real API quota. Sessions are created asynchronously, so read their ids and outcomes back with task_board_get."
8726
8854
  ].join(" "),
8727
8855
  parameters: {
@@ -8756,15 +8884,23 @@ function buildRunTool(host) {
8756
8884
  }));
8757
8885
  });
8758
8886
  const root = snapshot.tasks.find((task) => task.id === args.taskId);
8887
+ const handle = remoteView(host.describeRun?.(String(args.taskId)))?.view;
8888
+ const waitHint = typeof handle?.next === "string" ? handle.next : void 0;
8759
8889
  return json({
8760
8890
  ok: true,
8761
8891
  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."
8892
+ ...handle === void 0 ? {} : {
8893
+ run: handle,
8894
+ ...liftHandle(handle)
8895
+ },
8896
+ ...root === void 0 ? {} : { task: taskSummary(root, snapshot.tasks, snapshot.sessionDefaultPermission, host) },
8897
+ note: waitHint ?? "Executions run asynchronously; call task_board_get to read session ids and the settled outcome."
8764
8898
  });
8765
8899
  } catch (error) {
8766
8900
  const message = messageOf(error);
8767
- return refused(message.startsWith("confirmation-required") ? "confirmation-required" : "refused", message);
8901
+ if (message.startsWith("confirmation-required")) return refused("confirmation-required", message);
8902
+ const coded = /^([a-z][a-z0-9-]*): ([\s\S]+)$/.exec(message);
8903
+ return coded === null ? refused("refused", message) : refused(coded[1], coded[2]);
8768
8904
  }
8769
8905
  }
8770
8906
  });
@@ -8842,7 +8978,7 @@ function buildManageTool(host) {
8842
8978
  return json({
8843
8979
  ok: true,
8844
8980
  action: args.action,
8845
- ...task === void 0 ? {} : { task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission) },
8981
+ ...task === void 0 ? {} : { task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission, host) },
8846
8982
  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
8983
  });
8848
8984
  } catch (error) {
@@ -8906,7 +9042,7 @@ function buildManageTool(host) {
8906
9042
  return json({
8907
9043
  ok: true,
8908
9044
  action: args.action,
8909
- task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission)
9045
+ task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission, host)
8910
9046
  });
8911
9047
  } catch (error) {
8912
9048
  return refused("refused", messageOf(error));
@@ -8983,7 +9119,7 @@ function buildScheduleTool(host) {
8983
9119
  return json({
8984
9120
  ok: true,
8985
9121
  schedule: task.schedule === void 0 ? null : scheduleView(task.schedule),
8986
- task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission)
9122
+ task: taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission, host)
8987
9123
  });
8988
9124
  } catch (error) {
8989
9125
  return refused("refused", messageOf(error));
@@ -8997,7 +9133,7 @@ function buildListTool(host) {
8997
9133
  description: [
8998
9134
  "List tasks on the DSH task board (the Host-authoritative ledger behind the Web GUI task board).",
8999
9135
  "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).",
9136
+ "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
9137
  "Use task_board_get for one task in full, task_board_create to add work, and task_board_run to execute it."
9002
9138
  ].join(" "),
9003
9139
  parameters: {
@@ -9067,7 +9203,7 @@ function buildListTool(host) {
9067
9203
  board: boardView(snapshot, snapshot.maxSubtaskDepth ?? 1),
9068
9204
  total: matched.length,
9069
9205
  count: Math.min(matched.length, limit),
9070
- tasks: matched.slice(0, limit).map((task) => taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission))
9206
+ tasks: matched.slice(0, limit).map((task) => taskSummary(task, snapshot.tasks, snapshot.sessionDefaultPermission, host))
9071
9207
  });
9072
9208
  }
9073
9209
  });
@@ -9096,7 +9232,7 @@ function buildGetTool(host) {
9096
9232
  if (task === void 0) return refused("task-not-found", "no task with id " + args.taskId);
9097
9233
  return json({
9098
9234
  ok: true,
9099
- task: taskDetail(task, snapshot.tasks, snapshot.sessionDefaultPermission)
9235
+ task: taskDetail(task, snapshot.tasks, snapshot.sessionDefaultPermission, host)
9100
9236
  });
9101
9237
  }
9102
9238
  });
@@ -9244,7 +9380,7 @@ function buildCreateTool(host) {
9244
9380
  if (task === void 0) return refused("create-failed", "the Host did not confirm the new task");
9245
9381
  return json({
9246
9382
  ok: true,
9247
- task: taskDetail(task, snapshot.tasks, snapshot.sessionDefaultPermission)
9383
+ task: taskDetail(task, snapshot.tasks, snapshot.sessionDefaultPermission, host)
9248
9384
  });
9249
9385
  } catch (error) {
9250
9386
  return refused("refused", messageOf(error));
@@ -9362,7 +9498,7 @@ function buildUpdateTool(host) {
9362
9498
  if (task === void 0) return refused("task-not-found", "no task with id " + args.taskId);
9363
9499
  return json({
9364
9500
  ok: true,
9365
- task: taskDetail(task, snapshot.tasks, snapshot.sessionDefaultPermission)
9501
+ task: taskDetail(task, snapshot.tasks, snapshot.sessionDefaultPermission, host)
9366
9502
  });
9367
9503
  } catch (error) {
9368
9504
  return refused("refused", messageOf(error));
@@ -56,7 +56,7 @@ export declare function attachmentKindOf(file: File): TaskAttachmentKind;
56
56
  * The component owns the local staging only: the selection it reports is what
57
57
  * the card will carry, and the parent uploads the staged files on save.
58
58
  */
59
- export declare function AttachmentField({ selection, onChange, limits, disabled, onError, }: {
59
+ export declare function AttachmentField({ selection, onChange, limits, disabled, lockedHint, onError, }: {
60
60
  /** What the card currently carries and what is staged on top of it. */
61
61
  selection: AttachmentSelection;
62
62
  /** Receives the new selection after every change. */
@@ -65,6 +65,8 @@ export declare function AttachmentField({ selection, onChange, limits, disabled,
65
65
  limits?: AttachmentLimits;
66
66
  /** Whether the field refuses new input. */
67
67
  disabled?: boolean;
68
+ /** Replaces the inviting upload hint when the caller locks the field. */
69
+ lockedHint?: string;
68
70
  /** Receives the reason a selection was refused. */
69
71
  onError?: (message: string) => void;
70
72
  }): import("react").JSX.Element;
@@ -157,6 +157,7 @@ export declare const zh: {
157
157
  'detail.close': string;
158
158
  'edit.title': string;
159
159
  'edit.save': string;
160
+ 'edit.attachmentsLocked': string;
160
161
  'new.duplicateTitle': string;
161
162
  'new.archiveOriginal': string;
162
163
  'detail.prompt': string;
@@ -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
@@ -96,6 +107,15 @@ export interface ExecutionRecord {
96
107
  frozenAt?: number;
97
108
  /** Freeze source session captured from the card snapshot when the run opened. */
98
109
  frozenBy?: string;
110
+ /**
111
+ * The prompt this execution was opened with, captured at run start. The
112
+ * card's prompt stays editable between runs; this snapshot — not the live
113
+ * field — is the record of what actually ran. Absent on executions recorded
114
+ * before snapshots were introduced.
115
+ */
116
+ promptSnapshot?: string;
117
+ /** Title captured alongside {@link promptSnapshot} when the run opened. */
118
+ titleSnapshot?: string;
99
119
  /**
100
120
  * Cascade run group shared by the parent execution and every descendant
101
121
  * execution one run request opened. Absent on a plain single-task run.