dsh-model-think-level 2.0.3 → 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.
Files changed (55) hide show
  1. package/README.md +38 -22
  2. package/lib/balance.d.ts +44 -0
  3. package/lib/client/ComposerSlider.d.ts +19 -0
  4. package/lib/client/ConfigPane.d.ts +47 -0
  5. package/lib/client/EffortEditor.d.ts +1 -8
  6. package/lib/client/KeyManager.d.ts +2 -2
  7. package/lib/client/balance-client.d.ts +34 -0
  8. package/lib/client/events.d.ts +31 -2
  9. package/lib/client/image-config-client.d.ts +75 -0
  10. package/lib/client/injection/autofill-run.d.ts +2 -2
  11. package/lib/client/injection/config-button-seat.d.ts +96 -0
  12. package/lib/client/injection/create-key-seat.d.ts +3 -3
  13. package/lib/client/injection/create-keys-pane.d.ts +4 -2
  14. package/lib/client/injection/editor-tab-bar.d.ts +1 -1
  15. package/lib/client/injection/editor-tabs.d.ts +1 -1
  16. package/lib/client/injection/image-card.d.ts +85 -0
  17. package/lib/client/injection/imagegen-completion.d.ts +43 -0
  18. package/lib/client/injection/imagegen-entry.d.ts +22 -0
  19. package/lib/client/injection/key-prefetch.d.ts +44 -0
  20. package/lib/client/injection/key-reveal.d.ts +2 -3
  21. package/lib/client/injection/models-page-editor.d.ts +24 -27
  22. package/lib/client/injection/models-page.d.ts +15 -3
  23. package/lib/client/injection/provider-balance.d.ts +83 -0
  24. package/lib/client/injection/provider-endpoints.d.ts +2 -2
  25. package/lib/client/injection/row-drag.d.ts +7 -0
  26. package/lib/client/injection/staged-keys.d.ts +24 -12
  27. package/lib/client/key-manager-client.d.ts +68 -17
  28. package/lib/client/locales.d.ts +60 -6
  29. package/lib/client/ops.d.ts +1 -0
  30. package/lib/client/styles.d.ts +1 -1
  31. package/lib/client/types.d.ts +4 -1
  32. package/lib/client.js +672 -13
  33. package/lib/client.js.map +4 -4
  34. package/lib/constants.d.ts +45 -0
  35. package/lib/fingerprint/estimate.d.ts +16 -0
  36. package/lib/fingerprint/run.d.ts +6 -0
  37. package/lib/fingerprint/store.d.ts +2 -2
  38. package/lib/fingerprint/verdict.d.ts +24 -0
  39. package/lib/headers-core.d.ts +3 -1
  40. package/lib/headers-fetch.d.ts +25 -0
  41. package/lib/image/command.d.ts +84 -0
  42. package/lib/image/config.d.ts +150 -0
  43. package/lib/image/generate.d.ts +135 -0
  44. package/lib/image/legacy-cleanup.d.ts +29 -0
  45. package/lib/image/sizes.d.ts +28 -0
  46. package/lib/image/tool.d.ts +107 -0
  47. package/lib/index.js +3666 -1534
  48. package/lib/index.js.map +4 -4
  49. package/lib/key-index.d.ts +37 -7
  50. package/lib/key-probe.d.ts +42 -17
  51. package/lib/key-refs.d.ts +43 -19
  52. package/lib/key-route-core.d.ts +100 -32
  53. package/lib/key-serves.d.ts +81 -0
  54. package/lib/listing.d.ts +18 -20
  55. package/package.json +1 -8
@@ -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;