dsh-more 0.0.5 → 0.0.7
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 +15 -7
- package/README.zh-CN.md +15 -7
- package/dist/client.js +1149 -293
- package/dist/index.js +406 -156
- package/dist/types/generated/host-settings-schema.d.ts +4 -2
- package/dist/types/generated/patch-catalog.d.ts +12 -4
- package/dist/types/patches/conversation-markdown-export/client/menu.d.ts +5 -0
- package/dist/types/patches/model-capabilities/client/api.d.ts +4 -0
- package/dist/types/patches/model-capabilities/client/editor.d.ts +26 -0
- package/dist/types/patches/model-capabilities/client/index.d.ts +10 -0
- package/dist/types/patches/model-capabilities/client/model-entries.d.ts +15 -0
- package/dist/types/patches/model-capabilities/client/styles.d.ts +1 -0
- package/dist/types/patches/model-capabilities/host/deepseek.d.ts +11 -0
- package/dist/types/patches/{model-reasoning-efforts → model-capabilities}/host/validate.d.ts +3 -2
- package/dist/types/patches/model-capabilities/shared.d.ts +38 -0
- package/dist/types/patches/projectless-tasks/client/adapter.d.ts +17 -0
- package/dist/types/patches/projectless-tasks/client/create-task.d.ts +7 -0
- package/dist/types/patches/projectless-tasks/client/draft.d.ts +23 -0
- package/dist/types/patches/projectless-tasks/client/group-menu.d.ts +2 -0
- package/dist/types/patches/projectless-tasks/client/groups.d.ts +21 -0
- package/dist/types/patches/projectless-tasks/client/index.d.ts +2 -0
- package/dist/types/patches/projectless-tasks/client/new-session.d.ts +34 -0
- package/dist/types/patches/projectless-tasks/client/picker.d.ts +26 -0
- package/dist/types/patches/projectless-tasks/groups.d.ts +6 -0
- package/dist/types/patches/projectless-tasks/host/groups.d.ts +9 -0
- package/dist/types/patches/projectless-tasks/host/index.d.ts +5 -0
- package/dist/types/patches/projectless-tasks/shared.d.ts +6 -0
- package/dsh.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/types/patches/model-reasoning-efforts/client/index.d.ts +0 -54
- package/dist/types/patches/model-reasoning-efforts/shared.d.ts +0 -51
- /package/dist/types/patches/{model-reasoning-efforts → model-capabilities}/host/index.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -519,10 +519,11 @@ function buildCleanSeed(source, selection) {
|
|
|
519
519
|
}
|
|
520
520
|
if (event.type === "assistant/message") {
|
|
521
521
|
rebuilt.append("assistant/message", {
|
|
522
|
+
// Keep the durable stream and settlement metadata required by DSH 0.1.5.
|
|
523
|
+
// Only the reconstructed turn/step coordinates belong to the new log.
|
|
524
|
+
...event.data,
|
|
522
525
|
turn,
|
|
523
|
-
step
|
|
524
|
-
message: event.data.message,
|
|
525
|
-
...event.data.usage === void 0 ? {} : { usage: event.data.usage }
|
|
526
|
+
step
|
|
526
527
|
}, { surfaceOp: "append" });
|
|
527
528
|
assistantSeen = true;
|
|
528
529
|
for (const call of event.data.message.content) {
|
|
@@ -664,15 +665,13 @@ var SESSION_DELETE_PATCH_ID = "session-delete";
|
|
|
664
665
|
// src/patches/session-delete/host/live-session-handles.ts
|
|
665
666
|
var TRACKER = /* @__PURE__ */ Symbol.for("dsh-more.session-delete.live-session-handles");
|
|
666
667
|
function trackedHandle(tracker, handle) {
|
|
667
|
-
let
|
|
668
|
+
let disposal;
|
|
668
669
|
const wrapped = {
|
|
669
670
|
agent: handle.agent,
|
|
670
|
-
dispose: async () => {
|
|
671
|
-
if (disposed) return;
|
|
672
|
-
disposed = true;
|
|
673
|
-
if (tracker.handles.get(handle.agent.id) === wrapped) tracker.handles.delete(handle.agent.id);
|
|
671
|
+
dispose: () => disposal ??= Promise.resolve().then(async () => {
|
|
674
672
|
await handle.dispose();
|
|
675
|
-
|
|
673
|
+
if (tracker.handles.get(handle.agent.id) === wrapped) tracker.handles.delete(handle.agent.id);
|
|
674
|
+
})
|
|
676
675
|
};
|
|
677
676
|
tracker.handles.set(handle.agent.id, wrapped);
|
|
678
677
|
return wrapped;
|
|
@@ -682,26 +681,37 @@ function installLiveSessionHandleTracker(ctx) {
|
|
|
682
681
|
const existing = registry[TRACKER];
|
|
683
682
|
if (existing !== void 0) {
|
|
684
683
|
existing.references += 1;
|
|
685
|
-
return ()
|
|
686
|
-
existing.references -= 1;
|
|
687
|
-
};
|
|
684
|
+
return releaseTracker(registry, existing);
|
|
688
685
|
}
|
|
689
686
|
const originalCreate = registry.create;
|
|
690
687
|
const originalResume = registry.resume;
|
|
691
688
|
const tracker = { handles: /* @__PURE__ */ new Map() };
|
|
692
689
|
tracker.originalCreate = originalCreate;
|
|
693
690
|
tracker.originalResume = originalResume;
|
|
691
|
+
tracker.createDescriptor = Object.getOwnPropertyDescriptor(registry, "create");
|
|
692
|
+
tracker.resumeDescriptor = Object.getOwnPropertyDescriptor(registry, "resume");
|
|
694
693
|
tracker.wrappedCreate = async (options) => trackedHandle(tracker, await originalCreate.call(registry, options));
|
|
695
694
|
tracker.wrappedResume = async (options) => trackedHandle(tracker, await originalResume.call(registry, options));
|
|
696
695
|
tracker.references = 1;
|
|
697
696
|
registry[TRACKER] = tracker;
|
|
698
697
|
registry.create = tracker.wrappedCreate;
|
|
699
698
|
registry.resume = tracker.wrappedResume;
|
|
699
|
+
return releaseTracker(registry, tracker);
|
|
700
|
+
}
|
|
701
|
+
function releaseTracker(registry, tracker) {
|
|
702
|
+
let released = false;
|
|
700
703
|
return () => {
|
|
704
|
+
if (released) return;
|
|
705
|
+
released = true;
|
|
701
706
|
tracker.references -= 1;
|
|
702
707
|
if (tracker.references > 0 || registry[TRACKER] !== tracker) return;
|
|
703
|
-
|
|
704
|
-
|
|
708
|
+
const restore = (key, installed, descriptor) => {
|
|
709
|
+
if (Object.getOwnPropertyDescriptor(registry, key)?.value !== installed) return;
|
|
710
|
+
if (descriptor === void 0) Reflect.deleteProperty(registry, key);
|
|
711
|
+
else Object.defineProperty(registry, key, descriptor);
|
|
712
|
+
};
|
|
713
|
+
restore("create", tracker.wrappedCreate, tracker.createDescriptor);
|
|
714
|
+
restore("resume", tracker.wrappedResume, tracker.resumeDescriptor);
|
|
705
715
|
delete registry[TRACKER];
|
|
706
716
|
};
|
|
707
717
|
}
|
|
@@ -725,12 +735,16 @@ function detachInternal(registry, sessionId, label) {
|
|
|
725
735
|
async function unloadLiveSession(ctx, sessionId) {
|
|
726
736
|
const agent = ctx.agents.get(sessionId);
|
|
727
737
|
const session = ctx.sessions.get(sessionId);
|
|
738
|
+
const handle = getLiveSessionHandle(ctx, sessionId);
|
|
739
|
+
const ownsWriter = "open" in ctx.sessionPersistence && typeof ctx.sessionPersistence.open === "function";
|
|
740
|
+
if (session !== void 0 && ownsWriter && handle === void 0) {
|
|
741
|
+
throw new DshMoreError("session-not-live", "\u65E0\u6CD5\u5B89\u5168\u5378\u8F7D\u8FD9\u6761\u5DF2\u52A0\u8F7D\u7684\u4F1A\u8BDD\uFF0C\u8BF7\u91CD\u542F DSH \u540E\u518D\u5220\u9664\u3002", 409);
|
|
742
|
+
}
|
|
728
743
|
if (agent !== void 0) {
|
|
729
744
|
agent.cancel({ kind: "disposed" });
|
|
730
745
|
await agent.whenIdle();
|
|
731
746
|
}
|
|
732
747
|
if (session !== void 0) await ctx.sessions.flush(session);
|
|
733
|
-
const handle = getLiveSessionHandle(ctx, sessionId);
|
|
734
748
|
if (handle !== void 0) {
|
|
735
749
|
await handle.dispose();
|
|
736
750
|
} else {
|
|
@@ -753,7 +767,8 @@ function sessionDirectoryFromLocation(locationPath) {
|
|
|
753
767
|
throw new DshMoreError("internal", "\u5F53\u524D\u6301\u4E45\u5316\u540E\u7AEF\u6CA1\u6709\u8FD4\u56DE\u7EDD\u5BF9\u4F1A\u8BDD\u8DEF\u5F84\u3002", 409);
|
|
754
768
|
}
|
|
755
769
|
const artifact = basename(locationPath);
|
|
756
|
-
|
|
770
|
+
const match = /^session(?:\.v([1-9][0-9]*))?\.jsonl(?:\.zstd)?$/.exec(artifact);
|
|
771
|
+
if (match === null || match[1] !== void 0 && !Number.isSafeInteger(Number(match[1]))) {
|
|
757
772
|
throw new DshMoreError("internal", "\u6301\u4E45\u5316\u540E\u7AEF\u8FD4\u56DE\u4E86\u672A\u77E5\u7684\u4F1A\u8BDD\u6587\u4EF6\u5E03\u5C40\u3002", 500);
|
|
758
773
|
}
|
|
759
774
|
const sessionDir = dirname(locationPath);
|
|
@@ -765,9 +780,10 @@ function sessionDirectoryFromLocation(locationPath) {
|
|
|
765
780
|
async function deleteSessionPermanently(ctx, rawSessionId) {
|
|
766
781
|
const sessionId = SessionId6(rawSessionId);
|
|
767
782
|
const live = ctx.sessions.get(sessionId);
|
|
768
|
-
const
|
|
783
|
+
const stored = await ctx.sessionPersistence.list();
|
|
784
|
+
const header2 = stored.map((candidate) => "header" in candidate ? candidate.header : candidate).find((candidate) => candidate.id === sessionId) ?? live?.header;
|
|
769
785
|
if (header2 === void 0) throw new DshMoreError("not-found", "\u4F1A\u8BDD\u8BB0\u5F55\u4E0D\u5B58\u5728\u3002", 404);
|
|
770
|
-
const location = ctx.sessionPersistence.locate(header2);
|
|
786
|
+
const location = typeof ctx.sessionPersistence.locate === "function" ? ctx.sessionPersistence.locate(header2) : void 0;
|
|
771
787
|
if (location === void 0) {
|
|
772
788
|
throw new DshMoreError("internal", "\u5F53\u524D\u6301\u4E45\u5316\u540E\u7AEF\u4E0D\u652F\u6301\u9010\u4F1A\u8BDD\u7269\u7406\u5220\u9664\u3002", 409);
|
|
773
789
|
}
|
|
@@ -776,7 +792,10 @@ async function deleteSessionPermanently(ctx, rawSessionId) {
|
|
|
776
792
|
}
|
|
777
793
|
const sessionDir = sessionDirectoryFromLocation(location.path);
|
|
778
794
|
await unloadLiveSession(ctx, sessionId);
|
|
779
|
-
const info = await stat(sessionDir).catch(() =>
|
|
795
|
+
const info = await stat(sessionDir).catch((error) => {
|
|
796
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") return void 0;
|
|
797
|
+
throw error;
|
|
798
|
+
});
|
|
780
799
|
if (info !== void 0) {
|
|
781
800
|
if (!info.isDirectory()) throw new DshMoreError("internal", "\u4F1A\u8BDD\u6301\u4E45\u5316\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\u3002", 500);
|
|
782
801
|
await rm(sessionDir, { recursive: true, force: false });
|
|
@@ -977,20 +996,38 @@ var hostPatch4 = {
|
|
|
977
996
|
})
|
|
978
997
|
};
|
|
979
998
|
|
|
980
|
-
// src/patches/model-
|
|
981
|
-
|
|
999
|
+
// src/patches/model-capabilities/host/index.ts
|
|
1000
|
+
import { SettingsConflictError } from "@deepseek-ai/dsh-settings";
|
|
1001
|
+
|
|
1002
|
+
// src/patches/model-capabilities/shared.ts
|
|
1003
|
+
var MODEL_CAPABILITIES_PATCH_ID = "model-capabilities";
|
|
982
1004
|
var LLM_PI_AI_SETTINGS_NAMESPACE = "llm-pi-ai";
|
|
1005
|
+
var LLM_DEEPSEEK_SETTINGS_NAMESPACE = "llm-deepseek";
|
|
1006
|
+
var DEEPSEEK_PROVIDER = "deepseek-official";
|
|
1007
|
+
var CAPABILITIES_PROTOCOL_VERSION = 2;
|
|
1008
|
+
var DEEPSEEK_THINKING_LEVELS = ["off", "low", "high", "max"];
|
|
983
1009
|
var THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
984
|
-
var
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1010
|
+
var THINKING_FORMATS = [
|
|
1011
|
+
"openai",
|
|
1012
|
+
"deepseek",
|
|
1013
|
+
"openrouter",
|
|
1014
|
+
"together",
|
|
1015
|
+
"baseten",
|
|
1016
|
+
"zai",
|
|
1017
|
+
"qwen",
|
|
1018
|
+
"chat-template",
|
|
1019
|
+
"qwen-chat-template",
|
|
1020
|
+
"string-thinking",
|
|
1021
|
+
"ant-ling"
|
|
1022
|
+
];
|
|
989
1023
|
|
|
990
|
-
// src/patches/model-
|
|
1024
|
+
// src/patches/model-capabilities/host/deepseek.ts
|
|
1025
|
+
import { LlmError, ReasoningEffortId } from "@deepseek-ai/dsh-llm";
|
|
1026
|
+
|
|
1027
|
+
// src/patches/model-capabilities/host/validate.ts
|
|
991
1028
|
var LEVEL_SET = new Set(THINKING_LEVELS);
|
|
992
1029
|
function validateReasoningEfforts(raw) {
|
|
993
|
-
if (raw === null
|
|
1030
|
+
if (raw === null) return null;
|
|
994
1031
|
if (raw === false) return false;
|
|
995
1032
|
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
996
1033
|
throw new DshMoreError("bad-request", "reasoningEfforts \u5FC5\u987B\u662F false\u3001\u601D\u8003\u7EA7\u522B\u5B57\u5178\u6216 null\u3002");
|
|
@@ -1017,135 +1054,276 @@ function validateReasoningEfforts(raw) {
|
|
|
1017
1054
|
if (!offersThinking) throw new DshMoreError("bad-request", "\u9700\u8981\u81F3\u5C11\u58F0\u660E\u4E00\u4E2A\u975E off \u7684\u601D\u8003\u7EA7\u522B\u3002");
|
|
1018
1055
|
return result;
|
|
1019
1056
|
}
|
|
1057
|
+
function validateCapabilities(raw) {
|
|
1058
|
+
const { vision, thinkingFormat } = raw;
|
|
1059
|
+
if (vision !== null && typeof vision !== "boolean") {
|
|
1060
|
+
throw new DshMoreError("bad-request", "\u8BF7\u9009\u62E9\u8BC6\u56FE\u80FD\u529B\uFF1A\u6CBF\u7528\u9ED8\u8BA4\u3001\u652F\u6301\u6216\u4E0D\u652F\u6301\u3002");
|
|
1061
|
+
}
|
|
1062
|
+
if (thinkingFormat !== null && !THINKING_FORMATS.some((format) => format === thinkingFormat)) {
|
|
1063
|
+
throw new DshMoreError("bad-request", "\u8BF7\u9009\u62E9 DSH \u652F\u6301\u7684\u601D\u8003\u53C2\u6570\u683C\u5F0F\u3002");
|
|
1064
|
+
}
|
|
1065
|
+
return {
|
|
1066
|
+
vision,
|
|
1067
|
+
reasoningEfforts: validateReasoningEfforts(raw.reasoningEfforts),
|
|
1068
|
+
thinkingFormat
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
// src/patches/model-capabilities/host/deepseek.ts
|
|
1073
|
+
function record(value) {
|
|
1074
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
1075
|
+
}
|
|
1076
|
+
function validateDeepSeekEfforts(efforts) {
|
|
1077
|
+
if (efforts === false || efforts === null) return;
|
|
1078
|
+
for (const [level, wire] of Object.entries(efforts)) {
|
|
1079
|
+
if (!DEEPSEEK_THINKING_LEVELS.some((item) => item === level) || wire !== level && !(level === "off" && wire === null)) {
|
|
1080
|
+
throw new Error("\u539F\u751F DeepSeek \u652F\u6301\u4E0D\u601D\u8003\u3001\u4F4E\u3001\u9AD8\u3001\u6700\u9AD8\uFF0C\u53C2\u6570\u503C\u56FA\u5B9A\u4E3A off\u3001low\u3001high\u3001max\u3002");
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
function ruleFor(ctx, provider, modelId) {
|
|
1085
|
+
if (provider !== DEEPSEEK_PROVIDER) return void 0;
|
|
1086
|
+
const profile = record(ctx.settings.get(LLM_DEEPSEEK_SETTINGS_NAMESPACE));
|
|
1087
|
+
const models = Array.isArray(profile.models) ? profile.models : [];
|
|
1088
|
+
const model = record(models.find((item) => record(item).id === modelId));
|
|
1089
|
+
if (model.reasoningEfforts === void 0) return void 0;
|
|
1090
|
+
const efforts = validateReasoningEfforts(model.reasoningEfforts);
|
|
1091
|
+
validateDeepSeekEfforts(efforts);
|
|
1092
|
+
if (efforts === null) return void 0;
|
|
1093
|
+
const levels = efforts === false ? ["off"] : DEEPSEEK_THINKING_LEVELS.filter((level) => Object.hasOwn(efforts, level));
|
|
1094
|
+
if (profile.thinking === "disabled" && levels.some((level) => level !== "off")) {
|
|
1095
|
+
throw new LlmError("DeepSeek \u63D0\u4F9B\u65B9\u5DF2\u5173\u95ED\u601D\u8003\uFF0C\u8BF7\u5148\u8C03\u6574\u63D0\u4F9B\u65B9\u914D\u7F6E\u3002", "UNSUPPORTED_REASONING_EFFORT");
|
|
1096
|
+
}
|
|
1097
|
+
const preferred = typeof profile.reasoningEffort === "string" ? profile.reasoningEffort : "high";
|
|
1098
|
+
return { levels, defaultEffort: levels.includes(preferred) ? preferred : levels[0] };
|
|
1099
|
+
}
|
|
1100
|
+
function revise(config, rule) {
|
|
1101
|
+
if (rule === void 0) return config;
|
|
1102
|
+
const effort = config.reasoningEffort ?? ReasoningEffortId(rule.defaultEffort);
|
|
1103
|
+
if (!rule.levels.includes(effort)) {
|
|
1104
|
+
throw new LlmError(`\u6A21\u578B ${config.model} \u672A\u914D\u7F6E\u601D\u8003\u7C7B\u578B ${effort}\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u601D\u8003\u7C7B\u578B\u3002`, "UNSUPPORTED_REASONING_EFFORT");
|
|
1105
|
+
}
|
|
1106
|
+
return { ...config, reasoningEffort: effort };
|
|
1107
|
+
}
|
|
1108
|
+
function reasoning(rule) {
|
|
1109
|
+
return {
|
|
1110
|
+
efforts: rule.levels.map((level) => ({ id: ReasoningEffortId(level), name: level })),
|
|
1111
|
+
defaultEffort: ReasoningEffortId(rule.defaultEffort)
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
function installDeepSeekReasoning(ctx) {
|
|
1115
|
+
let active = true;
|
|
1116
|
+
let cleanup = () => {
|
|
1117
|
+
};
|
|
1118
|
+
const fiber = ctx.inject(["llm", "settings"], (scope) => {
|
|
1119
|
+
if (!active) return;
|
|
1120
|
+
const llm = scope.llm;
|
|
1121
|
+
const descriptors = {
|
|
1122
|
+
resolveModelInfo: Object.getOwnPropertyDescriptor(llm, "resolveModelInfo"),
|
|
1123
|
+
resolveCallConfig: Object.getOwnPropertyDescriptor(llm, "resolveCallConfig"),
|
|
1124
|
+
prepareCall: Object.getOwnPropertyDescriptor(llm, "prepareCall"),
|
|
1125
|
+
stream: Object.getOwnPropertyDescriptor(llm, "stream")
|
|
1126
|
+
};
|
|
1127
|
+
const originalInfo = llm.resolveModelInfo;
|
|
1128
|
+
const originalResolve = llm.resolveCallConfig;
|
|
1129
|
+
const originalPrepare = llm.prepareCall;
|
|
1130
|
+
const originalStream = llm.stream;
|
|
1131
|
+
const info = async (provider, model, signal) => {
|
|
1132
|
+
const rule = active ? ruleFor(scope, provider, model) : void 0;
|
|
1133
|
+
const result = await originalInfo.call(llm, provider, model, signal);
|
|
1134
|
+
return rule === void 0 ? result : { ...result, reasoning: reasoning(rule) };
|
|
1135
|
+
};
|
|
1136
|
+
const resolve = async (config, signal) => originalResolve.call(llm, revise(config, active ? ruleFor(scope, config.provider, config.model) : void 0), signal);
|
|
1137
|
+
const prepare = async (config, signal) => {
|
|
1138
|
+
const revised = revise(config, active ? ruleFor(scope, config.provider, config.model) : void 0);
|
|
1139
|
+
const prepared = await originalPrepare.call(llm, revised, signal);
|
|
1140
|
+
if (config.reasoningEffort !== void 0 || revised.reasoningEffort === void 0) return prepared;
|
|
1141
|
+
return Object.freeze({ ...prepared, adapterDefaults: Object.freeze({ ...prepared.adapterDefaults, reasoningEffort: true }) });
|
|
1142
|
+
};
|
|
1143
|
+
const stream = (options) => {
|
|
1144
|
+
try {
|
|
1145
|
+
return originalStream.call(llm, revise(options, active ? ruleFor(scope, options.provider, options.model) : void 0));
|
|
1146
|
+
} catch (error) {
|
|
1147
|
+
if (!(error instanceof LlmError)) throw error;
|
|
1148
|
+
return (async function* () {
|
|
1149
|
+
yield { type: "finish", reason: { kind: "error", failure: { code: error.code, message: error.message } } };
|
|
1150
|
+
})();
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
llm.resolveModelInfo = info;
|
|
1154
|
+
llm.resolveCallConfig = resolve;
|
|
1155
|
+
llm.prepareCall = prepare;
|
|
1156
|
+
llm.stream = stream;
|
|
1157
|
+
cleanup = () => {
|
|
1158
|
+
const restore = (name2, installed) => {
|
|
1159
|
+
if (Object.getOwnPropertyDescriptor(llm, name2)?.value !== installed) return;
|
|
1160
|
+
const descriptor = descriptors[name2];
|
|
1161
|
+
if (descriptor === void 0) Reflect.deleteProperty(llm, name2);
|
|
1162
|
+
else Object.defineProperty(llm, name2, descriptor);
|
|
1163
|
+
};
|
|
1164
|
+
restore("resolveModelInfo", info);
|
|
1165
|
+
restore("resolveCallConfig", resolve);
|
|
1166
|
+
restore("prepareCall", prepare);
|
|
1167
|
+
restore("stream", stream);
|
|
1168
|
+
};
|
|
1169
|
+
scope.effect(() => cleanup);
|
|
1170
|
+
});
|
|
1171
|
+
return () => {
|
|
1172
|
+
active = false;
|
|
1173
|
+
cleanup();
|
|
1174
|
+
void fiber.dispose();
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1020
1177
|
|
|
1021
|
-
// src/patches/model-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1178
|
+
// src/patches/model-capabilities/host/index.ts
|
|
1179
|
+
function record2(value) {
|
|
1180
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
1181
|
+
}
|
|
1182
|
+
function modelsOf(profile) {
|
|
1183
|
+
return Array.isArray(profile.models) ? profile.models.map(record2) : [];
|
|
1184
|
+
}
|
|
1185
|
+
function capabilitiesOf(model, native = false) {
|
|
1186
|
+
const input = native ? model.inputModalities : model.input;
|
|
1187
|
+
const format = record2(model.compat).thinkingFormat;
|
|
1188
|
+
return {
|
|
1189
|
+
vision: Array.isArray(input) && input.length > 0 ? input.includes("image") : null,
|
|
1190
|
+
reasoningEfforts: model.reasoningEfforts === void 0 ? null : validateReasoningEfforts(model.reasoningEfforts),
|
|
1191
|
+
thinkingFormat: THINKING_FORMATS.find((entry) => entry === format) ?? null
|
|
1192
|
+
};
|
|
1034
1193
|
}
|
|
1035
1194
|
function read(ctx) {
|
|
1036
|
-
const
|
|
1195
|
+
const descriptor = ctx.settings.describe().find((entry) => entry.ns === LLM_PI_AI_SETTINGS_NAMESPACE);
|
|
1037
1196
|
const rows = [];
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
if (
|
|
1043
|
-
const
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
reasoningEfforts: normalizeEfforts(model.reasoningEfforts)
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1197
|
+
const providers = record2(record2(descriptor?.value).providers);
|
|
1198
|
+
for (const [provider, raw] of Object.entries(providers)) {
|
|
1199
|
+
const profile = record2(raw);
|
|
1200
|
+
for (const model of modelsOf(profile)) {
|
|
1201
|
+
if (typeof model.id !== "string" || model.id === "") continue;
|
|
1202
|
+
const api = model.api ?? profile.api;
|
|
1203
|
+
rows.push({
|
|
1204
|
+
namespace: LLM_PI_AI_SETTINGS_NAMESPACE,
|
|
1205
|
+
revision: descriptor.revision,
|
|
1206
|
+
provider,
|
|
1207
|
+
providerName: typeof profile.displayName === "string" ? profile.displayName : provider,
|
|
1208
|
+
modelId: model.id,
|
|
1209
|
+
api: typeof api === "string" ? api : null,
|
|
1210
|
+
...capabilitiesOf(model)
|
|
1211
|
+
});
|
|
1056
1212
|
}
|
|
1057
1213
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1214
|
+
const native = ctx.settings.describe().find((entry) => entry.ns === LLM_DEEPSEEK_SETTINGS_NAMESPACE);
|
|
1215
|
+
for (const model of modelsOf(record2(native?.value))) {
|
|
1216
|
+
if (typeof model.id !== "string" || model.id === "") continue;
|
|
1217
|
+
rows.push({
|
|
1218
|
+
namespace: LLM_DEEPSEEK_SETTINGS_NAMESPACE,
|
|
1219
|
+
revision: native.revision,
|
|
1220
|
+
provider: DEEPSEEK_PROVIDER,
|
|
1221
|
+
providerName: "DeepSeek",
|
|
1222
|
+
modelId: model.id,
|
|
1223
|
+
api: "deepseek-native",
|
|
1224
|
+
...capabilitiesOf(model, true)
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
return { protocolVersion: CAPABILITIES_PROTOCOL_VERSION, rows, writable: ctx.settings.writable, revision: descriptor?.revision ?? null };
|
|
1063
1228
|
}
|
|
1064
1229
|
async function save(ctx, payload) {
|
|
1230
|
+
const namespace = requireString(payload, "namespace");
|
|
1231
|
+
if (namespace !== LLM_PI_AI_SETTINGS_NAMESPACE && namespace !== LLM_DEEPSEEK_SETTINGS_NAMESPACE) throw new DshMoreError("bad-request", "\u672A\u77E5\u7684\u6A21\u578B\u914D\u7F6E\u6765\u6E90\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u3002");
|
|
1065
1232
|
const provider = requireString(payload, "provider");
|
|
1066
1233
|
const modelId = requireString(payload, "modelId");
|
|
1067
|
-
const
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1234
|
+
const expectedRevision = requireInteger(payload, "expectedRevision");
|
|
1235
|
+
if (expectedRevision < 0) throw new DshMoreError("bad-request", "\u914D\u7F6E\u7248\u672C\u65E0\u6548\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u6A21\u578B\u80FD\u529B\u3002");
|
|
1236
|
+
const capabilities = validateCapabilities(record2(payload));
|
|
1237
|
+
if (!ctx.settings.writable) throw new DshMoreError("forbidden", "\u5F53\u524D\u914D\u7F6E\u4E3A\u53EA\u8BFB\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u4FEE\u6539\u3002", 403);
|
|
1238
|
+
const descriptor = ctx.settings.describe().find((entry) => entry.ns === namespace);
|
|
1239
|
+
if (descriptor === void 0) throw new DshMoreError("bad-request", "\u6A21\u578B\u914D\u7F6E\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002");
|
|
1240
|
+
if (descriptor.revision !== expectedRevision) throw staleSettings();
|
|
1241
|
+
if (namespace === LLM_DEEPSEEK_SETTINGS_NAMESPACE) {
|
|
1242
|
+
if (provider !== DEEPSEEK_PROVIDER) throw new DshMoreError("bad-request", "DeepSeek \u63D0\u4F9B\u65B9\u4E0D\u5339\u914D\u3002");
|
|
1243
|
+
if (capabilities.thinkingFormat !== null) throw new DshMoreError("bad-request", "\u539F\u751F DeepSeek \u4F7F\u7528\u56FA\u5B9A\u7684\u601D\u8003\u534F\u8BAE\uFF0C\u65E0\u9700\u914D\u7F6E\u53C2\u6570\u683C\u5F0F\u3002");
|
|
1244
|
+
try {
|
|
1245
|
+
validateDeepSeekEfforts(capabilities.reasoningEfforts);
|
|
1246
|
+
} catch (error) {
|
|
1247
|
+
throw new DshMoreError("bad-request", error instanceof Error ? error.message : "DeepSeek \u601D\u8003\u7C7B\u578B\u65E0\u6548\u3002");
|
|
1248
|
+
}
|
|
1249
|
+
const profile2 = record2(descriptor.value);
|
|
1250
|
+
if (profile2.thinking === "disabled" && capabilities.reasoningEfforts !== null && capabilities.reasoningEfforts !== false) {
|
|
1251
|
+
throw new DshMoreError("bad-request", "DeepSeek \u63D0\u4F9B\u65B9\u5DF2\u5173\u95ED\u601D\u8003\uFF0C\u8BF7\u5148\u8C03\u6574\u63D0\u4F9B\u65B9\u914D\u7F6E\u3002");
|
|
1252
|
+
}
|
|
1253
|
+
const user = record2(descriptor.user);
|
|
1254
|
+
const base = record2(descriptor.base);
|
|
1255
|
+
const source2 = Array.isArray(user.models) ? user : Array.isArray(base.models) ? base : profile2;
|
|
1256
|
+
const models = modelsOf(source2);
|
|
1257
|
+
const matches2 = models.filter((model2) => model2.id === modelId);
|
|
1258
|
+
if (matches2.length !== 1) throw new DshMoreError("bad-request", "\u8BF7\u5148\u4FDD\u5B58\u6A21\u578B\u914D\u7F6E\uFF0C\u5E76\u786E\u4FDD\u6A21\u578B\u540D\u79F0\u552F\u4E00\u3002");
|
|
1259
|
+
const next2 = { ...matches2[0] };
|
|
1260
|
+
if (capabilities.vision === null) delete next2.inputModalities;
|
|
1261
|
+
else next2.inputModalities = capabilities.vision ? ["text", "image"] : ["text"];
|
|
1262
|
+
if (capabilities.vision !== true) {
|
|
1263
|
+
delete next2.imagePixelBudget;
|
|
1264
|
+
delete next2.imageMaxBytes;
|
|
1265
|
+
}
|
|
1266
|
+
if (capabilities.reasoningEfforts === null) delete next2.reasoningEfforts;
|
|
1267
|
+
else next2.reasoningEfforts = capabilities.reasoningEfforts;
|
|
1268
|
+
await mutate(ctx, namespace, [{ op: "set", path: ["models"], value: models.map((model2) => model2.id === modelId ? next2 : model2) }], expectedRevision);
|
|
1269
|
+
return read(ctx);
|
|
1103
1270
|
}
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
const
|
|
1117
|
-
const
|
|
1118
|
-
const
|
|
1119
|
-
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
const
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1271
|
+
const providers = record2(record2(descriptor.value).providers);
|
|
1272
|
+
if (!Object.hasOwn(providers, provider)) throw new DshMoreError("not-found", "\u8BE5\u63D0\u4F9B\u65B9\u5DF2\u4E0D\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u6A21\u578B\u914D\u7F6E\u3002", 404);
|
|
1273
|
+
const profile = record2(providers[provider]);
|
|
1274
|
+
const matches = modelsOf(profile).filter((entry) => entry.id === modelId);
|
|
1275
|
+
const model = matches[0];
|
|
1276
|
+
if (matches.length !== 1 || model === void 0) {
|
|
1277
|
+
throw new DshMoreError("bad-request", "\u8BF7\u5148\u4FDD\u5B58\u63D0\u4F9B\u65B9\u914D\u7F6E\uFF0C\u5E76\u786E\u4FDD\u6A21\u578B\u540D\u79F0\u552F\u4E00\u3002");
|
|
1278
|
+
}
|
|
1279
|
+
const api = model.api ?? profile.api;
|
|
1280
|
+
if (capabilities.thinkingFormat !== null && api !== void 0 && api !== "openai-completions") {
|
|
1281
|
+
throw new DshMoreError("bad-request", "\u8BE5\u63A5\u53E3\u4F7F\u7528\u539F\u751F\u601D\u8003\u534F\u8BAE\uFF0C\u65E0\u9700\u6307\u5B9A\u601D\u8003\u53C2\u6570\u683C\u5F0F\u3002");
|
|
1282
|
+
}
|
|
1283
|
+
const userProviders = record2(record2(descriptor.user).providers);
|
|
1284
|
+
const userProfile = record2(Object.hasOwn(userProviders, provider) ? userProviders[provider] : void 0);
|
|
1285
|
+
const baseProfile = record2(record2(record2(descriptor.base).providers)[provider]);
|
|
1286
|
+
const source = Array.isArray(userProfile.models) ? userProfile : baseProfile;
|
|
1287
|
+
const storedModels = modelsOf(source);
|
|
1288
|
+
const index = storedModels.findIndex((entry) => entry.id === modelId);
|
|
1289
|
+
if (index < 0) throw new DshMoreError("bad-request", "\u672A\u627E\u5230\u5DF2\u4FDD\u5B58\u7684\u6A21\u578B\uFF0C\u8BF7\u5148\u4FDD\u5B58\u63D0\u4F9B\u65B9\u914D\u7F6E\u3002");
|
|
1290
|
+
const next = { ...storedModels[index] };
|
|
1291
|
+
if (capabilities.vision === null) delete next.input;
|
|
1292
|
+
else {
|
|
1293
|
+
const input = Array.isArray(model.input) ? model.input.filter((entry) => entry !== "image") : ["text"];
|
|
1294
|
+
if (!input.includes("text")) input.unshift("text");
|
|
1295
|
+
next.input = capabilities.vision ? [...input, "image"] : input;
|
|
1296
|
+
}
|
|
1297
|
+
if (capabilities.reasoningEfforts === null) delete next.reasoningEfforts;
|
|
1298
|
+
else next.reasoningEfforts = capabilities.reasoningEfforts;
|
|
1299
|
+
const compat = { ...record2(next.compat) };
|
|
1300
|
+
if (capabilities.thinkingFormat === null) delete compat.thinkingFormat;
|
|
1301
|
+
else compat.thinkingFormat = capabilities.thinkingFormat;
|
|
1302
|
+
if (Object.keys(compat).length === 0) delete next.compat;
|
|
1303
|
+
else next.compat = compat;
|
|
1304
|
+
const nextModels = storedModels.map((entry, position) => position === index ? next : entry);
|
|
1305
|
+
await mutate(ctx, namespace, [{
|
|
1306
|
+
op: "set",
|
|
1307
|
+
path: ["providers"],
|
|
1308
|
+
value: { ...userProviders, [provider]: { ...userProfile, models: nextModels } }
|
|
1309
|
+
}], expectedRevision);
|
|
1310
|
+
return read(ctx);
|
|
1311
|
+
}
|
|
1312
|
+
async function mutate(ctx, namespace, ops, revision) {
|
|
1313
|
+
try {
|
|
1314
|
+
await ctx.settings.mutate(namespace, ops, revision);
|
|
1315
|
+
} catch (error) {
|
|
1316
|
+
if (error instanceof SettingsConflictError) throw staleSettings();
|
|
1317
|
+
throw new DshMoreError("bad-request", "\u6A21\u578B\u914D\u7F6E\u672A\u4FDD\u5B58\uFF0C\u8BF7\u68C0\u67E5\u601D\u8003\u7C7B\u578B\u3001\u63A5\u53E3\u683C\u5F0F\u53CA\u63D0\u4F9B\u65B9\u8BBE\u7F6E\u3002");
|
|
1136
1318
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
return { filled };
|
|
1319
|
+
}
|
|
1320
|
+
function staleSettings() {
|
|
1321
|
+
return new DshMoreError("stale-preview", "\u6A21\u578B\u914D\u7F6E\u5DF2\u53D8\u66F4\uFF0C\u8BF7\u5173\u95ED\u540E\u91CD\u65B0\u6253\u5F00\u6A21\u578B\u80FD\u529B\uFF0C\u518D\u4FDD\u5B58\u4FEE\u6539\u3002", 409);
|
|
1141
1322
|
}
|
|
1142
1323
|
var hostPatch5 = {
|
|
1143
|
-
id:
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
save: (payload) => save(ctx, payload),
|
|
1147
|
-
fillDefaults: () => fillDefaults(ctx)
|
|
1148
|
-
})
|
|
1324
|
+
id: MODEL_CAPABILITIES_PATCH_ID,
|
|
1325
|
+
setup: installDeepSeekReasoning,
|
|
1326
|
+
routes: ({ ctx }) => ({ read: () => read(ctx), save: (payload) => save(ctx, payload) })
|
|
1149
1327
|
};
|
|
1150
1328
|
|
|
1151
1329
|
// src/patches/session-auto-title/host/index.ts
|
|
@@ -1229,8 +1407,8 @@ var hostPatch6 = {
|
|
|
1229
1407
|
async function* dispatch() {
|
|
1230
1408
|
if (revised.reasoningEffort === void 0) {
|
|
1231
1409
|
const info = await scope.llm.resolveModelInfo(revised.provider, revised.model, signal);
|
|
1232
|
-
const
|
|
1233
|
-
const effort =
|
|
1410
|
+
const reasoning2 = info.reasoning;
|
|
1411
|
+
const effort = reasoning2?.defaultEffort ?? (reasoning2?.efforts.some((item) => item.id === "off") ? void 0 : reasoning2?.efforts[0]?.id);
|
|
1234
1412
|
if (effort !== void 0) revised.reasoningEffort = effort;
|
|
1235
1413
|
}
|
|
1236
1414
|
signal.throwIfAborted();
|
|
@@ -1268,8 +1446,78 @@ var hostPatch6 = {
|
|
|
1268
1446
|
})
|
|
1269
1447
|
};
|
|
1270
1448
|
|
|
1449
|
+
// src/patches/projectless-tasks/host/index.ts
|
|
1450
|
+
import { homedir } from "node:os";
|
|
1451
|
+
import { join } from "node:path";
|
|
1452
|
+
|
|
1453
|
+
// src/patches/projectless-tasks/shared.ts
|
|
1454
|
+
var PROJECTLESS_TASKS_PATCH_ID = "projectless-tasks";
|
|
1455
|
+
var TASK_ID_PATTERN = /^task-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
1456
|
+
|
|
1457
|
+
// src/patches/projectless-tasks/groups.ts
|
|
1458
|
+
var SESSION_GROUPS_NAMESPACE = "dsh-more-session-groups";
|
|
1459
|
+
var EMPTY_GROUPS = { assignments: {} };
|
|
1460
|
+
function decodeSessionGroups(value) {
|
|
1461
|
+
if (typeof value !== "object" || value === null || !("assignments" in value)) return void 0;
|
|
1462
|
+
const assignments = value.assignments;
|
|
1463
|
+
if (typeof assignments !== "object" || assignments === null || Array.isArray(assignments) || !Object.values(assignments).every((id) => typeof id === "string")) return void 0;
|
|
1464
|
+
return { assignments };
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
// src/patches/projectless-tasks/host/groups.ts
|
|
1468
|
+
import z2 from "@deepseek-ai/schemastery";
|
|
1469
|
+
import { SessionId as SessionId7 } from "@deepseek-ai/dsh-session";
|
|
1470
|
+
import { WorkspaceId } from "@deepseek-ai/dsh-workspace";
|
|
1471
|
+
var SessionGroupsSchema = z2.object({ assignments: z2.dict(z2.string()).default({}) });
|
|
1472
|
+
async function moveSessionGroup(ctx, payload) {
|
|
1473
|
+
const sessionId = SessionId7(requireString(payload, "sessionId"));
|
|
1474
|
+
if (typeof payload !== "object" || payload === null || !("workspaceId" in payload) || !(payload.workspaceId === null || typeof payload.workspaceId === "string" && payload.workspaceId.length > 0)) {
|
|
1475
|
+
throw new DshMoreError("bad-request", "\u8BF7\u9009\u62E9\u76EE\u6807\u5DE5\u4F5C\u533A\u3002");
|
|
1476
|
+
}
|
|
1477
|
+
const workspaceId = payload.workspaceId;
|
|
1478
|
+
if (!ctx.settings.writable) throw new DshMoreError("forbidden", "\u5F53\u524D\u914D\u7F6E\u4E3A\u53EA\u8BFB\uFF0C\u65E0\u6CD5\u79FB\u52A8\u4F1A\u8BDD\u3002", 403);
|
|
1479
|
+
if (workspaceId !== null && ctx.workspaceRegistry.get(WorkspaceId(workspaceId)) === void 0) {
|
|
1480
|
+
throw new DshMoreError("not-found", "\u76EE\u6807\u5DE5\u4F5C\u533A\u5DF2\u4E0D\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002", 404);
|
|
1481
|
+
}
|
|
1482
|
+
const storedHeaders = async () => {
|
|
1483
|
+
const stored = await ctx.sessionPersistence.list();
|
|
1484
|
+
return stored.map((item) => "header" in item ? item.header : item);
|
|
1485
|
+
};
|
|
1486
|
+
const header2 = ctx.sessions.get(sessionId)?.header ?? (await storedHeaders()).find((item) => item.id === sessionId);
|
|
1487
|
+
if (header2 === void 0) throw new DshMoreError("not-found", "\u8BE5\u4F1A\u8BDD\u5DF2\u4E0D\u5B58\u5728\u3002", 404);
|
|
1488
|
+
if (header2.origin === "subagent") throw new DshMoreError("bad-request", "\u5B50\u4F1A\u8BDD\u8DDF\u968F\u4E3B\u4F1A\u8BDD\u5F52\u7EC4\uFF0C\u8BF7\u79FB\u52A8\u4E3B\u4F1A\u8BDD\u3002");
|
|
1489
|
+
if (ctx.workspaceRegistry.list().some((workspace) => workspace.sessionIds.includes(sessionId))) {
|
|
1490
|
+
throw new DshMoreError("bad-request", "\u8FD9\u6761\u4F1A\u8BDD\u5DF2\u6709\u539F\u751F\u5DE5\u4F5C\u533A\uFF0C\u53EA\u652F\u6301\u79FB\u52A8\u672A\u5206\u7EC4\u6216\u624B\u52A8\u5F52\u7EC4\u7684\u4F1A\u8BDD\u3002");
|
|
1491
|
+
}
|
|
1492
|
+
const current = decodeSessionGroups(ctx.settings.get(SESSION_GROUPS_NAMESPACE)) ?? EMPTY_GROUPS;
|
|
1493
|
+
const result = { sessionId, workspaceId };
|
|
1494
|
+
if ((current.assignments[sessionId] ?? null) === workspaceId) return result;
|
|
1495
|
+
await ctx.settings.mutate(SESSION_GROUPS_NAMESPACE, [workspaceId === null ? { op: "unset", path: ["assignments", sessionId] } : { op: "set", path: ["assignments", sessionId], value: workspaceId }]);
|
|
1496
|
+
return result;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
// src/patches/projectless-tasks/host/index.ts
|
|
1500
|
+
function prepareTask(payload, homeDirectory = homedir()) {
|
|
1501
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload) || !("sessionId" in payload) || typeof payload.sessionId !== "string" || !TASK_ID_PATTERN.test(payload.sessionId) || Object.keys(payload).length !== 1) {
|
|
1502
|
+
throw new DshMoreError("bad-request", "\u72EC\u7ACB\u4EFB\u52A1\u6807\u8BC6\u65E0\u6548\uFF0C\u8BF7\u91CD\u65B0\u65B0\u5EFA\u4EFB\u52A1\u3002");
|
|
1503
|
+
}
|
|
1504
|
+
return { sessionId: payload.sessionId, cwd: join(homeDirectory, "Documents", "DSH", "tasks", payload.sessionId) };
|
|
1505
|
+
}
|
|
1506
|
+
var hostPatch7 = {
|
|
1507
|
+
id: PROJECTLESS_TASKS_PATCH_ID,
|
|
1508
|
+
setup: (ctx) => {
|
|
1509
|
+
const fiber = ctx.inject(["settings"], (scope) => {
|
|
1510
|
+
scope.settings.register(SESSION_GROUPS_NAMESPACE, SessionGroupsSchema);
|
|
1511
|
+
});
|
|
1512
|
+
return () => {
|
|
1513
|
+
void fiber.dispose();
|
|
1514
|
+
};
|
|
1515
|
+
},
|
|
1516
|
+
routes: ({ ctx }) => ({ prepare: (payload) => prepareTask(payload), move: (payload) => moveSessionGroup(ctx, payload) })
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1271
1519
|
// src/generated/host-registry.ts
|
|
1272
|
-
var HOST_PATCHES = [hostPatch, hostPatch2, hostPatch3, hostPatch4, hostPatch5, hostPatch6];
|
|
1520
|
+
var HOST_PATCHES = [hostPatch, hostPatch2, hostPatch3, hostPatch4, hostPatch5, hostPatch6, hostPatch7];
|
|
1273
1521
|
|
|
1274
1522
|
// src/generated/patch-catalog.ts
|
|
1275
1523
|
var DEFAULT_PATCH_SETTINGS = {
|
|
@@ -1277,8 +1525,9 @@ var DEFAULT_PATCH_SETTINGS = {
|
|
|
1277
1525
|
"message-delete": true,
|
|
1278
1526
|
"session-delete": true,
|
|
1279
1527
|
"conversation-markdown-export": true,
|
|
1280
|
-
"model-
|
|
1281
|
-
"session-auto-title": true
|
|
1528
|
+
"model-capabilities": true,
|
|
1529
|
+
"session-auto-title": true,
|
|
1530
|
+
"projectless-tasks": true
|
|
1282
1531
|
};
|
|
1283
1532
|
|
|
1284
1533
|
// src/kernel/host/activation.ts
|
|
@@ -1315,14 +1564,15 @@ var HostPatchActivation = class {
|
|
|
1315
1564
|
};
|
|
1316
1565
|
|
|
1317
1566
|
// src/generated/host-settings-schema.ts
|
|
1318
|
-
import
|
|
1319
|
-
var PatchSettingsSchema =
|
|
1320
|
-
"message-edit":
|
|
1321
|
-
"message-delete":
|
|
1322
|
-
"session-delete":
|
|
1323
|
-
"conversation-markdown-export":
|
|
1324
|
-
"model-
|
|
1325
|
-
"session-auto-title":
|
|
1567
|
+
import z3 from "@deepseek-ai/schemastery";
|
|
1568
|
+
var PatchSettingsSchema = z3.object({
|
|
1569
|
+
"message-edit": z3.boolean().default(true),
|
|
1570
|
+
"message-delete": z3.boolean().default(true),
|
|
1571
|
+
"session-delete": z3.boolean().default(true),
|
|
1572
|
+
"conversation-markdown-export": z3.boolean().default(true),
|
|
1573
|
+
"model-capabilities": z3.boolean().default(true),
|
|
1574
|
+
"session-auto-title": z3.boolean().default(true),
|
|
1575
|
+
"projectless-tasks": z3.boolean().default(true)
|
|
1326
1576
|
});
|
|
1327
1577
|
|
|
1328
1578
|
// src/kernel/host/settings.ts
|