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.
- package/ASSETS_NOTICE.md +22 -0
- package/LICENSE +661 -29
- package/NOTICE +9 -0
- package/README.md +93 -94
- package/THIRD_PARTY_NOTICES.md +92 -0
- package/cordis.patch.yml +6 -6
- package/docs/V2.0-RELEASE-NOTES.md +30 -0
- package/docs/V2.0-USER-GUIDE.md +74 -0
- package/lib/adapter/dsh-backend.js +327 -24
- package/lib/adapter/dsh-backend.js.map +1 -1
- package/lib/adapter/dsh-cost.js +68 -0
- package/lib/adapter/dsh-cost.js.map +1 -0
- package/lib/adapter/dsh-session-events.js +86 -0
- package/lib/adapter/dsh-session-events.js.map +1 -0
- package/lib/adapter/dsh-usage.js +159 -0
- package/lib/adapter/dsh-usage.js.map +1 -0
- package/lib/capability/admin.js +72 -0
- package/lib/capability/admin.js.map +1 -0
- package/lib/capability/dsh-enforcement.js +143 -34
- package/lib/capability/dsh-enforcement.js.map +1 -1
- package/lib/capability/resolver.js +21 -8
- package/lib/capability/resolver.js.map +1 -1
- package/lib/capability/service.js +169 -26
- package/lib/capability/service.js.map +1 -1
- package/lib/capability/tool-disclosure.js +144 -0
- package/lib/capability/tool-disclosure.js.map +1 -0
- package/lib/core/binding.js +52 -34
- package/lib/core/binding.js.map +1 -1
- package/lib/core/budget.js +304 -0
- package/lib/core/budget.js.map +1 -0
- package/lib/core/collaboration.js +422 -0
- package/lib/core/collaboration.js.map +1 -0
- package/lib/core/cost.js +212 -0
- package/lib/core/cost.js.map +1 -0
- package/lib/core/db.js +197 -4
- package/lib/core/db.js.map +1 -1
- package/lib/core/execution.js +2 -2
- package/lib/core/execution.js.map +1 -1
- package/lib/core/governed-claim.js +46 -0
- package/lib/core/governed-claim.js.map +1 -0
- package/lib/core/governed.js +891 -98
- package/lib/core/governed.js.map +1 -1
- package/lib/core/kingdom.js +78 -70
- package/lib/core/kingdom.js.map +1 -1
- package/lib/core/owner-binding-intent.js +732 -0
- package/lib/core/owner-binding-intent.js.map +1 -0
- package/lib/core/owner-control.js +86 -0
- package/lib/core/owner-control.js.map +1 -0
- package/lib/core/owner-window.js +822 -0
- package/lib/core/owner-window.js.map +1 -0
- package/lib/core/task-service.js +296 -133
- package/lib/core/task-service.js.map +1 -1
- package/lib/core/territory.js +44 -14
- package/lib/core/territory.js.map +1 -1
- package/lib/core/usage.js +39 -0
- package/lib/core/usage.js.map +1 -0
- package/lib/core/workspace-admission.js +225 -0
- package/lib/core/workspace-admission.js.map +1 -0
- package/lib/dispatch/evidence.js +5 -2
- package/lib/dispatch/evidence.js.map +1 -1
- package/lib/dispatch/reconcile.js +3 -9
- package/lib/dispatch/reconcile.js.map +1 -1
- package/lib/dispatch/service.js +464 -64
- package/lib/dispatch/service.js.map +1 -1
- package/lib/gui/assets/characters/chancellor-idle.svg +67 -0
- package/lib/gui/assets/characters/chancellor-sleeping.svg +67 -0
- package/lib/gui/assets/characters/chancellor-thinking.svg +67 -0
- package/lib/gui/assets/characters/chancellor-working.svg +67 -0
- package/lib/gui/assets/characters/knight-redraw-r1-idle.svg +67 -0
- package/lib/gui/assets/characters/knight-redraw-r1-sleeping.svg +67 -0
- package/lib/gui/assets/characters/knight-redraw-r1-thinking.svg +67 -0
- package/lib/gui/assets/characters/knight-redraw-r1-working.svg +67 -0
- package/lib/gui/assets/characters/supervisor-idle.svg +67 -0
- package/lib/gui/assets/characters/supervisor-sleeping.svg +67 -0
- package/lib/gui/assets/characters/supervisor-thinking.svg +67 -0
- package/lib/gui/assets/characters/supervisor-working.svg +67 -0
- package/lib/gui/console-app.js +2330 -0
- package/lib/gui/console-app.js.map +1 -0
- package/lib/gui/contract.js +5 -5
- package/lib/gui/contract.js.map +1 -1
- package/lib/gui/control-contract.js +232 -0
- package/lib/gui/control-contract.js.map +1 -0
- package/lib/gui/local-control.js +423 -0
- package/lib/gui/local-control.js.map +1 -0
- package/lib/gui/owner-control.js +310 -0
- package/lib/gui/owner-control.js.map +1 -0
- package/lib/gui/owner-ui.js +191 -0
- package/lib/gui/owner-ui.js.map +1 -0
- package/lib/gui/server.js +445 -35
- package/lib/gui/server.js.map +1 -1
- package/lib/gui/snapshot.js +1346 -67
- package/lib/gui/snapshot.js.map +1 -1
- package/lib/gui/visual-assets.js +56 -0
- package/lib/gui/visual-assets.js.map +1 -0
- package/lib/gui/visual-system.js +272 -0
- package/lib/gui/visual-system.js.map +1 -0
- package/lib/gui/workbench-ui.js +358 -0
- package/lib/gui/workbench-ui.js.map +1 -0
- package/lib/gui/workbench.js +163 -0
- package/lib/gui/workbench.js.map +1 -0
- package/lib/index.js +1384 -361
- package/lib/index.js.map +1 -1
- package/lib/runner-context-broker.js +1134 -0
- package/lib/runner-context-broker.js.map +1 -0
- package/lib/runtime-cost-observer.js +145 -0
- package/lib/runtime-cost-observer.js.map +1 -0
- package/lib/types/adapter/contract.d.ts +61 -1
- package/lib/types/adapter/dsh-backend.d.ts +32 -13
- package/lib/types/adapter/dsh-cost.d.ts +13 -0
- package/lib/types/adapter/dsh-session-events.d.ts +16 -0
- package/lib/types/adapter/dsh-usage.d.ts +36 -0
- package/lib/types/capability/admin.d.ts +13 -0
- package/lib/types/capability/dsh-enforcement.d.ts +11 -7
- package/lib/types/capability/service.d.ts +10 -3
- package/lib/types/capability/tool-disclosure.d.ts +36 -0
- package/lib/types/core/binding.d.ts +19 -10
- package/lib/types/core/budget.d.ts +81 -0
- package/lib/types/core/collaboration.d.ts +110 -0
- package/lib/types/core/cost.d.ts +99 -0
- package/lib/types/core/db.d.ts +44 -4
- package/lib/types/core/execution.d.ts +1 -1
- package/lib/types/core/governed-claim.d.ts +7 -0
- package/lib/types/core/governed.d.ts +182 -1
- package/lib/types/core/kingdom.d.ts +3 -0
- package/lib/types/core/owner-binding-intent.d.ts +176 -0
- package/lib/types/core/owner-control.d.ts +53 -0
- package/lib/types/core/owner-window.d.ts +226 -0
- package/lib/types/core/task-service.d.ts +60 -13
- package/lib/types/core/territory.d.ts +9 -2
- package/lib/types/core/usage.d.ts +26 -0
- package/lib/types/core/workspace-admission.d.ts +43 -0
- package/lib/types/dispatch/evidence.d.ts +2 -5
- package/lib/types/dispatch/service.d.ts +62 -4
- package/lib/types/gui/console-app.d.ts +137 -0
- package/lib/types/gui/contract.d.ts +396 -16
- package/lib/types/gui/control-contract.d.ts +111 -0
- package/lib/types/gui/local-control.d.ts +120 -0
- package/lib/types/gui/owner-control.d.ts +45 -0
- package/lib/types/gui/owner-ui.d.ts +2 -0
- package/lib/types/gui/server.d.ts +17 -3
- package/lib/types/gui/snapshot.d.ts +33 -11
- package/lib/types/gui/visual-assets.d.ts +27 -0
- package/lib/types/gui/visual-system.d.ts +2 -0
- package/lib/types/gui/workbench-ui.d.ts +5 -0
- package/lib/types/gui/workbench.d.ts +33 -0
- package/lib/types/index.d.ts +157 -6
- package/lib/types/runner-context-broker.d.ts +119 -0
- package/lib/types/runtime-cost-observer.d.ts +22 -0
- package/lib/types/worker/collaboration.d.ts +35 -0
- package/lib/types/worker/dsh-subagent.d.ts +4 -4
- package/lib/types/worker/executor-factory.d.ts +2 -1
- package/lib/types/worker/executor.d.ts +8 -3
- package/lib/types/worker/governed-executor.d.ts +8 -1
- package/lib/worker/collaboration.js +172 -0
- package/lib/worker/collaboration.js.map +1 -0
- package/lib/worker/dsh-subagent.js +4 -4
- package/lib/worker/executor-factory.js.map +1 -1
- package/lib/worker/executor.js +7 -2
- package/lib/worker/executor.js.map +1 -1
- package/lib/worker/governed-executor.js +295 -84
- package/lib/worker/governed-executor.js.map +1 -1
- package/package.json +23 -8
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { Principal } from '../core/task-service.js';
|
|
2
|
+
import { GuiControlAuthorizeResult, GuiControlBroker, GuiControlInspectResult, GuiControlRedeemResult, GuiControlRequestMeta } from './control-contract.js';
|
|
3
|
+
export declare const LOCAL_CONTROL_REDIRECT_PATH = "/console";
|
|
4
|
+
export declare const LOCAL_CONTROL_LAUNCH_PATH = "/console";
|
|
5
|
+
export declare const LOCAL_CONTROL_SESSION_COOKIE = "dsh_kingdom_control";
|
|
6
|
+
export declare const LOCAL_CONTROL_CSRF_HEADER = "x-kingdom-csrf";
|
|
7
|
+
export declare const LOCAL_CONTROL_REQUEST_ID_HEADER = "x-kingdom-request-id";
|
|
8
|
+
type Clock = () => number;
|
|
9
|
+
type TokenFactory = () => string;
|
|
10
|
+
export interface LocalControlOptions {
|
|
11
|
+
/** HTTP Host must resolve to this exact IPv4 loopback address. */
|
|
12
|
+
host?: string;
|
|
13
|
+
/** Browser Origin must equal this exact value; `*` is never accepted. */
|
|
14
|
+
expectedOrigin: string | (() => string);
|
|
15
|
+
ticketTtlMs?: number;
|
|
16
|
+
sessionTtlMs?: number;
|
|
17
|
+
maxRequestIds?: number;
|
|
18
|
+
now?: Clock;
|
|
19
|
+
tokenFactory?: TokenFactory;
|
|
20
|
+
}
|
|
21
|
+
export interface LocalControlActivation {
|
|
22
|
+
/** One-time secret for the GUI launch route; never log or persist it. */
|
|
23
|
+
readonly launchTicket: string;
|
|
24
|
+
readonly launchPath: typeof LOCAL_CONTROL_LAUNCH_PATH;
|
|
25
|
+
readonly activationId: string;
|
|
26
|
+
readonly expiresAt: string;
|
|
27
|
+
readonly ttlMs: number;
|
|
28
|
+
}
|
|
29
|
+
export interface LocalControlRedeemRequest {
|
|
30
|
+
host: string;
|
|
31
|
+
/** Navigation requests may omit Origin; if present it is checked exactly. */
|
|
32
|
+
origin?: string | null;
|
|
33
|
+
}
|
|
34
|
+
export interface LocalControlCookie {
|
|
35
|
+
readonly name: typeof LOCAL_CONTROL_SESSION_COOKIE;
|
|
36
|
+
readonly value: string;
|
|
37
|
+
readonly httpOnly: true;
|
|
38
|
+
readonly sameSite: 'Strict';
|
|
39
|
+
readonly path: '/';
|
|
40
|
+
readonly maxAgeSeconds: number;
|
|
41
|
+
}
|
|
42
|
+
export interface LocalControlRedemption {
|
|
43
|
+
readonly ok: true;
|
|
44
|
+
readonly status: 303;
|
|
45
|
+
readonly location: typeof LOCAL_CONTROL_REDIRECT_PATH;
|
|
46
|
+
readonly cookie: LocalControlCookie;
|
|
47
|
+
/** Returned to the GUI page through the redemption response, not a cookie. */
|
|
48
|
+
readonly csrfToken: string;
|
|
49
|
+
readonly expiresAt: string;
|
|
50
|
+
}
|
|
51
|
+
export type LocalControlRejectionCode = 'LOCAL_CONTROL_CLOSED' | 'LOOPBACK_REQUIRED' | 'ORIGIN_MISMATCH' | 'ORIGIN_NOT_CONFIGURED' | 'LAUNCH_TICKET_REQUIRED' | 'LAUNCH_TICKET_INVALID' | 'LAUNCH_TICKET_EXPIRED' | 'SESSION_COOKIE_REQUIRED' | 'SESSION_INVALID' | 'SESSION_EXPIRED' | 'SESSION_REVOKED' | 'CSRF_REQUIRED' | 'CSRF_INVALID' | 'REQUEST_ID_REQUIRED' | 'REQUEST_ID_INVALID' | 'REQUEST_REPLAY' | 'REQUEST_WINDOW_EXHAUSTED' | 'MUTATION_IN_FLIGHT';
|
|
52
|
+
export interface LocalControlRejection {
|
|
53
|
+
readonly ok: false;
|
|
54
|
+
readonly code: LocalControlRejectionCode;
|
|
55
|
+
readonly message: string;
|
|
56
|
+
}
|
|
57
|
+
export interface LocalControlAuthority {
|
|
58
|
+
/** Captured exact DSH Agent object; never accepted from the HTTP payload. */
|
|
59
|
+
readonly agent: unknown;
|
|
60
|
+
/** Captured at activation time and re-used for session-bound Role checks. */
|
|
61
|
+
readonly principal: Principal;
|
|
62
|
+
/** Aborted on TTL expiry, revoke, replacement, or plugin unload. */
|
|
63
|
+
readonly signal: AbortSignal;
|
|
64
|
+
}
|
|
65
|
+
export interface LocalControlAdmission {
|
|
66
|
+
readonly ok: true;
|
|
67
|
+
readonly authority: LocalControlAuthority;
|
|
68
|
+
readonly expiresAt: string;
|
|
69
|
+
/** Must be called exactly once after the command handler settles. */
|
|
70
|
+
readonly release: () => void;
|
|
71
|
+
}
|
|
72
|
+
export type LocalControlRedemptionResult = LocalControlRedemption | LocalControlRejection;
|
|
73
|
+
export type LocalControlAdmissionResult = LocalControlAdmission | LocalControlRejection;
|
|
74
|
+
/** Accept `127.0.0.1` and `127.0.0.1:port`; reject localhost/IPv6/other hosts. */
|
|
75
|
+
export declare function isExactLoopbackHost(value: string, expectedHost?: string): boolean;
|
|
76
|
+
/** The server is IPv4-loopback only; do not widen this to localhost or ::1. */
|
|
77
|
+
export declare function isExactLoopbackRemoteAddress(value: string | null): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* In-process Local GUI Control Session manager.
|
|
80
|
+
*
|
|
81
|
+
* `activate()` is intended to be called only from the direct Slash handler.
|
|
82
|
+
* `redeem()` and `admit()` are transport seams; neither one mints authority.
|
|
83
|
+
*/
|
|
84
|
+
export declare class LocalControlManager implements GuiControlBroker {
|
|
85
|
+
private readonly host;
|
|
86
|
+
private readonly expectedOriginSource;
|
|
87
|
+
private readonly ticketTtlMs;
|
|
88
|
+
private readonly sessionTtlMs;
|
|
89
|
+
private readonly maxRequestIds;
|
|
90
|
+
private readonly now;
|
|
91
|
+
private readonly tokenFactory;
|
|
92
|
+
private readonly tickets;
|
|
93
|
+
private readonly sessions;
|
|
94
|
+
private closed;
|
|
95
|
+
constructor(options: LocalControlOptions);
|
|
96
|
+
private expectedOrigin;
|
|
97
|
+
private validateTransport;
|
|
98
|
+
private publicView;
|
|
99
|
+
private sessionFor;
|
|
100
|
+
activate(agent: unknown): LocalControlActivation;
|
|
101
|
+
redeem(launchTicket: string, meta: GuiControlRequestMeta): GuiControlRedeemResult;
|
|
102
|
+
inspect(cookieValue: string | null, meta: GuiControlRequestMeta): GuiControlInspectResult;
|
|
103
|
+
authorize(cookieValue: string | null, csrfToken: string | null, requestId: string | null, meta: GuiControlRequestMeta): GuiControlAuthorizeResult;
|
|
104
|
+
admit(request: {
|
|
105
|
+
host: string;
|
|
106
|
+
origin?: string | null;
|
|
107
|
+
cookie?: string | null;
|
|
108
|
+
csrfToken?: string | null;
|
|
109
|
+
requestId?: string | null;
|
|
110
|
+
mutation?: boolean;
|
|
111
|
+
}): LocalControlAdmissionResult;
|
|
112
|
+
revoke(cookieHeaderOrValue: string | null): void;
|
|
113
|
+
revokeAllSessions(): void;
|
|
114
|
+
close(): void;
|
|
115
|
+
dispose(): void;
|
|
116
|
+
private revokeAll;
|
|
117
|
+
private revokeRecord;
|
|
118
|
+
}
|
|
119
|
+
export declare function createLocalControl(options: LocalControlOptions): LocalControlManager;
|
|
120
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import type { OwnerControlCapability } from '../core/owner-control.js';
|
|
3
|
+
import type { OwnerDecisionController, OwnerDecisionInput } from '../core/owner-window.js';
|
|
4
|
+
import { type GuiControlRequestMeta } from './control-contract.js';
|
|
5
|
+
export declare const OWNER_CONTROL_COOKIE = "dsh_kingdom_owner";
|
|
6
|
+
export declare class OwnerTransportError extends Error {
|
|
7
|
+
readonly code: string;
|
|
8
|
+
readonly status: number;
|
|
9
|
+
constructor(code: string, message: string, status?: number);
|
|
10
|
+
}
|
|
11
|
+
export interface OwnerLocalControlOptions {
|
|
12
|
+
controller: OwnerDecisionController;
|
|
13
|
+
expectedOrigin: string | (() => string);
|
|
14
|
+
now?: () => number;
|
|
15
|
+
}
|
|
16
|
+
/** Transport references existing direct-human decisions; it never accepts an HTTP identity. */
|
|
17
|
+
export declare class OwnerLocalControlManager {
|
|
18
|
+
private readonly options;
|
|
19
|
+
private readonly tickets;
|
|
20
|
+
private readonly windows;
|
|
21
|
+
private readonly now;
|
|
22
|
+
private closed;
|
|
23
|
+
constructor(options: OwnerLocalControlOptions);
|
|
24
|
+
private origin;
|
|
25
|
+
checkTransport(meta: GuiControlRequestMeta, mutation?: boolean, navigation?: boolean): void;
|
|
26
|
+
activate(capability: OwnerControlCapability, input: OwnerDecisionInput): {
|
|
27
|
+
launchTicket: string;
|
|
28
|
+
launchPath: '/owner';
|
|
29
|
+
decisionId: string;
|
|
30
|
+
expiresAt: string;
|
|
31
|
+
ttlMs: number;
|
|
32
|
+
};
|
|
33
|
+
redeem(ticket: string, meta: GuiControlRequestMeta): {
|
|
34
|
+
cookie: string;
|
|
35
|
+
maxAgeSeconds: number;
|
|
36
|
+
};
|
|
37
|
+
private window;
|
|
38
|
+
inspect(cookie: string | null, meta: GuiControlRequestMeta): Promise<unknown>;
|
|
39
|
+
receipt(cookie: string | null, meta: GuiControlRequestMeta, operationId: string, decisionId: string | null): unknown;
|
|
40
|
+
mutate(cookie: string | null, csrf: string | null, requestId: string | null, meta: GuiControlRequestMeta, action: 'prepare' | 'commit' | 'revoke', payload: Record<string, unknown>): Promise<unknown>;
|
|
41
|
+
private invalidate;
|
|
42
|
+
dispose(): void;
|
|
43
|
+
}
|
|
44
|
+
/** Runs before the Role Plane bearer/admission routes. Neither cookie upgrades the other. */
|
|
45
|
+
export declare function handleOwnerRequest(req: IncomingMessage, res: ServerResponse, url: URL, manager: OwnerLocalControlManager | undefined): Promise<boolean>;
|
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
import type { CommandResultView, SnapshotView, TaskDetailView } from './contract.js';
|
|
2
2
|
import type { EventView } from './contract.js';
|
|
3
|
+
import { type OwnerLocalControlManager } from './owner-control.js';
|
|
4
|
+
import { GuiControlBroker, GuiControlExecutionContext, type GuiControlReadContext } from './control-contract.js';
|
|
3
5
|
export interface GuiServerHandlers {
|
|
4
|
-
snapshot(): SnapshotView;
|
|
5
|
-
taskDetail(taskId: string): TaskDetailView | null;
|
|
6
|
+
snapshot(readContext?: GuiControlReadContext): SnapshotView;
|
|
7
|
+
taskDetail(taskId: string, readContext?: GuiControlReadContext): TaskDetailView | null;
|
|
6
8
|
eventsSince(afterSeq: number, limit: number): {
|
|
7
9
|
revision: number;
|
|
8
10
|
events: EventView[];
|
|
9
11
|
};
|
|
10
|
-
command(name: string, payload: Record<string, unknown
|
|
12
|
+
command(name: string, payload: Record<string, unknown>, control?: GuiControlExecutionContext): Promise<CommandResultView>;
|
|
13
|
+
}
|
|
14
|
+
export interface GuiServerAddress {
|
|
15
|
+
host: string;
|
|
16
|
+
port: number;
|
|
17
|
+
origin: string;
|
|
11
18
|
}
|
|
12
19
|
export interface GuiServerOptions {
|
|
13
20
|
port: number;
|
|
14
21
|
host?: string;
|
|
15
22
|
token?: string;
|
|
16
23
|
allowOrigins?: string[];
|
|
24
|
+
control?: GuiControlBroker;
|
|
25
|
+
/** Independent direct-human decision transport; never upgrades Role cookies. */
|
|
26
|
+
ownerControl?: OwnerLocalControlManager;
|
|
27
|
+
onListening?(address: GuiServerAddress): void;
|
|
28
|
+
onUnavailable?(error: Error): void;
|
|
17
29
|
logger?: {
|
|
18
30
|
info(message: string): void;
|
|
19
31
|
warn(message: string): void;
|
|
20
32
|
};
|
|
21
33
|
}
|
|
34
|
+
/** v0.9 S2:四区只读 Console;数据只来自现有 GET projection seam。 */
|
|
35
|
+
export declare const READONLY_CONSOLE_HTML = "<!doctype html>\n<html lang=\"zh-CN\">\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <title>dsh-Kingdom Read-only Projection Console</title>\n <style>\n :root { color-scheme: dark; font-family: system-ui, sans-serif; background: #111827; color: #e5e7eb; }\n * { box-sizing: border-box; }\n body { margin: 0; min-width: 0; background: #111827; }\n main { width: min(100% - 24px, 1180px); margin: 0 auto; padding: 16px 0 28px; }\n h1, h2, p { margin: 0; }\n h1 { font-size: 1.35rem; margin-bottom: 12px; }\n h2 { font-size: 1rem; margin-bottom: 8px; }\n .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }\n section { min-width: 0; background: #1f2937; border: 1px solid #374151; border-radius: 10px; padding: 12px; overflow-wrap: anywhere; }\n .wide { grid-column: 1 / -1; }\n .muted { color: #9ca3af; font-size: .88rem; }\n .row { border-top: 1px solid #374151; padding: 8px 0; }\n .row:first-child { border-top: 0; padding-top: 0; }\n .tag { display: inline-block; color: #bfdbfe; font-size: .76rem; margin-right: 6px; }\n .attention { color: #fbbf24; }\n .critical { color: #fca5a5; }\n @media (max-width: 640px) {\n main { width: min(100% - 16px, 1180px); padding-top: 10px; }\n .grid { grid-template-columns: minmax(0, 1fr); }\n .wide { grid-column: auto; }\n section { padding: 10px; }\n }\n </style>\n</head>\n<body>\n <main>\n <h1>Read-only Projection Console</h1>\n <p class=\"muted\">Owner-only actions: DIRECT_SLASH_REQUIRED</p>\n <p id=\"status\" class=\"muted\">\u6B63\u5728\u8BFB\u53D6\u53EA\u8BFB Projection\u2026</p>\n <div class=\"grid\">\n <section id=\"overview\" aria-labelledby=\"overview-title\"><h2 id=\"overview-title\">\u72B6\u6001\u603B\u89C8</h2><div class=\"content\"></div></section>\n <section id=\"task-detail\" aria-labelledby=\"task-title\"><h2 id=\"task-title\">Task Detail</h2><div class=\"content\"></div></section>\n <section id=\"timeline\" class=\"wide\" aria-labelledby=\"timeline-title\"><h2 id=\"timeline-title\">Timeline</h2><div class=\"content\"></div></section>\n <section id=\"attention\" class=\"wide\" aria-labelledby=\"attention-title\"><h2 id=\"attention-title\">Attention</h2><div class=\"content\"></div></section>\n </div>\n </main>\n <script>\n (() => {\n const text = value => String(value ?? 'UNKNOWN');\n const line = (parent, label, value, className = '') => {\n const item = document.createElement('div');\n item.className = 'row ' + className;\n const tag = document.createElement('span');\n tag.className = 'tag';\n tag.textContent = label;\n const body = document.createElement('span');\n body.textContent = text(value);\n item.append(tag, body);\n parent.append(item);\n };\n const clear = id => {\n const content = document.querySelector('#' + id + ' .content');\n content.replaceChildren();\n return content;\n };\n const renderSnapshot = (snapshot, detail) => {\n const projection = snapshot.projection || {};\n const overview = projection.overview?.data || {};\n const overviewBox = clear('overview');\n line(overviewBox, 'Health', overview.health, overview.health === 'CRITICAL' ? 'critical' : '');\n line(overviewBox, 'Tasks', overview.taskCount);\n line(overviewBox, 'Active Execution', overview.activeExecutionCount);\n for (const action of overview.ownerActions || []) {\n line(overviewBox, 'Owner action', text(action.action) + ' \u2014 ' + text(action.disabledReason?.code), 'attention');\n }\n const taskBox = clear('task-detail');\n const task = snapshot.tasks?.[0];\n if (!task) line(taskBox, 'State', 'UNKNOWN \u2014 no task detail available');\n else {\n line(taskBox, 'Task status', text(task.status) + ' [GOVERNANCE_FACT]');\n line(taskBox, 'Claim', text(task.latestClaim?.claimedOutcome) + ' [WORKER_CLAIM]');\n line(taskBox, 'Execution', text(task.latestExecution?.state) + ' [RUNTIME_OBSERVATION]');\n line(taskBox, 'Actions', (detail?.projection?.data?.actionAvailability || []).map(a => text(a.action) + ': ' + text(a.disabledReason?.code || 'EXECUTABLE')).join('; ') || 'NONE');\n }\n const timelineBox = clear('timeline');\n for (const item of projection.timeline?.data || []) line(timelineBox, text(item.kind), item.summary);\n if (!(projection.timeline?.data || []).length) line(timelineBox, 'Timeline', 'UNKNOWN / NOT_RUN');\n const attentionBox = clear('attention');\n for (const item of projection.attention?.data || []) line(attentionBox, text(item.severity), text(item.reason?.code) + ' \u2014 ' + text(item.summary), item.severity.toLowerCase());\n if (!(projection.attention?.data || []).length) line(attentionBox, 'Attention', 'NONE');\n };\n const load = async () => {\n try {\n const response = await fetch('/api/snapshot', { headers: { Accept: 'application/json' } });\n if (!response.ok) throw new Error('snapshot HTTP ' + response.status);\n const snapshot = await response.json();\n let detail = null;\n const task = snapshot.tasks?.[0];\n if (task?.taskId) {\n const detailResponse = await fetch('/api/tasks/' + encodeURIComponent(task.taskId), { headers: { Accept: 'application/json' } });\n if (detailResponse.ok) detail = await detailResponse.json();\n }\n renderSnapshot(snapshot, detail);\n document.querySelector('#status').textContent = '\u53EA\u8BFB Projection \u5DF2\u52A0\u8F7D\uFF1BConsole \u4E0D\u6267\u884C\u5199\u52A8\u4F5C\u3002';\n } catch (error) {\n document.querySelector('#status').textContent = 'UNKNOWN \u2014 ' + text(error?.message || error);\n }\n };\n void load();\n })();\n </script>\n</body>\n</html>";
|
|
22
36
|
/**
|
|
23
37
|
* 启动本地 GUI 通道。
|
|
24
38
|
* @returns 关闭函数(挂到 ctx.effect,插件卸载/热重载时自动收回端口)。
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
* dsh-kingdom — DB 行 → GUI 视图的投影(Phase 3)。
|
|
3
|
-
*
|
|
4
|
-
* 全部是**纯函数**:给定 (库状态, now) 就唯一确定输出。
|
|
5
|
-
* 因此 GUI 轮询即可拿到正确的表演状态,服务端不需要任何定时器或推送状态机。
|
|
6
|
-
*
|
|
7
|
-
* 再次强调边界:本文件只产出 `{ role, state, activity }` 这类语义,
|
|
8
|
-
* 绝不产出贴图、clip、场景文件名——那些是 GUI 的 visual-map 的事。
|
|
9
|
-
*/
|
|
10
|
-
import type { AllowedAction, BindingView, ClaimView, EventView, ExecutionView, RuntimeGovernanceView, StageActorView, TaskDetailView, TaskView, TerritoryView, SnapshotView, AuthView } from './contract.js';
|
|
1
|
+
import type { AllowedAction, ActionAvailability, AttentionItem, BindingView, ClaimView, EventView, ExecutionView, ProjectionEnvelope, ProjectionSecurityContext, ReadonlySnapshotProjection, RuntimeGovernanceView, SourceRef, StageActorView, TaskProjectionData, TaskDetailView, TaskView, TerritoryView, SnapshotView, TimelineItem, AuthView, WorkbenchCostRuntime } from './contract.js';
|
|
11
2
|
import { type EventRow, type ExecutionRow, type KingdomStore, type RoleBindingRow, type TaskRow, type TerritoryRow, type WorkerResultRow } from '../core/db.js';
|
|
3
|
+
/** 对外暴露前统一限制数量与标识格式;不接受 session/raw payload/path 作为引用。 */
|
|
4
|
+
export declare function boundedSourceRefs(refs: SourceRef[]): SourceRef[];
|
|
5
|
+
/** 只返回生命周期候选的可执行性,不执行 action,也不改变任何状态。 */
|
|
6
|
+
export declare function buildActionAvailability(store: KingdomStore, task: TaskRow, execution: ExecutionRow | null, security?: ProjectionSecurityContext): ActionAvailability[];
|
|
12
7
|
export declare function toEventView(row: EventRow): EventView;
|
|
13
8
|
export declare function toBindingView(row: RoleBindingRow): BindingView;
|
|
14
9
|
export declare function toTerritoryView(row: TerritoryRow): TerritoryView;
|
|
@@ -28,6 +23,7 @@ export declare function allowedActionsFor(task: TaskRow, execution: ExecutionRow
|
|
|
28
23
|
export declare function toTaskView(store: KingdomStore, task: TaskRow): TaskView;
|
|
29
24
|
interface StageInput {
|
|
30
25
|
bindings: RoleBindingRow[];
|
|
26
|
+
territories: TerritoryRow[];
|
|
31
27
|
tasks: TaskRow[];
|
|
32
28
|
executions: ExecutionRow[];
|
|
33
29
|
events: EventRow[];
|
|
@@ -36,13 +32,39 @@ interface StageInput {
|
|
|
36
32
|
}
|
|
37
33
|
/** 计算全部角色此刻的表演语义。 */
|
|
38
34
|
export declare function projectStage(input: StageInput): StageActorView[];
|
|
35
|
+
/** 固定 reason code 的 Attention 派生;只读,不修复、不重试、不推进状态。 */
|
|
36
|
+
export declare function buildAttention(store: KingdomStore, kingdomId: string): AttentionItem[];
|
|
37
|
+
/** 从现有 row/event/observation 重建 timeline;不是新 Ledger。 */
|
|
38
|
+
export declare function buildTimeline(store: KingdomStore, kingdomId: string, options?: {
|
|
39
|
+
eventLimit?: number;
|
|
40
|
+
security?: ProjectionSecurityContext;
|
|
41
|
+
}): TimelineItem[];
|
|
42
|
+
/** Task Detail 的只读派生 Envelope;保留旧 TaskDetailView 字段,不复刻状态机。 */
|
|
43
|
+
export declare function buildTaskProjection(store: KingdomStore, kingdomId: string, task: TaskRow, options?: {
|
|
44
|
+
nowMs?: number;
|
|
45
|
+
security?: ProjectionSecurityContext;
|
|
46
|
+
}): ProjectionEnvelope<TaskProjectionData>;
|
|
47
|
+
export interface ReadonlyProjectionOptions {
|
|
48
|
+
eventLimit?: number;
|
|
49
|
+
nowMs?: number;
|
|
50
|
+
security?: ProjectionSecurityContext;
|
|
51
|
+
costRuntime?: WorkbenchCostRuntime;
|
|
52
|
+
}
|
|
53
|
+
/** S1 顶层只读 Projection;没有 kingdom 时显式返回 UNKNOWN/空数据。 */
|
|
54
|
+
export declare function buildReadonlySnapshotProjection(store: KingdomStore, kingdomId: string | null, options?: ReadonlyProjectionOptions): ReadonlySnapshotProjection;
|
|
39
55
|
export interface SnapshotOptions {
|
|
40
56
|
auth: AuthView;
|
|
41
57
|
eventLimit?: number;
|
|
42
58
|
transientWindowMs?: number;
|
|
43
59
|
/** 注入的"现在",仅供测试确定性使用。 */
|
|
44
60
|
nowMs?: number;
|
|
61
|
+
/** 缺少完整主体/scope/Host context 时 action 保持 fail-closed。 */
|
|
62
|
+
security?: ProjectionSecurityContext;
|
|
63
|
+
costRuntime?: WorkbenchCostRuntime;
|
|
45
64
|
}
|
|
46
65
|
export declare function buildSnapshot(store: KingdomStore, options: SnapshotOptions): SnapshotView;
|
|
47
|
-
export declare function buildTaskDetail(store: KingdomStore, kingdomId: string, taskId: string
|
|
66
|
+
export declare function buildTaskDetail(store: KingdomStore, kingdomId: string, taskId: string, options?: {
|
|
67
|
+
nowMs?: number;
|
|
68
|
+
security?: ProjectionSecurityContext;
|
|
69
|
+
}): TaskDetailView | null;
|
|
48
70
|
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Decorative icons must be paired with visible text or an accessible control name. */
|
|
2
|
+
export declare const GUI_ICONS: Readonly<{
|
|
3
|
+
map: string;
|
|
4
|
+
management: string;
|
|
5
|
+
ledger: string;
|
|
6
|
+
refresh: string;
|
|
7
|
+
chancellor: string;
|
|
8
|
+
supervisor: string;
|
|
9
|
+
worker: string;
|
|
10
|
+
plan: string;
|
|
11
|
+
assign: string;
|
|
12
|
+
next: string;
|
|
13
|
+
run: string;
|
|
14
|
+
review: string;
|
|
15
|
+
accept: string;
|
|
16
|
+
lock: string;
|
|
17
|
+
error: string;
|
|
18
|
+
idle: string;
|
|
19
|
+
unknown: string;
|
|
20
|
+
empty: string;
|
|
21
|
+
}>;
|
|
22
|
+
/** Original gate-and-organization brand mark; the adjacent wordmark supplies its name. */
|
|
23
|
+
export declare const KINGDOM_BRAND_SVG = "<svg class=\"kingdom-brand-mark\" xmlns=\"http://www.w3.org/2000/svg\" width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"M9 31V12h6v5h6v-5h6v5h6v-5h6v19H9Z\" />\n <path d=\"M19 31v-7a5 5 0 0 1 10 0v7M24 31v5M12 36h24M12 36v3M36 36v3\" />\n <circle cx=\"12\" cy=\"41\" r=\"2\" /><circle cx=\"24\" cy=\"38\" r=\"2\" /><circle cx=\"36\" cy=\"41\" r=\"2\" />\n</svg>";
|
|
24
|
+
/** Original decorative empty state. It deliberately contains no role or binding claims. */
|
|
25
|
+
export declare const EMPTY_STATE_SVG = "<svg class=\"empty-state-art\" xmlns=\"http://www.w3.org/2000/svg\" width=\"240\" height=\"128\" viewBox=\"0 0 240 128\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"M84 67V27h12v9h16v-9h16v9h16v-9h12v40H84Z\" />\n <path d=\"M109 67V53a11 11 0 0 1 22 0v14M76 67h88\" />\n <path d=\"M120 74v10M62 84h116M62 84v12M120 84v12M178 84v12\" stroke-dasharray=\"4 5\" opacity=\".55\" />\n <rect x=\"43\" y=\"96\" width=\"38\" height=\"20\" rx=\"6\" stroke-dasharray=\"4 5\" opacity=\".65\" />\n <rect x=\"101\" y=\"96\" width=\"38\" height=\"20\" rx=\"6\" stroke-dasharray=\"4 5\" opacity=\".65\" />\n <rect x=\"159\" y=\"96\" width=\"38\" height=\"20\" rx=\"6\" stroke-dasharray=\"4 5\" opacity=\".65\" />\n</svg>";
|
|
26
|
+
/** Static governance guidance, never a projection of current task progress. */
|
|
27
|
+
export declare const GOVERNANCE_FLOW_HTML: string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Personal workbench presentation. No model calls or authority are created here. */
|
|
2
|
+
export declare const WORKBENCH_CSS: string;
|
|
3
|
+
export declare const WORKBENCH_HTML: string;
|
|
4
|
+
/** Injected into the existing console closure; all Host text uses append/textContent. */
|
|
5
|
+
export declare const WORKBENCH_SCRIPT: string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ActionAvailability, ExecutionView, PersonalWorkbenchData, RuntimeGovernanceView, SupervisorDecisionView, TaskView, WorkbenchUsageSummary, WorkbenchCostSummary, WorkbenchCollaborationView } from './contract.js';
|
|
2
|
+
export declare const WORKBENCH_ITEM_LIMIT = 40;
|
|
3
|
+
/** All inputs are public projections. This module has no Store, command or model access. */
|
|
4
|
+
export interface PersonalWorkbenchInput {
|
|
5
|
+
kingdomPresent: boolean;
|
|
6
|
+
bindings: {
|
|
7
|
+
bindingId: string;
|
|
8
|
+
roleType: string;
|
|
9
|
+
roleName: string;
|
|
10
|
+
status: string;
|
|
11
|
+
sessionBound: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
territories: {
|
|
14
|
+
territoryId: string;
|
|
15
|
+
name: string;
|
|
16
|
+
status: string;
|
|
17
|
+
supervisorBindingId: string | null;
|
|
18
|
+
}[];
|
|
19
|
+
tasks: {
|
|
20
|
+
task: Pick<TaskView, 'taskId' | 'territoryId' | 'title' | 'status' | 'assignedBindingId' | 'latestClaim' | 'latestExecution' | 'updatedAt'>;
|
|
21
|
+
actionAvailability: ActionAvailability[];
|
|
22
|
+
latestReview: SupervisorDecisionView | null;
|
|
23
|
+
claimExecutionMismatch: boolean;
|
|
24
|
+
}[];
|
|
25
|
+
executions: Pick<ExecutionView, 'executionId' | 'taskId' | 'workerBindingId' | 'state'>[];
|
|
26
|
+
governance: RuntimeGovernanceView;
|
|
27
|
+
cost?: WorkbenchCostSummary;
|
|
28
|
+
collaboration?: WorkbenchCollaborationView;
|
|
29
|
+
}
|
|
30
|
+
/** Sum only provider reports whose identity and numeric shape match this Dispatch. */
|
|
31
|
+
export declare function buildWorkbenchUsage(input: Pick<PersonalWorkbenchInput, 'governance' | 'executions'>): WorkbenchUsageSummary;
|
|
32
|
+
/** Derive current work; past DENIED and ordinary in-flight receipts are not current incidents. */
|
|
33
|
+
export declare function buildPersonalWorkbench(input: PersonalWorkbenchInput): PersonalWorkbenchData;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
* kingdom_list_bindings
|
|
14
14
|
*
|
|
15
15
|
* Phase 2 能力(Worker Claim Bridge → 治理闭环):
|
|
16
|
-
* - 工具:kingdom_plan_task / kingdom_assign_task /
|
|
17
|
-
* kingdom_review_task / kingdom_list_tasks
|
|
18
|
-
* -
|
|
16
|
+
* - 工具:kingdom_plan_task / kingdom_assign_task /
|
|
17
|
+
* kingdom_start_task_governed / kingdom_review_task / kingdom_list_tasks
|
|
18
|
+
* - `kingdom_start_task` 仅保留为显式选择的 LEGACY_COMPAT one-shot 兼容入口;
|
|
19
|
+
* 正常 headless 执行必须走 governed persistent 路径。
|
|
19
20
|
*
|
|
20
21
|
* 治理底线(Phase 1 保持 + Phase 2 强化):
|
|
21
22
|
* - **无任何工具能把 Task 直接标 DONE**:DONE 唯一入口是 REVIEW + Supervisor ACCEPT。
|
|
@@ -24,9 +25,15 @@
|
|
|
24
25
|
*/
|
|
25
26
|
import type { Context } from '@deepseek-ai/cordis';
|
|
26
27
|
import z from '@deepseek-ai/schemastery';
|
|
28
|
+
import { type ToolDisclosureConfig } from './capability/tool-disclosure.js';
|
|
29
|
+
import { type AdminAuth, type ExecutionProfileV1 } from './core/binding.js';
|
|
30
|
+
import type { KingdomStore, RoleBindingRow, TerritoryRow } from './core/db.js';
|
|
31
|
+
import type { CommandResult } from '@deepseek-ai/dsh-commands';
|
|
32
|
+
import { type TargetSessionClassification } from './core/owner-binding-intent.js';
|
|
27
33
|
export declare const name = "dsh-kingdom";
|
|
28
34
|
export declare const inject: string[];
|
|
29
35
|
export interface Config {
|
|
36
|
+
toolDisclosure?: ToolDisclosureConfig;
|
|
30
37
|
kingdomName: string;
|
|
31
38
|
ownerName: string;
|
|
32
39
|
workerProvider: string;
|
|
@@ -37,7 +44,102 @@ export interface Config {
|
|
|
37
44
|
/** v0.8(M3-S2 v6):允许对已有 v3 库执行 Schema v4 迁移(Formal DB Migration Gate 用)。 */
|
|
38
45
|
migrateV4: boolean;
|
|
39
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Process-local seams for deterministic integration verification. Normal
|
|
49
|
+
* Cordis/DSH loading uses the two-argument apply(ctx, config) path. These
|
|
50
|
+
* functions are not Config, HTTP, GUI payload, or persisted-state inputs.
|
|
51
|
+
*/
|
|
52
|
+
export interface ApplyDependencies {
|
|
53
|
+
governedPolling?: {
|
|
54
|
+
intervalMs: number;
|
|
55
|
+
maxPolls: number;
|
|
56
|
+
};
|
|
57
|
+
openLocalConsole?: (url: string) => boolean;
|
|
58
|
+
loadS4Policy?: () => Promise<{
|
|
59
|
+
sandboxPolicy: {
|
|
60
|
+
setSandboxMode(session: unknown, mode: string): void;
|
|
61
|
+
} | null;
|
|
62
|
+
approval: {
|
|
63
|
+
setApprovalPolicy(session: unknown, policy: string): void;
|
|
64
|
+
} | null;
|
|
65
|
+
}>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The public DSH runtime seam used by the Owner-binding boundary. Keep this
|
|
69
|
+
* local duck type instead of importing a concrete registry implementation: the
|
|
70
|
+
* plugin is loaded against a host-provided bundle, while the identity checks
|
|
71
|
+
* below intentionally depend only on the documented methods and object
|
|
72
|
+
* identity.
|
|
73
|
+
*/
|
|
74
|
+
export interface KingdomDshAgentLike {
|
|
75
|
+
readonly id?: unknown;
|
|
76
|
+
readonly session?: unknown;
|
|
77
|
+
readonly status?: unknown;
|
|
78
|
+
}
|
|
79
|
+
export interface KingdomDshAgentRegistryLike {
|
|
80
|
+
currentInitiator?: () => unknown;
|
|
81
|
+
get?: (id: string) => unknown;
|
|
82
|
+
list?: () => readonly unknown[];
|
|
83
|
+
}
|
|
84
|
+
export interface KingdomDshSessionRegistryLike {
|
|
85
|
+
get?: (id: string) => unknown;
|
|
86
|
+
}
|
|
87
|
+
export interface KingdomDshRegistrySeam {
|
|
88
|
+
agents?: KingdomDshAgentRegistryLike | null;
|
|
89
|
+
sessions?: KingdomDshSessionRegistryLike | null;
|
|
90
|
+
}
|
|
91
|
+
export interface KingdomToolExecutionLike {
|
|
92
|
+
readonly agent?: unknown;
|
|
93
|
+
readonly signal?: {
|
|
94
|
+
readonly aborted?: boolean;
|
|
95
|
+
} | null;
|
|
96
|
+
}
|
|
97
|
+
export type TrustedToolSessionResolution = {
|
|
98
|
+
readonly classification: 'ACTIVE';
|
|
99
|
+
readonly sessionId: string;
|
|
100
|
+
readonly agent: KingdomDshAgentLike;
|
|
101
|
+
readonly session: {
|
|
102
|
+
readonly id?: unknown;
|
|
103
|
+
};
|
|
104
|
+
} | {
|
|
105
|
+
readonly classification: Exclude<TargetSessionClassification, 'ACTIVE'>;
|
|
106
|
+
readonly sessionId: string | null;
|
|
107
|
+
readonly reason: string;
|
|
108
|
+
};
|
|
109
|
+
export type LiveDirectSessionResolution = {
|
|
110
|
+
readonly ok: true;
|
|
111
|
+
readonly sessionId: string;
|
|
112
|
+
readonly agent: KingdomDshAgentLike;
|
|
113
|
+
readonly session: {
|
|
114
|
+
readonly id?: unknown;
|
|
115
|
+
};
|
|
116
|
+
} | {
|
|
117
|
+
readonly ok: false;
|
|
118
|
+
readonly classification: Exclude<TargetSessionClassification, 'ACTIVE'>;
|
|
119
|
+
readonly reason: string;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Resolve the exact DSH Tool caller. A non-empty session id is only a target
|
|
123
|
+
* reference; it becomes an ACTIVE Principal after every public identity/life
|
|
124
|
+
* check succeeds. In particular, tool arguments are not accepted here.
|
|
125
|
+
*/
|
|
126
|
+
export declare function resolveTrustedToolSession(execution: KingdomToolExecutionLike | null | undefined, seam: KingdomDshRegistrySeam): TrustedToolSessionResolution;
|
|
127
|
+
/** Validate a direct Owner Slash target without requiring current-initiator scope. */
|
|
128
|
+
export declare function validateLiveDirectSession(sessionId: string, seam: KingdomDshRegistrySeam): LiveDirectSessionResolution;
|
|
40
129
|
export declare const Config: z<Schemastery.ObjectS<{
|
|
130
|
+
toolDisclosure: z<Schemastery.ObjectS<{
|
|
131
|
+
mode: z<"off" | "pilot", "off" | "pilot">;
|
|
132
|
+
residentTools: z<string[], string[]>;
|
|
133
|
+
phaseTools: z<string[], string[]>;
|
|
134
|
+
maxResults: z<number, number>;
|
|
135
|
+
maxResultBytes: z<number, number>;
|
|
136
|
+
}>, Schemastery.ObjectT<{
|
|
137
|
+
mode: z<"off" | "pilot", "off" | "pilot">;
|
|
138
|
+
residentTools: z<string[], string[]>;
|
|
139
|
+
phaseTools: z<string[], string[]>;
|
|
140
|
+
maxResults: z<number, number>;
|
|
141
|
+
maxResultBytes: z<number, number>;
|
|
142
|
+
}>>;
|
|
41
143
|
kingdomName: z<string, string>;
|
|
42
144
|
ownerName: z<string, string>;
|
|
43
145
|
/** Worker 执行用的 subagent provider(dsh base bundle 默认注册 spawn / fork)。 */
|
|
@@ -47,7 +149,7 @@ export declare const Config: z<Schemastery.ObjectS<{
|
|
|
47
149
|
* 设为非零值即启用,只绑定 127.0.0.1。
|
|
48
150
|
*/
|
|
49
151
|
guiPort: z<number, number>;
|
|
50
|
-
/** 可选 bearer
|
|
152
|
+
/** Role GUI 可选 bearer;独立 Owner 路由使用其直接激活的短期凭据,不升级 Role 权限。 */
|
|
51
153
|
guiToken: z<string, string>;
|
|
52
154
|
/** CORS 允许的 Origin 列表;默认放开(服务只绑本机回环)。 */
|
|
53
155
|
guiAllowOrigins: z<string[], string[]>;
|
|
@@ -65,6 +167,19 @@ export declare const Config: z<Schemastery.ObjectS<{
|
|
|
65
167
|
*/
|
|
66
168
|
migrateV4: z<boolean, boolean>;
|
|
67
169
|
}>, Schemastery.ObjectT<{
|
|
170
|
+
toolDisclosure: z<Schemastery.ObjectS<{
|
|
171
|
+
mode: z<"off" | "pilot", "off" | "pilot">;
|
|
172
|
+
residentTools: z<string[], string[]>;
|
|
173
|
+
phaseTools: z<string[], string[]>;
|
|
174
|
+
maxResults: z<number, number>;
|
|
175
|
+
maxResultBytes: z<number, number>;
|
|
176
|
+
}>, Schemastery.ObjectT<{
|
|
177
|
+
mode: z<"off" | "pilot", "off" | "pilot">;
|
|
178
|
+
residentTools: z<string[], string[]>;
|
|
179
|
+
phaseTools: z<string[], string[]>;
|
|
180
|
+
maxResults: z<number, number>;
|
|
181
|
+
maxResultBytes: z<number, number>;
|
|
182
|
+
}>>;
|
|
68
183
|
kingdomName: z<string, string>;
|
|
69
184
|
ownerName: z<string, string>;
|
|
70
185
|
/** Worker 执行用的 subagent provider(dsh base bundle 默认注册 spawn / fork)。 */
|
|
@@ -74,7 +189,7 @@ export declare const Config: z<Schemastery.ObjectS<{
|
|
|
74
189
|
* 设为非零值即启用,只绑定 127.0.0.1。
|
|
75
190
|
*/
|
|
76
191
|
guiPort: z<number, number>;
|
|
77
|
-
/** 可选 bearer
|
|
192
|
+
/** Role GUI 可选 bearer;独立 Owner 路由使用其直接激活的短期凭据,不升级 Role 权限。 */
|
|
78
193
|
guiToken: z<string, string>;
|
|
79
194
|
/** CORS 允许的 Origin 列表;默认放开(服务只绑本机回环)。 */
|
|
80
195
|
guiAllowOrigins: z<string[], string[]>;
|
|
@@ -92,4 +207,40 @@ export declare const Config: z<Schemastery.ObjectS<{
|
|
|
92
207
|
*/
|
|
93
208
|
migrateV4: z<boolean, boolean>;
|
|
94
209
|
}>>;
|
|
95
|
-
|
|
210
|
+
/** Smallest capability fact used by the GUI thin slice's governed path. */
|
|
211
|
+
export declare const MINIMAL_CAPABILITY_JSON = "{\"tool:pwsh\":true}";
|
|
212
|
+
export { connectRunnerContextBroker, createRunnerContextBrokerLaunch, createRunnerContextBrokerProductLifecycle, } from './runner-context-broker.js';
|
|
213
|
+
export type { RunnerContextBrokerClient, RunnerContextBrokerCleanupReceipt, RunnerContextBrokerConnectionBootstrap, RunnerContextBrokerConnectorInput, RunnerContextBrokerDescriptor, RunnerContextBrokerEnvironment, RunnerContextBrokerProductLifecycle, } from './runner-context-broker.js';
|
|
214
|
+
/**
|
|
215
|
+
* Format the direct GUI activation result without accepting any launch secret
|
|
216
|
+
* as presentation data. The ticket is handed only to the local URL opener;
|
|
217
|
+
* command/done persistence, logger output, and domain events receive this
|
|
218
|
+
* clean result instead.
|
|
219
|
+
*/
|
|
220
|
+
export declare function formatGuiLaunchCommandResult(origin: string, expiresAt: string, browserOpened: boolean): CommandResult;
|
|
221
|
+
/** Reuse an ACTIVE same-name Territory without changing its topology. */
|
|
222
|
+
export declare function ensureGuiSetupTerritory(store: KingdomStore, input: {
|
|
223
|
+
kingdomId: string;
|
|
224
|
+
name: string;
|
|
225
|
+
workspacePath?: string | null;
|
|
226
|
+
}, auth: AdminAuth): TerritoryRow;
|
|
227
|
+
/** Ensure setup role identity without ever binding a Worker to the activator. */
|
|
228
|
+
export declare function ensureGuiSetupBinding(store: KingdomStore, input: {
|
|
229
|
+
kingdomId: string;
|
|
230
|
+
roleType: 'CHANCELLOR' | 'SUPERVISOR' | 'WORKER';
|
|
231
|
+
roleName: string;
|
|
232
|
+
sessionId: string | null;
|
|
233
|
+
}, auth: AdminAuth): RoleBindingRow;
|
|
234
|
+
/** Set the requested Worker profile only when its semantic value changes. */
|
|
235
|
+
export declare function ensureGuiSetupExecutionProfile(store: KingdomStore, input: {
|
|
236
|
+
kingdomId: string;
|
|
237
|
+
bindingId: string;
|
|
238
|
+
profile: ExecutionProfileV1;
|
|
239
|
+
}, auth: AdminAuth): string | null;
|
|
240
|
+
/** Set Territory scope only when the target Supervisor binding changes. */
|
|
241
|
+
export declare function ensureGuiSetupTerritorySupervisor(store: KingdomStore, input: {
|
|
242
|
+
kingdomId: string;
|
|
243
|
+
territoryId: string;
|
|
244
|
+
supervisorBindingId: string;
|
|
245
|
+
}, auth: AdminAuth): string | null;
|
|
246
|
+
export declare function apply(ctx: Context, config: Config, dependencies?: ApplyDependencies): void;
|