@liberseek/boft-cli-linux-x64 0.7.4 → 0.7.5
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 +4 -0
- package/app/codexhost-distribution.json +1 -1
- package/app/host-runtime.mjs +458 -171
- package/app/plugins/claude-code/plugin.mjs +3 -6
- package/app/plugins/cursor-cli/plugin.mjs +80 -19
- package/app/plugins/deepseek-harness/plugin.mjs +598 -125
- package/app/plugins/omp/plugin.mjs +163 -103
- package/app/plugins/opencode/plugin.mjs +3175 -169
- package/app/plugins/pi/plugin.mjs +4 -1
- package/app/renderer-extension.js +149 -156
- package/bin/boft +0 -0
- package/libexec/boft-shim +0 -0
- package/libexec/boft-updater +0 -0
- package/licenses/OpenCode-v2-Client-LICENSE.txt +21 -0
- package/package.json +1 -1
|
@@ -20891,7 +20891,8 @@ var ModernRemoteConnection = class {
|
|
|
20891
20891
|
} catch (error51) {
|
|
20892
20892
|
throw this.#transportFailure("DeepSeek Harness Web authentication failed", error51);
|
|
20893
20893
|
}
|
|
20894
|
-
|
|
20894
|
+
const location = response.headers.get("location");
|
|
20895
|
+
if (response.status !== 303 || location !== "/" && location !== "./") {
|
|
20895
20896
|
await cancelResponse(response);
|
|
20896
20897
|
throw new ModernRemoteConnectionError(response.status === 401 || response.status === 403 ? "authenticationRequired" : "protocolError", "DeepSeek Harness Web rejected its bootstrap authentication exchange");
|
|
20897
20898
|
}
|
|
@@ -21423,7 +21424,7 @@ function parseEvent(value, format = 0) {
|
|
|
21423
21424
|
throw protocolError("journal event has invalid scalar fields");
|
|
21424
21425
|
}
|
|
21425
21426
|
assertJsonValue(value.data, "journal event data");
|
|
21426
|
-
if (format
|
|
21427
|
+
if (format >= 3 && value.ignorable === true) {
|
|
21427
21428
|
if (Object.hasOwn(value, "sourceEventSeqs"))
|
|
21428
21429
|
assertJsonValue(value.sourceEventSeqs, "journal event sourceEventSeqs");
|
|
21429
21430
|
if (Object.hasOwn(value, "surfaceOp"))
|
|
@@ -21442,8 +21443,8 @@ function parseEvent(value, format = 0) {
|
|
|
21442
21443
|
function parseSurfaceOp(value, format) {
|
|
21443
21444
|
if (value === "append")
|
|
21444
21445
|
return value;
|
|
21445
|
-
const start = format
|
|
21446
|
-
const end = format
|
|
21446
|
+
const start = format >= 3 ? "startSeq" : "start";
|
|
21447
|
+
const end = format >= 3 ? "endSeq" : "end";
|
|
21447
21448
|
if (!isRecord3(value) || !hasExactKeys2(value, ["op", start, end]) || value.op !== "replace" || !isSeq(value[start]) || !isSeq(value[end])) {
|
|
21448
21449
|
throw protocolError("journal event has an invalid surfaceOp");
|
|
21449
21450
|
}
|
|
@@ -21945,12 +21946,33 @@ function parseArguments(value) {
|
|
|
21945
21946
|
return value;
|
|
21946
21947
|
}
|
|
21947
21948
|
}
|
|
21949
|
+
function contentText(value) {
|
|
21950
|
+
if (!isRecord4(value) || !Array.isArray(value.content))
|
|
21951
|
+
return "";
|
|
21952
|
+
return value.content.filter((block) => isRecord4(block) && block.type === "text" && typeof block.text === "string").map((block) => block.text).join("");
|
|
21953
|
+
}
|
|
21948
21954
|
function projectToolResult(value, limit) {
|
|
21949
21955
|
if (!isRecord4(value) || !isRecord4(value.source) || value.source.kind !== "tool")
|
|
21950
21956
|
return null;
|
|
21951
21957
|
const callId = value.source.callId;
|
|
21952
21958
|
if (!nonBlankString(callId) || !Array.isArray(value.content))
|
|
21953
21959
|
return null;
|
|
21960
|
+
if (value.role === "tool") {
|
|
21961
|
+
if (value.toolCallId !== callId || value.isError !== void 0 && typeof value.isError !== "boolean")
|
|
21962
|
+
return null;
|
|
21963
|
+
const text2 = contentText(value);
|
|
21964
|
+
const truncated2 = text2.length > limit;
|
|
21965
|
+
return {
|
|
21966
|
+
callId,
|
|
21967
|
+
failed: value.isError === true,
|
|
21968
|
+
...text2 ? {
|
|
21969
|
+
output: {
|
|
21970
|
+
content: [{ type: "text", text: truncated2 ? text2.slice(0, limit) : text2 }],
|
|
21971
|
+
...truncated2 ? { truncated: true } : {}
|
|
21972
|
+
}
|
|
21973
|
+
} : {}
|
|
21974
|
+
};
|
|
21975
|
+
}
|
|
21954
21976
|
const resultBlocks = value.content.filter((block) => isRecord4(block) && block.type === "tool-result" && block.toolCallId === callId && Array.isArray(block.content));
|
|
21955
21977
|
if (resultBlocks.length === 0)
|
|
21956
21978
|
return null;
|
|
@@ -22066,6 +22088,12 @@ function projectTurnReason(value) {
|
|
|
22066
22088
|
history: { status: "cancelled", reason: "Cancelled by user" }
|
|
22067
22089
|
};
|
|
22068
22090
|
}
|
|
22091
|
+
if (value.kind === "forked") {
|
|
22092
|
+
return {
|
|
22093
|
+
outcome: { status: "cancelled", reason: "Forked from parent Session" },
|
|
22094
|
+
history: { status: "cancelled", reason: "Forked from parent Session" }
|
|
22095
|
+
};
|
|
22096
|
+
}
|
|
22069
22097
|
const error51 = {
|
|
22070
22098
|
code: "nativeFailure",
|
|
22071
22099
|
message: value.kind === "error" && isRecord4(value.error) && typeof value.error.message === "string" ? value.error.message : `DeepSeek Harness Turn ended with '${value.kind}'`,
|
|
@@ -22204,6 +22232,12 @@ function positiveInteger(value, label) {
|
|
|
22204
22232
|
function nonNegativeInteger(value, label) {
|
|
22205
22233
|
return boundedInteger(value, label, 0);
|
|
22206
22234
|
}
|
|
22235
|
+
function nonNegativeFiniteNumber(value, label) {
|
|
22236
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
22237
|
+
fail(`${label} must be a finite number greater than or equal to 0`);
|
|
22238
|
+
}
|
|
22239
|
+
return value;
|
|
22240
|
+
}
|
|
22207
22241
|
function nonNegativeSafeInteger2(value) {
|
|
22208
22242
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
22209
22243
|
}
|
|
@@ -22904,13 +22938,219 @@ function matchesForkTail2(expectedPrefix, childEvents) {
|
|
|
22904
22938
|
return childOwned.every((event) => event.type !== "turn/start" && event.type !== "session/end-seed");
|
|
22905
22939
|
}
|
|
22906
22940
|
|
|
22941
|
+
// dist/profiles/v017.js
|
|
22942
|
+
function invalid2(label) {
|
|
22943
|
+
throw new ModernHistoryError("protocolError", `DSH V4 ${label} is malformed`);
|
|
22944
|
+
}
|
|
22945
|
+
function requiredFields(value, fields) {
|
|
22946
|
+
if (fields.some((field) => !Object.hasOwn(value, field)))
|
|
22947
|
+
invalid2("required fields");
|
|
22948
|
+
}
|
|
22949
|
+
function validateV4Content(value) {
|
|
22950
|
+
if (!Array.isArray(value))
|
|
22951
|
+
invalid2("content");
|
|
22952
|
+
for (const block of value) {
|
|
22953
|
+
if (!isRecord3(block) || block.type === "tool-result")
|
|
22954
|
+
invalid2("content block");
|
|
22955
|
+
if (block.type === "tool-addition" || block.type === "tool-removal") {
|
|
22956
|
+
requiredString(block.toolName, "tool change toolName");
|
|
22957
|
+
continue;
|
|
22958
|
+
}
|
|
22959
|
+
if (block.type === "image" && block.offloaded !== void 0 && block.offloaded !== true) {
|
|
22960
|
+
invalid2("image offloaded marker");
|
|
22961
|
+
}
|
|
22962
|
+
const ordinary = Object.fromEntries(Object.entries(block).filter(([key]) => key !== "offloaded"));
|
|
22963
|
+
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;
|
|
22964
|
+
DEEPSEEK_V015_PROFILE.validateContent([canonical]);
|
|
22965
|
+
}
|
|
22966
|
+
}
|
|
22967
|
+
function validateV4Chunk(value) {
|
|
22968
|
+
DEEPSEEK_V015_PROFILE.validateChunk(value);
|
|
22969
|
+
if (!isRecord3(value))
|
|
22970
|
+
invalid2("assistant chunk");
|
|
22971
|
+
const blockType = value.type === "block-start" ? value.blockType : value.type === "block-end" && isRecord3(value.block) ? value.block.type : void 0;
|
|
22972
|
+
if (blockType === "tool-result" || blockType === "tool-addition" || blockType === "tool-removal") {
|
|
22973
|
+
invalid2("assistant tool-change block");
|
|
22974
|
+
}
|
|
22975
|
+
}
|
|
22976
|
+
function validateV4Stream(value) {
|
|
22977
|
+
for (const entry of expandV015AssistantStream(value))
|
|
22978
|
+
validateV4Chunk(entry.chunk);
|
|
22979
|
+
}
|
|
22980
|
+
function validateDeveloperMessage(event) {
|
|
22981
|
+
if (!isRecord3(event.data))
|
|
22982
|
+
invalid2("developer/message data");
|
|
22983
|
+
const data = event.data;
|
|
22984
|
+
requiredFields(data, ["turn", "step", "message"]);
|
|
22985
|
+
if (Object.hasOwn(data, "headerSeq") && !Number.isSafeInteger(data.headerSeq))
|
|
22986
|
+
invalid2("developer/message headerSeq");
|
|
22987
|
+
positiveInteger(data.turn, "developer/message turn");
|
|
22988
|
+
positiveInteger(data.step, "developer/message step");
|
|
22989
|
+
if (!isRecord3(data.message))
|
|
22990
|
+
invalid2("developer/message message");
|
|
22991
|
+
const message = data.message;
|
|
22992
|
+
requiredFields(message, ["id", "role", "content", "source"]);
|
|
22993
|
+
requiredString(message.id, "developer/message id");
|
|
22994
|
+
if (message.role !== "developer" || !isRecord3(message.source) || typeof message.source.kind !== "string" || !message.source.kind || message.source.kind === "plugin" || !Array.isArray(message.content)) {
|
|
22995
|
+
invalid2("developer/message role, source or content");
|
|
22996
|
+
}
|
|
22997
|
+
let additions = false;
|
|
22998
|
+
for (const block of message.content) {
|
|
22999
|
+
if (!isRecord3(block))
|
|
23000
|
+
invalid2("developer content block");
|
|
23001
|
+
if (block.type === "tool-addition" || block.type === "tool-removal") {
|
|
23002
|
+
requiredString(block.toolName, "developer toolName");
|
|
23003
|
+
additions ||= block.type === "tool-addition";
|
|
23004
|
+
} else {
|
|
23005
|
+
validateV4Content([block]);
|
|
23006
|
+
}
|
|
23007
|
+
}
|
|
23008
|
+
if (additions !== Object.hasOwn(data, "headerSeq") || additions && (!Number.isSafeInteger(data.headerSeq) || Object.is(data.headerSeq, -0) || data.headerSeq < 0 || data.headerSeq >= event.seq)) {
|
|
23009
|
+
invalid2("developer/message headerSeq");
|
|
23010
|
+
}
|
|
23011
|
+
}
|
|
23012
|
+
function matchesV4ForkTail(prefix, child) {
|
|
23013
|
+
if (!DEEPSEEK_V015_PROFILE.matchesForkTail(prefix, child))
|
|
23014
|
+
return false;
|
|
23015
|
+
const tail = child.slice(prefix.length + 1);
|
|
23016
|
+
const openTurn = prefix.reduce((turn, event) => event.type === "turn/start" ? event.data.turn : event.type === "turn/end" ? null : turn, null);
|
|
23017
|
+
const closer = tail.find((event) => event.type === "turn/end");
|
|
23018
|
+
if (openTurn === null)
|
|
23019
|
+
return closer === void 0 && !tail.some((event) => event.type === "step/end");
|
|
23020
|
+
return closer !== void 0 && isRecord3(closer.data) && closer.data.turn === openTurn && isRecord3(closer.data.reason) && closer.data.reason.kind === "forked";
|
|
23021
|
+
}
|
|
23022
|
+
var DEEPSEEK_V017_PROFILE = Object.freeze({
|
|
23023
|
+
...DEEPSEEK_V015_PROFILE,
|
|
23024
|
+
version: "0.1.7-rc.1",
|
|
23025
|
+
checkpointPrefix: "v4-turn-end:",
|
|
23026
|
+
sessionFormatVersion: 4,
|
|
23027
|
+
matchesForkTail: matchesV4ForkTail,
|
|
23028
|
+
parseHeader(value, expected) {
|
|
23029
|
+
if (!isRecord3(value) || value.version !== 4)
|
|
23030
|
+
invalid2("journal header");
|
|
23031
|
+
if (value.delegationDepth !== void 0 && (!Number.isSafeInteger(value.delegationDepth) || Object.is(value.delegationDepth, -0) || value.delegationDepth < 0)) {
|
|
23032
|
+
invalid2("journal header delegationDepth");
|
|
23033
|
+
}
|
|
23034
|
+
const delegationDepth = value.delegationDepth ?? 0;
|
|
23035
|
+
DEEPSEEK_V015_PROFILE.parseHeader({ ...value, version: 3, delegationDepth }, expected);
|
|
23036
|
+
return { ...value, delegationDepth };
|
|
23037
|
+
},
|
|
23038
|
+
parseHistoryRecord: (value, remaining) => parseV015HistoryRecord(value, remaining, (event) => parseEvent(event, 4)),
|
|
23039
|
+
parseLiveItem: (value) => {
|
|
23040
|
+
const item = parseV015LiveItem(value, (event) => parseEvent(event, 4));
|
|
23041
|
+
if (item.type === "assistant-stream" && "frame" in item && item.frame.type === "chunk") {
|
|
23042
|
+
validateV4Chunk(item.frame.chunk);
|
|
23043
|
+
}
|
|
23044
|
+
return item;
|
|
23045
|
+
},
|
|
23046
|
+
parseAssistantBaseline(value) {
|
|
23047
|
+
const baseline = parseV015AssistantBaseline(value);
|
|
23048
|
+
if (baseline.activeAttempt)
|
|
23049
|
+
validateV4Stream(baseline.activeAttempt.stream);
|
|
23050
|
+
return baseline;
|
|
23051
|
+
},
|
|
23052
|
+
validateContent: validateV4Content,
|
|
23053
|
+
validateChunk: validateV4Chunk,
|
|
23054
|
+
validateEvent(event) {
|
|
23055
|
+
if (event.type === "developer/message") {
|
|
23056
|
+
validateDeveloperMessage(event);
|
|
23057
|
+
} else if (event.type === "system/message") {
|
|
23058
|
+
if (!isRecord3(event.data) || !isRecord3(event.data.message))
|
|
23059
|
+
invalid2("system/message");
|
|
23060
|
+
exactKeys2(event.data, ["turn", "step", "message"]);
|
|
23061
|
+
const message = event.data.message;
|
|
23062
|
+
requiredFields(message, ["id", "role", "content", "source"]);
|
|
23063
|
+
requiredString(message.id, "system/message id");
|
|
23064
|
+
if (message.role !== "system" || !isRecord3(message.source) || message.source.kind !== "system-prompt") {
|
|
23065
|
+
invalid2("system/message source");
|
|
23066
|
+
}
|
|
23067
|
+
validateV4Content(message.content);
|
|
23068
|
+
} else if (event.type === "image/offload") {
|
|
23069
|
+
if (!isRecord3(event.data))
|
|
23070
|
+
invalid2("image/offload");
|
|
23071
|
+
exactKeys2(event.data, ["targets"]);
|
|
23072
|
+
if (!Array.isArray(event.data.targets) || event.data.targets.length === 0)
|
|
23073
|
+
invalid2("image/offload targets");
|
|
23074
|
+
} else if (event.type === "workspace/changes") {
|
|
23075
|
+
if (!isRecord3(event.data))
|
|
23076
|
+
invalid2("workspace/changes");
|
|
23077
|
+
exactKeys2(event.data, ["turn"]);
|
|
23078
|
+
positiveInteger(event.data.turn, "workspace/changes turn");
|
|
23079
|
+
} else if (event.type === "tool/result") {
|
|
23080
|
+
if (!isRecord3(event.data))
|
|
23081
|
+
invalid2("tool/result");
|
|
23082
|
+
const message = event.data.message;
|
|
23083
|
+
if (event.data.error !== void 0 && (!isRecord3(message) || message.isError !== true)) {
|
|
23084
|
+
invalid2("tool/result error marker");
|
|
23085
|
+
}
|
|
23086
|
+
} else if (event.type === "request/header") {
|
|
23087
|
+
DEEPSEEK_V015_PROFILE.validateEvent(event);
|
|
23088
|
+
if (!isRecord3(event.data) || !isRecord3(event.data.header))
|
|
23089
|
+
invalid2("request/header");
|
|
23090
|
+
const tools = event.data.header.tools;
|
|
23091
|
+
if (tools !== void 0 && (!Array.isArray(tools) || tools.some((tool) => !isRecord3(tool) || tool.deferLoading !== void 0 && tool.deferLoading !== true))) {
|
|
23092
|
+
invalid2("request/header tools");
|
|
23093
|
+
}
|
|
23094
|
+
} else if (event.type === "assistant/message" || event.type === "assistant/attempt") {
|
|
23095
|
+
DEEPSEEK_V015_PROFILE.validateEvent(event);
|
|
23096
|
+
if (!isRecord3(event.data))
|
|
23097
|
+
invalid2("assistant settlement");
|
|
23098
|
+
validateV4Stream(event.data.stream);
|
|
23099
|
+
} else {
|
|
23100
|
+
DEEPSEEK_V015_PROFILE.validateEvent(event);
|
|
23101
|
+
}
|
|
23102
|
+
}
|
|
23103
|
+
});
|
|
23104
|
+
|
|
22907
23105
|
// dist/profiles/profile.js
|
|
23106
|
+
var V4_MINIMUM = parseSemVer("0.1.7-rc.1");
|
|
23107
|
+
function parseSemVer(value) {
|
|
23108
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/u.exec(value);
|
|
23109
|
+
if (!match)
|
|
23110
|
+
return void 0;
|
|
23111
|
+
const prerelease = match[4] ? match[4].split(".").map((part) => /^\d+$/u.test(part) ? Number(part) : part) : [];
|
|
23112
|
+
return {
|
|
23113
|
+
major: Number(match[1]),
|
|
23114
|
+
minor: Number(match[2]),
|
|
23115
|
+
patch: Number(match[3]),
|
|
23116
|
+
prerelease
|
|
23117
|
+
};
|
|
23118
|
+
}
|
|
23119
|
+
function compareSemVer(left, right) {
|
|
23120
|
+
for (const key of ["major", "minor", "patch"]) {
|
|
23121
|
+
if (left[key] !== right[key])
|
|
23122
|
+
return left[key] > right[key] ? 1 : -1;
|
|
23123
|
+
}
|
|
23124
|
+
if (left.prerelease.length === 0 || right.prerelease.length === 0) {
|
|
23125
|
+
return left.prerelease.length === right.prerelease.length ? 0 : left.prerelease.length === 0 ? 1 : -1;
|
|
23126
|
+
}
|
|
23127
|
+
const length = Math.max(left.prerelease.length, right.prerelease.length);
|
|
23128
|
+
for (let index = 0; index < length; index += 1) {
|
|
23129
|
+
const leftPart = left.prerelease[index];
|
|
23130
|
+
const rightPart = right.prerelease[index];
|
|
23131
|
+
if (leftPart === void 0 || rightPart === void 0) {
|
|
23132
|
+
return leftPart === rightPart ? 0 : leftPart === void 0 ? -1 : 1;
|
|
23133
|
+
}
|
|
23134
|
+
if (leftPart === rightPart)
|
|
23135
|
+
continue;
|
|
23136
|
+
if (typeof leftPart === "number" && typeof rightPart === "string")
|
|
23137
|
+
return -1;
|
|
23138
|
+
if (typeof leftPart === "string" && typeof rightPart === "number")
|
|
23139
|
+
return 1;
|
|
23140
|
+
return leftPart > rightPart ? 1 : -1;
|
|
23141
|
+
}
|
|
23142
|
+
return 0;
|
|
23143
|
+
}
|
|
23144
|
+
function usesV4Profile(version2) {
|
|
23145
|
+
const parsed = parseSemVer(version2);
|
|
23146
|
+
return parsed !== void 0 && V4_MINIMUM !== void 0 && compareSemVer(parsed, V4_MINIMUM) >= 0;
|
|
23147
|
+
}
|
|
22908
23148
|
function deepSeekModernProfile(version2) {
|
|
22909
|
-
const base = /^0\.1\.2(?:-|\+|$)/u.test(version2) ? DEEPSEEK_V012_PROFILE : DEEPSEEK_V015_PROFILE;
|
|
23149
|
+
const base = /^0\.1\.2(?:-|\+|$)/u.test(version2) ? DEEPSEEK_V012_PROFILE : usesV4Profile(version2) ? DEEPSEEK_V017_PROFILE : DEEPSEEK_V015_PROFILE;
|
|
22910
23150
|
return base.version === version2 ? base : Object.freeze({ ...base, version: version2 });
|
|
22911
23151
|
}
|
|
22912
|
-
function
|
|
22913
|
-
return profile.sessionFormatVersion
|
|
23152
|
+
function hasDeepSeekModernStream(profile) {
|
|
23153
|
+
return profile.sessionFormatVersion >= 3;
|
|
22914
23154
|
}
|
|
22915
23155
|
|
|
22916
23156
|
// dist/modern/commands.js
|
|
@@ -22992,7 +23232,7 @@ async function callModernCommand(remote, endpoint, args, parse3, signal, timeout
|
|
|
22992
23232
|
}
|
|
22993
23233
|
}
|
|
22994
23234
|
function executeModernCommand(remote, agentId, line, signal, profile = DEEPSEEK_V012_PROFILE) {
|
|
22995
|
-
return callModernCommand(remote, "commands/execute",
|
|
23235
|
+
return callModernCommand(remote, "commands/execute", profile.sessionFormatVersion !== 0 ? { agentId, line, submittedAttachments: [] } : { agentId, line, images: [] }, parseModernCommandExecution, signal, null);
|
|
22996
23236
|
}
|
|
22997
23237
|
|
|
22998
23238
|
// dist/modern/control-store.js
|
|
@@ -23264,13 +23504,15 @@ function parseSessionCollection(value, kind, sessions, maxSessions) {
|
|
|
23264
23504
|
}
|
|
23265
23505
|
}
|
|
23266
23506
|
}
|
|
23267
|
-
function parseBaseline(value, maxSessions, maxKeys) {
|
|
23268
|
-
if (!isRecord6(value) || !hasExactKeys4(value, ["queues", "jobs", "projections"]) || !isPlainRecord3(value.projections)) {
|
|
23507
|
+
function parseBaseline(value, maxSessions, maxKeys, formatVersion) {
|
|
23508
|
+
if (!isRecord6(value) || !hasExactKeys4(value, formatVersion === 4 ? ["projections"] : ["queues", "jobs", "projections"]) || !isPlainRecord3(value.projections)) {
|
|
23269
23509
|
throw storeError("protocolError", "DeepSeek Harness control stream emitted an invalid baseline");
|
|
23270
23510
|
}
|
|
23271
23511
|
const sessions = /* @__PURE__ */ new Set();
|
|
23272
|
-
|
|
23273
|
-
|
|
23512
|
+
if (formatVersion !== 4) {
|
|
23513
|
+
parseSessionCollection(value.queues, "queues", sessions, maxSessions);
|
|
23514
|
+
parseSessionCollection(value.jobs, "jobs", sessions, maxSessions);
|
|
23515
|
+
}
|
|
23274
23516
|
const projections = /* @__PURE__ */ Object.create(null);
|
|
23275
23517
|
for (const [sessionId, block] of Object.entries(value.projections)) {
|
|
23276
23518
|
if (!validIdentifier(sessionId)) {
|
|
@@ -23284,12 +23526,15 @@ function parseBaseline(value, maxSessions, maxKeys) {
|
|
|
23284
23526
|
}
|
|
23285
23527
|
return { projections };
|
|
23286
23528
|
}
|
|
23287
|
-
function parseControlFrame(value, maxSessions, maxKeys) {
|
|
23529
|
+
function parseControlFrame(value, maxSessions, maxKeys, formatVersion) {
|
|
23288
23530
|
if (!isRecord6(value) || typeof value.type !== "string") {
|
|
23289
23531
|
throw storeError("protocolError", "DeepSeek Harness control stream emitted an invalid frame");
|
|
23290
23532
|
}
|
|
23291
23533
|
if (value.type === "baseline" && hasExactKeys4(value, ["type", "value"])) {
|
|
23292
|
-
return {
|
|
23534
|
+
return {
|
|
23535
|
+
type: "baseline",
|
|
23536
|
+
value: parseBaseline(value.value, maxSessions, maxKeys, formatVersion)
|
|
23537
|
+
};
|
|
23293
23538
|
}
|
|
23294
23539
|
if (value.type === "projection" && hasExactKeys4(value, ["type", "sessionId", "key", "value", "seq"]) && validIdentifier(value.sessionId) && validProjectionKey(value.key) && validSeq(value.seq)) {
|
|
23295
23540
|
const projection = measureProjection(value.key, value.value);
|
|
@@ -23302,12 +23547,12 @@ function parseControlFrame(value, maxSessions, maxKeys) {
|
|
|
23302
23547
|
bytes: projection.bytes
|
|
23303
23548
|
};
|
|
23304
23549
|
}
|
|
23305
|
-
if (value.type === "queue" && hasExactKeys4(value, ["type", "sessionId", "items"]) && validIdentifier(value.sessionId) && Array.isArray(value.items) && value.items.length <= MAX_COLLECTION_ITEMS) {
|
|
23550
|
+
if (formatVersion !== 4 && value.type === "queue" && hasExactKeys4(value, ["type", "sessionId", "items"]) && validIdentifier(value.sessionId) && Array.isArray(value.items) && value.items.length <= MAX_COLLECTION_ITEMS) {
|
|
23306
23551
|
for (const item of value.items)
|
|
23307
23552
|
parseQueueItem(item);
|
|
23308
23553
|
return { type: "queue", sessionId: value.sessionId };
|
|
23309
23554
|
}
|
|
23310
|
-
if (value.type === "jobs" && hasExactKeys4(value, ["type", "sessionId", "jobs"]) && validIdentifier(value.sessionId) && Array.isArray(value.jobs) && value.jobs.length <= MAX_COLLECTION_ITEMS) {
|
|
23555
|
+
if (formatVersion !== 4 && value.type === "jobs" && hasExactKeys4(value, ["type", "sessionId", "jobs"]) && validIdentifier(value.sessionId) && Array.isArray(value.jobs) && value.jobs.length <= MAX_COLLECTION_ITEMS) {
|
|
23311
23556
|
for (const job of value.jobs)
|
|
23312
23557
|
parseJob(job);
|
|
23313
23558
|
return { type: "jobs", sessionId: value.sessionId };
|
|
@@ -23319,6 +23564,7 @@ function parseSeed(value, maxKeys) {
|
|
|
23319
23564
|
}
|
|
23320
23565
|
var ModernControlStore = class {
|
|
23321
23566
|
#lifetime = new AbortController();
|
|
23567
|
+
#formatVersion;
|
|
23322
23568
|
#maxKeys;
|
|
23323
23569
|
#maxSessions;
|
|
23324
23570
|
#maxWaiters;
|
|
@@ -23339,6 +23585,7 @@ var ModernControlStore = class {
|
|
|
23339
23585
|
#readyResolve;
|
|
23340
23586
|
constructor(source, options = {}) {
|
|
23341
23587
|
this.#source = source;
|
|
23588
|
+
this.#formatVersion = options.profile?.sessionFormatVersion ?? 3;
|
|
23342
23589
|
this.#maxSessions = positiveInteger3(options.maxSessions ?? DEFAULT_MAX_SESSIONS, "maxSessions");
|
|
23343
23590
|
this.#maxKeys = positiveInteger3(options.maxKeysPerSession ?? DEFAULT_MAX_KEYS_PER_SESSION, "maxKeysPerSession");
|
|
23344
23591
|
this.#maxWaiters = positiveInteger3(options.maxWaiters ?? DEFAULT_MAX_WAITERS, "maxWaiters");
|
|
@@ -23507,7 +23754,7 @@ var ModernControlStore = class {
|
|
|
23507
23754
|
replaceBaseline(frame) {
|
|
23508
23755
|
this.#assertUsable();
|
|
23509
23756
|
try {
|
|
23510
|
-
const parsed = parseControlFrame(frame, this.#maxSessions, this.#maxKeys);
|
|
23757
|
+
const parsed = parseControlFrame(frame, this.#maxSessions, this.#maxKeys, this.#formatVersion);
|
|
23511
23758
|
if (parsed.type !== "baseline") {
|
|
23512
23759
|
throw storeError("protocolError", "Control baseline replacement requires a baseline frame");
|
|
23513
23760
|
}
|
|
@@ -23548,7 +23795,7 @@ var ModernControlStore = class {
|
|
|
23548
23795
|
return;
|
|
23549
23796
|
throw storeError(this.#opened ? "unavailable" : "protocolError", this.#opened ? "DeepSeek Harness control stream ended unexpectedly" : "DeepSeek Harness control stream ended before its baseline");
|
|
23550
23797
|
}
|
|
23551
|
-
const frame = parseControlFrame(next.value, this.#maxSessions, this.#maxKeys);
|
|
23798
|
+
const frame = parseControlFrame(next.value, this.#maxSessions, this.#maxKeys, this.#formatVersion);
|
|
23552
23799
|
if (!generationOpened && frame.type !== "baseline") {
|
|
23553
23800
|
throw storeError("protocolError", "DeepSeek Harness control stream omitted its baseline");
|
|
23554
23801
|
}
|
|
@@ -24679,7 +24926,7 @@ function validateSecrets(value) {
|
|
|
24679
24926
|
}
|
|
24680
24927
|
return value;
|
|
24681
24928
|
}
|
|
24682
|
-
function parseDescribe(value) {
|
|
24929
|
+
function parseDescribe(value, profile) {
|
|
24683
24930
|
assertBoundedJson2(value);
|
|
24684
24931
|
if (!isPlainRecord4(value) || !exactKeys3(value, ["writable", "hasDocument", "namespaces"])) {
|
|
24685
24932
|
throw permissionError("protocolError", "DeepSeek Harness returned an invalid settings response");
|
|
@@ -24693,7 +24940,7 @@ function parseDescribe(value) {
|
|
|
24693
24940
|
const namespaceIds = [];
|
|
24694
24941
|
const permissionNamespaces = [];
|
|
24695
24942
|
for (const candidate of value.namespaces) {
|
|
24696
|
-
if (!isPlainRecord4(candidate) || !exactKeys3(candidate, ["ns", "schema", "value", "applies", "secrets", "revision"], ["base", "user"]) || candidate.applies !== "live" && candidate.applies !== "restart" || !validRevision(candidate.revision)) {
|
|
24943
|
+
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)) {
|
|
24697
24944
|
throw permissionError("protocolError", "DeepSeek Harness returned an invalid settings namespace");
|
|
24698
24945
|
}
|
|
24699
24946
|
const ns = nonBlankString2(candidate.ns, MAX_NAMESPACE_ID_LENGTH, "settings namespace id");
|
|
@@ -24731,7 +24978,7 @@ function permissionSection(value, requireDefault, knownIds, area) {
|
|
|
24731
24978
|
}
|
|
24732
24979
|
}
|
|
24733
24980
|
}
|
|
24734
|
-
function catalogFromNamespace(view) {
|
|
24981
|
+
function catalogFromNamespace(view, profile) {
|
|
24735
24982
|
if (view.applies !== "live") {
|
|
24736
24983
|
throw permissionError("protocolError", "DeepSeek Harness permission settings are not live");
|
|
24737
24984
|
}
|
|
@@ -24750,10 +24997,14 @@ function catalogFromNamespace(view) {
|
|
|
24750
24997
|
}
|
|
24751
24998
|
const field = dictionary.defaultPreset;
|
|
24752
24999
|
if (field.meta?.required !== true) {
|
|
25000
|
+
if (profile.sessionFormatVersion === 4)
|
|
25001
|
+
return null;
|
|
24753
25002
|
throw permissionError("protocolError", "DeepSeek Harness permission default is not required");
|
|
24754
25003
|
}
|
|
24755
25004
|
const choices = field.type === "union" ? field.list : field.type === "const" ? [field] : void 0;
|
|
24756
25005
|
if (!Array.isArray(choices) || choices.length === 0) {
|
|
25006
|
+
if (profile.sessionFormatVersion === 4)
|
|
25007
|
+
return null;
|
|
24757
25008
|
throw permissionError("protocolError", "DeepSeek Harness permission schema has no preset choices");
|
|
24758
25009
|
}
|
|
24759
25010
|
if (choices.length > HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH) {
|
|
@@ -24793,18 +25044,18 @@ function catalogFromNamespace(view) {
|
|
|
24793
25044
|
throw permissionError("protocolError", "DeepSeek Harness returned an unusable permission catalog");
|
|
24794
25045
|
}
|
|
24795
25046
|
}
|
|
24796
|
-
function parseModernPermissionModeCatalog(value) {
|
|
24797
|
-
const permission = parseDescribe(value);
|
|
24798
|
-
return permission ? catalogFromNamespace(permission) : null;
|
|
25047
|
+
function parseModernPermissionModeCatalog(value, profile = DEEPSEEK_V015_PROFILE) {
|
|
25048
|
+
const permission = parseDescribe(value, profile);
|
|
25049
|
+
return permission ? catalogFromNamespace(permission, profile) : null;
|
|
24799
25050
|
}
|
|
24800
|
-
async function loadModernPermissionModeCatalog(remote, signal) {
|
|
25051
|
+
async function loadModernPermissionModeCatalog(remote, signal, profile = DEEPSEEK_V015_PROFILE) {
|
|
24801
25052
|
try {
|
|
24802
25053
|
const result = await remote.call("settings/describe", {}, signal);
|
|
24803
25054
|
if (!result.ok) {
|
|
24804
25055
|
const safe = sanitizeModernRemoteFailure(result.error);
|
|
24805
25056
|
throw permissionError("remoteError", `DeepSeek Harness settings/describe failed: ${safe.message}`, safe.code);
|
|
24806
25057
|
}
|
|
24807
|
-
return parseModernPermissionModeCatalog(result.value);
|
|
25058
|
+
return parseModernPermissionModeCatalog(result.value, profile);
|
|
24808
25059
|
} catch (error51) {
|
|
24809
25060
|
if (error51 instanceof ModernPermissionModeError)
|
|
24810
25061
|
throw error51;
|
|
@@ -24860,8 +25111,10 @@ function parseProjectionValue(value, catalog) {
|
|
|
24860
25111
|
}
|
|
24861
25112
|
return current.data;
|
|
24862
25113
|
}
|
|
24863
|
-
function readModernPermissionModeState(row, catalog) {
|
|
25114
|
+
function readModernPermissionModeState(row, catalog, profile) {
|
|
24864
25115
|
if (!catalog) {
|
|
25116
|
+
if (profile?.sessionFormatVersion === 4)
|
|
25117
|
+
return void 0;
|
|
24865
25118
|
if (row) {
|
|
24866
25119
|
throw permissionError("protocolError", "DeepSeek Harness exposed permissions without a settings catalog");
|
|
24867
25120
|
}
|
|
@@ -24996,7 +25249,7 @@ function readModernConfigurationSnapshot(input) {
|
|
|
24996
25249
|
throw configurationError("protocolError", "DeepSeek Harness control state is detached");
|
|
24997
25250
|
}
|
|
24998
25251
|
const model = readModernModelSelectionState(rows[MODERN_MODEL_SELECTION_PROJECTION_KEY], input.modelCatalog);
|
|
24999
|
-
const permission = readModernPermissionModeState(rows[MODERN_PERMISSION_PROJECTION_KEY], input.permissionModes);
|
|
25252
|
+
const permission = readModernPermissionModeState(rows[MODERN_PERMISSION_PROJECTION_KEY], input.permissionModes, input.profile);
|
|
25000
25253
|
return {
|
|
25001
25254
|
model,
|
|
25002
25255
|
state: stateForSelection(input.nativeRef, model.selection, input.modelCatalog, permission?.permissionModeId),
|
|
@@ -25971,10 +26224,14 @@ function parseQuestionOption(value) {
|
|
|
25971
26224
|
};
|
|
25972
26225
|
}
|
|
25973
26226
|
function parseQuestionIntent(value) {
|
|
25974
|
-
if (!isPlainRecord6(value) || !
|
|
26227
|
+
if (!isPlainRecord6(value) || !hasOnlyKeys(value, ["kind", "approve"], ["callId"]) || value.kind !== "plan-review" || !nonBlankString3(value.approve) || Object.hasOwn(value, "callId") && !nonBlankString3(value.callId)) {
|
|
25975
26228
|
throw invalidFrame();
|
|
25976
26229
|
}
|
|
25977
|
-
return {
|
|
26230
|
+
return {
|
|
26231
|
+
kind: "plan-review",
|
|
26232
|
+
approve: value.approve,
|
|
26233
|
+
...typeof value.callId === "string" ? { callId: value.callId } : {}
|
|
26234
|
+
};
|
|
25978
26235
|
}
|
|
25979
26236
|
function parseQuestionAnswer(value) {
|
|
25980
26237
|
if (!isPlainRecord6(value) || !hasExactKeys5(value, ["answers"]) || !Array.isArray(value.answers)) {
|
|
@@ -26758,6 +27015,13 @@ var KNOWN_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
26758
27015
|
"user/message",
|
|
26759
27016
|
"web/deepseek-search-llm-request"
|
|
26760
27017
|
]);
|
|
27018
|
+
var V4_EVENT_TYPES = /* @__PURE__ */ new Set(["developer/message", "image/offload", "workspace/changes"]);
|
|
27019
|
+
function knownEvent(type, profile) {
|
|
27020
|
+
return KNOWN_EVENT_TYPES.has(type) || profile.sessionFormatVersion === 4 && V4_EVENT_TYPES.has(type);
|
|
27021
|
+
}
|
|
27022
|
+
function surfaceEvent(type, profile) {
|
|
27023
|
+
return SURFACE_EVENT_TYPES.has(type) || profile.sessionFormatVersion === 4 && type === "developer/message";
|
|
27024
|
+
}
|
|
26761
27025
|
var SURFACE_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
26762
27026
|
"system/message",
|
|
26763
27027
|
"user/message",
|
|
@@ -26776,7 +27040,10 @@ var ModernEventValidator = class {
|
|
|
26776
27040
|
surface: [],
|
|
26777
27041
|
pendingCalls: /* @__PURE__ */ new Set(),
|
|
26778
27042
|
commandStates: /* @__PURE__ */ new Map(),
|
|
26779
|
-
commandEventSeqs: /* @__PURE__ */ new Set()
|
|
27043
|
+
commandEventSeqs: /* @__PURE__ */ new Set(),
|
|
27044
|
+
requestHeaders: /* @__PURE__ */ new Map(),
|
|
27045
|
+
offloadedImages: /* @__PURE__ */ new Set(),
|
|
27046
|
+
toolCalls: /* @__PURE__ */ new Map()
|
|
26780
27047
|
};
|
|
26781
27048
|
constructor(maxEvents = MODERN_HISTORY_MAX_EVENTS, profile = DEEPSEEK_V012_PROFILE) {
|
|
26782
27049
|
this.#maxEvents = boundedInteger(maxEvents, "maxEvents", 1);
|
|
@@ -26789,16 +27056,16 @@ var ModernEventValidator = class {
|
|
|
26789
27056
|
if (event.seq !== trace.count)
|
|
26790
27057
|
fail("Modern history is not a contiguous zero-based prefix");
|
|
26791
27058
|
trace.count += 1;
|
|
26792
|
-
if (
|
|
27059
|
+
if (hasDeepSeekModernStream(this.#profile) && !knownEvent(event.type, this.#profile) && event.ignorable === true)
|
|
26793
27060
|
return;
|
|
26794
|
-
if (!
|
|
27061
|
+
if (!surfaceEvent(event.type, this.#profile)) {
|
|
26795
27062
|
if (event.surfaceOp !== void 0 || event.sourceEventSeqs !== void 0) {
|
|
26796
27063
|
fail("Modern history has surface metadata on a log-only event");
|
|
26797
27064
|
}
|
|
26798
27065
|
} else if (event.surfaceOp === void 0) {
|
|
26799
27066
|
fail("Modern history surface event omitted surfaceOp");
|
|
26800
27067
|
}
|
|
26801
|
-
if (!
|
|
27068
|
+
if (!knownEvent(event.type, this.#profile)) {
|
|
26802
27069
|
if (event.ignorable === true)
|
|
26803
27070
|
return;
|
|
26804
27071
|
fail("Modern history contains an unknown required event");
|
|
@@ -26822,10 +27089,13 @@ var ModernEventValidator = class {
|
|
|
26822
27089
|
case "turn/end": {
|
|
26823
27090
|
exactKeys2(data, ["turn", "reason"]);
|
|
26824
27091
|
const turn = positiveInteger(data.turn, "turn/end turn");
|
|
26825
|
-
validateTurnReason(data.reason);
|
|
27092
|
+
validateTurnReason(data.reason, this.#profile);
|
|
26826
27093
|
if (trace.openTurn !== turn || trace.openStep !== null) {
|
|
26827
27094
|
fail("Modern history has an invalid turn/end boundary");
|
|
26828
27095
|
}
|
|
27096
|
+
if (this.#profile.sessionFormatVersion === 4 && trace.toolCalls.size > 0) {
|
|
27097
|
+
fail("Modern history turn/end leaves unresolved tool calls");
|
|
27098
|
+
}
|
|
26829
27099
|
trace.openTurn = null;
|
|
26830
27100
|
trace.nextTurn += 1;
|
|
26831
27101
|
return;
|
|
@@ -26842,6 +27112,9 @@ var ModernEventValidator = class {
|
|
|
26842
27112
|
case "step/end": {
|
|
26843
27113
|
exactKeys2(data, ["turn", "step"]);
|
|
26844
27114
|
requireOpenStep(trace, data, "step/end");
|
|
27115
|
+
if (this.#profile.sessionFormatVersion === 4 && trace.toolCalls.size > 0) {
|
|
27116
|
+
fail("Modern history step/end leaves unresolved tool calls");
|
|
27117
|
+
}
|
|
26845
27118
|
trace.openStep = null;
|
|
26846
27119
|
trace.nextStep += 1;
|
|
26847
27120
|
trace.pendingCalls.clear();
|
|
@@ -26850,6 +27123,10 @@ var ModernEventValidator = class {
|
|
|
26850
27123
|
case "user/message":
|
|
26851
27124
|
validateUserMessage(data, this.#profile);
|
|
26852
27125
|
return;
|
|
27126
|
+
case "developer/message":
|
|
27127
|
+
requireOpenStep(trace, data, "developer/message");
|
|
27128
|
+
validateDeveloperHeader(event, trace);
|
|
27129
|
+
return;
|
|
26853
27130
|
case "system/message":
|
|
26854
27131
|
requireOpenStep(trace, data, "system/message");
|
|
26855
27132
|
return;
|
|
@@ -26861,6 +27138,8 @@ var ModernEventValidator = class {
|
|
|
26861
27138
|
case "assistant/message": {
|
|
26862
27139
|
requireOpenStep(trace, data, "assistant/message");
|
|
26863
27140
|
validateAssistantMessage(data.message, this.#profile);
|
|
27141
|
+
if (this.#profile.sessionFormatVersion === 4)
|
|
27142
|
+
registerV4ToolCalls(data.message, trace);
|
|
26864
27143
|
if (data.interrupted !== void 0 && data.interrupted !== true) {
|
|
26865
27144
|
fail("Modern history assistant/message has invalid interrupted marker");
|
|
26866
27145
|
}
|
|
@@ -26874,10 +27153,18 @@ var ModernEventValidator = class {
|
|
|
26874
27153
|
exactKeys2(data, ["turn", "step", "callId", "name", "arguments"]);
|
|
26875
27154
|
requireOpenStep(trace, data, "tool/call");
|
|
26876
27155
|
const callId = requiredString(data.callId, "tool/call callId");
|
|
26877
|
-
requiredString(data.name, "tool/call name");
|
|
27156
|
+
const name = requiredString(data.name, "tool/call name");
|
|
26878
27157
|
if (typeof data.arguments !== "string" || trace.pendingCalls.has(callId)) {
|
|
26879
27158
|
fail("Modern history contains an invalid tool/call");
|
|
26880
27159
|
}
|
|
27160
|
+
if (this.#profile.sessionFormatVersion === 4) {
|
|
27161
|
+
const tool = trace.toolCalls.get(callId);
|
|
27162
|
+
if (!tool || tool.started || tool.name !== name || tool.arguments !== data.arguments) {
|
|
27163
|
+
fail("Modern history tool/call does not match its advertised tool call");
|
|
27164
|
+
}
|
|
27165
|
+
tool.started = true;
|
|
27166
|
+
return;
|
|
27167
|
+
}
|
|
26881
27168
|
trace.pendingCalls.add(callId);
|
|
26882
27169
|
return;
|
|
26883
27170
|
}
|
|
@@ -26885,10 +27172,16 @@ var ModernEventValidator = class {
|
|
|
26885
27172
|
requiredOptionalKeys(data, ["turn", "step", "message"], ["error", "meta"]);
|
|
26886
27173
|
const callId = validateToolResultMessage(data.message, this.#profile);
|
|
26887
27174
|
if (data.error !== void 0)
|
|
26888
|
-
validateToolError(data.error);
|
|
27175
|
+
validateToolError(data.error, this.#profile);
|
|
26889
27176
|
if (event.surfaceOp === "append") {
|
|
26890
27177
|
requireOpenStep(trace, data, "tool/result");
|
|
26891
|
-
if (
|
|
27178
|
+
if (this.#profile.sessionFormatVersion === 4) {
|
|
27179
|
+
const tool = trace.toolCalls.get(callId);
|
|
27180
|
+
if (!tool || !tool.started && !isV4ForkToolResult(data, event.sourceEventSeqs, event.seq)) {
|
|
27181
|
+
fail("Modern history contains an unmatched tool/result");
|
|
27182
|
+
}
|
|
27183
|
+
trace.toolCalls.delete(callId);
|
|
27184
|
+
} else if (!trace.pendingCalls.delete(callId)) {
|
|
26892
27185
|
fail("Modern history contains an unmatched tool/result");
|
|
26893
27186
|
}
|
|
26894
27187
|
} else if (trace.openTurn === null) {
|
|
@@ -26900,6 +27193,7 @@ var ModernEventValidator = class {
|
|
|
26900
27193
|
validateRequestHeader(data);
|
|
26901
27194
|
if (trace.openTurn === null)
|
|
26902
27195
|
fail("Modern history request/header is outside a Turn");
|
|
27196
|
+
trace.requestHeaders.set(event.seq, data.header);
|
|
26903
27197
|
return;
|
|
26904
27198
|
case "request/context":
|
|
26905
27199
|
validateRequestContext(data, this.#profile);
|
|
@@ -26911,6 +27205,11 @@ var ModernEventValidator = class {
|
|
|
26911
27205
|
return;
|
|
26912
27206
|
case "session/end-seed":
|
|
26913
27207
|
return;
|
|
27208
|
+
case "image/offload":
|
|
27209
|
+
validateImageOffload(data, trace);
|
|
27210
|
+
return;
|
|
27211
|
+
case "workspace/changes":
|
|
27212
|
+
return;
|
|
26914
27213
|
case "agent-preset/selected":
|
|
26915
27214
|
exactKeys2(data, ["agentPreset"]);
|
|
26916
27215
|
requiredString(data.agentPreset, "agent-preset/selected agentPreset");
|
|
@@ -27040,20 +27339,113 @@ var ModernEventValidator = class {
|
|
|
27040
27339
|
}
|
|
27041
27340
|
}
|
|
27042
27341
|
};
|
|
27342
|
+
function registerV4ToolCalls(value, trace) {
|
|
27343
|
+
if (!isRecord4(value) || !Array.isArray(value.content))
|
|
27344
|
+
return;
|
|
27345
|
+
for (const block of value.content) {
|
|
27346
|
+
if (!isRecord4(block) || block.type !== "tool-call")
|
|
27347
|
+
continue;
|
|
27348
|
+
const callId = requiredString(block.id, "assistant tool-call id");
|
|
27349
|
+
const name = requiredString(block.name, "assistant tool-call name");
|
|
27350
|
+
if (typeof block.arguments !== "string" || trace.toolCalls.has(callId)) {
|
|
27351
|
+
fail("Modern history assistant/message repeats an advertised tool call");
|
|
27352
|
+
}
|
|
27353
|
+
trace.toolCalls.set(callId, { name, arguments: block.arguments, started: false });
|
|
27354
|
+
}
|
|
27355
|
+
}
|
|
27356
|
+
function isV4ForkToolResult(data, sourceEventSeqs, seq) {
|
|
27357
|
+
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) {
|
|
27358
|
+
return false;
|
|
27359
|
+
}
|
|
27360
|
+
const content = data.message.content[0];
|
|
27361
|
+
return isRecord4(content) && content.type === "text" && typeof content.text === "string" && data.message.id.endsWith(`-${seq}`);
|
|
27362
|
+
}
|
|
27363
|
+
function validateDeveloperHeader(event, trace) {
|
|
27364
|
+
const data = event.data;
|
|
27365
|
+
if (data.headerSeq === void 0)
|
|
27366
|
+
return;
|
|
27367
|
+
const header = trace.requestHeaders.get(data.headerSeq);
|
|
27368
|
+
if (!header || !Array.isArray(header.tools)) {
|
|
27369
|
+
fail("Modern history developer/message references an invalid request/header");
|
|
27370
|
+
}
|
|
27371
|
+
const message = data.message;
|
|
27372
|
+
for (const block of message.content) {
|
|
27373
|
+
if (!isRecord4(block) || block.type !== "tool-addition")
|
|
27374
|
+
continue;
|
|
27375
|
+
const matching = header.tools.filter((tool) => isRecord4(tool) && tool.name === block.toolName);
|
|
27376
|
+
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) {
|
|
27377
|
+
fail("Modern history developer/message references an invalid tool definition");
|
|
27378
|
+
}
|
|
27379
|
+
}
|
|
27380
|
+
}
|
|
27381
|
+
function strictIndex(value, label) {
|
|
27382
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0 || Object.is(value, -0)) {
|
|
27383
|
+
fail(`Modern history ${label} is malformed`);
|
|
27384
|
+
}
|
|
27385
|
+
return value;
|
|
27386
|
+
}
|
|
27387
|
+
function validateImageOffload(data, trace) {
|
|
27388
|
+
const seen = /* @__PURE__ */ new Set();
|
|
27389
|
+
for (const target of data.targets) {
|
|
27390
|
+
if (!isRecord4(target))
|
|
27391
|
+
fail("Modern history image/offload target is malformed");
|
|
27392
|
+
exactKeys2(target, ["seq", "imageIndexes"]);
|
|
27393
|
+
const seq = strictIndex(target.seq, "image/offload target seq");
|
|
27394
|
+
if (seen.has(seq))
|
|
27395
|
+
fail("Modern history image/offload repeats a target");
|
|
27396
|
+
seen.add(seq);
|
|
27397
|
+
const source = trace.surface.find((event) => event.seq === seq);
|
|
27398
|
+
if (!source || source.type !== "user/message" && source.type !== "tool/result") {
|
|
27399
|
+
fail("Modern history image/offload target is not a current message");
|
|
27400
|
+
}
|
|
27401
|
+
const sourceData = source.type === "user/message" ? source.data : source.data.message;
|
|
27402
|
+
const content = isRecord4(sourceData) ? sourceData.content : void 0;
|
|
27403
|
+
if (!Array.isArray(content) || !Array.isArray(target.imageIndexes) || !target.imageIndexes.length) {
|
|
27404
|
+
fail("Modern history image/offload indexes are malformed");
|
|
27405
|
+
}
|
|
27406
|
+
const images = [];
|
|
27407
|
+
const collectImages = (value) => {
|
|
27408
|
+
if (!Array.isArray(value))
|
|
27409
|
+
return;
|
|
27410
|
+
for (const block of value) {
|
|
27411
|
+
if (!isRecord4(block))
|
|
27412
|
+
continue;
|
|
27413
|
+
if (block.type === "image")
|
|
27414
|
+
images.push(block);
|
|
27415
|
+
if (Array.isArray(block.content))
|
|
27416
|
+
collectImages(block.content);
|
|
27417
|
+
}
|
|
27418
|
+
};
|
|
27419
|
+
collectImages(content);
|
|
27420
|
+
let previous = -1;
|
|
27421
|
+
for (const value of target.imageIndexes) {
|
|
27422
|
+
const index = strictIndex(value, "image/offload index");
|
|
27423
|
+
const image = images[index];
|
|
27424
|
+
if (index <= previous || !isRecord4(image) || image.offloaded === true || trace.offloadedImages.has(`${seq}:${index}`)) {
|
|
27425
|
+
fail("Modern history image/offload references an invalid image occurrence");
|
|
27426
|
+
}
|
|
27427
|
+
trace.offloadedImages.add(`${seq}:${index}`);
|
|
27428
|
+
previous = index;
|
|
27429
|
+
}
|
|
27430
|
+
}
|
|
27431
|
+
}
|
|
27043
27432
|
function acceptSurfaceEvent(trace, event, profile) {
|
|
27044
|
-
if (!
|
|
27433
|
+
if (!surfaceEvent(event.type, profile))
|
|
27045
27434
|
return;
|
|
27046
27435
|
const sources = event.sourceEventSeqs;
|
|
27047
|
-
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")) {
|
|
27436
|
+
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"))) {
|
|
27048
27437
|
fail("Modern history surface event has invalid sourceEventSeqs");
|
|
27049
27438
|
}
|
|
27050
27439
|
const op = event.surfaceOp;
|
|
27051
27440
|
if (op === "append") {
|
|
27441
|
+
if (profile.sessionFormatVersion === 4 && event.type === "system/message" && trace.surface.length > 0 && !trace.surface.some((surface) => surface.type === "system/message")) {
|
|
27442
|
+
fail("Modern history system/message must remain the protected surface head");
|
|
27443
|
+
}
|
|
27052
27444
|
trace.surface.push(event);
|
|
27053
27445
|
return;
|
|
27054
27446
|
}
|
|
27055
|
-
const start =
|
|
27056
|
-
const end =
|
|
27447
|
+
const start = hasDeepSeekModernStream(profile) ? "startSeq" : "start";
|
|
27448
|
+
const end = hasDeepSeekModernStream(profile) ? "endSeq" : "end";
|
|
27057
27449
|
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)) {
|
|
27058
27450
|
fail("Modern history surface event has an invalid replacement operation");
|
|
27059
27451
|
}
|
|
@@ -27071,17 +27463,20 @@ function acceptSurfaceEvent(trace, event, profile) {
|
|
|
27071
27463
|
fail("Modern history system head may only be replaced by one system/message");
|
|
27072
27464
|
}
|
|
27073
27465
|
if (event.type === "tool/result") {
|
|
27074
|
-
if (shadowed.length !== 1 || shadowed[0]?.type !== "tool/result" || !isDeepStrictEqual6(comparableToolResultData(shadowed[0]), comparableToolResultData(event))) {
|
|
27466
|
+
if (shadowed.length !== 1 || shadowed[0]?.type !== "tool/result" || !isDeepStrictEqual6(comparableToolResultData(shadowed[0], profile), comparableToolResultData(event, profile))) {
|
|
27075
27467
|
fail("Modern history tool/result replacement changed more than result content");
|
|
27076
27468
|
}
|
|
27077
27469
|
}
|
|
27078
27470
|
trace.surface.splice(startIndex, endIndex - startIndex + 1, event);
|
|
27079
27471
|
}
|
|
27080
|
-
function comparableToolResultData(event) {
|
|
27472
|
+
function comparableToolResultData(event, profile) {
|
|
27081
27473
|
const data = event.data;
|
|
27082
|
-
if (!isRecord4(data) || !isRecord4(data.message) || !Array.isArray(data.message.content) || !isRecord4(data.message.content[0])) {
|
|
27474
|
+
if (!isRecord4(data) || !isRecord4(data.message) || !Array.isArray(data.message.content) || profile.sessionFormatVersion !== 4 && !isRecord4(data.message.content[0])) {
|
|
27083
27475
|
fail("Modern history tool/result replacement is malformed");
|
|
27084
27476
|
}
|
|
27477
|
+
if (profile.sessionFormatVersion === 4) {
|
|
27478
|
+
return { ...data, message: { ...data.message, content: null } };
|
|
27479
|
+
}
|
|
27085
27480
|
return {
|
|
27086
27481
|
...data,
|
|
27087
27482
|
message: {
|
|
@@ -27104,6 +27499,8 @@ function resolveModernForkBoundary(events, checkpointId, profile = DEEPSEEK_V012
|
|
|
27104
27499
|
if (atSeq === null || events[atSeq]?.seq !== atSeq || events[atSeq]?.type !== "turn/end") {
|
|
27105
27500
|
return null;
|
|
27106
27501
|
}
|
|
27502
|
+
if (profile.sessionFormatVersion === 4)
|
|
27503
|
+
return { atSeq, events: events.slice(0, atSeq + 1) };
|
|
27107
27504
|
let cut = atSeq + 1;
|
|
27108
27505
|
while (cut < events.length && events[cut]?.type !== "turn/start")
|
|
27109
27506
|
cut += 1;
|
|
@@ -27152,7 +27549,7 @@ function projectModernHistory(input) {
|
|
|
27152
27549
|
};
|
|
27153
27550
|
for (const [index, event] of input.events.entries()) {
|
|
27154
27551
|
validator.accept(event);
|
|
27155
|
-
if (!
|
|
27552
|
+
if (!knownEvent(event.type, profile) || !isRecord4(event.data))
|
|
27156
27553
|
continue;
|
|
27157
27554
|
const data = event.data;
|
|
27158
27555
|
switch (event.type) {
|
|
@@ -27163,6 +27560,7 @@ function projectModernHistory(input) {
|
|
|
27163
27560
|
input: [],
|
|
27164
27561
|
items: [],
|
|
27165
27562
|
tools: /* @__PURE__ */ new Map(),
|
|
27563
|
+
advertisedTools: /* @__PURE__ */ new Map(),
|
|
27166
27564
|
model: effectiveModel
|
|
27167
27565
|
};
|
|
27168
27566
|
break;
|
|
@@ -27241,7 +27639,7 @@ function projectModernHistory(input) {
|
|
|
27241
27639
|
harnessId,
|
|
27242
27640
|
nativeSessionId: input.sessionId,
|
|
27243
27641
|
formatVersion: 1,
|
|
27244
|
-
...
|
|
27642
|
+
...hasDeepSeekModernStream(profile) ? { locator: { dshVersion: profile.version } } : {}
|
|
27245
27643
|
});
|
|
27246
27644
|
const state = {
|
|
27247
27645
|
nativeRef,
|
|
@@ -27273,7 +27671,7 @@ function modernCheckpointRef(harnessId, sessionId, seq, profile = DEEPSEEK_V012_
|
|
|
27273
27671
|
nativeSessionId: sessionId,
|
|
27274
27672
|
checkpointId: `${profile.checkpointPrefix}${seq}`,
|
|
27275
27673
|
formatVersion: 1,
|
|
27276
|
-
...
|
|
27674
|
+
...hasDeepSeekModernStream(profile) ? { locator: { dshVersion: profile.version } } : {}
|
|
27277
27675
|
});
|
|
27278
27676
|
}
|
|
27279
27677
|
function modernItemId(sessionId, key) {
|
|
@@ -27281,6 +27679,13 @@ function modernItemId(sessionId, key) {
|
|
|
27281
27679
|
}
|
|
27282
27680
|
function projectAssistantMessage(turn, sessionId, data) {
|
|
27283
27681
|
const message = data.message;
|
|
27682
|
+
if (Array.isArray(message.content)) {
|
|
27683
|
+
for (const block of message.content) {
|
|
27684
|
+
if (isRecord4(block) && block.type === "tool-call" && typeof block.id === "string" && typeof block.name === "string" && typeof block.arguments === "string") {
|
|
27685
|
+
turn.advertisedTools.set(block.id, { toolName: block.name, arguments: block.arguments });
|
|
27686
|
+
}
|
|
27687
|
+
}
|
|
27688
|
+
}
|
|
27284
27689
|
const reasoning2 = contentByType(message.content, "reasoning");
|
|
27285
27690
|
if (reasoning2) {
|
|
27286
27691
|
const item = {
|
|
@@ -27313,15 +27718,32 @@ function projectToolCall(turn, sessionId, data, seq) {
|
|
|
27313
27718
|
const itemIndex = turn.items.length;
|
|
27314
27719
|
turn.items.push({ item, outcome: incompleteToolOutcome(item.toolName) });
|
|
27315
27720
|
turn.tools.set(data.callId, { itemIndex, item, toolName: item.toolName });
|
|
27721
|
+
turn.advertisedTools.delete(data.callId);
|
|
27316
27722
|
}
|
|
27317
27723
|
function projectToolResultEvent(turn, sessionId, data, seq, limit) {
|
|
27318
27724
|
const result = projectToolResult(data.message, limit);
|
|
27319
27725
|
if (!result)
|
|
27320
27726
|
fail("Modern history contains an unprojectable tool/result");
|
|
27321
|
-
|
|
27322
|
-
if (!tool)
|
|
27727
|
+
let tool = turn.tools.get(result.callId);
|
|
27728
|
+
if (!tool) {
|
|
27729
|
+
const advertised = turn.advertisedTools.get(result.callId);
|
|
27730
|
+
if (advertised && isForkedToolResult(data, result.callId, seq)) {
|
|
27731
|
+
const item2 = {
|
|
27732
|
+
type: "toolExecution",
|
|
27733
|
+
itemId: modernItemId(sessionId, `event:${seq}:tool`),
|
|
27734
|
+
toolName: advertised.toolName,
|
|
27735
|
+
arguments: parseArguments(advertised.arguments)
|
|
27736
|
+
};
|
|
27737
|
+
const itemIndex = turn.items.length;
|
|
27738
|
+
turn.items.push({ item: item2, outcome: incompleteToolOutcome(item2.toolName) });
|
|
27739
|
+
tool = { itemIndex, item: item2, toolName: item2.toolName };
|
|
27740
|
+
}
|
|
27741
|
+
}
|
|
27742
|
+
if (!tool) {
|
|
27323
27743
|
fail("Modern history contains an unmatched projected tool/result");
|
|
27744
|
+
}
|
|
27324
27745
|
turn.tools.delete(result.callId);
|
|
27746
|
+
turn.advertisedTools.delete(result.callId);
|
|
27325
27747
|
const item = { ...tool.item, ...result.output ? { output: result.output } : {} };
|
|
27326
27748
|
turn.items[tool.itemIndex] = {
|
|
27327
27749
|
item,
|
|
@@ -27347,6 +27769,10 @@ function projectToolResultEvent(turn, sessionId, data, seq, limit) {
|
|
|
27347
27769
|
}
|
|
27348
27770
|
}
|
|
27349
27771
|
}
|
|
27772
|
+
function isForkedToolResult(data, callId, seq) {
|
|
27773
|
+
const message = data.message;
|
|
27774
|
+
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}`;
|
|
27775
|
+
}
|
|
27350
27776
|
function finishIncompleteTools(turn, outcome) {
|
|
27351
27777
|
for (const tool of turn.tools.values())
|
|
27352
27778
|
turn.items[tool.itemIndex] = { item: tool.item, outcome };
|
|
@@ -27417,12 +27843,15 @@ function stepPosition(data, label) {
|
|
|
27417
27843
|
};
|
|
27418
27844
|
}
|
|
27419
27845
|
function validateUserMessage(data, profile = DEEPSEEK_V012_PROFILE) {
|
|
27420
|
-
|
|
27846
|
+
if (profile.sessionFormatVersion === 4)
|
|
27847
|
+
requiredFields2(data, ["id", "role", "content", "source"]);
|
|
27848
|
+
else
|
|
27849
|
+
exactKeys2(data, ["id", "role", "content", "source"]);
|
|
27421
27850
|
requiredString(data.id, "user/message id");
|
|
27422
27851
|
if (data.role !== "user")
|
|
27423
27852
|
fail("Modern history user/message has an invalid role");
|
|
27424
27853
|
profile.validateContent(data.content);
|
|
27425
|
-
if (!isRecord4(data.source) || !requiredString(data.source.kind, "user/message source kind")) {
|
|
27854
|
+
if (!isRecord4(data.source) || !requiredString(data.source.kind, "user/message source kind") || profile.sessionFormatVersion === 4 && data.source.kind === "plugin") {
|
|
27426
27855
|
fail("Modern history user/message has an invalid source");
|
|
27427
27856
|
}
|
|
27428
27857
|
if (data.source.kind === "user" && data.source.rpcId !== void 0) {
|
|
@@ -27432,7 +27861,10 @@ function validateUserMessage(data, profile = DEEPSEEK_V012_PROFILE) {
|
|
|
27432
27861
|
function validateAssistantMessage(value, profile = DEEPSEEK_V012_PROFILE) {
|
|
27433
27862
|
if (!isRecord4(value))
|
|
27434
27863
|
fail("Modern history assistant/message is malformed");
|
|
27435
|
-
|
|
27864
|
+
if (profile.sessionFormatVersion === 4)
|
|
27865
|
+
requiredFields2(value, ["id", "role", "content", "source"]);
|
|
27866
|
+
else
|
|
27867
|
+
exactKeys2(value, ["id", "role", "content", "source"]);
|
|
27436
27868
|
requiredString(value.id, "assistant/message id");
|
|
27437
27869
|
if (value.role !== "assistant")
|
|
27438
27870
|
fail("Modern history assistant/message has an invalid role");
|
|
@@ -27444,6 +27876,19 @@ function validateAssistantMessage(value, profile = DEEPSEEK_V012_PROFILE) {
|
|
|
27444
27876
|
function validateToolResultMessage(value, profile = DEEPSEEK_V012_PROFILE) {
|
|
27445
27877
|
if (!isRecord4(value))
|
|
27446
27878
|
fail("Modern history tool/result message is malformed");
|
|
27879
|
+
if (profile.sessionFormatVersion === 4) {
|
|
27880
|
+
requiredFields2(value, ["id", "role", "content", "source", "toolCallId"]);
|
|
27881
|
+
requiredString(value.id, "tool/result message id");
|
|
27882
|
+
if (value.role !== "tool" || !isRecord4(value.source) || value.source.kind !== "tool") {
|
|
27883
|
+
fail("Modern history tool/result message has an invalid role or source");
|
|
27884
|
+
}
|
|
27885
|
+
const callId2 = requiredString(value.source.callId, "tool/result source callId");
|
|
27886
|
+
if (value.toolCallId !== callId2 || value.isError !== void 0 && typeof value.isError !== "boolean") {
|
|
27887
|
+
fail("Modern history tool/result message has invalid callId or isError");
|
|
27888
|
+
}
|
|
27889
|
+
profile.validateContent(value.content);
|
|
27890
|
+
return callId2;
|
|
27891
|
+
}
|
|
27447
27892
|
exactKeys2(value, ["id", "role", "content", "source"]);
|
|
27448
27893
|
requiredString(value.id, "tool/result message id");
|
|
27449
27894
|
if (value.role !== "user" || !isRecord4(value.source) || value.source.kind !== "tool") {
|
|
@@ -27464,6 +27909,11 @@ function validateToolResultMessage(value, profile = DEEPSEEK_V012_PROFILE) {
|
|
|
27464
27909
|
}
|
|
27465
27910
|
return callId;
|
|
27466
27911
|
}
|
|
27912
|
+
function requiredFields2(value, fields) {
|
|
27913
|
+
if (fields.some((field) => !Object.hasOwn(value, field))) {
|
|
27914
|
+
fail("Modern history known event omitted a required field");
|
|
27915
|
+
}
|
|
27916
|
+
}
|
|
27467
27917
|
function validateUsage(value) {
|
|
27468
27918
|
if (!validUsage(value))
|
|
27469
27919
|
fail("Modern history usage is malformed");
|
|
@@ -27487,7 +27937,7 @@ function validUsage(value) {
|
|
|
27487
27937
|
}
|
|
27488
27938
|
return fields.slice(2).every((field) => value[field] === void 0 || nonNegativeSafeInteger2(value[field]));
|
|
27489
27939
|
}
|
|
27490
|
-
function validateTurnReason(value) {
|
|
27940
|
+
function validateTurnReason(value, profile) {
|
|
27491
27941
|
if (!isRecord4(value) || typeof value.kind !== "string") {
|
|
27492
27942
|
fail("Modern history turn/end reason is malformed");
|
|
27493
27943
|
}
|
|
@@ -27498,6 +27948,11 @@ function validateTurnReason(value) {
|
|
|
27498
27948
|
case "interrupted":
|
|
27499
27949
|
exactKeys2(value, ["kind"]);
|
|
27500
27950
|
return;
|
|
27951
|
+
case "forked":
|
|
27952
|
+
if (profile.sessionFormatVersion !== 4)
|
|
27953
|
+
fail("Modern history contains an unknown Turn outcome");
|
|
27954
|
+
exactKeys2(value, ["kind"]);
|
|
27955
|
+
return;
|
|
27501
27956
|
case "aborted":
|
|
27502
27957
|
exactKeys2(value, ["kind", "reason"]);
|
|
27503
27958
|
if (!isRecord4(value.reason) || typeof value.reason.kind !== "string") {
|
|
@@ -27552,7 +28007,7 @@ function validateRequestHeader(data) {
|
|
|
27552
28007
|
}
|
|
27553
28008
|
}
|
|
27554
28009
|
function validateRequestContext(data, profile) {
|
|
27555
|
-
requiredOptionalKeys(data, ["provider", "model"],
|
|
28010
|
+
requiredOptionalKeys(data, ["provider", "model"], hasDeepSeekModernStream(profile) ? ["contextWindow", "systemPromptUpdate"] : ["contextWindow"]);
|
|
27556
28011
|
if (!nonBlankString(data.provider) || !nonBlankString(data.model)) {
|
|
27557
28012
|
fail("Modern history request/context has an invalid Model route");
|
|
27558
28013
|
}
|
|
@@ -27570,12 +28025,15 @@ function validateModelSelection(data) {
|
|
|
27570
28025
|
fail("Modern history model/selection has invalid reasoningEffort");
|
|
27571
28026
|
}
|
|
27572
28027
|
}
|
|
27573
|
-
function validateToolError(value) {
|
|
28028
|
+
function validateToolError(value, profile) {
|
|
27574
28029
|
if (!isRecord4(value))
|
|
27575
28030
|
fail("Modern history tool/result error is malformed");
|
|
27576
|
-
|
|
28031
|
+
requiredOptionalKeys(value, ["name", "code"], profile.sessionFormatVersion === 4 ? ["reason"] : []);
|
|
27577
28032
|
requiredString(value.name, "tool/result error name");
|
|
27578
28033
|
requiredString(value.code, "tool/result error code");
|
|
28034
|
+
if (value.reason !== void 0 && typeof value.reason !== "string") {
|
|
28035
|
+
fail("Modern history tool/result error reason is malformed");
|
|
28036
|
+
}
|
|
27579
28037
|
}
|
|
27580
28038
|
function validateInboxSplice(data, profile) {
|
|
27581
28039
|
requiredOptionalKeys(data, ["target", "start", "inserted"], ["removedCount", "outcome"]);
|
|
@@ -27685,7 +28143,7 @@ function validateRetry(data) {
|
|
|
27685
28143
|
requiredString(data.provider, "llm/retry provider");
|
|
27686
28144
|
requiredString(data.policyKey, "llm/retry policyKey");
|
|
27687
28145
|
positiveInteger(data.retry, "llm/retry retry");
|
|
27688
|
-
|
|
28146
|
+
nonNegativeFiniteNumber(data.delayMs, "llm/retry delayMs");
|
|
27689
28147
|
if (mode === "normal")
|
|
27690
28148
|
positiveInteger(data.maxRetries, "llm/retry maxRetries");
|
|
27691
28149
|
validateLlmFailure(data.failure, "llm/retry failure");
|
|
@@ -27899,7 +28357,7 @@ function validateSubagentModelPolicy(data) {
|
|
|
27899
28357
|
validateModelRoute(route, "subagent Model policy route");
|
|
27900
28358
|
}
|
|
27901
28359
|
function validateTeamEvent(type, data, profile) {
|
|
27902
|
-
if (data.version !== (
|
|
28360
|
+
if (data.version !== (hasDeepSeekModernStream(profile) ? 2 : 1))
|
|
27903
28361
|
fail("Modern history team event version is malformed");
|
|
27904
28362
|
requiredString(data.teamId, "team event teamId");
|
|
27905
28363
|
if (type === "team/message/delivered") {
|
|
@@ -28087,7 +28545,8 @@ var ModernHarnessSession = class {
|
|
|
28087
28545
|
sessionId: this.#sessionId,
|
|
28088
28546
|
nativeRef: projection.nativeRef,
|
|
28089
28547
|
modelCatalog: this.#modelCatalog,
|
|
28090
|
-
permissionModes: this.#permissionModes
|
|
28548
|
+
permissionModes: this.#permissionModes,
|
|
28549
|
+
profile: this.#profile
|
|
28091
28550
|
});
|
|
28092
28551
|
this.#nativeRef = projection.nativeRef;
|
|
28093
28552
|
this.initialState = configuration.state;
|
|
@@ -28387,7 +28846,8 @@ ${question.detail}` : question.question;
|
|
|
28387
28846
|
sessionId: this.#sessionId,
|
|
28388
28847
|
nativeRef: this.#nativeRef,
|
|
28389
28848
|
modelCatalog: this.#modelCatalog,
|
|
28390
|
-
permissionModes: this.#permissionModes
|
|
28849
|
+
permissionModes: this.#permissionModes,
|
|
28850
|
+
profile: this.#profile
|
|
28391
28851
|
});
|
|
28392
28852
|
}
|
|
28393
28853
|
#onConfigurationProjection() {
|
|
@@ -29025,6 +29485,9 @@ ${question.detail}` : question.question;
|
|
|
29025
29485
|
if (attempt && !attempt.projected && active?.nativeTurn === attempt.turn && active.agent) {
|
|
29026
29486
|
this.#cancelAgentItem(active);
|
|
29027
29487
|
}
|
|
29488
|
+
if (attempt && active?.reasoning?.attemptId === attempt.attemptId) {
|
|
29489
|
+
this.#cancelReasoningItem(active);
|
|
29490
|
+
}
|
|
29028
29491
|
this.#assistantAttempt = void 0;
|
|
29029
29492
|
}
|
|
29030
29493
|
#cancelAgentItem(active) {
|
|
@@ -29042,6 +29505,13 @@ ${question.detail}` : question.question;
|
|
|
29042
29505
|
delete active.agent;
|
|
29043
29506
|
this.#completeItem(active, agent.item, { status: "cancelled" });
|
|
29044
29507
|
}
|
|
29508
|
+
#cancelReasoningItem(active) {
|
|
29509
|
+
const reasoning2 = active.reasoning;
|
|
29510
|
+
if (!reasoning2)
|
|
29511
|
+
return;
|
|
29512
|
+
delete active.reasoning;
|
|
29513
|
+
this.#completeItem(active, reasoning2.item, { status: "cancelled" });
|
|
29514
|
+
}
|
|
29045
29515
|
#projectAssistantLiveChunks() {
|
|
29046
29516
|
const attempt = this.#assistantAttempt;
|
|
29047
29517
|
const active = this.#active;
|
|
@@ -29076,6 +29546,7 @@ ${question.detail}` : question.question;
|
|
|
29076
29546
|
this.#projectAssistantLiveChunks();
|
|
29077
29547
|
} else {
|
|
29078
29548
|
this.#cancelAgentItem(active);
|
|
29549
|
+
this.#cancelReasoningItem(active);
|
|
29079
29550
|
}
|
|
29080
29551
|
attempt.projected = true;
|
|
29081
29552
|
if (attempt.ended)
|
|
@@ -29295,6 +29766,7 @@ ${question.detail}` : question.question;
|
|
|
29295
29766
|
input: [...input],
|
|
29296
29767
|
autonomous,
|
|
29297
29768
|
tools: /* @__PURE__ */ new Map(),
|
|
29769
|
+
reasoningOrdinal: 0,
|
|
29298
29770
|
interactions: /* @__PURE__ */ new Set(),
|
|
29299
29771
|
terminal: false,
|
|
29300
29772
|
cancelAcknowledged: false
|
|
@@ -29350,6 +29822,9 @@ ${question.detail}` : question.question;
|
|
|
29350
29822
|
if (event.surfaceOp === "append")
|
|
29351
29823
|
this.#completeTool(active, data, event.seq);
|
|
29352
29824
|
return;
|
|
29825
|
+
case "step/end":
|
|
29826
|
+
this.#cancelReasoningItem(active);
|
|
29827
|
+
return;
|
|
29353
29828
|
case "turn/end":
|
|
29354
29829
|
this.#finishTurn(buffer, active, data.reason, event.seq);
|
|
29355
29830
|
return;
|
|
@@ -29361,7 +29836,7 @@ ${question.detail}` : question.question;
|
|
|
29361
29836
|
if (chunk.type === "text-delta") {
|
|
29362
29837
|
this.#appendAgent(active, chunk.text, step, attemptId);
|
|
29363
29838
|
} else if (chunk.type === "reasoning-delta") {
|
|
29364
|
-
this.#appendReasoning(active, chunk.text, step, startedAtMs);
|
|
29839
|
+
this.#appendReasoning(active, chunk.text, step, true, attemptId, false, startedAtMs);
|
|
29365
29840
|
} else if (chunk.type === "usage" && !initialReplay) {
|
|
29366
29841
|
this.#publishUsageChanges(active.turnId);
|
|
29367
29842
|
}
|
|
@@ -29387,39 +29862,51 @@ ${question.detail}` : question.question;
|
|
|
29387
29862
|
update: { type: "text.append", text }
|
|
29388
29863
|
});
|
|
29389
29864
|
}
|
|
29390
|
-
#startReasoning(active, step) {
|
|
29865
|
+
#startReasoning(active, step, provisional, attemptId) {
|
|
29391
29866
|
if (!active.reasoning) {
|
|
29867
|
+
const key = provisional ? `reasoning:provisional:${++active.reasoningOrdinal}` : "reasoning";
|
|
29392
29868
|
const item = {
|
|
29393
29869
|
type: "reasoning",
|
|
29394
|
-
itemId: modernItemId(this.#sessionId, `turn:${active.nativeTurn}:step:${step}
|
|
29870
|
+
itemId: modernItemId(this.#sessionId, `turn:${active.nativeTurn}:step:${step}:${key}`),
|
|
29395
29871
|
text: ""
|
|
29396
29872
|
};
|
|
29397
|
-
active.reasoning = {
|
|
29873
|
+
active.reasoning = {
|
|
29874
|
+
item,
|
|
29875
|
+
text: "",
|
|
29876
|
+
provisional,
|
|
29877
|
+
pendingLineBreaks: "",
|
|
29878
|
+
...attemptId ? { attemptId } : {}
|
|
29879
|
+
};
|
|
29398
29880
|
this.#emit({ type: "item.started", turnId: active.turnId, item });
|
|
29399
29881
|
}
|
|
29400
29882
|
return active.reasoning;
|
|
29401
29883
|
}
|
|
29402
|
-
#appendReasoning(active, text, step, startedAtMs) {
|
|
29884
|
+
#appendReasoning(active, text, step, provisional = false, attemptId, final = false, startedAtMs) {
|
|
29403
29885
|
if (!text)
|
|
29404
29886
|
return;
|
|
29405
|
-
const reasoning2 = this.#startReasoning(active, step);
|
|
29887
|
+
const reasoning2 = this.#startReasoning(active, step, provisional, attemptId);
|
|
29406
29888
|
if (startedAtMs !== void 0 && reasoning2.startedAtMs === void 0) {
|
|
29407
29889
|
reasoning2.startedAtMs = startedAtMs;
|
|
29408
29890
|
}
|
|
29409
|
-
reasoning2.
|
|
29891
|
+
const candidate = final ? text : reasoning2.pendingLineBreaks + text;
|
|
29892
|
+
const appended = final ? candidate : candidate.replace(/[\r\n]+$/u, "");
|
|
29893
|
+
reasoning2.pendingLineBreaks = final ? "" : candidate.slice(appended.length);
|
|
29894
|
+
if (!appended)
|
|
29895
|
+
return;
|
|
29896
|
+
reasoning2.text += appended;
|
|
29410
29897
|
reasoning2.item = { ...reasoning2.item, text: reasoning2.text };
|
|
29411
29898
|
this.#emit({
|
|
29412
29899
|
type: "item.updated",
|
|
29413
29900
|
turnId: active.turnId,
|
|
29414
29901
|
itemId: reasoning2.item.itemId,
|
|
29415
|
-
update: { type: "text.append", text }
|
|
29902
|
+
update: { type: "text.append", text: appended }
|
|
29416
29903
|
});
|
|
29417
29904
|
}
|
|
29418
29905
|
#completeAssistant(active, data, endedAtMs) {
|
|
29419
29906
|
const message = data.message;
|
|
29420
29907
|
const step = data.step;
|
|
29421
|
-
const reasoning2 =
|
|
29422
|
-
const text =
|
|
29908
|
+
const reasoning2 = contentText2(message.content, "reasoning");
|
|
29909
|
+
const text = contentText2(message.content, "text");
|
|
29423
29910
|
if (this.#profile.assistantStream && active.agent && !text.startsWith(active.agent.text)) {
|
|
29424
29911
|
this.#cancelAgentItem(active);
|
|
29425
29912
|
}
|
|
@@ -29434,48 +29921,26 @@ ${question.detail}` : question.question;
|
|
|
29434
29921
|
}
|
|
29435
29922
|
}
|
|
29436
29923
|
/**
|
|
29437
|
-
* Reconciles the streamed
|
|
29438
|
-
*
|
|
29439
|
-
*
|
|
29440
|
-
*
|
|
29441
|
-
* restarts as its own Item. durationMs keeps native journal time
|
|
29442
|
-
* (first reasoning delta → block end) whenever both are known.
|
|
29924
|
+
* Reconciles the streamed preview with the authoritative block-end text.
|
|
29925
|
+
* A diverging preview is cancelled; the journal text is what remains.
|
|
29926
|
+
* durationMs keeps native journal time (first reasoning delta → block end)
|
|
29927
|
+
* whenever both are known.
|
|
29443
29928
|
*/
|
|
29444
29929
|
#completeReasoning(active, finalText, step, endedAtMs) {
|
|
29930
|
+
if (active.reasoning && !finalText.startsWith(active.reasoning.text)) {
|
|
29931
|
+
this.#cancelReasoningItem(active);
|
|
29932
|
+
}
|
|
29933
|
+
const suffix = finalText.slice(active.reasoning?.text.length ?? 0);
|
|
29934
|
+
if (suffix)
|
|
29935
|
+
this.#appendReasoning(active, suffix, step, false, void 0, true);
|
|
29445
29936
|
const current = active.reasoning;
|
|
29446
|
-
if (!current)
|
|
29447
|
-
if (!finalText)
|
|
29448
|
-
return;
|
|
29449
|
-
this.#appendReasoning(active, finalText, step);
|
|
29450
|
-
const materialized = active.reasoning;
|
|
29451
|
-
delete active.reasoning;
|
|
29452
|
-
if (materialized) {
|
|
29453
|
-
this.#completeItem(active, materialized.item, { status: "succeeded" });
|
|
29454
|
-
}
|
|
29937
|
+
if (!current)
|
|
29455
29938
|
return;
|
|
29456
|
-
}
|
|
29457
29939
|
const durationMs = current.startedAtMs === void 0 ? void 0 : Math.max(0, endedAtMs - current.startedAtMs);
|
|
29458
|
-
if (finalText.startsWith(current.text)) {
|
|
29459
|
-
this.#appendReasoning(active, finalText.slice(current.text.length), step);
|
|
29460
|
-
const item = withReasoningDuration(current.item, durationMs);
|
|
29461
|
-
delete active.reasoning;
|
|
29462
|
-
this.#completeItem(active, item, { status: "succeeded" });
|
|
29463
|
-
return;
|
|
29464
|
-
}
|
|
29465
29940
|
delete active.reasoning;
|
|
29466
29941
|
this.#completeItem(active, withReasoningDuration(current.item, durationMs), {
|
|
29467
29942
|
status: "succeeded"
|
|
29468
29943
|
});
|
|
29469
|
-
if (!finalText)
|
|
29470
|
-
return;
|
|
29471
|
-
const authoritative = {
|
|
29472
|
-
type: "reasoning",
|
|
29473
|
-
itemId: modernItemId(this.#sessionId, `turn:${active.nativeTurn}:step:${step}:reasoning:final`),
|
|
29474
|
-
text: finalText,
|
|
29475
|
-
...durationMs === void 0 ? {} : { durationMs }
|
|
29476
|
-
};
|
|
29477
|
-
this.#emit({ type: "item.started", turnId: active.turnId, item: authoritative });
|
|
29478
|
-
this.#completeItem(active, authoritative, { status: "succeeded" });
|
|
29479
29944
|
}
|
|
29480
29945
|
#completeAgentPrefix(active, finalText, step) {
|
|
29481
29946
|
let current = active.agent;
|
|
@@ -29555,6 +30020,7 @@ ${question.detail}` : question.question;
|
|
|
29555
30020
|
const projected = turnOutcome(reason);
|
|
29556
30021
|
const itemOutcome2 = toItemOutcome(projected);
|
|
29557
30022
|
this.#discardAssistantAttempt();
|
|
30023
|
+
this.#cancelReasoningItem(active);
|
|
29558
30024
|
this.#closeActiveInteractions(active);
|
|
29559
30025
|
this.#completeOpenItems(active, itemOutcome2);
|
|
29560
30026
|
active.terminal = true;
|
|
@@ -29666,6 +30132,7 @@ ${question.detail}` : question.question;
|
|
|
29666
30132
|
input: hostBound ? textInputs2(pending.command.input) : [...buffer.input],
|
|
29667
30133
|
autonomous: !hostBound,
|
|
29668
30134
|
tools: /* @__PURE__ */ new Map(),
|
|
30135
|
+
reasoningOrdinal: 0,
|
|
29669
30136
|
interactions: /* @__PURE__ */ new Set(),
|
|
29670
30137
|
terminal: false,
|
|
29671
30138
|
cancelAcknowledged: false
|
|
@@ -30106,6 +30573,9 @@ function turnOutcome(reason) {
|
|
|
30106
30573
|
if (reason.kind === "aborted") {
|
|
30107
30574
|
return { status: "cancelled", reason: "Cancelled by user" };
|
|
30108
30575
|
}
|
|
30576
|
+
if (reason.kind === "forked") {
|
|
30577
|
+
return { status: "cancelled", reason: "Forked from parent Session" };
|
|
30578
|
+
}
|
|
30109
30579
|
return {
|
|
30110
30580
|
status: "failed",
|
|
30111
30581
|
error: {
|
|
@@ -30129,7 +30599,7 @@ function textInputs2(value) {
|
|
|
30129
30599
|
function hasText(part) {
|
|
30130
30600
|
return part.text.length > 0;
|
|
30131
30601
|
}
|
|
30132
|
-
function
|
|
30602
|
+
function contentText2(value, type) {
|
|
30133
30603
|
return Array.isArray(value) ? value.filter((block) => isRecord4(block) && block.type === type && typeof block.text === "string").map((block) => block.text).join("") : "";
|
|
30134
30604
|
}
|
|
30135
30605
|
function withReasoningDuration(item, durationMs) {
|
|
@@ -30239,17 +30709,17 @@ function boundedId(value, area) {
|
|
|
30239
30709
|
function validUpdatedAt(value) {
|
|
30240
30710
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value <= DEEPSEEK_MODERN_SESSION_UPDATED_AT_MAX && !Object.is(value, -0);
|
|
30241
30711
|
}
|
|
30242
|
-
function titleFromProjections(value) {
|
|
30712
|
+
function titleFromProjections(value, profile) {
|
|
30243
30713
|
if (value === void 0)
|
|
30244
30714
|
return null;
|
|
30245
|
-
if (!isPlainRecord7(value) || !exactKeys5(value, ["asOfSeq", "values"]) || !Number.isSafeInteger(value.asOfSeq) || value.asOfSeq < -1 || !isPlainRecord7(value.values)) {
|
|
30715
|
+
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)) {
|
|
30246
30716
|
throw sessionListError("protocolError", "DeepSeek Harness returned invalid Session list projections");
|
|
30247
30717
|
}
|
|
30248
30718
|
const title = value.values.title;
|
|
30249
30719
|
return typeof title === "string" && title.trim().length > 0 && title.length <= DEEPSEEK_MODERN_SESSION_TITLE_MAX_LENGTH && !title.includes("\0") ? title : null;
|
|
30250
30720
|
}
|
|
30251
|
-
function parseSummary(value) {
|
|
30252
|
-
if (!isPlainRecord7(value) || !exactKeys5(value, ["sessionId", "updatedAt", "running", "blank"], ["parentSessionId", "origin", "cwd", "projections"]) || typeof value.running !== "boolean" || typeof value.blank !== "boolean" || !validUpdatedAt(value.updatedAt)) {
|
|
30721
|
+
function parseSummary(value, profile) {
|
|
30722
|
+
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)) {
|
|
30253
30723
|
throw sessionListError("protocolError", "DeepSeek Harness returned an invalid Session row");
|
|
30254
30724
|
}
|
|
30255
30725
|
const sessionId = boundedId(value.sessionId, "Session id");
|
|
@@ -30272,13 +30742,13 @@ function parseSummary(value) {
|
|
|
30272
30742
|
blank: value.blank,
|
|
30273
30743
|
...value.origin === void 0 ? {} : { origin: value.origin },
|
|
30274
30744
|
...value.cwd === void 0 ? {} : { cwd: value.cwd },
|
|
30275
|
-
title: titleFromProjections(value.projections)
|
|
30745
|
+
title: titleFromProjections(value.projections, profile)
|
|
30276
30746
|
};
|
|
30277
30747
|
}
|
|
30278
30748
|
function isCanonicalAbsoluteCwd(value) {
|
|
30279
30749
|
return value !== void 0 && value.trim().length > 0 && !value.includes("\0") && path2.isAbsolute(value) && path2.resolve(value) === value;
|
|
30280
30750
|
}
|
|
30281
|
-
function parseModernSessionCandidates(value) {
|
|
30751
|
+
function parseModernSessionCandidates(value, profile = DEEPSEEK_V015_PROFILE) {
|
|
30282
30752
|
assertBoundedJson4(value);
|
|
30283
30753
|
if (!isPlainRecord7(value) || !exactKeys5(value, ["items"]) || !Array.isArray(value.items)) {
|
|
30284
30754
|
throw sessionListError("protocolError", "DeepSeek Harness returned an invalid Session list");
|
|
@@ -30288,7 +30758,7 @@ function parseModernSessionCandidates(value) {
|
|
|
30288
30758
|
}
|
|
30289
30759
|
const seen = /* @__PURE__ */ new Set();
|
|
30290
30760
|
const summaries = value.items.map((item) => {
|
|
30291
|
-
const summary = parseSummary(item);
|
|
30761
|
+
const summary = parseSummary(item, profile);
|
|
30292
30762
|
if (seen.has(summary.sessionId)) {
|
|
30293
30763
|
throw sessionListError("protocolError", "DeepSeek Harness returned duplicate Session identities");
|
|
30294
30764
|
}
|
|
@@ -30310,14 +30780,14 @@ function parseModernSessionCandidates(value) {
|
|
|
30310
30780
|
];
|
|
30311
30781
|
});
|
|
30312
30782
|
}
|
|
30313
|
-
async function loadModernSessionCandidates(remote, signal) {
|
|
30783
|
+
async function loadModernSessionCandidates(remote, signal, profile = DEEPSEEK_V015_PROFILE) {
|
|
30314
30784
|
try {
|
|
30315
30785
|
const result = await remote.call("session/list", { _request: {} }, signal);
|
|
30316
30786
|
if (!result.ok) {
|
|
30317
30787
|
const safe = sanitizeModernRemoteFailure(result.error);
|
|
30318
30788
|
throw sessionListError("remoteError", `DeepSeek Harness session/list failed: ${safe.message}`, safe.code);
|
|
30319
30789
|
}
|
|
30320
|
-
return parseModernSessionCandidates(result.value);
|
|
30790
|
+
return parseModernSessionCandidates(result.value, profile);
|
|
30321
30791
|
} catch (error51) {
|
|
30322
30792
|
if (error51 instanceof ModernSessionListError)
|
|
30323
30793
|
throw error51;
|
|
@@ -30386,6 +30856,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30386
30856
|
onFault: (error51) => this.#fail(toHarnessError(error51, "unavailable"))
|
|
30387
30857
|
});
|
|
30388
30858
|
this.#control = new ModernControlStore(this.#connection, {
|
|
30859
|
+
profile: this.#profile,
|
|
30389
30860
|
onFault: (error51) => this.#fail(toHarnessError(error51, "unavailable"))
|
|
30390
30861
|
});
|
|
30391
30862
|
this.#removeConnectionFaultListener = this.#connection.onFault((error51) => {
|
|
@@ -30458,7 +30929,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30458
30929
|
try {
|
|
30459
30930
|
await this.#connection.connect();
|
|
30460
30931
|
this.#assertAccepting();
|
|
30461
|
-
const candidates = await loadModernSessionCandidates(this.#connection, this.#lifetime.signal);
|
|
30932
|
+
const candidates = await loadModernSessionCandidates(this.#connection, this.#lifetime.signal, this.#profile);
|
|
30462
30933
|
this.#assertAccepting();
|
|
30463
30934
|
return { ok: true, value: candidates };
|
|
30464
30935
|
} catch (error51) {
|
|
@@ -30554,7 +31025,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30554
31025
|
this.#assertAccepting();
|
|
30555
31026
|
if (forkExpectation) {
|
|
30556
31027
|
await this.#verifyForkJournal(forkExpectation, journal, cwd);
|
|
30557
|
-
if (
|
|
31028
|
+
if (hasDeepSeekModernStream(this.#profile) && await clearInheritedForkInbox(this.#connection, journal, this.#lifetime.signal)) {
|
|
30558
31029
|
await journal.close();
|
|
30559
31030
|
journal = await openModernJournal(this.#connection, { sessionId, cwd }, this.#journalOptions());
|
|
30560
31031
|
await this.#verifyForkJournal(forkExpectation, journal, cwd);
|
|
@@ -30590,10 +31061,11 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30590
31061
|
harnessId: this.harnessId,
|
|
30591
31062
|
nativeSessionId: sessionId,
|
|
30592
31063
|
formatVersion: 1,
|
|
30593
|
-
...
|
|
31064
|
+
...hasDeepSeekModernStream(this.#profile) ? { locator: { dshVersion: this.#profile.version } } : {}
|
|
30594
31065
|
}),
|
|
30595
31066
|
modelCatalog: catalog,
|
|
30596
|
-
permissionModes
|
|
31067
|
+
permissionModes,
|
|
31068
|
+
profile: this.#profile
|
|
30597
31069
|
});
|
|
30598
31070
|
verifyCreateConfiguration(createConfiguration, openedConfiguration);
|
|
30599
31071
|
if (createConfiguration?.unattended && !delegationPermissionIsApplied(journal.events)) {
|
|
@@ -30611,7 +31083,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30611
31083
|
modelCatalog: catalog,
|
|
30612
31084
|
permissionModes,
|
|
30613
31085
|
sessionId,
|
|
30614
|
-
...
|
|
31086
|
+
...hasDeepSeekModernStream(this.#profile) ? { flushSession: () => this.#connection.flushSession(sessionId) } : {},
|
|
30615
31087
|
randomUUID: this.#dependencies.randomUUID,
|
|
30616
31088
|
now: this.#dependencies.now,
|
|
30617
31089
|
...this.#options.toolOutputLimit === void 0 ? {} : { toolOutputLimit: this.#options.toolOutputLimit },
|
|
@@ -30753,7 +31225,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30753
31225
|
}
|
|
30754
31226
|
atSeq = boundary.atSeq;
|
|
30755
31227
|
minimumSeedLength = boundary.events.length;
|
|
30756
|
-
if (boundary.events.length < source.events.length) {
|
|
31228
|
+
if (this.#profile.sessionFormatVersion === 4 || boundary.events.length < source.events.length) {
|
|
30757
31229
|
exactSeedLength = boundary.events.length;
|
|
30758
31230
|
}
|
|
30759
31231
|
} finally {
|
|
@@ -30846,7 +31318,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30846
31318
|
}
|
|
30847
31319
|
if (this.#permissionModesPromise)
|
|
30848
31320
|
return this.#permissionModesPromise;
|
|
30849
|
-
const operation = loadModernPermissionModeCatalog(this.#connection).then((catalog) => {
|
|
31321
|
+
const operation = loadModernPermissionModeCatalog(this.#connection, this.#lifetime.signal, this.#profile).then((catalog) => {
|
|
30850
31322
|
this.#permissionModes = catalog;
|
|
30851
31323
|
this.#permissionModesLoaded = true;
|
|
30852
31324
|
return catalog;
|
|
@@ -31071,18 +31543,19 @@ function parseModernForkInput(input, profile) {
|
|
|
31071
31543
|
function sessionLocatorMatches(locator, profile) {
|
|
31072
31544
|
if (locator === void 0)
|
|
31073
31545
|
return true;
|
|
31074
|
-
if (!
|
|
31546
|
+
if (!hasDeepSeekModernStream(profile) || !isRecord8(locator) || Reflect.ownKeys(locator).length !== 1 || typeof locator.dshVersion !== "string") {
|
|
31075
31547
|
return false;
|
|
31076
31548
|
}
|
|
31077
31549
|
try {
|
|
31078
31550
|
const { version: version2 } = classifyDeepSeekVersionOutput(locator.dshVersion);
|
|
31079
|
-
|
|
31551
|
+
const original = deepSeekModernProfile(version2);
|
|
31552
|
+
return original.sessionFormatVersion === profile.sessionFormatVersion || profile.sessionFormatVersion === 4 && original.sessionFormatVersion === 3;
|
|
31080
31553
|
} catch {
|
|
31081
31554
|
return false;
|
|
31082
31555
|
}
|
|
31083
31556
|
}
|
|
31084
31557
|
function checkpointLocatorMatches(locator, profile) {
|
|
31085
|
-
return
|
|
31558
|
+
return hasDeepSeekModernStream(profile) ? profileLocatorMatches(locator, profile) : locator === void 0;
|
|
31086
31559
|
}
|
|
31087
31560
|
function profileLocatorMatches(locator, profile) {
|
|
31088
31561
|
return isRecord8(locator) && Reflect.ownKeys(locator).length === 1 && locator.dshVersion === profile.version;
|
|
@@ -31293,7 +31766,7 @@ var DeepSeekHarnessAdapter = class {
|
|
|
31293
31766
|
harnessId: this.harnessId,
|
|
31294
31767
|
nativeSessionId,
|
|
31295
31768
|
formatVersion: 1,
|
|
31296
|
-
...this.#delegate &&
|
|
31769
|
+
...this.#delegate && hasDeepSeekModernStream(deepSeekModernProfile(this.#delegate.version)) ? { locator: { dshVersion: this.#delegate.version } } : {}
|
|
31297
31770
|
})
|
|
31298
31771
|
}
|
|
31299
31772
|
};
|