@fish-under-sea/dsh-client-ui-task-board-fish 0.0.0-stage → 0.5.0
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/LICENSE +202 -0
- package/README.i18n.yaml +6 -0
- package/README.md +202 -2
- package/README.zh.md +203 -0
- package/cordis.patch.yml +12 -0
- package/icon.svg +3 -0
- package/lib/client.js +12941 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +10471 -0
- package/lib/types/client/PluginSettingsCard.d.ts +144 -0
- package/lib/types/client/TaskBoardSettingsCard.d.ts +92 -0
- package/lib/types/client/apply-guard.d.ts +25 -0
- package/lib/types/client/board/ClampedMarkdown.d.ts +3 -0
- package/lib/types/client/board/ConfirmDialog.d.ts +15 -0
- package/lib/types/client/board/EditTaskModal.d.ts +17 -0
- package/lib/types/client/board/LinkSubtaskModal.d.ts +14 -0
- package/lib/types/client/board/NewTaskModal.d.ts +26 -0
- package/lib/types/client/board/TagManagerModal.d.ts +26 -0
- package/lib/types/client/board/TaskBoard.d.ts +26 -0
- package/lib/types/client/board/TaskCard.d.ts +36 -0
- package/lib/types/client/board/TaskDetail.d.ts +9 -0
- package/lib/types/client/board/TaskForm.d.ts +72 -0
- package/lib/types/client/board/VerificationReport.d.ts +23 -0
- package/lib/types/client/board/card-view.d.ts +113 -0
- package/lib/types/client/board/icons.d.ts +32 -0
- package/lib/types/client/board/overlay.d.ts +69 -0
- package/lib/types/client/board/parse-model-pref.d.ts +4 -0
- package/lib/types/client/board/preset-label.d.ts +22 -0
- package/lib/types/client/board/status-key.d.ts +19 -0
- package/lib/types/client/board/task-markdown.d.ts +19 -0
- package/lib/types/client/host-api.d.ts +63 -0
- package/lib/types/client/index.d.ts +128 -0
- package/lib/types/client/locales.d.ts +443 -0
- package/lib/types/client/main-session.d.ts +32 -0
- package/lib/types/client/native-panel.d.ts +48 -0
- package/lib/types/client/plugin-card-seat.d.ts +108 -0
- package/lib/types/client/schedule-presets.d.ts +10 -0
- package/lib/types/client/schedule-zone.d.ts +97 -0
- package/lib/types/client/seats.d.ts +18 -0
- package/lib/types/client/service.d.ts +32 -0
- package/lib/types/client/settings-entry-form.d.ts +49 -0
- package/lib/types/client/settings-form.d.ts +213 -0
- package/lib/types/core/controller.d.ts +373 -0
- package/lib/types/core/degraded-reason.d.ts +46 -0
- package/lib/types/core/extension.d.ts +283 -0
- package/lib/types/core/freeze-snapshot.d.ts +71 -0
- package/lib/types/core/handover.d.ts +70 -0
- package/lib/types/core/issue-form.d.ts +16 -0
- package/lib/types/core/package-name.d.ts +9 -0
- package/lib/types/core/poll-cadence.d.ts +31 -0
- package/lib/types/core/schedule.d.ts +124 -0
- package/lib/types/core/session-reuse.d.ts +24 -0
- package/lib/types/core/store.d.ts +64 -0
- package/lib/types/core/subtask.d.ts +141 -0
- package/lib/types/core/tasks.d.ts +601 -0
- package/lib/types/core/use-cases/task-archive.d.ts +20 -0
- package/lib/types/core/use-cases/task-create.d.ts +27 -0
- package/lib/types/core/use-cases/task-delete.d.ts +27 -0
- package/lib/types/core/use-cases/task-parent.d.ts +21 -0
- package/lib/types/core/use-cases/task-schedule.d.ts +96 -0
- package/lib/types/core/use-cases/task-tag.d.ts +48 -0
- package/lib/types/core/use-cases/task-update.d.ts +56 -0
- package/lib/types/core/verification-budget.d.ts +52 -0
- package/lib/types/core/verification.d.ts +753 -0
- package/lib/types/core/workspace-target.d.ts +41 -0
- package/lib/types/dsh-home.d.ts +16 -0
- package/lib/types/host/agent-tools.d.ts +27 -0
- package/lib/types/host/extension-registry.d.ts +111 -0
- package/lib/types/host/llm-dispatch.d.ts +63 -0
- package/lib/types/host/verification-gate.d.ts +95 -0
- package/lib/types/host/verification-runner.d.ts +139 -0
- package/lib/types/host/workspace-evidence.d.ts +53 -0
- package/lib/types/host-ai.d.ts +51 -0
- package/lib/types/host-ledger.d.ts +385 -0
- package/lib/types/host-routes.d.ts +36 -0
- package/lib/types/host-runner.d.ts +252 -0
- package/lib/types/host-service.d.ts +379 -0
- package/lib/types/http.d.ts +59 -0
- package/lib/types/index.d.ts +322 -0
- package/lib/types/loopback.d.ts +24 -0
- package/lib/types/mount-once.d.ts +55 -0
- package/lib/types/power-inhibitor.d.ts +73 -0
- package/lib/types/protocol.d.ts +212 -0
- package/lib/types/tool-surface.d.ts +71 -0
- package/package.json +107 -4
- package/src/client/PluginSettingsCard.tsx +564 -0
- package/src/client/TaskBoardSettingsCard.tsx +539 -0
- package/src/client/apply-guard.ts +35 -0
- package/src/client/board/ClampedMarkdown.tsx +69 -0
- package/src/client/board/ConfirmDialog.tsx +44 -0
- package/src/client/board/EditTaskModal.tsx +110 -0
- package/src/client/board/LinkSubtaskModal.tsx +97 -0
- package/src/client/board/NewTaskModal.tsx +718 -0
- package/src/client/board/TagManagerModal.tsx +235 -0
- package/src/client/board/TaskBoard.tsx +558 -0
- package/src/client/board/TaskCard.tsx +315 -0
- package/src/client/board/TaskDetail.tsx +985 -0
- package/src/client/board/TaskForm.tsx +264 -0
- package/src/client/board/VerificationReport.tsx +322 -0
- package/src/client/board/card-view.ts +220 -0
- package/src/client/board/icons.tsx +89 -0
- package/src/client/board/overlay.tsx +189 -0
- package/src/client/board/parse-model-pref.ts +35 -0
- package/src/client/board/preset-label.ts +44 -0
- package/src/client/board/status-key.ts +41 -0
- package/src/client/board/task-markdown.module.css +137 -0
- package/src/client/board/task-markdown.tsx +106 -0
- package/src/client/board-settings.module.css +66 -0
- package/src/client/board.module.css +1837 -0
- package/src/client/css-modules.d.ts +5 -0
- package/src/client/host-api.ts +336 -0
- package/src/client/index.ts +501 -0
- package/src/client/locales.ts +905 -0
- package/src/client/main-session.ts +43 -0
- package/src/client/native-panel.tsx +140 -0
- package/src/client/plugin-card-seat.ts +199 -0
- package/src/client/schedule-presets.ts +13 -0
- package/src/client/schedule-zone.ts +233 -0
- package/src/client/seats.tsx +58 -0
- package/src/client/service.ts +94 -0
- package/src/client/settings-card.module.css +444 -0
- package/src/client/settings-entry-form.ts +142 -0
- package/src/client/settings-form.ts +468 -0
- package/src/core/controller.ts +871 -0
- package/src/core/degraded-reason.ts +81 -0
- package/src/core/extension.ts +376 -0
- package/src/core/freeze-snapshot.ts +213 -0
- package/src/core/handover.ts +132 -0
- package/src/core/issue-form.ts +19 -0
- package/src/core/package-name.ts +9 -0
- package/src/core/poll-cadence.ts +41 -0
- package/src/core/schedule.ts +363 -0
- package/src/core/session-reuse.ts +40 -0
- package/src/core/store.ts +371 -0
- package/src/core/subtask.ts +341 -0
- package/src/core/tasks.ts +843 -0
- package/src/core/use-cases/task-archive.ts +91 -0
- package/src/core/use-cases/task-create.ts +110 -0
- package/src/core/use-cases/task-delete.ts +43 -0
- package/src/core/use-cases/task-parent.ts +65 -0
- package/src/core/use-cases/task-schedule.ts +251 -0
- package/src/core/use-cases/task-tag.ts +110 -0
- package/src/core/use-cases/task-update.ts +126 -0
- package/src/core/verification-budget.ts +115 -0
- package/src/core/verification.ts +1594 -0
- package/src/core/workspace-target.ts +59 -0
- package/src/dsh-home.ts +42 -0
- package/src/host/agent-tools.ts +762 -0
- package/src/host/extension-registry.ts +509 -0
- package/src/host/llm-dispatch.ts +87 -0
- package/src/host/verification-gate.ts +487 -0
- package/src/host/verification-runner.ts +702 -0
- package/src/host/workspace-evidence.ts +176 -0
- package/src/host-ai.ts +158 -0
- package/src/host-ledger.ts +1826 -0
- package/src/host-routes.ts +306 -0
- package/src/host-runner.ts +755 -0
- package/src/host-service.ts +1112 -0
- package/src/http.ts +127 -0
- package/src/index.ts +722 -0
- package/src/loopback.ts +63 -0
- package/src/mount-once.ts +142 -0
- package/src/power-inhibitor.ts +321 -0
- package/src/protocol.ts +591 -0
- package/src/tool-surface.ts +95 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family health ledger's degraded-record contract (issues #1528, #1730).
|
|
3
|
+
*
|
|
4
|
+
* A family plugin row that fails during apply is recorded by the dsh-web-all
|
|
5
|
+
* shell as a degraded record; the shell serves the ledger through its
|
|
6
|
+
* loopback-only `GET /api/dsh-web-all/degraded` route because the failed
|
|
7
|
+
* plugin could not register any route of its own — the task board whose ledger
|
|
8
|
+
* lock is held by another DSH process is exactly that case, and without this
|
|
9
|
+
* the panel could only report "the Host API is not mounted".
|
|
10
|
+
*
|
|
11
|
+
* Both halves define this shape: the shell WRITES it (packages/dsh-web-all,
|
|
12
|
+
* src/degraded.ts — the two packages have no import edge, one is bundled into
|
|
13
|
+
* the other's profile) and a plugin's browser half PARSES it. The edits move
|
|
14
|
+
* together.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Where a degraded row failed: module import, plugin shape, or fiber start. */
|
|
18
|
+
export type DegradedStage = 'import' | 'shape' | 'start'
|
|
19
|
+
|
|
20
|
+
/** One degraded family row as the shell's health route serves it. */
|
|
21
|
+
export interface DegradedRow {
|
|
22
|
+
/** Real plugin package name from the shell row config. */
|
|
23
|
+
plugin: string
|
|
24
|
+
/** Where the failure happened. */
|
|
25
|
+
stage: DegradedStage
|
|
26
|
+
/** The shell's one-line reason, for display. */
|
|
27
|
+
reason: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The one degraded record naming `plugin`, or undefined when that row is not
|
|
32
|
+
* degraded (or the payload does not come from the shell's own shape). A
|
|
33
|
+
* plugin may appear once: the shell keys the ledger by package name and
|
|
34
|
+
* refreshes the record on every new failure.
|
|
35
|
+
* @param body - parsed JSON body of the health route.
|
|
36
|
+
* @param plugin - the real plugin package name to look for.
|
|
37
|
+
* @returns the degraded row, or undefined when the ledger does not name it.
|
|
38
|
+
*/
|
|
39
|
+
export function degradedRowOf(body: unknown, plugin: string): DegradedRow | undefined {
|
|
40
|
+
if (typeof body !== 'object' || body === null) return undefined
|
|
41
|
+
const ledger = (body as { ok?: unknown; degraded?: unknown })
|
|
42
|
+
if (ledger.ok !== true || !Array.isArray(ledger.degraded)) return undefined
|
|
43
|
+
for (const entry of ledger.degraded) {
|
|
44
|
+
if (typeof entry !== 'object' || entry === null) continue
|
|
45
|
+
const record = entry as { plugin?: unknown; stage?: unknown; reason?: unknown }
|
|
46
|
+
if (record.plugin !== plugin) continue
|
|
47
|
+
const stage = record.stage === 'import' || record.stage === 'shape' || record.stage === 'start' ? record.stage : undefined
|
|
48
|
+
if (stage === undefined) continue
|
|
49
|
+
return { plugin, stage, reason: typeof record.reason === 'string' ? record.reason : '' }
|
|
50
|
+
}
|
|
51
|
+
return undefined
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The ledger owner pid a task-board lock reason names, when it names one. */
|
|
55
|
+
const OWNED_BY_PROCESS_RE = /already owned by process\s+(\d+)/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The marker the ledger appends when it could NOT confirm the recorded PID
|
|
59
|
+
* belongs to the lock's real owner: the PID was reused by an unrelated process
|
|
60
|
+
* after a crash, and the reason then carries the manual-removal step instead.
|
|
61
|
+
* That reason must be rendered verbatim — telling the user to close "the other
|
|
62
|
+
* DSH instance" would send them after a process that never touched the board.
|
|
63
|
+
*/
|
|
64
|
+
const UNCONFIRMED_OWNER_MARKER = 'reused after a crash'
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Extract the pid of the LIVE process a ledger-lock failure blames, when the
|
|
68
|
+
* reason identifies one. The task board's lock refusal is the one degraded
|
|
69
|
+
* reason that carries an owner the user can act on, so the panel renders the
|
|
70
|
+
* pid in its own sentence and adds the guidance that actually applies.
|
|
71
|
+
* @param reason - the shell's one-line failure reason.
|
|
72
|
+
* @returns the confirmed owner pid, or undefined when the reason names none or
|
|
73
|
+
* warns that the PID may have been reused (its own text owns the recovery).
|
|
74
|
+
*/
|
|
75
|
+
export function ledgerOwnerPid(reason: string): number | undefined {
|
|
76
|
+
if (reason.includes(UNCONFIRMED_OWNER_MARKER)) return undefined
|
|
77
|
+
const match = OWNED_BY_PROCESS_RE.exec(reason)
|
|
78
|
+
if (match === null) return undefined
|
|
79
|
+
const pid = Number(match[1])
|
|
80
|
+
return Number.isSafeInteger(pid) && pid > 0 ? pid : undefined
|
|
81
|
+
}
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The task board's external provider extension contract.
|
|
3
|
+
*
|
|
4
|
+
* This module is the single source of truth for how another plugin adds a
|
|
5
|
+
* provider surface to the task board: the cordis service name both halves
|
|
6
|
+
* publish, the API version they negotiate, the child seats a provider renders
|
|
7
|
+
* into, the host capability face a provider implements against, and the client
|
|
8
|
+
* capability face the board's browser half provides. It is framework-free and
|
|
9
|
+
* shared by the host and browser programs; the only imported SDK type is
|
|
10
|
+
* type-only, so the browser bundle never pulls a value out of an SDK package.
|
|
11
|
+
*
|
|
12
|
+
* @module dsh-task-board/core/extension
|
|
13
|
+
*/
|
|
14
|
+
import type { ToolDefinition } from '@deepseek-ai/dsh-tools'
|
|
15
|
+
import type { ExecutionOutcome, TaskRecord, TaskStatus } from './tasks.ts'
|
|
16
|
+
|
|
17
|
+
/** Cordis service name the host and browser halves each publish. */
|
|
18
|
+
export const TASK_BOARD_SERVICE_NAME = 'taskBoard'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Contract version of {@link TASK_BOARD_SERVICE_NAME}. A provider declares the
|
|
22
|
+
* version it was built against; the board refuses (visibly) any other version
|
|
23
|
+
* instead of guessing at a stale shape.
|
|
24
|
+
*/
|
|
25
|
+
export const TASK_BOARD_API_VERSION = 1
|
|
26
|
+
|
|
27
|
+
/** Child seat a provider registers its task-detail section into. */
|
|
28
|
+
export const TASK_BOARD_DETAIL_SECTION = 'task-board.detail.section'
|
|
29
|
+
/** Child seat a provider registers its settings section into. */
|
|
30
|
+
export const TASK_BOARD_SETTINGS_SECTION = 'task-board.settings.section'
|
|
31
|
+
/** Child seat a provider registers its card decoration into. */
|
|
32
|
+
export const TASK_BOARD_CARD_DECORATION = 'task-board.card.decoration'
|
|
33
|
+
|
|
34
|
+
/** Every child seat the board declares for extensions, in render order. */
|
|
35
|
+
export const TASK_BOARD_EXTENSION_SEATS: readonly string[] = [
|
|
36
|
+
TASK_BOARD_DETAIL_SECTION,
|
|
37
|
+
TASK_BOARD_SETTINGS_SECTION,
|
|
38
|
+
TASK_BOARD_CARD_DECORATION,
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Largest accepted extension payload, in bytes of its JSON serialization. One
|
|
43
|
+
* integration entry — and one action payload — may carry schema the board does
|
|
44
|
+
* not interpret, but never enough of it to bloat the ledger or the action
|
|
45
|
+
* channel.
|
|
46
|
+
*/
|
|
47
|
+
export const TASK_BOARD_PAYLOAD_LIMIT_BYTES = 64 * 1024
|
|
48
|
+
|
|
49
|
+
/** Depth beyond which a payload is refused instead of walked. */
|
|
50
|
+
const PAYLOAD_DEPTH_LIMIT = 64
|
|
51
|
+
|
|
52
|
+
/** One opaque provider payload the board stores and forwards without interpreting. */
|
|
53
|
+
export type TaskBoardExtensionPayload = Record<string, unknown>
|
|
54
|
+
|
|
55
|
+
/** Whether a value is a plain JSON value (no undefined, function, symbol, bigint or cycle). */
|
|
56
|
+
function isJsonValue(value: unknown, depth: number): boolean {
|
|
57
|
+
if (depth > PAYLOAD_DEPTH_LIMIT) return false
|
|
58
|
+
if (value === null) return true
|
|
59
|
+
switch (typeof value) {
|
|
60
|
+
case 'string':
|
|
61
|
+
case 'boolean':
|
|
62
|
+
return true
|
|
63
|
+
case 'number':
|
|
64
|
+
return Number.isFinite(value)
|
|
65
|
+
// A provider's in-memory metadata legitimately clears a field by setting it
|
|
66
|
+
// to undefined; JSON serialization drops such a key, so the persisted
|
|
67
|
+
// payload is still pure JSON.
|
|
68
|
+
case 'undefined':
|
|
69
|
+
return true
|
|
70
|
+
case 'object':
|
|
71
|
+
break
|
|
72
|
+
default:
|
|
73
|
+
return false
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(value)) return value.every(item => isJsonValue(item, depth + 1))
|
|
76
|
+
const prototype = Object.getPrototypeOf(value)
|
|
77
|
+
if (prototype !== Object.prototype && prototype !== null) return false
|
|
78
|
+
return Object.values(value as Record<string, unknown>).every(item => isJsonValue(item, depth + 1))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Validate one extension payload: a pure JSON object whose serialization fits
|
|
83
|
+
* {@link TASK_BOARD_PAYLOAD_LIMIT_BYTES}. Arrays, primitives and non-plain
|
|
84
|
+
* objects are refused; the board never interprets the keys.
|
|
85
|
+
* @param value - candidate payload.
|
|
86
|
+
* @returns whether the value is an acceptable opaque payload.
|
|
87
|
+
*/
|
|
88
|
+
export function isTaskBoardExtensionPayload(value: unknown): value is TaskBoardExtensionPayload {
|
|
89
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) return false
|
|
90
|
+
if (!isJsonValue(value, 0)) return false
|
|
91
|
+
try {
|
|
92
|
+
return new TextEncoder().encode(JSON.stringify(value)).length <= TASK_BOARD_PAYLOAD_LIMIT_BYTES
|
|
93
|
+
} catch {
|
|
94
|
+
return false
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Byte length of a value's JSON serialization, or undefined when it does not serialize. */
|
|
99
|
+
export function taskBoardPayloadBytes(value: unknown): number | undefined {
|
|
100
|
+
try {
|
|
101
|
+
return new TextEncoder().encode(JSON.stringify(value)).length
|
|
102
|
+
} catch {
|
|
103
|
+
return undefined
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Normalize a task's whole integrations container: a plain JSON object whose
|
|
109
|
+
* values are each an opaque provider payload within the size limit. A malformed
|
|
110
|
+
* container normalizes to undefined (the field is dropped), and one malformed
|
|
111
|
+
* entry is dropped alone so a single bad provider can never take a card — or
|
|
112
|
+
* another provider's data — with it.
|
|
113
|
+
* @param value - candidate container from the wire, the ledger, or a create input.
|
|
114
|
+
* @returns the cleaned container, or undefined when nothing usable remains.
|
|
115
|
+
*/
|
|
116
|
+
export function normalizeTaskIntegrations(value: unknown): Record<string, TaskBoardExtensionPayload> | undefined {
|
|
117
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) return undefined
|
|
118
|
+
const prototype = Object.getPrototypeOf(value)
|
|
119
|
+
if (prototype !== Object.prototype && prototype !== null) return undefined
|
|
120
|
+
const result: Record<string, TaskBoardExtensionPayload> = {}
|
|
121
|
+
for (const [key, entry] of Object.entries(value as Record<string, unknown>)) {
|
|
122
|
+
if (key === '') continue
|
|
123
|
+
if (!isTaskBoardExtensionPayload(entry)) continue
|
|
124
|
+
result[key] = entry
|
|
125
|
+
}
|
|
126
|
+
return Object.keys(result).length === 0 ? undefined : result
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** One action a provider dispatches over the board's same-origin channel. */
|
|
130
|
+
export interface TaskBoardExtensionActionRequest {
|
|
131
|
+
/** Id of the extension the action belongs to. */
|
|
132
|
+
extensionId: string
|
|
133
|
+
/** Provider-owned action name, routed back to that extension's handleAction. */
|
|
134
|
+
action: string
|
|
135
|
+
/** Task the action targets, when it targets one. */
|
|
136
|
+
taskId?: string
|
|
137
|
+
/** Opaque provider payload, bounded like every other extension payload. */
|
|
138
|
+
payload?: TaskBoardExtensionPayload
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Deliver one extension action through the board's same-origin action channel.
|
|
143
|
+
* The extension never opens an HTTP surface of its own.
|
|
144
|
+
*/
|
|
145
|
+
export type TaskBoardExtensionDispatch = (request: TaskBoardExtensionActionRequest) => Promise<boolean>
|
|
146
|
+
|
|
147
|
+
/** Draft one provider creates a task from. */
|
|
148
|
+
export interface TaskBoardTaskDraft {
|
|
149
|
+
title: string
|
|
150
|
+
description: string
|
|
151
|
+
prompt: string
|
|
152
|
+
/** Column the created card opens in; absent means the board default (todo). */
|
|
153
|
+
status?: TaskStatus
|
|
154
|
+
/** Parent card id, when the provider materializes a subtask. */
|
|
155
|
+
parentId?: string
|
|
156
|
+
/**
|
|
157
|
+
* Workspace the execution must run in. Absent leaves the board's own
|
|
158
|
+
* inheritance rules in charge (the creating session's workspace for a root
|
|
159
|
+
* card, else the recent workspace at execution time), so a provider that has
|
|
160
|
+
* no reason to know better pins nothing.
|
|
161
|
+
*/
|
|
162
|
+
workspaceId?: string
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Options of {@link TaskBoardTasksFace.create}. */
|
|
166
|
+
export interface TaskBoardCreateOptions {
|
|
167
|
+
/** Opaque payload stored under the creating extension's id. */
|
|
168
|
+
payload?: TaskBoardExtensionPayload
|
|
169
|
+
/** Create the card off-board: it exists in the ledger but is never shown on the board. */
|
|
170
|
+
hidden?: boolean
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** One task linked to an extension, with that extension's own payload. */
|
|
174
|
+
export interface TaskBoardLinkedTask {
|
|
175
|
+
task: TaskRecord
|
|
176
|
+
payload: TaskBoardExtensionPayload
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Task reads and writes the board grants an extension. */
|
|
180
|
+
export interface TaskBoardTasksFace {
|
|
181
|
+
/** Every task in the ledger, most recent mutation last. */
|
|
182
|
+
list(): readonly TaskRecord[]
|
|
183
|
+
/** One task by id, or undefined. */
|
|
184
|
+
get(taskId: string): TaskRecord | undefined
|
|
185
|
+
/**
|
|
186
|
+
* Create a task through the board's own creation gate; the payload lands
|
|
187
|
+
* under the creating extension's id. Throws on a refused draft.
|
|
188
|
+
*/
|
|
189
|
+
create(draft: TaskBoardTaskDraft, options?: TaskBoardCreateOptions): TaskRecord
|
|
190
|
+
/**
|
|
191
|
+
* Patch a task's content. Reuses the board's own content gate: a task that
|
|
192
|
+
* has started executing keeps its recorded title/description/prompt.
|
|
193
|
+
* Throws when the card is frozen.
|
|
194
|
+
*/
|
|
195
|
+
patchContent(taskId: string, patch: { title?: string; description?: string; prompt?: string }): void
|
|
196
|
+
/**
|
|
197
|
+
* Move a task through the board's existing status gates (running lock,
|
|
198
|
+
* permission confirmation gate). Throws on refusal.
|
|
199
|
+
*/
|
|
200
|
+
setStatus(taskId: string, status: TaskStatus, initiator?: string): void
|
|
201
|
+
/** Every task carrying this extension's payload. */
|
|
202
|
+
linked(): readonly TaskBoardLinkedTask[]
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Storage face for one extension's own payload on a task. */
|
|
206
|
+
export interface TaskBoardIntegrationFace {
|
|
207
|
+
/** Read this extension's payload, or undefined when the task carries none. */
|
|
208
|
+
read(taskId: string): TaskBoardExtensionPayload | undefined
|
|
209
|
+
/**
|
|
210
|
+
* Shallow-merge this extension's payload into the task: the given keys
|
|
211
|
+
* replace the stored ones, and a key explicitly set to undefined clears it.
|
|
212
|
+
* The board stores the result opaquely; a non-JSON or oversized payload is
|
|
213
|
+
* refused.
|
|
214
|
+
*/
|
|
215
|
+
write(taskId: string, payload: TaskBoardExtensionPayload): void
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Status-change notification. */
|
|
219
|
+
export interface TaskBoardStatusChangedEvent {
|
|
220
|
+
taskId: string
|
|
221
|
+
status: TaskStatus
|
|
222
|
+
previous: TaskStatus
|
|
223
|
+
initiator?: string
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** Execution-settlement notification. */
|
|
227
|
+
export interface TaskBoardExecutionSettledEvent {
|
|
228
|
+
taskId: string
|
|
229
|
+
executionId: string
|
|
230
|
+
outcome: ExecutionOutcome
|
|
231
|
+
error?: string
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** Task-deletion notification. */
|
|
235
|
+
export interface TaskBoardTaskDeletedEvent {
|
|
236
|
+
taskId: string
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Event subscriptions an extension registers for. Every callback runs isolated:
|
|
241
|
+
* a throw is logged and never interrupts the board's own execution path.
|
|
242
|
+
*/
|
|
243
|
+
export interface TaskBoardEventFace {
|
|
244
|
+
onStatusChanged(callback: (event: TaskBoardStatusChangedEvent) => void): () => void
|
|
245
|
+
onExecutionSettled(callback: (event: TaskBoardExecutionSettledEvent) => void): () => void
|
|
246
|
+
onTaskDeleted(callback: (event: TaskBoardTaskDeletedEvent) => void): () => void
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Host capability face handed to one extension while it is started. The face
|
|
251
|
+
* lives for the extension's enabled lifetime; the board revokes it by calling
|
|
252
|
+
* the extension's stop().
|
|
253
|
+
*/
|
|
254
|
+
export interface TaskBoardExtensionHost {
|
|
255
|
+
tasks: TaskBoardTasksFace
|
|
256
|
+
integration: TaskBoardIntegrationFace
|
|
257
|
+
events: TaskBoardEventFace
|
|
258
|
+
/**
|
|
259
|
+
* Publish this extension's read-only summary; it lands in the snapshot's
|
|
260
|
+
* extensions[id] for the extension's browser half to render.
|
|
261
|
+
*/
|
|
262
|
+
publish(summary: TaskBoardExtensionPayload): void
|
|
263
|
+
/** Register one model-visible tool; the returned disposer unregisters it. */
|
|
264
|
+
registerTool(definition: ToolDefinition): () => void
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** One external provider contributed to the task board. */
|
|
268
|
+
export interface TaskBoardExtension {
|
|
269
|
+
/** Stable extension id; also the key of this extension's integration payload. */
|
|
270
|
+
readonly id: string
|
|
271
|
+
/** Contract version this extension was built against. */
|
|
272
|
+
readonly apiVersion: number
|
|
273
|
+
/** Volatile per-extension switch; absent means enabled. Read at use time. */
|
|
274
|
+
enabled?(): boolean
|
|
275
|
+
/** Acquire the capability face and start any provider-side work. */
|
|
276
|
+
start?(host: TaskBoardExtensionHost): void
|
|
277
|
+
/** Release provider-side work. Never clears stored data. */
|
|
278
|
+
stop?(): void
|
|
279
|
+
/** Route one dispatched action; the returned value goes back to the dispatcher. */
|
|
280
|
+
handleAction?(request: TaskBoardExtensionActionRequest): unknown | Promise<unknown>
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Board mirror an extension's browser half observes. */
|
|
284
|
+
export interface TaskBoardClientMirror {
|
|
285
|
+
/** Whether the board's master switch currently runs the extension faces. */
|
|
286
|
+
enabled: boolean
|
|
287
|
+
/** Tasks the board currently holds. */
|
|
288
|
+
tasks: readonly TaskRecord[]
|
|
289
|
+
/** Published extension summaries, keyed by extension id (opaque to the board). */
|
|
290
|
+
extensions: Readonly<Record<string, unknown>>
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Whether a task should be shown on the board; false hides it. */
|
|
294
|
+
export type TaskBoardVisibilityPredicate = (task: TaskRecord) => boolean
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Client capability face the board's browser half provides. A provider's
|
|
298
|
+
* browser half resolves it from the shared cordis service name; it never
|
|
299
|
+
* value-imports the board package.
|
|
300
|
+
*/
|
|
301
|
+
export interface TaskBoardClientFace {
|
|
302
|
+
/** Deliver one action through the board's same-origin action channel. */
|
|
303
|
+
dispatch(request: TaskBoardExtensionActionRequest): Promise<boolean>
|
|
304
|
+
/** Register one card visibility predicate; the returned disposer removes it. */
|
|
305
|
+
registerVisibility(predicate: TaskBoardVisibilityPredicate): () => void
|
|
306
|
+
/** Subscribe to the board mirror. */
|
|
307
|
+
subscribe(callback: (mirror: TaskBoardClientMirror) => void): () => void
|
|
308
|
+
/** Read the current board mirror. */
|
|
309
|
+
snapshot(): TaskBoardClientMirror
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** Owner props of the task-detail seat. */
|
|
313
|
+
export interface TaskBoardDetailSectionProps {
|
|
314
|
+
task: TaskRecord
|
|
315
|
+
dispatch: TaskBoardExtensionDispatch
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** Owner props of the settings seat. */
|
|
319
|
+
export interface TaskBoardSettingsSectionProps {
|
|
320
|
+
dispatch: TaskBoardExtensionDispatch
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** Owner props of the card-decoration seat. */
|
|
324
|
+
export interface TaskBoardCardDecorationProps {
|
|
325
|
+
task: TaskRecord
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Host-half service face published under {@link TASK_BOARD_SERVICE_NAME}. A
|
|
330
|
+
* provider package's host half resolves this from the shared cordis service
|
|
331
|
+
* and registers its extension; the board's ledger never crosses this boundary.
|
|
332
|
+
*/
|
|
333
|
+
export interface TaskBoardHostFace {
|
|
334
|
+
/**
|
|
335
|
+
* Admit one provider extension. Idempotent by extension id; the returned
|
|
336
|
+
* disposer releases it without clearing stored data.
|
|
337
|
+
*/
|
|
338
|
+
registerExtension(extension: TaskBoardExtension): () => void
|
|
339
|
+
/** Whether the board currently runs a given extension (board x extension). */
|
|
340
|
+
isExtensionEnabled(extensionId: string): boolean
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
declare module '@deepseek-ai/cordis' {
|
|
344
|
+
interface Context {
|
|
345
|
+
/**
|
|
346
|
+
* The board's extension service. The host half publishes
|
|
347
|
+
* {@link TaskBoardHostFace}; the browser half publishes
|
|
348
|
+
* {@link TaskBoardClientFace} under the same name. The two halves never run
|
|
349
|
+
* in one process, so the browser half resolves its face through
|
|
350
|
+
* {@link resolveTaskBoardClientFace} and this shared declaration names the
|
|
351
|
+
* host face that registration-side consumers type against.
|
|
352
|
+
*/
|
|
353
|
+
taskBoard: TaskBoardHostFace
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** The narrow context seat {@link resolveTaskBoardClientFace} needs. */
|
|
358
|
+
export interface TaskBoardClientContextSeat {
|
|
359
|
+
get(name: string): unknown
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Resolve the browser half's client capability face by service name. Returns
|
|
364
|
+
* undefined when the board is not loaded or the service is not served, so a
|
|
365
|
+
* provider's browser half can degrade instead of throwing.
|
|
366
|
+
* @param ctx - client context.
|
|
367
|
+
* @returns the client face, or undefined.
|
|
368
|
+
*/
|
|
369
|
+
export function resolveTaskBoardClientFace(ctx: TaskBoardClientContextSeat): TaskBoardClientFace | undefined {
|
|
370
|
+
try {
|
|
371
|
+
const face = ctx.get(TASK_BOARD_SERVICE_NAME) as TaskBoardClientFace | undefined
|
|
372
|
+
return face !== undefined && typeof (face as { dispatch?: unknown }).dispatch === 'function' ? face : undefined
|
|
373
|
+
} catch {
|
|
374
|
+
return undefined
|
|
375
|
+
}
|
|
376
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Freeze-request parser and security gate: parses the system-prompt-agreed
|
|
3
|
+
* freeze format into a structured context snapshot (goal / progress / next),
|
|
4
|
+
* redacts sensitive patterns to markers, rejects slash-prefixed DSH command
|
|
5
|
+
* lines, and enforces the 8 KiB per-field byte limit.
|
|
6
|
+
* Pure functions only: no session, network, or filesystem access.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Hard per-field limit: 8 KiB measured in UTF-8 bytes. */
|
|
10
|
+
export const FREEZE_FIELD_BYTE_LIMIT = 8 * 1024
|
|
11
|
+
|
|
12
|
+
/** Marker replacing every sensitive match. */
|
|
13
|
+
export const REDACTED_MARKER = '[REDACTED]'
|
|
14
|
+
|
|
15
|
+
/** Structured context snapshot carried by a continuation card. */
|
|
16
|
+
export interface FreezeSnapshot {
|
|
17
|
+
goal: string
|
|
18
|
+
progress: string
|
|
19
|
+
next: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Non-fatal notices produced by the security gate. */
|
|
23
|
+
export type FreezeWarning = 'redacted'
|
|
24
|
+
|
|
25
|
+
export type FreezeResult =
|
|
26
|
+
| { ok: true; snapshot: FreezeSnapshot; warnings: FreezeWarning[] }
|
|
27
|
+
| { ok: false; error: { code: string; message: string } }
|
|
28
|
+
|
|
29
|
+
const BEGIN = '<<<FREEZE'
|
|
30
|
+
const END = '>>>FREEZE'
|
|
31
|
+
|
|
32
|
+
const SECTION_KEYS: ReadonlyMap<string, SectionKey> = new Map([
|
|
33
|
+
['目标:', 'goal'],
|
|
34
|
+
['进度:', 'progress'],
|
|
35
|
+
['下一步:', 'next'],
|
|
36
|
+
])
|
|
37
|
+
|
|
38
|
+
type SectionKey = 'goal' | 'progress' | 'next'
|
|
39
|
+
|
|
40
|
+
const SECTION_ORDER: readonly SectionKey[] = ['goal', 'progress', 'next']
|
|
41
|
+
|
|
42
|
+
const SECTION_NAMES: Record<SectionKey, string> = {
|
|
43
|
+
goal: '目标',
|
|
44
|
+
progress: '进度',
|
|
45
|
+
next: '下一步',
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Sensitive patterns, each matched globally over every field body:
|
|
50
|
+
* PEM private key blocks (whole block collapses to one marker), Bearer
|
|
51
|
+
* credentials, OpenAI sk-, `ghp_`-shaped provider tokens, GitLab glpat-,
|
|
52
|
+
* Slack xox* tokens, and AWS access key ids.
|
|
53
|
+
*/
|
|
54
|
+
const SENSITIVE_PATTERNS: RegExp[] = [
|
|
55
|
+
/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,
|
|
56
|
+
/Bearer\s+[A-Za-z0-9._~+\/=:-]{8,}/gi,
|
|
57
|
+
/sk-[A-Za-z0-9_-]{8,}/g,
|
|
58
|
+
/ghp_[A-Za-z0-9]{20,}/g,
|
|
59
|
+
/glpat-[A-Za-z0-9_-]{15,}/g,
|
|
60
|
+
/xox[bpars]-[A-Za-z0-9-]{10,}/g,
|
|
61
|
+
/AKIA[0-9A-Z]{16}/g,
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
function fail(code: string, message: string): FreezeResult {
|
|
65
|
+
return { ok: false, error: { code, message } }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function utf8Bytes(text: string): number {
|
|
69
|
+
return new TextEncoder().encode(text).length
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Redact sensitive patterns to the marker; reports whether any hit occurred. */
|
|
73
|
+
export function redactSensitive(text: string): { text: string; redacted: boolean } {
|
|
74
|
+
let out = text
|
|
75
|
+
let redacted = false
|
|
76
|
+
for (const pattern of SENSITIVE_PATTERNS) {
|
|
77
|
+
if (pattern.test(out)) {
|
|
78
|
+
redacted = true
|
|
79
|
+
out = out.replace(pattern, REDACTED_MARKER)
|
|
80
|
+
}
|
|
81
|
+
pattern.lastIndex = 0
|
|
82
|
+
}
|
|
83
|
+
return { text: out, redacted }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* True when any line of the text starts with "/" (a DSH command line).
|
|
88
|
+
* Leading horizontal whitespace before the slash counts too: a frozen
|
|
89
|
+
* body line like ` /kill` is still a command, not prose.
|
|
90
|
+
*/
|
|
91
|
+
export function hasSlashCommandLines(text: string): boolean {
|
|
92
|
+
return text.split(/\r?\n/).some(line => /^[ \t]+\//.test(line) || line.startsWith('/'))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Sanitize a structured freeze snapshot (the create/update action payload):
|
|
97
|
+
* shape check, slash-command taint rejection, sensitive redaction, and the
|
|
98
|
+
* per-field byte cap - the same gate parseFreezeRequest applies to
|
|
99
|
+
* free-text freeze requests, exposed for the action data plane (issue #4).
|
|
100
|
+
* @param value - the freeze object carried by an action or read back from disk.
|
|
101
|
+
* @param extraKeys - keys allowed alongside goal/progress/next (e.g. the
|
|
102
|
+
* protocol redacted flag, the ledger frozenAt stamp) and preserved verbatim
|
|
103
|
+
* when present; their validation stays with the caller.
|
|
104
|
+
*/
|
|
105
|
+
export function sanitizeFreezeSnapshot(
|
|
106
|
+
value: unknown,
|
|
107
|
+
extraKeys: readonly string[] = [],
|
|
108
|
+
): { ok: true; snapshot: FreezeSnapshot; redacted: boolean; extras: Record<string, unknown> } | { ok: false; error: { code: string; message: string } } {
|
|
109
|
+
const bad = (code: string, message: string) => ({ ok: false as const, error: { code, message } })
|
|
110
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
111
|
+
return bad('invalid-freeze', '冻结快照必须是 goal/progress/next 字符串对象')
|
|
112
|
+
}
|
|
113
|
+
const record = value as Record<string, unknown>
|
|
114
|
+
const allowed = ['goal', 'progress', 'next', ...extraKeys]
|
|
115
|
+
if (!Object.keys(record).every(key => allowed.includes(key))) {
|
|
116
|
+
return bad('invalid-freeze', '冻结快照包含未知字段')
|
|
117
|
+
}
|
|
118
|
+
for (const key of SECTION_ORDER) {
|
|
119
|
+
if (typeof record[key] !== 'string') {
|
|
120
|
+
return bad('invalid-freeze', '冻结快照字段 ' + SECTION_NAMES[key] + ' 必须是字符串')
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
for (const key of SECTION_ORDER) {
|
|
124
|
+
if (hasSlashCommandLines(record[key] as string)) {
|
|
125
|
+
return bad('dsh-command-line', '冻结文本的' + SECTION_NAMES[key] + '包含以 / 开头的命令行,整体拒绝')
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
let redacted = false
|
|
129
|
+
const snapshot: Record<SectionKey, string> = { goal: '', progress: '', next: '' }
|
|
130
|
+
for (const key of SECTION_ORDER) {
|
|
131
|
+
const result = redactSensitive(record[key] as string)
|
|
132
|
+
snapshot[key] = result.text
|
|
133
|
+
redacted = redacted || result.redacted
|
|
134
|
+
}
|
|
135
|
+
for (const key of SECTION_ORDER) {
|
|
136
|
+
if (utf8Bytes(snapshot[key]) > FREEZE_FIELD_BYTE_LIMIT) {
|
|
137
|
+
return bad('field-too-large', '冻结快照字段 ' + SECTION_NAMES[key] + ' 超过 8 KiB 上限')
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const extras: Record<string, unknown> = {}
|
|
141
|
+
for (const key of extraKeys) if (key in record) extras[key] = record[key]
|
|
142
|
+
return { ok: true, snapshot: { goal: snapshot.goal, progress: snapshot.progress, next: snapshot.next }, redacted, extras }
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Parse the freeze-request format: a <<<FREEZE ... >>>FREEZE block whose body
|
|
147
|
+
* is 目标: / 进度: / 下一步: section headers, each followed by body lines.
|
|
148
|
+
* The gate applies before returning: slash-command taint rejects the whole
|
|
149
|
+
* request, sensitive patterns are redacted to markers, and each field is
|
|
150
|
+
* capped at FREEZE_FIELD_BYTE_LIMIT UTF-8 bytes.
|
|
151
|
+
*/
|
|
152
|
+
export function parseFreezeRequest(input: string): FreezeResult {
|
|
153
|
+
const beginIndex = input.indexOf(BEGIN)
|
|
154
|
+
if (beginIndex === -1) {
|
|
155
|
+
return fail('missing-block', '未找到冻结请求块(需要 <<<FREEZE ... >>>FREEZE)')
|
|
156
|
+
}
|
|
157
|
+
const bodyStart = beginIndex + BEGIN.length
|
|
158
|
+
const endIndex = input.indexOf(END, bodyStart)
|
|
159
|
+
if (endIndex === -1) {
|
|
160
|
+
return fail('unterminated-block', '冻结请求块未闭合(缺少 >>>FREEZE)')
|
|
161
|
+
}
|
|
162
|
+
const block = input.slice(bodyStart, endIndex)
|
|
163
|
+
|
|
164
|
+
const raw = new Map<SectionKey, string[]>()
|
|
165
|
+
let current: SectionKey | undefined
|
|
166
|
+
for (const line of block.split(/\r?\n/)) {
|
|
167
|
+
const key = SECTION_KEYS.get(line)
|
|
168
|
+
if (key !== undefined) {
|
|
169
|
+
if (raw.has(key)) {
|
|
170
|
+
return fail('duplicate-section', `重复的段落标题:${SECTION_NAMES[key]}`)
|
|
171
|
+
}
|
|
172
|
+
raw.set(key, [])
|
|
173
|
+
current = key
|
|
174
|
+
} else if (current !== undefined) {
|
|
175
|
+
raw.get(current)!.push(line)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const snapshot: Record<SectionKey, string> = { goal: '', progress: '', next: '' }
|
|
180
|
+
for (const key of SECTION_ORDER) {
|
|
181
|
+
if (!raw.has(key)) {
|
|
182
|
+
return fail('missing-section', `冻结请求缺少段落:${SECTION_NAMES[key]}`)
|
|
183
|
+
}
|
|
184
|
+
const lines = raw.get(key)!
|
|
185
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === '') lines.pop()
|
|
186
|
+
snapshot[key] = lines.join('\n')
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
for (const key of SECTION_ORDER) {
|
|
190
|
+
if (hasSlashCommandLines(snapshot[key])) {
|
|
191
|
+
return fail('dsh-command-line', `冻结文本的${SECTION_NAMES[key]}包含以 / 开头的命令行,整体拒绝`)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
let redacted = false
|
|
196
|
+
for (const key of SECTION_ORDER) {
|
|
197
|
+
const result = redactSensitive(snapshot[key])
|
|
198
|
+
snapshot[key] = result.text
|
|
199
|
+
redacted = redacted || result.redacted
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
for (const key of SECTION_ORDER) {
|
|
203
|
+
if (utf8Bytes(snapshot[key]) > FREEZE_FIELD_BYTE_LIMIT) {
|
|
204
|
+
return fail('field-too-large', `冻结快照字段 ${SECTION_NAMES[key]} 超过 8 KiB 上限`)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
ok: true,
|
|
210
|
+
snapshot: { goal: snapshot.goal, progress: snapshot.progress, next: snapshot.next },
|
|
211
|
+
warnings: redacted ? ['redacted'] : [],
|
|
212
|
+
}
|
|
213
|
+
}
|