@rezti/dsh-rez-suite 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/LICENSE +13 -0
- package/README.md +9 -0
- package/README.zh.md +11 -0
- package/cordis.patch.yml +68 -0
- package/lib/client.d.ts +7479 -0
- package/lib/client.js +1190 -0
- package/lib/index.d.ts +1726 -0
- package/lib/index.js +7659 -0
- package/lib/style.css +309 -0
- package/package.json +103 -0
- package/servers/fs-mcp-server.mjs +71 -0
- package/servers/sqlite-mcp-server.mjs +50 -0
- package/src/client/api.ts +75 -0
- package/src/client/css-modules.d.ts +4 -0
- package/src/client/index.ts +45 -0
- package/src/client/locales.ts +176 -0
- package/src/client/mount.tsx +97 -0
- package/src/client/panel/AuditTab.tsx +87 -0
- package/src/client/panel/ConfigTab.tsx +223 -0
- package/src/client/panel/RezPanel.tsx +50 -0
- package/src/client/panel/StatusTab.tsx +66 -0
- package/src/client/panel/controller.ts +42 -0
- package/src/client/panel/helpers.ts +21 -0
- package/src/client/panel/panel.module.css +316 -0
- package/src/client/sidebar-entry.ts +80 -0
- package/src/index.ts +166 -0
- package/src/mcp-host.ts +418 -0
- package/src/presets.ts +125 -0
- package/src/protocol.ts +133 -0
- package/src/routes.ts +191 -0
- package/src/store.ts +152 -0
- package/src/token-manager.ts +252 -0
- package/src/tools.ts +167 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,1726 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cosmokit@1.8.2/node_modules/@deepseek-ai/cosmokit/lib/types/types.d.ts
|
|
2
|
+
declare function isArrayBufferLike(value: any): value is ArrayBufferLike;
|
|
3
|
+
declare function isArrayBufferSource(value: any): value is Binary.Source;
|
|
4
|
+
/** Binary source detection and base64/hex conversion helpers. */
|
|
5
|
+
declare namespace Binary {
|
|
6
|
+
type Source<T extends ArrayBufferLike = ArrayBufferLike> = T | ArrayBufferView<T>;
|
|
7
|
+
const is: typeof isArrayBufferLike;
|
|
8
|
+
const isSource: typeof isArrayBufferSource;
|
|
9
|
+
function fromSource<T extends ArrayBufferLike>(source: Source<T>): T;
|
|
10
|
+
function toBase64(source: Source): string;
|
|
11
|
+
function fromBase64(source: string): ArrayBuffer | Uint8Array<ArrayBuffer>;
|
|
12
|
+
function toHex(source: Source): string;
|
|
13
|
+
function fromHex(source: string): ArrayBuffer;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cosmokit@1.8.2/node_modules/@deepseek-ai/cosmokit/lib/types/misc.d.ts
|
|
17
|
+
/** String/symbol keyed dictionary type. */
|
|
18
|
+
type Dict<T = any, K extends string | symbol = string> = { [key in K]: T };
|
|
19
|
+
/** Wrap a value in `Promise`, preserving the resolved type of existing promises. */
|
|
20
|
+
type Promisify<T> = Promise<T extends Promise<infer S> ? S : T>;
|
|
21
|
+
/** Accept a value or promise unless the value type is already promise-like. */
|
|
22
|
+
type Awaitable<T> = [T] extends [Promise<unknown>] ? T : T | Promise<T>;
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
|
|
25
|
+
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
26
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
27
|
+
/** The Standard properties. */
|
|
28
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
29
|
+
}
|
|
30
|
+
declare namespace StandardTypedV1 {
|
|
31
|
+
/** The Standard Typed properties interface. */
|
|
32
|
+
interface Props<Input = unknown, Output = Input> {
|
|
33
|
+
/** The version number of the standard. */
|
|
34
|
+
readonly version: 1;
|
|
35
|
+
/** The vendor name of the schema library. */
|
|
36
|
+
readonly vendor: string;
|
|
37
|
+
/** Inferred types associated with the schema. */
|
|
38
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
39
|
+
}
|
|
40
|
+
/** The Standard Typed types interface. */
|
|
41
|
+
interface Types<Input = unknown, Output = Input> {
|
|
42
|
+
/** The input type of the schema. */
|
|
43
|
+
readonly input: Input;
|
|
44
|
+
/** The output type of the schema. */
|
|
45
|
+
readonly output: Output;
|
|
46
|
+
}
|
|
47
|
+
/** Infers the input type of a Standard Typed. */
|
|
48
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
49
|
+
/** Infers the output type of a Standard Typed. */
|
|
50
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
51
|
+
}
|
|
52
|
+
/** The Standard Schema interface. */
|
|
53
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
54
|
+
/** The Standard Schema properties. */
|
|
55
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
56
|
+
}
|
|
57
|
+
declare namespace StandardSchemaV1 {
|
|
58
|
+
/** The Standard Schema properties interface. */
|
|
59
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
60
|
+
/** Validates unknown input values. */
|
|
61
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
62
|
+
}
|
|
63
|
+
/** The result interface of the validate function. */
|
|
64
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
65
|
+
/** The result interface if validation succeeds. */
|
|
66
|
+
interface SuccessResult<Output> {
|
|
67
|
+
/** The typed output value. */
|
|
68
|
+
readonly value: Output;
|
|
69
|
+
/** A falsy value for `issues` indicates success. */
|
|
70
|
+
readonly issues?: undefined;
|
|
71
|
+
}
|
|
72
|
+
interface Options {
|
|
73
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
74
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
75
|
+
}
|
|
76
|
+
/** The result interface if validation fails. */
|
|
77
|
+
interface FailureResult {
|
|
78
|
+
/** The issues of failed validation. */
|
|
79
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
80
|
+
}
|
|
81
|
+
/** The issue interface of the failure output. */
|
|
82
|
+
interface Issue {
|
|
83
|
+
/** The error message of the issue. */
|
|
84
|
+
readonly message: string;
|
|
85
|
+
/** The path of the issue, if any. */
|
|
86
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
87
|
+
}
|
|
88
|
+
/** The path segment interface of the issue. */
|
|
89
|
+
interface PathSegment {
|
|
90
|
+
/** The key representing a path segment. */
|
|
91
|
+
readonly key: PropertyKey;
|
|
92
|
+
}
|
|
93
|
+
/** The Standard types interface. */
|
|
94
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
95
|
+
/** Infers the input type of a Standard. */
|
|
96
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
97
|
+
/** Infers the output type of a Standard. */
|
|
98
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
99
|
+
}
|
|
100
|
+
/** The Standard JSON Schema interface. */
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cordis@4.0.1_@deepseek-ai+cordis-plugin-include@1.0.6_@deepseek-ai+cordis-plugin-loader@1.0.2/node_modules/@deepseek-ai/cordis/lib/types/utils.d.ts
|
|
103
|
+
/** Ordered collection of disposable values with O(1) deletion by value. */
|
|
104
|
+
declare class DisposableList<T extends WeakKey> {
|
|
105
|
+
private sn;
|
|
106
|
+
private map;
|
|
107
|
+
private weak;
|
|
108
|
+
get length(): number;
|
|
109
|
+
push(value: T): () => boolean;
|
|
110
|
+
delete(value: T): boolean;
|
|
111
|
+
clear(): T[];
|
|
112
|
+
[Symbol.iterator](): MapIterator<T>;
|
|
113
|
+
}
|
|
114
|
+
/** Shared symbols used to avoid public property-name collisions. */
|
|
115
|
+
declare const symbols: {
|
|
116
|
+
shadow: symbol;
|
|
117
|
+
receiver: symbol;
|
|
118
|
+
original: symbol;
|
|
119
|
+
metadata: symbol;
|
|
120
|
+
initHooks: symbol;
|
|
121
|
+
checkProto: symbol;
|
|
122
|
+
effect: typeof Context.effect;
|
|
123
|
+
filter: typeof Context.filter;
|
|
124
|
+
isolate: typeof Context.isolate;
|
|
125
|
+
intercept: typeof Context.intercept;
|
|
126
|
+
init: typeof Service.init;
|
|
127
|
+
check: typeof Service.check;
|
|
128
|
+
config: typeof Service.config;
|
|
129
|
+
invoke: typeof Service.invoke;
|
|
130
|
+
extend: typeof Service.extend;
|
|
131
|
+
tracker: typeof Service.tracker;
|
|
132
|
+
resolveConfig: typeof Service.resolveConfig;
|
|
133
|
+
};
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cordis@4.0.1_@deepseek-ai+cordis-plugin-include@1.0.6_@deepseek-ai+cordis-plugin-loader@1.0.2/node_modules/@deepseek-ai/cordis/lib/types/registry.d.ts
|
|
136
|
+
/**
|
|
137
|
+
* Service dependency declaration accepted by plugins and the `@Inject`
|
|
138
|
+
* decorator.
|
|
139
|
+
*
|
|
140
|
+
* Array form requests services without intercept config. Object form maps each
|
|
141
|
+
* service name to optional intercept config for the plugin context.
|
|
142
|
+
*/
|
|
143
|
+
type Inject<M = Dict> = (keyof M)[] | { [K in keyof M]?: M[K] };
|
|
144
|
+
/** Context keys that correspond to services with typed intercept config. */
|
|
145
|
+
type InjectKey = keyof { [K in keyof Context & string as Context[K] extends {
|
|
146
|
+
[symbols.config]: any;
|
|
147
|
+
} ? K : never]: any };
|
|
148
|
+
/**
|
|
149
|
+
* Decorator for declaring service dependencies on classes or class methods.
|
|
150
|
+
*
|
|
151
|
+
* On classes it contributes to the plugin's static `inject` map. On methods it
|
|
152
|
+
* delays the method call until the declared services are available.
|
|
153
|
+
*/
|
|
154
|
+
/**
|
|
155
|
+
* @param name — the required service name.
|
|
156
|
+
* @param config — optional intercept config applied for that service.
|
|
157
|
+
* @returns the class or method decorator.
|
|
158
|
+
*/
|
|
159
|
+
declare function Inject<K extends InjectKey>(name: K, config?: Context[K] extends {
|
|
160
|
+
[symbols.config]: infer T;
|
|
161
|
+
} ? T : never): (value: any, decorator: ClassDecoratorContext<any> | ClassMethodDecoratorContext<any>) => void;
|
|
162
|
+
/** Utilities for normalizing plugin dependency declarations. */
|
|
163
|
+
declare namespace Inject {
|
|
164
|
+
/**
|
|
165
|
+
* Convert array/object/class-inherited inject metadata into a plain map.
|
|
166
|
+
*
|
|
167
|
+
* @param inject — the declaration to normalize; `null`/`undefined` add nothing.
|
|
168
|
+
* @param result — the map to fill (service name → intercept config or `null`).
|
|
169
|
+
* @returns `result`.
|
|
170
|
+
*/
|
|
171
|
+
function resolve(inject: Inject | null | undefined, result?: Dict): Dict;
|
|
172
|
+
}
|
|
173
|
+
/** Supported plugin entrypoint shapes. */
|
|
174
|
+
type Plugin<T = any> = Plugin.Function<T> | Plugin.Constructor<T> | Plugin.Object<T>;
|
|
175
|
+
/** Types associated with plugin entrypoints and runtime records. */
|
|
176
|
+
declare namespace Plugin {
|
|
177
|
+
/** Shared metadata understood by the plugin registry and related tooling. */
|
|
178
|
+
interface Base<T = any> {
|
|
179
|
+
/** Display name used for fiber diagnostics and logger names. */
|
|
180
|
+
name?: string;
|
|
181
|
+
/** Standard-schema validator applied to config before the plugin starts. */
|
|
182
|
+
Config?: StandardSchemaV1<any, T>;
|
|
183
|
+
/** Services the plugin requires; it only loads while all are available. */
|
|
184
|
+
inject?: Inject;
|
|
185
|
+
/** Service name(s) the plugin provides (read by `Service` and by loaders). */
|
|
186
|
+
provide?: string | string[];
|
|
187
|
+
/** Service names whose intercept config the plugin declares it consumes. */
|
|
188
|
+
intercept?: Dict<boolean>;
|
|
189
|
+
}
|
|
190
|
+
interface Transform<S, T> {
|
|
191
|
+
/** Marks the transform object as a schema/config transform. */
|
|
192
|
+
schema?: true;
|
|
193
|
+
/** Convert user-facing config to runtime config. */
|
|
194
|
+
Config: (config: S) => T;
|
|
195
|
+
}
|
|
196
|
+
/** Function plugin called with `(ctx, config)`. */
|
|
197
|
+
interface Function<T = any> extends Base<T> {
|
|
198
|
+
(ctx: Context, config: T): any;
|
|
199
|
+
}
|
|
200
|
+
/** Class plugin constructed with `(ctx, config)`. */
|
|
201
|
+
interface Constructor<T = any> extends Base<T> {
|
|
202
|
+
new (ctx: Context, config: T): any;
|
|
203
|
+
}
|
|
204
|
+
/** Object plugin with an `apply(ctx, config)` method. */
|
|
205
|
+
interface Object<T = any> extends Base<T> {
|
|
206
|
+
apply(ctx: Context, config: T): any;
|
|
207
|
+
}
|
|
208
|
+
/** Mutable registry record shared by all fibers of one plugin callback. */
|
|
209
|
+
interface Runtime {
|
|
210
|
+
/** Display name copied from the first registered plugin shape. */
|
|
211
|
+
name?: string;
|
|
212
|
+
/** Every live fiber of this plugin (one per `ctx.plugin()` call). */
|
|
213
|
+
fibers: DisposableList<Fiber>;
|
|
214
|
+
/** The executable entrypoint all fibers share (registry identity key). */
|
|
215
|
+
callback: globalThis.Function;
|
|
216
|
+
/** Standard-schema validator applied to each fiber's config. */
|
|
217
|
+
Config?: StandardSchemaV1;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
type Spread<T> = undefined extends T ? [config?: T] : [config: T];
|
|
221
|
+
type GetPluginParameters<P> = P extends ((ctx: Context, ...args: infer R) => any) ? R : P extends (new (ctx: Context, ...args: infer R) => any) ? R : P extends {
|
|
222
|
+
apply(ctx: Context, ...args: infer R): any;
|
|
223
|
+
} ? R : never;
|
|
224
|
+
type GetPluginConfig<P> = P extends Plugin.Transform<infer S, any> ? S : GetPluginParameters<P>[0];
|
|
225
|
+
declare module './context.ts' {
|
|
226
|
+
interface Context {
|
|
227
|
+
/**
|
|
228
|
+
* Run a callback once the requested services are available.
|
|
229
|
+
*
|
|
230
|
+
* Shorthand for `ctx.plugin({ inject, apply: callback })`: the callback
|
|
231
|
+
* is unloaded and re-run whenever a required service changes.
|
|
232
|
+
*
|
|
233
|
+
* @param deps — required services, as an array or a name → config map.
|
|
234
|
+
* @param callback — plugin body called with `(ctx, config)`.
|
|
235
|
+
* @returns the fiber; awaiting it settles once loading finished.
|
|
236
|
+
*/
|
|
237
|
+
inject(deps: Inject, callback: Plugin.Function<void>): Fiber & PromiseLike<Fiber>;
|
|
238
|
+
/**
|
|
239
|
+
* Load a plugin in the current context.
|
|
240
|
+
*
|
|
241
|
+
* @param plugin — a function, class, or `{ apply }` object plugin.
|
|
242
|
+
* @param args — the plugin config, validated against its `Config` schema.
|
|
243
|
+
* @returns the fiber; awaiting it settles once loading finished
|
|
244
|
+
* (rejecting on config or startup errors).
|
|
245
|
+
*/
|
|
246
|
+
plugin<P extends Plugin>(plugin: P, ...args: Spread<GetPluginConfig<P>>): Fiber & PromiseLike<Fiber>;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Plugin registry installed as `ctx.registry` and mixed into every context.
|
|
251
|
+
*
|
|
252
|
+
* It normalizes plugin shapes, tracks plugin runtimes, starts fibers, and
|
|
253
|
+
* exposes map-like inspection over active plugin callbacks.
|
|
254
|
+
*/
|
|
255
|
+
declare class RegistryService {
|
|
256
|
+
ctx: Context;
|
|
257
|
+
private _counter;
|
|
258
|
+
private _internal;
|
|
259
|
+
constructor(ctx: Context);
|
|
260
|
+
/** Allocate the next fiber uid (increments on every read). */
|
|
261
|
+
get counter(): number;
|
|
262
|
+
/** Number of registered plugin runtimes. */
|
|
263
|
+
get size(): number;
|
|
264
|
+
/**
|
|
265
|
+
* Resolve a supported plugin shape to its executable callback.
|
|
266
|
+
*
|
|
267
|
+
* @param plugin — a function, class, or `{ apply }` object plugin.
|
|
268
|
+
* @returns the callback identifying the plugin, or `undefined` if invalid.
|
|
269
|
+
*/
|
|
270
|
+
resolve(plugin: Plugin): Function | undefined;
|
|
271
|
+
/**
|
|
272
|
+
* Look up the runtime record for a plugin.
|
|
273
|
+
*
|
|
274
|
+
* @param plugin — any supported plugin shape.
|
|
275
|
+
* @returns the runtime, or `undefined` when the plugin is not registered.
|
|
276
|
+
*/
|
|
277
|
+
get(plugin: Plugin): Plugin.Runtime | undefined;
|
|
278
|
+
/**
|
|
279
|
+
* Check whether a plugin has a registered runtime.
|
|
280
|
+
*
|
|
281
|
+
* @param plugin — any supported plugin shape.
|
|
282
|
+
* @returns `true` when at least one fiber of the plugin exists.
|
|
283
|
+
*/
|
|
284
|
+
has(plugin: Plugin): boolean;
|
|
285
|
+
/**
|
|
286
|
+
* Dispose every running fiber for a plugin and remove its runtime record.
|
|
287
|
+
*
|
|
288
|
+
* @param plugin — any supported plugin shape.
|
|
289
|
+
* @returns the removed runtime, or `undefined` when none was registered.
|
|
290
|
+
*/
|
|
291
|
+
delete(plugin: Plugin): Plugin.Runtime | undefined;
|
|
292
|
+
/** Iterate the registered plugin callbacks. */
|
|
293
|
+
keys(): MapIterator<Function>;
|
|
294
|
+
/** Iterate the registered plugin runtimes. */
|
|
295
|
+
values(): MapIterator<Plugin.Runtime>;
|
|
296
|
+
/** Iterate `[callback, runtime]` pairs. */
|
|
297
|
+
entries(): MapIterator<[Function, Plugin.Runtime]>;
|
|
298
|
+
/**
|
|
299
|
+
* Visit every registered runtime.
|
|
300
|
+
*
|
|
301
|
+
* @param callback — receives each runtime and its identifying callback.
|
|
302
|
+
*/
|
|
303
|
+
forEach(callback: (value: Plugin.Runtime, key: Function) => void): void;
|
|
304
|
+
/**
|
|
305
|
+
* Start a callback once the requested dependencies are available.
|
|
306
|
+
*
|
|
307
|
+
* @param inject — required services, as an array or a name → config map.
|
|
308
|
+
* @param callback — plugin body called with `(ctx, config)`.
|
|
309
|
+
* @returns the fiber; awaiting it settles once loading finished.
|
|
310
|
+
*/
|
|
311
|
+
inject(inject: Inject, callback: Plugin.Function<void>): Fiber & PromiseLike<Fiber>;
|
|
312
|
+
/**
|
|
313
|
+
* Start a plugin in the current context and return its fiber.
|
|
314
|
+
*
|
|
315
|
+
* Creates (or reuses) the plugin's runtime record, then starts a new fiber
|
|
316
|
+
* under the current context. Throws if `plugin` is not a supported shape or
|
|
317
|
+
* if the current fiber is already disposed.
|
|
318
|
+
*
|
|
319
|
+
* @param plugin — a function, class, or `{ apply }` object plugin.
|
|
320
|
+
* @param config — the plugin config, validated against its `Config` schema.
|
|
321
|
+
* @param getOuterStack — captures the caller stack for effect diagnostics.
|
|
322
|
+
* @returns the fiber; awaiting it settles once loading finished.
|
|
323
|
+
*/
|
|
324
|
+
plugin(plugin: Plugin, config?: any, getOuterStack?: () => string[]): Fiber & PromiseLike<Fiber>;
|
|
325
|
+
}
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cordis@4.0.1_@deepseek-ai+cordis-plugin-include@1.0.6_@deepseek-ai+cordis-plugin-loader@1.0.2/node_modules/@deepseek-ai/cordis/lib/types/reflect.d.ts
|
|
328
|
+
declare module './context.ts' {
|
|
329
|
+
interface Context {
|
|
330
|
+
/**
|
|
331
|
+
* Read a service from the store without the inject requirement.
|
|
332
|
+
*
|
|
333
|
+
* @param name — the service name.
|
|
334
|
+
* @param strict — when `true` (default), only return implementations
|
|
335
|
+
* whose providing fiber is currently active.
|
|
336
|
+
* @returns the service value, or `undefined` when not (yet) provided.
|
|
337
|
+
*/
|
|
338
|
+
get<K extends string & keyof this>(name: K, strict?: boolean): undefined | this[K];
|
|
339
|
+
/** Same as above for service names outside the typed `Context` surface. */
|
|
340
|
+
get(name: string, strict?: boolean): any;
|
|
341
|
+
/**
|
|
342
|
+
* Overwrite a provided service's value.
|
|
343
|
+
*
|
|
344
|
+
* Only the fiber that provided the service may set it; setting an
|
|
345
|
+
* unprovided name throws.
|
|
346
|
+
*
|
|
347
|
+
* @param name — the service name.
|
|
348
|
+
* @param value — the new service value.
|
|
349
|
+
*/
|
|
350
|
+
set<K extends string & keyof this>(name: K, value: undefined | this[K]): void;
|
|
351
|
+
/** Same as above for service names outside the typed `Context` surface. */
|
|
352
|
+
set(name: string, value: any): void;
|
|
353
|
+
/**
|
|
354
|
+
* Register a service implementation owned by the current fiber.
|
|
355
|
+
*
|
|
356
|
+
* The service becomes visible to dependents in the same isolation scope
|
|
357
|
+
* once the fiber is active; it is unregistered (waking dependents) when
|
|
358
|
+
* the returned disposer runs or the fiber unloads. Throws if the name is
|
|
359
|
+
* already provided in this scope or declared as an accessor.
|
|
360
|
+
*
|
|
361
|
+
* @param name — the service name.
|
|
362
|
+
* @param value — the service value.
|
|
363
|
+
* @returns a disposer that unregisters the service.
|
|
364
|
+
*/
|
|
365
|
+
provide<K extends string & keyof this>(name: K, value: undefined | this[K]): () => void;
|
|
366
|
+
/** Same as above for service names outside the typed `Context` surface. */
|
|
367
|
+
provide(name: string, value?: any): () => void;
|
|
368
|
+
/**
|
|
369
|
+
* Define a computed context property backed by get/set hooks.
|
|
370
|
+
*
|
|
371
|
+
* The accessor is removed when the current fiber unloads. Throws if the
|
|
372
|
+
* name is already declared.
|
|
373
|
+
*
|
|
374
|
+
* @param name — the context property name.
|
|
375
|
+
* @param options — the `get` hook and optional `set` hook.
|
|
376
|
+
*/
|
|
377
|
+
accessor(name: string, options: Omit<Property.Accessor, 'type'>): void;
|
|
378
|
+
/**
|
|
379
|
+
* Expose selected members of a service directly on `ctx`.
|
|
380
|
+
*
|
|
381
|
+
* Each mixed-in key becomes an accessor that forwards to the service
|
|
382
|
+
* (binding methods to it), so e.g. `ctx.on` forwards to `ctx.events.on`.
|
|
383
|
+
* Mixins are removed when the current fiber unloads.
|
|
384
|
+
*
|
|
385
|
+
* @param name — the context property holding the source service.
|
|
386
|
+
* @param mixins — keys to forward, or a source-key → ctx-key map.
|
|
387
|
+
*/
|
|
388
|
+
mixin<K extends string & keyof this>(name: K, mixins: (keyof this & keyof this[K])[] | Dict<string>): void;
|
|
389
|
+
/** Same as above with a source object instead of a context property name. */
|
|
390
|
+
mixin<T extends {}>(source: T, mixins: (keyof this & keyof T)[] | Dict<string>): void;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
/** Context property definition known by the reflection service. */
|
|
394
|
+
type Property = Property.Service | Property.Accessor;
|
|
395
|
+
/** Property definition variants understood by `ReflectService`. */
|
|
396
|
+
declare namespace Property {
|
|
397
|
+
/** Service property backed by a provided implementation. */
|
|
398
|
+
interface Service {
|
|
399
|
+
/** Discriminator. */
|
|
400
|
+
type: 'service';
|
|
401
|
+
}
|
|
402
|
+
/** Computed context property backed by custom get/set hooks. */
|
|
403
|
+
interface Accessor {
|
|
404
|
+
/** Discriminator. */
|
|
405
|
+
type: 'accessor';
|
|
406
|
+
/** Compute the property value; `error` carries the caller stack for diagnostics. */
|
|
407
|
+
get: (this: Context, receiver: any, error: Error) => any;
|
|
408
|
+
/** Optional setter; return `false` to reject the write. */
|
|
409
|
+
set?: (this: Context, value: any, receiver: any, error: Error) => boolean;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
/** Concrete service implementation record stored in the root reflect service. */
|
|
413
|
+
interface Impl {
|
|
414
|
+
/** The service name. */
|
|
415
|
+
name: string;
|
|
416
|
+
/** The fiber that provided the service (owns its lifetime). */
|
|
417
|
+
fiber: Fiber;
|
|
418
|
+
/** The current service value. */
|
|
419
|
+
value?: any;
|
|
420
|
+
/** Optional availability predicate consulted before dependents may load. */
|
|
421
|
+
check?: () => boolean;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Reflection and service-resolution layer installed as `ctx.reflect`.
|
|
425
|
+
*
|
|
426
|
+
* This service powers the context proxy, service registration, accessors, and
|
|
427
|
+
* the mixins that expose core service methods directly on `ctx`.
|
|
428
|
+
*/
|
|
429
|
+
declare class ReflectService {
|
|
430
|
+
ctx: Context;
|
|
431
|
+
/** Proxy traps implementing service resolution for every context object. */
|
|
432
|
+
static handler: ProxyHandler<Context>;
|
|
433
|
+
/** Service implementations, keyed by isolation label. */
|
|
434
|
+
store: Dict<Impl, symbol>;
|
|
435
|
+
/** Declared context properties (services and accessors), by name. */
|
|
436
|
+
props: Dict<Property>;
|
|
437
|
+
constructor(ctx: Context);
|
|
438
|
+
/**
|
|
439
|
+
* Read a service from the store without the inject requirement.
|
|
440
|
+
*
|
|
441
|
+
* @param name — the service name.
|
|
442
|
+
* @param strict — when `true`, only return implementations whose providing
|
|
443
|
+
* fiber is currently active.
|
|
444
|
+
* @returns the service value, or `undefined` when not (yet) provided.
|
|
445
|
+
*/
|
|
446
|
+
get(name: string, strict?: boolean): any;
|
|
447
|
+
_getImpl(name: string, strict?: boolean): Impl | undefined;
|
|
448
|
+
/**
|
|
449
|
+
* Overwrite a provided service's value.
|
|
450
|
+
*
|
|
451
|
+
* @param name — the service name.
|
|
452
|
+
* @param value — the new service value.
|
|
453
|
+
* @param error — carrier for the caller stack in diagnostics.
|
|
454
|
+
* @returns `true` on success.
|
|
455
|
+
* @throws when `name` was never provided, or was provided by another fiber.
|
|
456
|
+
*/
|
|
457
|
+
set(name: string, value: any, error?: Error): boolean;
|
|
458
|
+
/**
|
|
459
|
+
* Register a service implementation owned by the current fiber.
|
|
460
|
+
*
|
|
461
|
+
* See the `ctx.provide()` overload above for the full contract.
|
|
462
|
+
*
|
|
463
|
+
* @param name — the service name.
|
|
464
|
+
* @param value — the service value.
|
|
465
|
+
* @param check — optional availability predicate for dependents.
|
|
466
|
+
* @returns a disposer that unregisters the service.
|
|
467
|
+
*/
|
|
468
|
+
provide(name: string, value?: any, check?: () => boolean): Disposable<Promise<void>>;
|
|
469
|
+
/**
|
|
470
|
+
* Re-evaluate every fiber that requires one of the given services.
|
|
471
|
+
*
|
|
472
|
+
* @param names — the service names that changed.
|
|
473
|
+
* @param filter — restricts notification to matching isolation scopes.
|
|
474
|
+
* @returns the fibers whose dependency state was refreshed.
|
|
475
|
+
*/
|
|
476
|
+
notify(names: string[], filter?: (ctx: Context, name: string) => boolean): Fiber[];
|
|
477
|
+
/**
|
|
478
|
+
* Define a computed context property backed by get/set hooks.
|
|
479
|
+
*
|
|
480
|
+
* @param name — the context property name.
|
|
481
|
+
* @param options — the `get` hook and optional `set` hook.
|
|
482
|
+
* @returns a disposer that removes the accessor.
|
|
483
|
+
*/
|
|
484
|
+
accessor(name: string, options: Omit<Property.Accessor, 'type'>): Disposable<Promise<void>>;
|
|
485
|
+
/**
|
|
486
|
+
* Expose selected members of a service directly on `ctx`.
|
|
487
|
+
*
|
|
488
|
+
* See the `ctx.mixin()` overload above for the full contract.
|
|
489
|
+
*
|
|
490
|
+
* @param source — a context property name or a source object.
|
|
491
|
+
* @param mixins — keys to forward, or a source-key → ctx-key map.
|
|
492
|
+
* @returns a disposer that removes all created accessors.
|
|
493
|
+
*/
|
|
494
|
+
mixin(source: any, mixins: string[] | Dict<string>): Disposable<Promise<void>>;
|
|
495
|
+
/**
|
|
496
|
+
* Attach this context's tracing wrapper to a value.
|
|
497
|
+
*
|
|
498
|
+
* @param value — the value to wrap.
|
|
499
|
+
* @returns the traceable wrapper (or the value itself when not applicable).
|
|
500
|
+
*/
|
|
501
|
+
trace<T>(value: T): T;
|
|
502
|
+
/**
|
|
503
|
+
* Wrap a callback so calls trace `this` and arguments to this context.
|
|
504
|
+
*
|
|
505
|
+
* @param callback — the function to wrap.
|
|
506
|
+
* @returns a proxy delegating to `callback` with traced values.
|
|
507
|
+
*/
|
|
508
|
+
bind<T extends Function>(callback: T): T;
|
|
509
|
+
}
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cordis@4.0.1_@deepseek-ai+cordis-plugin-include@1.0.6_@deepseek-ai+cordis-plugin-loader@1.0.2/node_modules/@deepseek-ai/cordis/lib/types/fiber.d.ts
|
|
512
|
+
declare module './context.ts' {
|
|
513
|
+
interface Context extends Pick<Fiber, 'effect'> {
|
|
514
|
+
/** The fiber (plugin runtime instance) that owns this context. */
|
|
515
|
+
fiber: Fiber;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
/** Error raised when plugin configuration fails standard-schema validation. */
|
|
519
|
+
interface AsyncDisposable<T extends Awaitable<void> = Awaitable<void>> extends PromiseLike<() => T> {
|
|
520
|
+
(): T;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Function returned by an effect to release resources during disposal.
|
|
524
|
+
*
|
|
525
|
+
* Disposers run in reverse registration order when the owning fiber unloads;
|
|
526
|
+
* they may be async, in which case unloading awaits them.
|
|
527
|
+
*/
|
|
528
|
+
type Disposable<T = any> = () => T;
|
|
529
|
+
/**
|
|
530
|
+
* Effect body result accepted by `ctx.effect()` and plugin startup.
|
|
531
|
+
*
|
|
532
|
+
* Either a single disposer, a promise of one, or a (possibly async) iterable
|
|
533
|
+
* yielding several — generator effects register each yielded disposer as it
|
|
534
|
+
* is produced.
|
|
535
|
+
*/
|
|
536
|
+
type Effect<T = any> = SyncEffect<T> | AsyncEffect<T>;
|
|
537
|
+
type SyncEffect<T = any> = Disposable<T> | Iterable<Disposable<T>, void, void>;
|
|
538
|
+
type AsyncEffect<T = any> = Promise<Disposable<T>> | AsyncIterable<Disposable<T>, void, void>;
|
|
539
|
+
/** Tree node used to expose nested effect labels for diagnostics. */
|
|
540
|
+
interface EffectMeta {
|
|
541
|
+
/** Human-readable effect label, e.g. `ctx.on("event")` or `ctx.provide("name")`. */
|
|
542
|
+
label: string;
|
|
543
|
+
/** Metadata of nested effects registered while this effect ran. */
|
|
544
|
+
children: EffectMeta[];
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Lifecycle state for one plugin fiber.
|
|
548
|
+
*
|
|
549
|
+
* `PENDING` — waiting for required services; `LOADING` — the plugin callback
|
|
550
|
+
* is running; `ACTIVE` — loaded and providing; `FAILED` — the callback or its
|
|
551
|
+
* config threw; `UNLOADING` — disposers are running; `DISPOSED` — the fiber
|
|
552
|
+
* was removed and cannot restart.
|
|
553
|
+
*/
|
|
554
|
+
declare const enum FiberState {
|
|
555
|
+
PENDING = 0,
|
|
556
|
+
LOADING = 1,
|
|
557
|
+
ACTIVE = 2,
|
|
558
|
+
FAILED = 3,
|
|
559
|
+
DISPOSED = 4,
|
|
560
|
+
UNLOADING = 5
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Runtime instance of one plugin application.
|
|
564
|
+
*
|
|
565
|
+
* A fiber tracks dependency state, validated config, lifecycle effects, and
|
|
566
|
+
* cleanup for the plugin context returned by `ctx.plugin()`.
|
|
567
|
+
*/
|
|
568
|
+
declare class Fiber {
|
|
569
|
+
parent: Context;
|
|
570
|
+
inject: Dict<any>;
|
|
571
|
+
runtime: Plugin.Runtime | null;
|
|
572
|
+
/** Unique id within the registry; 0 for the root fiber, `null` once disposed. */
|
|
573
|
+
uid: number | null;
|
|
574
|
+
/** The context this fiber's plugin runs in (extends the parent context). */
|
|
575
|
+
readonly ctx: Context;
|
|
576
|
+
/** The validated plugin config (updated by `update()`). */
|
|
577
|
+
config: any;
|
|
578
|
+
/** The raw plugin config, re-resolved before each activation. */
|
|
579
|
+
_config: any;
|
|
580
|
+
/** Current lifecycle state; transitions emit `internal/status`. */
|
|
581
|
+
state: FiberState;
|
|
582
|
+
/** Dispose this fiber: unload the plugin, then settle once cleanup finished. */
|
|
583
|
+
readonly dispose: () => Promise<void>;
|
|
584
|
+
/** Snapshot of required service implementations while loaded; `undefined` otherwise. */
|
|
585
|
+
store: Dict<Impl> | undefined;
|
|
586
|
+
/** The in-flight load/unload transition, if one is currently running. */
|
|
587
|
+
inertia: Promise<void> | undefined;
|
|
588
|
+
readonly _hooks: Dict<DisposableList<Function>>;
|
|
589
|
+
readonly _disposables: DisposableList<Disposable<any>>;
|
|
590
|
+
protected context: Context;
|
|
591
|
+
private _error;
|
|
592
|
+
private _runner;
|
|
593
|
+
private _store;
|
|
594
|
+
/**
|
|
595
|
+
* Create a fiber. Plugin authors normally obtain fibers from `ctx.plugin()`
|
|
596
|
+
* rather than constructing them directly.
|
|
597
|
+
*
|
|
598
|
+
* @param parent — the context the plugin was loaded from.
|
|
599
|
+
* @param config — raw config, validated against the runtime's schema.
|
|
600
|
+
* @param inject — resolved dependency map (service name → intercept config).
|
|
601
|
+
* @param runtime — the shared plugin runtime, or `null` for the root fiber.
|
|
602
|
+
* @param getOuterStack — captures the caller stack for effect diagnostics.
|
|
603
|
+
*/
|
|
604
|
+
constructor(parent: Context, config: any, inject: Dict<any>, runtime: Plugin.Runtime | null, getOuterStack: () => string[]);
|
|
605
|
+
/** The plugin's display name, inherited from the nearest named ancestor, else `'root'`. */
|
|
606
|
+
get name(): string;
|
|
607
|
+
/**
|
|
608
|
+
* Throw if the fiber has already been disposed.
|
|
609
|
+
*
|
|
610
|
+
* @returns nothing when the fiber is still active.
|
|
611
|
+
* @throws {CordisError} `INACTIVE_EFFECT` when the fiber's uid has been cleared.
|
|
612
|
+
*/
|
|
613
|
+
assertActive(): void;
|
|
614
|
+
private _execute;
|
|
615
|
+
/**
|
|
616
|
+
* Register a cleanup-aware effect on this fiber.
|
|
617
|
+
*
|
|
618
|
+
* `execute` runs immediately; the disposers it produces are collected and
|
|
619
|
+
* run (in reverse order) either when the returned disposer is called or
|
|
620
|
+
* when the fiber unloads, whichever comes first. Calling the disposer twice
|
|
621
|
+
* is a no-op. Throws `CordisError('INACTIVE_EFFECT')` if the fiber is
|
|
622
|
+
* already disposed, and `TypeError` if `execute` returns an invalid shape.
|
|
623
|
+
*
|
|
624
|
+
* @param execute — the effect body; see {@link Effect} for accepted shapes.
|
|
625
|
+
* @param label — effect label shown in `getEffects()` diagnostics.
|
|
626
|
+
* @returns a disposer that tears the effect down and settles once done.
|
|
627
|
+
*/
|
|
628
|
+
effect(execute: () => SyncEffect, label?: string): Disposable<Promise<void>>;
|
|
629
|
+
/** Same as above for async effects; the disposer is also awaitable. */
|
|
630
|
+
effect(execute: () => Effect, label?: string): AsyncDisposable<Promise<void>>;
|
|
631
|
+
/**
|
|
632
|
+
* Return metadata for currently registered effects.
|
|
633
|
+
*
|
|
634
|
+
* @returns one {@link EffectMeta} tree per labeled live effect.
|
|
635
|
+
*/
|
|
636
|
+
getEffects(): EffectMeta[];
|
|
637
|
+
private _getState;
|
|
638
|
+
private _updateState;
|
|
639
|
+
_checkImpl(name: string): boolean | undefined;
|
|
640
|
+
_refresh(): void;
|
|
641
|
+
private _setEpoch;
|
|
642
|
+
private _resolveConfig;
|
|
643
|
+
private _reload;
|
|
644
|
+
private _unload;
|
|
645
|
+
/**
|
|
646
|
+
* Wait for current lifecycle work and rethrow startup errors.
|
|
647
|
+
*
|
|
648
|
+
* @returns this fiber, once it has settled into a stable state.
|
|
649
|
+
* @throws the config-validation or plugin-startup error, if any.
|
|
650
|
+
*/
|
|
651
|
+
await(): Promise<this>;
|
|
652
|
+
/**
|
|
653
|
+
* Dispose and immediately reload this plugin with its current config.
|
|
654
|
+
*
|
|
655
|
+
* @returns a promise resolving once the reload settled.
|
|
656
|
+
* @throws {CordisError} `INACTIVE_EFFECT` when the fiber is already disposed.
|
|
657
|
+
*/
|
|
658
|
+
restart(): Promise<void>;
|
|
659
|
+
/**
|
|
660
|
+
* Validate and apply new config, then restart the plugin.
|
|
661
|
+
*
|
|
662
|
+
* Runs the `internal/update` waterfall first, so update hooks (and HMR)
|
|
663
|
+
* can veto or replace the restart.
|
|
664
|
+
*
|
|
665
|
+
* @param config — the new raw config; validated before anything restarts.
|
|
666
|
+
* @param noSave — hint for persistence hooks not to write the change back.
|
|
667
|
+
* @returns the update waterfall result; the default restart returns a promise.
|
|
668
|
+
* @throws when validation, an update listener, or the restarted plugin fails.
|
|
669
|
+
*/
|
|
670
|
+
update(config: any, noSave?: boolean): void | Promise<void>;
|
|
671
|
+
}
|
|
672
|
+
//#endregion
|
|
673
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cordis@4.0.1_@deepseek-ai+cordis-plugin-include@1.0.6_@deepseek-ai+cordis-plugin-loader@1.0.2/node_modules/@deepseek-ai/cordis/lib/types/events.d.ts
|
|
674
|
+
/** Extract the parameter tuple from a function type. */
|
|
675
|
+
type Parameters<F> = F extends ((...args: infer P) => any) ? P : never;
|
|
676
|
+
/** Extract the return type from a function type. */
|
|
677
|
+
type ReturnType$1<F> = F extends ((...args: any) => infer R) ? R : never;
|
|
678
|
+
/** Extract the explicit `this` type from a function type. */
|
|
679
|
+
type ThisType<F> = F extends ((this: infer T, ...args: any) => any) ? T : never;
|
|
680
|
+
/**
|
|
681
|
+
* Event dispatch strategy used by the event service.
|
|
682
|
+
*
|
|
683
|
+
* `emit` runs synchronous listeners without awaiting them, `parallel` awaits
|
|
684
|
+
* all listeners together, `serial` awaits them in order until one bails,
|
|
685
|
+
* `bail` stops on the first synchronous bail value, and `waterfall` composes
|
|
686
|
+
* listeners around a final `next` callback.
|
|
687
|
+
*/
|
|
688
|
+
type DispatchMode = 'emit' | 'parallel' | 'serial' | 'bail' | 'waterfall';
|
|
689
|
+
declare module './context.ts' {
|
|
690
|
+
interface Context {
|
|
691
|
+
/**
|
|
692
|
+
* Dispatch an event, running all listeners concurrently.
|
|
693
|
+
*
|
|
694
|
+
* @param name — the event name.
|
|
695
|
+
* @param args — arguments passed to every listener.
|
|
696
|
+
* @returns a promise resolving once every listener has settled.
|
|
697
|
+
*/
|
|
698
|
+
parallel<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): Promise<void>;
|
|
699
|
+
/** Same as above, with an explicit `this` for listeners (also used for filtering). */
|
|
700
|
+
parallel<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): Promise<void>;
|
|
701
|
+
/**
|
|
702
|
+
* Dispatch an event synchronously, ignoring listener return values.
|
|
703
|
+
*
|
|
704
|
+
* @param name — the event name.
|
|
705
|
+
* @param args — arguments passed to every listener.
|
|
706
|
+
*/
|
|
707
|
+
emit<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void;
|
|
708
|
+
/** Same as above, with an explicit `this` for listeners (also used for filtering). */
|
|
709
|
+
emit<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): void;
|
|
710
|
+
/**
|
|
711
|
+
* Dispatch an event, awaiting listeners in order until one bails.
|
|
712
|
+
*
|
|
713
|
+
* @param name — the event name.
|
|
714
|
+
* @param args — arguments passed to each listener.
|
|
715
|
+
* @returns the first bail value (non-null, non-false, non-undefined), if any.
|
|
716
|
+
*/
|
|
717
|
+
serial<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): Promisify<ReturnType$1<Events[K]>>;
|
|
718
|
+
/** Same as above, with an explicit `this` for listeners (also used for filtering). */
|
|
719
|
+
serial<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): Promisify<ReturnType$1<Events[K]>>;
|
|
720
|
+
/**
|
|
721
|
+
* Dispatch an event, calling listeners in order until one bails.
|
|
722
|
+
*
|
|
723
|
+
* @param name — the event name.
|
|
724
|
+
* @param args — arguments passed to each listener.
|
|
725
|
+
* @returns the first bail value (non-null, non-false, non-undefined), if any.
|
|
726
|
+
*/
|
|
727
|
+
bail<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): ReturnType$1<Events[K]>;
|
|
728
|
+
/** Same as above, with an explicit `this` for listeners (also used for filtering). */
|
|
729
|
+
bail<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): ReturnType$1<Events[K]>;
|
|
730
|
+
/**
|
|
731
|
+
* Dispatch an event whose last argument is a `next` continuation.
|
|
732
|
+
*
|
|
733
|
+
* Each listener wraps the rest of the chain: calling `next()` invokes the
|
|
734
|
+
* next listener (finally the built-in behavior); not calling it vetoes.
|
|
735
|
+
*
|
|
736
|
+
* @param name — the event name.
|
|
737
|
+
* @param args — listener arguments; the final one is the innermost `next`.
|
|
738
|
+
* @returns the outermost listener's return value.
|
|
739
|
+
*/
|
|
740
|
+
waterfall<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): ReturnType$1<Events[K]>;
|
|
741
|
+
/** Same as above, with an explicit `this` for listeners (also used for filtering). */
|
|
742
|
+
waterfall<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): ReturnType$1<Events[K]>;
|
|
743
|
+
/**
|
|
744
|
+
* Register an event listener owned by the current fiber.
|
|
745
|
+
*
|
|
746
|
+
* @param name — the event name to listen for.
|
|
747
|
+
* @param listener — called with the dispatch arguments.
|
|
748
|
+
* @param options — listener options; a boolean is shorthand for `prepend`.
|
|
749
|
+
* @returns a disposer removing the listener; `true` if it was still registered.
|
|
750
|
+
*/
|
|
751
|
+
on<K extends keyof Events>(name: K, listener: Events[K], options?: boolean | EventOptions): () => boolean;
|
|
752
|
+
/**
|
|
753
|
+
* Same as `on()`, but the listener disposes itself after its first call.
|
|
754
|
+
*
|
|
755
|
+
* @param name — the event name to listen for.
|
|
756
|
+
* @param listener — called at most once with the dispatch arguments.
|
|
757
|
+
* @param options — listener options; a boolean is shorthand for `prepend`.
|
|
758
|
+
* @returns a disposer removing the listener; `true` if it was still registered.
|
|
759
|
+
*/
|
|
760
|
+
once<K extends keyof Events>(name: K, listener: Events[K], options?: boolean | EventOptions): () => boolean;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
/** Options accepted by `ctx.on()` and `ctx.once()`. */
|
|
764
|
+
interface EventOptions {
|
|
765
|
+
/** Add the listener before existing listeners for the same event. */
|
|
766
|
+
prepend?: boolean;
|
|
767
|
+
/** Receive the event regardless of context filter checks. */
|
|
768
|
+
global?: boolean;
|
|
769
|
+
}
|
|
770
|
+
/** Registered listener record stored by the event service. */
|
|
771
|
+
interface Hook extends EventOptions {
|
|
772
|
+
ctx: Context;
|
|
773
|
+
callback: (...args: any[]) => any;
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Event bus installed as `ctx.events` and mixed into every context.
|
|
777
|
+
*
|
|
778
|
+
* The service supports concurrent, synchronous, serial, bail, and waterfall
|
|
779
|
+
* dispatch and automatically disposes listeners with their owning fiber.
|
|
780
|
+
*/
|
|
781
|
+
declare class EventsService {
|
|
782
|
+
private ctx;
|
|
783
|
+
_hooks: Record<keyof any, Hook[]>;
|
|
784
|
+
constructor(ctx: Context);
|
|
785
|
+
/**
|
|
786
|
+
* Resolve listeners for one dispatch and apply context filtering.
|
|
787
|
+
*
|
|
788
|
+
* @param type — the dispatch mode, reported on `internal/dispatch`.
|
|
789
|
+
* @param args — the raw dispatch arguments; consumed up to the event name.
|
|
790
|
+
* @returns the matching listener callbacks, bound to the dispatch `this`.
|
|
791
|
+
*/
|
|
792
|
+
dispatch(type: string, args: any[]): ((...args: any[]) => any)[];
|
|
793
|
+
/**
|
|
794
|
+
* Run listeners concurrently and wait for all of them.
|
|
795
|
+
*
|
|
796
|
+
* @param args — optional `this`, the event name, then listener arguments.
|
|
797
|
+
* @returns a promise resolving once every listener has settled.
|
|
798
|
+
*/
|
|
799
|
+
parallel(...args: any[]): Promise<void>;
|
|
800
|
+
/**
|
|
801
|
+
* Run listeners synchronously without waiting for returned promises.
|
|
802
|
+
*
|
|
803
|
+
* @param args — optional `this`, the event name, then listener arguments.
|
|
804
|
+
*/
|
|
805
|
+
emit(...args: any[]): void;
|
|
806
|
+
/**
|
|
807
|
+
* Run listeners in order, awaiting each, until one returns a bail value.
|
|
808
|
+
*
|
|
809
|
+
* @param args — optional `this`, the event name, then listener arguments.
|
|
810
|
+
* @returns the first bail value (see {@link isBailed}), if any.
|
|
811
|
+
*/
|
|
812
|
+
serial(...args: any[]): Promise<any>;
|
|
813
|
+
/**
|
|
814
|
+
* Run listeners synchronously until one returns a bail value.
|
|
815
|
+
*
|
|
816
|
+
* @param args — optional `this`, the event name, then listener arguments.
|
|
817
|
+
* @returns the first bail value (see {@link isBailed}), if any.
|
|
818
|
+
*/
|
|
819
|
+
bail(...args: any[]): any;
|
|
820
|
+
/**
|
|
821
|
+
* Compose listeners around the final `next` callback.
|
|
822
|
+
*
|
|
823
|
+
* The last dispatch argument is treated as the innermost `next`. Listeners
|
|
824
|
+
* run outermost-first; a listener that does not call `next()` vetoes the
|
|
825
|
+
* rest of the chain, including the built-in behavior.
|
|
826
|
+
*
|
|
827
|
+
* @param args — optional `this`, the event name, listener arguments, then `next`.
|
|
828
|
+
* @returns the outermost listener's return value.
|
|
829
|
+
*/
|
|
830
|
+
waterfall(...args: any[]): any;
|
|
831
|
+
/**
|
|
832
|
+
* Store a listener record as an effect on the current fiber.
|
|
833
|
+
*
|
|
834
|
+
* @param label — effect label shown in fiber diagnostics.
|
|
835
|
+
* @param hooks — the listener list for one event.
|
|
836
|
+
* @param callback — the listener to store.
|
|
837
|
+
* @param options — placement and filtering options.
|
|
838
|
+
* @returns a disposer that unregisters the listener.
|
|
839
|
+
*/
|
|
840
|
+
register(label: string, hooks: Hook[], callback: any, options: EventOptions): () => void;
|
|
841
|
+
/**
|
|
842
|
+
* Remove a stored listener record.
|
|
843
|
+
*
|
|
844
|
+
* @param hooks — the listener list for one event.
|
|
845
|
+
* @param callback — the listener to remove.
|
|
846
|
+
* @returns `true` if the listener was found and removed.
|
|
847
|
+
*/
|
|
848
|
+
unregister(hooks: Hook[], callback: any): true | undefined;
|
|
849
|
+
/**
|
|
850
|
+
* Register an event listener owned by the current fiber.
|
|
851
|
+
*
|
|
852
|
+
* The listener is removed automatically when the fiber unloads. Throws
|
|
853
|
+
* `CordisError('INACTIVE_EFFECT')` if the fiber is already disposed.
|
|
854
|
+
*
|
|
855
|
+
* @param name — the event name to listen for.
|
|
856
|
+
* @param listener — called with the dispatch arguments.
|
|
857
|
+
* @param options — listener options; a boolean is shorthand for `prepend`.
|
|
858
|
+
* @returns a disposer removing the listener; `true` if it was still registered.
|
|
859
|
+
*/
|
|
860
|
+
on(name: string | symbol, listener: (...args: any) => any, options?: boolean | EventOptions): any;
|
|
861
|
+
/**
|
|
862
|
+
* Register an event listener that disposes itself after the first call.
|
|
863
|
+
*
|
|
864
|
+
* @param name — the event name to listen for.
|
|
865
|
+
* @param listener — called at most once with the dispatch arguments.
|
|
866
|
+
* @param options — listener options; a boolean is shorthand for `prepend`.
|
|
867
|
+
* @returns a disposer removing the listener; `true` if it was still registered.
|
|
868
|
+
*/
|
|
869
|
+
once(name: string, listener: (...args: any) => any, options?: boolean | EventOptions): any;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Built-in framework events used by core services and extension points.
|
|
873
|
+
*
|
|
874
|
+
* Plugin and status events track fiber lifecycle, service events observe
|
|
875
|
+
* dependency registration, update/get/set/listener events allow core services
|
|
876
|
+
* to intercept runtime operations, and `internal/dispatch` exposes event-bus
|
|
877
|
+
* diagnostics before public events are delivered.
|
|
878
|
+
*/
|
|
879
|
+
interface Events {
|
|
880
|
+
/** A plugin fiber was created or its uid was cleared on disposal. */
|
|
881
|
+
'internal/plugin'(fiber: Fiber): void;
|
|
882
|
+
/** A fiber changed lifecycle state; receives the fiber and its previous state. */
|
|
883
|
+
'internal/status'(fiber: Fiber, oldValue: FiberState): void;
|
|
884
|
+
/**
|
|
885
|
+
* Resolve raw plugin config after the fiber's injections become active.
|
|
886
|
+
* @param config - the raw config for this activation.
|
|
887
|
+
* @mode waterfall
|
|
888
|
+
*/
|
|
889
|
+
'internal/config'(this: Fiber, config: any, next: () => any): any;
|
|
890
|
+
/** Interception hook for a service binding (no core producer). */
|
|
891
|
+
'internal/service'(this: Context, name: string, value: any): void;
|
|
892
|
+
/** Waterfall: a fiber config update is being applied; skip `next()` to veto. */
|
|
893
|
+
'internal/update'(this: Fiber, config: any, noSave: boolean, next: () => void | Promise<void>): void | Promise<void>;
|
|
894
|
+
/** Waterfall: a service is being read through the context proxy. */
|
|
895
|
+
'internal/get'(ctx: Context, name: string, error: Error, next: () => any): any;
|
|
896
|
+
/** Waterfall: a service is being written through the context proxy. */
|
|
897
|
+
'internal/set'(ctx: Context, name: string, value: any, error: Error, next: () => boolean): boolean;
|
|
898
|
+
/** Bail: a listener is being registered; a non-null result replaces registration. */
|
|
899
|
+
'internal/listener'(this: Context, name: string, listener: any, prepend: boolean): void;
|
|
900
|
+
/** An event is being dispatched to listeners (fired for non-internal events only). */
|
|
901
|
+
'internal/dispatch'(mode: DispatchMode, name: string, args: any[], thisArg: any): void;
|
|
902
|
+
}
|
|
903
|
+
//#endregion
|
|
904
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cordis@4.0.1_@deepseek-ai+cordis-plugin-include@1.0.6_@deepseek-ai+cordis-plugin-loader@1.0.2/node_modules/@deepseek-ai/cordis/lib/types/logger.d.ts
|
|
905
|
+
declare module './context.ts' {
|
|
906
|
+
interface Intercept {
|
|
907
|
+
logger: LoggerService.Intercept;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
/** Logger method name and severity category. */
|
|
911
|
+
type LoggerType = 'error' | 'info' | 'warn' | 'debug';
|
|
912
|
+
/** Callable shape for one logger severity method. */
|
|
913
|
+
type LoggerMethod = (format: any, ...param: any[]) => void;
|
|
914
|
+
/** Formatter used to resolve a printf-style placeholder. */
|
|
915
|
+
type Formatter = (value: any, exporter: Exporter, message: Message) => any;
|
|
916
|
+
/** Structured log record delivered to exporters. */
|
|
917
|
+
interface Message {
|
|
918
|
+
sn: number;
|
|
919
|
+
ts: number;
|
|
920
|
+
name: string;
|
|
921
|
+
type: LoggerType;
|
|
922
|
+
level: number;
|
|
923
|
+
args: any[];
|
|
924
|
+
fiber?: WeakRef<Fiber>;
|
|
925
|
+
}
|
|
926
|
+
/** Sink that receives structured log messages. */
|
|
927
|
+
interface Exporter {
|
|
928
|
+
colors?: number | false;
|
|
929
|
+
maxLength?: number;
|
|
930
|
+
levels?: Record<string, number>;
|
|
931
|
+
formatters?: Record<string, Formatter>;
|
|
932
|
+
export(message: Message): void;
|
|
933
|
+
}
|
|
934
|
+
/** Options used when creating a named logger facade. */
|
|
935
|
+
interface LoggerOptions {
|
|
936
|
+
/** The logger name shown with each message. */
|
|
937
|
+
name: string;
|
|
938
|
+
/** Message fields merged into every record from this logger. */
|
|
939
|
+
meta?: Partial<Message>;
|
|
940
|
+
/** Default maximum level exported when an exporter has no own threshold. */
|
|
941
|
+
level?: number;
|
|
942
|
+
}
|
|
943
|
+
/** Logger facade identity, inherited message metadata, and optional minimum level. */
|
|
944
|
+
interface Logger extends LoggerOptions {}
|
|
945
|
+
/** Logger facade severity methods. */
|
|
946
|
+
interface Logger extends Record<LoggerType, LoggerMethod> {}
|
|
947
|
+
/** Logger facade for one named subsystem. */
|
|
948
|
+
declare class Logger {
|
|
949
|
+
private service;
|
|
950
|
+
static color(exporter: Exporter, code: number, value: any, decoration?: string): string;
|
|
951
|
+
static code(name: string, level?: false | number): number;
|
|
952
|
+
static format(exporter: Exporter, message: Message): string;
|
|
953
|
+
constructor(options: LoggerOptions, service: LoggerService);
|
|
954
|
+
private _method;
|
|
955
|
+
}
|
|
956
|
+
/** Logger service configuration merged from context intercepts. */
|
|
957
|
+
declare namespace LoggerService {
|
|
958
|
+
interface Intercept {
|
|
959
|
+
name?: string;
|
|
960
|
+
level?: number;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
/** Callable `ctx.logger` service shape. */
|
|
964
|
+
interface LoggerService extends Record<LoggerType, LoggerMethod> {
|
|
965
|
+
(name?: string): Logger;
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Built-in logging service.
|
|
969
|
+
*
|
|
970
|
+
* Call `ctx.logger()` to create a named logger, or call `ctx.logger.info()`
|
|
971
|
+
* directly to log with the current fiber-derived name.
|
|
972
|
+
*/
|
|
973
|
+
declare class LoggerService {
|
|
974
|
+
bufferSize: number;
|
|
975
|
+
buffer: Message[];
|
|
976
|
+
ctx: Context;
|
|
977
|
+
_snMessage: number;
|
|
978
|
+
_snExporter: number;
|
|
979
|
+
exporters: Map<number, Exporter>;
|
|
980
|
+
constructor(ctx: Context);
|
|
981
|
+
/**
|
|
982
|
+
* Register an exporter and dispose it with the current fiber.
|
|
983
|
+
*
|
|
984
|
+
* @param exporter — the sink that receives structured log messages.
|
|
985
|
+
* @returns a disposer that removes the exporter.
|
|
986
|
+
*/
|
|
987
|
+
exporter(exporter: Exporter): Disposable<Promise<void>>;
|
|
988
|
+
private _resolveConfig;
|
|
989
|
+
[symbols.invoke](name?: string): Logger;
|
|
990
|
+
}
|
|
991
|
+
//#endregion
|
|
992
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cordis@4.0.1_@deepseek-ai+cordis-plugin-include@1.0.6_@deepseek-ai+cordis-plugin-loader@1.0.2/node_modules/@deepseek-ai/cordis/lib/types/context.d.ts
|
|
993
|
+
/**
|
|
994
|
+
* Public shape of a Cordis context.
|
|
995
|
+
*
|
|
996
|
+
* The concrete `Context` class is proxied at runtime, so this interface is
|
|
997
|
+
* augmented by core services and plugins to describe the properties that may
|
|
998
|
+
* be read from `ctx`.
|
|
999
|
+
*/
|
|
1000
|
+
interface Context {
|
|
1001
|
+
/** Isolation map: service name → scope label. Lookups for a name resolve within its label. */
|
|
1002
|
+
[symbols.isolate]: Dict<symbol>;
|
|
1003
|
+
/** Intercept map: service name → config merged into that service's per-plugin config. */
|
|
1004
|
+
[symbols.intercept]: Dict;
|
|
1005
|
+
/** The root context of the application (every child context shares it). @experimental */
|
|
1006
|
+
root: this;
|
|
1007
|
+
/** Base URL used to resolve relative plugin/module specifiers, if the runtime sets one. */
|
|
1008
|
+
baseUrl?: string;
|
|
1009
|
+
/** The event bus. Its methods are also mixed onto `ctx` (`ctx.on`, `ctx.emit`, ...). */
|
|
1010
|
+
events: EventsService;
|
|
1011
|
+
/** The logging service. Call `ctx.logger(name)` for a named logger. */
|
|
1012
|
+
logger: LoggerService;
|
|
1013
|
+
/** The reflection layer backing the context proxy (`ctx.get`, `ctx.provide`, ...). */
|
|
1014
|
+
reflect: ReflectService;
|
|
1015
|
+
/** The plugin registry. Its methods are mixed onto `ctx` (`ctx.plugin`, `ctx.inject`). */
|
|
1016
|
+
registry: RegistryService;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Root and child dependency containers for Cordis plugins.
|
|
1020
|
+
*
|
|
1021
|
+
* A context is a proxy: normal property reads go through the service resolver,
|
|
1022
|
+
* while `extend()`, `isolate()`, and `intercept()` create scoped child
|
|
1023
|
+
* contexts without mutating their parent.
|
|
1024
|
+
*/
|
|
1025
|
+
declare class Context {
|
|
1026
|
+
/** Symbol key under which a disposer exposes its {@link EffectMeta} diagnostics tree. */
|
|
1027
|
+
static readonly effect: unique symbol;
|
|
1028
|
+
/** Symbol key for a context's listener filter, consulted on every event dispatch. */
|
|
1029
|
+
static readonly filter: unique symbol;
|
|
1030
|
+
/** Symbol key of the isolation map (see the `Context[symbols.isolate]` property). */
|
|
1031
|
+
static readonly isolate: unique symbol;
|
|
1032
|
+
/** Symbol key of the intercept map (see the `Context[symbols.intercept]` property). */
|
|
1033
|
+
static readonly intercept: unique symbol;
|
|
1034
|
+
/**
|
|
1035
|
+
* Returns true for Cordis context proxies and context prototypes.
|
|
1036
|
+
*
|
|
1037
|
+
* Works across realms and across multiple copies of cordis, because the
|
|
1038
|
+
* brand is keyed by a global symbol rather than by `instanceof`.
|
|
1039
|
+
*
|
|
1040
|
+
* @param value — the value to test.
|
|
1041
|
+
* @returns `true` if `value` is a Cordis context, narrowing its type.
|
|
1042
|
+
*/
|
|
1043
|
+
static is(value: any): value is Context;
|
|
1044
|
+
/** Create the root context and install the built-in services. */
|
|
1045
|
+
constructor();
|
|
1046
|
+
/**
|
|
1047
|
+
* Create a child context with extra metadata on top of the current scope.
|
|
1048
|
+
*
|
|
1049
|
+
* The child prototypally inherits every property of this context; own
|
|
1050
|
+
* properties of `meta` shadow the inherited ones. The parent is not mutated.
|
|
1051
|
+
*
|
|
1052
|
+
* @param meta — own properties (including symbol keys) to define on the child.
|
|
1053
|
+
* @returns a child context inheriting from this one.
|
|
1054
|
+
*/
|
|
1055
|
+
extend(meta?: {}): this;
|
|
1056
|
+
/**
|
|
1057
|
+
* Create a child context with an independent service scope for `name`.
|
|
1058
|
+
*
|
|
1059
|
+
* Below the returned context, reads and writes of the service `name`
|
|
1060
|
+
* resolve against the new label instead of the parent's, so a different
|
|
1061
|
+
* implementation can be provided without affecting the parent scope.
|
|
1062
|
+
* Passing the same `label` to two `isolate()` calls joins their scopes.
|
|
1063
|
+
*
|
|
1064
|
+
* @param name — the service name to isolate.
|
|
1065
|
+
* @param label — scope label to join; defaults to a fresh unique symbol.
|
|
1066
|
+
* @returns a child context whose `name` service resolves in the new scope.
|
|
1067
|
+
*/
|
|
1068
|
+
isolate(name: string, label?: symbol): this;
|
|
1069
|
+
/**
|
|
1070
|
+
* Add service-specific intercept config for plugins started below this
|
|
1071
|
+
* context.
|
|
1072
|
+
*
|
|
1073
|
+
* Plugins loaded under the returned context see `config` merged into the
|
|
1074
|
+
* service's resolved config (ancestor entries first; see
|
|
1075
|
+
* `Service[symbols.resolveConfig]`). The parent context is not affected.
|
|
1076
|
+
*
|
|
1077
|
+
* @param name — the service name whose config to intercept.
|
|
1078
|
+
* @param config — the intercept config to merge for that service.
|
|
1079
|
+
* @returns a child context carrying the additional intercept entry.
|
|
1080
|
+
*/
|
|
1081
|
+
intercept<K extends InjectKey>(name: K, config: Context[K] extends {
|
|
1082
|
+
[symbols.config]: infer T;
|
|
1083
|
+
} ? T : never): this;
|
|
1084
|
+
intercept(name: string, config: any): this;
|
|
1085
|
+
}
|
|
1086
|
+
//#endregion
|
|
1087
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cordis@4.0.1_@deepseek-ai+cordis-plugin-include@1.0.6_@deepseek-ai+cordis-plugin-loader@1.0.2/node_modules/@deepseek-ai/cordis/lib/types/service.d.ts
|
|
1088
|
+
/**
|
|
1089
|
+
* Base class for services that expose a named API on `ctx`.
|
|
1090
|
+
*
|
|
1091
|
+
* Subclasses call `super(ctx, name)` from their constructor. The service is
|
|
1092
|
+
* registered immediately and is automatically removed with the owning fiber.
|
|
1093
|
+
*/
|
|
1094
|
+
declare abstract class Service<out T = never> {
|
|
1095
|
+
protected ctx: Context;
|
|
1096
|
+
/** Symbol key of an instance method run after construction (class plugins). */
|
|
1097
|
+
static readonly init: unique symbol;
|
|
1098
|
+
/** Symbol key of the availability predicate passed to `ctx.provide()`. */
|
|
1099
|
+
static readonly check: unique symbol;
|
|
1100
|
+
/** Symbol key of the phantom intercept-config type parameter. */
|
|
1101
|
+
static readonly config: unique symbol;
|
|
1102
|
+
/** Symbol key of the call body making a service callable (e.g. `ctx.logger()`). */
|
|
1103
|
+
static readonly invoke: unique symbol;
|
|
1104
|
+
/** Symbol key of the helper deriving an extended service instance. */
|
|
1105
|
+
static readonly extend: unique symbol;
|
|
1106
|
+
/** Symbol key of the tracker metadata used for context tracing. */
|
|
1107
|
+
static readonly tracker: unique symbol;
|
|
1108
|
+
/** Symbol key of the intercept-config resolution helper below. */
|
|
1109
|
+
static readonly resolveConfig: unique symbol;
|
|
1110
|
+
[symbols.config]: T;
|
|
1111
|
+
/** The service name this instance is registered under. */
|
|
1112
|
+
name: string;
|
|
1113
|
+
/**
|
|
1114
|
+
* Register this instance as `name` in the current context.
|
|
1115
|
+
*
|
|
1116
|
+
* Calls `ctx.reflect.provide(name, this, this[Service.check])`, so the
|
|
1117
|
+
* service is unregistered automatically when the owning fiber unloads.
|
|
1118
|
+
* Services with a `[Service.invoke]` body return a callable instance.
|
|
1119
|
+
*
|
|
1120
|
+
* @param ctx — the context to register in (stored as `this.ctx`).
|
|
1121
|
+
* @param name — the service name; defaults to the static `provide` field.
|
|
1122
|
+
*/
|
|
1123
|
+
constructor(ctx: Context, name: string);
|
|
1124
|
+
protected [symbols.filter](ctx: Context): boolean;
|
|
1125
|
+
protected [symbols.extend](props?: any): any;
|
|
1126
|
+
/**
|
|
1127
|
+
* Merge intercept config from ancestors with optional base and head values.
|
|
1128
|
+
*
|
|
1129
|
+
* Entries added closer to the root apply first; `base` is prepended and
|
|
1130
|
+
* `head` appended. Uses `Config.merge` when the service declares one,
|
|
1131
|
+
* otherwise a shallow `Object.assign`.
|
|
1132
|
+
*
|
|
1133
|
+
* @param base — lowest-precedence config merged before all intercepts.
|
|
1134
|
+
* @param head — highest-precedence config merged after all intercepts.
|
|
1135
|
+
* @returns the merged config.
|
|
1136
|
+
*/
|
|
1137
|
+
[symbols.resolveConfig](base?: T, head?: T): T;
|
|
1138
|
+
static [Symbol.hasInstance](instance: any): boolean;
|
|
1139
|
+
}
|
|
1140
|
+
//#endregion
|
|
1141
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+schemastery@3.18.1/node_modules/@deepseek-ai/schemastery/lib/types/index.d.ts
|
|
1142
|
+
declare const kSchema: unique symbol;
|
|
1143
|
+
declare global {
|
|
1144
|
+
namespace Schemastery {
|
|
1145
|
+
/** Convert primitive constructors, constants, and existing schemas into a schema type. */
|
|
1146
|
+
type From<X> = X extends string | number | boolean ? Schema<X> : X extends Schema ? X : X extends typeof String ? Schema<string> : X extends typeof Number ? Schema<number> : X extends typeof Boolean ? Schema<boolean> : X extends typeof Function ? Schema<Function, (...args: any[]) => any> : X extends Constructor<infer S> ? Schema<S> : never;
|
|
1147
|
+
type TypeS1<X> = X extends Schema<infer S, unknown> ? S : never;
|
|
1148
|
+
type Inverse<X> = X extends Schema<any, infer Y> ? (arg: Y) => void : never;
|
|
1149
|
+
/** Input type accepted by a schema-like value. */
|
|
1150
|
+
type TypeS<X> = TypeS1<From<X>>;
|
|
1151
|
+
/** Output type returned by a schema-like value after validation. */
|
|
1152
|
+
type TypeT<X> = ReturnType<From<X>>;
|
|
1153
|
+
/** Resolver callback used by custom schema types registered with `Schema.extend()`. */
|
|
1154
|
+
type Resolve = (data: any, schema: Schema, options: Options, strict?: boolean) => [any, any?];
|
|
1155
|
+
/** Input type accepted by one schema in an intersection. */
|
|
1156
|
+
type IntersectS<X> = From<X> extends Schema<infer S, unknown> ? S : never;
|
|
1157
|
+
/** Output type returned by one schema in an intersection. */
|
|
1158
|
+
type IntersectT<X> = Inverse<From<X>> extends ((arg: infer T) => void) ? T : never;
|
|
1159
|
+
type TupleS<X extends readonly any[]> = X extends readonly [infer L, ...infer R] ? [TypeS<L>?, ...TupleS<R>] : any[];
|
|
1160
|
+
type TupleT<X extends readonly any[]> = X extends readonly [infer L, ...infer R] ? [TypeT<L>?, ...TupleT<R>] : any[];
|
|
1161
|
+
type ObjectS<X extends Dict> = { [K in keyof X]?: TypeS<X[K]> | null } & Dict;
|
|
1162
|
+
type ObjectT<X extends Dict> = { [K in keyof X]: TypeT<X[K]> } & Dict;
|
|
1163
|
+
type Constructor<T = any> = new (...args: any[]) => T;
|
|
1164
|
+
/** Static constructor and factory methods exposed by the default `Schema` export. */
|
|
1165
|
+
interface Static {
|
|
1166
|
+
<T = any>(options: Partial<Schema<T>>): Schema<T>;
|
|
1167
|
+
new <T = any>(options: Partial<Schema<T>>): Schema<T>;
|
|
1168
|
+
prototype: Schema;
|
|
1169
|
+
/** Validate a value against a schema node and return `[output, adaptedInput?]`. */
|
|
1170
|
+
resolve: Resolve;
|
|
1171
|
+
/** Infer a schema from a primitive value, constructor, or existing schema. */
|
|
1172
|
+
from<X = any>(source?: X): From<X>;
|
|
1173
|
+
/** Register a resolver for a custom schema `type`. */
|
|
1174
|
+
extend(type: string, resolve: Resolve): void;
|
|
1175
|
+
/** Accept any value without validation. */
|
|
1176
|
+
any<T = any>(): Schema<T>;
|
|
1177
|
+
/** Accept only nullable input. */
|
|
1178
|
+
never(): Schema<never>;
|
|
1179
|
+
/** Accept exactly one constant value. */
|
|
1180
|
+
const<const T>(value: T): Schema<T>;
|
|
1181
|
+
/** Accept strings, with optional metadata constraints added by instance methods. */
|
|
1182
|
+
string(): Schema<string>;
|
|
1183
|
+
/** Accept numbers, with optional range and step constraints. */
|
|
1184
|
+
number(): Schema<number>;
|
|
1185
|
+
/** Accept non-negative integer numbers. */
|
|
1186
|
+
natural(): Schema<number>;
|
|
1187
|
+
/** Accept a number between 0 and 1 and mark it as a slider. */
|
|
1188
|
+
percent(): Schema<number>;
|
|
1189
|
+
/** Accept booleans. */
|
|
1190
|
+
boolean(): Schema<boolean>;
|
|
1191
|
+
/** Accept `Date` instances or parse datetime strings into `Date` objects. */
|
|
1192
|
+
date(): Schema<string | Date, Date>;
|
|
1193
|
+
/** Accept `RegExp` instances or parse strings into regular expressions. */
|
|
1194
|
+
regExp(flag?: string): Schema<string | RegExp, RegExp>;
|
|
1195
|
+
/** Accept binary sources and normalize them to `ArrayBufferLike`. */
|
|
1196
|
+
arrayBuffer(): Schema<Binary.Source, ArrayBufferLike>;
|
|
1197
|
+
arrayBuffer(encoding: 'hex' | 'base64'): Schema<Binary.Source | string, ArrayBufferLike>;
|
|
1198
|
+
/** Accept a numeric bitset or string keys and normalize to a number. */
|
|
1199
|
+
bitset<K extends string>(bits: Partial<Record<K, number>>): Schema<number | readonly K[], number>;
|
|
1200
|
+
/** Accept functions. */
|
|
1201
|
+
function(): Schema<Function, (...args: any[]) => any>;
|
|
1202
|
+
/** Accept instances of a constructor or objects whose constructor name matches. */
|
|
1203
|
+
is(constructor: string): Schema;
|
|
1204
|
+
is<T>(constructor: Constructor<T>): Schema<T>;
|
|
1205
|
+
/** Accept arrays whose elements match `inner`. */
|
|
1206
|
+
array<X>(inner: X): Schema<TypeS<X>[], TypeT<X>[]>;
|
|
1207
|
+
/** Accept plain objects with values matching `inner` and optional key schema. */
|
|
1208
|
+
dict<X, Y extends Schema<any, string> = Schema<string>>(inner: X, sKey?: Y): Schema<Dict<TypeS<X>, TypeS<Y>>, Dict<TypeT<X>, TypeT<Y>>>;
|
|
1209
|
+
/** Accept tuple arrays where each index matches the corresponding schema. */
|
|
1210
|
+
tuple<const X extends readonly any[]>(list: X): Schema<TupleS<X>, TupleT<X>>;
|
|
1211
|
+
/** Accept plain objects whose declared properties match the schema dictionary. */
|
|
1212
|
+
object<X extends Dict>(dict: X): Schema<ObjectS<X>, ObjectT<X>>;
|
|
1213
|
+
/** Accept values matching at least one schema in `list`. */
|
|
1214
|
+
union<const X>(list: readonly X[]): Schema<TypeS<X>, TypeT<X>>;
|
|
1215
|
+
/** Accept values matching every schema in `list`, merging object outputs. */
|
|
1216
|
+
intersect<const X>(list: readonly X[]): Schema<IntersectS<X>, IntersectT<X>>;
|
|
1217
|
+
/** Validate with `inner`, then convert the result with `callback`. */
|
|
1218
|
+
transform<X, T>(inner: X, callback: (value: TypeS<X>, options: Schemastery.Options) => T, preserve?: boolean): Schema<TypeS<X>, T>;
|
|
1219
|
+
/** Defer construction of a recursive schema until validation or serialization. */
|
|
1220
|
+
lazy<X extends Schema>(callback: () => X): X;
|
|
1221
|
+
ValidationError: typeof ValidationError;
|
|
1222
|
+
}
|
|
1223
|
+
/** Runtime validation options shared by all schema calls. */
|
|
1224
|
+
interface Options {
|
|
1225
|
+
/** Remove invalid object properties instead of throwing when possible. */
|
|
1226
|
+
autofix?: boolean;
|
|
1227
|
+
/** Skip validation for selected values and schema nodes. */
|
|
1228
|
+
ignore?(data: any, schema: Schema): boolean;
|
|
1229
|
+
/** Path used to format nested validation errors. */
|
|
1230
|
+
path?: (keyof any)[];
|
|
1231
|
+
}
|
|
1232
|
+
/** UI and validation metadata attached by schema builder methods. */
|
|
1233
|
+
interface Meta<T = any> {
|
|
1234
|
+
default?: T extends {} ? Partial<T> : T;
|
|
1235
|
+
required?: boolean;
|
|
1236
|
+
disabled?: boolean;
|
|
1237
|
+
collapse?: boolean;
|
|
1238
|
+
badges?: {
|
|
1239
|
+
text: string;
|
|
1240
|
+
type: string;
|
|
1241
|
+
}[];
|
|
1242
|
+
hidden?: boolean;
|
|
1243
|
+
loose?: boolean;
|
|
1244
|
+
role?: string;
|
|
1245
|
+
extra?: any;
|
|
1246
|
+
link?: string;
|
|
1247
|
+
description?: string | Dict<string>;
|
|
1248
|
+
comment?: string;
|
|
1249
|
+
pattern?: {
|
|
1250
|
+
source: string;
|
|
1251
|
+
flags?: string;
|
|
1252
|
+
};
|
|
1253
|
+
max?: number;
|
|
1254
|
+
min?: number;
|
|
1255
|
+
step?: number;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
/** Callable schema instance that validates input and returns normalized output. */
|
|
1259
|
+
interface Schemastery<S = any, T = S> {
|
|
1260
|
+
(data?: S | null, options?: Schemastery.Options): T;
|
|
1261
|
+
new (data?: S | null, options?: Schemastery.Options): T;
|
|
1262
|
+
[kSchema]: true;
|
|
1263
|
+
uid: number;
|
|
1264
|
+
meta: Schemastery.Meta<T>;
|
|
1265
|
+
type: string;
|
|
1266
|
+
sKey?: Schema;
|
|
1267
|
+
inner?: Schema;
|
|
1268
|
+
list?: Schema[];
|
|
1269
|
+
dict?: Dict<Schema>;
|
|
1270
|
+
bits?: Dict<number>;
|
|
1271
|
+
callback?: Function;
|
|
1272
|
+
constructor?: string | Function;
|
|
1273
|
+
builder?: Function;
|
|
1274
|
+
value?: T;
|
|
1275
|
+
refs?: Dict<Schema>;
|
|
1276
|
+
preserve?: boolean;
|
|
1277
|
+
'~standard': StandardSchemaV1.Props;
|
|
1278
|
+
/** Format this schema as a compact TypeScript-like type string. */
|
|
1279
|
+
toString(inline?: boolean): string;
|
|
1280
|
+
/** Serialize this schema, preserving shared and recursive references. */
|
|
1281
|
+
toJSON(): Schema<S, T>;
|
|
1282
|
+
/** Mark nullable input as invalid unless a default supplies a fallback. */
|
|
1283
|
+
required(value?: boolean): Schema<S, T>;
|
|
1284
|
+
/** Hide this schema node from UI renderers. */
|
|
1285
|
+
hidden(value?: boolean): Schema<S, T>;
|
|
1286
|
+
/** Return the default value instead of throwing when validation fails. */
|
|
1287
|
+
loose(value?: boolean): Schema<S, T>;
|
|
1288
|
+
/** Attach a renderer role and optional role-specific metadata. */
|
|
1289
|
+
role(text: string, extra?: any): Schema<S, T>;
|
|
1290
|
+
/** Attach an external documentation link. */
|
|
1291
|
+
link(link: string): Schema<S, T>;
|
|
1292
|
+
/** Set the fallback value used for nullable input. */
|
|
1293
|
+
default(value: T): Schema<S, T>;
|
|
1294
|
+
/** Attach an auxiliary comment for documentation or form UIs. */
|
|
1295
|
+
comment(text: string): Schema<S, T>;
|
|
1296
|
+
/** Attach a localized or plain description for documentation or form UIs. */
|
|
1297
|
+
description(text: string): Schema<S, T>;
|
|
1298
|
+
/** Mark this schema node as disabled for form UIs. */
|
|
1299
|
+
disabled(value?: boolean): Schema<S, T>;
|
|
1300
|
+
/** Request collapsed rendering for nested form UIs. */
|
|
1301
|
+
collapse(value?: boolean): Schema<S, T>;
|
|
1302
|
+
/** Add a deprecated badge to this schema node. */
|
|
1303
|
+
deprecated(): Schema<S, T>;
|
|
1304
|
+
/** Add an experimental badge to this schema node. */
|
|
1305
|
+
experimental(): Schema<S, T>;
|
|
1306
|
+
/** Require strings to match a regular expression. */
|
|
1307
|
+
pattern(regexp: RegExp): Schema<S, T>;
|
|
1308
|
+
/** Set an inclusive maximum for numbers or collection lengths. */
|
|
1309
|
+
max(value: number): Schema<S, T>;
|
|
1310
|
+
/** Set an inclusive minimum for numbers or collection lengths. */
|
|
1311
|
+
min(value: number): Schema<S, T>;
|
|
1312
|
+
/** Set the numeric increment constraint. */
|
|
1313
|
+
step(value: number): Schema<S, T>;
|
|
1314
|
+
/** Add or replace an object property schema. */
|
|
1315
|
+
set(key: string, value: Schema): Schema<S, T>;
|
|
1316
|
+
/** Append a tuple, union, or intersection member schema. */
|
|
1317
|
+
push(value: Schema): Schema<S, T>;
|
|
1318
|
+
/** Remove values equal to schema defaults from normalized output. */
|
|
1319
|
+
simplify(value?: any): any;
|
|
1320
|
+
/** Return a schema clone with descriptions merged from locale messages. */
|
|
1321
|
+
i18n(messages: Dict): Schema<S, T>;
|
|
1322
|
+
/** Attach arbitrary metadata consumed by form renderers and downstream tools. */
|
|
1323
|
+
extra<K extends keyof Schemastery.Meta>(key: K, value: Schemastery.Meta[K]): Schema<S, T>;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
declare class ValidationError extends TypeError {
|
|
1327
|
+
options: Schemastery.Options;
|
|
1328
|
+
name: string;
|
|
1329
|
+
constructor(message: string, options: Schemastery.Options);
|
|
1330
|
+
static is(error: any): error is ValidationError;
|
|
1331
|
+
}
|
|
1332
|
+
type Schema<S = any, T = S> = Schemastery<S, T>;
|
|
1333
|
+
declare const Schema: Schemastery.Static;
|
|
1334
|
+
//#endregion
|
|
1335
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+dsh-settings@0.1.0-rc.6_@deepseek-ai+cordis@4.0.1_@deepseek-ai+dsh-brand@0_52495af71738a1095726249ceff4fd7b/node_modules/@deepseek-ai/dsh-settings/lib/types/redact.d.ts
|
|
1336
|
+
/** One schema-declared secret position inside a redacted value. */
|
|
1337
|
+
interface RedactedSecret {
|
|
1338
|
+
/** Path from the section root to the removed field (concrete dict keys and array indexes included). */
|
|
1339
|
+
path: string[];
|
|
1340
|
+
/** Whether the field held a value before redaction. */
|
|
1341
|
+
set: boolean;
|
|
1342
|
+
}
|
|
1343
|
+
//#endregion
|
|
1344
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+dsh-brand@0.1.0-rc.6_@deepseek-ai+cordis@4.0.1_@deepseek-ai+dsh-invariants_757bf6a984ac37281430ad822ab10469/node_modules/@deepseek-ai/dsh-brand/lib/types/index.d.ts
|
|
1345
|
+
/**
|
|
1346
|
+
* The `Branded<B>` nominal-typing primitive — a type-only utility (no runtime
|
|
1347
|
+
* code, no harness-package dependency) shared by every package that owns a
|
|
1348
|
+
* cross-boundary id.
|
|
1349
|
+
*
|
|
1350
|
+
* A brand makes structurally-identical strings non-interchangeable at the type
|
|
1351
|
+
* level: a `SessionId` cannot be passed where a `CallId` is expected, even
|
|
1352
|
+
* though both are plain strings at runtime. Construction goes through a per-id
|
|
1353
|
+
* factory in the OWNING package (a plain cast inside — zero runtime cost);
|
|
1354
|
+
* comparison, logging, and serialization all behave as ordinary strings.
|
|
1355
|
+
*
|
|
1356
|
+
* Policy: a package brands the ids it owns — `CallId` in dsh-llm (tool-call
|
|
1357
|
+
* correlation), the shared agent/session `SessionId` in dsh-session, and
|
|
1358
|
+
* `JobId` in dsh-jobs. Branding is for ids that cross package boundaries and
|
|
1359
|
+
* could plausibly be confused; not every string needs a brand.
|
|
1360
|
+
* This package owns ONLY the primitive — no concrete id, no runtime code beyond
|
|
1361
|
+
* the (erased) type — so the brand vocabulary stays dependency-free and a
|
|
1362
|
+
* package can brand its ids without depending on an unrelated capability
|
|
1363
|
+
* package.
|
|
1364
|
+
*
|
|
1365
|
+
* @module @deepseek-ai/dsh-brand
|
|
1366
|
+
*/
|
|
1367
|
+
declare const BRAND: unique symbol;
|
|
1368
|
+
/** A string carrying a compile-time-only brand `B`. */
|
|
1369
|
+
type Branded<B extends string> = string & {
|
|
1370
|
+
readonly [BRAND]: B;
|
|
1371
|
+
};
|
|
1372
|
+
//#endregion
|
|
1373
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+dsh-settings@0.1.0-rc.6_@deepseek-ai+cordis@4.0.1_@deepseek-ai+dsh-brand@0_52495af71738a1095726249ceff4fd7b/node_modules/@deepseek-ai/dsh-settings/lib/types/types.d.ts
|
|
1374
|
+
/** Nominal id of one registered settings namespace. */
|
|
1375
|
+
type SettingsNamespace = Branded<'SettingsNamespace'>;
|
|
1376
|
+
/** Origin of one committed settings change. */
|
|
1377
|
+
type SettingsUpdateSource = 'update' | 'provider';
|
|
1378
|
+
declare module '@deepseek-ai/cordis' {
|
|
1379
|
+
interface Events {
|
|
1380
|
+
/**
|
|
1381
|
+
* Committed change to one registered namespace's resolved value. Emitted
|
|
1382
|
+
* after the provider persisted (for `update`) or published (`provider`)
|
|
1383
|
+
* the change; never emitted when the resolved value is deep-equal.
|
|
1384
|
+
* Listener failures are contained and logged — a sync throw and an async
|
|
1385
|
+
* rejection alike — except `INVARIANT`-coded failures, which rethrow
|
|
1386
|
+
* after every listener ran; that rethrow reaches the emitter only from
|
|
1387
|
+
* synchronous listeners, so invariant checks on this event must not be
|
|
1388
|
+
* async functions.
|
|
1389
|
+
* @param ns - the namespace whose resolved value changed.
|
|
1390
|
+
* @param next - the new resolved value.
|
|
1391
|
+
* @param prev - the previous resolved value.
|
|
1392
|
+
* @param source - whether the change entered through `update()` or the provider.
|
|
1393
|
+
* @mode emit
|
|
1394
|
+
*/
|
|
1395
|
+
'settings/updated'(ns: SettingsNamespace, next: unknown, prev: unknown, source: SettingsUpdateSource): void;
|
|
1396
|
+
/**
|
|
1397
|
+
* One registered namespace's RAW user section changed, whether or not the
|
|
1398
|
+
* resolved value did. `settings/updated` is the consumer-facing event and
|
|
1399
|
+
* stays deep-equal-gated; this one exists for configuration surfaces,
|
|
1400
|
+
* which must learn that a field went from inherited to overridden (same
|
|
1401
|
+
* resolved value, different meaning) and that their held revision is
|
|
1402
|
+
* stale. Listener containment matches `settings/updated`.
|
|
1403
|
+
* @param ns - the namespace whose stored section changed.
|
|
1404
|
+
* @param revision - the namespace's new revision.
|
|
1405
|
+
* @mode emit
|
|
1406
|
+
*/
|
|
1407
|
+
'settings/document-updated'(ns: SettingsNamespace, revision: number): void;
|
|
1408
|
+
}
|
|
1409
|
+
} //# sourceMappingURL=types.d.ts.map
|
|
1410
|
+
//#endregion
|
|
1411
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+dsh-settings@0.1.0-rc.6_@deepseek-ai+cordis@4.0.1_@deepseek-ai+dsh-brand@0_52495af71738a1095726249ceff4fd7b/node_modules/@deepseek-ai/dsh-settings/lib/types/index.d.ts
|
|
1412
|
+
/** When a namespace's changes take effect for its owner. */
|
|
1413
|
+
type SettingsApplies = 'live' | 'restart';
|
|
1414
|
+
/** Registration options beyond the namespace schema. */
|
|
1415
|
+
interface SettingsRegisterOptions<T> {
|
|
1416
|
+
/** Composition-layer values resolved below the user layer (entry-config subset). */
|
|
1417
|
+
base?: Partial<T>;
|
|
1418
|
+
/** Owner's effect timing, surfaced to configuration UIs; defaults to `live`. */
|
|
1419
|
+
applies?: SettingsApplies;
|
|
1420
|
+
/**
|
|
1421
|
+
* Reject a resolved section the owner could not act on, for constraints its
|
|
1422
|
+
* schema cannot express — a cross-field requirement, or one field's validity
|
|
1423
|
+
* depending on another's. Throwing here refuses the *write* that produced the
|
|
1424
|
+
* value, so a caller learns at `update`/`replace`/`mutate` instead of storing
|
|
1425
|
+
* something that would silently disable the owner.
|
|
1426
|
+
*
|
|
1427
|
+
* Kept separate from the schema because the schema is also what a
|
|
1428
|
+
* configuration surface renders and what an absent section resolves through;
|
|
1429
|
+
* folding a cross-field check into it would change both.
|
|
1430
|
+
*
|
|
1431
|
+
* Once the owner is registered, a stored section that fails this keeps the
|
|
1432
|
+
* namespace's last good value and warns, exactly as a schema failure does,
|
|
1433
|
+
* so an externally edited document cannot strand a running owner. At
|
|
1434
|
+
* registration there is no last good value yet, so a stored section that
|
|
1435
|
+
* already fails rejects the registration itself — again exactly as a schema
|
|
1436
|
+
* failure does.
|
|
1437
|
+
* @param value - the resolved section, schema-valid by construction.
|
|
1438
|
+
*/
|
|
1439
|
+
validate?: (value: T) => void;
|
|
1440
|
+
}
|
|
1441
|
+
/** One registered namespace as surfaced to configuration UIs. */
|
|
1442
|
+
interface SettingsDescriptor {
|
|
1443
|
+
/** The registered namespace. */
|
|
1444
|
+
ns: SettingsNamespace;
|
|
1445
|
+
/** Serialized schemastery schema (`schema.toJSON()`). */
|
|
1446
|
+
schema: unknown;
|
|
1447
|
+
/** Current resolved value. */
|
|
1448
|
+
value: unknown;
|
|
1449
|
+
/**
|
|
1450
|
+
* Monotonic revision of the raw user section this descriptor was read at.
|
|
1451
|
+
* Send it back as `expectedRevision` on a write to refuse a stale one.
|
|
1452
|
+
*/
|
|
1453
|
+
revision: number;
|
|
1454
|
+
/** Registrant's composition `base` layer (detached), when one was declared. */
|
|
1455
|
+
base?: unknown;
|
|
1456
|
+
/**
|
|
1457
|
+
* Raw user section from the stored document (detached), when one exists and
|
|
1458
|
+
* is well-formed; a field's presence here is what marks it user-overridden.
|
|
1459
|
+
*/
|
|
1460
|
+
user?: unknown;
|
|
1461
|
+
/** Owner's declared effect timing. */
|
|
1462
|
+
applies: SettingsApplies;
|
|
1463
|
+
/** Schema-declared secret positions; present only under `redactSecrets`. */
|
|
1464
|
+
secrets?: RedactedSecret[];
|
|
1465
|
+
}
|
|
1466
|
+
/** Options for {@link SettingsProvider.describe}. */
|
|
1467
|
+
interface SettingsDescribeOptions {
|
|
1468
|
+
/**
|
|
1469
|
+
* Strip `role('secret')` fields from `value`/`base`/`user` and enumerate
|
|
1470
|
+
* them in each descriptor's `secrets`. Every wire surface MUST pass this;
|
|
1471
|
+
* the verbatim default exists for same-process configuration UIs only.
|
|
1472
|
+
*/
|
|
1473
|
+
redactSecrets?: boolean;
|
|
1474
|
+
}
|
|
1475
|
+
/** Owner-facing handle for one registered namespace. */
|
|
1476
|
+
interface SettingsScope<T> {
|
|
1477
|
+
/** Current resolved value: schema defaults, then `base`, then the user layer. */
|
|
1478
|
+
get(): T;
|
|
1479
|
+
/**
|
|
1480
|
+
* Observe committed changes to this namespace's resolved value. Invocations
|
|
1481
|
+
* of one callback run asynchronously, one at a time, in commit order; a
|
|
1482
|
+
* rejection is contained and logged like a sync throw. After the disposer
|
|
1483
|
+
* returns, no further invocation starts — one already queued is skipped;
|
|
1484
|
+
* one already started still settles, and service disposal waits for it.
|
|
1485
|
+
* @param callback - invoked after each commit with the next and previous values.
|
|
1486
|
+
* @returns the disposer removing this observer.
|
|
1487
|
+
*/
|
|
1488
|
+
watch(callback: (next: T, prev: T) => void | Promise<void>): () => void;
|
|
1489
|
+
/**
|
|
1490
|
+
* Merge a partial patch into this namespace's user layer and persist it.
|
|
1491
|
+
* @param patch - plain-object patch over the user section; JSON-compatible data
|
|
1492
|
+
* only (non-JSON values reject with their path before anything persists).
|
|
1493
|
+
*/
|
|
1494
|
+
update(patch: object): Promise<void>;
|
|
1495
|
+
/**
|
|
1496
|
+
* Replace this namespace's user section wholesale; absent keys re-inherit
|
|
1497
|
+
* the composition `base` and schema defaults (`replace({})` resets all).
|
|
1498
|
+
* @param section - the complete next user section; JSON-compatible data only,
|
|
1499
|
+
* as for {@link update}.
|
|
1500
|
+
*/
|
|
1501
|
+
replace(section: object): Promise<void>;
|
|
1502
|
+
}
|
|
1503
|
+
declare module '@deepseek-ai/cordis' {
|
|
1504
|
+
interface Context {
|
|
1505
|
+
settings: SettingsProvider;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Deep equality over JSON-compatible data (objects, arrays, primitives) — the
|
|
1510
|
+
* Service Definition's single change-detection predicate, exported so the invariant
|
|
1511
|
+
* companion checks exactly the implementation's relation.
|
|
1512
|
+
* @param a - one JSON-compatible value.
|
|
1513
|
+
* @param b - the other JSON-compatible value.
|
|
1514
|
+
* @returns whether the two values are structurally equal.
|
|
1515
|
+
*/
|
|
1516
|
+
/**
|
|
1517
|
+
* One path-addressed edit to a namespace's user section. Path mutation exists
|
|
1518
|
+
* for a caller holding an INCOMPLETE view of the section — a configuration UI
|
|
1519
|
+
* reads the redacted descriptor, which by construction never received the
|
|
1520
|
+
* `role('secret')` fields. Such a caller can name the field it means without
|
|
1521
|
+
* restating the section: a wholesale `replace` rebuilt from a redacted
|
|
1522
|
+
* document silently deletes every secret the wire never returned.
|
|
1523
|
+
*/
|
|
1524
|
+
type SettingsPathOp = {
|
|
1525
|
+
op: 'set';
|
|
1526
|
+
path: readonly string[];
|
|
1527
|
+
value: unknown;
|
|
1528
|
+
} | {
|
|
1529
|
+
op: 'unset';
|
|
1530
|
+
path: readonly string[];
|
|
1531
|
+
};
|
|
1532
|
+
/**
|
|
1533
|
+
* Abstract settings service. Providers implement raw-document storage
|
|
1534
|
+
* (`load`/`persist`) and push external changes through {@link Settings.publish};
|
|
1535
|
+
* the base class owns namespace registration, resolution, validation, change
|
|
1536
|
+
* detection, and the `settings/updated` commit event.
|
|
1537
|
+
*/
|
|
1538
|
+
declare abstract class SettingsProvider extends Service {
|
|
1539
|
+
private readonly registrations;
|
|
1540
|
+
/** Latest published raw document; empty until the provider's first publish. */
|
|
1541
|
+
private document;
|
|
1542
|
+
/** Per-namespace write chains; settled tails, so a failure never poisons the queue. */
|
|
1543
|
+
private readonly writeQueues;
|
|
1544
|
+
/** In-flight watcher invocation segments, drained by the dispose teardown. */
|
|
1545
|
+
private readonly pendingTails;
|
|
1546
|
+
/** Set at service dispose: refuse new writes while queued ones drain. */
|
|
1547
|
+
private stopped;
|
|
1548
|
+
/** Opaque read of {@link stopped}: control flow cannot narrow it across awaits. */
|
|
1549
|
+
private isStopped;
|
|
1550
|
+
constructor(ctx: Context);
|
|
1551
|
+
/**
|
|
1552
|
+
* Load the provider's document once and publish it before the service
|
|
1553
|
+
* becomes injectable, and register the write-drain teardown. Providers with
|
|
1554
|
+
* their own init (watchers, connections) delegate here first via
|
|
1555
|
+
* `yield* super[Service.init]()`; their disposers then run before the drain.
|
|
1556
|
+
*/
|
|
1557
|
+
[Service.init](): AsyncGenerator<() => Promise<void> | void, void, void>;
|
|
1558
|
+
/** Whether {@link update} may persist through this provider. */
|
|
1559
|
+
abstract readonly writable: boolean;
|
|
1560
|
+
/**
|
|
1561
|
+
* Absolute path of the provider's user-editable document, when its storage
|
|
1562
|
+
* is one local file. Configuration surfaces use this only as availability
|
|
1563
|
+
* metadata; the guarded open operation resolves the path again Host-side.
|
|
1564
|
+
* Non-file providers leave it undefined and expose no open-document affordance.
|
|
1565
|
+
* @returns the absolute local document path, or undefined for non-file storage.
|
|
1566
|
+
*/
|
|
1567
|
+
get documentPath(): string | undefined;
|
|
1568
|
+
/**
|
|
1569
|
+
* Prepare the provider's user-editable document for a native editor. File
|
|
1570
|
+
* providers may materialize an absent document before returning its path;
|
|
1571
|
+
* non-file providers return undefined.
|
|
1572
|
+
* @returns the absolute local document path, or undefined for non-file storage.
|
|
1573
|
+
*/
|
|
1574
|
+
prepareDocument(): Promise<string | undefined>;
|
|
1575
|
+
/**
|
|
1576
|
+
* Read the provider's current raw document (namespace to raw section).
|
|
1577
|
+
* @returns the detached raw document.
|
|
1578
|
+
*/
|
|
1579
|
+
protected abstract load(): Promise<Record<string, unknown>>;
|
|
1580
|
+
/**
|
|
1581
|
+
* Durably store one namespace's merged user section.
|
|
1582
|
+
* @param ns - the namespace being written.
|
|
1583
|
+
* @param section - the complete merged user section to store.
|
|
1584
|
+
*/
|
|
1585
|
+
protected abstract persist(ns: SettingsNamespace, section: Record<string, unknown>): Promise<void>;
|
|
1586
|
+
/**
|
|
1587
|
+
* Register a namespace schema and receive its owner scope. The registration
|
|
1588
|
+
* is an effect on the calling plugin's fiber: disposing that fiber removes
|
|
1589
|
+
* the namespace and its observers. An invalid stored section fails the
|
|
1590
|
+
* registration itself — the earliest point where the schema can judge it.
|
|
1591
|
+
* @param ns - unique namespace; duplicate registration fails loud.
|
|
1592
|
+
* @param schema - schemastery schema resolving this namespace's value.
|
|
1593
|
+
* @param options - composition `base` layer and effect timing.
|
|
1594
|
+
* @returns the owner scope for reads, observation, and updates.
|
|
1595
|
+
*/
|
|
1596
|
+
register<T>(ns: SettingsNamespace, schema: Schema<T>, options?: SettingsRegisterOptions<T>): SettingsScope<T>;
|
|
1597
|
+
/**
|
|
1598
|
+
* Describe every registered namespace for configuration surfaces, including
|
|
1599
|
+
* the composition `base` and raw user layers so a form can mark which fields
|
|
1600
|
+
* the user overrode (presence in `user`) and what a reset returns to.
|
|
1601
|
+
* @param options - redaction switch; wire surfaces must redact.
|
|
1602
|
+
* @returns one descriptor per registered namespace, in registration order.
|
|
1603
|
+
*/
|
|
1604
|
+
describe(options?: SettingsDescribeOptions): SettingsDescriptor[];
|
|
1605
|
+
/**
|
|
1606
|
+
* Read one registered namespace's resolved value.
|
|
1607
|
+
* @param ns - the namespace to read.
|
|
1608
|
+
* @returns the resolved value, or `undefined` while unregistered.
|
|
1609
|
+
*/
|
|
1610
|
+
get(ns: SettingsNamespace): unknown;
|
|
1611
|
+
/**
|
|
1612
|
+
* Merge a patch into one registered namespace's user layer, validate the
|
|
1613
|
+
* resolved candidate, persist through the provider, then commit and emit.
|
|
1614
|
+
* A validation failure rejects before anything is persisted. Writes to one
|
|
1615
|
+
* namespace are serialized: concurrent updates apply in call order, each
|
|
1616
|
+
* merging over the previous write's committed section.
|
|
1617
|
+
* @param ns - the registered namespace to update.
|
|
1618
|
+
* @param patch - plain-object patch over the user section.
|
|
1619
|
+
* @param expectedRevision - the descriptor `revision` the caller read; a
|
|
1620
|
+
* namespace that moved past it rejects with {@link SettingsConflictError}.
|
|
1621
|
+
*/
|
|
1622
|
+
update(ns: SettingsNamespace, patch: object, expectedRevision?: number): Promise<void>;
|
|
1623
|
+
/**
|
|
1624
|
+
* Replace one registered namespace's user section wholesale, validate,
|
|
1625
|
+
* persist, then commit and emit. Keys absent from `section` fall back to the
|
|
1626
|
+
* composition `base` and schema defaults — this is the removal/reset path a
|
|
1627
|
+
* merge-only patch cannot express (`replace({})` re-inherits everything).
|
|
1628
|
+
* @param ns - the registered namespace to replace.
|
|
1629
|
+
* @param section - the complete next user section.
|
|
1630
|
+
* @param expectedRevision - the descriptor `revision` the caller read; a
|
|
1631
|
+
* namespace that moved past it rejects with {@link SettingsConflictError}.
|
|
1632
|
+
*/
|
|
1633
|
+
replace(ns: SettingsNamespace, section: object, expectedRevision?: number): Promise<void>;
|
|
1634
|
+
/**
|
|
1635
|
+
* Apply path-addressed edits to one registered namespace's user section,
|
|
1636
|
+
* validate, persist, then commit and emit. The ops are applied to the
|
|
1637
|
+
* section as it stands when the write reaches the front of the queue, so a
|
|
1638
|
+
* caller never has to restate fields it did not touch — and, crucially,
|
|
1639
|
+
* cannot delete fields it never saw. This is the write path for any caller
|
|
1640
|
+
* holding a redacted view; `replace` remains the wholesale reset.
|
|
1641
|
+
* @param ns - the registered namespace to edit.
|
|
1642
|
+
* @param ops - ordered path edits; later ops observe earlier ones.
|
|
1643
|
+
* @param expectedRevision - the descriptor `revision` the caller read; a
|
|
1644
|
+
* namespace that moved past it rejects with {@link SettingsConflictError}.
|
|
1645
|
+
*/
|
|
1646
|
+
mutate(ns: SettingsNamespace, ops: readonly SettingsPathOp[], expectedRevision?: number): Promise<void>;
|
|
1647
|
+
/** Validate a write, then queue it on the namespace's serialized write chain. */
|
|
1648
|
+
private write;
|
|
1649
|
+
/**
|
|
1650
|
+
* Provider hook: commit a complete raw document observed in storage. Each
|
|
1651
|
+
* registered namespace re-resolves; an invalid section keeps that
|
|
1652
|
+
* namespace's last good value and warns, other namespaces still commit.
|
|
1653
|
+
* @param doc - the detached raw document (unregistered sections preserved).
|
|
1654
|
+
* @param source - change origin; defaults to `provider`.
|
|
1655
|
+
*/
|
|
1656
|
+
protected publish(doc: Record<string, unknown>, source?: SettingsUpdateSource): void;
|
|
1657
|
+
/** Read one namespace's raw user section, rejecting non-object sections. */
|
|
1658
|
+
private section;
|
|
1659
|
+
/** Resolve one namespace value: schema defaults, then `base`, then the user layer. */
|
|
1660
|
+
private resolve;
|
|
1661
|
+
/**
|
|
1662
|
+
* Advance a namespace's revision when its RAW section changed, and announce
|
|
1663
|
+
* it. Deliberately independent of {@link commit}'s resolved-value equality:
|
|
1664
|
+
* storing an override equal to the composition base leaves the resolved
|
|
1665
|
+
* value alone but changes what the document says, which is exactly what a
|
|
1666
|
+
* configuration surface must re-read.
|
|
1667
|
+
*/
|
|
1668
|
+
private bumpRevision;
|
|
1669
|
+
/** Contained fan-out of `settings/document-updated`, mirroring {@link commit}'s. */
|
|
1670
|
+
private emitDocumentUpdated;
|
|
1671
|
+
/** Commit a resolved value when changed: swap, notify watchers, emit the event. */
|
|
1672
|
+
private commit;
|
|
1673
|
+
/** Contained-watcher diagnostic shared by the sync and async failure paths. */
|
|
1674
|
+
private warnWatcherFailure;
|
|
1675
|
+
/** Contained-listener diagnostic shared by the sync and async failure paths. */
|
|
1676
|
+
private warnListenerFailure;
|
|
1677
|
+
}
|
|
1678
|
+
//#endregion
|
|
1679
|
+
//#region src/protocol.d.ts
|
|
1680
|
+
/** Agent role, the preset-loader key. */
|
|
1681
|
+
type RezRoleId = 'engineer' | 'sales' | 'operations' | 'all';
|
|
1682
|
+
/** Transport kinds the in-plugin MCP host can connect. */
|
|
1683
|
+
type RezMcpTransport = 'stdio' | 'streamable-http';
|
|
1684
|
+
/** One MCP server launch descriptor (standard MCP-style config). */
|
|
1685
|
+
interface RezMcpServerSpec {
|
|
1686
|
+
/** Master switch for this server. */
|
|
1687
|
+
enabled: boolean;
|
|
1688
|
+
/** stdio or streamable-http. */
|
|
1689
|
+
transport: RezMcpTransport;
|
|
1690
|
+
/** stdio executable (npx, uvx, node, absolute binary, ...). */
|
|
1691
|
+
command?: string;
|
|
1692
|
+
/** stdio args passed without shell interpolation. */
|
|
1693
|
+
args?: string[];
|
|
1694
|
+
/** stdio env merged over the scrubbed parent env. */
|
|
1695
|
+
env?: Record<string, string>;
|
|
1696
|
+
/** stdio working directory. */
|
|
1697
|
+
cwd?: string;
|
|
1698
|
+
/** streamable-http endpoint URL. */
|
|
1699
|
+
url?: string;
|
|
1700
|
+
/** streamable-http request headers (Authorization, ...). */
|
|
1701
|
+
headers?: Record<string, string>;
|
|
1702
|
+
/** Per-tool-call timeout in milliseconds. */
|
|
1703
|
+
toolCallTimeoutMs?: number;
|
|
1704
|
+
}
|
|
1705
|
+
/** Full plugin configuration persisted under ~/.dsh/dsh-rez-suite.json. */
|
|
1706
|
+
interface RezConfig {
|
|
1707
|
+
enabled: boolean;
|
|
1708
|
+
announceToAgent: boolean;
|
|
1709
|
+
role: RezRoleId;
|
|
1710
|
+
servers: Record<string, RezMcpServerSpec>;
|
|
1711
|
+
billing: {
|
|
1712
|
+
inputCostPer1k: number;
|
|
1713
|
+
outputCostPer1k: number;
|
|
1714
|
+
monthlyBudget: number;
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
//#endregion
|
|
1718
|
+
//#region src/index.d.ts
|
|
1719
|
+
declare const name = "rez-suite";
|
|
1720
|
+
declare const inject: string[];
|
|
1721
|
+
declare const REZ_SETTINGS_NAMESPACE: SettingsNamespace;
|
|
1722
|
+
declare const Config: Schema<RezConfig>;
|
|
1723
|
+
declare const REZ_GUIDANCE: string;
|
|
1724
|
+
declare function apply(ctx: Context, config?: RezConfig): void;
|
|
1725
|
+
//#endregion
|
|
1726
|
+
export { Config, REZ_GUIDANCE, REZ_SETTINGS_NAMESPACE, apply, inject, name };
|