dsh-desktop-enhance 0.6.13 → 0.7.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/README.md +10 -1
- package/lib/client.js +832 -7
- package/lib/index.d.ts +214 -5
- package/lib/index.js +928 -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,190 @@ 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
|
+
type SkillLoadSource = {
|
|
294
|
+
readonly kind: 'user';
|
|
295
|
+
readonly name: string;
|
|
296
|
+
} | {
|
|
297
|
+
readonly kind: 'tool';
|
|
298
|
+
readonly name: string;
|
|
299
|
+
} | {
|
|
300
|
+
readonly kind: 'recovery';
|
|
301
|
+
readonly name: string;
|
|
302
|
+
};
|
|
303
|
+
interface SkillLoad {
|
|
304
|
+
readonly name: string;
|
|
305
|
+
readonly source: SkillLoadSource;
|
|
306
|
+
readonly seq: number;
|
|
307
|
+
readonly onSurface: boolean;
|
|
308
|
+
}
|
|
309
|
+
interface CompactionSpan {
|
|
310
|
+
readonly seq: number;
|
|
311
|
+
}
|
|
312
|
+
interface RecoveryInput {
|
|
313
|
+
readonly loads: readonly SkillLoad[];
|
|
314
|
+
readonly recoveries: readonly SkillLoad[];
|
|
315
|
+
readonly latestCompaction: CompactionSpan | null;
|
|
316
|
+
readonly available: (name: string) => boolean;
|
|
317
|
+
}
|
|
318
|
+
interface RecoveryDecision {
|
|
319
|
+
readonly names: readonly string[];
|
|
320
|
+
readonly compactionSeq: number | null;
|
|
321
|
+
}
|
|
322
|
+
declare function decideRecovery(input: RecoveryInput): RecoveryDecision;
|
|
323
|
+
declare function renderSkillContentForRecovery(skill: {
|
|
324
|
+
readonly name: string;
|
|
325
|
+
readonly provider: string;
|
|
326
|
+
readonly content: string;
|
|
327
|
+
readonly resourceBase?: {
|
|
328
|
+
readonly kind: string;
|
|
329
|
+
readonly path?: string;
|
|
330
|
+
readonly url?: string;
|
|
331
|
+
readonly description?: string;
|
|
332
|
+
};
|
|
333
|
+
}): string;
|
|
334
|
+
declare function buildRecoveryText(skill: Parameters<typeof renderSkillContentForRecovery>[0]): string;
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region src/skill-recovery/host.d.ts
|
|
337
|
+
interface HostSessionEventLike {
|
|
338
|
+
readonly type?: string;
|
|
339
|
+
readonly seq?: number;
|
|
340
|
+
readonly data?: unknown;
|
|
341
|
+
readonly surfaceOp?: unknown;
|
|
342
|
+
readonly sourceEventSeqs?: readonly number[];
|
|
343
|
+
}
|
|
344
|
+
interface RecoveryHookHost extends HostContext {
|
|
345
|
+
on?(event: string, listener: (...args: never[]) => unknown): () => void;
|
|
346
|
+
}
|
|
347
|
+
interface RecoveryBody {
|
|
348
|
+
readonly name: string;
|
|
349
|
+
readonly text: string;
|
|
350
|
+
}
|
|
351
|
+
declare function projectRecoveryState(events: readonly HostSessionEventLike[], surfaceNodes: readonly number[]): {
|
|
352
|
+
loads: SkillLoad[];
|
|
353
|
+
recoveries: Array<SkillLoad & RecoveryBody>;
|
|
354
|
+
latestCompaction: CompactionSpan | null;
|
|
355
|
+
};
|
|
356
|
+
interface SkillRecoveryOptions {
|
|
357
|
+
readonly enabled: () => boolean;
|
|
358
|
+
readonly available?: (name: string, sessionId: string) => boolean;
|
|
359
|
+
}
|
|
360
|
+
declare function readSkillRecoveryEnabled(config: unknown): boolean;
|
|
361
|
+
declare function installSkillRecovery(ctx: RecoveryHookHost, options: SkillRecoveryOptions): () => void;
|
|
362
|
+
//#endregion
|
|
179
363
|
//#region src/index.d.ts
|
|
180
364
|
export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
181
365
|
findBar: Schema<boolean, boolean, "volatile-defined">;
|
|
@@ -197,6 +381,9 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
197
381
|
sessionToolOverrides: Schema<string, string, "volatile-defined">;
|
|
198
382
|
disabledSkills: Schema<string, string, "volatile-defined">;
|
|
199
383
|
sessionSkillOverrides: Schema<string, string, "volatile-defined">;
|
|
384
|
+
contextManager: Schema<boolean, boolean, "volatile-defined">;
|
|
385
|
+
skillRecovery: Schema<boolean, boolean, "volatile-defined">;
|
|
386
|
+
sessionCompactionCaps: Schema<string, string, "volatile-defined">;
|
|
200
387
|
}>>, Schemastery.ObjectT<NoInfer<{
|
|
201
388
|
findBar: Schema<boolean, boolean, "volatile-defined">;
|
|
202
389
|
turnPrefix: Schema<boolean, boolean, "volatile-defined">;
|
|
@@ -217,6 +404,9 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
217
404
|
sessionToolOverrides: Schema<string, string, "volatile-defined">;
|
|
218
405
|
disabledSkills: Schema<string, string, "volatile-defined">;
|
|
219
406
|
sessionSkillOverrides: Schema<string, string, "volatile-defined">;
|
|
407
|
+
contextManager: Schema<boolean, boolean, "volatile-defined">;
|
|
408
|
+
skillRecovery: Schema<boolean, boolean, "volatile-defined">;
|
|
409
|
+
sessionCompactionCaps: Schema<string, string, "volatile-defined">;
|
|
220
410
|
}>>, "plain">;
|
|
221
411
|
export declare function apply(ctx: ToolsHostContext, config?: unknown): void;
|
|
222
412
|
export declare const __test: {
|
|
@@ -274,6 +464,25 @@ export declare const __test: {
|
|
|
274
464
|
} | null;
|
|
275
465
|
};
|
|
276
466
|
};
|
|
467
|
+
CONTEXT_PATH: string;
|
|
468
|
+
createContextControl: typeof createContextControl;
|
|
469
|
+
handleContextRequest: typeof handleContextRequest;
|
|
470
|
+
installContextHooks: typeof installContextHooks;
|
|
471
|
+
readCap: typeof readCap;
|
|
472
|
+
readContextManagerEnabled: typeof readContextManagerEnabled;
|
|
473
|
+
registerContextRoute: typeof registerContextRoute;
|
|
474
|
+
resolveTargetAgent: typeof resolveTargetAgent;
|
|
475
|
+
capOf: typeof capOf;
|
|
476
|
+
decodeCaps: typeof decodeCaps;
|
|
477
|
+
encodeCaps: typeof encodeCaps;
|
|
478
|
+
resolvePolicy: typeof resolvePolicy;
|
|
479
|
+
withCap: typeof withCap;
|
|
480
|
+
buildRecoveryText: typeof buildRecoveryText;
|
|
481
|
+
decideRecovery: typeof decideRecovery;
|
|
482
|
+
renderSkillContentForRecovery: typeof renderSkillContentForRecovery;
|
|
483
|
+
installSkillRecovery: typeof installSkillRecovery;
|
|
484
|
+
projectRecoveryState: typeof projectRecoveryState;
|
|
485
|
+
readSkillRecoveryEnabled: typeof readSkillRecoveryEnabled;
|
|
277
486
|
SUGGEST_PATH: string;
|
|
278
487
|
SUGGEST_MODELS_PATH: string;
|
|
279
488
|
SUGGEST_EFFORTS_PATH: string;
|