dsh-kingdom 2.0.0 → 3.2.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.
Files changed (78) hide show
  1. package/ASSETS_NOTICE.md +22 -22
  2. package/README.md +246 -243
  3. package/THIRD_PARTY_NOTICES.md +92 -92
  4. package/docs/DSH-KINGDOM-3.0-ANNOUNCEMENT.md +13 -0
  5. package/docs/V2.0-RELEASE-NOTES.md +30 -30
  6. package/docs/V2.0-USER-GUIDE.md +74 -74
  7. package/docs/V3.0-RELEASE-NOTES.md +21 -0
  8. package/docs/V3.0-USER-GUIDE.md +33 -0
  9. package/docs/V3.1-RELEASE-NOTES.md +76 -0
  10. package/docs/V3.2-RELEASE-NOTES.md +103 -0
  11. package/lib/core/binding.js +167 -60
  12. package/lib/core/binding.js.map +1 -1
  13. package/lib/core/db.js +582 -546
  14. package/lib/core/db.js.map +1 -1
  15. package/lib/core/delivery-ack.js +1356 -0
  16. package/lib/core/delivery-ack.js.map +1 -0
  17. package/lib/core/delivery-change.js +1237 -0
  18. package/lib/core/delivery-change.js.map +1 -0
  19. package/lib/core/owner-binding-intent.js +14 -25
  20. package/lib/core/owner-binding-intent.js.map +1 -1
  21. package/lib/core/owner-window.js +698 -23
  22. package/lib/core/owner-window.js.map +1 -1
  23. package/lib/core/task-service.js +144 -5
  24. package/lib/core/task-service.js.map +1 -1
  25. package/lib/core/territory.js +43 -9
  26. package/lib/core/territory.js.map +1 -1
  27. package/lib/gui/assets/characters/chancellor-idle.svg +67 -67
  28. package/lib/gui/assets/characters/chancellor-sleeping.svg +67 -67
  29. package/lib/gui/assets/characters/chancellor-thinking.svg +67 -67
  30. package/lib/gui/assets/characters/chancellor-working.svg +67 -67
  31. package/lib/gui/assets/characters/knight-redraw-r1-idle.svg +67 -67
  32. package/lib/gui/assets/characters/knight-redraw-r1-sleeping.svg +67 -67
  33. package/lib/gui/assets/characters/knight-redraw-r1-thinking.svg +67 -67
  34. package/lib/gui/assets/characters/knight-redraw-r1-working.svg +67 -67
  35. package/lib/gui/assets/characters/supervisor-idle.svg +67 -67
  36. package/lib/gui/assets/characters/supervisor-sleeping.svg +67 -67
  37. package/lib/gui/assets/characters/supervisor-thinking.svg +67 -67
  38. package/lib/gui/assets/characters/supervisor-working.svg +67 -67
  39. package/lib/gui/console-app.js +7 -1
  40. package/lib/gui/console-app.js.map +1 -1
  41. package/lib/gui/contract.js +6 -0
  42. package/lib/gui/contract.js.map +1 -1
  43. package/lib/gui/control-contract.js +3 -2
  44. package/lib/gui/control-contract.js.map +1 -1
  45. package/lib/gui/owner-control.js +114 -4
  46. package/lib/gui/owner-control.js.map +1 -1
  47. package/lib/gui/owner-ui.js +645 -183
  48. package/lib/gui/owner-ui.js.map +1 -1
  49. package/lib/gui/server.js +109 -109
  50. package/lib/gui/snapshot.js +127 -4
  51. package/lib/gui/snapshot.js.map +1 -1
  52. package/lib/gui/visual-assets.js +37 -21
  53. package/lib/gui/visual-assets.js.map +1 -1
  54. package/lib/gui/visual-system.js +269 -269
  55. package/lib/gui/workbench-ui.js +549 -136
  56. package/lib/gui/workbench-ui.js.map +1 -1
  57. package/lib/gui/workbench.js +133 -0
  58. package/lib/gui/workbench.js.map +1 -1
  59. package/lib/index.js +392 -40
  60. package/lib/index.js.map +1 -1
  61. package/lib/types/core/binding.d.ts +29 -0
  62. package/lib/types/core/db.d.ts +14 -0
  63. package/lib/types/core/delivery-ack.d.ts +688 -0
  64. package/lib/types/core/delivery-change.d.ts +381 -0
  65. package/lib/types/core/owner-binding-intent.d.ts +9 -1
  66. package/lib/types/core/owner-window.d.ts +237 -3
  67. package/lib/types/core/task-service.d.ts +22 -0
  68. package/lib/types/core/territory.d.ts +18 -3
  69. package/lib/types/gui/contract.d.ts +162 -1
  70. package/lib/types/gui/owner-control.d.ts +61 -1
  71. package/lib/types/gui/snapshot.d.ts +8 -0
  72. package/lib/types/gui/visual-assets.d.ts +16 -0
  73. package/lib/types/gui/workbench.d.ts +47 -1
  74. package/lib/types/index.d.ts +60 -1
  75. package/lib/types/worker/governed-executor.d.ts +15 -0
  76. package/lib/worker/governed-executor.js +21 -0
  77. package/lib/worker/governed-executor.js.map +1 -1
  78. package/package.json +80 -75
@@ -3,7 +3,8 @@ import { type ExecutionProfileV1 } from './binding.js';
3
3
  import { type OwnerControlCapability } from './owner-control.js';
4
4
  import { type BudgetPolicyParameters } from './budget.js';
5
5
  import { type PlanAdoptionParameters, type CollaborationPlanView } from './collaboration.js';
6
- export declare const OWNER_MUTATION_ACTIONS: readonly ["init", "territory.create", "territory.update", "territory.supervisor", "role.bind", "role.session", "ceiling", "execution-profile", "budget.policy", "plan.adopt"];
6
+ import { type DeliveryAcceptanceEvidenceKind, type DeliveryItemVersionState, type DeliveryReplyState } from './delivery-ack.js';
7
+ export declare const OWNER_MUTATION_ACTIONS: readonly ["init", "territory.create", "territory.update", "territory.supervisor", "role.bind", "role.session", "ceiling", "execution-profile", "budget.policy", "plan.adopt", "delivery.item.ack", "delivery.item.question"];
7
8
  export type OwnerMutationAction = typeof OWNER_MUTATION_ACTIONS[number];
8
9
  export type OwnerManagedRole = 'CHANCELLOR' | 'SUPERVISOR' | 'WORKER';
9
10
  export interface OwnerDecisionScope {
@@ -60,6 +61,148 @@ export interface OwnerRuntimeSessionChoice {
60
61
  id: string;
61
62
  label: string;
62
63
  }
64
+ /** 交付清单条目:只有已被主管 ACCEPT 确认的交付才会出现。 */
65
+ export interface OwnerDeliveryItemChoice {
66
+ taskId: string;
67
+ taskTitle: string;
68
+ deliveryId: string;
69
+ attemptNo: number;
70
+ resultId: string;
71
+ itemId: string;
72
+ contentHash: string;
73
+ layer: string;
74
+ label: string;
75
+ detail: string;
76
+ changeKind: string;
77
+ changeNote: string;
78
+ acknowledgementState: 'ACKNOWLEDGED' | 'PENDING' | 'PENDING_REVISION';
79
+ acknowledgedAt: string | null;
80
+ /**
81
+ * 本次确认交付实际依据的接受证据强度。`LEGACY_ATTEMPT_ONLY` 时
82
+ * `acceptanceEvidenceNote` 必须原样展示给 Owner(历史接受证据较弱),
83
+ * 且不得把它当作 exact result-bound。
84
+ */
85
+ acceptanceEvidenceKind: DeliveryAcceptanceEvidenceKind;
86
+ acceptanceEvidenceExact: boolean;
87
+ acceptanceEvidenceNote: string | null;
88
+ /**
89
+ * 该条目已有的 Owner 提问元数据(不含正文)。正文只经
90
+ * {@link OwnerDecisionController.readDeliveryQuestions} 在有效窗口内按精确条目返回。
91
+ */
92
+ questions: OwnerDeliveryItemQuestions | null;
93
+ }
94
+ /** 条目提问的**元数据**:不含问题或回复正文。 */
95
+ export interface OwnerDeliveryItemQuestions {
96
+ threadId: string;
97
+ totalCount: number;
98
+ /** 主管尚未回复的问题数;未被实际读取前只算「待领取」。 */
99
+ pendingCount: number;
100
+ answeredCount: number;
101
+ /** 属于旧内容版本、仅留历史的问题数。 */
102
+ historyCount: number;
103
+ lastAskedAt: string | null;
104
+ lastRepliedAt: string | null;
105
+ /** 最近一条问题的接收主管是否仍可回复;不可达时界面必须照实说明。 */
106
+ latestReplyState: DeliveryReplyState | null;
107
+ }
108
+ /**
109
+ * Owner 只读问答历史入口的一条精确条目(不含问题或回复正文)。
110
+ *
111
+ * 与 `deliveryItems` 分开:它只来自既有提问事实,因此包含已经离开当前交付目录、
112
+ * 目前无法重验的旧问答。它只供只读回看,**绝不**作为新提问目标;新提问仍须落在
113
+ * 当前已确认交付目录内并逐条精确重验。
114
+ */
115
+ export interface OwnerDeliveryQuestionHistoryChoice {
116
+ taskId: string;
117
+ taskTitle: string;
118
+ itemId: string;
119
+ itemLabel: string;
120
+ lastAskedAt: string;
121
+ questionCount: number;
122
+ /** 已验证当前版本且尚无回复的条数;历史版与无法重验的都不计入。 */
123
+ pendingCount: number;
124
+ answeredCount: number;
125
+ historyCount: number;
126
+ unverifiableCount: number;
127
+ latestItemVersion: DeliveryItemVersionState;
128
+ currentContentHash: string | null;
129
+ }
130
+ /**
131
+ * Owner 只读的条目问答线程。
132
+ *
133
+ * 与「查看改动」同款边界:只经有效 Owner 窗口、精确条目引用与本次动作授权返回,
134
+ * **读取不写任何事实**、不自动知悉、也不替主管回复。
135
+ */
136
+ export interface OwnerDeliveryQuestionEntry {
137
+ questionId: string;
138
+ questionText: string;
139
+ askedAt: string;
140
+ ownerId: string;
141
+ /** 接受该交付的主管 binding;首版唯一合法接收者。 */
142
+ reviewerBindingId: string;
143
+ replyState: DeliveryReplyState;
144
+ replyStateNote: string;
145
+ /**
146
+ * 该问题相对当前交付目录的版本关系:已验证当前、可确认的旧版本,或无法重验。
147
+ * 后两者仍可读、仍保留原文与回复,但**不计当前待办**,界面也不得据此声称
148
+ * 「当前可回复」。
149
+ */
150
+ itemVersion: DeliveryItemVersionState;
151
+ /** 当前读取时该条目重新派生出的内容版本;无法派生时为 null。 */
152
+ currentItemContentHash: string | null;
153
+ reply: {
154
+ replyText: string;
155
+ repliedAt: string;
156
+ responderBindingId: string;
157
+ } | null;
158
+ }
159
+ export interface OwnerDeliveryQuestionView {
160
+ deliveryId: string;
161
+ taskId: string;
162
+ taskTitle: string;
163
+ itemId: string;
164
+ itemLabel: string;
165
+ /** 本次读取时该条目的当前内容版本;无法在当前交付目录中重验时为 null。 */
166
+ contentHash: string | null;
167
+ questions: OwnerDeliveryQuestionEntry[];
168
+ answeredCount: number;
169
+ /** 已验证当前版本且尚无回复的条数;历史版与无法重验的未答问题都不计入。 */
170
+ pendingCount: number;
171
+ historyCount: number;
172
+ /** 当前交付目录无法重验该条目版本、因此不声称任何版本关系的条数。 */
173
+ unverifiableCount: number;
174
+ note: string;
175
+ }
176
+ /**
177
+ * Owner 只读的已确认改动详情。
178
+ *
179
+ * 这是「主管确认的改动证据」的可读视图:只经有效 Owner 窗口、精确
180
+ * task/evidence/entry id 与 scope 返回,**查看不写入任何事实**,也不自动知悉。
181
+ */
182
+ export interface OwnerDeliveryChangeView {
183
+ kind: 'SUPERVISOR_CONFIRMED_BOUNDED_WINDOW';
184
+ label: string;
185
+ evidenceId: string;
186
+ entryId: string;
187
+ taskId: string;
188
+ taskTitle: string;
189
+ attemptNo: number;
190
+ status: string;
191
+ repoPath: string;
192
+ revision: string;
193
+ repoVcs: string;
194
+ repoHead: string | null;
195
+ coverageComplete: boolean;
196
+ coverageReasons: string[];
197
+ labels: string[];
198
+ note: string;
199
+ hunks: {
200
+ kind: string;
201
+ beforeLine: number | null;
202
+ afterLine: number | null;
203
+ text: string;
204
+ }[];
205
+ }
63
206
  export interface OwnerDecisionControllerOptions {
64
207
  now?: () => number;
65
208
  validationTimeoutMs?: number;
@@ -83,6 +226,16 @@ export interface OwnerOperationCatalog {
83
226
  }[];
84
227
  runtimeSessions: OwnerRuntimeSessionChoice[];
85
228
  workspaceRoots: string[];
229
+ /**
230
+ * 本次授权范围内的已确认交付条目;逐条知悉与逐条提问共用同一份目录。
231
+ * 只要窗口授权了其中任一动作就返回;读取权限仍由各自动作单独把关。
232
+ */
233
+ deliveryItems?: OwnerDeliveryItemChoice[];
234
+ /**
235
+ * 本次授权范围内**已有提问记录**的精确条目只读入口(含已离开当前目录的旧问答)。
236
+ * 只在窗口授权 `delivery.item.question` 时返回,供只读回看;不是新提问目标来源。
237
+ */
238
+ deliveryQuestionHistory?: OwnerDeliveryQuestionHistoryChoice[];
86
239
  }
87
240
  export type OwnerOperationInput = {
88
241
  action: 'init';
@@ -108,7 +261,7 @@ export type OwnerOperationInput = {
108
261
  action: 'territory.supervisor';
109
262
  parameters: {
110
263
  territory_id: string;
111
- supervisor_binding_id: string;
264
+ supervisor_binding_id: string | null;
112
265
  };
113
266
  } | {
114
267
  action: 'role.bind';
@@ -116,6 +269,7 @@ export type OwnerOperationInput = {
116
269
  role_type: OwnerManagedRole;
117
270
  role_name: string;
118
271
  session_id?: string | null;
272
+ territory_id?: string | null;
119
273
  };
120
274
  } | {
121
275
  action: 'role.session';
@@ -140,6 +294,27 @@ export type OwnerOperationInput = {
140
294
  } | {
141
295
  action: 'plan.adopt';
142
296
  parameters: PlanAdoptionParameters;
297
+ } | {
298
+ action: 'delivery.item.ack';
299
+ parameters: {
300
+ task_id: string;
301
+ delivery_id: string;
302
+ item_id: string;
303
+ content_hash: string;
304
+ attempt_no: number;
305
+ result_id: string;
306
+ };
307
+ } | {
308
+ action: 'delivery.item.question';
309
+ parameters: {
310
+ task_id: string;
311
+ delivery_id: string;
312
+ item_id: string;
313
+ content_hash: string;
314
+ attempt_no: number;
315
+ result_id: string;
316
+ question_text: string;
317
+ };
143
318
  };
144
319
  export interface OwnerOperationPreview {
145
320
  prepareId: string;
@@ -170,7 +345,7 @@ export interface OwnerOperationReceipt {
170
345
  inputHash: string;
171
346
  status: 'APPLIED';
172
347
  target: {
173
- type: 'kingdom' | 'territory' | 'binding' | 'collaboration-plan';
348
+ type: 'kingdom' | 'territory' | 'binding' | 'collaboration-plan' | 'delivery';
174
349
  id: string;
175
350
  };
176
351
  receiptSeq: number;
@@ -196,6 +371,65 @@ export declare class OwnerDecisionController {
196
371
  };
197
372
  inspect(handle: OwnerDecisionHandle): OwnerDecisionView | null;
198
373
  catalog(handle: OwnerDecisionHandle): Promise<OwnerOperationCatalog>;
374
+ /**
375
+ * 本次授权范围内的**已有提问记录**条目(只读历史入口)。
376
+ *
377
+ * 只读且不依赖有界交付目录:它按权威提问事实列出精确 task/item,再逐条用
378
+ * `deliveryScopeAllows` 过滤,因此不含跨领地条目;不在当前目录、当前无法重验的
379
+ * 旧问答也能在这里被发现。它不返回任何正文,也**不**进入新提问 prepare 的来源目录。
380
+ */
381
+ private deliveryQuestionHistory;
382
+ /**
383
+ * 交付知悉的授权范围判据。
384
+ *
385
+ * catalog 与 prepare/commit 必须共用同一判据:否则会出现「清单可见、
386
+ * 提交被拒」或「清单不可见、提交却可行」。`kingdomWide` 是 Owner 的最高
387
+ * 授权级别;其余情况要求任务所在领地在 `territoryIds` 内,或该领地由
388
+ * 授权 `bindingIds` 中的主管主理且本次授权声明了 SUPERVISOR 角色。
389
+ */
390
+ private deliveryScopeAllows;
391
+ /**
392
+ * 本次授权范围内的已确认交付条目。只有同一 Task/attempt 主管 ACCEPT 的交付才出现,
393
+ * Worker Claim 永远不会进入该清单。
394
+ */
395
+ private deliveryItems;
396
+ /**
397
+ * 只读返回一条已确认交付条目的完整问答线程。
398
+ *
399
+ * 有效性要求与 `readDeliveryChange` 同款:窗口 ACTIVE、本次授权包含
400
+ * `delivery.item.question`、任务在授权范围内、该 task 确实存在写给它的问题记录。
401
+ * 版本关系按该精确 task/item **独立重验**(不受有界展示目录截断影响):命中当前
402
+ * 派生版本即已验证当前版,命中的是旧版本即历史版;条目已无法从当前 ACCEPT/证据
403
+ * 重验(例如 CHANGE 证据丢失)时仍可按精确 itemId 读回,但整条标为无法重验,
404
+ * 不冒充当前版、也不可回复。任一不成立都失败,且不写任何事实、不自动知悉。
405
+ */
406
+ readDeliveryQuestions(handle: OwnerDecisionHandle, input: {
407
+ taskId: string;
408
+ itemId: string;
409
+ }): OwnerDeliveryQuestionView;
410
+ /**
411
+ * 已由主管在 ACCEPT 中显式选择、且本地 hash 重验通过的改动证据。
412
+ * 缺失、漂移或未确认时返回 null:调用方显示「不可定位」,不退回执行者自述。
413
+ */
414
+ private changeEvidenceFor;
415
+ private acceptedChangeRef;
416
+ /**
417
+ * 只读返回一条已确认改动条目的有界详情。
418
+ *
419
+ * 有效性要求:窗口 ACTIVE、**本次授权动作包含 `delivery.item.ack`**、任务在本次
420
+ * 授权范围内、该 task 确实存在一条主管 ACCEPT 绑定的改动证据、evidence id 与
421
+ * entry id 精确匹配、该条目仍需出现在当前有效交付目录中,且本地 hash 重验通过。
422
+ * 任一不成立都失败,且不写任何事实、不产生知悉。
423
+ *
424
+ * 只检查 ACTIVE + Territory scope 是不够的:同一领地的另一个管理窗口若没有该
425
+ * 动作授权,就不能凭 id 读取差异正文。这里与 `catalog` 使用同一动作判据,
426
+ * 不默认放行(也不新增只读动作)。
427
+ */
428
+ readDeliveryChange(handle: OwnerDecisionHandle, input: {
429
+ taskId: string;
430
+ evidenceId: string;
431
+ entryId: string;
432
+ }): OwnerDeliveryChangeView;
199
433
  prepare(handle: OwnerDecisionHandle, raw: OwnerOperationInput, options?: {
200
434
  signal?: AbortSignal;
201
435
  }): Promise<OwnerOperationPreview>;
@@ -106,12 +106,34 @@ export interface StartTaskInput {
106
106
  * - executor 客观失败 → **RUNNING → FAILED** + `WORKER_EXECUTION_FAILED`,且不落 Claim。
107
107
  */
108
108
  export declare function startTask(store: KingdomStore, executor: WorkerExecutor, ctx: CommandContext, input: StartTaskInput): Promise<CommandResultView>;
109
+ /**
110
+ * 主管只读候选清单:列出本 Task 当前 attempt 的有界改动条目。
111
+ *
112
+ * 这是主管「查看候选并显式选择」的入口;它只读、不写任何事实,也要求
113
+ * 真实 session-bound 主管。没有快照时如实说明,不伪造候选。
114
+ */
115
+ export declare function describeTaskChangeCandidates(store: KingdomStore, ctx: CommandContext, taskId: string): {
116
+ ok: true;
117
+ text: string;
118
+ } | {
119
+ ok: false;
120
+ code: KingdomErrorCode;
121
+ message: string;
122
+ };
109
123
  export interface ReviewTaskInput {
110
124
  taskId: string;
111
125
  decision: string;
112
126
  reason?: string;
113
127
  /** HANDOFF 专用:目标 Worker binding id。 */
114
128
  to_binding_id?: string;
129
+ /**
130
+ * ACCEPT 专用:主管显式选择属于本次交付的改动引用。
131
+ *
132
+ * 两者必须同时给出;只给 evidence id 或只给空选择都视为非法,普通 ACCEPT
133
+ * 不会自动确认全部 diff。确认入口额外要求真实 session-bound 主管会话。
134
+ */
135
+ change_evidence_id?: string;
136
+ change_entry_ids?: string[];
115
137
  }
116
138
  /**
117
139
  * Supervisor 审查 Worker Claim,把 Claim 转成组织事实(v0.7.0:scope + HANDOFF + Ledger 关闭)。
@@ -25,11 +25,26 @@ export declare function updateTerritory(store: KingdomStore, input: {
25
25
  summary?: string | null;
26
26
  }, auth?: AdminAuth): string;
27
27
  /**
28
- * v0.7.0(M2):设置 Territory 主理 Supervisor(Topology Administration Plane)。
29
- * - 仅 direct Owner Control capability 可执行(requireAdmin → requireOwnerControl);
28
+ * v0.7.0(M2)语义 + 3.2.0 边界:**授权无关**的主理写入。校验不变量后更新领地并写事件。
29
+ *
30
30
  * - supervisorBindingId=null → 未指派 → fail-closed(TERRITORY_SUPERVISOR_MISSING,无 Supervisor 可治理);
31
- * - 指派必须是当前王国的 ACTIVE SUPERVISOR 绑定。
31
+ * - 指派必须是当前王国的 ACTIVE SUPERVISOR 绑定;
32
+ * - 不变量(Owner 2026-09-28 口径 + 2026-09-29 裁定:领地和主管完全绑定):
33
+ * ① 一个领地至多一个主理——目标领地已有**在任 ACTIVE** 主理时拒绝(**先解除再指派**,不静默覆盖);
34
+ * 引用指向已退任席位的悬挂引用属于修复,可直接改派;
35
+ * ② 一个主管席位至多主理一个领地——席位已隶属其它未删除领地时拒绝,须先解除原领地的主理。
36
+ * DELETED 领地不参与治理,其历史指针不锁住席位。
37
+ *
38
+ * 授权由调用方负责:`setTerritorySupervisor` = requireAdmin + 委托本函数。
32
39
  */
40
+ export declare function applyTerritorySupervisor(store: KingdomStore, input: {
41
+ kingdomId: string;
42
+ territoryId: string;
43
+ supervisorBindingId: string | null;
44
+ }, actor: {
45
+ actorId: string | null;
46
+ eventSource: object;
47
+ }): string;
33
48
  export declare function setTerritorySupervisor(store: KingdomStore, input: {
34
49
  kingdomId: string;
35
50
  territoryId: string;
@@ -45,7 +45,13 @@ export type ActorState = (typeof ACTOR_STATES)[number];
45
45
  */
46
46
  export type ActorActivity = 'plan' | 'read' | 'assign' | 'review' | 'rework' | 'accept' | 'execute' | null;
47
47
  /** 命令返回的稳定错误码。GUI 据此决定提示与可用按钮,不解析中文文案。 */
48
- export type KingdomErrorCode = 'KINGDOM_NOT_INITIALIZED' | 'ROLE_BINDING_MISSING' | 'UNAUTHORIZED_PRINCIPAL' | 'SESSION_AUTH_REQUIRED' | 'TERRITORY_MISSING' | 'TERRITORY_AMBIGUOUS' | 'TERRITORY_NOT_IN_KINGDOM' | 'TASK_NOT_FOUND' | 'TASK_NOT_IN_KINGDOM' | 'ILLEGAL_TASK_STATE' | 'INVALID_INPUT' | 'INVALID_DECISION' | 'REASON_REQUIRED' | 'WORKER_BINDING_INVALID' | 'WORKER_AMBIGUOUS' | 'TERRITORY_SUPERVISOR_MISSING' | 'TASK_OUT_OF_SCOPE' | 'EXECUTOR_UNAVAILABLE' | 'WORKER_EXECUTION_FAILED' | 'CLAIM_INTEGRITY_BLOCKED' | 'EXECUTION_NOT_FOUND' | 'ILLEGAL_EXECUTION_STATE' | 'RECOVERY_REQUIRED';
48
+ export type KingdomErrorCode = 'KINGDOM_NOT_INITIALIZED' | 'ROLE_BINDING_MISSING' | 'UNAUTHORIZED_PRINCIPAL' | 'SESSION_AUTH_REQUIRED' | 'TERRITORY_MISSING' | 'TERRITORY_AMBIGUOUS' | 'TERRITORY_NOT_IN_KINGDOM' | 'TASK_NOT_FOUND' | 'TASK_NOT_IN_KINGDOM' | 'ILLEGAL_TASK_STATE' | 'INVALID_INPUT' | 'INVALID_DECISION' | 'REASON_REQUIRED' | 'WORKER_BINDING_INVALID' | 'WORKER_AMBIGUOUS' | 'TERRITORY_SUPERVISOR_MISSING' | 'TASK_OUT_OF_SCOPE' | 'EXECUTOR_UNAVAILABLE' | 'WORKER_EXECUTION_FAILED' | 'CLAIM_INTEGRITY_BLOCKED' | 'EXECUTION_NOT_FOUND' | 'ILLEGAL_EXECUTION_STATE' | 'RECOVERY_REQUIRED'
49
+ /** 改动证据必须由真实 session-bound 主管确认;declarative 低信任模式不得签发。 */
50
+ | 'CHANGE_EVIDENCE_SESSION_REQUIRED'
51
+ /** 证据不存在、hash 漂移、不属于本次 Task/attempt/result 或领地工作区。 */
52
+ | 'CHANGE_EVIDENCE_UNVERIFIED'
53
+ /** 未显式选择、选择为空或选择了快照中不存在的改动引用。 */
54
+ | 'CHANGE_SELECTION_INVALID';
49
55
  /**
50
56
  * v0.5.2(M1-B/P0-B):GUI 写命令守卫。
51
57
  *
@@ -233,6 +239,96 @@ export interface WorkbenchActionItem {
233
239
  actionAvailability: ActionAvailability[];
234
240
  sourceRefs: SourceRef[];
235
241
  }
242
+ /** 交付知悉状态。仅 Owner 通过 canonical 人类管理窗口知悉当前版本。 */
243
+ export type DeliveryAcknowledgementState = 'ACKNOWLEDGED' | 'PENDING' | 'PENDING_REVISION';
244
+ /** 条目「查看改动」的可信度;不可信时明确不可定位,不给链接。 */
245
+ export type DeliveryChangeKind = 'REPO_RELATIVE_VERIFIED' | 'NOT_LOCATABLE';
246
+ export interface DeliveryChangeView {
247
+ kind: DeliveryChangeKind;
248
+ /** 仅可信时存在;仓库相对路径,绝不是本机绝对路径。 */
249
+ repoPath: string | null;
250
+ /** 固定源码版本或差异标识。 */
251
+ revision: string | null;
252
+ reasonCode: string | null;
253
+ note: string;
254
+ /**
255
+ * 主管确认的改动证据引用;只在 `REPO_RELATIVE_VERIFIED` 时存在。
256
+ * Owner 面板据此经有效管理窗口读取只读详情,工作台不携带差异正文。
257
+ */
258
+ evidenceId?: string | null;
259
+ entryId?: string | null;
260
+ /** 固定标注「主管确认的改动证据」;不可定位时为 null。 */
261
+ evidenceLabel?: string | null;
262
+ /** 部分覆盖的诚实提示;完整覆盖为 null。 */
263
+ coverageNote?: string | null;
264
+ }
265
+ export interface DeliveryItemView {
266
+ /** 稳定 ID;同一交付内同一逻辑条目跨重建不变。 */
267
+ itemId: string;
268
+ /** 内容版本;变化后旧知悉只留历史,当前版本重新待知悉。 */
269
+ contentHash: string;
270
+ /** 层级:SUMMARY(成果摘要)/ EVIDENCE(证据与改动)。 */
271
+ layer: 'SUMMARY' | 'EVIDENCE';
272
+ label: string;
273
+ detail: string;
274
+ change: DeliveryChangeView;
275
+ acknowledgement: {
276
+ state: DeliveryAcknowledgementState;
277
+ acknowledged: boolean;
278
+ /** 旧版本知悉次数;只作历史,不代表当前版本已知悉。 */
279
+ historicalCount: number;
280
+ acknowledgedAt: string | null;
281
+ acknowledgementEventSeq: number | null;
282
+ };
283
+ /**
284
+ * 条目提问的**最小元数据**:只有计数、时间与接收主管是否可达,绝不含问题或回复
285
+ * 正文。正文只经有效 Owner 窗口或当前责任主管的 session-bound Agent Tool 返回。
286
+ */
287
+ questions?: DeliveryItemQuestionState | null;
288
+ }
289
+ /** 条目提问状态;仅 Owner 窗口与当前责任主管 Tool 能看到正文。 */
290
+ export interface DeliveryItemQuestionState {
291
+ threadId: string;
292
+ totalCount: number;
293
+ /** 当前内容版本且尚无回复的条数;旧版未答问题不计入。 */
294
+ pendingCount: number;
295
+ answeredCount: number;
296
+ /** 属于可确认的旧内容版本、仅留历史的条数。 */
297
+ historyCount: number;
298
+ lastAskedAt: string | null;
299
+ lastRepliedAt: string | null;
300
+ /** 最近一条问题的接收主管当前是否可回复;不可达时界面必须照实说明。 */
301
+ latestReplyState: 'REPLY_ACCESSIBLE' | 'REVIEWER_BINDING_MISSING' | 'REVIEWER_BINDING_RETIRED' | 'REVIEWER_SESSION_CHANGED' | 'SUPERVISOR_REBOUND' | null;
302
+ /**
303
+ * 最近一条问题相对当前交付目录的版本关系。`CURRENT` 之外的值都不得被读成
304
+ * 「当前仍可回复」;`UNVERIFIABLE` 表示当前无法重验该条目版本。
305
+ */
306
+ latestItemVersion: 'CURRENT' | 'HISTORICAL' | 'UNVERIFIABLE';
307
+ /** 最近一条当前版本问题的内容版本;没有当前版本问题时为 null。 */
308
+ currentContentHash: string | null;
309
+ }
310
+ /** 模块/事项层:把证据层的条目按来源分组,形成「摘要 → 模块/事项 → 证据/改动」层级。 */
311
+ export interface DeliveryModuleView {
312
+ moduleId: string;
313
+ label: string;
314
+ detail: string;
315
+ items: DeliveryItemView[];
316
+ }
317
+ /** 主管 ACCEPT 确认交付时实际可核对到的接受证据强度(与 Core 分类同义)。 */
318
+ export type DeliveryAcceptanceEvidenceKind = 'EXACT_RESULT_BOUND' | 'LEGACY_ATTEMPT_ONLY';
319
+ /**
320
+ * 历史接受证据较弱的固定标注。单一来源是 `src/core/delivery-ack.ts`;这里只做
321
+ * 类型兼容的再导出,避免两处文案漂移。运行期值为 `undefined` 时由 GUI 回退到
322
+ * 「按真实事件字段与唯一 WorkerResult 判定」的等价短文案。
323
+ */
324
+ export { LEGACY_ACCEPTANCE_EVIDENCE_NOTE } from '../core/delivery-ack.js';
325
+ export interface WorkbenchAcceptanceEvidence {
326
+ kind: DeliveryAcceptanceEvidenceKind;
327
+ /** true 仅当 TASK_ACCEPTED 锁定了本次结果 ID 与内容摘要且两者都与当前呈报一致。 */
328
+ exactResultBound: boolean;
329
+ /** 弱证据时必须在界面可见地标注的固定文案;强证据为 null。 */
330
+ note: string | null;
331
+ }
236
332
  export interface WorkbenchDeliveryItem {
237
333
  taskId: string;
238
334
  title: string;
@@ -243,6 +339,47 @@ export interface WorkbenchDeliveryItem {
243
339
  /** 当前没有人类验收事实;DONE 也不能填为人类已验收。 */
244
340
  humanAcceptance: 'NOT_RECORDED';
245
341
  updatedAt: string;
342
+ /** 已由同一 Task/attempt 主管 ACCEPT 确认后才为 true;Worker Claim 不会使其为真。 */
343
+ deliveryConfirmed: boolean;
344
+ /** 确认该交付实际依据的接受证据;未确认交付时为 null。 */
345
+ acceptanceEvidence: WorkbenchAcceptanceEvidence | null;
346
+ /** 交付身份;未确认交付时为 null。 */
347
+ deliveryId: string | null;
348
+ attemptNo: number | null;
349
+ /**
350
+ * 生成「复制本条 Owner 激活命令」图标所需的准确范围事实。
351
+ * 只用于让人类复制一条 direct `/kingdom owner.gui` 命令;命令本身仍由
352
+ * Owner 直接执行并授权,这些字段不构成任何权限,也不授予知悉。
353
+ */
354
+ kingdomId: string | null;
355
+ territoryId: string;
356
+ territoryName: string | null;
357
+ /** 该领地当前 ACTIVE 主管绑定;未知时复制命令只用领地范围,不用 kingdomWide 兜底。 */
358
+ supervisorBindingId: string | null;
359
+ /** 成果摘要层条目文本(执行者自述摘要)。 */
360
+ summary: string | null;
361
+ /** 成果摘要层条目自身的稳定 ID 与内容版本;未确认交付时为 null。 */
362
+ summaryItemId: string | null;
363
+ summaryContentHash: string | null;
364
+ /** 成果摘要层知悉状态;子条知悉不覆盖它,它也不覆盖子条。 */
365
+ summaryAcknowledgement: DeliveryItemView['acknowledgement'] | null;
366
+ /** 成果摘要层的提问元数据(不含正文);无记录时为 null。 */
367
+ summaryQuestions: DeliveryItemQuestionState | null;
368
+ /** 模块/事项层。未确认交付时为空数组。 */
369
+ modules: DeliveryModuleView[];
370
+ /**
371
+ * 条目提问的最小元数据(不含正文)。正文只经有效 Owner 窗口或当前责任主管的
372
+ * session-bound Agent Tool 返回;工作台不携带、也不投影问答正文。
373
+ */
374
+ deliveryQuestions: DeliveryItemQuestionState[];
375
+ acknowledgement: {
376
+ acknowledgedCount: number;
377
+ pendingCount: number;
378
+ pendingRevisionCount: number;
379
+ lastAcknowledgedAt: string | null;
380
+ /** 条目版本已知悉,但整体仍不等于人类验收、Task DONE 或发布授权。 */
381
+ note: string;
382
+ };
246
383
  sourceRefs: SourceRef[];
247
384
  }
248
385
  export interface WorkbenchRoleItem {
@@ -250,6 +387,15 @@ export interface WorkbenchRoleItem {
250
387
  roleType: string;
251
388
  roleName: string;
252
389
  sessionBound: boolean;
390
+ /**
391
+ * v3.2.0:主管席位的隶属领地(来自领地投影的同一份事实)。
392
+ * 空数组 = 该席位未隶属任何活跃领地(遗留席位,需 Owner 处理);非主管角色恒为空数组(不适用)。
393
+ * 一个席位可以主理多个领地,因此这里是列表而不是单个值。
394
+ */
395
+ territories: {
396
+ territoryId: string;
397
+ name: string;
398
+ }[];
253
399
  taskCount: number;
254
400
  taskIds: string[];
255
401
  taskIdsTruncated: boolean;
@@ -379,6 +525,21 @@ export interface PersonalWorkbenchData {
379
525
  usage: WorkbenchUsageSummary;
380
526
  cost: WorkbenchCostSummary;
381
527
  collaboration: WorkbenchCollaborationView;
528
+ /**
529
+ * 交付条目提问的**最小元数据**汇总(无正文)。用于说明「有多少问题等待主管
530
+ * 回复」,不作通知、不作待办状态库,也不代表主管已读取。
531
+ */
532
+ deliveryQuestions: {
533
+ totalQuestions: number;
534
+ /** 当前内容版本且主管尚未回复的问题数;未被实际读取前只算「待领取」。 */
535
+ pendingQuestions: number;
536
+ answeredQuestions: number;
537
+ /** 接收主管已退任、换 session 或领地改绑的**当前版**问题数;它们保持可见但明确不可达。 */
538
+ unreachableQuestions: number;
539
+ /** 属于旧内容版本、仅留历史的问题数;它们不计当前待办,也不声称可回复。 */
540
+ historicalQuestions: number;
541
+ note: string;
542
+ };
382
543
  }
383
544
  export interface ReadonlySnapshotProjection {
384
545
  overview: ProjectionEnvelope<OverviewProjectionData>;
@@ -13,6 +13,44 @@ export interface OwnerLocalControlOptions {
13
13
  expectedOrigin: string | (() => string);
14
14
  now?: () => number;
15
15
  }
16
+ /**
17
+ * 非授权启动定位提示(launch hint)。
18
+ *
19
+ * 只描述人类刚点的那一条交付,用于在新标签页里预选;它不进入
20
+ * `OwnerDecisionInput`、不改变授权含义,也不产生任何写入。
21
+ */
22
+ export interface OwnerLaunchHintInput {
23
+ task?: unknown;
24
+ item?: unknown;
25
+ contentHash?: unknown;
26
+ /** 提示指向的动作:知悉(`ack`)还是提问(`ask`)。只决定兑换后预选哪个动作,不参与授权。 */
27
+ action?: unknown;
28
+ }
29
+ export interface OwnerLaunchAckHint {
30
+ task: string;
31
+ item: string;
32
+ contentHash: string;
33
+ /** `ack` = 预选逐条知悉;`ask` = 预选交付条目提问。 */
34
+ action: 'ack' | 'ask';
35
+ }
36
+ /**
37
+ * 按格式校验定位提示。三个字段要么全部合法,要么整体不成立:不部分采用。
38
+ *
39
+ * `input` 是拆分后的 direct 命令参数,因此能区分「未携带」(三个字段都
40
+ * `undefined`)与「携带了但不完整/非法」。调用方必须把后者当作输入错误在激活前
41
+ * 拒绝,而不是丢掉提示后照常激活——否则人类会以为新标签页仍会预选该条。
42
+ */
43
+ export declare function validateLaunchAckHint(input: OwnerLaunchHintInput | undefined): {
44
+ ok: true;
45
+ hint: OwnerLaunchAckHint | null;
46
+ } | {
47
+ ok: false;
48
+ message: string;
49
+ };
50
+ /** 三者同时存在且各自合法时返回提示,否则返回 null(不部分采用)。 */
51
+ export declare function normalizeLaunchAckHint(input: OwnerLaunchHintInput | undefined): OwnerLaunchAckHint | null;
52
+ /** 兑换成功后跳转的无票据地址;只带非授权提示字段,绝不带 ticket。 */
53
+ export declare function launchRedirectPath(hint: OwnerLaunchAckHint | null): string;
16
54
  /** Transport references existing direct-human decisions; it never accepts an HTTP identity. */
17
55
  export declare class OwnerLocalControlManager {
18
56
  private readonly options;
@@ -23,7 +61,7 @@ export declare class OwnerLocalControlManager {
23
61
  constructor(options: OwnerLocalControlOptions);
24
62
  private origin;
25
63
  checkTransport(meta: GuiControlRequestMeta, mutation?: boolean, navigation?: boolean): void;
26
- activate(capability: OwnerControlCapability, input: OwnerDecisionInput): {
64
+ activate(capability: OwnerControlCapability, input: OwnerDecisionInput, hintInput?: OwnerLaunchHintInput): {
27
65
  launchTicket: string;
28
66
  launchPath: '/owner';
29
67
  decisionId: string;
@@ -33,8 +71,30 @@ export declare class OwnerLocalControlManager {
33
71
  redeem(ticket: string, meta: GuiControlRequestMeta): {
34
72
  cookie: string;
35
73
  maxAgeSeconds: number;
74
+ redirectPath: string;
36
75
  };
37
76
  private window;
77
+ /**
78
+ * 只读返回一条已由主管确认的改动条目详情。
79
+ *
80
+ * 不消耗 CSRF、不写任何事实、不产生知悉;有效性完全由 Core 的
81
+ * `readDeliveryChange` 依据当前 ACTIVE 窗口、scope 与证据 hash 判定。
82
+ */
83
+ readChange(cookie: string | null, meta: GuiControlRequestMeta, params: {
84
+ taskId: string;
85
+ evidenceId: string;
86
+ entryId: string;
87
+ }): unknown;
88
+ /**
89
+ * 只读返回一条已确认交付条目的问答线程。
90
+ *
91
+ * 不消耗 CSRF、不写任何事实、不产生知悉、也不替主管回复;有效性完全由 Core 的
92
+ * `readDeliveryQuestions` 依据当前 ACTIVE 窗口、动作授权、scope 与精确条目判定。
93
+ */
94
+ readQuestions(cookie: string | null, meta: GuiControlRequestMeta, params: {
95
+ taskId: string;
96
+ itemId: string;
97
+ }): unknown;
38
98
  inspect(cookie: string | null, meta: GuiControlRequestMeta): Promise<unknown>;
39
99
  receipt(cookie: string | null, meta: GuiControlRequestMeta, operationId: string, decisionId: string | null): unknown;
40
100
  mutate(cookie: string | null, csrf: string | null, requestId: string | null, meta: GuiControlRequestMeta, action: 'prepare' | 'commit' | 'revoke', payload: Record<string, unknown>): Promise<unknown>;
@@ -4,6 +4,14 @@ import { type EventRow, type ExecutionRow, type KingdomStore, type RoleBindingRo
4
4
  export declare function boundedSourceRefs(refs: SourceRef[]): SourceRef[];
5
5
  /** 只返回生命周期候选的可执行性,不执行 action,也不改变任何状态。 */
6
6
  export declare function buildActionAvailability(store: KingdomStore, task: TaskRow, execution: ExecutionRow | null, security?: ProjectionSecurityContext): ActionAvailability[];
7
+ /**
8
+ * 事件 → 公开投影。
9
+ *
10
+ * 交付问答事件的正文**只**经受权入口返回:Owner 窗口走
11
+ * `OwnerDecisionController.readDeliveryQuestions`,主管走 session-bound Agent Tool
12
+ * 的账本读取。因此快照、TaskDetail.relatedEvents、recentEvents 与任何事件轮询/SSE
13
+ * 都只保留不含正文的最小元数据,绝不透传 `questionText`/`replyText`。
14
+ */
7
15
  export declare function toEventView(row: EventRow): EventView;
8
16
  export declare function toBindingView(row: RoleBindingRow): BindingView;
9
17
  export declare function toTerritoryView(row: TerritoryRow): TerritoryView;