@artenx/dshb 0.1.7 → 0.1.9
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 +1 -1
- package/lib/auth/index.js +2 -1
- package/lib/auth/index.js.map +1 -1
- package/lib/client.js +1 -1
- package/lib/client.js.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/workspace-instruction-context.d.ts +281 -122
- package/lib/core/workspace-instruction-context.js +1 -1
- package/lib/exec-docker/docker-backend.d.ts +1 -1
- package/lib/exec-docker/docker-client.d.ts +1 -1
- package/lib/exec-docker/docker-client.js +4 -1
- package/lib/exec-docker/docker-client.js.map +1 -1
- package/lib/exec-docker/process-provider.d.ts +3 -1
- package/lib/exec-docker/process-provider.js +68 -5
- package/lib/exec-docker/process-provider.js.map +1 -1
- package/lib/exec-docker/remote-docker-cli.d.ts +1 -1
- package/lib/exec-docker/remote-docker-cli.js +1 -1
- package/lib/exec-docker/remote-docker-cli.js.map +1 -1
- package/lib/exec-docker/world.d.ts +1 -1
- package/lib/exec-ssh/executor.d.ts +1 -2
- package/lib/exec-ssh/executor.js +7 -5
- package/lib/exec-ssh/executor.js.map +1 -1
- package/lib/exec-ssh/process-provider.d.ts +3 -1
- package/lib/exec-ssh/process-provider.js +65 -5
- package/lib/exec-ssh/process-provider.js.map +1 -1
- package/lib/exec-ssh/world.d.ts +1 -1
- package/lib/router/decorate-shell.d.ts +11 -2
- package/lib/router/decorate-shell.js +80 -18
- package/lib/router/decorate-shell.js.map +1 -1
- package/lib/router/index.d.ts +1 -1
- package/lib/router/index.js +20 -0
- package/lib/router/index.js.map +1 -1
- package/lib/router/resolve.d.ts +1 -1
- package/lib/router/router-shell.d.ts +2 -3
- package/lib/router/router-shell.js +4 -13
- package/lib/router/router-shell.js.map +1 -1
- package/lib/router/types.d.ts +1 -1
- package/lib/{types-C0TtEO7z.d.ts → types-ekJQQ4x6.d.ts} +4 -2
- package/lib/{workspace-instruction-context-CxUldQkP.js → workspace-instruction-context-DzHFTN87.js} +156 -76
- package/lib/workspace-instruction-context-DzHFTN87.js.map +1 -0
- package/package.json +34 -33
- package/lib/workspace-instruction-context-CxUldQkP.js.map +0 -1
package/lib/{workspace-instruction-context-CxUldQkP.js → workspace-instruction-context-DzHFTN87.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sharedSessionInstructionSnapshotStore, sharedWorkspaceInstructionStore } from "./core/workspace-instructions.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { Service } from "@deepseek-ai/cordis";
|
|
3
|
+
import { Context, Service } from "@deepseek-ai/cordis";
|
|
4
4
|
//#region ../../node_modules/@deepseek-ai/dsh-typert-protocol/lib/index.js
|
|
5
5
|
/** The one Remote failure class shared by owners, the Gateway, and consumers. */
|
|
6
6
|
/**
|
|
@@ -45,7 +45,10 @@ function isTypertRemoteSegment(value) {
|
|
|
45
45
|
}
|
|
46
46
|
const REMOTE_METHOD_DESCRIPTOR = "@deepseek-ai/dsh-typert-protocol/remote-methods";
|
|
47
47
|
/**
|
|
48
|
-
* Bind one visible Service field to a Cordis key and Remote namespace.
|
|
48
|
+
* Bind one visible Service field to a Cordis key and Remote namespace. A
|
|
49
|
+
* service that owns a Cordis Context also gives its tree `ctx.invocation`,
|
|
50
|
+
* `undefined` outside a Remote call, so no `TypertRemoteService` is needed for
|
|
51
|
+
* a Host composition to read it.
|
|
49
52
|
* @param service - owning Service instance, normally `this`.
|
|
50
53
|
* @param serviceKey - exact Cordis service key.
|
|
51
54
|
* @param options - optional distinct wire namespace.
|
|
@@ -55,6 +58,8 @@ function bindTypertRemote(service, serviceKey, options = {}) {
|
|
|
55
58
|
validateName("service key", serviceKey);
|
|
56
59
|
const namespace = options.namespace ?? serviceKey;
|
|
57
60
|
validateName("namespace", namespace);
|
|
61
|
+
const ctx = Reflect.get(service, "ctx");
|
|
62
|
+
if (ctx instanceof Context) provideInvocationAccessor(ctx);
|
|
58
63
|
return Object.freeze({
|
|
59
64
|
service,
|
|
60
65
|
serviceKey,
|
|
@@ -76,6 +81,16 @@ var TypertRemoteService = class extends Service {
|
|
|
76
81
|
this.typertRemote = bindTypertRemote(this, this.name, options);
|
|
77
82
|
}
|
|
78
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* Make `ctx.invocation` read as `undefined` outside a Remote call instead of the
|
|
86
|
+
* reflect service's "cannot get property" error; a call-derived Context shadows
|
|
87
|
+
* the accessor with its own property. The first Remote Service constructed in a
|
|
88
|
+
* tree registers it on the root, where it outlives any one Service.
|
|
89
|
+
*/
|
|
90
|
+
function provideInvocationAccessor(ctx) {
|
|
91
|
+
if (Object.hasOwn(ctx.root.reflect.props, "invocation")) return;
|
|
92
|
+
ctx.root.accessor("invocation", { get: () => void 0 });
|
|
93
|
+
}
|
|
79
94
|
function Remote(methodExportOrOptions, context) {
|
|
80
95
|
if (typeof methodExportOrOptions === "string") {
|
|
81
96
|
validateName("Remote export name", methodExportOrOptions);
|
|
@@ -250,6 +265,43 @@ function pick(source, keys, forced) {
|
|
|
250
265
|
for (const key of keys) if (forced || source[key] !== void 0) result[key] = source[key];
|
|
251
266
|
return result;
|
|
252
267
|
}
|
|
268
|
+
/** Shared config references used by schema validators and plugin runtimes. */
|
|
269
|
+
const write = Symbol.for("cosmokit.volatile.write");
|
|
270
|
+
function snapshot(value, ancestors = /* @__PURE__ */ new Set()) {
|
|
271
|
+
if (typeof value === "function") throw new TypeError("volatile config cannot contain functions");
|
|
272
|
+
if (value === null || typeof value !== "object") return value;
|
|
273
|
+
if (ancestors.has(value)) throw new TypeError("volatile config cannot contain cycles");
|
|
274
|
+
ancestors.add(value);
|
|
275
|
+
try {
|
|
276
|
+
if (Array.isArray(value)) return Object.freeze(value.map((item) => snapshot(item, ancestors)));
|
|
277
|
+
if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) throw new TypeError("volatile config objects must be plain objects or arrays");
|
|
278
|
+
return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, snapshot(item, ancestors)])));
|
|
279
|
+
} finally {
|
|
280
|
+
ancestors.delete(value);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Create a detached reference containing an immutable copy of the supplied data.
|
|
285
|
+
* @param value - validated config data; class instances and functions are unsupported.
|
|
286
|
+
* @returns a reference whose value is updated only by its owning runtime.
|
|
287
|
+
*/
|
|
288
|
+
function createVolatile(value) {
|
|
289
|
+
let current = snapshot(value);
|
|
290
|
+
return Object.freeze({
|
|
291
|
+
get: () => current,
|
|
292
|
+
[write]: (value) => {
|
|
293
|
+
current = value;
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Identify references across ESM/CJS copies of the shared library.
|
|
299
|
+
* @param value - a parsed config value.
|
|
300
|
+
* @returns whether the value implements the shared reference protocol.
|
|
301
|
+
*/
|
|
302
|
+
function isVolatile(value) {
|
|
303
|
+
return typeof value === "object" && value !== null && write in value;
|
|
304
|
+
}
|
|
253
305
|
/** Test values using `instanceof` with a `toStringTag` fallback. */
|
|
254
306
|
function is(type, value) {
|
|
255
307
|
if (arguments.length === 1) return (value) => is(type, value);
|
|
@@ -330,26 +382,47 @@ function clone(source, refs = /* @__PURE__ */ new Map()) {
|
|
|
330
382
|
}
|
|
331
383
|
return result;
|
|
332
384
|
}
|
|
333
|
-
/**
|
|
385
|
+
/**
|
|
386
|
+
* Compare values recursively, treating two volatile references as equal regardless of value.
|
|
387
|
+
* Strict comparison distinguishes null/undefined, treats opaque objects by identity,
|
|
388
|
+
* compares URLs by normalized href, treats array holes as undefined, and considers distinct cyclic structures unequal.
|
|
389
|
+
* @param a - first value.
|
|
390
|
+
* @param b - second value.
|
|
391
|
+
* @param strict - whether to require strict data equality outside volatile references.
|
|
392
|
+
* @returns whether the values compare equal.
|
|
393
|
+
*/
|
|
334
394
|
function deepEqual(a, b, strict) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
395
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
396
|
+
function compare(a, b) {
|
|
397
|
+
if (a === b) return true;
|
|
398
|
+
if (isVolatile(a) || isVolatile(b)) return isVolatile(a) && isVolatile(b);
|
|
399
|
+
if (!strict && isNullable(a) && isNullable(b)) return true;
|
|
400
|
+
if (typeof a !== typeof b || typeof a !== "object" || !a || !b) return false;
|
|
401
|
+
if (ancestors.has(a)) return false;
|
|
402
|
+
function check(test, then) {
|
|
403
|
+
return test(a) ? test(b) ? then(a, b) : false : test(b) ? false : void 0;
|
|
404
|
+
}
|
|
405
|
+
ancestors.add(a);
|
|
406
|
+
try {
|
|
407
|
+
return check(Array.isArray, (a, b) => {
|
|
408
|
+
if (a.length !== b.length) return false;
|
|
409
|
+
for (let index = 0; index < a.length; index++) if (!compare(a[index], b[index])) return false;
|
|
410
|
+
return true;
|
|
411
|
+
}) ?? check(is("Date"), (a, b) => a.valueOf() === b.valueOf()) ?? check(is("URL"), (a, b) => a.href === b.href) ?? check(is("RegExp"), (a, b) => a.source === b.source && a.flags === b.flags) ?? check(isArrayBufferLike, (a, b) => {
|
|
412
|
+
if (a.byteLength !== b.byteLength) return false;
|
|
413
|
+
const viewA = new Uint8Array(a);
|
|
414
|
+
const viewB = new Uint8Array(b);
|
|
415
|
+
for (let i = 0; i < viewA.length; i++) if (viewA[i] !== viewB[i]) return false;
|
|
416
|
+
return true;
|
|
417
|
+
}) ?? ((!strict || [a, b].every((value) => Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)) && Object.keys({
|
|
418
|
+
...a,
|
|
419
|
+
...b
|
|
420
|
+
}).every((key) => compare(a[key], b[key])));
|
|
421
|
+
} finally {
|
|
422
|
+
ancestors.delete(a);
|
|
423
|
+
}
|
|
342
424
|
}
|
|
343
|
-
return
|
|
344
|
-
if (a.byteLength !== b.byteLength) return false;
|
|
345
|
-
const viewA = new Uint8Array(a);
|
|
346
|
-
const viewB = new Uint8Array(b);
|
|
347
|
-
for (let i = 0; i < viewA.length; i++) if (viewA[i] !== viewB[i]) return false;
|
|
348
|
-
return true;
|
|
349
|
-
}) ?? Object.keys({
|
|
350
|
-
...a,
|
|
351
|
-
...b
|
|
352
|
-
}).every((key) => deepEqual(a[key], b[key], strict));
|
|
425
|
+
return compare(a, b);
|
|
353
426
|
}
|
|
354
427
|
/** Time constants plus parsing and formatting helpers. */
|
|
355
428
|
var Time;
|
|
@@ -598,6 +671,7 @@ Schema.prototype.pattern = function pattern(regexp) {
|
|
|
598
671
|
return schema;
|
|
599
672
|
};
|
|
600
673
|
Schema.prototype.simplify = function simplify(value) {
|
|
674
|
+
if (isVolatile(value)) value = value.get();
|
|
601
675
|
if (deepEqual(value, this.meta.default, this.type === "dict")) return null;
|
|
602
676
|
if (isNullable(value)) return value;
|
|
603
677
|
if (this.type === "object" || this.type === "dict") {
|
|
@@ -654,12 +728,49 @@ for (const key of [
|
|
|
654
728
|
};
|
|
655
729
|
return schema;
|
|
656
730
|
} });
|
|
731
|
+
Schema.prototype.volatile = function volatile() {
|
|
732
|
+
if (this.meta.volatile) throw new TypeError("volatile schema is already wrapped");
|
|
733
|
+
return this.extra("volatile", true);
|
|
734
|
+
};
|
|
657
735
|
const resolvers = {};
|
|
736
|
+
const checkedVolatile = Symbol("checked-volatile-schema");
|
|
737
|
+
function validateVolatileSchema(schema, path = [], blocked = false, seen = /* @__PURE__ */ new Map()) {
|
|
738
|
+
const states = seen.get(schema) ?? /* @__PURE__ */ new Set();
|
|
739
|
+
if (states.has(blocked)) return;
|
|
740
|
+
states.add(blocked);
|
|
741
|
+
seen.set(schema, states);
|
|
742
|
+
if (schema.meta?.volatile && blocked) throw new ValidationError("volatile fields require a fixed object path without an enclosing volatile field", { path });
|
|
743
|
+
const nested = blocked || !!schema.meta?.volatile;
|
|
744
|
+
if (schema.dict) for (const [key, child] of Object.entries(schema.dict)) validateVolatileSchema(child, [...path, key], nested, seen);
|
|
745
|
+
if (schema.sKey) validateVolatileSchema(schema.sKey, [...path, "<key>"], true, seen);
|
|
746
|
+
if (schema.inner && (schema.type !== "lazy" || schema.inner[kSchema])) validateVolatileSchema(schema.inner, [...path, "*"], true, seen);
|
|
747
|
+
if (schema.list) for (let index = 0; index < schema.list.length; index++) validateVolatileSchema(schema.list[index], [...path, String(index)], true, seen);
|
|
748
|
+
}
|
|
658
749
|
Schema.extend = function extend(type, resolve) {
|
|
659
750
|
resolvers[type] = resolve;
|
|
660
751
|
};
|
|
661
752
|
Schema.resolve = function resolve(data, schema, options = {}, strict = false) {
|
|
662
753
|
if (!schema) return [data];
|
|
754
|
+
if (!options[checkedVolatile]) {
|
|
755
|
+
validateVolatileSchema(schema, options.path);
|
|
756
|
+
options = {
|
|
757
|
+
...options,
|
|
758
|
+
[checkedVolatile]: true
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
if (schema.meta?.volatile) {
|
|
762
|
+
const inner = Schema(schema);
|
|
763
|
+
inner.meta = {
|
|
764
|
+
...schema.meta,
|
|
765
|
+
volatile: false
|
|
766
|
+
};
|
|
767
|
+
const [value, adapted] = Schema.resolve(data, inner, options, strict);
|
|
768
|
+
try {
|
|
769
|
+
return [createVolatile(value), adapted];
|
|
770
|
+
} catch (error) {
|
|
771
|
+
throw new ValidationError(error instanceof Error ? error.message : String(error), options);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
663
774
|
if (options.ignore?.(data, schema)) return [data];
|
|
664
775
|
if (isNullable(data) && schema.type !== "lazy") {
|
|
665
776
|
if (schema.meta.required) throw new ValidationError(`missing required value`, options);
|
|
@@ -762,6 +873,7 @@ Schema.extend("lazy", (data, schema, options, strict) => {
|
|
|
762
873
|
...schema.meta,
|
|
763
874
|
...schema.inner.meta
|
|
764
875
|
};
|
|
876
|
+
validateVolatileSchema(schema.inner, options.path, true);
|
|
765
877
|
}
|
|
766
878
|
return Schema.resolve(data, schema.inner, options, strict);
|
|
767
879
|
});
|
|
@@ -861,7 +973,7 @@ function property(data, key, schema, options) {
|
|
|
861
973
|
} catch (e) {
|
|
862
974
|
if (!options?.autofix) throw e;
|
|
863
975
|
delete data[key];
|
|
864
|
-
return schema.meta.default;
|
|
976
|
+
return schema.meta.volatile ? createVolatile(schema.meta.default) : schema.meta.default;
|
|
865
977
|
}
|
|
866
978
|
}
|
|
867
979
|
Schema.extend("array", (data, { inner, meta }, options) => {
|
|
@@ -1035,10 +1147,10 @@ function freezeMessage(message) {
|
|
|
1035
1147
|
* @returns an immutable message with a fresh stable identity.
|
|
1036
1148
|
*/
|
|
1037
1149
|
function createMessage(input) {
|
|
1038
|
-
return
|
|
1150
|
+
return deepFreeze(structuredClone({
|
|
1039
1151
|
...input,
|
|
1040
1152
|
id: brandString(randomUUID())
|
|
1041
|
-
});
|
|
1153
|
+
}));
|
|
1042
1154
|
}
|
|
1043
1155
|
/**
|
|
1044
1156
|
* Create one identified user-role message and freeze it before publication.
|
|
@@ -1262,13 +1374,15 @@ function failureSnapshot(value) {
|
|
|
1262
1374
|
const status = candidate.status;
|
|
1263
1375
|
const providerRetryAfterMs = candidate.providerRetryAfterMs;
|
|
1264
1376
|
const requestId = candidate.requestId;
|
|
1265
|
-
|
|
1377
|
+
const offloadImages = candidate.offloadImages;
|
|
1378
|
+
if (typeof message !== "string" || message.length === 0 || typeof code !== "string" || code.length === 0 || status !== void 0 && (!Number.isInteger(status) || status < 100 || status > 599) || providerRetryAfterMs !== void 0 && (!Number.isFinite(providerRetryAfterMs) || providerRetryAfterMs <= 0) || requestId !== void 0 && (typeof requestId !== "string" || requestId.length === 0) || offloadImages !== void 0 && (!Number.isSafeInteger(offloadImages) || offloadImages <= 0)) return void 0;
|
|
1266
1379
|
return Object.freeze({
|
|
1267
1380
|
message,
|
|
1268
1381
|
code,
|
|
1269
1382
|
...status === void 0 ? {} : { status },
|
|
1270
1383
|
...providerRetryAfterMs === void 0 ? {} : { providerRetryAfterMs },
|
|
1271
|
-
...requestId === void 0 ? {} : { requestId }
|
|
1384
|
+
...requestId === void 0 ? {} : { requestId },
|
|
1385
|
+
...offloadImages === void 0 ? {} : { offloadImages }
|
|
1272
1386
|
});
|
|
1273
1387
|
} catch (_sdkFailureGetter) {
|
|
1274
1388
|
return;
|
|
@@ -1298,25 +1412,23 @@ function textOnlyImageText(ref) {
|
|
|
1298
1412
|
return `[image omitted because this model accepts text only; attachment sha256:${String(ref.attachmentId).slice(7, 15)}]`;
|
|
1299
1413
|
}
|
|
1300
1414
|
/**
|
|
1301
|
-
* True when typed model content contains an image block
|
|
1302
|
-
*
|
|
1303
|
-
*
|
|
1304
|
-
* survey), so a consumer cannot silently diverge on nesting depth.
|
|
1415
|
+
* True when typed model content contains an image block. This is the one image
|
|
1416
|
+
* walk shared by every image policy (capability gating, text-only
|
|
1417
|
+
* serialization, compaction survey), so a consumer cannot silently diverge.
|
|
1305
1418
|
* @param content - typed model content blocks.
|
|
1306
|
-
* @returns whether any
|
|
1419
|
+
* @returns whether any block is an image.
|
|
1307
1420
|
*/
|
|
1308
1421
|
function contentHasImage(content) {
|
|
1309
|
-
return content.some((block) => block.type === "image"
|
|
1422
|
+
return content.some((block) => block.type === "image");
|
|
1310
1423
|
}
|
|
1311
1424
|
/**
|
|
1312
|
-
* True when typed model content contains a file block
|
|
1313
|
-
* tool-result content on the same recursion every file policy shares.
|
|
1425
|
+
* True when typed model content contains a file block.
|
|
1314
1426
|
* Reads current content on every call without retaining scan results.
|
|
1315
1427
|
* @param content - typed model content blocks.
|
|
1316
|
-
* @returns whether any
|
|
1428
|
+
* @returns whether any block is a file.
|
|
1317
1429
|
*/
|
|
1318
1430
|
function contentHasFile(content) {
|
|
1319
|
-
for (const block of content) if (block.type === "file"
|
|
1431
|
+
for (const block of content) if (block.type === "file") return true;
|
|
1320
1432
|
return false;
|
|
1321
1433
|
}
|
|
1322
1434
|
/**
|
|
@@ -1333,7 +1445,7 @@ function fileHandleText(ref, readonlyPath) {
|
|
|
1333
1445
|
if (readonlyPath === void 0) return `[${identity} was uploaded, but the current execution environment cannot access a readable path. Report that limitation if its contents are needed; do not claim to have read it.]`;
|
|
1334
1446
|
return `[${identity}: verbatim read-only copy saved at ${quoted(readonlyPath)}. Read that path with your file tools when its contents are needed; copy it to a writable location before modifying it. When delegating file work, include this saved path in the delegation prompt; only subagents sharing this execution environment can read it.]`;
|
|
1335
1447
|
}
|
|
1336
|
-
/** Replace every file occurrence
|
|
1448
|
+
/** Replace every file occurrence with handle text. */
|
|
1337
1449
|
function replaceFilesWithHandles(blocks, resolvePath) {
|
|
1338
1450
|
let next;
|
|
1339
1451
|
for (const [index, block] of blocks.entries()) {
|
|
@@ -1345,29 +1457,10 @@ function replaceFilesWithHandles(blocks, resolvePath) {
|
|
|
1345
1457
|
});
|
|
1346
1458
|
continue;
|
|
1347
1459
|
}
|
|
1348
|
-
if (block.type === "tool-result") {
|
|
1349
|
-
const content = replaceFilesWithHandles(block.content, resolvePath);
|
|
1350
|
-
if (content !== block.content) {
|
|
1351
|
-
next ??= blocks.slice(0, index);
|
|
1352
|
-
next.push({
|
|
1353
|
-
...block,
|
|
1354
|
-
content
|
|
1355
|
-
});
|
|
1356
|
-
continue;
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
1460
|
next?.push(block);
|
|
1360
1461
|
}
|
|
1361
1462
|
return next ?? blocks;
|
|
1362
1463
|
}
|
|
1363
|
-
/**
|
|
1364
|
-
* Project durable file history into deterministic handle text for every model
|
|
1365
|
-
* route. Unlike images, no provider receives file blocks natively, so this
|
|
1366
|
-
* projection is unconditional in request assembly.
|
|
1367
|
-
* @param messages - complete request history.
|
|
1368
|
-
* @param resolvePath - resolve one reference's current execution-world read path.
|
|
1369
|
-
* @returns the original list without files, otherwise shallow message copies with handle text.
|
|
1370
|
-
*/
|
|
1371
1464
|
function projectFilesToText(messages, resolvePath) {
|
|
1372
1465
|
if (!messages.some((message) => contentHasFile(message.content))) return messages;
|
|
1373
1466
|
return messages.map((message) => {
|
|
@@ -1378,7 +1471,7 @@ function projectFilesToText(messages, resolvePath) {
|
|
|
1378
1471
|
};
|
|
1379
1472
|
});
|
|
1380
1473
|
}
|
|
1381
|
-
/** Replace every image occurrence
|
|
1474
|
+
/** Replace every image occurrence for a text-only model. */
|
|
1382
1475
|
function replaceImagesForTextModel(blocks) {
|
|
1383
1476
|
let next;
|
|
1384
1477
|
for (const [index, block] of blocks.entries()) {
|
|
@@ -1390,26 +1483,10 @@ function replaceImagesForTextModel(blocks) {
|
|
|
1390
1483
|
});
|
|
1391
1484
|
continue;
|
|
1392
1485
|
}
|
|
1393
|
-
if (block.type === "tool-result") {
|
|
1394
|
-
const content = replaceImagesForTextModel(block.content);
|
|
1395
|
-
if (content !== block.content) {
|
|
1396
|
-
next ??= blocks.slice(0, index);
|
|
1397
|
-
next.push({
|
|
1398
|
-
...block,
|
|
1399
|
-
content
|
|
1400
|
-
});
|
|
1401
|
-
continue;
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
1486
|
next?.push(block);
|
|
1405
1487
|
}
|
|
1406
1488
|
return next ?? blocks;
|
|
1407
1489
|
}
|
|
1408
|
-
/**
|
|
1409
|
-
* Project durable image history into deterministic text for an exact text-only model.
|
|
1410
|
-
* @param messages - complete request history.
|
|
1411
|
-
* @returns the original list without images, otherwise shallow message copies with stable placeholders.
|
|
1412
|
-
*/
|
|
1413
1490
|
function projectImagesForTextModel(messages) {
|
|
1414
1491
|
if (!messages.some((message) => contentHasImage(message.content))) return messages;
|
|
1415
1492
|
return messages.map((message) => {
|
|
@@ -1499,7 +1576,8 @@ var LlmError = class extends HarnessError {
|
|
|
1499
1576
|
code,
|
|
1500
1577
|
...options?.status === void 0 ? {} : { status: options.status },
|
|
1501
1578
|
...options?.providerRetryAfterMs === void 0 ? {} : { providerRetryAfterMs: options.providerRetryAfterMs },
|
|
1502
|
-
...options?.requestId === void 0 ? {} : { requestId: options.requestId }
|
|
1579
|
+
...options?.requestId === void 0 ? {} : { requestId: options.requestId },
|
|
1580
|
+
...options?.offloadImages === void 0 ? {} : { offloadImages: options.offloadImages }
|
|
1503
1581
|
});
|
|
1504
1582
|
}
|
|
1505
1583
|
};
|
|
@@ -1767,7 +1845,8 @@ var LlmError = class extends HarnessError {
|
|
|
1767
1845
|
id: model.id,
|
|
1768
1846
|
...model.name === void 0 ? {} : { name: model.name },
|
|
1769
1847
|
...model.contextWindow === void 0 ? {} : { contextWindow: model.contextWindow },
|
|
1770
|
-
...model.maxTokens === void 0 ? {} : { maxTokens: model.maxTokens }
|
|
1848
|
+
...model.maxTokens === void 0 ? {} : { maxTokens: model.maxTokens },
|
|
1849
|
+
...model.inputModalities === void 0 ? {} : { inputModalities: [...model.inputModalities] }
|
|
1771
1850
|
});
|
|
1772
1851
|
}
|
|
1773
1852
|
return models;
|
|
@@ -1996,8 +2075,9 @@ var LlmError = class extends HarnessError {
|
|
|
1996
2075
|
/** Remove replay state whose historical route is owned by another adapter. */
|
|
1997
2076
|
forAdapter(options, adapter) {
|
|
1998
2077
|
const messages = options.messages.map((message) => {
|
|
2078
|
+
if (message.role !== "assistant") return message;
|
|
1999
2079
|
const source = message.source;
|
|
2000
|
-
if (
|
|
2080
|
+
if (source.replayState === void 0) return message;
|
|
2001
2081
|
if (this.adapters.get(source.provider)?.adapter === adapter) return message;
|
|
2002
2082
|
return freezeMessage({
|
|
2003
2083
|
...message,
|
|
@@ -2238,4 +2318,4 @@ const inject = ["workspaceRegistry"];
|
|
|
2238
2318
|
//#endregion
|
|
2239
2319
|
export { registerWorkspaceInstructionInjector as a, name as i, escapeInstructionFrameBody as n, renderInstructionMessageText as o, inject as r, resolveSnapshotForSession as s, createInstructionMessage as t };
|
|
2240
2320
|
|
|
2241
|
-
//# sourceMappingURL=workspace-instruction-context-
|
|
2321
|
+
//# sourceMappingURL=workspace-instruction-context-DzHFTN87.js.map
|