@zerowall/dsh-claude-coderun 0.0.0-stage → 0.1.0-preview.2
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/LICENSE +21 -0
- package/README.i18n.yaml +16 -0
- package/README.md +23 -2
- package/README.zh.md +24 -0
- package/dsh.bundle.patch.yml +23 -0
- package/lib/client.js +17823 -0
- package/lib/index.js +3754 -0
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +1938 -0
- package/lib/typert.remote-client.d.ts +101 -0
- package/lib/typert.remote-client.d.ts.map +1 -0
- package/lib/typert.remote-client.js +1327 -0
- package/lib/types/client/ClaudeCodeAction.d.ts +13 -0
- package/lib/types/client/ClaudeCodeSettingsSection.d.ts +7 -0
- package/lib/types/client/ClaudePermissionSelect.d.ts +11 -0
- package/lib/types/client/ClaudeStats.d.ts +17 -0
- package/lib/types/client/ClaudeTranscript.d.ts +22 -0
- package/lib/types/client/index.d.ts +1 -0
- package/lib/types/client/locales.d.ts +243 -0
- package/lib/types/client/upstream/GlobalSettingControls.d.ts +39 -0
- package/lib/types/client/upstream/markdown-theme.d.ts +42 -0
- package/lib/types/client/upstream/settings-styles.d.ts +42 -0
- package/lib/types/client/view.d.ts +9 -0
- package/lib/types/host/claude-commands.d.ts +19 -0
- package/lib/types/host/claude-settings.d.ts +19 -0
- package/lib/types/host/cli.d.ts +24 -0
- package/lib/types/host/diagnostic.d.ts +2 -0
- package/lib/types/host/environment.d.ts +2 -0
- package/lib/types/host/index.d.ts +78 -0
- package/lib/types/host/mcp-launcher.d.ts +16 -0
- package/lib/types/host/metrics-projection.d.ts +250 -0
- package/lib/types/host/metrics.d.ts +16 -0
- package/lib/types/host/permission-mode.d.ts +62 -0
- package/lib/types/host/projection.d.ts +124 -0
- package/lib/types/host/resource-status.d.ts +8 -0
- package/lib/types/host/route.d.ts +52 -0
- package/lib/types/host/runtime.d.ts +80 -0
- package/lib/types/host/sdk-driver.d.ts +29 -0
- package/lib/types/host/session-binding.d.ts +25 -0
- package/lib/types/host/subagent-tool.d.ts +6 -0
- package/lib/types/host/tool-journal.d.ts +13 -0
- package/lib/types/shared/metrics.d.ts +57 -0
- package/lib/types/shared/records.d.ts +33 -0
- package/lib/types/shared/types.d.ts +262 -0
- package/lib/types.js +18 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/migration-reference.md +67 -0
- package/package.json +252 -3
- package/plugin-detail.md +11 -0
- package/plugin-detail.zh.md +11 -0
- package/zerowall.plugin.json +65 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type ClaudeMetrics } from '../shared/metrics.js';
|
|
3
|
+
export declare const runMetricsSchema: z.ZodObject<{
|
|
4
|
+
runId: z.ZodString;
|
|
5
|
+
nativeSessionId: z.ZodString;
|
|
6
|
+
provider: z.ZodString;
|
|
7
|
+
model: z.ZodString;
|
|
8
|
+
turn: z.ZodNumber;
|
|
9
|
+
main: z.ZodBoolean;
|
|
10
|
+
finished: z.ZodBoolean;
|
|
11
|
+
settled: z.ZodBoolean;
|
|
12
|
+
models: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
13
|
+
inputTokens: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
cacheReadTokens: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
cacheWriteTokens: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
incomplete: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
18
|
+
inputTokens: "inputTokens";
|
|
19
|
+
outputTokens: "outputTokens";
|
|
20
|
+
cacheReadTokens: "cacheReadTokens";
|
|
21
|
+
cacheWriteTokens: "cacheWriteTokens";
|
|
22
|
+
}>>>;
|
|
23
|
+
}, z.core.$strict>>;
|
|
24
|
+
steps: z.ZodNumber;
|
|
25
|
+
decodeTokens: z.ZodNumber;
|
|
26
|
+
decodeMs: z.ZodNumber;
|
|
27
|
+
modelMs: z.ZodNumber;
|
|
28
|
+
context: z.ZodNullable<z.ZodObject<{
|
|
29
|
+
model: z.ZodString;
|
|
30
|
+
usedTokens: z.ZodNumber;
|
|
31
|
+
contextWindow: z.ZodNumber;
|
|
32
|
+
}, z.core.$strict>>;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
declare const stateSchema: z.ZodObject<{
|
|
35
|
+
runs: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
36
|
+
runId: z.ZodString;
|
|
37
|
+
nativeSessionId: z.ZodString;
|
|
38
|
+
provider: z.ZodString;
|
|
39
|
+
model: z.ZodString;
|
|
40
|
+
turn: z.ZodNumber;
|
|
41
|
+
main: z.ZodBoolean;
|
|
42
|
+
finished: z.ZodBoolean;
|
|
43
|
+
settled: z.ZodBoolean;
|
|
44
|
+
models: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
45
|
+
inputTokens: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
cacheReadTokens: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
cacheWriteTokens: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
incomplete: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
50
|
+
inputTokens: "inputTokens";
|
|
51
|
+
outputTokens: "outputTokens";
|
|
52
|
+
cacheReadTokens: "cacheReadTokens";
|
|
53
|
+
cacheWriteTokens: "cacheWriteTokens";
|
|
54
|
+
}>>>;
|
|
55
|
+
}, z.core.$strict>>;
|
|
56
|
+
steps: z.ZodNumber;
|
|
57
|
+
decodeTokens: z.ZodNumber;
|
|
58
|
+
decodeMs: z.ZodNumber;
|
|
59
|
+
modelMs: z.ZodNumber;
|
|
60
|
+
context: z.ZodNullable<z.ZodObject<{
|
|
61
|
+
model: z.ZodString;
|
|
62
|
+
usedTokens: z.ZodNumber;
|
|
63
|
+
contextWindow: z.ZodNumber;
|
|
64
|
+
}, z.core.$strict>>;
|
|
65
|
+
revision: z.ZodOptional<z.ZodNumber>;
|
|
66
|
+
}, z.core.$strict>>;
|
|
67
|
+
latest: z.ZodNullable<z.ZodString>;
|
|
68
|
+
invalidated: z.ZodBoolean;
|
|
69
|
+
nextRevision: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
contextAfterRevision: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
route: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
72
|
+
provider: z.ZodString;
|
|
73
|
+
model: z.ZodString;
|
|
74
|
+
}, z.core.$strict>>>;
|
|
75
|
+
}, z.core.$strict>;
|
|
76
|
+
type State = z.infer<typeof stateSchema>;
|
|
77
|
+
declare module '@deepseek-ai/dsh-session-projection/types' {
|
|
78
|
+
interface SessionProjectionStateMap {
|
|
79
|
+
zerowallClaudeMetrics: State;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export declare function metricsView(state: State): ClaudeMetrics;
|
|
83
|
+
export declare const claudeMetricsProjection: {
|
|
84
|
+
key: "zerowallClaudeMetrics";
|
|
85
|
+
stateVersion: number;
|
|
86
|
+
stateSchema: z.ZodObject<{
|
|
87
|
+
runs: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
88
|
+
runId: z.ZodString;
|
|
89
|
+
nativeSessionId: z.ZodString;
|
|
90
|
+
provider: z.ZodString;
|
|
91
|
+
model: z.ZodString;
|
|
92
|
+
turn: z.ZodNumber;
|
|
93
|
+
main: z.ZodBoolean;
|
|
94
|
+
finished: z.ZodBoolean;
|
|
95
|
+
settled: z.ZodBoolean;
|
|
96
|
+
models: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
97
|
+
inputTokens: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
cacheReadTokens: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
cacheWriteTokens: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
incomplete: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
102
|
+
inputTokens: "inputTokens";
|
|
103
|
+
outputTokens: "outputTokens";
|
|
104
|
+
cacheReadTokens: "cacheReadTokens";
|
|
105
|
+
cacheWriteTokens: "cacheWriteTokens";
|
|
106
|
+
}>>>;
|
|
107
|
+
}, z.core.$strict>>;
|
|
108
|
+
steps: z.ZodNumber;
|
|
109
|
+
decodeTokens: z.ZodNumber;
|
|
110
|
+
decodeMs: z.ZodNumber;
|
|
111
|
+
modelMs: z.ZodNumber;
|
|
112
|
+
context: z.ZodNullable<z.ZodObject<{
|
|
113
|
+
model: z.ZodString;
|
|
114
|
+
usedTokens: z.ZodNumber;
|
|
115
|
+
contextWindow: z.ZodNumber;
|
|
116
|
+
}, z.core.$strict>>;
|
|
117
|
+
revision: z.ZodOptional<z.ZodNumber>;
|
|
118
|
+
}, z.core.$strict>>;
|
|
119
|
+
latest: z.ZodNullable<z.ZodString>;
|
|
120
|
+
invalidated: z.ZodBoolean;
|
|
121
|
+
nextRevision: z.ZodOptional<z.ZodNumber>;
|
|
122
|
+
contextAfterRevision: z.ZodOptional<z.ZodNumber>;
|
|
123
|
+
route: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
124
|
+
provider: z.ZodString;
|
|
125
|
+
model: z.ZodString;
|
|
126
|
+
}, z.core.$strict>>>;
|
|
127
|
+
}, z.core.$strict>;
|
|
128
|
+
init: () => {
|
|
129
|
+
runs: {};
|
|
130
|
+
latest: null;
|
|
131
|
+
invalidated: false;
|
|
132
|
+
route: null;
|
|
133
|
+
nextRevision: number;
|
|
134
|
+
contextAfterRevision: number;
|
|
135
|
+
};
|
|
136
|
+
apply: (state: NoInfer<{
|
|
137
|
+
runs: Record<string, {
|
|
138
|
+
runId: string;
|
|
139
|
+
nativeSessionId: string;
|
|
140
|
+
provider: string;
|
|
141
|
+
model: string;
|
|
142
|
+
turn: number;
|
|
143
|
+
main: boolean;
|
|
144
|
+
finished: boolean;
|
|
145
|
+
settled: boolean;
|
|
146
|
+
models: Record<string, {
|
|
147
|
+
inputTokens?: number | undefined;
|
|
148
|
+
outputTokens?: number | undefined;
|
|
149
|
+
cacheReadTokens?: number | undefined;
|
|
150
|
+
cacheWriteTokens?: number | undefined;
|
|
151
|
+
incomplete?: ("inputTokens" | "outputTokens" | "cacheReadTokens" | "cacheWriteTokens")[] | undefined;
|
|
152
|
+
}>;
|
|
153
|
+
steps: number;
|
|
154
|
+
decodeTokens: number;
|
|
155
|
+
decodeMs: number;
|
|
156
|
+
modelMs: number;
|
|
157
|
+
context: {
|
|
158
|
+
model: string;
|
|
159
|
+
usedTokens: number;
|
|
160
|
+
contextWindow: number;
|
|
161
|
+
} | null;
|
|
162
|
+
revision?: number | undefined;
|
|
163
|
+
}>;
|
|
164
|
+
latest: string | null;
|
|
165
|
+
invalidated: boolean;
|
|
166
|
+
nextRevision?: number | undefined;
|
|
167
|
+
contextAfterRevision?: number | undefined;
|
|
168
|
+
route?: {
|
|
169
|
+
provider: string;
|
|
170
|
+
model: string;
|
|
171
|
+
} | null | undefined;
|
|
172
|
+
}>, event: import("@deepseek-ai/dsh-session").SessionEvent) => {
|
|
173
|
+
runs: Record<string, {
|
|
174
|
+
runId: string;
|
|
175
|
+
nativeSessionId: string;
|
|
176
|
+
provider: string;
|
|
177
|
+
model: string;
|
|
178
|
+
turn: number;
|
|
179
|
+
main: boolean;
|
|
180
|
+
finished: boolean;
|
|
181
|
+
settled: boolean;
|
|
182
|
+
models: Record<string, {
|
|
183
|
+
inputTokens?: number | undefined;
|
|
184
|
+
outputTokens?: number | undefined;
|
|
185
|
+
cacheReadTokens?: number | undefined;
|
|
186
|
+
cacheWriteTokens?: number | undefined;
|
|
187
|
+
incomplete?: ("inputTokens" | "outputTokens" | "cacheReadTokens" | "cacheWriteTokens")[] | undefined;
|
|
188
|
+
}>;
|
|
189
|
+
steps: number;
|
|
190
|
+
decodeTokens: number;
|
|
191
|
+
decodeMs: number;
|
|
192
|
+
modelMs: number;
|
|
193
|
+
context: {
|
|
194
|
+
model: string;
|
|
195
|
+
usedTokens: number;
|
|
196
|
+
contextWindow: number;
|
|
197
|
+
} | null;
|
|
198
|
+
revision?: number | undefined;
|
|
199
|
+
}>;
|
|
200
|
+
latest: string | null;
|
|
201
|
+
invalidated: boolean;
|
|
202
|
+
nextRevision?: number | undefined;
|
|
203
|
+
contextAfterRevision?: number | undefined;
|
|
204
|
+
route?: {
|
|
205
|
+
provider: string;
|
|
206
|
+
model: string;
|
|
207
|
+
} | null | undefined;
|
|
208
|
+
};
|
|
209
|
+
wire: {
|
|
210
|
+
viewSchema: z.ZodObject<{
|
|
211
|
+
models: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
212
|
+
inputTokens: z.ZodOptional<z.ZodNumber>;
|
|
213
|
+
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
214
|
+
cacheReadTokens: z.ZodOptional<z.ZodNumber>;
|
|
215
|
+
cacheWriteTokens: z.ZodOptional<z.ZodNumber>;
|
|
216
|
+
incomplete: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
217
|
+
inputTokens: "inputTokens";
|
|
218
|
+
outputTokens: "outputTokens";
|
|
219
|
+
cacheReadTokens: "cacheReadTokens";
|
|
220
|
+
cacheWriteTokens: "cacheWriteTokens";
|
|
221
|
+
}>>>;
|
|
222
|
+
}, z.core.$strict>>;
|
|
223
|
+
usage: z.ZodObject<{
|
|
224
|
+
inputTokens: z.ZodOptional<z.ZodNumber>;
|
|
225
|
+
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
226
|
+
cacheReadTokens: z.ZodOptional<z.ZodNumber>;
|
|
227
|
+
cacheWriteTokens: z.ZodOptional<z.ZodNumber>;
|
|
228
|
+
incomplete: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
229
|
+
inputTokens: "inputTokens";
|
|
230
|
+
outputTokens: "outputTokens";
|
|
231
|
+
cacheReadTokens: "cacheReadTokens";
|
|
232
|
+
cacheWriteTokens: "cacheWriteTokens";
|
|
233
|
+
}>>>;
|
|
234
|
+
}, z.core.$strict>;
|
|
235
|
+
turns: z.ZodNumber;
|
|
236
|
+
steps: z.ZodNumber;
|
|
237
|
+
decodeTokens: z.ZodNumber;
|
|
238
|
+
decodeMs: z.ZodNumber;
|
|
239
|
+
modelMs: z.ZodNumber;
|
|
240
|
+
incomplete: z.ZodBoolean;
|
|
241
|
+
context: z.ZodNullable<z.ZodObject<{
|
|
242
|
+
model: z.ZodString;
|
|
243
|
+
usedTokens: z.ZodNumber;
|
|
244
|
+
contextWindow: z.ZodNumber;
|
|
245
|
+
}, z.core.$strict>>;
|
|
246
|
+
}, z.core.$strict>;
|
|
247
|
+
view: typeof metricsView;
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ClaudeRunMetrics } from '../shared/metrics.js';
|
|
2
|
+
/** One collector per query, including resumed queries. Never reads native history. */
|
|
3
|
+
export declare class ClaudeMetricsCollector {
|
|
4
|
+
private readonly identity;
|
|
5
|
+
private readonly clock;
|
|
6
|
+
private readonly resumed;
|
|
7
|
+
private samples;
|
|
8
|
+
private active;
|
|
9
|
+
private windows;
|
|
10
|
+
private latest;
|
|
11
|
+
private finalModels;
|
|
12
|
+
private finished;
|
|
13
|
+
constructor(identity: Pick<ClaudeRunMetrics, 'runId' | 'nativeSessionId' | 'provider' | 'model' | 'turn' | 'main'>, clock?: () => number, resumed?: boolean);
|
|
14
|
+
observe(value: unknown): boolean;
|
|
15
|
+
snapshot(finished?: boolean): ClaudeRunMetrics;
|
|
16
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** Adapted from Norman-else/dsh-claude v0.1.65 (fe00e3af0b1ad03acc977b13b4d4ab805086f6da).
|
|
2
|
+
* Copyright (c) 2026 dsh-claude contributors. MIT; see upstream-LICENSE. */
|
|
3
|
+
/** Claude Code's own permission modes as the session's access control.
|
|
4
|
+
*
|
|
5
|
+
* DSH's access selector offers three sandbox modes, each bundled with an
|
|
6
|
+
* approval policy, and neither the table nor the selector is something a
|
|
7
|
+
* plugin can extend. Claude Code has more modes than that, and two of them
|
|
8
|
+
* (`default`, `acceptEdits`) sit on the same DSH sandbox mode, so the
|
|
9
|
+
* session's Claude mode is kept here, by this plugin, and the DSH knobs are
|
|
10
|
+
* driven from it rather than the other way round.
|
|
11
|
+
*
|
|
12
|
+
* The fold still honours DSH: a sandbox mode switched natively (the
|
|
13
|
+
* `/permission` command, another client) after the plugin's choice no
|
|
14
|
+
* longer matches what that choice needs, and the sandbox wins. */
|
|
15
|
+
/** Every mode the selector offers, in the order it lists them: tightest
|
|
16
|
+
* first. `auto` hands each ask to Claude Code's own classifier and is a
|
|
17
|
+
* per-model capability, so the selector greys it out where the catalog says
|
|
18
|
+
* the session's model lacks it. */
|
|
19
|
+
export declare const CLAUDE_PERMISSION_MODES: readonly ["plan", "default", "acceptEdits", "dontAsk", "auto", "bypassPermissions"];
|
|
20
|
+
export type ClaudePermissionMode = typeof CLAUDE_PERMISSION_MODES[number];
|
|
21
|
+
export declare function isClaudePermissionMode(value: unknown): value is ClaudePermissionMode;
|
|
22
|
+
export type DshSandboxMode = 'read-only' | 'workspace-write' | 'danger-full-access';
|
|
23
|
+
/** The DSH sandbox mode a Claude mode is carried on. The Host's preset table
|
|
24
|
+
* names its presets after these modes, so the same string selects the preset. */
|
|
25
|
+
export declare const SANDBOX_BY_CLAUDE_MODE: Readonly<Record<ClaudePermissionMode, DshSandboxMode>>;
|
|
26
|
+
/** The closest Claude mode for a sandbox mode chosen without this plugin's
|
|
27
|
+
* selector: what the session runs under until the selector is used. */
|
|
28
|
+
export declare const CLAUDE_MODE_BY_SANDBOX: Readonly<Record<DshSandboxMode, ClaudePermissionMode>>;
|
|
29
|
+
/** The session's effective sandbox mode: the newest `sandbox/mode` event,
|
|
30
|
+
* undefined when there is none, and `null` for a newest event this plugin
|
|
31
|
+
* cannot read (which fails safe rather than falling back to an older one). */
|
|
32
|
+
export declare function sandboxModeOf(events: readonly {
|
|
33
|
+
type: string;
|
|
34
|
+
data: unknown;
|
|
35
|
+
}[]): DshSandboxMode | null | undefined;
|
|
36
|
+
/** The Claude mode a session runs its next turn under.
|
|
37
|
+
*
|
|
38
|
+
* `chosen` is what the plugin's selector recorded; it stands for as long as
|
|
39
|
+
* the session's sandbox mode is the one it needs. A session that never chose
|
|
40
|
+
* runs the sandbox's closest mode, and one with no sandbox at all, or an
|
|
41
|
+
* unreadable one, runs `plan`: the mode that can do the least. */
|
|
42
|
+
export declare function claudePermissionMode(events: readonly {
|
|
43
|
+
type: string;
|
|
44
|
+
data: unknown;
|
|
45
|
+
}[], chosen?: ClaudePermissionMode): ClaudePermissionMode;
|
|
46
|
+
/** Which access control a Claude session shows and obeys: the Host's own
|
|
47
|
+
* three-preset selector with the sandbox mapping alone (`native`), or this
|
|
48
|
+
* plugin's selector over Claude Code's modes with the default mode and the
|
|
49
|
+
* creation-time alignment (`plugin`). */
|
|
50
|
+
export declare const CLAUDE_PERMISSION_SELECTORS: readonly ["plugin", "native"];
|
|
51
|
+
export type ClaudePermissionSelector = typeof CLAUDE_PERMISSION_SELECTORS[number];
|
|
52
|
+
export declare const DEFAULT_CLAUDE_PERMISSION_SELECTOR: ClaudePermissionSelector;
|
|
53
|
+
export declare function isClaudePermissionSelector(value: unknown): value is ClaudePermissionSelector;
|
|
54
|
+
/** What the client shows for one session. */
|
|
55
|
+
export interface ClaudePermissionModeView {
|
|
56
|
+
readonly mode: ClaudePermissionMode;
|
|
57
|
+
/** A turn is in flight; the mode it started under is the mode it keeps. */
|
|
58
|
+
readonly locked: boolean;
|
|
59
|
+
/** Whether the session's model can run `auto`, when the catalog knows the
|
|
60
|
+
* model; absent while it does not, and the selector offers the mode. */
|
|
61
|
+
readonly autoSupported?: boolean;
|
|
62
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export interface SkillSummaryProjectionInput {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
whenToUse?: string;
|
|
5
|
+
invocation: {
|
|
6
|
+
modelInvocable: boolean;
|
|
7
|
+
userInvocable?: boolean;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface SkillDefinitionProjectionInput extends SkillSummaryProjectionInput {
|
|
11
|
+
content: string;
|
|
12
|
+
resourceBase?: SkillResourceBaseProjectionInput;
|
|
13
|
+
}
|
|
14
|
+
export type SkillResourceBaseProjectionInput = {
|
|
15
|
+
kind: 'directory';
|
|
16
|
+
path: string;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'url';
|
|
19
|
+
url: string;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'opaque';
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
export interface SkillsProjectionApi {
|
|
25
|
+
snapshot(options?: {
|
|
26
|
+
cwd?: string;
|
|
27
|
+
scope?: object;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
skills: readonly SkillSummaryProjectionInput[];
|
|
30
|
+
complete: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
get(name: string, options?: {
|
|
33
|
+
cwd?: string;
|
|
34
|
+
scope?: object;
|
|
35
|
+
}): Promise<SkillDefinitionProjectionInput | undefined>;
|
|
36
|
+
}
|
|
37
|
+
export interface ProjectedClaudeSkill {
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
content: string;
|
|
41
|
+
invocation: {
|
|
42
|
+
modelInvocable: boolean;
|
|
43
|
+
userInvocable?: boolean;
|
|
44
|
+
};
|
|
45
|
+
whenToUse?: string;
|
|
46
|
+
resourceBase?: SkillResourceBaseProjectionInput;
|
|
47
|
+
}
|
|
48
|
+
export interface SkillProjectionResult {
|
|
49
|
+
skills: ProjectedClaudeSkill[];
|
|
50
|
+
skipped: Array<{
|
|
51
|
+
name: string;
|
|
52
|
+
reason: 'not-model-invocable' | 'invalid-summary' | 'unavailable' | 'invalid-definition';
|
|
53
|
+
}>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Load the current workspace catalog and full bodies, failing closed when
|
|
57
|
+
* discovery is incomplete. The shared registry applies management policies
|
|
58
|
+
* before advertising or loading a skill; invocation controls apply afterwards.
|
|
59
|
+
*/
|
|
60
|
+
export declare function projectSkillsForClaude(registry: SkillsProjectionApi, cwd: string, scope?: object): Promise<SkillProjectionResult>;
|
|
61
|
+
export interface McpServerProjectionInput {
|
|
62
|
+
name: string;
|
|
63
|
+
serverName: string;
|
|
64
|
+
transport: string;
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
command: string;
|
|
67
|
+
args: readonly string[];
|
|
68
|
+
cwd?: string;
|
|
69
|
+
url?: string;
|
|
70
|
+
envRefs: Readonly<Record<string, string>>;
|
|
71
|
+
headerRefs: Readonly<Record<string, string>>;
|
|
72
|
+
}
|
|
73
|
+
export interface McpLauncherSpec {
|
|
74
|
+
cwd: string;
|
|
75
|
+
command: string;
|
|
76
|
+
args: string[];
|
|
77
|
+
useBundledNode: boolean;
|
|
78
|
+
resolveFromPath?: boolean;
|
|
79
|
+
}
|
|
80
|
+
export type ProjectedClaudeMcpServer = {
|
|
81
|
+
serverName: string;
|
|
82
|
+
type: 'stdio';
|
|
83
|
+
command: string;
|
|
84
|
+
args: string[];
|
|
85
|
+
envRefs: Record<string, string>;
|
|
86
|
+
launcher?: McpLauncherSpec;
|
|
87
|
+
} | {
|
|
88
|
+
serverName: string;
|
|
89
|
+
type: 'http';
|
|
90
|
+
url: string;
|
|
91
|
+
headerRefs: Record<string, string>;
|
|
92
|
+
};
|
|
93
|
+
export type McpSkipReason = 'disabled' | 'unsupported-transport' | 'unsupported-working-directory' | 'unsupported-launch' | 'managed-server' | 'credential-reference' | 'invalid-credential-reference' | 'credential-unavailable' | 'invalid-launch' | 'duplicate-server-name';
|
|
94
|
+
export interface McpProjectionResult {
|
|
95
|
+
servers: ProjectedClaudeMcpServer[];
|
|
96
|
+
skipped: Array<{
|
|
97
|
+
serverName: string;
|
|
98
|
+
reason: McpSkipReason;
|
|
99
|
+
}>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Project independently launchable stdio or reachable HTTP MCP records. This function
|
|
103
|
+
* retains only reference names; the Host resolves values for one child process.
|
|
104
|
+
*/
|
|
105
|
+
export declare function projectMcpForClaude(records: readonly McpServerProjectionInput[], cwd: string): McpProjectionResult;
|
|
106
|
+
export interface ClaudeMcpRuntimeProjection {
|
|
107
|
+
servers: Array<{
|
|
108
|
+
serverName: string;
|
|
109
|
+
type: 'stdio';
|
|
110
|
+
command: string;
|
|
111
|
+
args: string[];
|
|
112
|
+
env?: Record<string, string>;
|
|
113
|
+
launcher?: McpLauncherSpec;
|
|
114
|
+
} | {
|
|
115
|
+
serverName: string;
|
|
116
|
+
type: 'http';
|
|
117
|
+
url: string;
|
|
118
|
+
headers?: Record<string, string>;
|
|
119
|
+
}>;
|
|
120
|
+
environment: Record<string, string>;
|
|
121
|
+
skipped: McpProjectionResult['skipped'];
|
|
122
|
+
}
|
|
123
|
+
/** Resolve MCP refs into parent-process variables and persist only placeholders. */
|
|
124
|
+
export declare function prepareClaudeMcpRuntime(projection: McpProjectionResult, resolveReference: (name: string) => Promise<string | undefined>): Promise<ClaudeMcpRuntimeProjection>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ToolSchema } from '@deepseek-ai/dsh-llm';
|
|
2
|
+
import type { ClaudeResourceStatus } from '../shared/types.js';
|
|
3
|
+
import type { McpServerProjectionInput, SkillProjectionResult } from './projection.js';
|
|
4
|
+
/** Availability is derived from the current Host view, never from launchability or a name denylist. */
|
|
5
|
+
export declare function resourceStatus(skills: SkillProjectionResult, servers: readonly McpServerProjectionInput[], tools: readonly ToolSchema[], runtime?: readonly {
|
|
6
|
+
serverName: string;
|
|
7
|
+
runtimeState: string;
|
|
8
|
+
}[], disabledSkills?: readonly string[]): ClaudeResourceStatus[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Host-only route resolution. No value returned here may be sent over Remote. */
|
|
2
|
+
export interface ClaudeSelection {
|
|
3
|
+
provider: string;
|
|
4
|
+
model: string;
|
|
5
|
+
reasoningEffort?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ClaudeRequestHeader {
|
|
8
|
+
config: ClaudeSelection;
|
|
9
|
+
adapterDefaults?: {
|
|
10
|
+
reasoningEffort?: boolean;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface ClaudeRoute extends ClaudeSelection {
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
apiKey: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ClaudeRouteServices {
|
|
18
|
+
directory(): readonly {
|
|
19
|
+
provider: string;
|
|
20
|
+
settingsNs: string;
|
|
21
|
+
settingsPath: readonly string[];
|
|
22
|
+
defaultBaseURL?: string;
|
|
23
|
+
}[];
|
|
24
|
+
settings(): readonly {
|
|
25
|
+
ns: string;
|
|
26
|
+
value: unknown;
|
|
27
|
+
}[];
|
|
28
|
+
credential(ref: string): Promise<string | undefined>;
|
|
29
|
+
managedRoute?(provider: string, model: string): Promise<{
|
|
30
|
+
api?: string;
|
|
31
|
+
baseUrl?: string;
|
|
32
|
+
apiKey?: string;
|
|
33
|
+
} | undefined>;
|
|
34
|
+
managedCredential?(provider: string, model: string): Promise<string | undefined>;
|
|
35
|
+
}
|
|
36
|
+
export declare function selectedClaudeModel(projection: {
|
|
37
|
+
pending?: ClaudeSelection | null;
|
|
38
|
+
lastUsed?: ClaudeSelection | null;
|
|
39
|
+
} | undefined, fallback: () => ClaudeSelection, loggedHeader?: ClaudeRequestHeader): ClaudeSelection;
|
|
40
|
+
export declare function resolveClaudeRoute(selection: ClaudeSelection, services: ClaudeRouteServices): Promise<ClaudeRoute>;
|
|
41
|
+
/** Hold a suffix until enough bytes arrive to redact secrets spanning chunks. */
|
|
42
|
+
export declare class ClaudeSafeOutput {
|
|
43
|
+
private readonly secrets;
|
|
44
|
+
private raw;
|
|
45
|
+
private finished;
|
|
46
|
+
constructor(secrets: readonly string[]);
|
|
47
|
+
append(text: string): void;
|
|
48
|
+
finish(): void;
|
|
49
|
+
/** Create an independent buffer with the same redaction set for one stream block. */
|
|
50
|
+
fork(): ClaudeSafeOutput;
|
|
51
|
+
snapshot(): string;
|
|
52
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as nodeFs from 'node:fs/promises';
|
|
2
|
+
export declare const CLAUDE_CODE_PACKAGE = "@anthropic-ai/claude-code";
|
|
3
|
+
export declare const CLAUDE_CODE_VERSION = "2.1.309";
|
|
4
|
+
export declare const CLAUDE_CODE_REGISTRY = "https://registry.npmmirror.com";
|
|
5
|
+
type FsPromises = Pick<typeof nodeFs, 'mkdir' | 'writeFile' | 'readFile' | 'rename' | 'rm' | 'lstat' | 'open' | 'chmod' | 'realpath' | 'link' | 'readdir'>;
|
|
6
|
+
export type ProcessRunOptions = {
|
|
7
|
+
cwd: string;
|
|
8
|
+
env: NodeJS.ProcessEnv;
|
|
9
|
+
windowsHide: true;
|
|
10
|
+
};
|
|
11
|
+
export type ProcessRunResult = {
|
|
12
|
+
code: number;
|
|
13
|
+
stdout?: string;
|
|
14
|
+
stderr?: string;
|
|
15
|
+
};
|
|
16
|
+
export type ProcessRunner = (command: string, args: string[], options: ProcessRunOptions) => Promise<ProcessRunResult>;
|
|
17
|
+
export type BundledPnpmRuntimeOptions = {
|
|
18
|
+
/** Electron's process.resourcesPath. When present, only its bundled pnpm is considered. */
|
|
19
|
+
resourcesPath?: string;
|
|
20
|
+
/** Repository root used to probe development copies of the bundled pnpm. */
|
|
21
|
+
projectRoot?: string;
|
|
22
|
+
electron?: boolean;
|
|
23
|
+
executable?: string;
|
|
24
|
+
existsSync?: (path: string) => boolean;
|
|
25
|
+
};
|
|
26
|
+
export type BundledPnpmRuntime = {
|
|
27
|
+
executable: string;
|
|
28
|
+
pnpmPath: string;
|
|
29
|
+
};
|
|
30
|
+
/** Resolve only application-owned pnpm. This deliberately has no PATH/system fallback. */
|
|
31
|
+
export declare function resolveBundledPnpmRuntime(options?: BundledPnpmRuntimeOptions): BundledPnpmRuntime;
|
|
32
|
+
export type ClaudeRuntimeStatus = {
|
|
33
|
+
installed: boolean;
|
|
34
|
+
version?: string;
|
|
35
|
+
executablePath?: string;
|
|
36
|
+
previousVersion?: string;
|
|
37
|
+
};
|
|
38
|
+
export type ClaudeRuntimeManagerOptions = {
|
|
39
|
+
/** Dedicated plugin-owned data directory, never the user's Claude home directory. */
|
|
40
|
+
dataDir: string;
|
|
41
|
+
platform?: NodeJS.Platform;
|
|
42
|
+
pnpm?: BundledPnpmRuntime;
|
|
43
|
+
fs?: FsPromises;
|
|
44
|
+
run?: ProcessRunner;
|
|
45
|
+
env?: NodeJS.ProcessEnv;
|
|
46
|
+
executable?: string;
|
|
47
|
+
createId?: () => string;
|
|
48
|
+
/** A successful probe or any error other than ESRCH treats the owner as live. */
|
|
49
|
+
processProbe?: (pid: number) => void | Promise<void>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Manages a plugin-private Claude Code install. Each install is staged beside
|
|
53
|
+
* the active version; current.json is the sole activation pointer. A failed
|
|
54
|
+
* candidate never replaces the active installation.
|
|
55
|
+
*/
|
|
56
|
+
export declare class ClaudeRuntimeManager {
|
|
57
|
+
#private;
|
|
58
|
+
readonly dataDir: string;
|
|
59
|
+
readonly configDir: string;
|
|
60
|
+
readonly homeDir: string;
|
|
61
|
+
readonly storeDir: string;
|
|
62
|
+
constructor(options: ClaudeRuntimeManagerOptions);
|
|
63
|
+
/** Return the active CLI's absolute path without consulting PATH or a user install. */
|
|
64
|
+
getExecutablePath(): Promise<string | undefined>;
|
|
65
|
+
status(): Promise<ClaudeRuntimeStatus>;
|
|
66
|
+
/** Install the pinned CLI into a private candidate and atomically activate it. */
|
|
67
|
+
installOrUpdate(): Promise<ClaudeRuntimeStatus>;
|
|
68
|
+
/** Atomically reactivate the previous successfully installed generation. */
|
|
69
|
+
rollback(): Promise<ClaudeRuntimeStatus>;
|
|
70
|
+
/** Remove managed executables only. Configuration and native transcripts survive reinstall. */
|
|
71
|
+
uninstall(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Build an isolated process environment for a CLI turn. Existing Anthropic
|
|
74
|
+
* routing variables are stripped so the host must supply the current turn's
|
|
75
|
+
* endpoint/model/credential explicitly in `turnEnvironment`.
|
|
76
|
+
*/
|
|
77
|
+
getCliEnvironment(turnEnvironment?: Record<string, string | undefined>, inherited?: NodeJS.ProcessEnv, ephemeralMcpEnvironment?: Record<string, string>, configuredEnvironment?: Record<string, string>): NodeJS.ProcessEnv;
|
|
78
|
+
}
|
|
79
|
+
export declare function createClaudeRuntimeManager(options: ClaudeRuntimeManagerOptions): ClaudeRuntimeManager;
|
|
80
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createSdkMcpServer, type CanUseTool, type Options, type Query, type SDKUserMessage } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
3
|
+
import { type GenerateOptions, type ToolSchema } from '@deepseek-ai/dsh-llm';
|
|
4
|
+
import type { SubprocessHandle, SubprocessRuntime } from '@deepseek-ai/dsh-subprocess';
|
|
5
|
+
import type { ApprovalService } from '@deepseek-ai/dsh-user-approval';
|
|
6
|
+
import { type ClaudeSessionBinding } from './session-binding.js';
|
|
7
|
+
/** Preserve exact JSON schemas, rather than approximating them with permissive Zod objects. */
|
|
8
|
+
export declare function createHostToolBridge(agent: Agent, schemas: readonly ToolSchema[], signal: AbortSignal, source: {
|
|
9
|
+
provider: string;
|
|
10
|
+
model: string;
|
|
11
|
+
}, state?: {
|
|
12
|
+
concluded: boolean;
|
|
13
|
+
delivered?: (keys: string[]) => Promise<void>;
|
|
14
|
+
drain?: () => Promise<unknown>;
|
|
15
|
+
}, currentSchemas?: () => readonly ToolSchema[]): ReturnType<typeof createSdkMcpServer>;
|
|
16
|
+
/** Resumed turns also receive current DSH system-message updates. */
|
|
17
|
+
export declare function sdkSystemPrompt(request: GenerateOptions): string;
|
|
18
|
+
/** Keep an explicit output cap; never silently discard unsupported sampling controls. */
|
|
19
|
+
export declare function sdkGenerationEnvironment(request: GenerateOptions): NodeJS.ProcessEnv;
|
|
20
|
+
/** The Host owns approval UI and audit; bridge execution owns its own policy checks. */
|
|
21
|
+
export declare function hostToolApproval(agent: Agent, approval: Pick<ApprovalService, 'request'>, signal: AbortSignal, recordCall: (id: string, name: string, input: Record<string, unknown>) => Promise<void>): CanUseTool;
|
|
22
|
+
/** Own the full process tree through DSH, including SDK cancellation and stderr. */
|
|
23
|
+
export declare function managedSdkSpawner(subprocess: SubprocessRuntime, onSpawn: (handle: SubprocessHandle) => void, stderr: (text: string) => void, ownerSignal?: AbortSignal): NonNullable<Options['spawnClaudeCodeProcess']>;
|
|
24
|
+
export declare function sdkInput(agent: Agent, request: GenerateOptions, binding: ClaudeSessionBinding, signal: AbortSignal): Promise<{
|
|
25
|
+
content: Exclude<SDKUserMessage['message']['content'], string>;
|
|
26
|
+
submitted: string[];
|
|
27
|
+
}>;
|
|
28
|
+
export declare function startSdkQuery(options: Options, content: SDKUserMessage['message']['content'], uuid?: string): Query;
|
|
29
|
+
export type { CanUseTool, Query, Options };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Independent from CLI generations and disposable resource projections. */
|
|
2
|
+
export interface ClaudeSessionBinding {
|
|
3
|
+
schema: 1;
|
|
4
|
+
nativeId: string;
|
|
5
|
+
cwd: string;
|
|
6
|
+
initialized: boolean;
|
|
7
|
+
submitted: string[];
|
|
8
|
+
pending?: {
|
|
9
|
+
uuid: string;
|
|
10
|
+
keys: string[];
|
|
11
|
+
};
|
|
12
|
+
state: 'idle' | 'submitted' | 'running' | 'failed' | 'stopped';
|
|
13
|
+
}
|
|
14
|
+
export declare class ClaudeSessionBindings {
|
|
15
|
+
private readonly configDir;
|
|
16
|
+
constructor(configDir: string);
|
|
17
|
+
private file;
|
|
18
|
+
load(id: string, cwd: string): Promise<{
|
|
19
|
+
binding: ClaudeSessionBinding;
|
|
20
|
+
recovery?: string;
|
|
21
|
+
}>;
|
|
22
|
+
save(id: string, binding: ClaudeSessionBinding): Promise<void>;
|
|
23
|
+
private transcript;
|
|
24
|
+
}
|
|
25
|
+
export declare function inputKey(value: unknown): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { Session } from '@deepseek-ai/dsh-session';
|
|
3
|
+
/** Keep official delegation, route policy and lifecycle, with plugin-owned names. */
|
|
4
|
+
export declare function registerClaudeSubagentTool(ctx: Context, session: Session): Promise<void>;
|
|
5
|
+
/** Mount into each Agent scope so official session-sampled selection stays local. */
|
|
6
|
+
export declare function mountClaudeSubagentTools(ctx: Context): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
2
|
+
import { type ToolCallId } from '@deepseek-ai/dsh-llm';
|
|
3
|
+
/** CLI-owned tools still require the complete DSH durable presentation lifecycle. */
|
|
4
|
+
export declare function appendClaudeToolCall(agent: Agent, call: {
|
|
5
|
+
callId: ToolCallId;
|
|
6
|
+
name: string;
|
|
7
|
+
arguments: string;
|
|
8
|
+
}, source: {
|
|
9
|
+
provider: string;
|
|
10
|
+
model: string;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
/** A stopped SDK may omit its final tool response; preserve the unknown outcome without replay. */
|
|
13
|
+
export declare function settleClaudeToolCalls(agent: Agent): Promise<void>;
|