@dsh-workbench/shared 0.1.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/dist/api/blocker-table.d.ts +9 -0
- package/dist/api/blocker-table.js +130 -0
- package/dist/api/blocker.d.ts +30 -0
- package/dist/api/blocker.js +1 -0
- package/dist/api/context-ref.d.ts +10 -0
- package/dist/api/context-ref.js +40 -0
- package/dist/api/dsh-client.d.ts +170 -0
- package/dist/api/dsh-client.js +1 -0
- package/dist/api/dsh.d.ts +153 -0
- package/dist/api/dsh.js +1 -0
- package/dist/api/facts.d.ts +27 -0
- package/dist/api/facts.js +146 -0
- package/dist/api/host-write.d.ts +12 -0
- package/dist/api/host-write.js +17 -0
- package/dist/api/long-task.d.ts +18 -0
- package/dist/api/long-task.js +22 -0
- package/dist/api/unit-board.d.ts +14 -0
- package/dist/api/unit-board.js +29 -0
- package/dist/api/unit.d.ts +54 -0
- package/dist/api/unit.js +1 -0
- package/dist/api/workbench-client.d.ts +19 -0
- package/dist/api/workbench-client.js +33 -0
- package/dist/api/workbench-contract.d.ts +32 -0
- package/dist/api/workbench-contract.js +1 -0
- package/dist/components/ApprovalDetail.d.ts +27 -0
- package/dist/components/ApprovalDetail.js +33 -0
- package/dist/components/CardHead.d.ts +16 -0
- package/dist/components/CardHead.js +14 -0
- package/dist/components/ChoiceGroup.d.ts +14 -0
- package/dist/components/ChoiceGroup.js +7 -0
- package/dist/components/LongTaskRow.d.ts +16 -0
- package/dist/components/LongTaskRow.js +28 -0
- package/dist/components/MockStrip.d.ts +14 -0
- package/dist/components/MockStrip.js +7 -0
- package/dist/components/ResourceStates.d.ts +18 -0
- package/dist/components/ResourceStates.js +17 -0
- package/dist/components/SaveBar.d.ts +12 -0
- package/dist/components/SaveBar.js +6 -0
- package/dist/components/StateDot.d.ts +5 -0
- package/dist/components/StateDot.js +10 -0
- package/dist/components/board-module.d.ts +67 -0
- package/dist/components/board-module.js +1 -0
- package/dist/components/icons.d.ts +18 -0
- package/dist/components/icons.js +81 -0
- package/dist/config/constants.d.ts +27 -0
- package/dist/config/constants.js +27 -0
- package/dist/config/storage.d.ts +4 -0
- package/dist/config/storage.js +27 -0
- package/dist/host/__tests__/fakes.d.ts +41 -0
- package/dist/host/__tests__/fakes.js +76 -0
- package/dist/host/__tests__/preflight-fixtures.d.ts +19 -0
- package/dist/host/__tests__/preflight-fixtures.js +47 -0
- package/dist/host/cli-error.d.ts +8 -0
- package/dist/host/cli-error.js +70 -0
- package/dist/host/context-inject.d.ts +24 -0
- package/dist/host/context-inject.js +74 -0
- package/dist/host/data-root.d.ts +3 -0
- package/dist/host/data-root.js +12 -0
- package/dist/host/events.d.ts +9 -0
- package/dist/host/events.js +70 -0
- package/dist/host/facts.d.ts +24 -0
- package/dist/host/facts.js +44 -0
- package/dist/host/git.d.ts +55 -0
- package/dist/host/git.js +64 -0
- package/dist/host/http.d.ts +36 -0
- package/dist/host/http.js +242 -0
- package/dist/host/long-task.d.ts +58 -0
- package/dist/host/long-task.js +148 -0
- package/dist/host/mount-units.d.ts +52 -0
- package/dist/host/mount-units.js +186 -0
- package/dist/host/opencli-runtime.d.ts +22 -0
- package/dist/host/opencli-runtime.js +46 -0
- package/dist/host/opencli.d.ts +37 -0
- package/dist/host/opencli.js +152 -0
- package/dist/host/plugin-source.d.ts +31 -0
- package/dist/host/plugin-source.js +81 -0
- package/dist/host/preflight.d.ts +58 -0
- package/dist/host/preflight.js +233 -0
- package/dist/host/probe-cache.d.ts +6 -0
- package/dist/host/probe-cache.js +19 -0
- package/dist/host/probe-libs.d.ts +45 -0
- package/dist/host/probe-libs.js +61 -0
- package/dist/host/probe-units.d.ts +17 -0
- package/dist/host/probe-units.js +102 -0
- package/dist/host/probe-verdict.d.ts +7 -0
- package/dist/host/probe-verdict.js +143 -0
- package/dist/host/provision.d.ts +14 -0
- package/dist/host/provision.js +12 -0
- package/dist/host/shell.d.ts +14 -0
- package/dist/host/shell.js +23 -0
- package/dist/host/tool-approval.d.ts +29 -0
- package/dist/host/tool-approval.js +190 -0
- package/dist/host/tool-kit.d.ts +19 -0
- package/dist/host/tool-kit.js +37 -0
- package/dist/host/tool-scope.d.ts +32 -0
- package/dist/host/tool-scope.js +84 -0
- package/dist/host/unit-face.d.ts +66 -0
- package/dist/host/unit-face.js +1 -0
- package/dist/host/unit-libs.d.ts +37 -0
- package/dist/host/unit-libs.js +1 -0
- package/dist/host/unit-readiness.d.ts +7 -0
- package/dist/host/unit-readiness.js +5 -0
- package/dist/host/unit-registry.d.ts +9 -0
- package/dist/host/unit-registry.js +33 -0
- package/dist/host/value-handoff.d.ts +16 -0
- package/dist/host/value-handoff.js +21 -0
- package/dist/host/version-range.d.ts +2 -0
- package/dist/host/version-range.js +73 -0
- package/dist/host/workspace-store.d.ts +19 -0
- package/dist/host/workspace-store.js +133 -0
- package/dist/host/write-result.d.ts +1 -0
- package/dist/host/write-result.js +18 -0
- package/dist/host.d.ts +19 -0
- package/dist/host.js +19 -0
- package/dist/i18n/en.d.ts +2 -0
- package/dist/i18n/en.js +162 -0
- package/dist/i18n/index.d.ts +172 -0
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/merge.d.ts +6 -0
- package/dist/i18n/merge.js +40 -0
- package/dist/i18n/zh.d.ts +163 -0
- package/dist/i18n/zh.js +162 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +33 -0
- package/dist/lib/blocker-action.d.ts +13 -0
- package/dist/lib/blocker-action.js +12 -0
- package/dist/lib/busy.d.ts +5 -0
- package/dist/lib/busy.js +7 -0
- package/dist/lib/react.d.ts +10 -0
- package/dist/lib/react.js +9 -0
- package/dist/lib/text.d.ts +4 -0
- package/dist/lib/text.js +48 -0
- package/dist/lib/ui.d.ts +11 -0
- package/dist/lib/ui.js +37 -0
- package/package.json +44 -0
- package/src/api/__tests__/blocker-table.test.ts +253 -0
- package/src/api/__tests__/facts.test.ts +274 -0
- package/src/api/__tests__/host-write.test.ts +55 -0
- package/src/api/__tests__/long-task.test.ts +52 -0
- package/src/api/__tests__/unit-board.test.ts +76 -0
- package/src/api/blocker-table.ts +155 -0
- package/src/api/blocker.ts +25 -0
- package/src/api/context-ref.ts +47 -0
- package/src/api/dsh-client.ts +176 -0
- package/src/api/dsh.ts +156 -0
- package/src/api/facts.ts +166 -0
- package/src/api/host-write.ts +27 -0
- package/src/api/long-task.ts +38 -0
- package/src/api/unit-board.ts +44 -0
- package/src/api/unit.ts +59 -0
- package/src/api/workbench-client.test.ts +92 -0
- package/src/api/workbench-client.ts +59 -0
- package/src/api/workbench-contract.ts +40 -0
- package/src/components/ApprovalDetail.tsx +57 -0
- package/src/components/CardHead.tsx +74 -0
- package/src/components/ChoiceGroup.tsx +38 -0
- package/src/components/LongTaskRow.tsx +65 -0
- package/src/components/MockStrip.tsx +40 -0
- package/src/components/ResourceStates.tsx +44 -0
- package/src/components/SaveBar.tsx +31 -0
- package/src/components/StateDot.tsx +31 -0
- package/src/components/board-module.ts +73 -0
- package/src/components/icons.tsx +232 -0
- package/src/config/constants.test.ts +41 -0
- package/src/config/constants.ts +52 -0
- package/src/config/storage.test.ts +82 -0
- package/src/config/storage.ts +25 -0
- package/src/host/__tests__/fakes.ts +116 -0
- package/src/host/__tests__/opencli-runtime.test.ts +46 -0
- package/src/host/cli-error.ts +77 -0
- package/src/host/data-root.ts +13 -0
- package/src/host/facts.ts +69 -0
- package/src/host/git.ts +99 -0
- package/src/host/http.ts +311 -0
- package/src/host/long-task.ts +235 -0
- package/src/host/opencli-runtime.ts +66 -0
- package/src/host/opencli.ts +210 -0
- package/src/host/plugin-source.ts +145 -0
- package/src/host/provision.ts +34 -0
- package/src/host/shell.ts +42 -0
- package/src/host/tool-approval.ts +243 -0
- package/src/host/tool-kit.ts +56 -0
- package/src/host/unit-face.ts +65 -0
- package/src/host/unit-libs.ts +41 -0
- package/src/host/value-handoff.ts +38 -0
- package/src/host/workspace-store.ts +161 -0
- package/src/host/write-result.ts +16 -0
- package/src/host.ts +19 -0
- package/src/i18n/en.ts +170 -0
- package/src/i18n/index.test.ts +15 -0
- package/src/i18n/index.ts +12 -0
- package/src/i18n/merge.test.ts +60 -0
- package/src/i18n/merge.ts +54 -0
- package/src/i18n/zh.test.ts +40 -0
- package/src/i18n/zh.ts +170 -0
- package/src/index.ts +33 -0
- package/src/lib/blocker-action.test.ts +40 -0
- package/src/lib/blocker-action.ts +28 -0
- package/src/lib/busy.test.ts +27 -0
- package/src/lib/busy.ts +11 -0
- package/src/lib/react.test.ts +26 -0
- package/src/lib/react.ts +16 -0
- package/src/lib/text.test.ts +92 -0
- package/src/lib/text.ts +46 -0
- package/src/lib/ui.test.ts +93 -0
- package/src/lib/ui.ts +38 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Translate } from './dsh-client';
|
|
2
|
+
import type { CapabilityPayload } from './workbench-contract';
|
|
3
|
+
import type { ApiError } from './workbench-client';
|
|
4
|
+
import type { ModuleBlocker } from './blocker';
|
|
5
|
+
export declare function blockerOfError(error: ApiError | undefined, t: Translate, context?: {
|
|
6
|
+
path?: string | null;
|
|
7
|
+
platform?: string;
|
|
8
|
+
}): ModuleBlocker;
|
|
9
|
+
export declare function blockerOfCapability(capability: CapabilityPayload, t: Translate): ModuleBlocker | undefined;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { shortenPath } from '../lib/ui.js';
|
|
2
|
+
function retryAction(t) {
|
|
3
|
+
return { kind: 'retry', label: t('blocker.retry') };
|
|
4
|
+
}
|
|
5
|
+
function copyAction(t, text) {
|
|
6
|
+
return { kind: 'copy', label: t('blocker.copy'), text };
|
|
7
|
+
}
|
|
8
|
+
export function blockerOfError(error, t, context = {}) {
|
|
9
|
+
if (error === undefined) {
|
|
10
|
+
return {
|
|
11
|
+
id: 'unknown',
|
|
12
|
+
severity: 'block',
|
|
13
|
+
title: t('blocker.unknown.title'),
|
|
14
|
+
actions: [retryAction(t)],
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
switch (error.code) {
|
|
18
|
+
case 'auth-required': {
|
|
19
|
+
const path = shortenPath(context.path ?? '');
|
|
20
|
+
void path;
|
|
21
|
+
const actions = error.helpUrl === undefined
|
|
22
|
+
? [retryAction(t)]
|
|
23
|
+
: [
|
|
24
|
+
{ kind: 'open-url', label: t('blocker.login.go'), url: error.helpUrl, inline: true },
|
|
25
|
+
retryAction(t),
|
|
26
|
+
];
|
|
27
|
+
return {
|
|
28
|
+
id: 'auth-required',
|
|
29
|
+
severity: 'block',
|
|
30
|
+
title: context.platform === undefined
|
|
31
|
+
? t('blocker.login.titleGeneric')
|
|
32
|
+
: t('blocker.login.title', { platform: context.platform }),
|
|
33
|
+
hint: error.helpUrl === undefined ? t('blocker.login.manual') : t('blocker.login.hint'),
|
|
34
|
+
...(error.detail === undefined ? {} : { detail: error.detail }),
|
|
35
|
+
actions,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
case 'permission-denied': {
|
|
39
|
+
const actions = error.helpUrl === undefined
|
|
40
|
+
? [retryAction(t)]
|
|
41
|
+
: [
|
|
42
|
+
{ kind: 'open-url', label: t('blocker.forbidden.open'), url: error.helpUrl },
|
|
43
|
+
{ kind: 'retry', label: t('blocker.retry') },
|
|
44
|
+
];
|
|
45
|
+
return {
|
|
46
|
+
id: 'permission-denied',
|
|
47
|
+
severity: 'block',
|
|
48
|
+
title: context.platform === undefined
|
|
49
|
+
? t('blocker.forbidden.titleGeneric')
|
|
50
|
+
: t('blocker.forbidden.title', { platform: context.platform }),
|
|
51
|
+
hint: t('blocker.forbidden.hint'),
|
|
52
|
+
...(error.detail === undefined ? {} : { detail: error.detail }),
|
|
53
|
+
actions,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
case 'cli-timeout':
|
|
57
|
+
return {
|
|
58
|
+
id: 'cli-timeout',
|
|
59
|
+
severity: 'notice',
|
|
60
|
+
title: error.message,
|
|
61
|
+
hint: error.hint ?? t('blocker.timeout.hint'),
|
|
62
|
+
...(error.detail === undefined ? {} : { detail: error.detail }),
|
|
63
|
+
actions: [retryAction(t)],
|
|
64
|
+
};
|
|
65
|
+
case 'cli-exec-failed':
|
|
66
|
+
return {
|
|
67
|
+
id: 'cli-exec-failed',
|
|
68
|
+
severity: 'block',
|
|
69
|
+
title: error.message,
|
|
70
|
+
hint: error.hint ?? t('blocker.exec.hint'),
|
|
71
|
+
...(error.detail === undefined ? {} : { detail: error.detail }),
|
|
72
|
+
actions: [retryAction(t)],
|
|
73
|
+
};
|
|
74
|
+
default:
|
|
75
|
+
return {
|
|
76
|
+
id: error.code,
|
|
77
|
+
severity: 'block',
|
|
78
|
+
title: error.message,
|
|
79
|
+
...(error.hint === undefined ? {} : { hint: error.hint }),
|
|
80
|
+
...(error.detail === undefined ? {} : { detail: error.detail }),
|
|
81
|
+
actions: [retryAction(t)],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export function blockerOfCapability(capability, t) {
|
|
86
|
+
if (capability.status === 'ok')
|
|
87
|
+
return undefined;
|
|
88
|
+
const fixAction = capability.fix === undefined
|
|
89
|
+
? undefined
|
|
90
|
+
: {
|
|
91
|
+
kind: 'run-fix',
|
|
92
|
+
label: capability.fix === 'install' ? t('blocker.fix.install') : t('blocker.fix.update'),
|
|
93
|
+
unit: capability.unit,
|
|
94
|
+
fix: capability.fix,
|
|
95
|
+
};
|
|
96
|
+
const sourceUnknown = capability.fix === undefined && capability.install !== undefined && capability.install !== 'ready';
|
|
97
|
+
const install = [
|
|
98
|
+
...(fixAction === undefined ? [] : [fixAction]),
|
|
99
|
+
...(sourceUnknown ? [{ kind: 'open-market', label: t('blocker.market.open'), unit: capability.unit }] : []),
|
|
100
|
+
...(capability.command === undefined || sourceUnknown ? [] : [copyAction(t, capability.command)]),
|
|
101
|
+
];
|
|
102
|
+
if (capability.status === 'missing-plugin') {
|
|
103
|
+
return {
|
|
104
|
+
id: 'unit-missing-plugin',
|
|
105
|
+
severity: 'block',
|
|
106
|
+
title: t('env.unit.missingPlugin'),
|
|
107
|
+
hint: t('env.unit.hint'),
|
|
108
|
+
...(capability.detail === undefined ? {} : { detail: capability.detail }),
|
|
109
|
+
actions: [...install, retryAction(t)],
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (capability.status === 'missing-commands') {
|
|
113
|
+
return {
|
|
114
|
+
id: 'unit-missing-commands',
|
|
115
|
+
severity: 'block',
|
|
116
|
+
title: t('env.unit.missingCommands'),
|
|
117
|
+
hint: t('env.unit.missingCommandsHint'),
|
|
118
|
+
...(capability.detail === undefined ? {} : { detail: capability.detail }),
|
|
119
|
+
actions: [...install, retryAction(t)],
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
id: 'unit-unchecked',
|
|
124
|
+
severity: 'notice',
|
|
125
|
+
title: t('env.unit.unchecked'),
|
|
126
|
+
hint: t('env.unit.uncheckedHint'),
|
|
127
|
+
...(capability.detail === undefined ? {} : { detail: capability.detail }),
|
|
128
|
+
actions: [retryAction(t)],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type BlockerAction = {
|
|
2
|
+
readonly kind: 'open-url';
|
|
3
|
+
readonly label: string;
|
|
4
|
+
readonly url: string;
|
|
5
|
+
readonly inline?: boolean;
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: 'copy';
|
|
8
|
+
readonly label: string;
|
|
9
|
+
readonly text: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: 'retry';
|
|
12
|
+
readonly label: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: 'run-fix';
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly unit: string;
|
|
17
|
+
readonly fix: 'install' | 'update';
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: 'open-market';
|
|
20
|
+
readonly label: string;
|
|
21
|
+
readonly unit: string;
|
|
22
|
+
};
|
|
23
|
+
export interface ModuleBlocker {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly severity: 'block' | 'notice';
|
|
26
|
+
readonly title: string;
|
|
27
|
+
readonly hint?: string;
|
|
28
|
+
readonly detail?: string;
|
|
29
|
+
readonly actions: readonly BlockerAction[];
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const CONTEXT_MARKER_NAME = "\u5DE5\u4F5C\u53F0";
|
|
2
|
+
export interface ContextRef {
|
|
3
|
+
readonly kind: string;
|
|
4
|
+
readonly parts: readonly string[];
|
|
5
|
+
}
|
|
6
|
+
export declare function encodeRef(ref: ContextRef): string;
|
|
7
|
+
export declare function decodeRef(text: string): ContextRef | undefined;
|
|
8
|
+
export declare function markerBody(encoded: string): string;
|
|
9
|
+
export declare function buildMarker(ref: ContextRef): string;
|
|
10
|
+
export declare function parseMarkers(text: string): ContextRef[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const CONTEXT_MARKER_NAME = '工作台';
|
|
2
|
+
const MARKER = new RegExp(`@${CONTEXT_MARKER_NAME}:([a-z][a-z0-9-]*:[A-Za-z0-9._~%#/-]+)`, 'g');
|
|
3
|
+
const TRAILING_PUNCTUATION = /[.,;:!?]+$/;
|
|
4
|
+
export function encodeRef(ref) {
|
|
5
|
+
return `${ref.kind}:${ref.parts.join('/')}`;
|
|
6
|
+
}
|
|
7
|
+
export function decodeRef(text) {
|
|
8
|
+
const at = text.indexOf(':');
|
|
9
|
+
if (at <= 0 || at === text.length - 1)
|
|
10
|
+
return undefined;
|
|
11
|
+
const kind = text.slice(0, at);
|
|
12
|
+
if (!/^[a-z][a-z0-9-]*$/.test(kind))
|
|
13
|
+
return undefined;
|
|
14
|
+
const parts = text.slice(at + 1).split('/').filter((part) => part !== '');
|
|
15
|
+
if (parts.length === 0)
|
|
16
|
+
return undefined;
|
|
17
|
+
return { kind, parts };
|
|
18
|
+
}
|
|
19
|
+
export function markerBody(encoded) {
|
|
20
|
+
return `${CONTEXT_MARKER_NAME}:${encoded}`;
|
|
21
|
+
}
|
|
22
|
+
export function buildMarker(ref) {
|
|
23
|
+
return `@${markerBody(encodeRef(ref))}`;
|
|
24
|
+
}
|
|
25
|
+
export function parseMarkers(text) {
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
const refs = [];
|
|
28
|
+
for (const match of String(text ?? '').matchAll(MARKER)) {
|
|
29
|
+
const raw = match[1].replace(TRAILING_PUNCTUATION, '');
|
|
30
|
+
const ref = decodeRef(raw);
|
|
31
|
+
if (ref === undefined)
|
|
32
|
+
continue;
|
|
33
|
+
const key = encodeRef(ref);
|
|
34
|
+
if (seen.has(key))
|
|
35
|
+
continue;
|
|
36
|
+
seen.add(key);
|
|
37
|
+
refs.push(ref);
|
|
38
|
+
}
|
|
39
|
+
return refs;
|
|
40
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface WorkspaceView {
|
|
3
|
+
readonly workspaceId: string;
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly title: string;
|
|
6
|
+
readonly sessionIds: readonly string[];
|
|
7
|
+
readonly createdAt: number;
|
|
8
|
+
readonly updatedAt: number;
|
|
9
|
+
}
|
|
10
|
+
export interface WorkspaceSnapshot {
|
|
11
|
+
readonly items: readonly WorkspaceView[];
|
|
12
|
+
readonly archivedSessionIds: readonly string[];
|
|
13
|
+
readonly pinnedSessionIds: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
export interface SessionSummary {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly displayTitle: string;
|
|
18
|
+
readonly blank: boolean;
|
|
19
|
+
readonly running: boolean;
|
|
20
|
+
readonly updatedAt: number;
|
|
21
|
+
readonly origin?: string;
|
|
22
|
+
readonly retainedBy: Readonly<Partial<Record<string, number>>>;
|
|
23
|
+
}
|
|
24
|
+
export interface SubagentCatalogEntry {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
}
|
|
27
|
+
export interface SessionsSnapshot {
|
|
28
|
+
readonly byId: Readonly<Record<string, SessionSummary>>;
|
|
29
|
+
readonly projectionsBySession: Readonly<Record<string, {
|
|
30
|
+
values?: {
|
|
31
|
+
subagentCatalog?: readonly SubagentCatalogEntry[];
|
|
32
|
+
};
|
|
33
|
+
} | undefined>>;
|
|
34
|
+
}
|
|
35
|
+
export interface SessionStatus {
|
|
36
|
+
readonly running?: boolean;
|
|
37
|
+
readonly completionUnread?: boolean;
|
|
38
|
+
readonly pendingInteraction?: {
|
|
39
|
+
readonly kind?: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export type SessionStatusSnapshot = ReadonlyMap<string, SessionStatus>;
|
|
43
|
+
export interface PanelInfo {
|
|
44
|
+
readonly activePanelId: string | null;
|
|
45
|
+
}
|
|
46
|
+
export interface PanelEntry {
|
|
47
|
+
readonly id: string;
|
|
48
|
+
readonly order: number;
|
|
49
|
+
readonly label: string | (() => string);
|
|
50
|
+
}
|
|
51
|
+
export type SnapshotSelectorHook<T> = <R>(selector: (state: T) => R) => R;
|
|
52
|
+
export type RenderSlot = (key: string, owner?: Record<string, unknown>, options?: {
|
|
53
|
+
fallback?: ReactNode;
|
|
54
|
+
hookContext?: unknown;
|
|
55
|
+
only?: string;
|
|
56
|
+
}) => ReactNode;
|
|
57
|
+
export type Translate = (key: string, params?: Record<string, unknown>) => string;
|
|
58
|
+
export interface SlotRegisterOptions {
|
|
59
|
+
name: string;
|
|
60
|
+
priority?: number;
|
|
61
|
+
key?: string;
|
|
62
|
+
id?: string;
|
|
63
|
+
order?: number;
|
|
64
|
+
locale?: string;
|
|
65
|
+
label?: string | (() => string);
|
|
66
|
+
children?: Record<string, unknown>;
|
|
67
|
+
inject?: (scope?: unknown) => Record<string, unknown>;
|
|
68
|
+
}
|
|
69
|
+
export interface DshSlots {
|
|
70
|
+
inject(name: string, callback: () => void | (() => void) | Iterable<() => void>): () => void;
|
|
71
|
+
register(options: SlotRegisterOptions, component: unknown): () => void;
|
|
72
|
+
entriesOfSlot(name: string): Array<{
|
|
73
|
+
options: SlotRegisterOptions;
|
|
74
|
+
}>;
|
|
75
|
+
subscribe(name: string, callback: () => void): () => void;
|
|
76
|
+
specDynamic?(name: string): unknown;
|
|
77
|
+
onMutate?(callback: (name: string) => void): () => void;
|
|
78
|
+
}
|
|
79
|
+
export interface DshLocale {
|
|
80
|
+
register(namespace: string, dictionaries: Record<string, Record<string, string>>): () => void;
|
|
81
|
+
bind(namespace: string): Translate;
|
|
82
|
+
}
|
|
83
|
+
export interface DshLayout {
|
|
84
|
+
selectPanel(panelId: string | null): void;
|
|
85
|
+
toggleSidebar(): void;
|
|
86
|
+
openRightbar(track: boolean, fullscreen: boolean): void;
|
|
87
|
+
closeRightbar(): void;
|
|
88
|
+
readonly panels?: DshLayoutPanels;
|
|
89
|
+
}
|
|
90
|
+
export interface DshLayoutPanels {
|
|
91
|
+
setRightbar?(px: number): void;
|
|
92
|
+
}
|
|
93
|
+
export interface DshShortcutCatalog {
|
|
94
|
+
readonly catalog: unknown;
|
|
95
|
+
}
|
|
96
|
+
export interface DshUiWorkspace {
|
|
97
|
+
openWorkspace(workspaceId: string): Promise<unknown>;
|
|
98
|
+
openSession(sessionId: string): void;
|
|
99
|
+
startSession(workspaceId: string): void;
|
|
100
|
+
pickDirectory(): Promise<string | null>;
|
|
101
|
+
}
|
|
102
|
+
export interface DshWorkspaces {
|
|
103
|
+
create(request: {
|
|
104
|
+
path: string;
|
|
105
|
+
}): Promise<{
|
|
106
|
+
workspaceId?: string;
|
|
107
|
+
} | undefined>;
|
|
108
|
+
}
|
|
109
|
+
export interface DshReferenceInsert {
|
|
110
|
+
readonly source: string;
|
|
111
|
+
readonly ref: string;
|
|
112
|
+
readonly label: string;
|
|
113
|
+
readonly appearance?: 'session' | 'file' | 'folder';
|
|
114
|
+
readonly clipboardText: string;
|
|
115
|
+
}
|
|
116
|
+
export interface DshTokenSpan {
|
|
117
|
+
readonly start: number;
|
|
118
|
+
readonly end: number;
|
|
119
|
+
readonly draftRev: number;
|
|
120
|
+
}
|
|
121
|
+
export interface DshSessionInput {
|
|
122
|
+
caretSpan?: () => {
|
|
123
|
+
start: number;
|
|
124
|
+
end: number;
|
|
125
|
+
};
|
|
126
|
+
readonly state: {
|
|
127
|
+
getSnapshot(): {
|
|
128
|
+
draftRev: number;
|
|
129
|
+
} | undefined;
|
|
130
|
+
};
|
|
131
|
+
insertReference(ref: DshReferenceInsert, span: DshTokenSpan): boolean;
|
|
132
|
+
notify(level: 'info' | 'error', text: string): void;
|
|
133
|
+
}
|
|
134
|
+
export interface DshInputTriggers {
|
|
135
|
+
registerSource(source: {
|
|
136
|
+
readonly trigger: '@';
|
|
137
|
+
readonly name: string;
|
|
138
|
+
readonly order?: number;
|
|
139
|
+
candidates: () => Promise<readonly unknown[]>;
|
|
140
|
+
onPick: () => undefined;
|
|
141
|
+
lexicon?: (session: unknown) => readonly string[] | undefined;
|
|
142
|
+
subscribeLexicon?: (session: unknown, listener: () => void) => () => void;
|
|
143
|
+
readonly codec?: {
|
|
144
|
+
clipboardText(ref: string): string;
|
|
145
|
+
serialize(ref: string, signal?: AbortSignal): Promise<string>;
|
|
146
|
+
};
|
|
147
|
+
}): () => void;
|
|
148
|
+
}
|
|
149
|
+
export interface DshConversationService {
|
|
150
|
+
readonly input: {
|
|
151
|
+
for(actx: unknown): DshSessionInput;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
export interface DshSessionsService {
|
|
155
|
+
readonly list: {
|
|
156
|
+
getSnapshot(): SessionsSnapshot;
|
|
157
|
+
};
|
|
158
|
+
scope(sessionId: string): unknown | undefined;
|
|
159
|
+
}
|
|
160
|
+
export interface DshClientContext {
|
|
161
|
+
get<T = unknown>(name: string): T | undefined;
|
|
162
|
+
provide(name: string, value: unknown): void;
|
|
163
|
+
effect(effect: () => void | (() => void), label?: string): () => void;
|
|
164
|
+
readonly slots: DshSlots;
|
|
165
|
+
readonly locale: DshLocale;
|
|
166
|
+
readonly layout: DshLayout;
|
|
167
|
+
readonly uiWorkspace: DshUiWorkspace;
|
|
168
|
+
readonly workspaces: DshWorkspaces;
|
|
169
|
+
readonly shortcuts: DshShortcutCatalog;
|
|
170
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
export interface DshLogger {
|
|
2
|
+
info?(message: string): void;
|
|
3
|
+
warn?(message: string): void;
|
|
4
|
+
}
|
|
5
|
+
export interface DshRequest {
|
|
6
|
+
readonly method?: string;
|
|
7
|
+
readonly url?: string;
|
|
8
|
+
[Symbol.asyncIterator]?(): AsyncIterator<Uint8Array>;
|
|
9
|
+
}
|
|
10
|
+
export interface DshResponse {
|
|
11
|
+
statusCode: number;
|
|
12
|
+
setHeader(name: string, value: string): void;
|
|
13
|
+
end(body?: string): void;
|
|
14
|
+
writeHead?(status: number, headers: Record<string, string>): void;
|
|
15
|
+
write?(chunk: string): void;
|
|
16
|
+
on?(event: 'close', listener: () => void): void;
|
|
17
|
+
}
|
|
18
|
+
export interface DshWebRoute {
|
|
19
|
+
readonly kind: 'prefix' | 'exact';
|
|
20
|
+
readonly path: string;
|
|
21
|
+
readonly handler: (req: DshRequest, res: DshResponse) => void | Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export interface DshProfileContext {
|
|
24
|
+
readonly dir?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface DshToolSchema {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly [key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
export interface DshPromptAssembly {
|
|
31
|
+
readonly tools?: readonly DshToolSchema[] | undefined;
|
|
32
|
+
readonly [key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
export interface DshAssemblyContext {
|
|
35
|
+
readonly agent?: unknown;
|
|
36
|
+
readonly scope?: unknown;
|
|
37
|
+
readonly [key: string]: unknown;
|
|
38
|
+
}
|
|
39
|
+
export interface DshHostContext {
|
|
40
|
+
on?: {
|
|
41
|
+
(event: 'system-prompt/assemble', listener: (assembly: DshPromptAssembly, context: DshAssemblyContext, next: () => Promise<DshPromptAssembly>) => Promise<DshPromptAssembly>): (() => void) | undefined;
|
|
42
|
+
} & {
|
|
43
|
+
(event: 'tools/pre-execute', listener: (exec: {
|
|
44
|
+
name?: string;
|
|
45
|
+
arguments?: unknown;
|
|
46
|
+
readonly agent?: DshToolRunContext['agent'];
|
|
47
|
+
}, next: () => Promise<{
|
|
48
|
+
kind: 'allow';
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'deny';
|
|
51
|
+
reason: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'cancel';
|
|
54
|
+
} | {
|
|
55
|
+
kind: 'ask';
|
|
56
|
+
reason?: string;
|
|
57
|
+
displayReason?: Record<string, string>;
|
|
58
|
+
}>) => Promise<{
|
|
59
|
+
kind: 'allow';
|
|
60
|
+
} | {
|
|
61
|
+
kind: 'deny';
|
|
62
|
+
reason: string;
|
|
63
|
+
} | {
|
|
64
|
+
kind: 'cancel';
|
|
65
|
+
} | {
|
|
66
|
+
kind: 'ask';
|
|
67
|
+
reason?: string;
|
|
68
|
+
displayReason?: Record<string, string>;
|
|
69
|
+
}>): (() => void) | undefined;
|
|
70
|
+
} & {
|
|
71
|
+
(event: 'tools/post-execute', listener: (exec: {
|
|
72
|
+
name?: string;
|
|
73
|
+
arguments?: unknown;
|
|
74
|
+
}, result: unknown, next: () => unknown) => unknown): (() => void) | undefined;
|
|
75
|
+
} & {
|
|
76
|
+
(event: 'agent/created', listener: (payload: {
|
|
77
|
+
agent?: unknown;
|
|
78
|
+
}) => void): (() => void) | undefined;
|
|
79
|
+
} & {
|
|
80
|
+
(event: 'agent/pre-step', listener: (payload: {
|
|
81
|
+
agent?: unknown;
|
|
82
|
+
messages?: readonly unknown[];
|
|
83
|
+
}, next: () => Promise<{
|
|
84
|
+
kind: string;
|
|
85
|
+
messages?: readonly unknown[];
|
|
86
|
+
}>) => Promise<{
|
|
87
|
+
kind: string;
|
|
88
|
+
messages?: readonly unknown[];
|
|
89
|
+
}>): (() => void) | undefined;
|
|
90
|
+
};
|
|
91
|
+
get<T = unknown>(name: string): T | undefined;
|
|
92
|
+
provide(name: string, value: unknown): () => void;
|
|
93
|
+
effect(effect: () => void | (() => void), label?: string): () => void;
|
|
94
|
+
readonly logger?: DshLogger;
|
|
95
|
+
readonly webServer: {
|
|
96
|
+
register(route: DshWebRoute): () => void;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export interface DshShellExecution {
|
|
100
|
+
result(): Promise<{
|
|
101
|
+
exitCode: number | null;
|
|
102
|
+
timedOut: boolean;
|
|
103
|
+
aborted: boolean;
|
|
104
|
+
stdout: {
|
|
105
|
+
text: string;
|
|
106
|
+
truncated: boolean;
|
|
107
|
+
};
|
|
108
|
+
stderr: {
|
|
109
|
+
text: string;
|
|
110
|
+
truncated: boolean;
|
|
111
|
+
};
|
|
112
|
+
}>;
|
|
113
|
+
}
|
|
114
|
+
export interface DshShell {
|
|
115
|
+
resolve(request: {
|
|
116
|
+
command: string;
|
|
117
|
+
workdir?: string;
|
|
118
|
+
timeoutMs?: number;
|
|
119
|
+
onExpiry?: 'kill' | 'none';
|
|
120
|
+
stdoutMaxBytes?: number;
|
|
121
|
+
signal?: AbortSignal;
|
|
122
|
+
}): unknown;
|
|
123
|
+
execute(spec: unknown): Promise<DshShellExecution>;
|
|
124
|
+
}
|
|
125
|
+
export interface DshWorkspaceRegistry {
|
|
126
|
+
get(id: string): {
|
|
127
|
+
id: string;
|
|
128
|
+
path?: string;
|
|
129
|
+
title?: string;
|
|
130
|
+
} | undefined;
|
|
131
|
+
}
|
|
132
|
+
export interface DshToolDefinition {
|
|
133
|
+
name: string;
|
|
134
|
+
description: string;
|
|
135
|
+
parameters: Record<string, unknown>;
|
|
136
|
+
output: {
|
|
137
|
+
schema: Record<string, unknown>;
|
|
138
|
+
render(args: unknown, value: unknown): Array<Record<string, unknown>>;
|
|
139
|
+
};
|
|
140
|
+
execute(args: any, exec: DshToolRunContext): Promise<unknown>;
|
|
141
|
+
}
|
|
142
|
+
export interface DshToolRunContext {
|
|
143
|
+
readonly agent?: {
|
|
144
|
+
readonly session?: {
|
|
145
|
+
readonly header?: {
|
|
146
|
+
readonly cwd?: string;
|
|
147
|
+
} | undefined;
|
|
148
|
+
} | undefined;
|
|
149
|
+
} | undefined;
|
|
150
|
+
}
|
|
151
|
+
export interface DshToolRegistry {
|
|
152
|
+
register(definition: DshToolDefinition): () => void;
|
|
153
|
+
}
|
package/dist/api/dsh.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface FactFrame {
|
|
2
|
+
readonly epoch?: string;
|
|
3
|
+
readonly rev: number;
|
|
4
|
+
readonly facts: readonly string[];
|
|
5
|
+
}
|
|
6
|
+
export declare const FACT_SCOPE_SUFFIX = "*";
|
|
7
|
+
export declare function unitFactScope(unit: string): string;
|
|
8
|
+
export declare function isFactScope(name: string): boolean;
|
|
9
|
+
export declare function scopePrefixOf(name: string): string;
|
|
10
|
+
export interface FactTransport {
|
|
11
|
+
start(handlers: {
|
|
12
|
+
readonly onFrame: (frame: FactFrame) => void;
|
|
13
|
+
readonly cursor: () => number;
|
|
14
|
+
}): () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface FactChannel {
|
|
17
|
+
subscribe(fact: string, listener: () => void): () => void;
|
|
18
|
+
revisionOf(fact: string): number;
|
|
19
|
+
refresh(fact?: string): void;
|
|
20
|
+
applyFrame(frame: FactFrame): void;
|
|
21
|
+
subscriberCount(): number;
|
|
22
|
+
}
|
|
23
|
+
export declare function createFactChannel(options: {
|
|
24
|
+
readonly transport: FactTransport;
|
|
25
|
+
}): FactChannel;
|
|
26
|
+
export declare function parseFactFrame(data: unknown): FactFrame | null;
|
|
27
|
+
export declare function factOfRoute(route: string): string;
|