dsh-model-think-level 2.1.0 → 2.3.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.
Files changed (35) hide show
  1. package/README.md +7 -4
  2. package/lib/autofill.d.ts +20 -2
  3. package/lib/client/ConfigPane.d.ts +6 -6
  4. package/lib/client/image-config-client.d.ts +6 -23
  5. package/lib/client/index.d.ts +1 -0
  6. package/lib/client/injection/compat-guard.d.ts +33 -0
  7. package/lib/client/injection/image-card.d.ts +19 -7
  8. package/lib/client/injection/key-prefetch.d.ts +13 -1
  9. package/lib/client/injection/model-order-drag.d.ts +1 -1
  10. package/lib/client/injection/models-page-editor.d.ts +1 -2
  11. package/lib/client/injection/models-page-mutation.d.ts +6 -0
  12. package/lib/client/injection/provider-balance.d.ts +12 -1
  13. package/lib/client/injection/provider-delete-seat.d.ts +4 -1
  14. package/lib/client/injection/provider-disabled-group.d.ts +4 -1
  15. package/lib/client/injection/provider-order-drag.d.ts +5 -1
  16. package/lib/client/injection/provider-toggle.d.ts +4 -1
  17. package/lib/client/key-manager-client.d.ts +21 -9
  18. package/lib/client/locales.d.ts +7 -25
  19. package/lib/client/model-order.d.ts +9 -0
  20. package/lib/client/order-sync.d.ts +74 -0
  21. package/lib/client/provider-enabled.d.ts +11 -0
  22. package/lib/client/styles.d.ts +1 -1
  23. package/lib/client.js +22 -166
  24. package/lib/client.js.map +4 -4
  25. package/lib/constants.d.ts +15 -7
  26. package/lib/image/command.d.ts +1 -1
  27. package/lib/image/deadline.d.ts +13 -0
  28. package/lib/image/generate.d.ts +8 -5
  29. package/lib/image/tool.d.ts +12 -3
  30. package/lib/index.js +848 -334
  31. package/lib/index.js.map +4 -4
  32. package/lib/key-index.d.ts +11 -0
  33. package/lib/knowledge.d.ts +26 -0
  34. package/lib/order-store.d.ts +100 -0
  35. package/package.json +1 -1
@@ -80,6 +80,21 @@ export declare const HEADERS_CONFIG_PATH = "/dsh-model-think-level/headers-confi
80
80
  * plumbing: run challenges through the llm service, parse, store.
81
81
  */
82
82
  export declare const FINGERPRINT_PATH = "/dsh-model-think-level/fingerprint";
83
+ /**
84
+ * Same-origin host route owning the UI-order document: the provider-row
85
+ * sequence and every provider's model-row sequence the user set by dragging
86
+ * on the official Models page. `GET` answers the stored document,
87
+ * `POST` folds a (whole-state) payload over it — the synced copy the browser
88
+ * half pulls at boot and pushes on every drag, so the orderings survive a
89
+ * machine switch (see {@link ORDER_FILE}).
90
+ */
91
+ export declare const ORDER_PATH = "/dsh-model-think-level/ui-order";
92
+ /**
93
+ * File name of the UI-order document inside the plugin's home dir. Holds no
94
+ * secrets — provider routes and model ids only — which is what makes it safe
95
+ * to carry through a sync mechanism.
96
+ */
97
+ export declare const ORDER_FILE = "ui-order.json";
83
98
  /** The settings namespace this plugin edits: pi-ai custom provider routes. */
84
99
  export declare const PI_AI_NS = "llm-pi-ai";
85
100
  /**
@@ -150,13 +165,6 @@ export declare const DEFAULT_EFFORT_FIELD = "defaultEffort";
150
165
  * {@link IMAGE_CONFIG_FILE}).
151
166
  */
152
167
  export declare const IMAGE_CONFIG_PATH = "/dsh-model-think-level/image-config";
153
- /**
154
- * Same-origin host route that runs one image generation through the shared
155
- * core (`src/image/generate.ts`): the explicit entry beside the native
156
- * `generate_image` tool and the `/生图` host command — used for scripted calls
157
- * and for callers that want the file paths back.
158
- */
159
- export declare const IMAGE_GENERATE_PATH = "/dsh-model-think-level/image-generate";
160
168
  /** File name of the image-generation config inside the plugin's home dir. */
161
169
  export declare const IMAGE_CONFIG_FILE = "image.json";
162
170
  /**
@@ -8,7 +8,7 @@
8
8
  * shape the built-in command plugins use (the dsh-command-goal precedent).
9
9
  *
10
10
  * The handler is a thin argument parser over the SHARED generation core —
11
- * the same `generateImage` the dispatch and the `/image-generate` route call.
11
+ * the same `generateImage` the native `generate_image` tool calls.
12
12
  *
13
13
  * @module dsh-model-think-level/image/command
14
14
  */
@@ -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;