dsh-desktop-enhance 0.6.13 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/lib/client.js +832 -7
- package/lib/index.d.ts +193 -5
- package/lib/index.js +852 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ interface HostContext {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
interface HostSession {
|
|
23
|
-
deriveMessages(): readonly HostMessage[];
|
|
23
|
+
deriveMessages(): readonly HostMessage$1[];
|
|
24
24
|
requestHeader(): {
|
|
25
25
|
readonly config?: HostRoute;
|
|
26
26
|
} | undefined;
|
|
@@ -29,7 +29,7 @@ interface HostRoute {
|
|
|
29
29
|
readonly provider?: string;
|
|
30
30
|
readonly model?: string;
|
|
31
31
|
}
|
|
32
|
-
interface HostMessage {
|
|
32
|
+
interface HostMessage$1 {
|
|
33
33
|
readonly role?: string;
|
|
34
34
|
readonly content?: readonly {
|
|
35
35
|
readonly type?: string;
|
|
@@ -43,7 +43,7 @@ interface HostMessage {
|
|
|
43
43
|
interface HostGenerateOptions {
|
|
44
44
|
readonly provider: string;
|
|
45
45
|
readonly model: string;
|
|
46
|
-
readonly messages: readonly HostMessage[];
|
|
46
|
+
readonly messages: readonly HostMessage$1[];
|
|
47
47
|
readonly system?: string;
|
|
48
48
|
readonly maxTokens?: number;
|
|
49
49
|
readonly sessionId?: string;
|
|
@@ -72,8 +72,8 @@ declare function routeOf(session: HostSession): {
|
|
|
72
72
|
provider: string;
|
|
73
73
|
model: string;
|
|
74
74
|
} | null;
|
|
75
|
-
declare function buildMessages(history: readonly HostMessage[], instruction: string): HostMessage[];
|
|
76
|
-
declare function knownNamesOf(messages: readonly HostMessage[]): ReadonlySet<string> | null;
|
|
75
|
+
declare function buildMessages(history: readonly HostMessage$1[], instruction: string): HostMessage$1[];
|
|
76
|
+
declare function knownNamesOf(messages: readonly HostMessage$1[]): ReadonlySet<string> | null;
|
|
77
77
|
declare function handleSuggest(ctx: HostContext, request: Request, timeoutMs?: number): Promise<Response>;
|
|
78
78
|
declare function quietEffortFor(llm: HostLlm, route: {
|
|
79
79
|
readonly provider: string;
|
|
@@ -176,6 +176,170 @@ declare function installSkillsPolicy(ctx: ToolsHostContext, readState: (sessionI
|
|
|
176
176
|
declare function handleSkillsCatalog(ctx: HostContext, request?: Request): Promise<Response>;
|
|
177
177
|
declare function registerSkillsRoute(ctx: HostContext): () => void;
|
|
178
178
|
//#endregion
|
|
179
|
+
//#region src/shared/context-policy.d.ts
|
|
180
|
+
type SessionCap = number | null;
|
|
181
|
+
interface NativePolicyInput {
|
|
182
|
+
readonly contextWindow: number;
|
|
183
|
+
readonly reservedOutputTokens: number;
|
|
184
|
+
readonly headroomTokens: number;
|
|
185
|
+
readonly thresholdRatio: number;
|
|
186
|
+
}
|
|
187
|
+
interface ResolvedPolicy {
|
|
188
|
+
readonly nativeThreshold: number;
|
|
189
|
+
readonly effectiveThreshold: number;
|
|
190
|
+
readonly capped: boolean;
|
|
191
|
+
}
|
|
192
|
+
declare function resolvePolicy(input: NativePolicyInput, cap: SessionCap): ResolvedPolicy | null;
|
|
193
|
+
declare function decodeCaps(raw: unknown): Map<string, number>;
|
|
194
|
+
declare function encodeCaps(map: ReadonlyMap<string, number>): string;
|
|
195
|
+
declare function capOf(raw: unknown, sessionId: string): SessionCap;
|
|
196
|
+
declare function withCap(raw: unknown, sessionId: string, cap: SessionCap): string;
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region src/context-manager/host.d.ts
|
|
199
|
+
type PruneState = 'done' | 'queued' | 'noop' | 'failed';
|
|
200
|
+
interface PruneOutcome {
|
|
201
|
+
readonly state: PruneState;
|
|
202
|
+
readonly prunedCount: number;
|
|
203
|
+
readonly charsRemoved: number;
|
|
204
|
+
readonly message?: string;
|
|
205
|
+
}
|
|
206
|
+
interface ContextSnapshot {
|
|
207
|
+
readonly pressure: {
|
|
208
|
+
readonly used: number;
|
|
209
|
+
readonly window: number;
|
|
210
|
+
} | null;
|
|
211
|
+
readonly nativeThreshold: number | null;
|
|
212
|
+
readonly effectiveThreshold: number | null;
|
|
213
|
+
readonly capped: boolean;
|
|
214
|
+
readonly cap: SessionCap;
|
|
215
|
+
readonly measurement: 'usage-backed' | 'estimated';
|
|
216
|
+
readonly cannotCapReason?: string;
|
|
217
|
+
readonly pruneOutcome?: PruneOutcome;
|
|
218
|
+
readonly pruneRevision?: number;
|
|
219
|
+
}
|
|
220
|
+
interface ContextControl {
|
|
221
|
+
snapshot(sessionId: string): Promise<ContextSnapshot>;
|
|
222
|
+
setCap(sessionId: string, cap: SessionCap): Promise<ContextSnapshot>;
|
|
223
|
+
pruneOnce(sessionId: string): Promise<PruneOutcome>;
|
|
224
|
+
}
|
|
225
|
+
interface HostAgentLike {
|
|
226
|
+
readonly id: string;
|
|
227
|
+
readonly session: HostSessionLike;
|
|
228
|
+
runMaintenance?<T>(job: (signal: AbortSignal) => Promise<T> | T): Promise<T>;
|
|
229
|
+
whenIdle?(): Promise<void>;
|
|
230
|
+
}
|
|
231
|
+
interface HostMessage {
|
|
232
|
+
readonly id?: string;
|
|
233
|
+
readonly role?: string;
|
|
234
|
+
readonly content?: readonly {
|
|
235
|
+
readonly type?: string;
|
|
236
|
+
readonly text?: string;
|
|
237
|
+
}[];
|
|
238
|
+
}
|
|
239
|
+
interface HostSessionEvent {
|
|
240
|
+
readonly type: string;
|
|
241
|
+
readonly seq: number;
|
|
242
|
+
readonly data?: {
|
|
243
|
+
readonly message?: HostMessage;
|
|
244
|
+
};
|
|
245
|
+
readonly sourceEventSeqs?: readonly number[];
|
|
246
|
+
readonly surfaceOp?: string | {
|
|
247
|
+
readonly op: string;
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
interface HostSessionLike {
|
|
251
|
+
readonly surface?: {
|
|
252
|
+
readonly nodes?: readonly number[];
|
|
253
|
+
readonly contentGeneration?: number;
|
|
254
|
+
};
|
|
255
|
+
deriveMessages?(): readonly HostMessage[];
|
|
256
|
+
snapshotEvents?(): readonly HostSessionEvent[];
|
|
257
|
+
requestHeader?(): {
|
|
258
|
+
readonly config?: {
|
|
259
|
+
readonly maxTokens?: number;
|
|
260
|
+
readonly provider?: string;
|
|
261
|
+
readonly model?: string;
|
|
262
|
+
};
|
|
263
|
+
} | undefined;
|
|
264
|
+
requestContext?(): {
|
|
265
|
+
readonly contextWindow?: number;
|
|
266
|
+
} | undefined;
|
|
267
|
+
}
|
|
268
|
+
declare function readCap(config: unknown, sessionId: string): SessionCap;
|
|
269
|
+
declare function readContextManagerEnabled(config: unknown): boolean;
|
|
270
|
+
declare function resolveTargetAgent(ctx: HostContext, sessionId: string): Promise<HostAgentLike | undefined>;
|
|
271
|
+
interface ContextControlOptions {
|
|
272
|
+
readonly config: () => unknown;
|
|
273
|
+
readonly save?: (field: string, value: string) => Promise<void>;
|
|
274
|
+
}
|
|
275
|
+
declare function createContextControl(ctx: HostContext, options: ContextControlOptions): {
|
|
276
|
+
consumePending: (sessionId: string) => Promise<void>;
|
|
277
|
+
forgetAgent: (agent: HostAgentLike) => void;
|
|
278
|
+
dispose: () => Promise<void>;
|
|
279
|
+
pruneOnce: (sessionId: string) => Promise<PruneOutcome>;
|
|
280
|
+
snapshot: (sessionId: string) => Promise<ContextSnapshot>;
|
|
281
|
+
setCap: (sessionId: string, cap: SessionCap) => Promise<ContextSnapshot>;
|
|
282
|
+
};
|
|
283
|
+
declare function handleContextRequest(control: ContextControl, request?: Request): Promise<Response>;
|
|
284
|
+
declare function registerContextRoute(ctx: HostContext, control: ContextControl): () => void;
|
|
285
|
+
interface ContextHookHost extends HostContext {
|
|
286
|
+
on?(event: string, listener: (...args: never[]) => unknown, options?: {
|
|
287
|
+
readonly prepend?: boolean;
|
|
288
|
+
}): () => void;
|
|
289
|
+
}
|
|
290
|
+
declare function installContextHooks(ctx: ContextHookHost, control: ReturnType<typeof createContextControl>, options: ContextControlOptions): () => void;
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/shared/skill-recovery.d.ts
|
|
293
|
+
interface SkillLoad {
|
|
294
|
+
readonly name: string;
|
|
295
|
+
readonly seq: number;
|
|
296
|
+
readonly onSurface: boolean;
|
|
297
|
+
}
|
|
298
|
+
interface CompactionSpan {
|
|
299
|
+
readonly seq: number;
|
|
300
|
+
}
|
|
301
|
+
interface RecoveryInput {
|
|
302
|
+
readonly loads: readonly SkillLoad[];
|
|
303
|
+
readonly latestCompaction: CompactionSpan | null;
|
|
304
|
+
readonly available: (name: string) => boolean;
|
|
305
|
+
}
|
|
306
|
+
declare function decideRecovery(input: RecoveryInput): {
|
|
307
|
+
readonly names: readonly string[];
|
|
308
|
+
};
|
|
309
|
+
declare function renderSkillContentForRecovery(skill: {
|
|
310
|
+
readonly name: string;
|
|
311
|
+
readonly provider: string;
|
|
312
|
+
readonly content: string;
|
|
313
|
+
readonly resourceBase?: {
|
|
314
|
+
readonly kind: string;
|
|
315
|
+
readonly path?: string;
|
|
316
|
+
readonly url?: string;
|
|
317
|
+
readonly description?: string;
|
|
318
|
+
};
|
|
319
|
+
}): string;
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/skill-recovery/host.d.ts
|
|
322
|
+
interface HostSessionEventLike {
|
|
323
|
+
readonly type?: string;
|
|
324
|
+
readonly seq?: number;
|
|
325
|
+
readonly data?: unknown;
|
|
326
|
+
}
|
|
327
|
+
interface RecoveryHookHost extends HostContext {
|
|
328
|
+
on?(event: string, listener: (...args: never[]) => unknown, options?: {
|
|
329
|
+
readonly prepend?: boolean;
|
|
330
|
+
}): () => void;
|
|
331
|
+
}
|
|
332
|
+
declare function projectRecoveryState(events: readonly HostSessionEventLike[], surfaceNodes: readonly number[]): {
|
|
333
|
+
loads: SkillLoad[];
|
|
334
|
+
latestCompaction: CompactionSpan | null;
|
|
335
|
+
};
|
|
336
|
+
interface SkillRecoveryOptions {
|
|
337
|
+
readonly enabled: () => boolean;
|
|
338
|
+
readonly available?: (name: string, sessionId: string) => boolean;
|
|
339
|
+
}
|
|
340
|
+
declare function readSkillRecoveryEnabled(config: unknown): boolean;
|
|
341
|
+
declare function installSkillRecovery(ctx: RecoveryHookHost, options: SkillRecoveryOptions): () => void;
|
|
342
|
+
//#endregion
|
|
179
343
|
//#region src/index.d.ts
|
|
180
344
|
export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
181
345
|
findBar: Schema<boolean, boolean, "volatile-defined">;
|
|
@@ -197,6 +361,9 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
197
361
|
sessionToolOverrides: Schema<string, string, "volatile-defined">;
|
|
198
362
|
disabledSkills: Schema<string, string, "volatile-defined">;
|
|
199
363
|
sessionSkillOverrides: Schema<string, string, "volatile-defined">;
|
|
364
|
+
contextManager: Schema<boolean, boolean, "volatile-defined">;
|
|
365
|
+
skillRecovery: Schema<boolean, boolean, "volatile-defined">;
|
|
366
|
+
sessionCompactionCaps: Schema<string, string, "volatile-defined">;
|
|
200
367
|
}>>, Schemastery.ObjectT<NoInfer<{
|
|
201
368
|
findBar: Schema<boolean, boolean, "volatile-defined">;
|
|
202
369
|
turnPrefix: Schema<boolean, boolean, "volatile-defined">;
|
|
@@ -217,6 +384,9 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
217
384
|
sessionToolOverrides: Schema<string, string, "volatile-defined">;
|
|
218
385
|
disabledSkills: Schema<string, string, "volatile-defined">;
|
|
219
386
|
sessionSkillOverrides: Schema<string, string, "volatile-defined">;
|
|
387
|
+
contextManager: Schema<boolean, boolean, "volatile-defined">;
|
|
388
|
+
skillRecovery: Schema<boolean, boolean, "volatile-defined">;
|
|
389
|
+
sessionCompactionCaps: Schema<string, string, "volatile-defined">;
|
|
220
390
|
}>>, "plain">;
|
|
221
391
|
export declare function apply(ctx: ToolsHostContext, config?: unknown): void;
|
|
222
392
|
export declare const __test: {
|
|
@@ -274,6 +444,24 @@ export declare const __test: {
|
|
|
274
444
|
} | null;
|
|
275
445
|
};
|
|
276
446
|
};
|
|
447
|
+
CONTEXT_PATH: string;
|
|
448
|
+
createContextControl: typeof createContextControl;
|
|
449
|
+
handleContextRequest: typeof handleContextRequest;
|
|
450
|
+
installContextHooks: typeof installContextHooks;
|
|
451
|
+
readCap: typeof readCap;
|
|
452
|
+
readContextManagerEnabled: typeof readContextManagerEnabled;
|
|
453
|
+
registerContextRoute: typeof registerContextRoute;
|
|
454
|
+
resolveTargetAgent: typeof resolveTargetAgent;
|
|
455
|
+
capOf: typeof capOf;
|
|
456
|
+
decodeCaps: typeof decodeCaps;
|
|
457
|
+
encodeCaps: typeof encodeCaps;
|
|
458
|
+
resolvePolicy: typeof resolvePolicy;
|
|
459
|
+
withCap: typeof withCap;
|
|
460
|
+
decideRecovery: typeof decideRecovery;
|
|
461
|
+
renderSkillContentForRecovery: typeof renderSkillContentForRecovery;
|
|
462
|
+
installSkillRecovery: typeof installSkillRecovery;
|
|
463
|
+
projectRecoveryState: typeof projectRecoveryState;
|
|
464
|
+
readSkillRecoveryEnabled: typeof readSkillRecoveryEnabled;
|
|
277
465
|
SUGGEST_PATH: string;
|
|
278
466
|
SUGGEST_MODELS_PATH: string;
|
|
279
467
|
SUGGEST_EFFORTS_PATH: string;
|