dsh-model-think-level 2.0.2 → 2.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/README.md +49 -23
- package/lib/balance.d.ts +44 -0
- package/lib/client/ComposerSlider.d.ts +19 -0
- package/lib/client/ConfigPane.d.ts +47 -0
- package/lib/client/EffortEditor.d.ts +34 -16
- package/lib/client/KeyManager.d.ts +2 -2
- package/lib/client/balance-client.d.ts +34 -0
- package/lib/client/capacity.d.ts +20 -4
- package/lib/client/configured-inputs.d.ts +11 -2
- package/lib/client/events.d.ts +31 -2
- package/lib/client/fingerprint-runner.d.ts +13 -1
- package/lib/client/image-config-client.d.ts +75 -0
- package/lib/client/injection/autofill-run.d.ts +2 -2
- package/lib/client/injection/config-button-seat.d.ts +96 -0
- package/lib/client/injection/create-key-seat.d.ts +3 -3
- package/lib/client/injection/create-keys-pane.d.ts +4 -2
- package/lib/client/injection/editor-tab-bar.d.ts +1 -1
- package/lib/client/injection/editor-tabs.d.ts +1 -1
- package/lib/client/injection/image-card.d.ts +85 -0
- package/lib/client/injection/imagegen-completion.d.ts +43 -0
- package/lib/client/injection/imagegen-entry.d.ts +22 -0
- package/lib/client/injection/key-prefetch.d.ts +44 -0
- package/lib/client/injection/key-reveal.d.ts +2 -3
- package/lib/client/injection/models-page-editor.d.ts +59 -28
- package/lib/client/injection/models-page.d.ts +15 -3
- package/lib/client/injection/provider-balance.d.ts +83 -0
- package/lib/client/injection/provider-endpoints.d.ts +2 -2
- package/lib/client/injection/row-drag.d.ts +7 -0
- package/lib/client/injection/staged-keys.d.ts +24 -12
- package/lib/client/key-manager-client.d.ts +70 -18
- package/lib/client/locales.d.ts +65 -15
- package/lib/client/ops.d.ts +12 -2
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/types.d.ts +21 -3
- package/lib/client.js +721 -78
- package/lib/client.js.map +4 -4
- package/lib/constants.d.ts +58 -0
- package/lib/detection.d.ts +7 -0
- package/lib/fingerprint/estimate.d.ts +16 -0
- package/lib/fingerprint/run.d.ts +24 -0
- package/lib/fingerprint/store.d.ts +2 -2
- package/lib/fingerprint/verdict.d.ts +53 -3
- package/lib/headers-core.d.ts +3 -1
- package/lib/headers-fetch.d.ts +25 -0
- package/lib/image/command.d.ts +84 -0
- package/lib/image/config.d.ts +150 -0
- package/lib/image/generate.d.ts +135 -0
- package/lib/image/legacy-cleanup.d.ts +29 -0
- package/lib/image/sizes.d.ts +28 -0
- package/lib/image/tool.d.ts +107 -0
- package/lib/index.js +3876 -1745
- package/lib/index.js.map +4 -4
- package/lib/key-index.d.ts +37 -7
- package/lib/key-probe.d.ts +39 -99
- package/lib/key-refs.d.ts +43 -19
- package/lib/key-route-core.d.ts +100 -32
- package/lib/key-serves.d.ts +81 -0
- package/lib/knowledge.d.ts +21 -0
- package/lib/listing.d.ts +18 -20
- package/lib/multi-key-listing.d.ts +3 -3
- package/package.json +1 -8
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-time migration: remove the retired image-MCP server's patch entry.
|
|
3
|
+
*
|
|
4
|
+
* The v2.0.3 image tool was an stdio MCP subprocess installed by splicing a
|
|
5
|
+
* marker block into the current profile's `cordis.patch.yml`. That transport
|
|
6
|
+
* is gone — `lib/image-mcp.mjs` is no longer built — so a leftover block would
|
|
7
|
+
* make the loader spawn a missing file on every boot AND expose a duplicate
|
|
8
|
+
* `mcp__dsh-image__generate_image` beside the native tool. The cleanup runs
|
|
9
|
+
* unconditionally at apply(): absent block → no-op, present block → the exact
|
|
10
|
+
* byte range is spliced out (never a re-serialization of the whole document,
|
|
11
|
+
* because third-party marker blocks share this file), with a timestamped
|
|
12
|
+
* `.bak`, an mtime-fenced retry, and a post-write re-read.
|
|
13
|
+
*
|
|
14
|
+
* The running process keeps whatever it loaded at boot; the removal takes
|
|
15
|
+
* effect on the next start, which the caller's log line says.
|
|
16
|
+
*
|
|
17
|
+
* @module dsh-model-think-level/image/legacy-cleanup
|
|
18
|
+
*/
|
|
19
|
+
/** Marker lines the retired installer owned inside the patch file. */
|
|
20
|
+
export declare const MARK_BEGIN = "# >>> dsh-model-think-level:image-mcp:begin";
|
|
21
|
+
export declare const MARK_END = "# <<< dsh-model-think-level:image-mcp:end";
|
|
22
|
+
/** How the current profile's patch file is located (the installer's own order). */
|
|
23
|
+
export declare function resolveLegacyPatchFile(home?: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Remove the retired MCP marker block if it is present.
|
|
26
|
+
* @returns the patch file that was written, or undefined when there was
|
|
27
|
+
* nothing to remove (absent block, absent file, or an unreadable home).
|
|
28
|
+
*/
|
|
29
|
+
export declare function removeLegacyImageMcpPatch(home?: string, patchFile?: string): string | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The image-size ladder the config pane shows: three friendly tiers over the
|
|
3
|
+
* pixel values the endpoint actually receives.
|
|
4
|
+
*
|
|
5
|
+
* The wire stays pixel-based (`1024x1024` …) — the tiers are presentation only,
|
|
6
|
+
* so relaying the picked value needs no translation. Legacy sizes a config may
|
|
7
|
+
* still hold (`1536x1024`, `512x512`) map to the nearest tier by longest edge;
|
|
8
|
+
* ties keep the smaller tier so the UI never claims more pixels than stored.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-model-think-level/image/sizes
|
|
11
|
+
*/
|
|
12
|
+
/** One size tier: the label the picker shows and the value the wire gets. */
|
|
13
|
+
export interface ImageSizeTier {
|
|
14
|
+
readonly label: '1K' | '2K' | '4K';
|
|
15
|
+
readonly value: string;
|
|
16
|
+
/** The longest edge in pixels; also the sort order of the ladder. */
|
|
17
|
+
readonly edge: number;
|
|
18
|
+
}
|
|
19
|
+
/** The ladder, smallest first. The values are the wire's `size` strings. */
|
|
20
|
+
export declare const IMAGE_SIZE_TIERS: readonly ImageSizeTier[];
|
|
21
|
+
/** The longest edge of a `WxH` size, or undefined for anything else. */
|
|
22
|
+
export declare function longestEdge(size: string): number | undefined;
|
|
23
|
+
/** The tier a stored size maps to (unparsable sizes read as the smallest). */
|
|
24
|
+
export declare function tierOfSize(size: string): ImageSizeTier;
|
|
25
|
+
/** The picker text for a stored size (`1536x1024` → `1K`). */
|
|
26
|
+
export declare function sizeLabel(size: string): string;
|
|
27
|
+
/** The canonical wire value for a stored size (`1536x1024` → `1024x1024`). */
|
|
28
|
+
export declare function canonicalSize(size: string): string;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The native `generate_image` tool — the conversation model's entry to the
|
|
3
|
+
* shared generation core, registered through the host's own `tools` service
|
|
4
|
+
* (the same in-process shape dsh-image-gen uses). Replaces the retired stdio
|
|
5
|
+
* MCP server: no subprocess, no patch-file entry, no env plumbing — the tool
|
|
6
|
+
* runs inside this plugin and reaches the attachment store and the credential
|
|
7
|
+
* service directly.
|
|
8
|
+
*
|
|
9
|
+
* Contract notes that are easy to get wrong:
|
|
10
|
+
* - `ctx.tools.register` REQUIRES `output: { schema, render }` — the schema
|
|
11
|
+
* is enforced against the canonical value `execute` returns, so the shape
|
|
12
|
+
* here and the value built below must agree exactly.
|
|
13
|
+
* - image blocks ride the result CONTENT (`{type:'image', attachment}`), and
|
|
14
|
+
* the host projects them to a text handle for models without image input
|
|
15
|
+
* (dsh-llm `projectImagesForTextModel`) — a text-only chat model calling
|
|
16
|
+
* this tool never breaks.
|
|
17
|
+
* - `exec.signal` MUST reach the core: a user stop must abort the paid
|
|
18
|
+
* upstream request, not just abandon the tool call.
|
|
19
|
+
*
|
|
20
|
+
* @module dsh-model-think-level/image/tool
|
|
21
|
+
*/
|
|
22
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
23
|
+
import { type GenerateDeps } from './generate.js';
|
|
24
|
+
import type { ImageConfig } from './config.js';
|
|
25
|
+
/** The attachment-store face this tool needs, typed structurally. */
|
|
26
|
+
export interface ImageAttachmentsLike {
|
|
27
|
+
saveImage(input: {
|
|
28
|
+
data: Uint8Array;
|
|
29
|
+
mediaType: string;
|
|
30
|
+
name?: string;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
attachmentId: string;
|
|
33
|
+
mediaType: string;
|
|
34
|
+
bytes: number;
|
|
35
|
+
width: number;
|
|
36
|
+
height: number;
|
|
37
|
+
name?: string;
|
|
38
|
+
}>;
|
|
39
|
+
readImage(ref: {
|
|
40
|
+
attachmentId: string;
|
|
41
|
+
}, signal?: AbortSignal): Promise<{
|
|
42
|
+
data: Uint8Array;
|
|
43
|
+
ref?: {
|
|
44
|
+
name?: string;
|
|
45
|
+
mediaType?: string;
|
|
46
|
+
};
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
/** The host tools service face: register and enumerate (for collision checks). */
|
|
50
|
+
export interface ImageToolsLike {
|
|
51
|
+
register(definition: unknown): unknown;
|
|
52
|
+
schemas?: () => readonly {
|
|
53
|
+
name: string;
|
|
54
|
+
}[];
|
|
55
|
+
}
|
|
56
|
+
/** The image-block value shape the tool's canonical value carries per image. */
|
|
57
|
+
export interface ImageToolImage {
|
|
58
|
+
readonly attachment: {
|
|
59
|
+
readonly attachmentId: string;
|
|
60
|
+
readonly mediaType: string;
|
|
61
|
+
readonly bytes: number;
|
|
62
|
+
readonly width: number;
|
|
63
|
+
readonly height: number;
|
|
64
|
+
readonly name?: string;
|
|
65
|
+
};
|
|
66
|
+
readonly filePath: string;
|
|
67
|
+
}
|
|
68
|
+
/** The tool's canonical output value (enforced by `OUTPUT_SCHEMA`). */
|
|
69
|
+
export interface ImageToolValue {
|
|
70
|
+
readonly images: readonly ImageToolImage[];
|
|
71
|
+
readonly model: string;
|
|
72
|
+
readonly prompt: string;
|
|
73
|
+
readonly paramsUsed: {
|
|
74
|
+
readonly size: string;
|
|
75
|
+
readonly quality: string;
|
|
76
|
+
readonly n: number;
|
|
77
|
+
};
|
|
78
|
+
readonly revisions: readonly string[];
|
|
79
|
+
}
|
|
80
|
+
/** The faces the tool needs. All injectable for tests. */
|
|
81
|
+
export interface ImageToolDeps {
|
|
82
|
+
readonly generateDeps: GenerateDeps;
|
|
83
|
+
readonly attachments: ImageAttachmentsLike;
|
|
84
|
+
/** The live config, for the params the hint and the defaults describe. */
|
|
85
|
+
readonly readConfig: () => ImageConfig;
|
|
86
|
+
readonly logger?: {
|
|
87
|
+
warn(message: string): void;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** The primary tool name; the fallback keeps a dsh-image-gen install working. */
|
|
91
|
+
export declare const IMAGE_TOOL_NAME = "generate_image";
|
|
92
|
+
export declare const IMAGE_TOOL_NAME_FALLBACK = "dsh_image_generate";
|
|
93
|
+
/**
|
|
94
|
+
* Register the native tool. The registration goes through the host's
|
|
95
|
+
* `tools.register` under the primary name; a name that is already taken
|
|
96
|
+
* (a dsh-image-gen install owns `generate_image`) falls back to
|
|
97
|
+
* `dsh_image_generate` with one warning — a hard failure here would take the
|
|
98
|
+
* whole plugin down over a name.
|
|
99
|
+
* @returns the registered name (the client's keyed image card reads it back
|
|
100
|
+
* over the config route) and the disposer that unregisters the tool.
|
|
101
|
+
*/
|
|
102
|
+
export declare function registerGenerateImageTool(ctx: Context, deps: ImageToolDeps): {
|
|
103
|
+
readonly name: string;
|
|
104
|
+
readonly dispose: () => void;
|
|
105
|
+
};
|
|
106
|
+
/** The system-prompt hint: which tool to call, what the defaults are. */
|
|
107
|
+
export declare function imageToolHint(config: ImageConfig): string;
|