@codexhost/cli-linux-arm64 0.9.2 → 0.10.1
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/THIRD_PARTY_NOTICES.txt +0 -4
- package/app/codexhost-distribution.json +1 -1
- package/app/desktop-controller.mjs +49 -18
- package/app/host-runtime.mjs +1050 -673
- package/app/plugins/antigravity/plugin.mjs +18 -3
- package/app/plugins/claude-code/plugin.mjs +214 -7
- package/app/plugins/codebuddy/plugin.mjs +103 -5
- package/app/plugins/cursor-cli/plugin.mjs +152 -53
- package/app/plugins/deepseek-harness/plugin.mjs +622 -109
- package/app/plugins/enabled.json +2 -1
- package/app/plugins/grok/plugin.mjs +272 -79
- package/app/plugins/hermes/plugin.mjs +162 -63
- package/app/plugins/kimi-code/manifest.json +11 -0
- package/app/plugins/kimi-code/plugin.mjs +24226 -0
- package/app/plugins/kiro-cli/plugin.mjs +257 -65
- package/app/plugins/omp/plugin.mjs +407 -156
- package/app/plugins/opencode/plugin.mjs +18 -3
- package/app/plugins/pi/plugin.mjs +215 -5
- package/app/plugins/qoder/plugin.mjs +279 -187
- package/app/plugins/qoder-cn/plugin.mjs +279 -187
- package/app/plugins/workbuddy/plugin.mjs +102 -5
- package/app/renderer-extension.js +1445 -497
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/licenses/opencodex-LICENSE.txt +0 -21
|
@@ -18985,10 +18985,21 @@ var harnessCommandDescriptorSchema = external_exports.object({
|
|
|
18985
18985
|
invocation: commandInvocationSchema,
|
|
18986
18986
|
label: commandLabelSchema,
|
|
18987
18987
|
description: commandDescriptionSchema.optional(),
|
|
18988
|
-
argumentMode: external_exports.enum(["none", "text"])
|
|
18988
|
+
argumentMode: external_exports.enum(["none", "text"]),
|
|
18989
|
+
/**
|
|
18990
|
+
* Native distinction reported by the Harness. Omitted when the Harness does
|
|
18991
|
+
* not tell skills and commands apart; consumers treat that as "command".
|
|
18992
|
+
*/
|
|
18993
|
+
kind: external_exports.enum(["command", "skill"]).optional()
|
|
18989
18994
|
}).strict();
|
|
18990
18995
|
var harnessCommandCatalogSchema = external_exports.object({
|
|
18991
|
-
commands: external_exports.array(harnessCommandDescriptorSchema)
|
|
18996
|
+
commands: external_exports.array(harnessCommandDescriptorSchema),
|
|
18997
|
+
/**
|
|
18998
|
+
* `live` when the catalog includes what a native Session reports for its
|
|
18999
|
+
* workspace (custom commands, skills); `static` for Adapter built-ins only.
|
|
19000
|
+
* Omitted by Adapters; set by the Host on inspection results.
|
|
19001
|
+
*/
|
|
19002
|
+
source: external_exports.enum(["live", "static"]).optional()
|
|
18992
19003
|
}).strict().superRefine((catalog, context) => {
|
|
18993
19004
|
const ids = /* @__PURE__ */ new Set();
|
|
18994
19005
|
for (const [index, command] of catalog.commands.entries()) {
|
|
@@ -19002,7 +19013,11 @@ var harnessCommandCatalogSchema = external_exports.object({
|
|
|
19002
19013
|
ids.add(command.id);
|
|
19003
19014
|
}
|
|
19004
19015
|
});
|
|
19005
|
-
var harnessCommandsInspectParamsSchema = external_exports.object({
|
|
19016
|
+
var harnessCommandsInspectParamsSchema = external_exports.object({
|
|
19017
|
+
harnessId: harnessIdSchema,
|
|
19018
|
+
/** Workspace of a draft without a Thread, for its live catalog when known. */
|
|
19019
|
+
cwd: external_exports.string().min(1).optional()
|
|
19020
|
+
}).strict();
|
|
19006
19021
|
var threadCommandsInspectParamsSchema = external_exports.object({
|
|
19007
19022
|
threadId: hostThreadIdSchema
|
|
19008
19023
|
}).strict();
|
|
@@ -19608,7 +19623,7 @@ function parseDeepSeekEndpoint(endpoint = DEFAULT_DEEPSEEK_ENDPOINT) {
|
|
|
19608
19623
|
throw probeError("protocolError", "DeepSeek Harness endpoint must be an uncredentialed loopback HTTP root");
|
|
19609
19624
|
}
|
|
19610
19625
|
if (parsed.searchParams.has("token")) {
|
|
19611
|
-
throw probeError("authenticationRequired", "DeepSeek Harness Web bootstrap URL 不可作为连接端点;请关闭该实例,让 codexhost
|
|
19626
|
+
throw probeError("authenticationRequired", "DeepSeek Harness Web bootstrap URL 不可作为连接端点;请关闭该实例,让 codexhost 启动本地 DSH Web。\nA DeepSeek Harness Web bootstrap URL cannot be used as an endpoint. Close that instance and let codexhost start the local DSH Web.");
|
|
19612
19627
|
}
|
|
19613
19628
|
if (parsed.search !== "") {
|
|
19614
19629
|
throw probeError("protocolError", "DeepSeek Harness endpoint must not contain a query");
|
|
@@ -19640,11 +19655,7 @@ function classifyDeepSeekVersionOutput(output) {
|
|
|
19640
19655
|
if (version2 === null || !SEMVER_PATTERN.test(version2)) {
|
|
19641
19656
|
throw probeError("protocolError", "DeepSeek Harness --version did not return exactly one semantic version");
|
|
19642
19657
|
}
|
|
19643
|
-
|
|
19644
|
-
return { generation: "modern", version: version2 };
|
|
19645
|
-
}
|
|
19646
|
-
throw probeError("unsupported", `当前 DeepSeek Harness 版本 ${version2} 不受支持;codexhost 仅支持 dsh-v0.1.2-rc.1 和 dsh-v0.1.5-rc.1,推荐安装 dsh-v0.1.5-rc.1。
|
|
19647
|
-
DeepSeek Harness ${version2} is unsupported. codexhost only supports dsh-v0.1.2-rc.1 and dsh-v0.1.5-rc.1; dsh-v0.1.5-rc.1 is recommended.`);
|
|
19658
|
+
return { generation: "modern", version: version2 };
|
|
19648
19659
|
}
|
|
19649
19660
|
function appendOutput(target, value, limit) {
|
|
19650
19661
|
const chunk = Buffer.isBuffer(value) ? value : Buffer.from(String(value));
|
|
@@ -20850,7 +20861,8 @@ var ModernRemoteConnection = class {
|
|
|
20850
20861
|
} catch (error51) {
|
|
20851
20862
|
throw this.#transportFailure("DeepSeek Harness Web authentication failed", error51);
|
|
20852
20863
|
}
|
|
20853
|
-
|
|
20864
|
+
const location = response.headers.get("location");
|
|
20865
|
+
if (response.status !== 303 || location !== "/" && location !== "./") {
|
|
20854
20866
|
await cancelResponse(response);
|
|
20855
20867
|
throw new ModernRemoteConnectionError(response.status === 401 || response.status === 403 ? "authenticationRequired" : "protocolError", "DeepSeek Harness Web rejected its bootstrap authentication exchange");
|
|
20856
20868
|
}
|
|
@@ -21382,7 +21394,7 @@ function parseEvent(value, format = 0) {
|
|
|
21382
21394
|
throw protocolError("journal event has invalid scalar fields");
|
|
21383
21395
|
}
|
|
21384
21396
|
assertJsonValue(value.data, "journal event data");
|
|
21385
|
-
if (format
|
|
21397
|
+
if (format >= 3 && value.ignorable === true) {
|
|
21386
21398
|
if (Object.hasOwn(value, "sourceEventSeqs"))
|
|
21387
21399
|
assertJsonValue(value.sourceEventSeqs, "journal event sourceEventSeqs");
|
|
21388
21400
|
if (Object.hasOwn(value, "surfaceOp"))
|
|
@@ -21401,8 +21413,8 @@ function parseEvent(value, format = 0) {
|
|
|
21401
21413
|
function parseSurfaceOp(value, format) {
|
|
21402
21414
|
if (value === "append")
|
|
21403
21415
|
return value;
|
|
21404
|
-
const start = format
|
|
21405
|
-
const end = format
|
|
21416
|
+
const start = format >= 3 ? "startSeq" : "start";
|
|
21417
|
+
const end = format >= 3 ? "endSeq" : "end";
|
|
21406
21418
|
if (!isRecord3(value) || !hasExactKeys2(value, ["op", start, end]) || value.op !== "replace" || !isSeq(value[start]) || !isSeq(value[end])) {
|
|
21407
21419
|
throw protocolError("journal event has an invalid surfaceOp");
|
|
21408
21420
|
}
|
|
@@ -21904,12 +21916,33 @@ function parseArguments(value) {
|
|
|
21904
21916
|
return value;
|
|
21905
21917
|
}
|
|
21906
21918
|
}
|
|
21919
|
+
function contentText(value) {
|
|
21920
|
+
if (!isRecord4(value) || !Array.isArray(value.content))
|
|
21921
|
+
return "";
|
|
21922
|
+
return value.content.filter((block) => isRecord4(block) && block.type === "text" && typeof block.text === "string").map((block) => block.text).join("");
|
|
21923
|
+
}
|
|
21907
21924
|
function projectToolResult(value, limit) {
|
|
21908
21925
|
if (!isRecord4(value) || !isRecord4(value.source) || value.source.kind !== "tool")
|
|
21909
21926
|
return null;
|
|
21910
21927
|
const callId = value.source.callId;
|
|
21911
21928
|
if (!nonBlankString(callId) || !Array.isArray(value.content))
|
|
21912
21929
|
return null;
|
|
21930
|
+
if (value.role === "tool") {
|
|
21931
|
+
if (value.toolCallId !== callId || value.isError !== void 0 && typeof value.isError !== "boolean")
|
|
21932
|
+
return null;
|
|
21933
|
+
const text2 = contentText(value);
|
|
21934
|
+
const truncated2 = text2.length > limit;
|
|
21935
|
+
return {
|
|
21936
|
+
callId,
|
|
21937
|
+
failed: value.isError === true,
|
|
21938
|
+
...text2 ? {
|
|
21939
|
+
output: {
|
|
21940
|
+
content: [{ type: "text", text: truncated2 ? text2.slice(0, limit) : text2 }],
|
|
21941
|
+
...truncated2 ? { truncated: true } : {}
|
|
21942
|
+
}
|
|
21943
|
+
} : {}
|
|
21944
|
+
};
|
|
21945
|
+
}
|
|
21913
21946
|
const resultBlocks = value.content.filter((block) => isRecord4(block) && block.type === "tool-result" && block.toolCallId === callId && Array.isArray(block.content));
|
|
21914
21947
|
if (resultBlocks.length === 0)
|
|
21915
21948
|
return null;
|
|
@@ -22025,6 +22058,12 @@ function projectTurnReason(value) {
|
|
|
22025
22058
|
history: { status: "cancelled", reason: "Cancelled by user" }
|
|
22026
22059
|
};
|
|
22027
22060
|
}
|
|
22061
|
+
if (value.kind === "forked") {
|
|
22062
|
+
return {
|
|
22063
|
+
outcome: { status: "cancelled", reason: "Forked from parent Session" },
|
|
22064
|
+
history: { status: "cancelled", reason: "Forked from parent Session" }
|
|
22065
|
+
};
|
|
22066
|
+
}
|
|
22028
22067
|
const error51 = {
|
|
22029
22068
|
code: "nativeFailure",
|
|
22030
22069
|
message: value.kind === "error" && isRecord4(value.error) && typeof value.error.message === "string" ? value.error.message : `DeepSeek Harness Turn ended with '${value.kind}'`,
|
|
@@ -22163,6 +22202,12 @@ function positiveInteger(value, label) {
|
|
|
22163
22202
|
function nonNegativeInteger(value, label) {
|
|
22164
22203
|
return boundedInteger(value, label, 0);
|
|
22165
22204
|
}
|
|
22205
|
+
function nonNegativeFiniteNumber(value, label) {
|
|
22206
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
22207
|
+
fail(`${label} must be a finite number greater than or equal to 0`);
|
|
22208
|
+
}
|
|
22209
|
+
return value;
|
|
22210
|
+
}
|
|
22166
22211
|
function nonNegativeSafeInteger2(value) {
|
|
22167
22212
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
22168
22213
|
}
|
|
@@ -22863,16 +22908,219 @@ function matchesForkTail2(expectedPrefix, childEvents) {
|
|
|
22863
22908
|
return childOwned.every((event) => event.type !== "turn/start" && event.type !== "session/end-seed");
|
|
22864
22909
|
}
|
|
22865
22910
|
|
|
22911
|
+
// dist/profiles/v017.js
|
|
22912
|
+
function invalid2(label) {
|
|
22913
|
+
throw new ModernHistoryError("protocolError", `DSH V4 ${label} is malformed`);
|
|
22914
|
+
}
|
|
22915
|
+
function requiredFields(value, fields) {
|
|
22916
|
+
if (fields.some((field) => !Object.hasOwn(value, field)))
|
|
22917
|
+
invalid2("required fields");
|
|
22918
|
+
}
|
|
22919
|
+
function validateV4Content(value) {
|
|
22920
|
+
if (!Array.isArray(value))
|
|
22921
|
+
invalid2("content");
|
|
22922
|
+
for (const block of value) {
|
|
22923
|
+
if (!isRecord3(block) || block.type === "tool-result")
|
|
22924
|
+
invalid2("content block");
|
|
22925
|
+
if (block.type === "tool-addition" || block.type === "tool-removal") {
|
|
22926
|
+
requiredString(block.toolName, "tool change toolName");
|
|
22927
|
+
continue;
|
|
22928
|
+
}
|
|
22929
|
+
if (block.type === "image" && block.offloaded !== void 0 && block.offloaded !== true) {
|
|
22930
|
+
invalid2("image offloaded marker");
|
|
22931
|
+
}
|
|
22932
|
+
const ordinary = Object.fromEntries(Object.entries(block).filter(([key]) => key !== "offloaded"));
|
|
22933
|
+
const canonical = block.type === "text" || block.type === "reasoning" ? { type: block.type, text: block.text } : block.type === "image" || block.type === "file" ? { type: block.type, attachment: block.attachment } : block.type === "tool-call" ? { type: block.type, id: block.id, name: block.name, arguments: block.arguments } : ordinary;
|
|
22934
|
+
DEEPSEEK_V015_PROFILE.validateContent([canonical]);
|
|
22935
|
+
}
|
|
22936
|
+
}
|
|
22937
|
+
function validateV4Chunk(value) {
|
|
22938
|
+
DEEPSEEK_V015_PROFILE.validateChunk(value);
|
|
22939
|
+
if (!isRecord3(value))
|
|
22940
|
+
invalid2("assistant chunk");
|
|
22941
|
+
const blockType = value.type === "block-start" ? value.blockType : value.type === "block-end" && isRecord3(value.block) ? value.block.type : void 0;
|
|
22942
|
+
if (blockType === "tool-result" || blockType === "tool-addition" || blockType === "tool-removal") {
|
|
22943
|
+
invalid2("assistant tool-change block");
|
|
22944
|
+
}
|
|
22945
|
+
}
|
|
22946
|
+
function validateV4Stream(value) {
|
|
22947
|
+
for (const entry of expandV015AssistantStream(value))
|
|
22948
|
+
validateV4Chunk(entry.chunk);
|
|
22949
|
+
}
|
|
22950
|
+
function validateDeveloperMessage(event) {
|
|
22951
|
+
if (!isRecord3(event.data))
|
|
22952
|
+
invalid2("developer/message data");
|
|
22953
|
+
const data = event.data;
|
|
22954
|
+
requiredFields(data, ["turn", "step", "message"]);
|
|
22955
|
+
if (Object.hasOwn(data, "headerSeq") && !Number.isSafeInteger(data.headerSeq))
|
|
22956
|
+
invalid2("developer/message headerSeq");
|
|
22957
|
+
positiveInteger(data.turn, "developer/message turn");
|
|
22958
|
+
positiveInteger(data.step, "developer/message step");
|
|
22959
|
+
if (!isRecord3(data.message))
|
|
22960
|
+
invalid2("developer/message message");
|
|
22961
|
+
const message = data.message;
|
|
22962
|
+
requiredFields(message, ["id", "role", "content", "source"]);
|
|
22963
|
+
requiredString(message.id, "developer/message id");
|
|
22964
|
+
if (message.role !== "developer" || !isRecord3(message.source) || typeof message.source.kind !== "string" || !message.source.kind || message.source.kind === "plugin" || !Array.isArray(message.content)) {
|
|
22965
|
+
invalid2("developer/message role, source or content");
|
|
22966
|
+
}
|
|
22967
|
+
let additions = false;
|
|
22968
|
+
for (const block of message.content) {
|
|
22969
|
+
if (!isRecord3(block))
|
|
22970
|
+
invalid2("developer content block");
|
|
22971
|
+
if (block.type === "tool-addition" || block.type === "tool-removal") {
|
|
22972
|
+
requiredString(block.toolName, "developer toolName");
|
|
22973
|
+
additions ||= block.type === "tool-addition";
|
|
22974
|
+
} else {
|
|
22975
|
+
validateV4Content([block]);
|
|
22976
|
+
}
|
|
22977
|
+
}
|
|
22978
|
+
if (additions !== Object.hasOwn(data, "headerSeq") || additions && (!Number.isSafeInteger(data.headerSeq) || Object.is(data.headerSeq, -0) || data.headerSeq < 0 || data.headerSeq >= event.seq)) {
|
|
22979
|
+
invalid2("developer/message headerSeq");
|
|
22980
|
+
}
|
|
22981
|
+
}
|
|
22982
|
+
function matchesV4ForkTail(prefix, child) {
|
|
22983
|
+
if (!DEEPSEEK_V015_PROFILE.matchesForkTail(prefix, child))
|
|
22984
|
+
return false;
|
|
22985
|
+
const tail = child.slice(prefix.length + 1);
|
|
22986
|
+
const openTurn = prefix.reduce((turn, event) => event.type === "turn/start" ? event.data.turn : event.type === "turn/end" ? null : turn, null);
|
|
22987
|
+
const closer = tail.find((event) => event.type === "turn/end");
|
|
22988
|
+
if (openTurn === null)
|
|
22989
|
+
return closer === void 0 && !tail.some((event) => event.type === "step/end");
|
|
22990
|
+
return closer !== void 0 && isRecord3(closer.data) && closer.data.turn === openTurn && isRecord3(closer.data.reason) && closer.data.reason.kind === "forked";
|
|
22991
|
+
}
|
|
22992
|
+
var DEEPSEEK_V017_PROFILE = Object.freeze({
|
|
22993
|
+
...DEEPSEEK_V015_PROFILE,
|
|
22994
|
+
version: "0.1.7-rc.1",
|
|
22995
|
+
checkpointPrefix: "v4-turn-end:",
|
|
22996
|
+
sessionFormatVersion: 4,
|
|
22997
|
+
matchesForkTail: matchesV4ForkTail,
|
|
22998
|
+
parseHeader(value, expected) {
|
|
22999
|
+
if (!isRecord3(value) || value.version !== 4)
|
|
23000
|
+
invalid2("journal header");
|
|
23001
|
+
if (value.delegationDepth !== void 0 && (!Number.isSafeInteger(value.delegationDepth) || Object.is(value.delegationDepth, -0) || value.delegationDepth < 0)) {
|
|
23002
|
+
invalid2("journal header delegationDepth");
|
|
23003
|
+
}
|
|
23004
|
+
const delegationDepth = value.delegationDepth ?? 0;
|
|
23005
|
+
DEEPSEEK_V015_PROFILE.parseHeader({ ...value, version: 3, delegationDepth }, expected);
|
|
23006
|
+
return { ...value, delegationDepth };
|
|
23007
|
+
},
|
|
23008
|
+
parseHistoryRecord: (value, remaining) => parseV015HistoryRecord(value, remaining, (event) => parseEvent(event, 4)),
|
|
23009
|
+
parseLiveItem: (value) => {
|
|
23010
|
+
const item = parseV015LiveItem(value, (event) => parseEvent(event, 4));
|
|
23011
|
+
if (item.type === "assistant-stream" && "frame" in item && item.frame.type === "chunk") {
|
|
23012
|
+
validateV4Chunk(item.frame.chunk);
|
|
23013
|
+
}
|
|
23014
|
+
return item;
|
|
23015
|
+
},
|
|
23016
|
+
parseAssistantBaseline(value) {
|
|
23017
|
+
const baseline = parseV015AssistantBaseline(value);
|
|
23018
|
+
if (baseline.activeAttempt)
|
|
23019
|
+
validateV4Stream(baseline.activeAttempt.stream);
|
|
23020
|
+
return baseline;
|
|
23021
|
+
},
|
|
23022
|
+
validateContent: validateV4Content,
|
|
23023
|
+
validateChunk: validateV4Chunk,
|
|
23024
|
+
validateEvent(event) {
|
|
23025
|
+
if (event.type === "developer/message") {
|
|
23026
|
+
validateDeveloperMessage(event);
|
|
23027
|
+
} else if (event.type === "system/message") {
|
|
23028
|
+
if (!isRecord3(event.data) || !isRecord3(event.data.message))
|
|
23029
|
+
invalid2("system/message");
|
|
23030
|
+
exactKeys2(event.data, ["turn", "step", "message"]);
|
|
23031
|
+
const message = event.data.message;
|
|
23032
|
+
requiredFields(message, ["id", "role", "content", "source"]);
|
|
23033
|
+
requiredString(message.id, "system/message id");
|
|
23034
|
+
if (message.role !== "system" || !isRecord3(message.source) || message.source.kind !== "system-prompt") {
|
|
23035
|
+
invalid2("system/message source");
|
|
23036
|
+
}
|
|
23037
|
+
validateV4Content(message.content);
|
|
23038
|
+
} else if (event.type === "image/offload") {
|
|
23039
|
+
if (!isRecord3(event.data))
|
|
23040
|
+
invalid2("image/offload");
|
|
23041
|
+
exactKeys2(event.data, ["targets"]);
|
|
23042
|
+
if (!Array.isArray(event.data.targets) || event.data.targets.length === 0)
|
|
23043
|
+
invalid2("image/offload targets");
|
|
23044
|
+
} else if (event.type === "workspace/changes") {
|
|
23045
|
+
if (!isRecord3(event.data))
|
|
23046
|
+
invalid2("workspace/changes");
|
|
23047
|
+
exactKeys2(event.data, ["turn"]);
|
|
23048
|
+
positiveInteger(event.data.turn, "workspace/changes turn");
|
|
23049
|
+
} else if (event.type === "tool/result") {
|
|
23050
|
+
if (!isRecord3(event.data))
|
|
23051
|
+
invalid2("tool/result");
|
|
23052
|
+
const message = event.data.message;
|
|
23053
|
+
if (event.data.error !== void 0 && (!isRecord3(message) || message.isError !== true)) {
|
|
23054
|
+
invalid2("tool/result error marker");
|
|
23055
|
+
}
|
|
23056
|
+
} else if (event.type === "request/header") {
|
|
23057
|
+
DEEPSEEK_V015_PROFILE.validateEvent(event);
|
|
23058
|
+
if (!isRecord3(event.data) || !isRecord3(event.data.header))
|
|
23059
|
+
invalid2("request/header");
|
|
23060
|
+
const tools = event.data.header.tools;
|
|
23061
|
+
if (tools !== void 0 && (!Array.isArray(tools) || tools.some((tool) => !isRecord3(tool) || tool.deferLoading !== void 0 && tool.deferLoading !== true))) {
|
|
23062
|
+
invalid2("request/header tools");
|
|
23063
|
+
}
|
|
23064
|
+
} else if (event.type === "assistant/message" || event.type === "assistant/attempt") {
|
|
23065
|
+
DEEPSEEK_V015_PROFILE.validateEvent(event);
|
|
23066
|
+
if (!isRecord3(event.data))
|
|
23067
|
+
invalid2("assistant settlement");
|
|
23068
|
+
validateV4Stream(event.data.stream);
|
|
23069
|
+
} else {
|
|
23070
|
+
DEEPSEEK_V015_PROFILE.validateEvent(event);
|
|
23071
|
+
}
|
|
23072
|
+
}
|
|
23073
|
+
});
|
|
23074
|
+
|
|
22866
23075
|
// dist/profiles/profile.js
|
|
23076
|
+
var V4_MINIMUM = parseSemVer("0.1.7-rc.1");
|
|
23077
|
+
function parseSemVer(value) {
|
|
23078
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/u.exec(value);
|
|
23079
|
+
if (!match)
|
|
23080
|
+
return void 0;
|
|
23081
|
+
const prerelease = match[4] ? match[4].split(".").map((part) => /^\d+$/u.test(part) ? Number(part) : part) : [];
|
|
23082
|
+
return {
|
|
23083
|
+
major: Number(match[1]),
|
|
23084
|
+
minor: Number(match[2]),
|
|
23085
|
+
patch: Number(match[3]),
|
|
23086
|
+
prerelease
|
|
23087
|
+
};
|
|
23088
|
+
}
|
|
23089
|
+
function compareSemVer(left, right) {
|
|
23090
|
+
for (const key of ["major", "minor", "patch"]) {
|
|
23091
|
+
if (left[key] !== right[key])
|
|
23092
|
+
return left[key] > right[key] ? 1 : -1;
|
|
23093
|
+
}
|
|
23094
|
+
if (left.prerelease.length === 0 || right.prerelease.length === 0) {
|
|
23095
|
+
return left.prerelease.length === right.prerelease.length ? 0 : left.prerelease.length === 0 ? 1 : -1;
|
|
23096
|
+
}
|
|
23097
|
+
const length = Math.max(left.prerelease.length, right.prerelease.length);
|
|
23098
|
+
for (let index = 0; index < length; index += 1) {
|
|
23099
|
+
const leftPart = left.prerelease[index];
|
|
23100
|
+
const rightPart = right.prerelease[index];
|
|
23101
|
+
if (leftPart === void 0 || rightPart === void 0) {
|
|
23102
|
+
return leftPart === rightPart ? 0 : leftPart === void 0 ? -1 : 1;
|
|
23103
|
+
}
|
|
23104
|
+
if (leftPart === rightPart)
|
|
23105
|
+
continue;
|
|
23106
|
+
if (typeof leftPart === "number" && typeof rightPart === "string")
|
|
23107
|
+
return -1;
|
|
23108
|
+
if (typeof leftPart === "string" && typeof rightPart === "number")
|
|
23109
|
+
return 1;
|
|
23110
|
+
return leftPart > rightPart ? 1 : -1;
|
|
23111
|
+
}
|
|
23112
|
+
return 0;
|
|
23113
|
+
}
|
|
23114
|
+
function usesV4Profile(version2) {
|
|
23115
|
+
const parsed = parseSemVer(version2);
|
|
23116
|
+
return parsed !== void 0 && V4_MINIMUM !== void 0 && compareSemVer(parsed, V4_MINIMUM) >= 0;
|
|
23117
|
+
}
|
|
22867
23118
|
function deepSeekModernProfile(version2) {
|
|
22868
|
-
|
|
22869
|
-
|
|
22870
|
-
if (version2 === "0.1.5-rc.1")
|
|
22871
|
-
return DEEPSEEK_V015_PROFILE;
|
|
22872
|
-
throw new TypeError("DeepSeek Harness only supports 0.1.2-rc.1 and 0.1.5-rc.1");
|
|
23119
|
+
const base = /^0\.1\.2(?:-|\+|$)/u.test(version2) ? DEEPSEEK_V012_PROFILE : usesV4Profile(version2) ? DEEPSEEK_V017_PROFILE : DEEPSEEK_V015_PROFILE;
|
|
23120
|
+
return base.version === version2 ? base : Object.freeze({ ...base, version: version2 });
|
|
22873
23121
|
}
|
|
22874
|
-
function
|
|
22875
|
-
return profile.
|
|
23122
|
+
function hasDeepSeekModernStream(profile) {
|
|
23123
|
+
return profile.sessionFormatVersion >= 3;
|
|
22876
23124
|
}
|
|
22877
23125
|
|
|
22878
23126
|
// dist/modern/commands.js
|
|
@@ -22954,7 +23202,7 @@ async function callModernCommand(remote, endpoint, args, parse3, signal, timeout
|
|
|
22954
23202
|
}
|
|
22955
23203
|
}
|
|
22956
23204
|
function executeModernCommand(remote, agentId, line, signal, profile = DEEPSEEK_V012_PROFILE) {
|
|
22957
|
-
return callModernCommand(remote, "commands/execute",
|
|
23205
|
+
return callModernCommand(remote, "commands/execute", profile.sessionFormatVersion !== 0 ? { agentId, line, submittedAttachments: [] } : { agentId, line, images: [] }, parseModernCommandExecution, signal, null);
|
|
22958
23206
|
}
|
|
22959
23207
|
|
|
22960
23208
|
// dist/modern/control-store.js
|
|
@@ -23226,13 +23474,15 @@ function parseSessionCollection(value, kind, sessions, maxSessions) {
|
|
|
23226
23474
|
}
|
|
23227
23475
|
}
|
|
23228
23476
|
}
|
|
23229
|
-
function parseBaseline(value, maxSessions, maxKeys) {
|
|
23230
|
-
if (!isRecord6(value) || !hasExactKeys4(value, ["queues", "jobs", "projections"]) || !isPlainRecord3(value.projections)) {
|
|
23477
|
+
function parseBaseline(value, maxSessions, maxKeys, formatVersion) {
|
|
23478
|
+
if (!isRecord6(value) || !hasExactKeys4(value, formatVersion === 4 ? ["projections"] : ["queues", "jobs", "projections"]) || !isPlainRecord3(value.projections)) {
|
|
23231
23479
|
throw storeError("protocolError", "DeepSeek Harness control stream emitted an invalid baseline");
|
|
23232
23480
|
}
|
|
23233
23481
|
const sessions = /* @__PURE__ */ new Set();
|
|
23234
|
-
|
|
23235
|
-
|
|
23482
|
+
if (formatVersion !== 4) {
|
|
23483
|
+
parseSessionCollection(value.queues, "queues", sessions, maxSessions);
|
|
23484
|
+
parseSessionCollection(value.jobs, "jobs", sessions, maxSessions);
|
|
23485
|
+
}
|
|
23236
23486
|
const projections = /* @__PURE__ */ Object.create(null);
|
|
23237
23487
|
for (const [sessionId, block] of Object.entries(value.projections)) {
|
|
23238
23488
|
if (!validIdentifier(sessionId)) {
|
|
@@ -23246,12 +23496,15 @@ function parseBaseline(value, maxSessions, maxKeys) {
|
|
|
23246
23496
|
}
|
|
23247
23497
|
return { projections };
|
|
23248
23498
|
}
|
|
23249
|
-
function parseControlFrame(value, maxSessions, maxKeys) {
|
|
23499
|
+
function parseControlFrame(value, maxSessions, maxKeys, formatVersion) {
|
|
23250
23500
|
if (!isRecord6(value) || typeof value.type !== "string") {
|
|
23251
23501
|
throw storeError("protocolError", "DeepSeek Harness control stream emitted an invalid frame");
|
|
23252
23502
|
}
|
|
23253
23503
|
if (value.type === "baseline" && hasExactKeys4(value, ["type", "value"])) {
|
|
23254
|
-
return {
|
|
23504
|
+
return {
|
|
23505
|
+
type: "baseline",
|
|
23506
|
+
value: parseBaseline(value.value, maxSessions, maxKeys, formatVersion)
|
|
23507
|
+
};
|
|
23255
23508
|
}
|
|
23256
23509
|
if (value.type === "projection" && hasExactKeys4(value, ["type", "sessionId", "key", "value", "seq"]) && validIdentifier(value.sessionId) && validProjectionKey(value.key) && validSeq(value.seq)) {
|
|
23257
23510
|
const projection = measureProjection(value.key, value.value);
|
|
@@ -23264,12 +23517,12 @@ function parseControlFrame(value, maxSessions, maxKeys) {
|
|
|
23264
23517
|
bytes: projection.bytes
|
|
23265
23518
|
};
|
|
23266
23519
|
}
|
|
23267
|
-
if (value.type === "queue" && hasExactKeys4(value, ["type", "sessionId", "items"]) && validIdentifier(value.sessionId) && Array.isArray(value.items) && value.items.length <= MAX_COLLECTION_ITEMS) {
|
|
23520
|
+
if (formatVersion !== 4 && value.type === "queue" && hasExactKeys4(value, ["type", "sessionId", "items"]) && validIdentifier(value.sessionId) && Array.isArray(value.items) && value.items.length <= MAX_COLLECTION_ITEMS) {
|
|
23268
23521
|
for (const item of value.items)
|
|
23269
23522
|
parseQueueItem(item);
|
|
23270
23523
|
return { type: "queue", sessionId: value.sessionId };
|
|
23271
23524
|
}
|
|
23272
|
-
if (value.type === "jobs" && hasExactKeys4(value, ["type", "sessionId", "jobs"]) && validIdentifier(value.sessionId) && Array.isArray(value.jobs) && value.jobs.length <= MAX_COLLECTION_ITEMS) {
|
|
23525
|
+
if (formatVersion !== 4 && value.type === "jobs" && hasExactKeys4(value, ["type", "sessionId", "jobs"]) && validIdentifier(value.sessionId) && Array.isArray(value.jobs) && value.jobs.length <= MAX_COLLECTION_ITEMS) {
|
|
23273
23526
|
for (const job of value.jobs)
|
|
23274
23527
|
parseJob(job);
|
|
23275
23528
|
return { type: "jobs", sessionId: value.sessionId };
|
|
@@ -23281,6 +23534,7 @@ function parseSeed(value, maxKeys) {
|
|
|
23281
23534
|
}
|
|
23282
23535
|
var ModernControlStore = class {
|
|
23283
23536
|
#lifetime = new AbortController();
|
|
23537
|
+
#formatVersion;
|
|
23284
23538
|
#maxKeys;
|
|
23285
23539
|
#maxSessions;
|
|
23286
23540
|
#maxWaiters;
|
|
@@ -23301,6 +23555,7 @@ var ModernControlStore = class {
|
|
|
23301
23555
|
#readyResolve;
|
|
23302
23556
|
constructor(source, options = {}) {
|
|
23303
23557
|
this.#source = source;
|
|
23558
|
+
this.#formatVersion = options.profile?.sessionFormatVersion ?? 3;
|
|
23304
23559
|
this.#maxSessions = positiveInteger3(options.maxSessions ?? DEFAULT_MAX_SESSIONS, "maxSessions");
|
|
23305
23560
|
this.#maxKeys = positiveInteger3(options.maxKeysPerSession ?? DEFAULT_MAX_KEYS_PER_SESSION, "maxKeysPerSession");
|
|
23306
23561
|
this.#maxWaiters = positiveInteger3(options.maxWaiters ?? DEFAULT_MAX_WAITERS, "maxWaiters");
|
|
@@ -23469,7 +23724,7 @@ var ModernControlStore = class {
|
|
|
23469
23724
|
replaceBaseline(frame) {
|
|
23470
23725
|
this.#assertUsable();
|
|
23471
23726
|
try {
|
|
23472
|
-
const parsed = parseControlFrame(frame, this.#maxSessions, this.#maxKeys);
|
|
23727
|
+
const parsed = parseControlFrame(frame, this.#maxSessions, this.#maxKeys, this.#formatVersion);
|
|
23473
23728
|
if (parsed.type !== "baseline") {
|
|
23474
23729
|
throw storeError("protocolError", "Control baseline replacement requires a baseline frame");
|
|
23475
23730
|
}
|
|
@@ -23510,7 +23765,7 @@ var ModernControlStore = class {
|
|
|
23510
23765
|
return;
|
|
23511
23766
|
throw storeError(this.#opened ? "unavailable" : "protocolError", this.#opened ? "DeepSeek Harness control stream ended unexpectedly" : "DeepSeek Harness control stream ended before its baseline");
|
|
23512
23767
|
}
|
|
23513
|
-
const frame = parseControlFrame(next.value, this.#maxSessions, this.#maxKeys);
|
|
23768
|
+
const frame = parseControlFrame(next.value, this.#maxSessions, this.#maxKeys, this.#formatVersion);
|
|
23514
23769
|
if (!generationOpened && frame.type !== "baseline") {
|
|
23515
23770
|
throw storeError("protocolError", "DeepSeek Harness control stream omitted its baseline");
|
|
23516
23771
|
}
|
|
@@ -24641,7 +24896,7 @@ function validateSecrets(value) {
|
|
|
24641
24896
|
}
|
|
24642
24897
|
return value;
|
|
24643
24898
|
}
|
|
24644
|
-
function parseDescribe(value) {
|
|
24899
|
+
function parseDescribe(value, profile) {
|
|
24645
24900
|
assertBoundedJson2(value);
|
|
24646
24901
|
if (!isPlainRecord4(value) || !exactKeys3(value, ["writable", "hasDocument", "namespaces"])) {
|
|
24647
24902
|
throw permissionError("protocolError", "DeepSeek Harness returned an invalid settings response");
|
|
@@ -24655,7 +24910,7 @@ function parseDescribe(value) {
|
|
|
24655
24910
|
const namespaceIds = [];
|
|
24656
24911
|
const permissionNamespaces = [];
|
|
24657
24912
|
for (const candidate of value.namespaces) {
|
|
24658
|
-
if (!isPlainRecord4(candidate) || !exactKeys3(candidate, ["ns", "schema", "value", "applies", "secrets", "revision"], ["base", "user"]) || candidate.applies !== "live" && candidate.applies !== "restart" || !validRevision(candidate.revision)) {
|
|
24913
|
+
if (!isPlainRecord4(candidate) || !exactKeys3(candidate, profile.sessionFormatVersion === 4 ? ["ns", "autoGenerate", "schema", "value", "applies", "secrets", "revision"] : ["ns", "schema", "value", "applies", "secrets", "revision"], ["base", "user"]) || profile.sessionFormatVersion === 4 && typeof candidate.autoGenerate !== "boolean" || candidate.applies !== "live" && candidate.applies !== "restart" || !validRevision(candidate.revision)) {
|
|
24659
24914
|
throw permissionError("protocolError", "DeepSeek Harness returned an invalid settings namespace");
|
|
24660
24915
|
}
|
|
24661
24916
|
const ns = nonBlankString2(candidate.ns, MAX_NAMESPACE_ID_LENGTH, "settings namespace id");
|
|
@@ -24693,7 +24948,7 @@ function permissionSection(value, requireDefault, knownIds, area) {
|
|
|
24693
24948
|
}
|
|
24694
24949
|
}
|
|
24695
24950
|
}
|
|
24696
|
-
function catalogFromNamespace(view) {
|
|
24951
|
+
function catalogFromNamespace(view, profile) {
|
|
24697
24952
|
if (view.applies !== "live") {
|
|
24698
24953
|
throw permissionError("protocolError", "DeepSeek Harness permission settings are not live");
|
|
24699
24954
|
}
|
|
@@ -24712,10 +24967,14 @@ function catalogFromNamespace(view) {
|
|
|
24712
24967
|
}
|
|
24713
24968
|
const field = dictionary.defaultPreset;
|
|
24714
24969
|
if (field.meta?.required !== true) {
|
|
24970
|
+
if (profile.sessionFormatVersion === 4)
|
|
24971
|
+
return null;
|
|
24715
24972
|
throw permissionError("protocolError", "DeepSeek Harness permission default is not required");
|
|
24716
24973
|
}
|
|
24717
24974
|
const choices = field.type === "union" ? field.list : field.type === "const" ? [field] : void 0;
|
|
24718
24975
|
if (!Array.isArray(choices) || choices.length === 0) {
|
|
24976
|
+
if (profile.sessionFormatVersion === 4)
|
|
24977
|
+
return null;
|
|
24719
24978
|
throw permissionError("protocolError", "DeepSeek Harness permission schema has no preset choices");
|
|
24720
24979
|
}
|
|
24721
24980
|
if (choices.length > HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH) {
|
|
@@ -24755,18 +25014,18 @@ function catalogFromNamespace(view) {
|
|
|
24755
25014
|
throw permissionError("protocolError", "DeepSeek Harness returned an unusable permission catalog");
|
|
24756
25015
|
}
|
|
24757
25016
|
}
|
|
24758
|
-
function parseModernPermissionModeCatalog(value) {
|
|
24759
|
-
const permission = parseDescribe(value);
|
|
24760
|
-
return permission ? catalogFromNamespace(permission) : null;
|
|
25017
|
+
function parseModernPermissionModeCatalog(value, profile = DEEPSEEK_V015_PROFILE) {
|
|
25018
|
+
const permission = parseDescribe(value, profile);
|
|
25019
|
+
return permission ? catalogFromNamespace(permission, profile) : null;
|
|
24761
25020
|
}
|
|
24762
|
-
async function loadModernPermissionModeCatalog(remote, signal) {
|
|
25021
|
+
async function loadModernPermissionModeCatalog(remote, signal, profile = DEEPSEEK_V015_PROFILE) {
|
|
24763
25022
|
try {
|
|
24764
25023
|
const result = await remote.call("settings/describe", {}, signal);
|
|
24765
25024
|
if (!result.ok) {
|
|
24766
25025
|
const safe = sanitizeModernRemoteFailure(result.error);
|
|
24767
25026
|
throw permissionError("remoteError", `DeepSeek Harness settings/describe failed: ${safe.message}`, safe.code);
|
|
24768
25027
|
}
|
|
24769
|
-
return parseModernPermissionModeCatalog(result.value);
|
|
25028
|
+
return parseModernPermissionModeCatalog(result.value, profile);
|
|
24770
25029
|
} catch (error51) {
|
|
24771
25030
|
if (error51 instanceof ModernPermissionModeError)
|
|
24772
25031
|
throw error51;
|
|
@@ -24822,8 +25081,10 @@ function parseProjectionValue(value, catalog) {
|
|
|
24822
25081
|
}
|
|
24823
25082
|
return current.data;
|
|
24824
25083
|
}
|
|
24825
|
-
function readModernPermissionModeState(row, catalog) {
|
|
25084
|
+
function readModernPermissionModeState(row, catalog, profile) {
|
|
24826
25085
|
if (!catalog) {
|
|
25086
|
+
if (profile?.sessionFormatVersion === 4)
|
|
25087
|
+
return void 0;
|
|
24827
25088
|
if (row) {
|
|
24828
25089
|
throw permissionError("protocolError", "DeepSeek Harness exposed permissions without a settings catalog");
|
|
24829
25090
|
}
|
|
@@ -24958,7 +25219,7 @@ function readModernConfigurationSnapshot(input) {
|
|
|
24958
25219
|
throw configurationError("protocolError", "DeepSeek Harness control state is detached");
|
|
24959
25220
|
}
|
|
24960
25221
|
const model = readModernModelSelectionState(rows[MODERN_MODEL_SELECTION_PROJECTION_KEY], input.modelCatalog);
|
|
24961
|
-
const permission = readModernPermissionModeState(rows[MODERN_PERMISSION_PROJECTION_KEY], input.permissionModes);
|
|
25222
|
+
const permission = readModernPermissionModeState(rows[MODERN_PERMISSION_PROJECTION_KEY], input.permissionModes, input.profile);
|
|
24962
25223
|
return {
|
|
24963
25224
|
model,
|
|
24964
25225
|
state: stateForSelection(input.nativeRef, model.selection, input.modelCatalog, permission?.permissionModeId),
|
|
@@ -25933,10 +26194,14 @@ function parseQuestionOption(value) {
|
|
|
25933
26194
|
};
|
|
25934
26195
|
}
|
|
25935
26196
|
function parseQuestionIntent(value) {
|
|
25936
|
-
if (!isPlainRecord6(value) || !
|
|
26197
|
+
if (!isPlainRecord6(value) || !hasOnlyKeys(value, ["kind", "approve"], ["callId"]) || value.kind !== "plan-review" || !nonBlankString3(value.approve) || Object.hasOwn(value, "callId") && !nonBlankString3(value.callId)) {
|
|
25937
26198
|
throw invalidFrame();
|
|
25938
26199
|
}
|
|
25939
|
-
return {
|
|
26200
|
+
return {
|
|
26201
|
+
kind: "plan-review",
|
|
26202
|
+
approve: value.approve,
|
|
26203
|
+
...typeof value.callId === "string" ? { callId: value.callId } : {}
|
|
26204
|
+
};
|
|
25940
26205
|
}
|
|
25941
26206
|
function parseQuestionAnswer(value) {
|
|
25942
26207
|
if (!isPlainRecord6(value) || !hasExactKeys5(value, ["answers"]) || !Array.isArray(value.answers)) {
|
|
@@ -26720,6 +26985,13 @@ var KNOWN_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
26720
26985
|
"user/message",
|
|
26721
26986
|
"web/deepseek-search-llm-request"
|
|
26722
26987
|
]);
|
|
26988
|
+
var V4_EVENT_TYPES = /* @__PURE__ */ new Set(["developer/message", "image/offload", "workspace/changes"]);
|
|
26989
|
+
function knownEvent(type, profile) {
|
|
26990
|
+
return KNOWN_EVENT_TYPES.has(type) || profile.sessionFormatVersion === 4 && V4_EVENT_TYPES.has(type);
|
|
26991
|
+
}
|
|
26992
|
+
function surfaceEvent(type, profile) {
|
|
26993
|
+
return SURFACE_EVENT_TYPES.has(type) || profile.sessionFormatVersion === 4 && type === "developer/message";
|
|
26994
|
+
}
|
|
26723
26995
|
var SURFACE_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
26724
26996
|
"system/message",
|
|
26725
26997
|
"user/message",
|
|
@@ -26738,7 +27010,10 @@ var ModernEventValidator = class {
|
|
|
26738
27010
|
surface: [],
|
|
26739
27011
|
pendingCalls: /* @__PURE__ */ new Set(),
|
|
26740
27012
|
commandStates: /* @__PURE__ */ new Map(),
|
|
26741
|
-
commandEventSeqs: /* @__PURE__ */ new Set()
|
|
27013
|
+
commandEventSeqs: /* @__PURE__ */ new Set(),
|
|
27014
|
+
requestHeaders: /* @__PURE__ */ new Map(),
|
|
27015
|
+
offloadedImages: /* @__PURE__ */ new Set(),
|
|
27016
|
+
toolCalls: /* @__PURE__ */ new Map()
|
|
26742
27017
|
};
|
|
26743
27018
|
constructor(maxEvents = MODERN_HISTORY_MAX_EVENTS, profile = DEEPSEEK_V012_PROFILE) {
|
|
26744
27019
|
this.#maxEvents = boundedInteger(maxEvents, "maxEvents", 1);
|
|
@@ -26751,16 +27026,16 @@ var ModernEventValidator = class {
|
|
|
26751
27026
|
if (event.seq !== trace.count)
|
|
26752
27027
|
fail("Modern history is not a contiguous zero-based prefix");
|
|
26753
27028
|
trace.count += 1;
|
|
26754
|
-
if (
|
|
27029
|
+
if (hasDeepSeekModernStream(this.#profile) && !knownEvent(event.type, this.#profile) && event.ignorable === true)
|
|
26755
27030
|
return;
|
|
26756
|
-
if (!
|
|
27031
|
+
if (!surfaceEvent(event.type, this.#profile)) {
|
|
26757
27032
|
if (event.surfaceOp !== void 0 || event.sourceEventSeqs !== void 0) {
|
|
26758
27033
|
fail("Modern history has surface metadata on a log-only event");
|
|
26759
27034
|
}
|
|
26760
27035
|
} else if (event.surfaceOp === void 0) {
|
|
26761
27036
|
fail("Modern history surface event omitted surfaceOp");
|
|
26762
27037
|
}
|
|
26763
|
-
if (!
|
|
27038
|
+
if (!knownEvent(event.type, this.#profile)) {
|
|
26764
27039
|
if (event.ignorable === true)
|
|
26765
27040
|
return;
|
|
26766
27041
|
fail("Modern history contains an unknown required event");
|
|
@@ -26784,10 +27059,13 @@ var ModernEventValidator = class {
|
|
|
26784
27059
|
case "turn/end": {
|
|
26785
27060
|
exactKeys2(data, ["turn", "reason"]);
|
|
26786
27061
|
const turn = positiveInteger(data.turn, "turn/end turn");
|
|
26787
|
-
validateTurnReason(data.reason);
|
|
27062
|
+
validateTurnReason(data.reason, this.#profile);
|
|
26788
27063
|
if (trace.openTurn !== turn || trace.openStep !== null) {
|
|
26789
27064
|
fail("Modern history has an invalid turn/end boundary");
|
|
26790
27065
|
}
|
|
27066
|
+
if (this.#profile.sessionFormatVersion === 4 && trace.toolCalls.size > 0) {
|
|
27067
|
+
fail("Modern history turn/end leaves unresolved tool calls");
|
|
27068
|
+
}
|
|
26791
27069
|
trace.openTurn = null;
|
|
26792
27070
|
trace.nextTurn += 1;
|
|
26793
27071
|
return;
|
|
@@ -26804,6 +27082,9 @@ var ModernEventValidator = class {
|
|
|
26804
27082
|
case "step/end": {
|
|
26805
27083
|
exactKeys2(data, ["turn", "step"]);
|
|
26806
27084
|
requireOpenStep(trace, data, "step/end");
|
|
27085
|
+
if (this.#profile.sessionFormatVersion === 4 && trace.toolCalls.size > 0) {
|
|
27086
|
+
fail("Modern history step/end leaves unresolved tool calls");
|
|
27087
|
+
}
|
|
26807
27088
|
trace.openStep = null;
|
|
26808
27089
|
trace.nextStep += 1;
|
|
26809
27090
|
trace.pendingCalls.clear();
|
|
@@ -26812,6 +27093,10 @@ var ModernEventValidator = class {
|
|
|
26812
27093
|
case "user/message":
|
|
26813
27094
|
validateUserMessage(data, this.#profile);
|
|
26814
27095
|
return;
|
|
27096
|
+
case "developer/message":
|
|
27097
|
+
requireOpenStep(trace, data, "developer/message");
|
|
27098
|
+
validateDeveloperHeader(event, trace);
|
|
27099
|
+
return;
|
|
26815
27100
|
case "system/message":
|
|
26816
27101
|
requireOpenStep(trace, data, "system/message");
|
|
26817
27102
|
return;
|
|
@@ -26823,6 +27108,8 @@ var ModernEventValidator = class {
|
|
|
26823
27108
|
case "assistant/message": {
|
|
26824
27109
|
requireOpenStep(trace, data, "assistant/message");
|
|
26825
27110
|
validateAssistantMessage(data.message, this.#profile);
|
|
27111
|
+
if (this.#profile.sessionFormatVersion === 4)
|
|
27112
|
+
registerV4ToolCalls(data.message, trace);
|
|
26826
27113
|
if (data.interrupted !== void 0 && data.interrupted !== true) {
|
|
26827
27114
|
fail("Modern history assistant/message has invalid interrupted marker");
|
|
26828
27115
|
}
|
|
@@ -26836,10 +27123,18 @@ var ModernEventValidator = class {
|
|
|
26836
27123
|
exactKeys2(data, ["turn", "step", "callId", "name", "arguments"]);
|
|
26837
27124
|
requireOpenStep(trace, data, "tool/call");
|
|
26838
27125
|
const callId = requiredString(data.callId, "tool/call callId");
|
|
26839
|
-
requiredString(data.name, "tool/call name");
|
|
27126
|
+
const name = requiredString(data.name, "tool/call name");
|
|
26840
27127
|
if (typeof data.arguments !== "string" || trace.pendingCalls.has(callId)) {
|
|
26841
27128
|
fail("Modern history contains an invalid tool/call");
|
|
26842
27129
|
}
|
|
27130
|
+
if (this.#profile.sessionFormatVersion === 4) {
|
|
27131
|
+
const tool = trace.toolCalls.get(callId);
|
|
27132
|
+
if (!tool || tool.started || tool.name !== name || tool.arguments !== data.arguments) {
|
|
27133
|
+
fail("Modern history tool/call does not match its advertised tool call");
|
|
27134
|
+
}
|
|
27135
|
+
tool.started = true;
|
|
27136
|
+
return;
|
|
27137
|
+
}
|
|
26843
27138
|
trace.pendingCalls.add(callId);
|
|
26844
27139
|
return;
|
|
26845
27140
|
}
|
|
@@ -26847,10 +27142,16 @@ var ModernEventValidator = class {
|
|
|
26847
27142
|
requiredOptionalKeys(data, ["turn", "step", "message"], ["error", "meta"]);
|
|
26848
27143
|
const callId = validateToolResultMessage(data.message, this.#profile);
|
|
26849
27144
|
if (data.error !== void 0)
|
|
26850
|
-
validateToolError(data.error);
|
|
27145
|
+
validateToolError(data.error, this.#profile);
|
|
26851
27146
|
if (event.surfaceOp === "append") {
|
|
26852
27147
|
requireOpenStep(trace, data, "tool/result");
|
|
26853
|
-
if (
|
|
27148
|
+
if (this.#profile.sessionFormatVersion === 4) {
|
|
27149
|
+
const tool = trace.toolCalls.get(callId);
|
|
27150
|
+
if (!tool || !tool.started && !isV4ForkToolResult(data, event.sourceEventSeqs, event.seq)) {
|
|
27151
|
+
fail("Modern history contains an unmatched tool/result");
|
|
27152
|
+
}
|
|
27153
|
+
trace.toolCalls.delete(callId);
|
|
27154
|
+
} else if (!trace.pendingCalls.delete(callId)) {
|
|
26854
27155
|
fail("Modern history contains an unmatched tool/result");
|
|
26855
27156
|
}
|
|
26856
27157
|
} else if (trace.openTurn === null) {
|
|
@@ -26862,6 +27163,7 @@ var ModernEventValidator = class {
|
|
|
26862
27163
|
validateRequestHeader(data);
|
|
26863
27164
|
if (trace.openTurn === null)
|
|
26864
27165
|
fail("Modern history request/header is outside a Turn");
|
|
27166
|
+
trace.requestHeaders.set(event.seq, data.header);
|
|
26865
27167
|
return;
|
|
26866
27168
|
case "request/context":
|
|
26867
27169
|
validateRequestContext(data, this.#profile);
|
|
@@ -26873,6 +27175,11 @@ var ModernEventValidator = class {
|
|
|
26873
27175
|
return;
|
|
26874
27176
|
case "session/end-seed":
|
|
26875
27177
|
return;
|
|
27178
|
+
case "image/offload":
|
|
27179
|
+
validateImageOffload(data, trace);
|
|
27180
|
+
return;
|
|
27181
|
+
case "workspace/changes":
|
|
27182
|
+
return;
|
|
26876
27183
|
case "agent-preset/selected":
|
|
26877
27184
|
exactKeys2(data, ["agentPreset"]);
|
|
26878
27185
|
requiredString(data.agentPreset, "agent-preset/selected agentPreset");
|
|
@@ -27002,20 +27309,113 @@ var ModernEventValidator = class {
|
|
|
27002
27309
|
}
|
|
27003
27310
|
}
|
|
27004
27311
|
};
|
|
27312
|
+
function registerV4ToolCalls(value, trace) {
|
|
27313
|
+
if (!isRecord4(value) || !Array.isArray(value.content))
|
|
27314
|
+
return;
|
|
27315
|
+
for (const block of value.content) {
|
|
27316
|
+
if (!isRecord4(block) || block.type !== "tool-call")
|
|
27317
|
+
continue;
|
|
27318
|
+
const callId = requiredString(block.id, "assistant tool-call id");
|
|
27319
|
+
const name = requiredString(block.name, "assistant tool-call name");
|
|
27320
|
+
if (typeof block.arguments !== "string" || trace.toolCalls.has(callId)) {
|
|
27321
|
+
fail("Modern history assistant/message repeats an advertised tool call");
|
|
27322
|
+
}
|
|
27323
|
+
trace.toolCalls.set(callId, { name, arguments: block.arguments, started: false });
|
|
27324
|
+
}
|
|
27325
|
+
}
|
|
27326
|
+
function isV4ForkToolResult(data, sourceEventSeqs, seq) {
|
|
27327
|
+
if (!isRecord4(data.error) || data.error.name !== "ToolNotStartedError" || data.error.code !== "TOOL_NOT_STARTED" || !isRecord4(data.message) || data.message.role !== "tool" || data.message.isError !== true || !isRecord4(data.message.source) || data.message.source.kind !== "tool" || typeof data.message.source.callId !== "string" || data.message.toolCallId !== data.message.source.callId || typeof data.message.id !== "string" || data.message.id !== `forked-tool-result-${data.message.source.callId}-${seq}` || sourceEventSeqs !== void 0 || !Array.isArray(data.message.content) || data.message.content.length !== 1) {
|
|
27328
|
+
return false;
|
|
27329
|
+
}
|
|
27330
|
+
const content = data.message.content[0];
|
|
27331
|
+
return isRecord4(content) && content.type === "text" && typeof content.text === "string" && data.message.id.endsWith(`-${seq}`);
|
|
27332
|
+
}
|
|
27333
|
+
function validateDeveloperHeader(event, trace) {
|
|
27334
|
+
const data = event.data;
|
|
27335
|
+
if (data.headerSeq === void 0)
|
|
27336
|
+
return;
|
|
27337
|
+
const header = trace.requestHeaders.get(data.headerSeq);
|
|
27338
|
+
if (!header || !Array.isArray(header.tools)) {
|
|
27339
|
+
fail("Modern history developer/message references an invalid request/header");
|
|
27340
|
+
}
|
|
27341
|
+
const message = data.message;
|
|
27342
|
+
for (const block of message.content) {
|
|
27343
|
+
if (!isRecord4(block) || block.type !== "tool-addition")
|
|
27344
|
+
continue;
|
|
27345
|
+
const matching = header.tools.filter((tool) => isRecord4(tool) && tool.name === block.toolName);
|
|
27346
|
+
if (matching.length !== 1 || !isRecord4(matching[0]) || typeof matching[0].description !== "string" || !isRecord4(matching[0].parameters) || matching[0].deferLoading !== void 0 && matching[0].deferLoading !== true) {
|
|
27347
|
+
fail("Modern history developer/message references an invalid tool definition");
|
|
27348
|
+
}
|
|
27349
|
+
}
|
|
27350
|
+
}
|
|
27351
|
+
function strictIndex(value, label) {
|
|
27352
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0 || Object.is(value, -0)) {
|
|
27353
|
+
fail(`Modern history ${label} is malformed`);
|
|
27354
|
+
}
|
|
27355
|
+
return value;
|
|
27356
|
+
}
|
|
27357
|
+
function validateImageOffload(data, trace) {
|
|
27358
|
+
const seen = /* @__PURE__ */ new Set();
|
|
27359
|
+
for (const target of data.targets) {
|
|
27360
|
+
if (!isRecord4(target))
|
|
27361
|
+
fail("Modern history image/offload target is malformed");
|
|
27362
|
+
exactKeys2(target, ["seq", "imageIndexes"]);
|
|
27363
|
+
const seq = strictIndex(target.seq, "image/offload target seq");
|
|
27364
|
+
if (seen.has(seq))
|
|
27365
|
+
fail("Modern history image/offload repeats a target");
|
|
27366
|
+
seen.add(seq);
|
|
27367
|
+
const source = trace.surface.find((event) => event.seq === seq);
|
|
27368
|
+
if (!source || source.type !== "user/message" && source.type !== "tool/result") {
|
|
27369
|
+
fail("Modern history image/offload target is not a current message");
|
|
27370
|
+
}
|
|
27371
|
+
const sourceData = source.type === "user/message" ? source.data : source.data.message;
|
|
27372
|
+
const content = isRecord4(sourceData) ? sourceData.content : void 0;
|
|
27373
|
+
if (!Array.isArray(content) || !Array.isArray(target.imageIndexes) || !target.imageIndexes.length) {
|
|
27374
|
+
fail("Modern history image/offload indexes are malformed");
|
|
27375
|
+
}
|
|
27376
|
+
const images = [];
|
|
27377
|
+
const collectImages = (value) => {
|
|
27378
|
+
if (!Array.isArray(value))
|
|
27379
|
+
return;
|
|
27380
|
+
for (const block of value) {
|
|
27381
|
+
if (!isRecord4(block))
|
|
27382
|
+
continue;
|
|
27383
|
+
if (block.type === "image")
|
|
27384
|
+
images.push(block);
|
|
27385
|
+
if (Array.isArray(block.content))
|
|
27386
|
+
collectImages(block.content);
|
|
27387
|
+
}
|
|
27388
|
+
};
|
|
27389
|
+
collectImages(content);
|
|
27390
|
+
let previous = -1;
|
|
27391
|
+
for (const value of target.imageIndexes) {
|
|
27392
|
+
const index = strictIndex(value, "image/offload index");
|
|
27393
|
+
const image = images[index];
|
|
27394
|
+
if (index <= previous || !isRecord4(image) || image.offloaded === true || trace.offloadedImages.has(`${seq}:${index}`)) {
|
|
27395
|
+
fail("Modern history image/offload references an invalid image occurrence");
|
|
27396
|
+
}
|
|
27397
|
+
trace.offloadedImages.add(`${seq}:${index}`);
|
|
27398
|
+
previous = index;
|
|
27399
|
+
}
|
|
27400
|
+
}
|
|
27401
|
+
}
|
|
27005
27402
|
function acceptSurfaceEvent(trace, event, profile) {
|
|
27006
|
-
if (!
|
|
27403
|
+
if (!surfaceEvent(event.type, profile))
|
|
27007
27404
|
return;
|
|
27008
27405
|
const sources = event.sourceEventSeqs;
|
|
27009
|
-
if (sources !== void 0 && (!Array.isArray(sources) || sources.some((seq) => !nonNegativeSafeInteger2(seq) || Object.is(seq, -0) || seq >= event.seq) || new Set(sources).size !== sources.length || sources.length === 0 && event.type !== "assistant/message")) {
|
|
27406
|
+
if (sources !== void 0 && (!Array.isArray(sources) || sources.some((seq) => !nonNegativeSafeInteger2(seq) || Object.is(seq, -0) || seq >= event.seq) || new Set(sources).size !== sources.length || sources.length === 0 && (profile.sessionFormatVersion === 4 || event.type !== "assistant/message"))) {
|
|
27010
27407
|
fail("Modern history surface event has invalid sourceEventSeqs");
|
|
27011
27408
|
}
|
|
27012
27409
|
const op = event.surfaceOp;
|
|
27013
27410
|
if (op === "append") {
|
|
27411
|
+
if (profile.sessionFormatVersion === 4 && event.type === "system/message" && trace.surface.length > 0 && !trace.surface.some((surface) => surface.type === "system/message")) {
|
|
27412
|
+
fail("Modern history system/message must remain the protected surface head");
|
|
27413
|
+
}
|
|
27014
27414
|
trace.surface.push(event);
|
|
27015
27415
|
return;
|
|
27016
27416
|
}
|
|
27017
|
-
const start =
|
|
27018
|
-
const end =
|
|
27417
|
+
const start = hasDeepSeekModernStream(profile) ? "startSeq" : "start";
|
|
27418
|
+
const end = hasDeepSeekModernStream(profile) ? "endSeq" : "end";
|
|
27019
27419
|
if (!isRecord4(op) || Reflect.ownKeys(op).length !== 3 || !Object.hasOwn(op, "op") || !Object.hasOwn(op, start) || !Object.hasOwn(op, end) || op.op !== "replace" || !nonNegativeSafeInteger2(op[start]) || Object.is(op[start], -0) || !nonNegativeSafeInteger2(op[end]) || Object.is(op[end], -0)) {
|
|
27020
27420
|
fail("Modern history surface event has an invalid replacement operation");
|
|
27021
27421
|
}
|
|
@@ -27033,17 +27433,20 @@ function acceptSurfaceEvent(trace, event, profile) {
|
|
|
27033
27433
|
fail("Modern history system head may only be replaced by one system/message");
|
|
27034
27434
|
}
|
|
27035
27435
|
if (event.type === "tool/result") {
|
|
27036
|
-
if (shadowed.length !== 1 || shadowed[0]?.type !== "tool/result" || !isDeepStrictEqual6(comparableToolResultData(shadowed[0]), comparableToolResultData(event))) {
|
|
27436
|
+
if (shadowed.length !== 1 || shadowed[0]?.type !== "tool/result" || !isDeepStrictEqual6(comparableToolResultData(shadowed[0], profile), comparableToolResultData(event, profile))) {
|
|
27037
27437
|
fail("Modern history tool/result replacement changed more than result content");
|
|
27038
27438
|
}
|
|
27039
27439
|
}
|
|
27040
27440
|
trace.surface.splice(startIndex, endIndex - startIndex + 1, event);
|
|
27041
27441
|
}
|
|
27042
|
-
function comparableToolResultData(event) {
|
|
27442
|
+
function comparableToolResultData(event, profile) {
|
|
27043
27443
|
const data = event.data;
|
|
27044
|
-
if (!isRecord4(data) || !isRecord4(data.message) || !Array.isArray(data.message.content) || !isRecord4(data.message.content[0])) {
|
|
27444
|
+
if (!isRecord4(data) || !isRecord4(data.message) || !Array.isArray(data.message.content) || profile.sessionFormatVersion !== 4 && !isRecord4(data.message.content[0])) {
|
|
27045
27445
|
fail("Modern history tool/result replacement is malformed");
|
|
27046
27446
|
}
|
|
27447
|
+
if (profile.sessionFormatVersion === 4) {
|
|
27448
|
+
return { ...data, message: { ...data.message, content: null } };
|
|
27449
|
+
}
|
|
27047
27450
|
return {
|
|
27048
27451
|
...data,
|
|
27049
27452
|
message: {
|
|
@@ -27066,6 +27469,8 @@ function resolveModernForkBoundary(events, checkpointId, profile = DEEPSEEK_V012
|
|
|
27066
27469
|
if (atSeq === null || events[atSeq]?.seq !== atSeq || events[atSeq]?.type !== "turn/end") {
|
|
27067
27470
|
return null;
|
|
27068
27471
|
}
|
|
27472
|
+
if (profile.sessionFormatVersion === 4)
|
|
27473
|
+
return { atSeq, events: events.slice(0, atSeq + 1) };
|
|
27069
27474
|
let cut = atSeq + 1;
|
|
27070
27475
|
while (cut < events.length && events[cut]?.type !== "turn/start")
|
|
27071
27476
|
cut += 1;
|
|
@@ -27114,7 +27519,7 @@ function projectModernHistory(input) {
|
|
|
27114
27519
|
};
|
|
27115
27520
|
for (const [index, event] of input.events.entries()) {
|
|
27116
27521
|
validator.accept(event);
|
|
27117
|
-
if (!
|
|
27522
|
+
if (!knownEvent(event.type, profile) || !isRecord4(event.data))
|
|
27118
27523
|
continue;
|
|
27119
27524
|
const data = event.data;
|
|
27120
27525
|
switch (event.type) {
|
|
@@ -27125,6 +27530,7 @@ function projectModernHistory(input) {
|
|
|
27125
27530
|
input: [],
|
|
27126
27531
|
items: [],
|
|
27127
27532
|
tools: /* @__PURE__ */ new Map(),
|
|
27533
|
+
advertisedTools: /* @__PURE__ */ new Map(),
|
|
27128
27534
|
model: effectiveModel
|
|
27129
27535
|
};
|
|
27130
27536
|
break;
|
|
@@ -27203,7 +27609,7 @@ function projectModernHistory(input) {
|
|
|
27203
27609
|
harnessId,
|
|
27204
27610
|
nativeSessionId: input.sessionId,
|
|
27205
27611
|
formatVersion: 1,
|
|
27206
|
-
...
|
|
27612
|
+
...hasDeepSeekModernStream(profile) ? { locator: { dshVersion: profile.version } } : {}
|
|
27207
27613
|
});
|
|
27208
27614
|
const state = {
|
|
27209
27615
|
nativeRef,
|
|
@@ -27235,7 +27641,7 @@ function modernCheckpointRef(harnessId, sessionId, seq, profile = DEEPSEEK_V012_
|
|
|
27235
27641
|
nativeSessionId: sessionId,
|
|
27236
27642
|
checkpointId: `${profile.checkpointPrefix}${seq}`,
|
|
27237
27643
|
formatVersion: 1,
|
|
27238
|
-
...
|
|
27644
|
+
...hasDeepSeekModernStream(profile) ? { locator: { dshVersion: profile.version } } : {}
|
|
27239
27645
|
});
|
|
27240
27646
|
}
|
|
27241
27647
|
function modernItemId(sessionId, key) {
|
|
@@ -27243,6 +27649,13 @@ function modernItemId(sessionId, key) {
|
|
|
27243
27649
|
}
|
|
27244
27650
|
function projectAssistantMessage(turn, sessionId, data) {
|
|
27245
27651
|
const message = data.message;
|
|
27652
|
+
if (Array.isArray(message.content)) {
|
|
27653
|
+
for (const block of message.content) {
|
|
27654
|
+
if (isRecord4(block) && block.type === "tool-call" && typeof block.id === "string" && typeof block.name === "string" && typeof block.arguments === "string") {
|
|
27655
|
+
turn.advertisedTools.set(block.id, { toolName: block.name, arguments: block.arguments });
|
|
27656
|
+
}
|
|
27657
|
+
}
|
|
27658
|
+
}
|
|
27246
27659
|
const reasoning2 = contentByType(message.content, "reasoning");
|
|
27247
27660
|
if (reasoning2) {
|
|
27248
27661
|
const item = {
|
|
@@ -27275,15 +27688,32 @@ function projectToolCall(turn, sessionId, data, seq) {
|
|
|
27275
27688
|
const itemIndex = turn.items.length;
|
|
27276
27689
|
turn.items.push({ item, outcome: incompleteToolOutcome(item.toolName) });
|
|
27277
27690
|
turn.tools.set(data.callId, { itemIndex, item, toolName: item.toolName });
|
|
27691
|
+
turn.advertisedTools.delete(data.callId);
|
|
27278
27692
|
}
|
|
27279
27693
|
function projectToolResultEvent(turn, sessionId, data, seq, limit) {
|
|
27280
27694
|
const result = projectToolResult(data.message, limit);
|
|
27281
27695
|
if (!result)
|
|
27282
27696
|
fail("Modern history contains an unprojectable tool/result");
|
|
27283
|
-
|
|
27284
|
-
if (!tool)
|
|
27697
|
+
let tool = turn.tools.get(result.callId);
|
|
27698
|
+
if (!tool) {
|
|
27699
|
+
const advertised = turn.advertisedTools.get(result.callId);
|
|
27700
|
+
if (advertised && isForkedToolResult(data, result.callId, seq)) {
|
|
27701
|
+
const item2 = {
|
|
27702
|
+
type: "toolExecution",
|
|
27703
|
+
itemId: modernItemId(sessionId, `event:${seq}:tool`),
|
|
27704
|
+
toolName: advertised.toolName,
|
|
27705
|
+
arguments: parseArguments(advertised.arguments)
|
|
27706
|
+
};
|
|
27707
|
+
const itemIndex = turn.items.length;
|
|
27708
|
+
turn.items.push({ item: item2, outcome: incompleteToolOutcome(item2.toolName) });
|
|
27709
|
+
tool = { itemIndex, item: item2, toolName: item2.toolName };
|
|
27710
|
+
}
|
|
27711
|
+
}
|
|
27712
|
+
if (!tool) {
|
|
27285
27713
|
fail("Modern history contains an unmatched projected tool/result");
|
|
27714
|
+
}
|
|
27286
27715
|
turn.tools.delete(result.callId);
|
|
27716
|
+
turn.advertisedTools.delete(result.callId);
|
|
27287
27717
|
const item = { ...tool.item, ...result.output ? { output: result.output } : {} };
|
|
27288
27718
|
turn.items[tool.itemIndex] = {
|
|
27289
27719
|
item,
|
|
@@ -27309,6 +27739,10 @@ function projectToolResultEvent(turn, sessionId, data, seq, limit) {
|
|
|
27309
27739
|
}
|
|
27310
27740
|
}
|
|
27311
27741
|
}
|
|
27742
|
+
function isForkedToolResult(data, callId, seq) {
|
|
27743
|
+
const message = data.message;
|
|
27744
|
+
return isRecord4(data.error) && data.error.name === "ToolNotStartedError" && data.error.code === "TOOL_NOT_STARTED" && isRecord4(message) && message.role === "tool" && message.isError === true && message.toolCallId === callId && typeof message.id === "string" && message.id === `forked-tool-result-${callId}-${seq}`;
|
|
27745
|
+
}
|
|
27312
27746
|
function finishIncompleteTools(turn, outcome) {
|
|
27313
27747
|
for (const tool of turn.tools.values())
|
|
27314
27748
|
turn.items[tool.itemIndex] = { item: tool.item, outcome };
|
|
@@ -27379,12 +27813,15 @@ function stepPosition(data, label) {
|
|
|
27379
27813
|
};
|
|
27380
27814
|
}
|
|
27381
27815
|
function validateUserMessage(data, profile = DEEPSEEK_V012_PROFILE) {
|
|
27382
|
-
|
|
27816
|
+
if (profile.sessionFormatVersion === 4)
|
|
27817
|
+
requiredFields2(data, ["id", "role", "content", "source"]);
|
|
27818
|
+
else
|
|
27819
|
+
exactKeys2(data, ["id", "role", "content", "source"]);
|
|
27383
27820
|
requiredString(data.id, "user/message id");
|
|
27384
27821
|
if (data.role !== "user")
|
|
27385
27822
|
fail("Modern history user/message has an invalid role");
|
|
27386
27823
|
profile.validateContent(data.content);
|
|
27387
|
-
if (!isRecord4(data.source) || !requiredString(data.source.kind, "user/message source kind")) {
|
|
27824
|
+
if (!isRecord4(data.source) || !requiredString(data.source.kind, "user/message source kind") || profile.sessionFormatVersion === 4 && data.source.kind === "plugin") {
|
|
27388
27825
|
fail("Modern history user/message has an invalid source");
|
|
27389
27826
|
}
|
|
27390
27827
|
if (data.source.kind === "user" && data.source.rpcId !== void 0) {
|
|
@@ -27394,7 +27831,10 @@ function validateUserMessage(data, profile = DEEPSEEK_V012_PROFILE) {
|
|
|
27394
27831
|
function validateAssistantMessage(value, profile = DEEPSEEK_V012_PROFILE) {
|
|
27395
27832
|
if (!isRecord4(value))
|
|
27396
27833
|
fail("Modern history assistant/message is malformed");
|
|
27397
|
-
|
|
27834
|
+
if (profile.sessionFormatVersion === 4)
|
|
27835
|
+
requiredFields2(value, ["id", "role", "content", "source"]);
|
|
27836
|
+
else
|
|
27837
|
+
exactKeys2(value, ["id", "role", "content", "source"]);
|
|
27398
27838
|
requiredString(value.id, "assistant/message id");
|
|
27399
27839
|
if (value.role !== "assistant")
|
|
27400
27840
|
fail("Modern history assistant/message has an invalid role");
|
|
@@ -27406,6 +27846,19 @@ function validateAssistantMessage(value, profile = DEEPSEEK_V012_PROFILE) {
|
|
|
27406
27846
|
function validateToolResultMessage(value, profile = DEEPSEEK_V012_PROFILE) {
|
|
27407
27847
|
if (!isRecord4(value))
|
|
27408
27848
|
fail("Modern history tool/result message is malformed");
|
|
27849
|
+
if (profile.sessionFormatVersion === 4) {
|
|
27850
|
+
requiredFields2(value, ["id", "role", "content", "source", "toolCallId"]);
|
|
27851
|
+
requiredString(value.id, "tool/result message id");
|
|
27852
|
+
if (value.role !== "tool" || !isRecord4(value.source) || value.source.kind !== "tool") {
|
|
27853
|
+
fail("Modern history tool/result message has an invalid role or source");
|
|
27854
|
+
}
|
|
27855
|
+
const callId2 = requiredString(value.source.callId, "tool/result source callId");
|
|
27856
|
+
if (value.toolCallId !== callId2 || value.isError !== void 0 && typeof value.isError !== "boolean") {
|
|
27857
|
+
fail("Modern history tool/result message has invalid callId or isError");
|
|
27858
|
+
}
|
|
27859
|
+
profile.validateContent(value.content);
|
|
27860
|
+
return callId2;
|
|
27861
|
+
}
|
|
27409
27862
|
exactKeys2(value, ["id", "role", "content", "source"]);
|
|
27410
27863
|
requiredString(value.id, "tool/result message id");
|
|
27411
27864
|
if (value.role !== "user" || !isRecord4(value.source) || value.source.kind !== "tool") {
|
|
@@ -27426,6 +27879,11 @@ function validateToolResultMessage(value, profile = DEEPSEEK_V012_PROFILE) {
|
|
|
27426
27879
|
}
|
|
27427
27880
|
return callId;
|
|
27428
27881
|
}
|
|
27882
|
+
function requiredFields2(value, fields) {
|
|
27883
|
+
if (fields.some((field) => !Object.hasOwn(value, field))) {
|
|
27884
|
+
fail("Modern history known event omitted a required field");
|
|
27885
|
+
}
|
|
27886
|
+
}
|
|
27429
27887
|
function validateUsage(value) {
|
|
27430
27888
|
if (!validUsage(value))
|
|
27431
27889
|
fail("Modern history usage is malformed");
|
|
@@ -27449,7 +27907,7 @@ function validUsage(value) {
|
|
|
27449
27907
|
}
|
|
27450
27908
|
return fields.slice(2).every((field) => value[field] === void 0 || nonNegativeSafeInteger2(value[field]));
|
|
27451
27909
|
}
|
|
27452
|
-
function validateTurnReason(value) {
|
|
27910
|
+
function validateTurnReason(value, profile) {
|
|
27453
27911
|
if (!isRecord4(value) || typeof value.kind !== "string") {
|
|
27454
27912
|
fail("Modern history turn/end reason is malformed");
|
|
27455
27913
|
}
|
|
@@ -27460,6 +27918,11 @@ function validateTurnReason(value) {
|
|
|
27460
27918
|
case "interrupted":
|
|
27461
27919
|
exactKeys2(value, ["kind"]);
|
|
27462
27920
|
return;
|
|
27921
|
+
case "forked":
|
|
27922
|
+
if (profile.sessionFormatVersion !== 4)
|
|
27923
|
+
fail("Modern history contains an unknown Turn outcome");
|
|
27924
|
+
exactKeys2(value, ["kind"]);
|
|
27925
|
+
return;
|
|
27463
27926
|
case "aborted":
|
|
27464
27927
|
exactKeys2(value, ["kind", "reason"]);
|
|
27465
27928
|
if (!isRecord4(value.reason) || typeof value.reason.kind !== "string") {
|
|
@@ -27514,7 +27977,7 @@ function validateRequestHeader(data) {
|
|
|
27514
27977
|
}
|
|
27515
27978
|
}
|
|
27516
27979
|
function validateRequestContext(data, profile) {
|
|
27517
|
-
requiredOptionalKeys(data, ["provider", "model"],
|
|
27980
|
+
requiredOptionalKeys(data, ["provider", "model"], hasDeepSeekModernStream(profile) ? ["contextWindow", "systemPromptUpdate"] : ["contextWindow"]);
|
|
27518
27981
|
if (!nonBlankString(data.provider) || !nonBlankString(data.model)) {
|
|
27519
27982
|
fail("Modern history request/context has an invalid Model route");
|
|
27520
27983
|
}
|
|
@@ -27532,12 +27995,15 @@ function validateModelSelection(data) {
|
|
|
27532
27995
|
fail("Modern history model/selection has invalid reasoningEffort");
|
|
27533
27996
|
}
|
|
27534
27997
|
}
|
|
27535
|
-
function validateToolError(value) {
|
|
27998
|
+
function validateToolError(value, profile) {
|
|
27536
27999
|
if (!isRecord4(value))
|
|
27537
28000
|
fail("Modern history tool/result error is malformed");
|
|
27538
|
-
|
|
28001
|
+
requiredOptionalKeys(value, ["name", "code"], profile.sessionFormatVersion === 4 ? ["reason"] : []);
|
|
27539
28002
|
requiredString(value.name, "tool/result error name");
|
|
27540
28003
|
requiredString(value.code, "tool/result error code");
|
|
28004
|
+
if (value.reason !== void 0 && typeof value.reason !== "string") {
|
|
28005
|
+
fail("Modern history tool/result error reason is malformed");
|
|
28006
|
+
}
|
|
27541
28007
|
}
|
|
27542
28008
|
function validateInboxSplice(data, profile) {
|
|
27543
28009
|
requiredOptionalKeys(data, ["target", "start", "inserted"], ["removedCount", "outcome"]);
|
|
@@ -27647,7 +28113,7 @@ function validateRetry(data) {
|
|
|
27647
28113
|
requiredString(data.provider, "llm/retry provider");
|
|
27648
28114
|
requiredString(data.policyKey, "llm/retry policyKey");
|
|
27649
28115
|
positiveInteger(data.retry, "llm/retry retry");
|
|
27650
|
-
|
|
28116
|
+
nonNegativeFiniteNumber(data.delayMs, "llm/retry delayMs");
|
|
27651
28117
|
if (mode === "normal")
|
|
27652
28118
|
positiveInteger(data.maxRetries, "llm/retry maxRetries");
|
|
27653
28119
|
validateLlmFailure(data.failure, "llm/retry failure");
|
|
@@ -27861,7 +28327,7 @@ function validateSubagentModelPolicy(data) {
|
|
|
27861
28327
|
validateModelRoute(route, "subagent Model policy route");
|
|
27862
28328
|
}
|
|
27863
28329
|
function validateTeamEvent(type, data, profile) {
|
|
27864
|
-
if (data.version !== (
|
|
28330
|
+
if (data.version !== (hasDeepSeekModernStream(profile) ? 2 : 1))
|
|
27865
28331
|
fail("Modern history team event version is malformed");
|
|
27866
28332
|
requiredString(data.teamId, "team event teamId");
|
|
27867
28333
|
if (type === "team/message/delivered") {
|
|
@@ -28049,7 +28515,8 @@ var ModernHarnessSession = class {
|
|
|
28049
28515
|
sessionId: this.#sessionId,
|
|
28050
28516
|
nativeRef: projection.nativeRef,
|
|
28051
28517
|
modelCatalog: this.#modelCatalog,
|
|
28052
|
-
permissionModes: this.#permissionModes
|
|
28518
|
+
permissionModes: this.#permissionModes,
|
|
28519
|
+
profile: this.#profile
|
|
28053
28520
|
});
|
|
28054
28521
|
this.#nativeRef = projection.nativeRef;
|
|
28055
28522
|
this.initialState = configuration.state;
|
|
@@ -28349,7 +28816,8 @@ ${question.detail}` : question.question;
|
|
|
28349
28816
|
sessionId: this.#sessionId,
|
|
28350
28817
|
nativeRef: this.#nativeRef,
|
|
28351
28818
|
modelCatalog: this.#modelCatalog,
|
|
28352
|
-
permissionModes: this.#permissionModes
|
|
28819
|
+
permissionModes: this.#permissionModes,
|
|
28820
|
+
profile: this.#profile
|
|
28353
28821
|
});
|
|
28354
28822
|
}
|
|
28355
28823
|
#onConfigurationProjection() {
|
|
@@ -28983,6 +29451,9 @@ ${question.detail}` : question.question;
|
|
|
28983
29451
|
if (attempt && !attempt.projected && active?.nativeTurn === attempt.turn && active.agent) {
|
|
28984
29452
|
this.#cancelAgentItem(active);
|
|
28985
29453
|
}
|
|
29454
|
+
if (attempt && active?.reasoning?.attemptId === attempt.attemptId) {
|
|
29455
|
+
this.#cancelReasoningItem(active);
|
|
29456
|
+
}
|
|
28986
29457
|
this.#assistantAttempt = void 0;
|
|
28987
29458
|
}
|
|
28988
29459
|
#cancelAgentItem(active) {
|
|
@@ -29000,6 +29471,13 @@ ${question.detail}` : question.question;
|
|
|
29000
29471
|
delete active.agent;
|
|
29001
29472
|
this.#completeItem(active, agent.item, { status: "cancelled" });
|
|
29002
29473
|
}
|
|
29474
|
+
#cancelReasoningItem(active) {
|
|
29475
|
+
const reasoning2 = active.reasoning;
|
|
29476
|
+
if (!reasoning2)
|
|
29477
|
+
return;
|
|
29478
|
+
delete active.reasoning;
|
|
29479
|
+
this.#completeItem(active, reasoning2.item, { status: "cancelled" });
|
|
29480
|
+
}
|
|
29003
29481
|
#projectAssistantLiveChunks() {
|
|
29004
29482
|
const attempt = this.#assistantAttempt;
|
|
29005
29483
|
const active = this.#active;
|
|
@@ -29034,6 +29512,7 @@ ${question.detail}` : question.question;
|
|
|
29034
29512
|
this.#projectAssistantLiveChunks();
|
|
29035
29513
|
} else {
|
|
29036
29514
|
this.#cancelAgentItem(active);
|
|
29515
|
+
this.#cancelReasoningItem(active);
|
|
29037
29516
|
}
|
|
29038
29517
|
attempt.projected = true;
|
|
29039
29518
|
if (attempt.ended)
|
|
@@ -29253,6 +29732,7 @@ ${question.detail}` : question.question;
|
|
|
29253
29732
|
input: [...input],
|
|
29254
29733
|
autonomous,
|
|
29255
29734
|
tools: /* @__PURE__ */ new Map(),
|
|
29735
|
+
reasoningOrdinal: 0,
|
|
29256
29736
|
interactions: /* @__PURE__ */ new Set(),
|
|
29257
29737
|
terminal: false,
|
|
29258
29738
|
cancelAcknowledged: false
|
|
@@ -29308,6 +29788,9 @@ ${question.detail}` : question.question;
|
|
|
29308
29788
|
if (event.surfaceOp === "append")
|
|
29309
29789
|
this.#completeTool(active, data, event.seq);
|
|
29310
29790
|
return;
|
|
29791
|
+
case "step/end":
|
|
29792
|
+
this.#cancelReasoningItem(active);
|
|
29793
|
+
return;
|
|
29311
29794
|
case "turn/end":
|
|
29312
29795
|
this.#finishTurn(buffer, active, data.reason, event.seq);
|
|
29313
29796
|
return;
|
|
@@ -29319,6 +29802,7 @@ ${question.detail}` : question.question;
|
|
|
29319
29802
|
if (chunk.type === "text-delta") {
|
|
29320
29803
|
this.#appendAgent(active, chunk.text, step, attemptId);
|
|
29321
29804
|
} else if (chunk.type === "reasoning-delta") {
|
|
29805
|
+
this.#appendReasoning(active, chunk.text, step, true, attemptId);
|
|
29322
29806
|
} else if (chunk.type === "usage" && !initialReplay) {
|
|
29323
29807
|
this.#publishUsageChanges(active.turnId);
|
|
29324
29808
|
}
|
|
@@ -29344,36 +29828,48 @@ ${question.detail}` : question.question;
|
|
|
29344
29828
|
update: { type: "text.append", text }
|
|
29345
29829
|
});
|
|
29346
29830
|
}
|
|
29347
|
-
#startReasoning(active, step) {
|
|
29831
|
+
#startReasoning(active, step, provisional, attemptId) {
|
|
29348
29832
|
if (!active.reasoning) {
|
|
29833
|
+
const key = provisional ? `reasoning:provisional:${++active.reasoningOrdinal}` : "reasoning";
|
|
29349
29834
|
const item = {
|
|
29350
29835
|
type: "reasoning",
|
|
29351
|
-
itemId: modernItemId(this.#sessionId, `turn:${active.nativeTurn}:step:${step}
|
|
29836
|
+
itemId: modernItemId(this.#sessionId, `turn:${active.nativeTurn}:step:${step}:${key}`),
|
|
29352
29837
|
text: ""
|
|
29353
29838
|
};
|
|
29354
|
-
active.reasoning = {
|
|
29839
|
+
active.reasoning = {
|
|
29840
|
+
item,
|
|
29841
|
+
text: "",
|
|
29842
|
+
provisional,
|
|
29843
|
+
pendingLineBreaks: "",
|
|
29844
|
+
...attemptId ? { attemptId } : {}
|
|
29845
|
+
};
|
|
29355
29846
|
this.#emit({ type: "item.started", turnId: active.turnId, item });
|
|
29356
29847
|
}
|
|
29357
29848
|
return active.reasoning;
|
|
29358
29849
|
}
|
|
29359
|
-
#appendReasoning(active, text, step) {
|
|
29850
|
+
#appendReasoning(active, text, step, provisional = false, attemptId, final = false) {
|
|
29360
29851
|
if (!text)
|
|
29361
29852
|
return;
|
|
29362
|
-
const reasoning2 = this.#startReasoning(active, step);
|
|
29363
|
-
reasoning2.
|
|
29853
|
+
const reasoning2 = this.#startReasoning(active, step, provisional, attemptId);
|
|
29854
|
+
const candidate = final ? text : reasoning2.pendingLineBreaks + text;
|
|
29855
|
+
const appended = final ? candidate : candidate.replace(/[\r\n]+$/u, "");
|
|
29856
|
+
reasoning2.pendingLineBreaks = final ? "" : candidate.slice(appended.length);
|
|
29857
|
+
if (!appended)
|
|
29858
|
+
return;
|
|
29859
|
+
reasoning2.text += appended;
|
|
29364
29860
|
reasoning2.item = { ...reasoning2.item, text: reasoning2.text };
|
|
29365
29861
|
this.#emit({
|
|
29366
29862
|
type: "item.updated",
|
|
29367
29863
|
turnId: active.turnId,
|
|
29368
29864
|
itemId: reasoning2.item.itemId,
|
|
29369
|
-
update: { type: "text.append", text }
|
|
29865
|
+
update: { type: "text.append", text: appended }
|
|
29370
29866
|
});
|
|
29371
29867
|
}
|
|
29372
29868
|
#completeAssistant(active, data) {
|
|
29373
29869
|
const message = data.message;
|
|
29374
29870
|
const step = data.step;
|
|
29375
|
-
const reasoning2 =
|
|
29376
|
-
const text =
|
|
29871
|
+
const reasoning2 = contentText2(message.content, "reasoning");
|
|
29872
|
+
const text = contentText2(message.content, "text");
|
|
29377
29873
|
if (this.#profile.assistantStream && active.agent && !text.startsWith(active.agent.text)) {
|
|
29378
29874
|
this.#cancelAgentItem(active);
|
|
29379
29875
|
}
|
|
@@ -29388,8 +29884,12 @@ ${question.detail}` : question.question;
|
|
|
29388
29884
|
}
|
|
29389
29885
|
}
|
|
29390
29886
|
#completeReasoning(active, finalText, step) {
|
|
29391
|
-
if (finalText)
|
|
29392
|
-
this.#
|
|
29887
|
+
if (active.reasoning && !finalText.startsWith(active.reasoning.text)) {
|
|
29888
|
+
this.#cancelReasoningItem(active);
|
|
29889
|
+
}
|
|
29890
|
+
const suffix = finalText.slice(active.reasoning?.text.length ?? 0);
|
|
29891
|
+
if (suffix)
|
|
29892
|
+
this.#appendReasoning(active, suffix, step, false, void 0, true);
|
|
29393
29893
|
const current = active.reasoning;
|
|
29394
29894
|
if (!current)
|
|
29395
29895
|
return;
|
|
@@ -29474,6 +29974,7 @@ ${question.detail}` : question.question;
|
|
|
29474
29974
|
const projected = turnOutcome(reason);
|
|
29475
29975
|
const itemOutcome2 = toItemOutcome(projected);
|
|
29476
29976
|
this.#discardAssistantAttempt();
|
|
29977
|
+
this.#cancelReasoningItem(active);
|
|
29477
29978
|
this.#closeActiveInteractions(active);
|
|
29478
29979
|
this.#completeOpenItems(active, itemOutcome2);
|
|
29479
29980
|
active.terminal = true;
|
|
@@ -29585,6 +30086,7 @@ ${question.detail}` : question.question;
|
|
|
29585
30086
|
input: hostBound ? [...pending.command.input] : [...buffer.input],
|
|
29586
30087
|
autonomous: !hostBound,
|
|
29587
30088
|
tools: /* @__PURE__ */ new Map(),
|
|
30089
|
+
reasoningOrdinal: 0,
|
|
29588
30090
|
interactions: /* @__PURE__ */ new Set(),
|
|
29589
30091
|
terminal: false,
|
|
29590
30092
|
cancelAcknowledged: false
|
|
@@ -30025,6 +30527,9 @@ function turnOutcome(reason) {
|
|
|
30025
30527
|
if (reason.kind === "aborted") {
|
|
30026
30528
|
return { status: "cancelled", reason: "Cancelled by user" };
|
|
30027
30529
|
}
|
|
30530
|
+
if (reason.kind === "forked") {
|
|
30531
|
+
return { status: "cancelled", reason: "Forked from parent Session" };
|
|
30532
|
+
}
|
|
30028
30533
|
return {
|
|
30029
30534
|
status: "failed",
|
|
30030
30535
|
error: {
|
|
@@ -30045,7 +30550,7 @@ function toItemOutcome(outcome) {
|
|
|
30045
30550
|
function textInputs2(value) {
|
|
30046
30551
|
return Array.isArray(value) ? value.flatMap((block) => isRecord4(block) && block.type === "text" && typeof block.text === "string" ? [{ type: "text", text: block.text }] : []) : [];
|
|
30047
30552
|
}
|
|
30048
|
-
function
|
|
30553
|
+
function contentText2(value, type) {
|
|
30049
30554
|
return Array.isArray(value) ? value.filter((block) => isRecord4(block) && block.type === type && typeof block.text === "string").map((block) => block.text).join("") : "";
|
|
30050
30555
|
}
|
|
30051
30556
|
function isVisibleWork(event) {
|
|
@@ -30152,17 +30657,17 @@ function boundedId(value, area) {
|
|
|
30152
30657
|
function validUpdatedAt(value) {
|
|
30153
30658
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value <= DEEPSEEK_MODERN_SESSION_UPDATED_AT_MAX && !Object.is(value, -0);
|
|
30154
30659
|
}
|
|
30155
|
-
function titleFromProjections(value) {
|
|
30660
|
+
function titleFromProjections(value, profile) {
|
|
30156
30661
|
if (value === void 0)
|
|
30157
30662
|
return null;
|
|
30158
|
-
if (!isPlainRecord7(value) || !exactKeys5(value, ["asOfSeq", "values"]) || !Number.isSafeInteger(value.asOfSeq) || value.asOfSeq < -1 || !isPlainRecord7(value.values)) {
|
|
30663
|
+
if (!isPlainRecord7(value) || !exactKeys5(value, profile.sessionFormatVersion === 4 ? ["kind", "asOfSeq", "values"] : ["asOfSeq", "values"]) || profile.sessionFormatVersion === 4 && value.kind !== "cached" && value.kind !== "sequenced" || !Number.isSafeInteger(value.asOfSeq) || value.asOfSeq < -1 || !isPlainRecord7(value.values)) {
|
|
30159
30664
|
throw sessionListError("protocolError", "DeepSeek Harness returned invalid Session list projections");
|
|
30160
30665
|
}
|
|
30161
30666
|
const title = value.values.title;
|
|
30162
30667
|
return typeof title === "string" && title.trim().length > 0 && title.length <= DEEPSEEK_MODERN_SESSION_TITLE_MAX_LENGTH && !title.includes("\0") ? title : null;
|
|
30163
30668
|
}
|
|
30164
|
-
function parseSummary(value) {
|
|
30165
|
-
if (!isPlainRecord7(value) || !exactKeys5(value, ["sessionId", "updatedAt", "running", "blank"], ["parentSessionId", "origin", "cwd", "projections"]) || typeof value.running !== "boolean" || typeof value.blank !== "boolean" || !validUpdatedAt(value.updatedAt)) {
|
|
30669
|
+
function parseSummary(value, profile) {
|
|
30670
|
+
if (!isPlainRecord7(value) || !exactKeys5(value, profile.sessionFormatVersion === 4 ? ["sessionId", "updatedAt", "agentAvailable", "running", "blank"] : ["sessionId", "updatedAt", "running", "blank"], ["parentSessionId", "origin", "cwd", "projections"]) || typeof value.running !== "boolean" || typeof value.blank !== "boolean" || profile.sessionFormatVersion === 4 && typeof value.agentAvailable !== "boolean" || !validUpdatedAt(value.updatedAt)) {
|
|
30166
30671
|
throw sessionListError("protocolError", "DeepSeek Harness returned an invalid Session row");
|
|
30167
30672
|
}
|
|
30168
30673
|
const sessionId = boundedId(value.sessionId, "Session id");
|
|
@@ -30185,13 +30690,13 @@ function parseSummary(value) {
|
|
|
30185
30690
|
blank: value.blank,
|
|
30186
30691
|
...value.origin === void 0 ? {} : { origin: value.origin },
|
|
30187
30692
|
...value.cwd === void 0 ? {} : { cwd: value.cwd },
|
|
30188
|
-
title: titleFromProjections(value.projections)
|
|
30693
|
+
title: titleFromProjections(value.projections, profile)
|
|
30189
30694
|
};
|
|
30190
30695
|
}
|
|
30191
30696
|
function isCanonicalAbsoluteCwd(value) {
|
|
30192
30697
|
return value !== void 0 && value.trim().length > 0 && !value.includes("\0") && path2.isAbsolute(value) && path2.resolve(value) === value;
|
|
30193
30698
|
}
|
|
30194
|
-
function parseModernSessionCandidates(value) {
|
|
30699
|
+
function parseModernSessionCandidates(value, profile = DEEPSEEK_V015_PROFILE) {
|
|
30195
30700
|
assertBoundedJson4(value);
|
|
30196
30701
|
if (!isPlainRecord7(value) || !exactKeys5(value, ["items"]) || !Array.isArray(value.items)) {
|
|
30197
30702
|
throw sessionListError("protocolError", "DeepSeek Harness returned an invalid Session list");
|
|
@@ -30201,7 +30706,7 @@ function parseModernSessionCandidates(value) {
|
|
|
30201
30706
|
}
|
|
30202
30707
|
const seen = /* @__PURE__ */ new Set();
|
|
30203
30708
|
const summaries = value.items.map((item) => {
|
|
30204
|
-
const summary = parseSummary(item);
|
|
30709
|
+
const summary = parseSummary(item, profile);
|
|
30205
30710
|
if (seen.has(summary.sessionId)) {
|
|
30206
30711
|
throw sessionListError("protocolError", "DeepSeek Harness returned duplicate Session identities");
|
|
30207
30712
|
}
|
|
@@ -30223,14 +30728,14 @@ function parseModernSessionCandidates(value) {
|
|
|
30223
30728
|
];
|
|
30224
30729
|
});
|
|
30225
30730
|
}
|
|
30226
|
-
async function loadModernSessionCandidates(remote, signal) {
|
|
30731
|
+
async function loadModernSessionCandidates(remote, signal, profile = DEEPSEEK_V015_PROFILE) {
|
|
30227
30732
|
try {
|
|
30228
30733
|
const result = await remote.call("session/list", { _request: {} }, signal);
|
|
30229
30734
|
if (!result.ok) {
|
|
30230
30735
|
const safe = sanitizeModernRemoteFailure(result.error);
|
|
30231
30736
|
throw sessionListError("remoteError", `DeepSeek Harness session/list failed: ${safe.message}`, safe.code);
|
|
30232
30737
|
}
|
|
30233
|
-
return parseModernSessionCandidates(result.value);
|
|
30738
|
+
return parseModernSessionCandidates(result.value, profile);
|
|
30234
30739
|
} catch (error51) {
|
|
30235
30740
|
if (error51 instanceof ModernSessionListError)
|
|
30236
30741
|
throw error51;
|
|
@@ -30299,6 +30804,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30299
30804
|
onFault: (error51) => this.#fail(toHarnessError(error51, "unavailable"))
|
|
30300
30805
|
});
|
|
30301
30806
|
this.#control = new ModernControlStore(this.#connection, {
|
|
30807
|
+
profile: this.#profile,
|
|
30302
30808
|
onFault: (error51) => this.#fail(toHarnessError(error51, "unavailable"))
|
|
30303
30809
|
});
|
|
30304
30810
|
this.#removeConnectionFaultListener = this.#connection.onFault((error51) => {
|
|
@@ -30371,7 +30877,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30371
30877
|
try {
|
|
30372
30878
|
await this.#connection.connect();
|
|
30373
30879
|
this.#assertAccepting();
|
|
30374
|
-
const candidates = await loadModernSessionCandidates(this.#connection, this.#lifetime.signal);
|
|
30880
|
+
const candidates = await loadModernSessionCandidates(this.#connection, this.#lifetime.signal, this.#profile);
|
|
30375
30881
|
this.#assertAccepting();
|
|
30376
30882
|
return { ok: true, value: candidates };
|
|
30377
30883
|
} catch (error51) {
|
|
@@ -30467,7 +30973,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30467
30973
|
this.#assertAccepting();
|
|
30468
30974
|
if (forkExpectation) {
|
|
30469
30975
|
await this.#verifyForkJournal(forkExpectation, journal, cwd);
|
|
30470
|
-
if (
|
|
30976
|
+
if (hasDeepSeekModernStream(this.#profile) && await clearInheritedForkInbox(this.#connection, journal, this.#lifetime.signal)) {
|
|
30471
30977
|
await journal.close();
|
|
30472
30978
|
journal = await openModernJournal(this.#connection, { sessionId, cwd }, this.#journalOptions());
|
|
30473
30979
|
await this.#verifyForkJournal(forkExpectation, journal, cwd);
|
|
@@ -30503,10 +31009,11 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30503
31009
|
harnessId: this.harnessId,
|
|
30504
31010
|
nativeSessionId: sessionId,
|
|
30505
31011
|
formatVersion: 1,
|
|
30506
|
-
...
|
|
31012
|
+
...hasDeepSeekModernStream(this.#profile) ? { locator: { dshVersion: this.#profile.version } } : {}
|
|
30507
31013
|
}),
|
|
30508
31014
|
modelCatalog: catalog,
|
|
30509
|
-
permissionModes
|
|
31015
|
+
permissionModes,
|
|
31016
|
+
profile: this.#profile
|
|
30510
31017
|
});
|
|
30511
31018
|
verifyCreateConfiguration(createConfiguration, openedConfiguration);
|
|
30512
31019
|
if (createConfiguration?.unattended && !delegationPermissionIsApplied(journal.events)) {
|
|
@@ -30524,7 +31031,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30524
31031
|
modelCatalog: catalog,
|
|
30525
31032
|
permissionModes,
|
|
30526
31033
|
sessionId,
|
|
30527
|
-
...
|
|
31034
|
+
...hasDeepSeekModernStream(this.#profile) ? { flushSession: () => this.#connection.flushSession(sessionId) } : {},
|
|
30528
31035
|
randomUUID: this.#dependencies.randomUUID,
|
|
30529
31036
|
now: this.#dependencies.now,
|
|
30530
31037
|
...this.#options.toolOutputLimit === void 0 ? {} : { toolOutputLimit: this.#options.toolOutputLimit },
|
|
@@ -30666,7 +31173,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30666
31173
|
}
|
|
30667
31174
|
atSeq = boundary.atSeq;
|
|
30668
31175
|
minimumSeedLength = boundary.events.length;
|
|
30669
|
-
if (boundary.events.length < source.events.length) {
|
|
31176
|
+
if (this.#profile.sessionFormatVersion === 4 || boundary.events.length < source.events.length) {
|
|
30670
31177
|
exactSeedLength = boundary.events.length;
|
|
30671
31178
|
}
|
|
30672
31179
|
} finally {
|
|
@@ -30759,7 +31266,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30759
31266
|
}
|
|
30760
31267
|
if (this.#permissionModesPromise)
|
|
30761
31268
|
return this.#permissionModesPromise;
|
|
30762
|
-
const operation = loadModernPermissionModeCatalog(this.#connection).then((catalog) => {
|
|
31269
|
+
const operation = loadModernPermissionModeCatalog(this.#connection, this.#lifetime.signal, this.#profile).then((catalog) => {
|
|
30763
31270
|
this.#permissionModes = catalog;
|
|
30764
31271
|
this.#permissionModesLoaded = true;
|
|
30765
31272
|
return catalog;
|
|
@@ -30984,10 +31491,19 @@ function parseModernForkInput(input, profile) {
|
|
|
30984
31491
|
function sessionLocatorMatches(locator, profile) {
|
|
30985
31492
|
if (locator === void 0)
|
|
30986
31493
|
return true;
|
|
30987
|
-
|
|
31494
|
+
if (!hasDeepSeekModernStream(profile) || !isRecord8(locator) || Reflect.ownKeys(locator).length !== 1 || typeof locator.dshVersion !== "string") {
|
|
31495
|
+
return false;
|
|
31496
|
+
}
|
|
31497
|
+
try {
|
|
31498
|
+
const { version: version2 } = classifyDeepSeekVersionOutput(locator.dshVersion);
|
|
31499
|
+
const original = deepSeekModernProfile(version2);
|
|
31500
|
+
return original.sessionFormatVersion === profile.sessionFormatVersion || profile.sessionFormatVersion === 4 && original.sessionFormatVersion === 3;
|
|
31501
|
+
} catch {
|
|
31502
|
+
return false;
|
|
31503
|
+
}
|
|
30988
31504
|
}
|
|
30989
31505
|
function checkpointLocatorMatches(locator, profile) {
|
|
30990
|
-
return
|
|
31506
|
+
return hasDeepSeekModernStream(profile) ? profileLocatorMatches(locator, profile) : locator === void 0;
|
|
30991
31507
|
}
|
|
30992
31508
|
function profileLocatorMatches(locator, profile) {
|
|
30993
31509
|
return isRecord8(locator) && Reflect.ownKeys(locator).length === 1 && locator.dshVersion === profile.version;
|
|
@@ -31198,7 +31714,7 @@ var DeepSeekHarnessAdapter = class {
|
|
|
31198
31714
|
harnessId: this.harnessId,
|
|
31199
31715
|
nativeSessionId,
|
|
31200
31716
|
formatVersion: 1,
|
|
31201
|
-
...this.#delegate
|
|
31717
|
+
...this.#delegate && hasDeepSeekModernStream(deepSeekModernProfile(this.#delegate.version)) ? { locator: { dshVersion: this.#delegate.version } } : {}
|
|
31202
31718
|
})
|
|
31203
31719
|
}
|
|
31204
31720
|
};
|
|
@@ -31350,9 +31866,6 @@ var DeepSeekHarnessAdapter = class {
|
|
|
31350
31866
|
durationMs: Math.max(0, Date.now() - startedAt)
|
|
31351
31867
|
};
|
|
31352
31868
|
}
|
|
31353
|
-
if (executableFailure?.code === "unsupported") {
|
|
31354
|
-
throw new DelegateSelectionError(executableFailure);
|
|
31355
|
-
}
|
|
31356
31869
|
if (await hasDeepSeekModernAuthenticationFingerprint(endpoint, signal)) {
|
|
31357
31870
|
throw new DelegateSelectionError({
|
|
31358
31871
|
code: "authenticationRequired",
|
|
@@ -31368,7 +31881,7 @@ var DeepSeekHarnessAdapter = class {
|
|
|
31368
31881
|
if (!executable) {
|
|
31369
31882
|
throw new DelegateSelectionError(executableFailure ? { ...executableFailure, durationMs: Math.max(0, Date.now() - startedAt) } : {
|
|
31370
31883
|
code: "notInstalled",
|
|
31371
|
-
message: "No
|
|
31884
|
+
message: "No local DeepSeek Harness executable was found",
|
|
31372
31885
|
retryable: false,
|
|
31373
31886
|
stage: "resolve-executable",
|
|
31374
31887
|
durationMs: Math.max(0, Date.now() - startedAt)
|