dsh-kingdom 0.8.0 → 2.0.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 (162) hide show
  1. package/ASSETS_NOTICE.md +22 -0
  2. package/LICENSE +661 -29
  3. package/NOTICE +9 -0
  4. package/README.md +93 -94
  5. package/THIRD_PARTY_NOTICES.md +92 -0
  6. package/cordis.patch.yml +6 -6
  7. package/docs/V2.0-RELEASE-NOTES.md +30 -0
  8. package/docs/V2.0-USER-GUIDE.md +74 -0
  9. package/lib/adapter/dsh-backend.js +327 -24
  10. package/lib/adapter/dsh-backend.js.map +1 -1
  11. package/lib/adapter/dsh-cost.js +68 -0
  12. package/lib/adapter/dsh-cost.js.map +1 -0
  13. package/lib/adapter/dsh-session-events.js +86 -0
  14. package/lib/adapter/dsh-session-events.js.map +1 -0
  15. package/lib/adapter/dsh-usage.js +159 -0
  16. package/lib/adapter/dsh-usage.js.map +1 -0
  17. package/lib/capability/admin.js +72 -0
  18. package/lib/capability/admin.js.map +1 -0
  19. package/lib/capability/dsh-enforcement.js +143 -34
  20. package/lib/capability/dsh-enforcement.js.map +1 -1
  21. package/lib/capability/resolver.js +21 -8
  22. package/lib/capability/resolver.js.map +1 -1
  23. package/lib/capability/service.js +169 -26
  24. package/lib/capability/service.js.map +1 -1
  25. package/lib/capability/tool-disclosure.js +144 -0
  26. package/lib/capability/tool-disclosure.js.map +1 -0
  27. package/lib/core/binding.js +52 -34
  28. package/lib/core/binding.js.map +1 -1
  29. package/lib/core/budget.js +304 -0
  30. package/lib/core/budget.js.map +1 -0
  31. package/lib/core/collaboration.js +422 -0
  32. package/lib/core/collaboration.js.map +1 -0
  33. package/lib/core/cost.js +212 -0
  34. package/lib/core/cost.js.map +1 -0
  35. package/lib/core/db.js +197 -4
  36. package/lib/core/db.js.map +1 -1
  37. package/lib/core/execution.js +2 -2
  38. package/lib/core/execution.js.map +1 -1
  39. package/lib/core/governed-claim.js +46 -0
  40. package/lib/core/governed-claim.js.map +1 -0
  41. package/lib/core/governed.js +891 -98
  42. package/lib/core/governed.js.map +1 -1
  43. package/lib/core/kingdom.js +78 -70
  44. package/lib/core/kingdom.js.map +1 -1
  45. package/lib/core/owner-binding-intent.js +732 -0
  46. package/lib/core/owner-binding-intent.js.map +1 -0
  47. package/lib/core/owner-control.js +86 -0
  48. package/lib/core/owner-control.js.map +1 -0
  49. package/lib/core/owner-window.js +822 -0
  50. package/lib/core/owner-window.js.map +1 -0
  51. package/lib/core/task-service.js +296 -133
  52. package/lib/core/task-service.js.map +1 -1
  53. package/lib/core/territory.js +44 -14
  54. package/lib/core/territory.js.map +1 -1
  55. package/lib/core/usage.js +39 -0
  56. package/lib/core/usage.js.map +1 -0
  57. package/lib/core/workspace-admission.js +225 -0
  58. package/lib/core/workspace-admission.js.map +1 -0
  59. package/lib/dispatch/evidence.js +5 -2
  60. package/lib/dispatch/evidence.js.map +1 -1
  61. package/lib/dispatch/reconcile.js +3 -9
  62. package/lib/dispatch/reconcile.js.map +1 -1
  63. package/lib/dispatch/service.js +464 -64
  64. package/lib/dispatch/service.js.map +1 -1
  65. package/lib/gui/assets/characters/chancellor-idle.svg +67 -0
  66. package/lib/gui/assets/characters/chancellor-sleeping.svg +67 -0
  67. package/lib/gui/assets/characters/chancellor-thinking.svg +67 -0
  68. package/lib/gui/assets/characters/chancellor-working.svg +67 -0
  69. package/lib/gui/assets/characters/knight-redraw-r1-idle.svg +67 -0
  70. package/lib/gui/assets/characters/knight-redraw-r1-sleeping.svg +67 -0
  71. package/lib/gui/assets/characters/knight-redraw-r1-thinking.svg +67 -0
  72. package/lib/gui/assets/characters/knight-redraw-r1-working.svg +67 -0
  73. package/lib/gui/assets/characters/supervisor-idle.svg +67 -0
  74. package/lib/gui/assets/characters/supervisor-sleeping.svg +67 -0
  75. package/lib/gui/assets/characters/supervisor-thinking.svg +67 -0
  76. package/lib/gui/assets/characters/supervisor-working.svg +67 -0
  77. package/lib/gui/console-app.js +2330 -0
  78. package/lib/gui/console-app.js.map +1 -0
  79. package/lib/gui/contract.js +5 -5
  80. package/lib/gui/contract.js.map +1 -1
  81. package/lib/gui/control-contract.js +232 -0
  82. package/lib/gui/control-contract.js.map +1 -0
  83. package/lib/gui/local-control.js +423 -0
  84. package/lib/gui/local-control.js.map +1 -0
  85. package/lib/gui/owner-control.js +310 -0
  86. package/lib/gui/owner-control.js.map +1 -0
  87. package/lib/gui/owner-ui.js +191 -0
  88. package/lib/gui/owner-ui.js.map +1 -0
  89. package/lib/gui/server.js +445 -35
  90. package/lib/gui/server.js.map +1 -1
  91. package/lib/gui/snapshot.js +1346 -67
  92. package/lib/gui/snapshot.js.map +1 -1
  93. package/lib/gui/visual-assets.js +56 -0
  94. package/lib/gui/visual-assets.js.map +1 -0
  95. package/lib/gui/visual-system.js +272 -0
  96. package/lib/gui/visual-system.js.map +1 -0
  97. package/lib/gui/workbench-ui.js +358 -0
  98. package/lib/gui/workbench-ui.js.map +1 -0
  99. package/lib/gui/workbench.js +163 -0
  100. package/lib/gui/workbench.js.map +1 -0
  101. package/lib/index.js +1384 -361
  102. package/lib/index.js.map +1 -1
  103. package/lib/runner-context-broker.js +1134 -0
  104. package/lib/runner-context-broker.js.map +1 -0
  105. package/lib/runtime-cost-observer.js +145 -0
  106. package/lib/runtime-cost-observer.js.map +1 -0
  107. package/lib/types/adapter/contract.d.ts +61 -1
  108. package/lib/types/adapter/dsh-backend.d.ts +32 -13
  109. package/lib/types/adapter/dsh-cost.d.ts +13 -0
  110. package/lib/types/adapter/dsh-session-events.d.ts +16 -0
  111. package/lib/types/adapter/dsh-usage.d.ts +36 -0
  112. package/lib/types/capability/admin.d.ts +13 -0
  113. package/lib/types/capability/dsh-enforcement.d.ts +11 -7
  114. package/lib/types/capability/service.d.ts +10 -3
  115. package/lib/types/capability/tool-disclosure.d.ts +36 -0
  116. package/lib/types/core/binding.d.ts +19 -10
  117. package/lib/types/core/budget.d.ts +81 -0
  118. package/lib/types/core/collaboration.d.ts +110 -0
  119. package/lib/types/core/cost.d.ts +99 -0
  120. package/lib/types/core/db.d.ts +44 -4
  121. package/lib/types/core/execution.d.ts +1 -1
  122. package/lib/types/core/governed-claim.d.ts +7 -0
  123. package/lib/types/core/governed.d.ts +182 -1
  124. package/lib/types/core/kingdom.d.ts +3 -0
  125. package/lib/types/core/owner-binding-intent.d.ts +176 -0
  126. package/lib/types/core/owner-control.d.ts +53 -0
  127. package/lib/types/core/owner-window.d.ts +226 -0
  128. package/lib/types/core/task-service.d.ts +60 -13
  129. package/lib/types/core/territory.d.ts +9 -2
  130. package/lib/types/core/usage.d.ts +26 -0
  131. package/lib/types/core/workspace-admission.d.ts +43 -0
  132. package/lib/types/dispatch/evidence.d.ts +2 -5
  133. package/lib/types/dispatch/service.d.ts +62 -4
  134. package/lib/types/gui/console-app.d.ts +137 -0
  135. package/lib/types/gui/contract.d.ts +396 -16
  136. package/lib/types/gui/control-contract.d.ts +111 -0
  137. package/lib/types/gui/local-control.d.ts +120 -0
  138. package/lib/types/gui/owner-control.d.ts +45 -0
  139. package/lib/types/gui/owner-ui.d.ts +2 -0
  140. package/lib/types/gui/server.d.ts +17 -3
  141. package/lib/types/gui/snapshot.d.ts +33 -11
  142. package/lib/types/gui/visual-assets.d.ts +27 -0
  143. package/lib/types/gui/visual-system.d.ts +2 -0
  144. package/lib/types/gui/workbench-ui.d.ts +5 -0
  145. package/lib/types/gui/workbench.d.ts +33 -0
  146. package/lib/types/index.d.ts +157 -6
  147. package/lib/types/runner-context-broker.d.ts +119 -0
  148. package/lib/types/runtime-cost-observer.d.ts +22 -0
  149. package/lib/types/worker/collaboration.d.ts +35 -0
  150. package/lib/types/worker/dsh-subagent.d.ts +4 -4
  151. package/lib/types/worker/executor-factory.d.ts +2 -1
  152. package/lib/types/worker/executor.d.ts +8 -3
  153. package/lib/types/worker/governed-executor.d.ts +8 -1
  154. package/lib/worker/collaboration.js +172 -0
  155. package/lib/worker/collaboration.js.map +1 -0
  156. package/lib/worker/dsh-subagent.js +4 -4
  157. package/lib/worker/executor-factory.js.map +1 -1
  158. package/lib/worker/executor.js +7 -2
  159. package/lib/worker/executor.js.map +1 -1
  160. package/lib/worker/governed-executor.js +295 -84
  161. package/lib/worker/governed-executor.js.map +1 -1
  162. package/package.json +23 -8
@@ -45,13 +45,14 @@ 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' | 'EXECUTION_NOT_FOUND' | 'ILLEGAL_EXECUTION_STATE';
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
49
  /**
50
50
  * v0.5.2(M1-B/P0-B):GUI 写命令守卫。
51
51
  *
52
52
  * GUI 网关没有可信 DSH Principal(HTTP payload 的 session_id 一律不再被信任),
53
- * 因此 `session-bound` 模式下所有写命令 fail-closed——宁可少一个按钮能用,
54
- * 也不能让 GUI 伪造治理身份。`declarative` 是本地可信演示模式,保持可用。
53
+ * R02 Owner Control ruling:GUI/HTTP 没有可信 direct Owner capability,
54
+ * 因此所有写命令都 fail-closed;declarative 仅保留为历史 fixture 语义,
55
+ * 不能解锁产品写入。
55
56
  */
56
57
  export declare function guiWriteGuard(authMode: string): {
57
58
  allowed: true;
@@ -60,7 +61,345 @@ export declare function guiWriteGuard(authMode: string): {
60
61
  code: 'SESSION_AUTH_REQUIRED';
61
62
  };
62
63
  /** GUI 可以呈现为按钮的下一步动作。 */
63
- export type AllowedAction = 'assign' | 'start' | 'review:accept' | 'review:rework' | 'review:fail' | 'execution:pause' | 'execution:resume' | 'execution:abort';
64
+ export type AllowedAction = 'assign' | 'start' | 'reconcile' | 'review:accept' | 'review:rework' | 'review:fail' | 'review:handoff' | 'execution:pause' | 'execution:resume' | 'execution:abort';
65
+ /** v0.9 S1:Projection 的可公开、可追溯来源引用。不得放入 raw payload/session/path。 */
66
+ export type ProjectionSourceType = 'table-row' | 'event' | 'runtime-evidence' | 'derived-rule';
67
+ export interface SourceRef {
68
+ sourceType: ProjectionSourceType;
69
+ entityType: string;
70
+ entityId: string | null;
71
+ eventSeq?: number;
72
+ ruleCode?: string;
73
+ }
74
+ export interface EntityRef {
75
+ type: string;
76
+ id: string;
77
+ }
78
+ export type ProjectionSourceKind = 'GOVERNANCE_FACT' | 'RUNTIME_OBSERVATION';
79
+ export interface AuthoritativeState {
80
+ sourceKind: ProjectionSourceKind;
81
+ value: string;
82
+ sourceRefs: SourceRef[];
83
+ }
84
+ export interface AttentionReason {
85
+ code: string;
86
+ sourceRefs: SourceRef[];
87
+ }
88
+ export interface ActionAvailability {
89
+ action: AllowedAction | string;
90
+ lifecycleAllowed: boolean;
91
+ executable: boolean;
92
+ disabledReason: AttentionReason | null;
93
+ sourceRefs: SourceRef[];
94
+ }
95
+ export type ProjectionItemKind = 'GOVERNANCE_FACT' | 'RUNTIME_OBSERVATION' | 'WORKER_CLAIM' | 'DERIVED_EXPLANATION';
96
+ export type ProjectionTerminality = 'NON_TERMINAL' | 'TERMINAL' | 'UNKNOWN';
97
+ export interface TimelineItem {
98
+ id: string;
99
+ kind: ProjectionItemKind;
100
+ occurredAt: string | null;
101
+ entityRef: EntityRef | null;
102
+ authoritativeState: AuthoritativeState | null;
103
+ sourceRefs: SourceRef[];
104
+ allowedActions: ActionAvailability[] | null;
105
+ attentionReason: AttentionReason | null;
106
+ terminality: ProjectionTerminality;
107
+ summary: string;
108
+ requiresOwnerAction: boolean;
109
+ rawEvidenceAvailable: boolean;
110
+ }
111
+ export interface AttentionItem {
112
+ id: string;
113
+ severity: 'ATTENTION' | 'CRITICAL' | 'UNKNOWN';
114
+ entityRef: EntityRef | null;
115
+ reason: AttentionReason;
116
+ summary: string;
117
+ sourceRefs: SourceRef[];
118
+ }
119
+ export interface ProjectionEnvelope<T> {
120
+ revision: number;
121
+ refreshedAt: string;
122
+ entityRef: EntityRef | null;
123
+ authoritativeState: AuthoritativeState | null;
124
+ sourceRefs: SourceRef[];
125
+ allowedActions: ActionAvailability[] | null;
126
+ attentionReason: AttentionReason | null;
127
+ data: T;
128
+ }
129
+ export interface OverviewProjectionData {
130
+ health: 'OK' | 'ATTENTION' | 'CRITICAL' | 'UNKNOWN';
131
+ /** Optional business-facing health wording supplied by the projection/fixture. */
132
+ healthTitle?: string | null;
133
+ healthLabel?: string | null;
134
+ healthMetrics?: {
135
+ blockedWorkers: number;
136
+ frozenTerritories: number;
137
+ attentionCount: number;
138
+ } | null;
139
+ taskCount: number;
140
+ activeExecutionCount: number;
141
+ statusCounts: Record<string, number>;
142
+ ownerActions: ActionAvailability[];
143
+ }
144
+ /** v1.0:组织页使用的有界角色摘要;不包含 session/model/meta/private path。 */
145
+ export interface OrganizationRoleSummary {
146
+ bindingRef: EntityRef;
147
+ roleType: string;
148
+ roleName: string;
149
+ /**
150
+ * Canonical organization scope for this binding when one exact territory is
151
+ * knowable. `null` is intentional for a worker with no current affinity or
152
+ * with conflicting territory evidence; the GUI must keep that actor visible
153
+ * in an explicit unassigned/unknown area.
154
+ */
155
+ territoryRef: EntityRef | null;
156
+ status: AuthoritativeState;
157
+ sessionBound: boolean;
158
+ sourceRefs: SourceRef[];
159
+ }
160
+ /** v1.0:组织页使用的有界 Territory 摘要;workspace path 永不进入 Projection。 */
161
+ export interface OrganizationTerritorySummary {
162
+ territoryRef: EntityRef;
163
+ name: string;
164
+ status: AuthoritativeState;
165
+ supervisorBindingRef: EntityRef | null;
166
+ taskCount: number;
167
+ sourceRefs: SourceRef[];
168
+ }
169
+ export interface OrganizationProjectionData {
170
+ kingdomName: string | null;
171
+ bindingCount: number;
172
+ territoryCount: number;
173
+ roles: OrganizationRoleSummary[];
174
+ territories: OrganizationTerritorySummary[];
175
+ rolesTruncated: boolean;
176
+ territoriesTruncated: boolean;
177
+ }
178
+ /** v1.0:Execution 导航使用的运行事实摘要;Claim 与治理 Fact 不在此混写。 */
179
+ export interface ExecutionProjectionSummary {
180
+ executionId: string;
181
+ taskId: string;
182
+ executionRef: EntityRef;
183
+ taskRef: EntityRef;
184
+ workerBindingRef: EntityRef | null;
185
+ attemptNo: number;
186
+ state: string;
187
+ authoritativeState: AuthoritativeState;
188
+ executionContract: string;
189
+ terminality: ProjectionTerminality;
190
+ pausePending: boolean;
191
+ startedAt: string | null;
192
+ endedAt: string | null;
193
+ actionAvailability: ActionAvailability[];
194
+ attentionReason: AttentionReason | null;
195
+ sourceRefs: SourceRef[];
196
+ }
197
+ export interface ExecutionProjectionData {
198
+ totalExecutionCount: number;
199
+ items: ExecutionProjectionSummary[];
200
+ truncated: boolean;
201
+ }
202
+ export interface TaskProjectionData {
203
+ taskRef: EntityRef;
204
+ status: AuthoritativeState;
205
+ claim: {
206
+ outcome: string;
207
+ sourceRefs: SourceRef[];
208
+ } | null;
209
+ execution: {
210
+ state: string;
211
+ executionContract: string;
212
+ terminality: ProjectionTerminality;
213
+ sourceRefs: SourceRef[];
214
+ } | null;
215
+ actionAvailability: ActionAvailability[];
216
+ }
217
+ /** v1.2:工作台只是现有事实的有界投影,不创建待办/验收状态库。 */
218
+ export interface WorkbenchQueue<T> {
219
+ totalCount: number;
220
+ items: T[];
221
+ truncated: boolean;
222
+ }
223
+ export interface WorkbenchActionItem {
224
+ id: string;
225
+ kind: string;
226
+ taskId: string | null;
227
+ territoryId: string | null;
228
+ title: string;
229
+ summary: string;
230
+ responsibility: 'OWNER' | 'CHANCELLOR' | 'SUPERVISOR' | 'UNDETERMINED';
231
+ responsibleBindingId: string | null;
232
+ /** 复用原有服务端许可;责任分类本身不授予调用权限。 */
233
+ actionAvailability: ActionAvailability[];
234
+ sourceRefs: SourceRef[];
235
+ }
236
+ export interface WorkbenchDeliveryItem {
237
+ taskId: string;
238
+ title: string;
239
+ status: string;
240
+ claim: ClaimView | null;
241
+ supervisorAccepted: boolean;
242
+ supervisorDecision: SupervisorDecisionView | null;
243
+ /** 当前没有人类验收事实;DONE 也不能填为人类已验收。 */
244
+ humanAcceptance: 'NOT_RECORDED';
245
+ updatedAt: string;
246
+ sourceRefs: SourceRef[];
247
+ }
248
+ export interface WorkbenchRoleItem {
249
+ bindingId: string;
250
+ roleType: string;
251
+ roleName: string;
252
+ sessionBound: boolean;
253
+ taskCount: number;
254
+ taskIds: string[];
255
+ taskIdsTruncated: boolean;
256
+ activeExecutionCount: number;
257
+ reviewTaskCount: number;
258
+ recoveringTaskCount: number;
259
+ sourceRefs: SourceRef[];
260
+ }
261
+ export interface WorkbenchUsageSummary {
262
+ scope: 'WORKER_DISPATCH_ONLY';
263
+ totalDispatches: number;
264
+ completeDispatches: number;
265
+ partialDispatches: number;
266
+ unavailableDispatches: number;
267
+ /** 实际执行中没有对应 Dispatch 的次数,可能包括 legacy 执行。 */
268
+ executionsWithoutDispatch: number;
269
+ coverage: 'COMPLETE' | 'PARTIAL' | 'UNAVAILABLE';
270
+ /** 仅累加完整、对应当前 Dispatch 的供应商报告;无完整报告返回 null。 */
271
+ reportedTotals: {
272
+ uncachedInputTokens: number;
273
+ outputTokens: number;
274
+ totalTokens: number;
275
+ } | null;
276
+ cost: null;
277
+ costStatus: 'NOT_RECORDED';
278
+ sourceRefs: SourceRef[];
279
+ }
280
+ export interface WorkbenchCostRuntime {
281
+ toolDisclosureMode: 'off' | 'pilot';
282
+ observerAvailable: boolean;
283
+ }
284
+ /** Public assembly measurements, without runtime/session references or prompt text. */
285
+ export interface WorkbenchPromptCostView {
286
+ bindingId: string | null;
287
+ roleType: string;
288
+ toolsBefore: number | null;
289
+ toolsAfter: number | null;
290
+ toolsBytesBefore: number | null;
291
+ toolsBytesAfter: number | null;
292
+ sections: {
293
+ name: string;
294
+ bytes: number | null;
295
+ }[];
296
+ contexts: {
297
+ name: string;
298
+ bytes: number | null;
299
+ }[];
300
+ partsTruncated: boolean;
301
+ historyBytes: null;
302
+ tokenEstimate: null;
303
+ mode: 'off' | 'pilot' | 'UNKNOWN';
304
+ reasonCode: string | null;
305
+ }
306
+ export interface WorkbenchCostSummary {
307
+ additionalRoles: import('../core/cost.js').AdditionalRoleCostSummary | null;
308
+ budget: import('../core/budget.js').BudgetView | null;
309
+ prompts: WorkbenchQueue<WorkbenchPromptCostView>;
310
+ runtime: {
311
+ toolDisclosureMode: 'off' | 'pilot' | 'UNKNOWN';
312
+ observerAvailable: boolean | null;
313
+ };
314
+ }
315
+ export interface WorkbenchPlanReadiness {
316
+ ready: boolean;
317
+ reasonCode: string | null;
318
+ blockingTaskIds: string[];
319
+ acceptedResults: {
320
+ taskId: string;
321
+ attemptNo: number;
322
+ resultId: string;
323
+ resultDigest: string;
324
+ acceptEventId: string;
325
+ }[];
326
+ }
327
+ export interface WorkbenchPlanView {
328
+ planId: string;
329
+ parentTaskId: string;
330
+ title: string;
331
+ version: number;
332
+ digest: string;
333
+ state: 'PROPOSED' | 'ADOPTED' | 'STALE';
334
+ mode: 'EXPERT' | 'TEAM';
335
+ reason: string;
336
+ integratorBindingId: string;
337
+ integratorName: string;
338
+ parentStatus: string;
339
+ budgetTokens: number;
340
+ reserveTokens: number;
341
+ adoptedAt: string | null;
342
+ integration: WorkbenchPlanReadiness | null;
343
+ budget: import('../core/collaboration.js').PlanBudgetView | null;
344
+ items: {
345
+ key: string;
346
+ taskId: string;
347
+ title: string;
348
+ description: string;
349
+ acceptanceCriteria: string;
350
+ territoryId: string;
351
+ territoryName: string;
352
+ workerBindingId: string;
353
+ workerName: string;
354
+ access: 'READ_ONLY' | 'WRITE';
355
+ dependsOn: string[];
356
+ expectedArtifact: string;
357
+ status: string;
358
+ readiness: WorkbenchPlanReadiness | null;
359
+ }[];
360
+ }
361
+ export interface WorkbenchCollaborationView {
362
+ plans: WorkbenchQueue<WorkbenchPlanView>;
363
+ pendingAdoptionCount: number;
364
+ /** Held resources only; absence is not proof that a future start can acquire a workspace. */
365
+ resources: WorkbenchQueue<{
366
+ taskId: string;
367
+ attemptNo: number;
368
+ access: 'READ_ONLY' | 'WRITE';
369
+ state: string;
370
+ recovery: boolean;
371
+ }>;
372
+ }
373
+ export interface PersonalWorkbenchData {
374
+ ownerActions: WorkbenchQueue<WorkbenchActionItem>;
375
+ internalActions: WorkbenchQueue<WorkbenchActionItem>;
376
+ exceptions: WorkbenchQueue<WorkbenchActionItem>;
377
+ deliveries: WorkbenchQueue<WorkbenchDeliveryItem>;
378
+ roles: WorkbenchQueue<WorkbenchRoleItem>;
379
+ usage: WorkbenchUsageSummary;
380
+ cost: WorkbenchCostSummary;
381
+ collaboration: WorkbenchCollaborationView;
382
+ }
383
+ export interface ReadonlySnapshotProjection {
384
+ overview: ProjectionEnvelope<OverviewProjectionData>;
385
+ organization: ProjectionEnvelope<OrganizationProjectionData>;
386
+ executions: ProjectionEnvelope<ExecutionProjectionData>;
387
+ timeline: ProjectionEnvelope<TimelineItem[]>;
388
+ attention: ProjectionEnvelope<AttentionItem[]>;
389
+ workbench: ProjectionEnvelope<PersonalWorkbenchData>;
390
+ }
391
+ /**
392
+ * S1 只读派生所需的 Host-only 可验证上下文;缺任一项时 action 必须 fail-closed。
393
+ * `principalSessionId` 由 local-control Host 以 opaque context 注入,不来自浏览器
394
+ * payload,也不表示 Owner principal。
395
+ */
396
+ export interface ProjectionSecurityContext {
397
+ principalSessionId?: string | null;
398
+ sessionVerified?: boolean;
399
+ scope?: string[] | null;
400
+ hostContext?: boolean;
401
+ commandCoverage?: string[] | null;
402
+ }
64
403
  export interface EventView {
65
404
  seq: number;
66
405
  eventId: string;
@@ -77,15 +416,17 @@ export interface BindingView {
77
416
  roleType: string;
78
417
  roleName: string;
79
418
  runtimeType: string;
80
- /** v0.5.2(M1-B/P0-C):脱敏后的会话标识(如 …8f21)。完整 session id 只进审计事件面,不出普通快照。 */
419
+ /** v0.5.2(M1-B/P0-C):脱敏后的会话标识(如 …8f21);完整 id 不进入公共 GUI JSON。 */
81
420
  sessionDisplay: string | null;
82
421
  /** 是否已绑定会话(session-bound 模式下该绑定可被验证身份)。 */
83
422
  sessionBound: boolean;
84
- /** v0.4:会话身份预留字段(模型名 / agent 工具名 / 扩展槽),可空。 */
423
+ /** v0.4:字段/null shape 兼容;已配置的私有模型值仅返回稳定脱敏标记。 */
85
424
  modelName: string | null;
425
+ /** 字段/null shape 兼容;已配置的私有 agent 值仅返回稳定脱敏标记。 */
86
426
  agentName: string | null;
427
+ /** 保留 object/null shape;敏感 key 递归脱敏,深度、条目、节点与字符串均有界。 */
87
428
  sessionMeta: Record<string, unknown> | null;
88
- /** v0.6.0(M1-C):执行配置(ExecutionProfile {provider?, model?})只读展示;null=未配置(回退全局)。 */
429
+ /** v0.6.0(M1-C):保留 ExecutionProfile 字段 shape;配置值脱敏,null=未配置(回退全局)。 */
89
430
  executionProfile: {
90
431
  provider: string | null;
91
432
  model: string | null;
@@ -105,6 +446,7 @@ export interface ClaimView {
105
446
  resultId: string;
106
447
  attemptNo: number;
107
448
  workerBindingId: string | null;
449
+ /** 与 BindingView 一致的脱敏 session id;字段 shape 保持兼容。 */
108
450
  sessionId: string | null;
109
451
  /** Worker 自称的结果,仅供展示与审查,不驱动状态。 */
110
452
  claimedOutcome: string;
@@ -119,6 +461,7 @@ export interface ExecutionView {
119
461
  taskId: string;
120
462
  attemptNo: number;
121
463
  workerBindingId: string | null;
464
+ /** 与 BindingView 一致的脱敏 session id;字段 shape 保持兼容。 */
122
465
  sessionId: string | null;
123
466
  state: string;
124
467
  detail: string | null;
@@ -176,6 +519,7 @@ export interface CapabilityDecisionView {
176
519
  }
177
520
  /** Dispatch Record 投影(RECOVERING 必须如实显示,禁止显示成 Done)。 */
178
521
  export interface DispatchView {
522
+ usage?: import('../core/usage.js').DispatchUsageView | null;
179
523
  dispatchId: string;
180
524
  leaseId: string;
181
525
  executionId: string;
@@ -236,6 +580,12 @@ export interface StageActorView {
236
580
  fallbackState: ActorState;
237
581
  /** 触发本状态的事件序号,便于 GUI 丢弃过期事件。 */
238
582
  sourceSeq: number | null;
583
+ /**
584
+ * Evidence is present but cannot be uniquely attributed (for example two
585
+ * live executions for one binding) or the actor has no exact territory
586
+ * scope. The renderer must not turn this into a live-success claim.
587
+ */
588
+ indeterminate: boolean;
239
589
  }
240
590
  /** 权限诚实度声明。Beta 若未做主体校验,必须让 GUI 能显示这个徽章。 */
241
591
  export interface AuthView {
@@ -274,6 +624,35 @@ export interface SnapshotView {
274
624
  recentEvents: EventView[];
275
625
  /** v0.8:Runtime Governance 投影(§32)。Schema 非 v4 时为全空数组。 */
276
626
  governance: RuntimeGovernanceView;
627
+ /** v1.0:保留四类证据并 additive 增加 Organization / Execution 摘要。 */
628
+ projection: ReadonlySnapshotProjection;
629
+ }
630
+ /** v1.0:Task Detail 的 Assignment Ledger 历史;不包含 session/private payload。 */
631
+ export interface TaskAssignmentHistoryView {
632
+ assignmentId: string;
633
+ workerBindingId: string;
634
+ assignedByBindingId: string;
635
+ assignedAt: string | null;
636
+ endedAt: string | null;
637
+ endReason: string | null;
638
+ previousAssignmentId: string | null;
639
+ handoffReason: string | null;
640
+ sourceRefs: SourceRef[];
641
+ }
642
+ /** v1.0:从治理事件还原的 Supervisor decision;HANDOFF 字段均为有界公开引用。 */
643
+ export interface SupervisorDecisionView {
644
+ seq: number;
645
+ decision: string;
646
+ reason: string | null;
647
+ reviewerBindingId: string | null;
648
+ reviewedAttemptNo: number | null;
649
+ claimedOutcome: string | null;
650
+ fromAssignmentId: string | null;
651
+ fromWorkerBindingId: string | null;
652
+ toAssignmentId: string | null;
653
+ toWorkerBindingId: string | null;
654
+ sourceRefs: SourceRef[];
655
+ createdAt: string;
277
656
  }
278
657
  /** 任务详情:验收标准、尝试历史、Claim、Supervisor 决策、关联事件、下一步动作。 */
279
658
  export interface TaskDetailView {
@@ -282,22 +661,23 @@ export interface TaskDetailView {
282
661
  task: TaskView;
283
662
  territory: TerritoryView | null;
284
663
  assignedBinding: BindingView | null;
664
+ assignments: TaskAssignmentHistoryView[];
285
665
  claims: ClaimView[];
286
666
  executions: ExecutionView[];
287
667
  /** Supervisor 的历次裁定(从 events 还原,不存在 task_reviews 表)。 */
288
- reviews: {
289
- seq: number;
290
- decision: string;
291
- reason: string | null;
292
- reviewerBindingId: string | null;
293
- reviewedAttemptNo: number | null;
294
- claimedOutcome: string | null;
295
- createdAt: string;
296
- }[];
668
+ reviews: SupervisorDecisionView[];
669
+ reviewsTruncated: boolean;
297
670
  relatedEvents: EventView[];
671
+ /** 先按本任务取事件再应用窗口,不受其他任务的事件数量影响。 */
672
+ relatedEventsTruncated: boolean;
673
+ humanAcceptance: 'NOT_RECORDED';
298
674
  allowedActions: AllowedAction[];
299
675
  /** v0.8:本任务的 Runtime Governance 投影(Lease/Decision/Dispatch)。 */
300
676
  governance: RuntimeGovernanceView;
677
+ /** Exact single-task attribution only; shared and unattributed units remain outside task totals. */
678
+ additionalRoleCost: import('../core/cost.js').AdditionalRoleCostSummary | null;
679
+ /** v0.9 S1:Task Detail 的只读 Projection Envelope。 */
680
+ projection: ProjectionEnvelope<TaskProjectionData>;
301
681
  }
302
682
  /** 所有写命令的统一返回。GUI 只读结构化字段,不解析 `message`。 */
303
683
  export interface CommandResultView {
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Shared seam between the loopback HTTP server and the direct-Slash-owned
3
+ * local control broker.
4
+ *
5
+ * The values in this file are transport evidence only. A cookie, CSRF token,
6
+ * request id, browser payload, or HTTP request never creates Owner or Role
7
+ * authority. Only the broker may return the opaque execution context captured
8
+ * from the direct `/kingdom gui` activation.
9
+ */
10
+ /** Commands that the loopback GUI may submit after control-session admission. */
11
+ export declare const GUI_SESSION_COMMANDS: readonly ["plan", "assign", "start", "reconcile", "review", "execution.pause", "execution.resume", "execution.abort", "control.revoke"];
12
+ export type GuiSessionCommand = (typeof GUI_SESSION_COMMANDS)[number];
13
+ /** Exact browser-controlled top-level fields for each executable command. */
14
+ export declare const GUI_COMMAND_PAYLOAD_FIELDS: Record<GuiSessionCommand, readonly string[]>;
15
+ /** Authority-shaped keys are forbidden at every structural depth. */
16
+ export declare const GUI_FORBIDDEN_PAYLOAD_FIELDS: readonly ["session", "session_id", "sessionId", "principal", "principal_id", "principalId", "principal_session_id", "principalSessionId", "agent", "agent_id", "agentId", "actor_id", "actorId", "owner", "owner_control", "ownerControl", "owner_capability", "ownerCapability", "authority", "authorization", "cookie", "csrf_token", "csrfToken", "request_id", "requestId", "source_channel", "sourceChannel", "ticket", "launch_ticket", "launchTicket", "control_token", "controlToken", "activation_id", "activationId"];
17
+ export declare class DuplicateJsonKeyError extends Error {
18
+ readonly key: string;
19
+ constructor(key: string);
20
+ }
21
+ /**
22
+ * Parse one strict JSON object without allowing duplicate keys at any depth.
23
+ * `JSON.parse` alone cannot enforce this because it silently keeps the last
24
+ * duplicate value.
25
+ */
26
+ export declare function parseStrictJsonObject(text: string): Record<string, unknown>;
27
+ export declare const GUI_START_SANDBOX_MODES: readonly ["workspace-write", "read-only"];
28
+ export type GuiStartSandboxMode = (typeof GUI_START_SANDBOX_MODES)[number];
29
+ export declare const GUI_REVIEW_DECISIONS: readonly ["ACCEPT", "REWORK", "FAIL", "HANDOFF"];
30
+ /**
31
+ * Canonical Owner-only actions advertised by the GUI as discoverable but
32
+ * non-executable. The retired `setup.basic` HTTP spelling is deliberately not
33
+ * advertised as an action; it remains deny-only below for fail-closed clients.
34
+ */
35
+ export declare const GUI_OWNER_ONLY_ACTIONS: readonly ["init", "reset", "ceiling", "territory.create", "territory.delete", "territory.supervisor", "role.bind", "role.unbind", "role.session", "execution-profile"];
36
+ export type GuiOwnerOnlyAction = (typeof GUI_OWNER_ONLY_ACTIONS)[number];
37
+ /** Historical HTTP spellings remain explicit deny-only routes. */
38
+ export declare const GUI_OWNER_ONLY_HTTP_COMMANDS: readonly ["init", "reset", "ceiling", "territory.create", "territory.delete", "territory.supervisor", "role.bind", "role.unbind", "role.session", "execution-profile", "setup.basic", "binding.bind", "binding.unbind", "binding.session"];
39
+ export declare const GUI_OWNER_DIRECT_SLASH_HINTS: Record<GuiOwnerOnlyAction, string>;
40
+ export type GuiControlDisabledReason = 'SESSION_AUTH_REQUIRED' | 'DIRECT_SLASH_REQUIRED';
41
+ export interface GuiControlActionView {
42
+ executable: boolean;
43
+ disabledReason: GuiControlDisabledReason | null;
44
+ /** Loopback command name when executable; Owner-only actions always use null. */
45
+ command: GuiSessionCommand | null;
46
+ /** Copyable direct Slash guidance for Owner-only actions only. */
47
+ directSlashHint: string | null;
48
+ }
49
+ export type GuiControlFailureCode = 'CONTROL_SESSION_REQUIRED' | 'CONTROL_SESSION_EXPIRED' | 'CONTROL_ORIGIN_DENIED' | 'CONTROL_CSRF_DENIED' | 'CONTROL_REPLAY_DENIED' | 'CONTROL_BUSY' | 'CONTROL_TICKET_INVALID';
50
+ export interface GuiControlRequestMeta {
51
+ host: string | null;
52
+ origin: string | null;
53
+ remoteAddress: string | null;
54
+ fetchSite: string | null;
55
+ }
56
+ export interface GuiControlPublicView {
57
+ active: true;
58
+ activationId: string;
59
+ expiresAt: string;
60
+ csrfToken: string;
61
+ roleSessionBound: boolean;
62
+ commands: string[];
63
+ reviewDecisions: string[];
64
+ sandboxModes: string[];
65
+ actions: Record<string, GuiControlActionView>;
66
+ disabledReason: null;
67
+ }
68
+ /**
69
+ * Opaque to the HTTP server. The broker creates this from direct activation;
70
+ * browser data cannot construct or amend it.
71
+ */
72
+ export interface GuiControlExecutionContext {
73
+ readonly activationId: string;
74
+ readonly principalSessionId: string;
75
+ readonly signal: AbortSignal;
76
+ }
77
+ /** Broker-originated read identity; never serialized or accepted from HTTP. */
78
+ export interface GuiControlReadContext {
79
+ readonly principalSessionId: string | null;
80
+ }
81
+ export interface GuiControlFailure {
82
+ ok: false;
83
+ code: GuiControlFailureCode;
84
+ message: string;
85
+ }
86
+ export interface GuiControlRedeemed {
87
+ ok: true;
88
+ cookieValue: string;
89
+ view: GuiControlPublicView;
90
+ }
91
+ export interface GuiControlInspected {
92
+ ok: true;
93
+ view: GuiControlPublicView;
94
+ readContext: GuiControlReadContext;
95
+ }
96
+ export interface GuiControlAuthorized {
97
+ ok: true;
98
+ context: GuiControlExecutionContext;
99
+ view: GuiControlPublicView;
100
+ finish(): void;
101
+ }
102
+ export type GuiControlRedeemResult = GuiControlRedeemed | GuiControlFailure;
103
+ export type GuiControlInspectResult = GuiControlInspected | GuiControlFailure;
104
+ export type GuiControlAuthorizeResult = GuiControlAuthorized | GuiControlFailure;
105
+ export interface GuiControlBroker {
106
+ redeem(ticket: string, meta: GuiControlRequestMeta): GuiControlRedeemResult;
107
+ inspect(cookieValue: string | null, meta: GuiControlRequestMeta): GuiControlInspectResult;
108
+ authorize(cookieValue: string | null, csrfToken: string | null, requestId: string | null, meta: GuiControlRequestMeta): GuiControlAuthorizeResult;
109
+ revoke(cookieValue: string | null): void;
110
+ dispose(): void;
111
+ }