dsh-mcviseron-plugin 0.7.2 → 0.7.8
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/CHANGELOG.md +71 -0
- package/README.en.md +12 -8
- package/README.md +16 -12
- package/docs/archive-integration.md +29 -0
- package/docs/auto-review-context.md +25 -24
- package/docs/automation-task.md +1 -1
- package/docs/release.md +2 -2
- package/lib/auto-review-fix.js +135 -6
- package/lib/client.js +105 -1
- package/lib/index.js +327 -65
- package/package.json +24 -23
- package/src/api.ts +5 -0
- package/src/archive-integration/index.ts +83 -0
- package/src/auto-review-fix/index.ts +2 -2
- package/src/automation-tasks/index.ts +59 -14
- package/src/client/SettingsSection.tsx +92 -3
- package/src/client/locales.ts +28 -0
- package/src/components/auto-review-fix/index.ts +2 -2
- package/src/components/auto-review-fix/review-context.ts +144 -2
- package/src/index.ts +2 -0
package/lib/index.js
CHANGED
|
@@ -11295,6 +11295,9 @@ var SESSION_END_API = {
|
|
|
11295
11295
|
var AUTH_COOKIE_API = {
|
|
11296
11296
|
prune: "/api/dsh-mcviseron/auth-cookies/prune"
|
|
11297
11297
|
};
|
|
11298
|
+
var ARCHIVE_API = {
|
|
11299
|
+
status: "/api/dsh-mcviseron/archive-integration/status"
|
|
11300
|
+
};
|
|
11298
11301
|
|
|
11299
11302
|
// src/namespace.ts
|
|
11300
11303
|
var MCVISERON_SETTINGS_NAMESPACE = "mcviseron";
|
|
@@ -11569,15 +11572,103 @@ function apply(ctx, _config) {
|
|
|
11569
11572
|
});
|
|
11570
11573
|
}
|
|
11571
11574
|
|
|
11575
|
+
// src/archive-integration/index.ts
|
|
11576
|
+
var archive_integration_exports = {};
|
|
11577
|
+
__export(archive_integration_exports, {
|
|
11578
|
+
apply: () => apply2,
|
|
11579
|
+
inject: () => inject2,
|
|
11580
|
+
makeArchiveStatus: () => makeArchiveStatus
|
|
11581
|
+
});
|
|
11582
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
11583
|
+
import { homedir } from "node:os";
|
|
11584
|
+
import { join } from "node:path";
|
|
11585
|
+
function dshHome() {
|
|
11586
|
+
const raw = process.env.DSH_HOME;
|
|
11587
|
+
if (raw !== void 0 && raw.trim() !== "") return raw.trim().startsWith("~") ? join(homedir(), raw.trim().slice(1).replace(/^[\\/]/, "")) : raw.trim();
|
|
11588
|
+
return join(homedir(), ".dsh");
|
|
11589
|
+
}
|
|
11590
|
+
function archiveAvailable(ctx) {
|
|
11591
|
+
try {
|
|
11592
|
+
const loader = ctx.loader;
|
|
11593
|
+
for (const entry of loader?.entries?.() ?? []) {
|
|
11594
|
+
const name = String(entry.options?.name ?? "");
|
|
11595
|
+
if (name.includes("session-archive") && entry.disabled !== true && entry.fiber !== void 0 && entry.fiber !== null) return true;
|
|
11596
|
+
}
|
|
11597
|
+
} catch {
|
|
11598
|
+
}
|
|
11599
|
+
return false;
|
|
11600
|
+
}
|
|
11601
|
+
function archivedIds(ctx) {
|
|
11602
|
+
try {
|
|
11603
|
+
const registry = ctx.get?.("workspaceRegistry");
|
|
11604
|
+
const value = registry?.archivedSessionIds;
|
|
11605
|
+
return Array.isArray(value) ? value.filter((id) => typeof id === "string" && id.length > 0) : [];
|
|
11606
|
+
} catch {
|
|
11607
|
+
return [];
|
|
11608
|
+
}
|
|
11609
|
+
}
|
|
11610
|
+
function makeArchiveStatus(ctx) {
|
|
11611
|
+
const available = archiveAvailable(ctx);
|
|
11612
|
+
const ledgerPath = join(dshHome(), "dsh-session-archive", "archive-ledger.json");
|
|
11613
|
+
let ledger;
|
|
11614
|
+
try {
|
|
11615
|
+
ledger = JSON.parse(readFileSync(ledgerPath, "utf8"));
|
|
11616
|
+
} catch {
|
|
11617
|
+
ledger = void 0;
|
|
11618
|
+
}
|
|
11619
|
+
const entries = ledger?.entries !== null && typeof ledger?.entries === "object" ? ledger.entries : {};
|
|
11620
|
+
const ids = archivedIds(ctx);
|
|
11621
|
+
let observed = 0;
|
|
11622
|
+
let manual = 0;
|
|
11623
|
+
for (const entry of Object.values(entries)) {
|
|
11624
|
+
if (entry.source === "observed") observed++;
|
|
11625
|
+
else if (entry.source === "manual") manual++;
|
|
11626
|
+
}
|
|
11627
|
+
let unknown = 0;
|
|
11628
|
+
for (const id of ids) if (entries[id] === void 0) unknown++;
|
|
11629
|
+
return {
|
|
11630
|
+
ok: true,
|
|
11631
|
+
available,
|
|
11632
|
+
ledgerPath,
|
|
11633
|
+
ledgerExists: existsSync(ledgerPath),
|
|
11634
|
+
entries: Object.keys(entries).length,
|
|
11635
|
+
observed,
|
|
11636
|
+
manual,
|
|
11637
|
+
archivedCount: ids.length,
|
|
11638
|
+
unknownCount: unknown
|
|
11639
|
+
};
|
|
11640
|
+
}
|
|
11641
|
+
var inject2 = ["webServer"];
|
|
11642
|
+
function apply2(ctx) {
|
|
11643
|
+
ctx.effect(() => ctx.webServer.register({
|
|
11644
|
+
kind: "exact",
|
|
11645
|
+
path: ARCHIVE_API.status,
|
|
11646
|
+
handler: async (req, res) => {
|
|
11647
|
+
const send = (status, value) => {
|
|
11648
|
+
res.statusCode = status;
|
|
11649
|
+
res.setHeader("content-type", "application/json; charset=utf-8");
|
|
11650
|
+
res.end(JSON.stringify(value));
|
|
11651
|
+
};
|
|
11652
|
+
if (req.method !== "GET" && req.method !== "POST") return send(405, { ok: false, error: "method-not-allowed" });
|
|
11653
|
+
if (!isLoopbackRequest(req)) return send(403, { ok: false, error: "forbidden" });
|
|
11654
|
+
try {
|
|
11655
|
+
send(200, makeArchiveStatus(ctx));
|
|
11656
|
+
} catch (error) {
|
|
11657
|
+
send(500, { ok: false, error: error instanceof Error ? error.message : String(error) });
|
|
11658
|
+
}
|
|
11659
|
+
}
|
|
11660
|
+
}), "mcviseron: archive integration status");
|
|
11661
|
+
}
|
|
11662
|
+
|
|
11572
11663
|
// src/auth-cookie/index.ts
|
|
11573
11664
|
var auth_cookie_exports = {};
|
|
11574
11665
|
__export(auth_cookie_exports, {
|
|
11575
11666
|
AUTH_COOKIE_PREFIX: () => AUTH_COOKIE_PREFIX,
|
|
11576
|
-
apply: () =>
|
|
11667
|
+
apply: () => apply3,
|
|
11577
11668
|
authCookieName: () => authCookieName,
|
|
11578
11669
|
authCookieNames: () => authCookieNames,
|
|
11579
11670
|
expiredAuthCookie: () => expiredAuthCookie,
|
|
11580
|
-
inject: () =>
|
|
11671
|
+
inject: () => inject3,
|
|
11581
11672
|
makeAuthCookieRoutes: () => makeAuthCookieRoutes,
|
|
11582
11673
|
pruneCookieHeaders: () => pruneCookieHeaders,
|
|
11583
11674
|
pruneScript: () => pruneScript,
|
|
@@ -11587,13 +11678,13 @@ __export(auth_cookie_exports, {
|
|
|
11587
11678
|
import { createHash } from "node:crypto";
|
|
11588
11679
|
import { appendFileSync } from "node:fs";
|
|
11589
11680
|
import { tmpdir } from "node:os";
|
|
11590
|
-
import { join } from "node:path";
|
|
11681
|
+
import { join as join2 } from "node:path";
|
|
11591
11682
|
var AUTH_COOKIE_PREFIX = "dsh-auth-";
|
|
11592
11683
|
var EXPIRED_AT = "Thu, 01 Jan 1970 00:00:00 GMT";
|
|
11593
11684
|
function logPrune(authority, pruned) {
|
|
11594
11685
|
try {
|
|
11595
11686
|
appendFileSync(
|
|
11596
|
-
|
|
11687
|
+
join2(tmpdir(), "dsh-mcviseron-auth-cookie.log"),
|
|
11597
11688
|
(/* @__PURE__ */ new Date()).toISOString() + " pruned=" + pruned + " authority=" + authority + "\n",
|
|
11598
11689
|
"utf8"
|
|
11599
11690
|
);
|
|
@@ -11696,8 +11787,8 @@ function installIndexInjection(ctx) {
|
|
|
11696
11787
|
} catch {
|
|
11697
11788
|
}
|
|
11698
11789
|
}
|
|
11699
|
-
var
|
|
11700
|
-
function
|
|
11790
|
+
var inject3 = ["webServer"];
|
|
11791
|
+
function apply3(ctx) {
|
|
11701
11792
|
const secure = () => {
|
|
11702
11793
|
try {
|
|
11703
11794
|
return ctx.webServer.protocol === "https:";
|
|
@@ -11718,12 +11809,12 @@ function apply2(ctx) {
|
|
|
11718
11809
|
// src/automation-tasks/index.ts
|
|
11719
11810
|
var automation_tasks_exports = {};
|
|
11720
11811
|
__export(automation_tasks_exports, {
|
|
11721
|
-
apply: () =>
|
|
11812
|
+
apply: () => apply4,
|
|
11722
11813
|
makeAutomationTaskTools: () => makeAutomationTaskTools
|
|
11723
11814
|
});
|
|
11724
11815
|
import { appendFileSync as appendFileSync2 } from "node:fs";
|
|
11725
11816
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
11726
|
-
import { join as
|
|
11817
|
+
import { join as join3 } from "node:path";
|
|
11727
11818
|
var OUTPUT_SCHEMA = { type: "object", additionalProperties: true };
|
|
11728
11819
|
var SELECTOR_KEYS = ["after_seconds", "at", "every_seconds", "daily", "weekly", "cron"];
|
|
11729
11820
|
function output() {
|
|
@@ -11734,10 +11825,26 @@ function output() {
|
|
|
11734
11825
|
}
|
|
11735
11826
|
function log(message) {
|
|
11736
11827
|
try {
|
|
11737
|
-
appendFileSync2(
|
|
11828
|
+
appendFileSync2(join3(tmpdir2(), "dsh-mcviseron-automation-tasks.log"), (/* @__PURE__ */ new Date()).toISOString() + " " + message + "\n", "utf8");
|
|
11738
11829
|
} catch {
|
|
11739
11830
|
}
|
|
11740
11831
|
}
|
|
11832
|
+
function isModernSchedule(schedule) {
|
|
11833
|
+
return typeof schedule.edit === "function";
|
|
11834
|
+
}
|
|
11835
|
+
function modernTiming(args) {
|
|
11836
|
+
if (args.after_seconds !== void 0) return { kind: "after", after_seconds: args.after_seconds };
|
|
11837
|
+
if (args.at !== void 0) return { kind: "at", at: args.at };
|
|
11838
|
+
if (args.every_seconds !== void 0) return { kind: "every", every_seconds: args.every_seconds };
|
|
11839
|
+
if (args.daily !== void 0) return { kind: "daily", daily: args.daily };
|
|
11840
|
+
if (args.weekly !== void 0) return { kind: "weekly", weekly: args.weekly };
|
|
11841
|
+
if (args.cron !== void 0) return { kind: "cron", cron: args.cron };
|
|
11842
|
+
if (args.rrule !== void 0) return { kind: "rrule", rrule: args.rrule };
|
|
11843
|
+
return void 0;
|
|
11844
|
+
}
|
|
11845
|
+
function listRecords(result) {
|
|
11846
|
+
return Array.isArray(result) ? result : result.items;
|
|
11847
|
+
}
|
|
11741
11848
|
function sessionIdOf(exec) {
|
|
11742
11849
|
const id = exec.agent?.session?.id;
|
|
11743
11850
|
return typeof id === "string" ? id : "";
|
|
@@ -11857,7 +11964,7 @@ function makeAutomationTaskTools(schedule) {
|
|
|
11857
11964
|
const sessionId = sessionIdOf(exec);
|
|
11858
11965
|
if (sessionId === "") return { ok: false, code: "no_session", error: "no current session" };
|
|
11859
11966
|
try {
|
|
11860
|
-
return { ok: true, tasks: await schedule.list({ sessionId }) };
|
|
11967
|
+
return { ok: true, tasks: listRecords(await schedule.list(isModernSchedule(schedule) ? {} : { sessionId })) };
|
|
11861
11968
|
} catch (error) {
|
|
11862
11969
|
return serviceFailure(error);
|
|
11863
11970
|
}
|
|
@@ -11874,11 +11981,23 @@ function makeAutomationTaskTools(schedule) {
|
|
|
11874
11981
|
const invalidInput = validateCreate(args);
|
|
11875
11982
|
if (invalidInput !== void 0) return invalid(invalidInput);
|
|
11876
11983
|
try {
|
|
11877
|
-
|
|
11878
|
-
|
|
11879
|
-
|
|
11880
|
-
|
|
11881
|
-
|
|
11984
|
+
let record2;
|
|
11985
|
+
if (isModernSchedule(schedule)) {
|
|
11986
|
+
const timing = modernTiming(args);
|
|
11987
|
+
if (timing === void 0) return invalid("timing is required");
|
|
11988
|
+
record2 = await schedule.create({
|
|
11989
|
+
title: String(args.title).trim(),
|
|
11990
|
+
prompt: String(args.prompt).trim(),
|
|
11991
|
+
timing,
|
|
11992
|
+
target: { kind: "session", sessionId }
|
|
11993
|
+
}, sessionId, exec.signal);
|
|
11994
|
+
} else {
|
|
11995
|
+
record2 = await schedule.create(sessionId, {
|
|
11996
|
+
...args,
|
|
11997
|
+
title: String(args.title).trim(),
|
|
11998
|
+
prompt: String(args.prompt).trim()
|
|
11999
|
+
}, exec.signal);
|
|
12000
|
+
}
|
|
11882
12001
|
return { ok: true, task: record2 };
|
|
11883
12002
|
} catch (error) {
|
|
11884
12003
|
return serviceFailure(error);
|
|
@@ -11897,9 +12016,18 @@ function makeAutomationTaskTools(schedule) {
|
|
|
11897
12016
|
if (invalidInput !== void 0) return invalid(invalidInput);
|
|
11898
12017
|
try {
|
|
11899
12018
|
const id = String(args.id);
|
|
11900
|
-
const expected = (await schedule.list({ sessionId })).find((record2) => record2.id === id);
|
|
11901
|
-
if (expected === void 0) return { ok: false, code: "schedule_not_found", error: "automation task not found
|
|
12019
|
+
const expected = listRecords(await schedule.list(isModernSchedule(schedule) ? {} : { sessionId })).find((record2) => record2.id === id);
|
|
12020
|
+
if (expected === void 0) return { ok: false, code: "schedule_not_found", error: "automation task not found: " + id };
|
|
11902
12021
|
const change = timingChange(args);
|
|
12022
|
+
if (isModernSchedule(schedule)) {
|
|
12023
|
+
const patch = {};
|
|
12024
|
+
if (args.title !== void 0) patch.title = String(args.title).trim();
|
|
12025
|
+
if (args.prompt !== void 0) patch.prompt = String(args.prompt).trim();
|
|
12026
|
+
const timing = modernTiming(args);
|
|
12027
|
+
if (timing !== void 0) patch.timing = timing;
|
|
12028
|
+
const result2 = await schedule.edit({ id, action: "update", patch }, sessionId, exec.signal);
|
|
12029
|
+
return { ok: true, task: result2 };
|
|
12030
|
+
}
|
|
11903
12031
|
const result = await schedule.update({
|
|
11904
12032
|
sessionId,
|
|
11905
12033
|
id,
|
|
@@ -11927,6 +12055,10 @@ function makeAutomationTaskTools(schedule) {
|
|
|
11927
12055
|
return invalid("id must be a non-empty string without surrounding whitespace");
|
|
11928
12056
|
}
|
|
11929
12057
|
try {
|
|
12058
|
+
if (isModernSchedule(schedule)) {
|
|
12059
|
+
const result2 = await schedule.edit({ id: String(args.id), action: "delete" }, sessionId, exec.signal);
|
|
12060
|
+
return { ok: true, ...result2 };
|
|
12061
|
+
}
|
|
11930
12062
|
const result = await schedule.delete({ sessionId, id: String(args.id) }, exec.signal);
|
|
11931
12063
|
return { ok: true, ...result };
|
|
11932
12064
|
} catch (error) {
|
|
@@ -11945,11 +12077,11 @@ function serviceOf(scope, name) {
|
|
|
11945
12077
|
return void 0;
|
|
11946
12078
|
}
|
|
11947
12079
|
}
|
|
11948
|
-
function
|
|
11949
|
-
const
|
|
11950
|
-
if (typeof
|
|
12080
|
+
function apply4(ctx) {
|
|
12081
|
+
const inject6 = ctx.inject;
|
|
12082
|
+
if (typeof inject6 !== "function") return;
|
|
11951
12083
|
try {
|
|
11952
|
-
|
|
12084
|
+
inject6.call(ctx, ["tools", "schedule"], (scope) => {
|
|
11953
12085
|
const tools = serviceOf(scope, "tools");
|
|
11954
12086
|
const schedule = serviceOf(scope, "schedule");
|
|
11955
12087
|
if (tools === void 0 || typeof tools.register !== "function" || schedule === void 0) {
|
|
@@ -11980,7 +12112,7 @@ function apply3(ctx) {
|
|
|
11980
12112
|
log("tool injection failed: " + (error instanceof Error ? error.message : String(error)));
|
|
11981
12113
|
}
|
|
11982
12114
|
try {
|
|
11983
|
-
|
|
12115
|
+
inject6.call(ctx, ["systemPrompt"], (scope) => {
|
|
11984
12116
|
const systemPrompt = serviceOf(scope, "systemPrompt");
|
|
11985
12117
|
if (typeof systemPrompt?.section === "function") {
|
|
11986
12118
|
systemPrompt.section({
|
|
@@ -12004,7 +12136,7 @@ var auto_review_fix_exports = {};
|
|
|
12004
12136
|
__export(auto_review_fix_exports, {
|
|
12005
12137
|
Config: () => Config2,
|
|
12006
12138
|
DEFAULT_AUTO_REVIEW_CONFIG: () => DEFAULT_AUTO_REVIEW_CONFIG,
|
|
12007
|
-
apply: () =>
|
|
12139
|
+
apply: () => apply5
|
|
12008
12140
|
});
|
|
12009
12141
|
import z2 from "@deepseek-ai/schemastery";
|
|
12010
12142
|
|
|
@@ -12014,7 +12146,7 @@ import { randomUUID } from "node:crypto";
|
|
|
12014
12146
|
// src/components/auto-review-fix/review-context.ts
|
|
12015
12147
|
import { appendFileSync as appendFileSync3 } from "node:fs";
|
|
12016
12148
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
12017
|
-
import { join as
|
|
12149
|
+
import { join as join4 } from "node:path";
|
|
12018
12150
|
var REVIEW_MARKER = "REVIEW_POLICY";
|
|
12019
12151
|
var REVIEW_MARKER_2 = "final authorization reviewer";
|
|
12020
12152
|
var HISTORY_HEADER = "FILTERED_HISTORY\n\n";
|
|
@@ -12035,7 +12167,7 @@ function textOf(message) {
|
|
|
12035
12167
|
}
|
|
12036
12168
|
return texts.join("");
|
|
12037
12169
|
}
|
|
12038
|
-
function
|
|
12170
|
+
function isLegacyAutoReviewRequest(options) {
|
|
12039
12171
|
if (!record(options)) return false;
|
|
12040
12172
|
const system = options.system;
|
|
12041
12173
|
if (typeof system !== "string" || !system.includes(REVIEW_MARKER) || !system.includes(REVIEW_MARKER_2)) return false;
|
|
@@ -12126,7 +12258,7 @@ function parseArray(text3) {
|
|
|
12126
12258
|
function logTrim(originalChars, nextChars, originalEntries, nextEntries) {
|
|
12127
12259
|
try {
|
|
12128
12260
|
appendFileSync3(
|
|
12129
|
-
|
|
12261
|
+
join4(tmpdir3(), "dsh-mcviseron-auto-review.log"),
|
|
12130
12262
|
(/* @__PURE__ */ new Date()).toISOString() + " review context trimmed: " + String(originalChars) + " -> " + String(nextChars) + " chars, history " + String(originalEntries) + " -> " + String(nextEntries) + "\n",
|
|
12131
12263
|
"utf8"
|
|
12132
12264
|
);
|
|
@@ -12134,7 +12266,9 @@ function logTrim(originalChars, nextChars, originalEntries, nextEntries) {
|
|
|
12134
12266
|
}
|
|
12135
12267
|
}
|
|
12136
12268
|
function trimReviewRequest(options, settings) {
|
|
12137
|
-
if (!settings.enabled
|
|
12269
|
+
if (!settings.enabled) return options;
|
|
12270
|
+
if (isModernAutoReviewRequest(options)) return trimModernReviewRequest(options, settings);
|
|
12271
|
+
if (!isLegacyAutoReviewRequest(options)) return options;
|
|
12138
12272
|
const messages = options.messages;
|
|
12139
12273
|
const message = messages[0];
|
|
12140
12274
|
const text3 = textOf(message);
|
|
@@ -12162,12 +12296,139 @@ function trimReviewRequest(options, settings) {
|
|
|
12162
12296
|
]
|
|
12163
12297
|
};
|
|
12164
12298
|
}
|
|
12299
|
+
var MODERN_PURPOSE = "auto-review";
|
|
12300
|
+
var ENVIRONMENT_HEADER = "ENVIRONMENT\n";
|
|
12301
|
+
var MODERN_USER_ROLES = /* @__PURE__ */ new Set(["user-instruction", "direct-parent-instruction", "constraint", "checkpoint", "human-instruction"]);
|
|
12302
|
+
var MODERN_USER_TEXT_CHARS = 8e3;
|
|
12303
|
+
var MODERN_TOOL_ARGUMENT_CHARS = 4e3;
|
|
12304
|
+
var MODERN_SCHEMA_DESCRIPTION_CHARS = 4e3;
|
|
12305
|
+
var MODERN_SCHEMA_PARAMETER_CHARS = 12e3;
|
|
12306
|
+
function isModernAutoReviewRequest(options) {
|
|
12307
|
+
if (!record(options) || options.purpose !== MODERN_PURPOSE) return false;
|
|
12308
|
+
if (typeof options.system !== "string" || !options.system.includes(REVIEW_MARKER) || !options.system.includes(REVIEW_MARKER_2)) return false;
|
|
12309
|
+
if (!Array.isArray(options.messages) || options.messages.length < 2) return false;
|
|
12310
|
+
const first = textOf(options.messages[0]);
|
|
12311
|
+
return first !== void 0 && first.startsWith(ENVIRONMENT_HEADER);
|
|
12312
|
+
}
|
|
12313
|
+
function modernRole(entry) {
|
|
12314
|
+
return record(entry) && typeof entry.role === "string" ? entry.role : void 0;
|
|
12315
|
+
}
|
|
12316
|
+
function modernProtected(entry, index, lastIndex, schemaIndexes) {
|
|
12317
|
+
if (index === lastIndex) return true;
|
|
12318
|
+
const role = modernRole(entry);
|
|
12319
|
+
if (role !== void 0 && MODERN_USER_ROLES.has(role)) return true;
|
|
12320
|
+
return schemaIndexes.has(index);
|
|
12321
|
+
}
|
|
12322
|
+
function compactModernContent(content, textLimit) {
|
|
12323
|
+
if (!Array.isArray(content)) return [];
|
|
12324
|
+
return content.map((block) => {
|
|
12325
|
+
if (!record(block)) return { type: "text", text: "[non-text history block omitted from reviewer context]" };
|
|
12326
|
+
if (block.type === "text" && typeof block.text === "string") {
|
|
12327
|
+
return { ...block, text: truncateText(block.text, textLimit) };
|
|
12328
|
+
}
|
|
12329
|
+
return { type: "text", text: "[" + String(block.type ?? "attachment") + " omitted from reviewer context]" };
|
|
12330
|
+
});
|
|
12331
|
+
}
|
|
12332
|
+
function compactModernEntry(entry, pending) {
|
|
12333
|
+
if (!record(entry)) return { kind: "summary", role: "fact", content: [{ type: "text", text: "[invalid history entry omitted]" }] };
|
|
12334
|
+
if (pending) return entry;
|
|
12335
|
+
if (entry.kind === "user-message") {
|
|
12336
|
+
return { ...entry, content: compactModernContent(entry.content, MODERN_USER_TEXT_CHARS) };
|
|
12337
|
+
}
|
|
12338
|
+
if (entry.kind === "tool-call") {
|
|
12339
|
+
if (typeof entry.arguments === "string") {
|
|
12340
|
+
return { ...entry, arguments: truncateText(entry.arguments, MODERN_TOOL_ARGUMENT_CHARS) };
|
|
12341
|
+
}
|
|
12342
|
+
if (entry.arguments !== void 0) {
|
|
12343
|
+
let rendered = "";
|
|
12344
|
+
try {
|
|
12345
|
+
rendered = JSON.stringify(entry.arguments) ?? "";
|
|
12346
|
+
} catch {
|
|
12347
|
+
rendered = "";
|
|
12348
|
+
}
|
|
12349
|
+
return { ...entry, arguments: truncateText(rendered, MODERN_TOOL_ARGUMENT_CHARS) };
|
|
12350
|
+
}
|
|
12351
|
+
}
|
|
12352
|
+
if (entry.kind === "tool-schema") {
|
|
12353
|
+
const description = typeof entry.description === "string" ? truncateText(entry.description, MODERN_SCHEMA_DESCRIPTION_CHARS) : entry.description;
|
|
12354
|
+
let parameters = entry.parameters;
|
|
12355
|
+
if (parameters !== void 0) {
|
|
12356
|
+
try {
|
|
12357
|
+
const rendered = JSON.stringify(parameters) ?? "";
|
|
12358
|
+
if (rendered.length > MODERN_SCHEMA_PARAMETER_CHARS) parameters = truncateText(rendered, MODERN_SCHEMA_PARAMETER_CHARS);
|
|
12359
|
+
} catch {
|
|
12360
|
+
parameters = "[unserializable schema parameters omitted]";
|
|
12361
|
+
}
|
|
12362
|
+
}
|
|
12363
|
+
return { ...entry, description, parameters };
|
|
12364
|
+
}
|
|
12365
|
+
return entry;
|
|
12366
|
+
}
|
|
12367
|
+
function modernSchemaIndexes(entries) {
|
|
12368
|
+
const indexes = /* @__PURE__ */ new Map();
|
|
12369
|
+
entries.forEach((entry, index) => {
|
|
12370
|
+
if (!record(entry) || entry.kind !== "tool-schema") return;
|
|
12371
|
+
indexes.set(String(entry.mode) + "\0" + String(entry.name), index);
|
|
12372
|
+
});
|
|
12373
|
+
return new Set(indexes.values());
|
|
12374
|
+
}
|
|
12375
|
+
function trimModernReviewRequest(options, settings) {
|
|
12376
|
+
const messages = options.messages;
|
|
12377
|
+
const first = textOf(messages[0]);
|
|
12378
|
+
if (first === void 0 || !first.startsWith(ENVIRONMENT_HEADER)) return options;
|
|
12379
|
+
const entries = [];
|
|
12380
|
+
for (const message of messages.slice(1)) {
|
|
12381
|
+
const text3 = textOf(message);
|
|
12382
|
+
if (text3 === void 0) return options;
|
|
12383
|
+
try {
|
|
12384
|
+
entries.push(JSON.parse(text3));
|
|
12385
|
+
} catch {
|
|
12386
|
+
return options;
|
|
12387
|
+
}
|
|
12388
|
+
}
|
|
12389
|
+
if (entries.length === 0) return options;
|
|
12390
|
+
const lastIndex = entries.length - 1;
|
|
12391
|
+
const schemaIndexes = modernSchemaIndexes(entries);
|
|
12392
|
+
const recentStart = Math.max(0, entries.length - Math.max(1, settings.keepRecentEntries));
|
|
12393
|
+
const selected = [];
|
|
12394
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
12395
|
+
if (index >= recentStart || modernProtected(entries[index], index, lastIndex, schemaIndexes)) selected.push(index);
|
|
12396
|
+
}
|
|
12397
|
+
let omitted = entries.length - selected.length;
|
|
12398
|
+
const compacted = selected.map((index) => compactModernEntry(entries[index], index === lastIndex));
|
|
12399
|
+
while (selected.length > 2 && jsonLength(compacted) > settings.maxHistoryChars) {
|
|
12400
|
+
let at = selected.findIndex((index, position) => index !== lastIndex && position < selected.length - 1 && !modernProtected(entries[index], index, lastIndex, schemaIndexes));
|
|
12401
|
+
if (at < 0) at = selected.findIndex((index, position) => index !== lastIndex && position < selected.length - 1);
|
|
12402
|
+
if (at < 0) break;
|
|
12403
|
+
selected.splice(at, 1);
|
|
12404
|
+
compacted.splice(at, 1);
|
|
12405
|
+
omitted += 1;
|
|
12406
|
+
}
|
|
12407
|
+
const summary = {
|
|
12408
|
+
kind: "summary",
|
|
12409
|
+
role: "fact",
|
|
12410
|
+
content: [{
|
|
12411
|
+
type: "text",
|
|
12412
|
+
text: "[auto-review-fix] " + String(omitted) + " earlier history entries omitted from the reviewer context (original history " + String(jsonLength(entries)) + " chars). Current action, instructions and recent context are retained."
|
|
12413
|
+
}]
|
|
12414
|
+
};
|
|
12415
|
+
const nextMessages = [messages[0]];
|
|
12416
|
+
if (omitted > 0) nextMessages.push({ role: "user", content: [{ type: "text", text: JSON.stringify(summary) }] });
|
|
12417
|
+
selected.forEach((originalIndex, position) => {
|
|
12418
|
+
const original = messages[originalIndex + 1];
|
|
12419
|
+
if (originalIndex === lastIndex) nextMessages.push(original);
|
|
12420
|
+
else nextMessages.push({ ...original, content: [{ type: "text", text: JSON.stringify(compacted[position]) }] });
|
|
12421
|
+
});
|
|
12422
|
+
if (jsonLength(nextMessages) >= jsonLength(messages)) return options;
|
|
12423
|
+
logTrim(jsonLength(messages), jsonLength(nextMessages), entries.length, selected.length);
|
|
12424
|
+
return { ...options, messages: nextMessages };
|
|
12425
|
+
}
|
|
12165
12426
|
var guardedLlms = /* @__PURE__ */ new WeakMap();
|
|
12166
12427
|
function whenService(ctx, name, run) {
|
|
12167
12428
|
try {
|
|
12168
|
-
const
|
|
12169
|
-
if (typeof
|
|
12170
|
-
|
|
12429
|
+
const inject6 = ctx.inject;
|
|
12430
|
+
if (typeof inject6 === "function") {
|
|
12431
|
+
inject6.call(ctx, [name], run);
|
|
12171
12432
|
return;
|
|
12172
12433
|
}
|
|
12173
12434
|
const get = ctx.get;
|
|
@@ -12398,16 +12659,16 @@ function normalizeConfig(config) {
|
|
|
12398
12659
|
model: stringSetting(source, "translateModel", ""),
|
|
12399
12660
|
reviewContext: {
|
|
12400
12661
|
enabled: boolSetting(source, "reviewContextGuard", true),
|
|
12401
|
-
maxHistoryChars: numberSetting(source, "reviewMaxHistoryChars",
|
|
12402
|
-
keepRecentEntries: numberSetting(source, "reviewKeepRecentEntries",
|
|
12662
|
+
maxHistoryChars: numberSetting(source, "reviewMaxHistoryChars", 2e5, 2e4, 6e5),
|
|
12663
|
+
keepRecentEntries: numberSetting(source, "reviewKeepRecentEntries", 32, 4, 64)
|
|
12403
12664
|
}
|
|
12404
12665
|
};
|
|
12405
12666
|
}
|
|
12406
12667
|
function whenService2(ctx, name, run) {
|
|
12407
12668
|
try {
|
|
12408
|
-
const
|
|
12409
|
-
if (typeof
|
|
12410
|
-
|
|
12669
|
+
const inject6 = ctx.inject;
|
|
12670
|
+
if (typeof inject6 === "function") {
|
|
12671
|
+
inject6.call(ctx, [name], run);
|
|
12411
12672
|
return;
|
|
12412
12673
|
}
|
|
12413
12674
|
const get = ctx.get;
|
|
@@ -12649,8 +12910,8 @@ var DEFAULT_AUTO_REVIEW_CONFIG = {
|
|
|
12649
12910
|
translateProvider: "",
|
|
12650
12911
|
translateModel: "",
|
|
12651
12912
|
reviewContextGuard: true,
|
|
12652
|
-
reviewMaxHistoryChars:
|
|
12653
|
-
reviewKeepRecentEntries:
|
|
12913
|
+
reviewMaxHistoryChars: 2e5,
|
|
12914
|
+
reviewKeepRecentEntries: 32
|
|
12654
12915
|
};
|
|
12655
12916
|
var Config2 = z2.object({
|
|
12656
12917
|
keepPresetGuard: z2.boolean().default(DEFAULT_AUTO_REVIEW_CONFIG.keepPresetGuard).volatile(),
|
|
@@ -12663,7 +12924,7 @@ var Config2 = z2.object({
|
|
|
12663
12924
|
reviewMaxHistoryChars: z2.number().min(2e4).max(6e5).default(DEFAULT_AUTO_REVIEW_CONFIG.reviewMaxHistoryChars).volatile(),
|
|
12664
12925
|
reviewKeepRecentEntries: z2.number().min(4).max(64).default(DEFAULT_AUTO_REVIEW_CONFIG.reviewKeepRecentEntries).volatile()
|
|
12665
12926
|
}).default(DEFAULT_AUTO_REVIEW_CONFIG);
|
|
12666
|
-
function
|
|
12927
|
+
function apply5(ctx, config) {
|
|
12667
12928
|
installAutoReview(ctx, toPlain(config));
|
|
12668
12929
|
}
|
|
12669
12930
|
|
|
@@ -12673,19 +12934,19 @@ __export(restart_exports, {
|
|
|
12673
12934
|
Config: () => Config3,
|
|
12674
12935
|
DEFAULT_RESTART_CONFIG: () => DEFAULT_RESTART_CONFIG,
|
|
12675
12936
|
RESTART_API: () => RESTART_API,
|
|
12676
|
-
apply: () =>
|
|
12937
|
+
apply: () => apply6,
|
|
12677
12938
|
closeDesktop: () => closeDesktop,
|
|
12678
12939
|
deriveDesktopAppPath: () => deriveDesktopAppPath,
|
|
12679
|
-
inject: () =>
|
|
12940
|
+
inject: () => inject4,
|
|
12680
12941
|
launchRestart: () => launchRestart,
|
|
12681
12942
|
makeRestartRoutes: () => makeRestartRoutes,
|
|
12682
12943
|
makeTaskScript: () => makeTaskScript,
|
|
12683
12944
|
resolveRestartTarget: () => resolveRestartTarget
|
|
12684
12945
|
});
|
|
12685
12946
|
import { execFileSync } from "node:child_process";
|
|
12686
|
-
import { appendFileSync as appendFileSync4, existsSync } from "node:fs";
|
|
12947
|
+
import { appendFileSync as appendFileSync4, existsSync as existsSync2 } from "node:fs";
|
|
12687
12948
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
12688
|
-
import { basename, dirname, join as
|
|
12949
|
+
import { basename, dirname, join as join5, resolve } from "node:path";
|
|
12689
12950
|
import z3 from "@deepseek-ai/schemastery";
|
|
12690
12951
|
var DEFAULT_RESTART_CONFIG = { enabled: true, appPath: "" };
|
|
12691
12952
|
var Config3 = z3.object({
|
|
@@ -12714,13 +12975,13 @@ function deriveDesktopAppPath(execPath, argv, exists) {
|
|
|
12714
12975
|
if (argv0 !== "" && argv0 !== execPath && !isNode(argv0) && exists(argv0)) return argv0;
|
|
12715
12976
|
const runtimeDir = argv[2] ?? "";
|
|
12716
12977
|
if (runtimeDir === "") return execPath;
|
|
12717
|
-
const candidate =
|
|
12978
|
+
const candidate = join5(resolve(runtimeDir, "../../.."), "DeepSeek Harness.exe");
|
|
12718
12979
|
return exists(candidate) ? candidate : execPath;
|
|
12719
12980
|
}
|
|
12720
12981
|
var RESTART_TASK_NAME = "DSH-MCviseron-Restart";
|
|
12721
12982
|
var RESTART_DELAY_SECONDS = 6;
|
|
12722
12983
|
function restartLogPath() {
|
|
12723
|
-
return
|
|
12984
|
+
return join5(tmpdir4(), "dsh-mcviseron-restart.log");
|
|
12724
12985
|
}
|
|
12725
12986
|
function makeTaskScript(target, taskName, delaySeconds) {
|
|
12726
12987
|
const quote = (value) => "'" + value.replace(/'/g, "''") + "'";
|
|
@@ -12841,13 +13102,13 @@ function makeRestartRoutes(deps) {
|
|
|
12841
13102
|
};
|
|
12842
13103
|
return [status, execute];
|
|
12843
13104
|
}
|
|
12844
|
-
var
|
|
12845
|
-
function
|
|
13105
|
+
var inject4 = ["webServer"];
|
|
13106
|
+
function apply6(ctx, config) {
|
|
12846
13107
|
const plain = toPlain(config) ?? {};
|
|
12847
13108
|
if (plain.enabled === false) return;
|
|
12848
13109
|
const appPath = typeof plain.appPath === "string" ? plain.appPath : "";
|
|
12849
13110
|
const routes = makeRestartRoutes({
|
|
12850
|
-
target: () => resolveRestartTarget(process.execPath, process.ppid,
|
|
13111
|
+
target: () => resolveRestartTarget(process.execPath, process.ppid, existsSync2, appPath, process.argv),
|
|
12851
13112
|
launch: launchHelper
|
|
12852
13113
|
});
|
|
12853
13114
|
ctx.effect(() => {
|
|
@@ -12863,9 +13124,9 @@ var session_end_exports = {};
|
|
|
12863
13124
|
__export(session_end_exports, {
|
|
12864
13125
|
Config: () => Config4,
|
|
12865
13126
|
DEFAULT_SESSION_END_CONFIG: () => DEFAULT_SESSION_END_CONFIG,
|
|
12866
|
-
apply: () =>
|
|
13127
|
+
apply: () => apply7,
|
|
12867
13128
|
createSessionEndController: () => createSessionEndController,
|
|
12868
|
-
inject: () =>
|
|
13129
|
+
inject: () => inject5,
|
|
12869
13130
|
inspectRunningTasks: () => inspectRunningTasks,
|
|
12870
13131
|
isSessionEndMode: () => isSessionEndMode,
|
|
12871
13132
|
makeSessionEndRoutes: () => makeSessionEndRoutes,
|
|
@@ -12873,9 +13134,9 @@ __export(session_end_exports, {
|
|
|
12873
13134
|
shutdownComputer: () => shutdownComputer
|
|
12874
13135
|
});
|
|
12875
13136
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
12876
|
-
import { appendFileSync as appendFileSync5, existsSync as
|
|
13137
|
+
import { appendFileSync as appendFileSync5, existsSync as existsSync3 } from "node:fs";
|
|
12877
13138
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
12878
|
-
import { join as
|
|
13139
|
+
import { join as join6 } from "node:path";
|
|
12879
13140
|
import z4 from "@deepseek-ai/schemastery";
|
|
12880
13141
|
|
|
12881
13142
|
// src/session-end/email.ts
|
|
@@ -13007,7 +13268,7 @@ function isSessionEndMode(value) {
|
|
|
13007
13268
|
return value === "off" || value === "restart" || value === "close" || value === "shutdown";
|
|
13008
13269
|
}
|
|
13009
13270
|
function sessionLogPath() {
|
|
13010
|
-
return
|
|
13271
|
+
return join6(tmpdir5(), "dsh-mcviseron-session-end.log");
|
|
13011
13272
|
}
|
|
13012
13273
|
function defaultLog(message) {
|
|
13013
13274
|
try {
|
|
@@ -13078,7 +13339,7 @@ function createSessionEndController(deps = {}) {
|
|
|
13078
13339
|
const resolveTarget = deps.resolveTarget ?? (() => resolveRestartTarget(
|
|
13079
13340
|
process.execPath,
|
|
13080
13341
|
process.ppid,
|
|
13081
|
-
|
|
13342
|
+
existsSync3,
|
|
13082
13343
|
typeof deps.appPath === "string" ? deps.appPath : "",
|
|
13083
13344
|
process.argv
|
|
13084
13345
|
));
|
|
@@ -13329,10 +13590,10 @@ function serviceOf4(ctx, name) {
|
|
|
13329
13590
|
}
|
|
13330
13591
|
}
|
|
13331
13592
|
function installGuidance(ctx) {
|
|
13332
|
-
const
|
|
13333
|
-
if (typeof
|
|
13593
|
+
const inject6 = ctx.inject;
|
|
13594
|
+
if (typeof inject6 !== "function") return;
|
|
13334
13595
|
try {
|
|
13335
|
-
|
|
13596
|
+
inject6.call(ctx, ["systemPrompt"], (scope) => {
|
|
13336
13597
|
const systemPrompt = serviceOf4(scope, "systemPrompt");
|
|
13337
13598
|
if (systemPrompt === void 0 || typeof systemPrompt.section !== "function") return;
|
|
13338
13599
|
try {
|
|
@@ -13351,10 +13612,10 @@ function installGuidance(ctx) {
|
|
|
13351
13612
|
}
|
|
13352
13613
|
var emailed = /* @__PURE__ */ new Map();
|
|
13353
13614
|
function installAgentTool(ctx, controller, options, log2) {
|
|
13354
|
-
const
|
|
13355
|
-
if (typeof
|
|
13615
|
+
const inject6 = ctx.inject;
|
|
13616
|
+
if (typeof inject6 !== "function") return;
|
|
13356
13617
|
try {
|
|
13357
|
-
|
|
13618
|
+
inject6.call(ctx, ["tools"], (scope) => {
|
|
13358
13619
|
const tools = serviceOf4(scope, "tools");
|
|
13359
13620
|
if (tools === void 0 || typeof tools.register !== "function") return;
|
|
13360
13621
|
const definition = {
|
|
@@ -13494,8 +13755,8 @@ function normalizeSessionEndOptions(input) {
|
|
|
13494
13755
|
appPath: string("appPath", "")
|
|
13495
13756
|
};
|
|
13496
13757
|
}
|
|
13497
|
-
var
|
|
13498
|
-
function
|
|
13758
|
+
var inject5 = ["webServer"];
|
|
13759
|
+
function apply7(ctx, config) {
|
|
13499
13760
|
const options = normalizeSessionEndOptions(config);
|
|
13500
13761
|
const log2 = defaultLog;
|
|
13501
13762
|
const controller = createSessionEndController({
|
|
@@ -13541,7 +13802,7 @@ var task_guard_exports = {};
|
|
|
13541
13802
|
__export(task_guard_exports, {
|
|
13542
13803
|
Config: () => Config5,
|
|
13543
13804
|
DEFAULT_TASK_GUARD_CONFIG: () => DEFAULT_TASK_GUARD_CONFIG,
|
|
13544
|
-
apply: () =>
|
|
13805
|
+
apply: () => apply8
|
|
13545
13806
|
});
|
|
13546
13807
|
import z5 from "@deepseek-ai/schemastery";
|
|
13547
13808
|
|
|
@@ -14253,7 +14514,7 @@ var Config5 = z5.object({
|
|
|
14253
14514
|
include: z5.array(z5.string()).default(DEFAULT_TASK_GUARD_CONFIG.include).volatile(),
|
|
14254
14515
|
exclude: z5.array(z5.string()).default(DEFAULT_TASK_GUARD_CONFIG.exclude).volatile()
|
|
14255
14516
|
}).default(DEFAULT_TASK_GUARD_CONFIG);
|
|
14256
|
-
function
|
|
14517
|
+
function apply8(ctx, config) {
|
|
14257
14518
|
installTaskGuard(ctx, toPlain(config));
|
|
14258
14519
|
}
|
|
14259
14520
|
|
|
@@ -14283,9 +14544,10 @@ function mount(ctx, component, config) {
|
|
|
14283
14544
|
logger?.warn?.(new Error("mcviseron: cannot mount a component", { cause: error }));
|
|
14284
14545
|
}
|
|
14285
14546
|
}
|
|
14286
|
-
function
|
|
14547
|
+
function apply9(ctx, rawConfig) {
|
|
14287
14548
|
const config = toPlain(rawConfig) ?? {};
|
|
14288
14549
|
mount(ctx, automation_tasks_exports, {});
|
|
14550
|
+
mount(ctx, archive_integration_exports, {});
|
|
14289
14551
|
mount(ctx, auth_cookie_exports, {});
|
|
14290
14552
|
mount(ctx, appearance_exports, {
|
|
14291
14553
|
enabled: config.enabled ?? DEFAULT_SCHEDULE_CONFIG.enabled,
|
|
@@ -14304,5 +14566,5 @@ function apply8(ctx, rawConfig) {
|
|
|
14304
14566
|
}
|
|
14305
14567
|
export {
|
|
14306
14568
|
Config6 as Config,
|
|
14307
|
-
|
|
14569
|
+
apply9 as apply
|
|
14308
14570
|
};
|