@sparkelf/dsh-dataops-managed 0.3.20 → 0.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/lib/client.js +3996 -267
- package/lib/client.js.map +1 -1
- package/lib/index.js +2355 -181
- package/lib/types/api-docs.d.ts +80 -0
- package/lib/types/auth-state.d.ts +50 -0
- package/lib/types/client/NotificationBell.d.ts +19 -0
- package/lib/types/client/PermissionCenterIcon.d.ts +9 -0
- package/lib/types/client/PermissionCenterSection.d.ts +15 -0
- package/lib/types/client/ReloginPrompt.d.ts +27 -0
- package/lib/types/client/ReviewSettingsCard.d.ts +12 -0
- package/lib/types/client/SkillPlazaSection.d.ts +3 -5
- package/lib/types/client/WanxiangBrand.d.ts +7 -1
- package/lib/types/client/WorkspaceUpgradePrompt.d.ts +21 -0
- package/lib/types/client/combobox.d.ts +17 -0
- package/lib/types/client/index.d.ts +17 -2
- package/lib/types/client/locales.d.ts +109 -6
- package/lib/types/client/review-client.d.ts +155 -0
- package/lib/types/client/review-demo.d.ts +13 -0
- package/lib/types/client/review-notification-store.d.ts +23 -0
- package/lib/types/client/review-types.d.ts +114 -0
- package/lib/types/client/settings-gate.d.ts +21 -0
- package/lib/types/client/skill-plaza-client.d.ts +21 -0
- package/lib/types/client/workspace-upgrade-client.d.ts +29 -0
- package/lib/types/connector-state.d.ts +51 -0
- package/lib/types/index.d.ts +36 -0
- package/lib/types/review-api.d.ts +32 -0
- package/lib/types/skill-plaza.d.ts +31 -0
- package/lib/types/tool-manager.d.ts +81 -0
- package/lib/types/tool-output.d.ts +25 -0
- package/lib/types/tool-scope.d.ts +156 -0
- package/lib/types/tools.d.ts +41 -0
- package/lib/types/workspace-upgrade-state.d.ts +66 -0
- package/lib/types/workspace-upgrade.d.ts +83 -0
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model tools for the skill centre, the shared review queues, and the DataOps API reference.
|
|
3
|
+
*
|
|
4
|
+
* Registration is disclosure, not authorization. `AiToolManager` computes the workspace's
|
|
5
|
+
* current DataOps scope once per credential/role sync and registers only the tools that scope
|
|
6
|
+
* can use; these definitions assume they were registered for a principal that may call them.
|
|
7
|
+
* Every `execute` therefore validates parameters, asks for user approval where a mutation needs
|
|
8
|
+
* it, writes its audit line, and lets DataOps answer — no per-call role read, no local permission
|
|
9
|
+
* tree, and no replacement for the backend's AuthGuard/PermissionGuard.
|
|
10
|
+
*
|
|
11
|
+
* The skill plaza is the catalogue. `scope=mine` exposes the caller's pending/rejected rows,
|
|
12
|
+
* the public list exposes what the caller may install, and the admin list (administrators only)
|
|
13
|
+
* exposes disabled entries. Installation, sharing and deletion are deliberately three different
|
|
14
|
+
* actions: uninstall removes only the caller's installation, unshare unpublishes the shared entry
|
|
15
|
+
* (with an unpublished notification), and delete permanently removes the entry after a second
|
|
16
|
+
* confirmation, with its own deleted notification and audit trail.
|
|
17
|
+
*
|
|
18
|
+
* @module tools
|
|
19
|
+
*/
|
|
20
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
21
|
+
import { type ToolDefinition } from '@deepseek-ai/dsh-tools';
|
|
22
|
+
import type { ReviewApi } from './review-api.ts';
|
|
23
|
+
import { type AiToolName, type DataOpsScope } from './tool-scope.ts';
|
|
24
|
+
/** One managed tool together with the name the disclosure map uses. */
|
|
25
|
+
export interface AiManagedTool {
|
|
26
|
+
name: AiToolName;
|
|
27
|
+
definition: ToolDefinition;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Build every managed tool definition.
|
|
31
|
+
*
|
|
32
|
+
* The definitions are built once; `readScope` is a live getter so a tool that survives a role
|
|
33
|
+
* change reports the scope the manager currently holds instead of the one it was registered
|
|
34
|
+
* with. An undefined scope can only be observed by an in-flight call during disposal, where the
|
|
35
|
+
* safe behavior is to show only the public catalogue.
|
|
36
|
+
* @param ctx - Host context used for local skills, approval and audit.
|
|
37
|
+
* @param reviewApi - Same-origin bridge holding the workspace JWT.
|
|
38
|
+
* @param readScope - Live accessor for the manager's current scope.
|
|
39
|
+
* @returns One definition per managed tool name.
|
|
40
|
+
*/
|
|
41
|
+
export declare function buildAiManagementTools(ctx: Context, reviewApi: ReviewApi, readScope: () => DataOpsScope | undefined): AiManagedTool[];
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistent hand-off record for one workspace image upgrade.
|
|
3
|
+
*
|
|
4
|
+
* The DSH companion and the workspace container share the same named volume at
|
|
5
|
+
* `/workspace`; a JSON file there survives the container recreate that applies a new
|
|
6
|
+
* image. The record is deliberately small: only sessions that were running when the
|
|
7
|
+
* user confirmed the upgrade, so recovery cannot send "继续" to unrelated history.
|
|
8
|
+
*
|
|
9
|
+
* @module workspace-upgrade-state
|
|
10
|
+
*/
|
|
11
|
+
/** Format version of the persisted hand-off record. */
|
|
12
|
+
export declare const WORKSPACE_UPGRADE_STATE_VERSION = 1;
|
|
13
|
+
/** One DSH session that was running when the upgrade was confirmed. */
|
|
14
|
+
export interface WorkspaceUpgradeSession {
|
|
15
|
+
/** DSH session id, the id `agents.get` and `agents.resume` accept. */
|
|
16
|
+
sessionId: string;
|
|
17
|
+
/** Optional human-readable title captured for diagnostics. */
|
|
18
|
+
title?: string;
|
|
19
|
+
/** Optional workspace directory captured for diagnostics. */
|
|
20
|
+
cwd?: string;
|
|
21
|
+
}
|
|
22
|
+
/** The JSON document written before the container is recreated. */
|
|
23
|
+
export interface WorkspaceUpgradeState {
|
|
24
|
+
version: typeof WORKSPACE_UPGRADE_STATE_VERSION;
|
|
25
|
+
upgradeId: string;
|
|
26
|
+
targetImage: string;
|
|
27
|
+
sessions: WorkspaceUpgradeSession[];
|
|
28
|
+
createdAt: string;
|
|
29
|
+
}
|
|
30
|
+
/** Directory used by this plugin below the DSH home. */
|
|
31
|
+
export declare const WORKSPACE_UPGRADE_STATE_DIR = "dataops-managed";
|
|
32
|
+
/** Name of the hand-off file. */
|
|
33
|
+
export declare const WORKSPACE_UPGRADE_STATE_FILE = "workspace-upgrade.json";
|
|
34
|
+
/**
|
|
35
|
+
* Resolve the persistent DSH home used by this workspace.
|
|
36
|
+
*
|
|
37
|
+
* The companion currently starts with `DSH_HOME=/workspace/.dataops/dsh`; the fallback
|
|
38
|
+
* keeps tests and a manually launched host deterministic without reaching outside the
|
|
39
|
+
* mounted workspace.
|
|
40
|
+
* @param dshHome - override for tests.
|
|
41
|
+
* @returns the state directory path.
|
|
42
|
+
*/
|
|
43
|
+
export declare function workspaceUpgradeStatePath(dshHome?: string): string;
|
|
44
|
+
/** Validate a parsed state document. */
|
|
45
|
+
export declare function asWorkspaceUpgradeState(value: unknown): WorkspaceUpgradeState | null;
|
|
46
|
+
/**
|
|
47
|
+
* Read the pending hand-off record.
|
|
48
|
+
* @param file - state file path.
|
|
49
|
+
* @returns the record, or null when none exists or it cannot be parsed.
|
|
50
|
+
*/
|
|
51
|
+
export declare function readWorkspaceUpgradeState(file?: string): Promise<WorkspaceUpgradeState | null>;
|
|
52
|
+
/**
|
|
53
|
+
* Persist the hand-off record atomically.
|
|
54
|
+
*
|
|
55
|
+
* A partially written JSON file would be indistinguishable from "no upgrade pending",
|
|
56
|
+
* which would silently skip recovery. The temporary file is renamed into place only
|
|
57
|
+
* after the content is complete.
|
|
58
|
+
* @param state - record to persist.
|
|
59
|
+
* @param file - state file path.
|
|
60
|
+
*/
|
|
61
|
+
export declare function writeWorkspaceUpgradeState(state: WorkspaceUpgradeState, file?: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Remove the hand-off record after recovery has been attempted.
|
|
64
|
+
* @param file - state file path.
|
|
65
|
+
*/
|
|
66
|
+
export declare function clearWorkspaceUpgradeState(file?: string): Promise<void>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace image upgrade orchestration.
|
|
3
|
+
*
|
|
4
|
+
* DataOps owns the Docker image comparison and the container restart. This plugin owns
|
|
5
|
+
* the two facts DSH alone can know: which sessions are running right now, and how to
|
|
6
|
+
* bring those sessions back after the container has been recreated. A small JSON file
|
|
7
|
+
* on the shared workspace volume carries that hand-off across the restart.
|
|
8
|
+
*
|
|
9
|
+
* @module workspace-upgrade
|
|
10
|
+
*/
|
|
11
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
+
import { type WorkspaceUpgradeSession, type WorkspaceUpgradeState } from './workspace-upgrade-state.ts';
|
|
13
|
+
/** Configuration needed to talk to DataOps. */
|
|
14
|
+
export interface WorkspaceUpgradeConfig {
|
|
15
|
+
/** DataOps API origin reachable from the DSH Host. */
|
|
16
|
+
baseUrl: string;
|
|
17
|
+
/** Credential reference holding the current DataOps JWT. */
|
|
18
|
+
credentialRef: string;
|
|
19
|
+
}
|
|
20
|
+
/** The subset of the DataOps restart-preview response this plugin uses. */
|
|
21
|
+
export interface WorkspaceUpgradePreview {
|
|
22
|
+
imageStatus: 'CURRENT' | 'UPDATE_AVAILABLE' | 'NOT_RUNNING' | 'UNKNOWN';
|
|
23
|
+
configuredImage: string;
|
|
24
|
+
activeSessions: WorkspaceUpgradeSession[];
|
|
25
|
+
}
|
|
26
|
+
/** A refusal or transport failure from the DataOps API. */
|
|
27
|
+
export declare class WorkspaceUpgradeError extends Error {
|
|
28
|
+
/** HTTP status, or 502 when DataOps could not be reached. */
|
|
29
|
+
readonly status: number;
|
|
30
|
+
constructor(
|
|
31
|
+
/** HTTP status, or 502 when DataOps could not be reached. */
|
|
32
|
+
status: number, message: string);
|
|
33
|
+
}
|
|
34
|
+
/** Owns DataOps preview/restart calls and the DSH session hand-off. */
|
|
35
|
+
export declare class WorkspaceUpgrade {
|
|
36
|
+
private readonly ctx;
|
|
37
|
+
private readonly config;
|
|
38
|
+
readonly statePath: string;
|
|
39
|
+
constructor(ctx: Context, config: WorkspaceUpgradeConfig, statePath?: string);
|
|
40
|
+
/** Resolve the injected DSH agents service, if the profile provides one. */
|
|
41
|
+
private agents;
|
|
42
|
+
/** Read the current DataOps credential. */
|
|
43
|
+
private token;
|
|
44
|
+
/** DataOps origin used by this workspace. */
|
|
45
|
+
private apiBase;
|
|
46
|
+
/** Call one DataOps API path with the workspace JWT. */
|
|
47
|
+
private request;
|
|
48
|
+
/** Read the DataOps restart preview plus this host's running-session snapshot. */
|
|
49
|
+
preview(): Promise<WorkspaceUpgradePreview>;
|
|
50
|
+
/** Snapshot sessions that are executing a turn right now. */
|
|
51
|
+
private runningSessions;
|
|
52
|
+
/** Restart DataOps' workspace container; force is required when sessions are snapshot. */
|
|
53
|
+
private restart;
|
|
54
|
+
/**
|
|
55
|
+
* Persist the running-session snapshot and ask DataOps to recreate the container.
|
|
56
|
+
* @returns the accepted hand-off record.
|
|
57
|
+
*/
|
|
58
|
+
upgrade(): Promise<WorkspaceUpgradeState>;
|
|
59
|
+
/**
|
|
60
|
+
* Resume every snapshotted session and send one "继续".
|
|
61
|
+
*
|
|
62
|
+
* The method deliberately does not wait for an answer: the user's workspace should
|
|
63
|
+
* become usable immediately, and an in-flight tool call cannot be replayed safely.
|
|
64
|
+
* `recoverWorkspaceUpgradeAfterBoot` removes the hand-off file after this attempt.
|
|
65
|
+
*/
|
|
66
|
+
recover(): Promise<{
|
|
67
|
+
recovered: number;
|
|
68
|
+
skipped: number;
|
|
69
|
+
}>;
|
|
70
|
+
/** Remove the hand-off record once recovery has been attempted. */
|
|
71
|
+
clearRecoveryState(): Promise<void>;
|
|
72
|
+
/** Find a live session or resume it from persisted state. */
|
|
73
|
+
private ensureAgent;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Run recovery after the DSH host and its session persistence have had time to boot.
|
|
77
|
+
*
|
|
78
|
+
* `apply()` runs before a persisted session necessarily has its live agent; resuming
|
|
79
|
+
* eagerly can race that boot. A short bounded retry is enough, and a failed attempt
|
|
80
|
+
* still removes the hand-off file so the next page load cannot send "继续" forever.
|
|
81
|
+
* @param upgrade - upgrade service.
|
|
82
|
+
*/
|
|
83
|
+
export declare function recoverWorkspaceUpgradeAfterBoot(upgrade: WorkspaceUpgrade): Promise<void>;
|
package/package.json
CHANGED