@mengruo/dsh-vision-toolkit 0.1.2 → 0.1.4
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.i18n.yaml +2 -2
- package/README.md +4 -0
- package/README.zh.md +4 -0
- package/docs/requirements-traceability/README.i18n.yaml +2 -2
- package/docs/requirements-traceability/README.md +1 -1
- package/docs/requirements-traceability/README.zh.md +1 -1
- package/lib/artifact-access.js +20 -2
- package/lib/artifact-access.js.map +1 -1
- package/lib/client.js +59 -19
- package/lib/client.js.map +1 -1
- package/lib/config.js +64 -12
- package/lib/config.js.map +1 -1
- package/lib/errors.js +25 -1
- package/lib/errors.js.map +1 -1
- package/lib/evidence-cache.js +5 -2
- package/lib/evidence-cache.js.map +1 -1
- package/lib/exposure.js +14 -1
- package/lib/exposure.js.map +1 -1
- package/lib/image-input-variants.js +22 -12
- package/lib/image-input-variants.js.map +1 -1
- package/lib/index.js +53 -6
- package/lib/index.js.map +1 -1
- package/lib/paste-images.js +67 -19
- package/lib/paste-images.js.map +1 -1
- package/lib/paths.js +214 -28
- package/lib/paths.js.map +1 -1
- package/lib/runtime-manager.js +76 -10
- package/lib/runtime-manager.js.map +1 -1
- package/lib/runtime.js +389 -104
- package/lib/runtime.js.map +1 -1
- package/lib/storage-history.js +154 -0
- package/lib/storage-history.js.map +1 -0
- package/lib/tools.js +68 -35
- package/lib/tools.js.map +1 -1
- package/lib/types/artifact-access.d.ts.map +1 -1
- package/lib/types/client/index.d.ts +23 -5
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/paste-images.d.ts +2 -0
- package/lib/types/client/paste-images.d.ts.map +1 -1
- package/lib/types/config.d.ts +38 -7
- package/lib/types/config.d.ts.map +1 -1
- package/lib/types/errors.d.ts +18 -2
- package/lib/types/errors.d.ts.map +1 -1
- package/lib/types/evidence-cache.d.ts +1 -1
- package/lib/types/evidence-cache.d.ts.map +1 -1
- package/lib/types/exposure.d.ts.map +1 -1
- package/lib/types/image-input-variants.d.ts +5 -3
- package/lib/types/image-input-variants.d.ts.map +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/paste-images.d.ts +12 -4
- package/lib/types/paste-images.d.ts.map +1 -1
- package/lib/types/paths.d.ts +31 -5
- package/lib/types/paths.d.ts.map +1 -1
- package/lib/types/runtime-manager.d.ts +28 -4
- package/lib/types/runtime-manager.d.ts.map +1 -1
- package/lib/types/runtime.d.ts +75 -12
- package/lib/types/runtime.d.ts.map +1 -1
- package/lib/types/storage-history.d.ts +63 -0
- package/lib/types/storage-history.d.ts.map +1 -0
- package/lib/types/tools.d.ts +1 -0
- package/lib/types/tools.d.ts.map +1 -1
- package/lib/types/upstream.d.ts.map +1 -1
- package/lib/types/web.d.ts.map +1 -1
- package/lib/upstream.js +31 -8
- package/lib/upstream.js.map +1 -1
- package/lib/web.js +9 -3
- package/lib/web.js.map +1 -1
- package/package.json +1 -1
- package/src/artifact-access.ts +22 -2
- package/src/client/index.tsx +72 -20
- package/src/client/paste-images.tsx +14 -4
- package/src/config.ts +107 -20
- package/src/errors.ts +25 -1
- package/src/evidence-cache.ts +5 -2
- package/src/exposure.ts +16 -2
- package/src/image-input-variants.ts +21 -6
- package/src/index.ts +65 -6
- package/src/paste-images.ts +81 -19
- package/src/paths.ts +249 -28
- package/src/runtime-manager.ts +93 -10
- package/src/runtime.ts +431 -115
- package/src/storage-history.ts +172 -0
- package/src/tools.ts +78 -46
- package/src/upstream.ts +33 -8
- package/src/web.ts +9 -2
package/lib/types/config.d.ts
CHANGED
|
@@ -33,8 +33,10 @@ export interface VisionProviderConfig {
|
|
|
33
33
|
anthropicThinking?: 'omit' | 'disabled' | 'adaptive';
|
|
34
34
|
/** Outbound User-Agent for provider requests and connection tests. */
|
|
35
35
|
userAgent?: string;
|
|
36
|
-
/**
|
|
37
|
-
|
|
36
|
+
/** t1: per-request hedge threshold in seconds. A single request exceeding t1 keeps running while the next provider starts in parallel. */
|
|
37
|
+
t1Seconds?: number;
|
|
38
|
+
/** t2: per-provider cumulative cutoff in seconds. Total accumulated request time reaching t2 terminates the provider. */
|
|
39
|
+
t2Seconds?: number;
|
|
38
40
|
/** Per-provider maximum input image bytes; larger images skip to a later provider or are compressed. */
|
|
39
41
|
maxImageBytes?: number;
|
|
40
42
|
/** Per-provider maximum decoded pixel count per input image. */
|
|
@@ -64,13 +66,17 @@ export interface VisionToolkitConfig {
|
|
|
64
66
|
providers?: VisionProviderConfig[];
|
|
65
67
|
/** Vision output language (`zh` or `en`). */
|
|
66
68
|
language?: 'zh' | 'en';
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
+
/** Global hard timeout in seconds for one tool invocation; the call never exceeds it. */
|
|
70
|
+
hardTimeoutSeconds?: number;
|
|
71
|
+
/** Per-session cap on concurrent tool operations (default 6). */
|
|
72
|
+
sessionMaxConcurrency?: number;
|
|
73
|
+
/** Minimum remaining budget in seconds required before issuing a new request (default 20). */
|
|
74
|
+
minAvailableSeconds?: number;
|
|
69
75
|
/** Maximum input image size in bytes; larger images are auto-compressed (lossless first). */
|
|
70
76
|
maxImageBytes?: number;
|
|
71
77
|
/** Maximum decoded pixel count per input image; larger images are auto-downscaled to fit. */
|
|
72
78
|
maxImagePixels?: number;
|
|
73
|
-
/**
|
|
79
|
+
/** Default per-model in-flight request cap inherited by providers that do not set their own. */
|
|
74
80
|
concurrency?: number;
|
|
75
81
|
runtime?: {
|
|
76
82
|
/** `managed` uses the packaged snapshot and isolated venv; `external` uses a clean pinned checkout. */
|
|
@@ -80,6 +86,14 @@ export interface VisionToolkitConfig {
|
|
|
80
86
|
/** Optional Python 3.11+ bootstrap/interpreter override. */
|
|
81
87
|
python?: string;
|
|
82
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* Optional shared storage root. When set, every workspace gets an isolated,
|
|
91
|
+
* automatically generated child directory below this root instead of writing
|
|
92
|
+
* `.dsh-vision-toolkit` into the workspace.
|
|
93
|
+
*/
|
|
94
|
+
storageDir?: string;
|
|
95
|
+
/** Internal read-only history used to keep persisted paths valid after storage moves. */
|
|
96
|
+
storageHistory?: string[];
|
|
83
97
|
/** Extra directories (besides the workspace) inputs may come from. */
|
|
84
98
|
allowedDirs?: string[];
|
|
85
99
|
/**
|
|
@@ -127,7 +141,8 @@ export interface ResolvedProvider {
|
|
|
127
141
|
protocol: 'openai' | 'anthropic';
|
|
128
142
|
anthropicThinking: 'omit' | 'disabled' | 'adaptive';
|
|
129
143
|
userAgent: string;
|
|
130
|
-
|
|
144
|
+
t1Seconds: number;
|
|
145
|
+
t2Seconds: number;
|
|
131
146
|
maxImageBytes: number;
|
|
132
147
|
maxImagePixels: number;
|
|
133
148
|
concurrency: number;
|
|
@@ -146,7 +161,9 @@ export interface ResolvedVisionToolkitConfig {
|
|
|
146
161
|
/** Ordered failover pool; array order is the priority, highest first. */
|
|
147
162
|
providers: ResolvedProvider[];
|
|
148
163
|
language: 'zh' | 'en';
|
|
149
|
-
|
|
164
|
+
hardTimeoutSeconds: number;
|
|
165
|
+
sessionMaxConcurrency: number;
|
|
166
|
+
minAvailableSeconds: number;
|
|
150
167
|
maxImageBytes: number;
|
|
151
168
|
maxImagePixels: number;
|
|
152
169
|
concurrency: number;
|
|
@@ -155,6 +172,8 @@ export interface ResolvedVisionToolkitConfig {
|
|
|
155
172
|
agentVisionToolkitPath?: string;
|
|
156
173
|
python?: string;
|
|
157
174
|
};
|
|
175
|
+
storageDir?: string;
|
|
176
|
+
storageHistory: string[];
|
|
158
177
|
allowedDirs: string[];
|
|
159
178
|
imageInputVariants: {
|
|
160
179
|
enabled: boolean;
|
|
@@ -172,6 +191,18 @@ export interface ResolvedVisionToolkitConfig {
|
|
|
172
191
|
* @returns the fully defaulted, validated configuration.
|
|
173
192
|
*/
|
|
174
193
|
export declare function resolveConfig(config?: VisionToolkitConfig): ResolvedVisionToolkitConfig;
|
|
194
|
+
/** Merge prior storage roots into the next resolved generation's read-only history. */
|
|
195
|
+
export declare function retainedStorageHistory(next: VisionToolkitConfig, previous: VisionToolkitConfig): string[];
|
|
196
|
+
export interface WatchedSettingsGeneration {
|
|
197
|
+
/** Configuration to activate now; omitted after a successful history writeback. */
|
|
198
|
+
config?: VisionToolkitConfig;
|
|
199
|
+
/** Whether the derived history still needs plugin-owned durable persistence. */
|
|
200
|
+
requiresDurableStorageHistory?: boolean;
|
|
201
|
+
/** Non-fatal internal-history persistence error. */
|
|
202
|
+
persistenceError?: unknown;
|
|
203
|
+
}
|
|
204
|
+
/** Prepare one live Settings generation without letting internal history writeback block activation. */
|
|
205
|
+
export declare function prepareWatchedSettingsGeneration(next: VisionToolkitConfig, previous: VisionToolkitConfig, writable: boolean, persistStorageHistory: (storageHistory: string[]) => Promise<void>): Promise<WatchedSettingsGeneration>;
|
|
175
206
|
/** Whether a resolved provider should use the bundled public key instead of DSH credentials. */
|
|
176
207
|
export declare function isBuiltInFreeVisionProvider(provider: ResolvedVisionToolkitConfig['provider']): boolean;
|
|
177
208
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAQlE,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,EAC/B,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,eAAe,CAAA;AAWtB,wDAAwD;AACxD,eAAO,MAAM,iCAAiC,EAAuB,iBAAiB,CAAA;AAMtF,yEAAyE;AACzE,eAAO,MAAM,yBAAyB,oHAAoH,CAAA;AAgB1J,uDAAuD;AACvD,MAAM,WAAW,oBAAoB;IACnC,0EAA0E;IAC1E,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,mEAAmE;IACnE,IAAI,CAAC,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,CAAC,MAAM,GAAE,mBAAwB,GAAG,2BAA2B,CAmG3F;AAED,uFAAuF;AACvF,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,mBAAmB,EACzB,QAAQ,EAAE,mBAAmB,GAC5B,MAAM,EAAE,CAQV;AAED,MAAM,WAAW,yBAAyB;IACxC,mFAAmF;IACnF,MAAM,CAAC,EAAE,mBAAmB,CAAA;IAC5B,gFAAgF;IAChF,6BAA6B,CAAC,EAAE,OAAO,CAAA;IACvC,oDAAoD;IACpD,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED,wGAAwG;AACxG,wBAAsB,gCAAgC,CACpD,IAAI,EAAE,mBAAmB,EACzB,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,OAAO,EACjB,qBAAqB,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GACjE,OAAO,CAAC,yBAAyB,CAAC,CAYpC;AAED,gGAAgG;AAChG,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,2BAA2B,CAAC,UAAU,CAAC,GAAG,OAAO,CAKtG"}
|
package/lib/types/errors.d.ts
CHANGED
|
@@ -4,8 +4,24 @@
|
|
|
4
4
|
* that never contains credentials or raw upstream stack traces.
|
|
5
5
|
* @module dsh-vision-toolkit/errors
|
|
6
6
|
*/
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Discriminant tag for every Vision Toolkit failure.
|
|
9
|
+
*
|
|
10
|
+
* The remote vision-provider failures are split by a machine-routable taxonomy
|
|
11
|
+
* so the failover loop can decide, per error, whether to retry the SAME
|
|
12
|
+
* provider or advance to the next one:
|
|
13
|
+
*
|
|
14
|
+
* - `auth` 401/403 — credential is wrong or unauthorized. Never retry.
|
|
15
|
+
* - `quota` 402 — account out of quota/unpaid. Never retry.
|
|
16
|
+
* - `rate_limit` 429 — throttled. Park and revisit, never retry in place.
|
|
17
|
+
* - `server` 5xx — transient provider fault. Worth a same-provider retry.
|
|
18
|
+
* - `network` connection refused / DNS / socket — transient. Worth a retry.
|
|
19
|
+
* - `region` provider unavailable in this region. Never retry.
|
|
20
|
+
* - `tos` rejected by content/safety policy. Never retry.
|
|
21
|
+
* - `invalid_request` 400/404/422 — bad request or unknown model. Never retry.
|
|
22
|
+
* - `service` fallback for unclassifiable remote failures. Never retry.
|
|
23
|
+
*/
|
|
24
|
+
export declare const VISION_TOOLKIT_ERROR_CODES: readonly ["config", "input", "capacity", "auth", "quota", "rate_limit", "server", "network", "region", "tos", "invalid_request", "service", "runtime", "output", "timeout", "cancelled", "path"];
|
|
9
25
|
/** Stable machine-readable error category. */
|
|
10
26
|
export type VisionToolkitErrorCode = typeof VISION_TOOLKIT_ERROR_CODES[number];
|
|
11
27
|
/** Error with a stable category; safe to surface to the model. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,0BAA0B,kMAkB7B,CAAA;AAEV,8CAA8C;AAC9C,MAAM,MAAM,sBAAsB,GAAG,OAAO,0BAA0B,CAAC,MAAM,CAAC,CAAA;AAE9E,kEAAkE;AAClE,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;gBAEzB,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAKzF;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAO3E;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAGvG"}
|
|
@@ -31,7 +31,7 @@ export interface EvidencePersistence {
|
|
|
31
31
|
read(key: EvidenceCacheKey): Promise<ContentBlock | undefined>;
|
|
32
32
|
write(key: EvidenceCacheKey, block: ContentBlock): Promise<void>;
|
|
33
33
|
}
|
|
34
|
-
/** Fingerprint every runtime setting that can change
|
|
34
|
+
/** Fingerprint every runtime setting that can change generated evidence or its embedded path. */
|
|
35
35
|
export declare function evidenceRuntimeFingerprint(config: ResolvedVisionToolkitConfig, credentialSha256?: string, sslVerify?: string): string;
|
|
36
36
|
/** Build a non-secret cache key from the Session, attachment, focus, and runtime contract. */
|
|
37
37
|
export declare function createEvidenceCacheKey(input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evidence-cache.d.ts","sourceRoot":"","sources":["../../src/evidence-cache.ts"],"names":[],"mappings":"AAAA,mFAAmF;AAGnF,OAAO,KAAK,EAAE,OAAO,EAAS,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAKxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAG9D,+EAA+E;AAC/E,eAAO,MAAM,yBAAyB,IAAI,CAAA;AA0B1C,KAAK,iBAAiB,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,mBAAmB,EAAE,OAAO,MAAM,CAAA;CAAE,CAAA;AAEjF,uFAAuF;AACvF,eAAO,MAAM,uBAAuB;;;;;;CASlC,CAAA;AAEF,yFAAyF;AACzF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAA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E;IA6BtD,uEAAuE;IACvE,OAAO,IAAI,MAAM,IAAI;IAoCrB,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,QAAQ;IA0BhB,6EAA6E;IAC7E,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,6BAA6B;IAQrC,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,MAAM;IAOd,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,YAAY;CAIrB"}
|
|
@@ -52,9 +52,10 @@ export declare function abortableWait<T>(promise: Promise<T>, signal: AbortSigna
|
|
|
52
52
|
* @param signal - the caller's cancellation for this conversion pass.
|
|
53
53
|
* @param sessionId - the live Session identity, when available.
|
|
54
54
|
* @param runtimeHash - stable fingerprint of the vision provider and evidence runtime.
|
|
55
|
+
* @param storageDir - optional shared plugin storage root.
|
|
55
56
|
* @returns the rewritten message list.
|
|
56
57
|
*/
|
|
57
|
-
export declare function convertImagesToEvidence(ctx: Context, runtime: () => CapturedEvidenceRuntime | undefined, cache: EvidenceCache, messages: readonly Message[], signal?: AbortSignal, sessionId?: string, runtimeHash?: string): Promise<Message[]>;
|
|
58
|
+
export declare function convertImagesToEvidence(ctx: Context, runtime: () => CapturedEvidenceRuntime | undefined, cache: EvidenceCache, messages: readonly Message[], signal?: AbortSignal, sessionId?: string, runtimeHash?: string, storageDir?: string): Promise<Message[]>;
|
|
58
59
|
/**
|
|
59
60
|
* The adapter behind one variant route: model metadata declares image input,
|
|
60
61
|
* and every stream rewrites image blocks before delegating to the upstream
|
|
@@ -69,7 +70,8 @@ export declare class ImageInputVariantAdapter extends LlmAdapter {
|
|
|
69
70
|
private readonly runtime;
|
|
70
71
|
private readonly cache;
|
|
71
72
|
private readonly hidden;
|
|
72
|
-
|
|
73
|
+
private readonly startupStorageDirectory;
|
|
74
|
+
constructor(ctx: Context, llm: LlmService, upstream: string, upstreamName: string, runtime: () => VisionToolkitRuntime | undefined, cache: EvidenceCache, hidden?: () => boolean, startupStorageDirectory?: () => string | undefined);
|
|
73
75
|
providerInfo(provider: string): LlmProviderInfo;
|
|
74
76
|
providerRetryPolicy(_provider: string): ResolvedRetryPolicy;
|
|
75
77
|
listModels(provider: string): Promise<readonly LlmModelInfo[]>;
|
|
@@ -142,7 +144,7 @@ export declare function createPasteTakeoverResolver(ctx: Context, getConfig: ()
|
|
|
142
144
|
* @param getRuntime - the currently serving Vision Toolkit runtime, if ready.
|
|
143
145
|
* @returns the disposer and a manual re-sweep trigger (settings changes).
|
|
144
146
|
*/
|
|
145
|
-
export declare function installImageInputVariants(ctx: Context, getConfig: () => ResolvedVisionToolkitConfig, getRuntime: () => VisionToolkitRuntime | undefined): {
|
|
147
|
+
export declare function installImageInputVariants(ctx: Context, getConfig: () => ResolvedVisionToolkitConfig, getRuntime: () => VisionToolkitRuntime | undefined, getStartupStorageDirectory?: () => string | undefined): {
|
|
146
148
|
dispose: () => void;
|
|
147
149
|
reconcile: () => void;
|
|
148
150
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-input-variants.d.ts","sourceRoot":"","sources":["../../src/image-input-variants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,UAAU,EAAE,EAAE,UAAU,EAAmB,MAAM,sBAAsB,CAAA;AAC9E,OAAO,KAAK,EAEV,eAAe,EAEf,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,OAAO,EACP,mBAAmB,EACnB,WAAW,EACZ,MAAM,sBAAsB,CAAA;AAI7B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EAEL,aAAa,EAEd,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAoB,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACjG,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAE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E,OAAO,EACZ,SAAS,EAAE,MAAM,2BAA2B,GAC3C,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,mBAAmB,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CAyCpG;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,MAAM,2BAA2B,EAC5C,UAAU,EAAE,MAAM,oBAAoB,GAAG,SAAS,EAClD,0BAA0B,GAAE,MAAM,MAAM,GAAG,SAA2B,GACrE;IAAE,OAAO,EAAE,MAAM,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,IAAI,CAAA;CAAE,CAoLhD"}
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,OAAO,EACL,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,OAAO,EACL,MAAM,EAKN,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAA;AAWpB,eAAO,MAAM,IAAI,gCAAgC,CAAA;AAEjD,OAAO,EAAE,MAAM,EAAE,CAAA;AAEjB,eAAO,MAAM,MAAM,UAAqF,CAAA;AAExG,qFAAqF;AACrF,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,mBAAwB,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CA6J/F"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Plugin-managed storage for images pasted into the DSH Web composer. */
|
|
2
2
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
3
|
import type { Context } from '@deepseek-ai/cordis';
|
|
4
4
|
/** Exact route used by the browser paste integration. */
|
|
@@ -55,19 +55,27 @@ export interface PasteRoot {
|
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Resolve the managed per-session image directory used by both browser pastes
|
|
58
|
-
* and native attachment bridging.
|
|
59
|
-
*
|
|
58
|
+
* and native attachment bridging. A configured shared storage root receives a
|
|
59
|
+
* stable workspace-specific child, keeping projects isolated without writing
|
|
60
|
+
* plugin files into the project directory.
|
|
60
61
|
*/
|
|
61
|
-
export declare function sessionPasteRoot(ctx: Context, sessionId: string): Promise<PasteRoot>;
|
|
62
|
+
export declare function sessionPasteRoot(ctx: Context, sessionId: string, storageDir?: string): Promise<PasteRoot>;
|
|
63
|
+
export interface PasteStorageGeneration {
|
|
64
|
+
generation: number;
|
|
65
|
+
storageDir?: string;
|
|
66
|
+
}
|
|
62
67
|
/** Runtime limit face kept separate for focused backend tests. */
|
|
63
68
|
export interface PasteImageRuntime {
|
|
64
69
|
maxUploadBytes(): number;
|
|
70
|
+
storageDirectory?(): string | undefined;
|
|
71
|
+
storageGeneration?(): PasteStorageGeneration;
|
|
65
72
|
}
|
|
66
73
|
/** Same-origin, live-Session-bound image upload endpoint. */
|
|
67
74
|
export declare class PastedImageBackend {
|
|
68
75
|
private readonly ctx;
|
|
69
76
|
private readonly runtime;
|
|
70
77
|
constructor(ctx: Context, runtime: PasteImageRuntime);
|
|
78
|
+
private storageGeneration;
|
|
71
79
|
handle(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
72
80
|
}
|
|
73
81
|
//# sourceMappingURL=paste-images.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paste-images.d.ts","sourceRoot":"","sources":["../../src/paste-images.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"paste-images.d.ts","sourceRoot":"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EACZ,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,SAAS,CAAC,CAmBpB;AA2DD,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAID,kEAAkE;AAClE,MAAM,WAAW,iBAAiB;IAChC,cAAc,IAAI,MAAM,CAAA;IACxB,gBAAgB,CAAC,IAAI,MAAM,GAAG,SAAS,CAAA;IACvC,iBAAiB,CAAC,IAAI,sBAAsB,CAAA;CAC7C;AAED,6DAA6D;AAC7D,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,iBAAiB;IAG7C,OAAO,CAAC,iBAAiB;IAUnB,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CA+CvE"}
|
package/lib/types/paths.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* link is allowed only when its real target stays inside the fence.
|
|
6
6
|
* @module dsh-vision-toolkit/paths
|
|
7
7
|
*/
|
|
8
|
+
import type { Stats } from 'node:fs';
|
|
8
9
|
/** Supported input image extensions (the upstream client's allowlist). */
|
|
9
10
|
export declare const SUPPORTED_IMAGE_EXTENSIONS: readonly [".png", ".jpg", ".jpeg", ".gif", ".webp"];
|
|
10
11
|
/** Resolved path policy for one tool invocation. */
|
|
@@ -15,9 +16,20 @@ export interface PathPolicy {
|
|
|
15
16
|
tempDir: string;
|
|
16
17
|
/** Real allowed roots: workspace, platform temp, and configured directories. */
|
|
17
18
|
allowedDirs: string[];
|
|
19
|
+
/** Real plugin-managed root containing artifacts and transient files. */
|
|
20
|
+
storageRoot: string;
|
|
18
21
|
/** Real plugin-managed output directory inside the fence. */
|
|
19
22
|
outputDir: string;
|
|
20
23
|
}
|
|
24
|
+
/** Resolved plugin storage for one workspace. */
|
|
25
|
+
export interface WorkspaceStorage {
|
|
26
|
+
/** Real workspace root. */
|
|
27
|
+
workspace: string;
|
|
28
|
+
/** Real plugin-managed root for this workspace. */
|
|
29
|
+
root: string;
|
|
30
|
+
/** Absolute user-visible spelling of the same managed root. */
|
|
31
|
+
visibleRoot: string;
|
|
32
|
+
}
|
|
21
33
|
/** Whether `child` equals or lies under `parent` on the same path root. */
|
|
22
34
|
export declare function isWithin(parent: string, child: string): boolean;
|
|
23
35
|
/** Current platform temporary directory before realpath canonicalization. */
|
|
@@ -28,16 +40,30 @@ export declare function platformTempDirectory(platform?: NodeJS.Platform, enviro
|
|
|
28
40
|
* unchanged, and the normal realpath fence still validates the result.
|
|
29
41
|
*/
|
|
30
42
|
export declare function normalizePlatformTempPath(raw: string, platform?: NodeJS.Platform, tempDirectory?: string): string;
|
|
43
|
+
/** Stable opaque per-user workspace id used below a shared storage root. */
|
|
44
|
+
export declare function workspaceStorageId(workspace: string, userIdentity?: string): string;
|
|
45
|
+
export declare function assertSecureWorkspaceStorage(info: Stats, requested: string): void;
|
|
46
|
+
/** Resolve a shared base and prove every POSIX ancestor is protected from replacement. */
|
|
47
|
+
export declare function assertSecureSharedStorageBase(requested: string): Promise<string>;
|
|
48
|
+
/** Validate and write-probe a configured shared root before Settings activation. */
|
|
49
|
+
export declare function preflightSharedStorageBase(storageDirRaw: string): Promise<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the plugin-managed root for one workspace. Blank configuration keeps
|
|
52
|
+
* the legacy workspace-local `.dsh-vision-toolkit` directory. A configured
|
|
53
|
+
* shared root receives one stable, automatically generated workspace child.
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveWorkspaceStorage(workspaceRaw: string, storageDirRaw?: string): Promise<WorkspaceStorage>;
|
|
31
56
|
/**
|
|
32
|
-
* Build the per-invocation path policy:
|
|
33
|
-
*
|
|
34
|
-
*
|
|
57
|
+
* Build the per-invocation path policy: resolve workspace storage, realpath the
|
|
58
|
+
* platform temp directory and allowed directories, and create the artifact
|
|
59
|
+
* directory inside the managed root.
|
|
35
60
|
* @param workspaceRaw - session workspace (or process cwd fallback).
|
|
36
61
|
* @param allowedDirs - configured extra allowed roots.
|
|
37
|
-
* @param
|
|
62
|
+
* @param storageDirRaw - optional shared storage root.
|
|
63
|
+
* @param readableStorageDirs - previously validated shared roots retained for persisted input paths.
|
|
38
64
|
* @returns the resolved policy.
|
|
39
65
|
*/
|
|
40
|
-
export declare function createPathPolicy(workspaceRaw: string, allowedDirs: readonly string[],
|
|
66
|
+
export declare function createPathPolicy(workspaceRaw: string, allowedDirs: readonly string[], storageDirRaw?: string, readableStorageDirs?: readonly string[]): Promise<PathPolicy>;
|
|
41
67
|
/**
|
|
42
68
|
* Validate one input image path and return its fence-checked absolute path
|
|
43
69
|
* and byte size.
|
package/lib/types/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAMpC,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B,qDAAsD,CAAA;AAE7F,oDAAoD;AACpD,MAAM,WAAW,UAAU;IACzB,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAA;IACf,gFAAgF;IAChF,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAA;IACnB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,2BAA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M,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAmBjH;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BhH;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAyB7G;AAED,gEAAgE;AAChE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAIxE"}
|
|
@@ -22,8 +22,15 @@ export interface RuntimeManagerStatus {
|
|
|
22
22
|
upstream?: UpstreamVersionInfo;
|
|
23
23
|
lastError?: string;
|
|
24
24
|
}
|
|
25
|
+
/** Storage selection paired to the active or validated startup generation. */
|
|
26
|
+
export interface RuntimeStorageGeneration {
|
|
27
|
+
generation: number;
|
|
28
|
+
storageDir?: string;
|
|
29
|
+
}
|
|
25
30
|
/** Test seam for preparing one generation. */
|
|
26
|
-
export type RuntimeGenerationFactory = (ctx: Context, config: ResolvedVisionToolkitConfig) => Promise<VisionToolkitRuntime>;
|
|
31
|
+
export type RuntimeGenerationFactory = (ctx: Context, config: ResolvedVisionToolkitConfig, readableStorageDirs: readonly string[]) => Promise<VisionToolkitRuntime>;
|
|
32
|
+
/** Async commit prerequisite run after preparation and before a generation becomes active. */
|
|
33
|
+
export type RuntimeGenerationBeforePublish = (candidate: PreparedRuntimeGeneration) => Promise<void>;
|
|
27
34
|
/** Internal runtime source with prepare-before-swap semantics. */
|
|
28
35
|
export declare class VisionToolkitRuntimeManager {
|
|
29
36
|
private readonly ctx;
|
|
@@ -32,11 +39,22 @@ export declare class VisionToolkitRuntimeManager {
|
|
|
32
39
|
private generation;
|
|
33
40
|
private reconfigureTicket;
|
|
34
41
|
private lastError;
|
|
42
|
+
private validatedStartupStorageDir;
|
|
43
|
+
private readonly readableStorageDirs;
|
|
35
44
|
constructor(ctx: Context, factory?: RuntimeGenerationFactory);
|
|
36
45
|
/** The currently serving runtime; unavailable until one generation prepares. */
|
|
37
46
|
current(): VisionToolkitRuntime;
|
|
47
|
+
/** Configuration belonging to the currently serving runtime generation. */
|
|
48
|
+
currentConfig(): ResolvedVisionToolkitConfig;
|
|
38
49
|
/** Whether at least one generation is available. */
|
|
39
50
|
get ready(): boolean;
|
|
51
|
+
/** Storage config safe for paste writes even when initial runtime preparation failed. */
|
|
52
|
+
storageGeneration(): RuntimeStorageGeneration;
|
|
53
|
+
/** Validated storage for best-effort consumers; undefined when startup preflight failed. */
|
|
54
|
+
validatedStorageDirectory(): string | undefined;
|
|
55
|
+
private prepareResolvedCandidate;
|
|
56
|
+
private rememberStorageDirectory;
|
|
57
|
+
private rememberStorageDirectories;
|
|
40
58
|
/** Resolve and fully prepare a candidate without changing the active runtime. */
|
|
41
59
|
prepareCandidate(raw: VisionToolkitConfig): Promise<PreparedRuntimeGeneration>;
|
|
42
60
|
/**
|
|
@@ -44,14 +62,20 @@ export declare class VisionToolkitRuntimeManager {
|
|
|
44
62
|
* @param candidate - generation returned by {@link prepareCandidate}.
|
|
45
63
|
*/
|
|
46
64
|
activateCandidate(candidate: PreparedRuntimeGeneration): void;
|
|
47
|
-
/**
|
|
48
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Prepare and publish the initial or explicitly validated generation.
|
|
67
|
+
* @param raw - untrusted Settings generation to resolve and prepare.
|
|
68
|
+
* @param beforePublish - optional durable prerequisite run after preparation.
|
|
69
|
+
*/
|
|
70
|
+
initialize(raw: VisionToolkitConfig, beforePublish?: RuntimeGenerationBeforePublish): Promise<void>;
|
|
49
71
|
/**
|
|
50
72
|
* Apply an externally committed Settings generation. Concurrent edits are
|
|
51
73
|
* last-write-wins; a slower obsolete prepare can never overwrite a newer one.
|
|
74
|
+
* @param raw - externally committed Settings generation.
|
|
75
|
+
* @param beforePublish - optional durable prerequisite run after preparation.
|
|
52
76
|
* @returns whether this call published a new active generation.
|
|
53
77
|
*/
|
|
54
|
-
reconfigure(raw: VisionToolkitConfig): Promise<boolean>;
|
|
78
|
+
reconfigure(raw: VisionToolkitConfig, beforePublish?: RuntimeGenerationBeforePublish): Promise<boolean>;
|
|
55
79
|
/** Record a failed preflight while retaining the previous generation. */
|
|
56
80
|
recordFailure(error: unknown): void;
|
|
57
81
|
/** Secret-free status snapshot for health/configuration surfaces. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-manager.d.ts","sourceRoot":"","sources":["../../src/runtime-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAiB,KAAK,2BAA2B,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"runtime-manager.d.ts","sourceRoot":"","sources":["../../src/runtime-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAiB,KAAK,2BAA2B,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEvG,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEzE,wDAAwD;AACxD,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,2BAA2B,CAAA;IACnC,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,oBAAoB,CAAA;CAC9B;AAED,4DAA4D;AAC5D,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,OAAO,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE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AmB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAMpF;;;OAGG;IACH,iBAAiB,CAAC,SAAS,EAAE,yBAAyB,GAAG,IAAI;IAqB7D;;;;OAIG;IACG,UAAU,CAAC,GAAG,EAAE,mBAAmB,EAAE,aAAa,CAAC,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBzG;;;;;;OAMG;IACG,WAAW,CAAC,GAAG,EAAE,mBAAmB,EAAE,aAAa,CAAC,EAAE,8BAA8B,GAAG,OAAO,CAAC,OAAO,CAAC;IA8B7G,yEAAyE;IACzE,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAInC,qEAAqE;IACrE,MAAM,IAAI,oBAAoB;CAgB/B"}
|
package/lib/types/runtime.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export declare class Semaphore {
|
|
|
29
29
|
constructor(limit: number);
|
|
30
30
|
/** Whether no active or queued caller still owns this gate. */
|
|
31
31
|
get idle(): boolean;
|
|
32
|
+
/** Free slots still claimable without queuing. */
|
|
33
|
+
get available(): number;
|
|
32
34
|
/** Acquire one slot, aborting while queued when `signal` fires. */
|
|
33
35
|
acquire(signal: AbortSignal, permits?: number): Promise<void>;
|
|
34
36
|
/** Release owned permits and wake FIFO waiters whose full weight now fits. */
|
|
@@ -197,7 +199,6 @@ export interface LongScreenshotOcrRequest {
|
|
|
197
199
|
overlap?: number;
|
|
198
200
|
prompt?: string;
|
|
199
201
|
jobs?: number;
|
|
200
|
-
chunkTimeoutSeconds?: number;
|
|
201
202
|
splitOnly?: boolean;
|
|
202
203
|
resume?: boolean;
|
|
203
204
|
}
|
|
@@ -317,6 +318,9 @@ export interface VisionToolkitHealthResult {
|
|
|
317
318
|
python: HealthCheck;
|
|
318
319
|
dependencies: HealthCheck;
|
|
319
320
|
chrome: HealthCheck;
|
|
321
|
+
credential: HealthCheck;
|
|
322
|
+
artifactDirectory: HealthCheck;
|
|
323
|
+
tempDirectory: HealthCheck;
|
|
320
324
|
service: HealthCheck;
|
|
321
325
|
model: HealthCheck;
|
|
322
326
|
};
|
|
@@ -329,7 +333,8 @@ export interface VisionToolkitHealthResult {
|
|
|
329
333
|
/** Shared per-call execution options. */
|
|
330
334
|
export interface ToolCallOptions {
|
|
331
335
|
signal: AbortSignal;
|
|
332
|
-
|
|
336
|
+
/** Override the global hard timeout (seconds) for this call. */
|
|
337
|
+
timeoutSeconds?: number;
|
|
333
338
|
workspace: string;
|
|
334
339
|
/** Session identity for the per-session concurrency cap. */
|
|
335
340
|
sessionId?: string;
|
|
@@ -353,26 +358,53 @@ interface ResolvedProviderEnv {
|
|
|
353
358
|
provider: ResolvedProvider;
|
|
354
359
|
env: UpstreamEnvironment;
|
|
355
360
|
}
|
|
361
|
+
/** Live concurrency accounting returned by the availability query tool. */
|
|
362
|
+
export interface ConcurrencyStatus {
|
|
363
|
+
/** New tool calls this session may start right now. */
|
|
364
|
+
available: number;
|
|
365
|
+
/** Per-session cap on concurrent tool operations. */
|
|
366
|
+
sessionMax: number;
|
|
367
|
+
/** Tool operations currently in flight in this session. */
|
|
368
|
+
sessionInUse: number;
|
|
369
|
+
/** Free per-session slots. */
|
|
370
|
+
sessionFree: number;
|
|
371
|
+
/** Total free model-request slots summed across enabled providers. */
|
|
372
|
+
modelFree: number;
|
|
373
|
+
/** Per-provider breakdown. */
|
|
374
|
+
models: Array<{
|
|
375
|
+
name: string;
|
|
376
|
+
concurrency: number;
|
|
377
|
+
inUse: number;
|
|
378
|
+
free: number;
|
|
379
|
+
}>;
|
|
380
|
+
}
|
|
356
381
|
/** Runtime facade used by every native tool. */
|
|
357
382
|
export declare class VisionToolkitRuntime {
|
|
358
383
|
private readonly ctx;
|
|
359
384
|
private readonly config;
|
|
385
|
+
private readonly readableStorageDirs;
|
|
360
386
|
private readonly semaphores;
|
|
361
387
|
private readonly glanceCache;
|
|
362
388
|
private readonly providerGates;
|
|
363
389
|
private readonly adapter;
|
|
364
|
-
constructor(ctx: Context, config: ResolvedVisionToolkitConfig, adapter?: UpstreamAdapter);
|
|
390
|
+
constructor(ctx: Context, config: ResolvedVisionToolkitConfig, adapter?: UpstreamAdapter, readableStorageDirs?: readonly string[]);
|
|
365
391
|
/** Pinned and prepared upstream identity. */
|
|
366
392
|
get upstreamVersion(): UpstreamVersionInfo;
|
|
393
|
+
/** Per-session cap on concurrent tool operations. */
|
|
394
|
+
get sessionMaxConcurrency(): number;
|
|
395
|
+
/** Shared storage root belonging to this immutable runtime generation. */
|
|
396
|
+
get storageDirectory(): string | undefined;
|
|
367
397
|
/** Stable identity for persisted image descriptions produced by this runtime. */
|
|
368
398
|
get evidenceFingerprint(): string;
|
|
369
399
|
/** Capture the credential and provider identity used by one evidence conversion. */
|
|
370
400
|
captureEvidenceRuntime(): Promise<CapturedEvidenceRuntime>;
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
private operationTimeoutMs;
|
|
401
|
+
/** Global hard timeout (ms) for one tool invocation, honoring the per-call override. */
|
|
402
|
+
private hardTimeoutMs;
|
|
374
403
|
private operationError;
|
|
375
|
-
|
|
404
|
+
/** Per-session concurrency gate; callers acquire without queuing (excess is rejected). */
|
|
405
|
+
private sessionGate;
|
|
406
|
+
/** Live concurrency accounting for the calling session across the enabled provider pool. */
|
|
407
|
+
concurrencyStatus(options: ToolCallOptions): ConcurrencyStatus;
|
|
376
408
|
private runOperation;
|
|
377
409
|
/** Highest-priority enabled provider, falling back to the first entry. */
|
|
378
410
|
private get primaryProvider();
|
|
@@ -403,12 +435,42 @@ export declare class VisionToolkitRuntime {
|
|
|
403
435
|
*/
|
|
404
436
|
private prepareVisionImage;
|
|
405
437
|
/**
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
438
|
+
* Hedge-based failover across the enabled provider pool. The highest-priority
|
|
439
|
+
* provider runs first; when one of its requests crosses t1 it keeps running
|
|
440
|
+
* while the next provider starts in parallel. A provider whose cumulative
|
|
441
|
+
* request time reaches t2 is terminated. A 429 provider is parked and moved
|
|
442
|
+
* past immediately; parked providers are revisited at a 10s cadence once
|
|
443
|
+
* every other provider is exhausted. The result always prefers the earliest
|
|
444
|
+
* (highest-priority) provider.
|
|
445
|
+
*/
|
|
446
|
+
private runVisionHedge;
|
|
447
|
+
/** Remaining request budget (ms) for one provider: the tighter of its t2 and the global deadline. */
|
|
448
|
+
private providerRequestBudget;
|
|
449
|
+
/**
|
|
450
|
+
* Advance to the next provider after one provider reached a terminal
|
|
451
|
+
* failure. This is what makes failover work for FAST failures too: the
|
|
452
|
+
* hedge timer only launches the next provider when the current one is SLOW
|
|
453
|
+
* (crosses t1), so a quick auth/5xx/network failure must explicitly launch
|
|
454
|
+
* the successor. Never advances when a higher-priority provider superseded
|
|
455
|
+
* this task, when the whole operation was cancelled, or when the global
|
|
456
|
+
* deadline has too little room left for another request. `launch` is
|
|
457
|
+
* idempotent, so an earlier hedge timer cannot cause a double launch.
|
|
458
|
+
*/
|
|
459
|
+
private advanceAfterFailure;
|
|
460
|
+
/**
|
|
461
|
+
* Run one provider to a terminal state: retryable errors retry within
|
|
462
|
+
* `attempts`, a single request crossing t1 hedges the next provider, and the
|
|
463
|
+
* provider is terminated once its cumulative time reaches t2. A 429 parks the
|
|
464
|
+
* provider and moves on. No request is issued once the remaining budget drops
|
|
465
|
+
* below the configured minimum available time.
|
|
466
|
+
*/
|
|
467
|
+
private runProviderTask;
|
|
468
|
+
/**
|
|
469
|
+
* Revisit parked (429) providers in priority order at a 10s cadence until one
|
|
470
|
+
* succeeds or every provider exhausts its budget. Returns a success result or
|
|
471
|
+
* `undefined` when the global deadline or minimum available time stops the loop.
|
|
410
472
|
*/
|
|
411
|
-
private
|
|
473
|
+
private revisitRateLimited;
|
|
412
474
|
private glanceCacheKey;
|
|
413
475
|
private runUpstream;
|
|
414
476
|
private probeGeneratedImage;
|
|
@@ -436,6 +498,7 @@ export declare class VisionToolkitRuntime {
|
|
|
436
498
|
dominantColors(request: DominantColorsRequest, options: ToolCallOptions): Promise<DominantColorsResult>;
|
|
437
499
|
/** html_screenshot: render only a path-fenced local HTML file in the pinned Chrome adapter. */
|
|
438
500
|
htmlScreenshot(request: HtmlScreenshotRequest, options: ToolCallOptions): Promise<HtmlScreenshotResult>;
|
|
501
|
+
private writableDirectoryCheck;
|
|
439
502
|
/** Health: inspect local readiness, and optionally probe one provider's `/models` plus one real multimodal request. */
|
|
440
503
|
health(testConnection: boolean, options: ToolCallOptions, testModel?: boolean, provider?: ResolvedProvider): Promise<VisionToolkitHealthResult>;
|
|
441
504
|
/** Report the packaged upstream snapshot version. */
|