dsh-model-think-level 2.2.0 → 2.3.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.
@@ -70,6 +70,12 @@ export interface ImageDefaults {
70
70
  /** The whole config document, exactly as it sits on disk. */
71
71
  export interface ImageConfig {
72
72
  readonly version: 2;
73
+ /**
74
+ * Whether the image-generation service is on. Off means the native tool is
75
+ * not registered and every generation entry refuses; the models and image
76
+ * params stay in the file untouched, so switching back on costs one click.
77
+ */
78
+ readonly enabled: boolean;
73
79
  /** When `models[]` was last re-derived from the settings document. */
74
80
  readonly syncedAt: string;
75
81
  /** `"<route>/<modelId>"` of the default model, when the user picked one. */
@@ -0,0 +1,13 @@
1
+ /** One cancellable budget shared by every asynchronous phase of an image call. */
2
+ export interface ImageDeadline {
3
+ readonly signal: AbortSignal;
4
+ check(): void;
5
+ run<T>(work: () => T | PromiseLike<T>): Promise<T>;
6
+ dispose(): void;
7
+ }
8
+ /**
9
+ * Factories run only after the cancellation listener is installed. The race
10
+ * bounds even a dependency that ignores signal; both late outcomes are consumed.
11
+ * It cannot physically stop such a dependency or preempt synchronous work.
12
+ */
13
+ export declare function createImageDeadline(timeoutMs: number, caller: AbortSignal | undefined, errorFor: (kind: 'aborted' | 'timeout') => Error): ImageDeadline;
@@ -20,6 +20,7 @@
20
20
  *
21
21
  * @module dsh-model-think-level/image/generate
22
22
  */
23
+ import { type ImageDeadline } from './deadline.js';
23
24
  import { type ImageConfig, type ImageModel } from './config.js';
24
25
  /** What a caller asks for. Everything but `prompt` is optional. */
25
26
  export interface GenerateRequest {
@@ -27,9 +28,9 @@ export interface GenerateRequest {
27
28
  readonly model?: string;
28
29
  readonly prompt: string;
29
30
  /**
30
- * The caller's cancellation (the user pressed stop while the reply stream
31
- * was still pending). Aborts the in-flight images request too, so a stop
32
- * never leaves a paid generation running to completion behind the UI.
31
+ * Caller cancellation is propagated to cooperative dependencies and bounds
32
+ * local waiting even when they ignore it. Aborting HTTP is best effort: it
33
+ * cannot guarantee that a remote paid job or an already-started save stops.
33
34
  */
34
35
  readonly signal?: AbortSignal;
35
36
  readonly size?: string;
@@ -97,7 +98,7 @@ export interface GenerateDeps {
97
98
  /** The live config; read fresh per call (the MCP path re-reads the file). */
98
99
  readonly config?: () => ImageConfig;
99
100
  /** Resolve one credential reference to its value. */
100
- readonly resolveKey: (ref: string) => Promise<string | undefined>;
101
+ readonly resolveKey: (ref: string, signal?: AbortSignal) => Promise<string | undefined>;
101
102
  /** The fetch beneath any wrapper — the images call must not be re-intercepted. */
102
103
  readonly send: typeof globalThis.fetch;
103
104
  /** Base dir for relative `outputDir`s (defaults to the harness home). */
@@ -127,9 +128,11 @@ export declare function promptSlug(prompt: string): string;
127
128
  * name — is created as a directory and receives the slug-timestamp naming.
128
129
  */
129
130
  export declare function resolveDestination(requested: string | undefined, fallbackDir: string, slug: string, now: () => number): string;
131
+ /** The core and native tool use identical cancellation/timeout classification. */
132
+ export declare function createGenerateDeadline(timeoutMs: number, signal?: AbortSignal): ImageDeadline;
130
133
  /**
131
134
  * Run one generation. Reads the config fresh, resolves the model per the
132
135
  * priority chain, merges params, calls the images endpoint (with one pass of
133
136
  * the param fallback chain), decodes and writes the file.
134
137
  */
135
- export declare function generateImage(deps: GenerateDeps, request: GenerateRequest): Promise<GenerateResult>;
138
+ export declare function generateImage(deps: GenerateDeps, request: GenerateRequest, sharedDeadline?: ImageDeadline): Promise<GenerateResult>;
@@ -21,14 +21,15 @@
21
21
  */
22
22
  import type { Context } from '@deepseek-ai/cordis';
23
23
  import { type GenerateDeps } from './generate.js';
24
- import type { ImageConfig } from './config.js';
24
+ import { type ImageConfig } from './config.js';
25
25
  /** The attachment-store face this tool needs, typed structurally. */
26
26
  export interface ImageAttachmentsLike {
27
+ /** Optional adapter signal; one-argument host stores still require a local deadline race. */
27
28
  saveImage(input: {
28
29
  data: Uint8Array;
29
30
  mediaType: string;
30
31
  name?: string;
31
- }): Promise<{
32
+ }, signal?: AbortSignal): Promise<{
32
33
  attachmentId: string;
33
34
  mediaType: string;
34
35
  bytes: number;
@@ -103,5 +104,13 @@ export declare function registerGenerateImageTool(ctx: Context, deps: ImageToolD
103
104
  readonly name: string;
104
105
  readonly dispose: () => void;
105
106
  };
106
- /** The system-prompt hint: which tool to call, what the defaults are. */
107
+ /**
108
+ * The system-prompt hint: which tool to call, what the defaults are.
109
+ *
110
+ * It must describe the SAME model `resolveImageModel` will pick, or the model
111
+ * follows the hint, omits `model`, and gets a `config` error. So the hint asks
112
+ * the resolver itself instead of guessing `models[0]`: with no default set and
113
+ * several candidates the resolver refuses, and the hint then has to say so —
114
+ * naming a model there is a promise the call cannot keep.
115
+ */
107
116
  export declare function imageToolHint(config: ImageConfig): string;
package/lib/index.d.ts CHANGED
@@ -44,6 +44,12 @@ export interface Config {
44
44
  * "try exactly once" (default [1000, 2000, 4000, 8000, 16000, 30000]).
45
45
  */
46
46
  bootRetryDelaysMs?: number[];
47
+ /**
48
+ * How long a key-index route must stay absent from the settings document
49
+ * before the vanish sweep deletes its residue, in milliseconds (default
50
+ * 30000). `0` sweeps on the first absent-reading pass.
51
+ */
52
+ routeSweepGraceMs?: number;
47
53
  /**
48
54
  * Rewrite effort-less calls to forced-thinking ladders into the ladder's
49
55
  * vendor default (default true). Only the request class that today becomes