dsh-mcviseron-plugin 0.6.4 → 0.6.6
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 +37 -5
- package/README.en.md +17 -5
- package/README.md +19 -7
- package/docs/auth-cookie.md +61 -0
- package/docs/auto-review-context.md +65 -0
- package/docs/automation-task.md +1 -1
- package/docs/release.md +3 -3
- package/docs/session-end.md +5 -2
- package/lib/auto-review-fix.js +253 -23
- package/lib/client.js +301 -171
- package/lib/index.js +606 -128
- package/package.json +3 -3
- package/src/api.ts +6 -0
- package/src/auth-cookie/index.ts +175 -0
- package/src/auto-review-fix/index.ts +9 -0
- package/src/client/ConfigForm.tsx +3 -0
- package/src/client/SessionEndControl.tsx +115 -165
- package/src/client/SessionEndGlobalNotice.ts +183 -0
- package/src/client/SettingsSection.tsx +4 -0
- package/src/client/index.ts +15 -0
- package/src/client/locales.ts +16 -2
- package/src/client/primitives.d.ts +37 -1
- package/src/components/auto-review-fix/index.ts +8 -0
- package/src/components/auto-review-fix/review-context.ts +285 -0
- package/src/index.ts +2 -0
- package/src/session-end/index.ts +146 -27
package/lib/index.js
CHANGED
|
@@ -11289,7 +11289,11 @@ var MCVISERON_API = {
|
|
|
11289
11289
|
};
|
|
11290
11290
|
var SESSION_END_API = {
|
|
11291
11291
|
state: "/api/dsh-mcviseron/session-end/state",
|
|
11292
|
-
set: "/api/dsh-mcviseron/session-end/set"
|
|
11292
|
+
set: "/api/dsh-mcviseron/session-end/set",
|
|
11293
|
+
global: "/api/dsh-mcviseron/session-end/global"
|
|
11294
|
+
};
|
|
11295
|
+
var AUTH_COOKIE_API = {
|
|
11296
|
+
prune: "/api/dsh-mcviseron/auth-cookies/prune"
|
|
11293
11297
|
};
|
|
11294
11298
|
|
|
11295
11299
|
// src/namespace.ts
|
|
@@ -11308,10 +11312,10 @@ function parseTimeOfDay(value) {
|
|
|
11308
11312
|
return Number(match[1]) * 60 + Number(match[2]);
|
|
11309
11313
|
}
|
|
11310
11314
|
function normalizeScheduleConfig(input) {
|
|
11311
|
-
const
|
|
11312
|
-
const lightStart = typeof
|
|
11313
|
-
const lightEnd = typeof
|
|
11314
|
-
const enabled = typeof
|
|
11315
|
+
const record2 = input !== null && typeof input === "object" ? input : {};
|
|
11316
|
+
const lightStart = typeof record2.lightStart === "string" && parseTimeOfDay(record2.lightStart) !== void 0 ? record2.lightStart : DEFAULT_SCHEDULE_CONFIG.lightStart;
|
|
11317
|
+
const lightEnd = typeof record2.lightEnd === "string" && parseTimeOfDay(record2.lightEnd) !== void 0 ? record2.lightEnd : DEFAULT_SCHEDULE_CONFIG.lightEnd;
|
|
11318
|
+
const enabled = typeof record2.enabled === "boolean" ? record2.enabled : DEFAULT_SCHEDULE_CONFIG.enabled;
|
|
11315
11319
|
return { enabled, lightStart, lightEnd };
|
|
11316
11320
|
}
|
|
11317
11321
|
|
|
@@ -11425,15 +11429,15 @@ function unwrapValue(value) {
|
|
|
11425
11429
|
}
|
|
11426
11430
|
function toPluginView(descriptor) {
|
|
11427
11431
|
const plain = toPlain(unwrapValue(descriptor.value));
|
|
11428
|
-
const
|
|
11432
|
+
const record2 = isRecord(plain) ? plain : {};
|
|
11429
11433
|
return {
|
|
11430
11434
|
ns: String(descriptor.ns),
|
|
11431
11435
|
value: {
|
|
11432
11436
|
...normalizeScheduleConfig(plain),
|
|
11433
|
-
autoReviewFix: isRecord(
|
|
11434
|
-
taskGuard: isRecord(
|
|
11435
|
-
restart: isRecord(
|
|
11436
|
-
sessionEnd: isRecord(
|
|
11437
|
+
autoReviewFix: isRecord(record2.autoReviewFix) ? record2.autoReviewFix : {},
|
|
11438
|
+
taskGuard: isRecord(record2.taskGuard) ? record2.taskGuard : {},
|
|
11439
|
+
restart: isRecord(record2.restart) ? record2.restart : {},
|
|
11440
|
+
sessionEnd: isRecord(record2.sessionEnd) ? record2.sessionEnd : {}
|
|
11437
11441
|
},
|
|
11438
11442
|
revision: descriptor.revision
|
|
11439
11443
|
};
|
|
@@ -11468,11 +11472,11 @@ function makeSettingsRoutes(settings) {
|
|
|
11468
11472
|
if (body === void 0 || typeof body !== "object" || body === null) {
|
|
11469
11473
|
return json(res, 400, { ok: false, code: "settings-rejected", message: "unreadable JSON body" });
|
|
11470
11474
|
}
|
|
11471
|
-
const
|
|
11472
|
-
if (
|
|
11475
|
+
const record2 = body;
|
|
11476
|
+
if (record2.ns !== MCVISERON_SETTINGS_NAMESPACE || !Array.isArray(record2.ops)) {
|
|
11473
11477
|
return json(res, 400, { ok: false, code: "settings-rejected", message: "malformed settings request" });
|
|
11474
11478
|
}
|
|
11475
|
-
const ops =
|
|
11479
|
+
const ops = record2.ops;
|
|
11476
11480
|
const valid = ops.every((op) => {
|
|
11477
11481
|
if (op.op !== "set" && op.op !== "unset") return false;
|
|
11478
11482
|
const rule = ruleFor(op.path);
|
|
@@ -11483,7 +11487,7 @@ function makeSettingsRoutes(settings) {
|
|
|
11483
11487
|
if (!valid) {
|
|
11484
11488
|
return json(res, 400, { ok: false, code: "settings-rejected", message: "malformed settings operation" });
|
|
11485
11489
|
}
|
|
11486
|
-
const expectedRevision = typeof
|
|
11490
|
+
const expectedRevision = typeof record2.expectedRevision === "number" ? record2.expectedRevision : void 0;
|
|
11487
11491
|
try {
|
|
11488
11492
|
await settings.mutate(MCVISERON_SETTINGS_NAMESPACE, ops, expectedRevision);
|
|
11489
11493
|
} catch (error) {
|
|
@@ -11565,18 +11569,382 @@ function apply(ctx, _config) {
|
|
|
11565
11569
|
});
|
|
11566
11570
|
}
|
|
11567
11571
|
|
|
11572
|
+
// src/auth-cookie/index.ts
|
|
11573
|
+
var auth_cookie_exports = {};
|
|
11574
|
+
__export(auth_cookie_exports, {
|
|
11575
|
+
AUTH_COOKIE_PREFIX: () => AUTH_COOKIE_PREFIX,
|
|
11576
|
+
apply: () => apply2,
|
|
11577
|
+
authCookieName: () => authCookieName,
|
|
11578
|
+
authCookieNames: () => authCookieNames,
|
|
11579
|
+
expiredAuthCookie: () => expiredAuthCookie,
|
|
11580
|
+
inject: () => inject2,
|
|
11581
|
+
makeAuthCookieRoutes: () => makeAuthCookieRoutes,
|
|
11582
|
+
pruneCookieHeaders: () => pruneCookieHeaders,
|
|
11583
|
+
pruneScript: () => pruneScript,
|
|
11584
|
+
requestAuthority: () => requestAuthority,
|
|
11585
|
+
staleAuthCookieNames: () => staleAuthCookieNames
|
|
11586
|
+
});
|
|
11587
|
+
import { createHash } from "node:crypto";
|
|
11588
|
+
import { appendFileSync } from "node:fs";
|
|
11589
|
+
import { tmpdir } from "node:os";
|
|
11590
|
+
import { join } from "node:path";
|
|
11591
|
+
var AUTH_COOKIE_PREFIX = "dsh-auth-";
|
|
11592
|
+
var EXPIRED_AT = "Thu, 01 Jan 1970 00:00:00 GMT";
|
|
11593
|
+
function logPrune(authority, pruned) {
|
|
11594
|
+
try {
|
|
11595
|
+
appendFileSync(
|
|
11596
|
+
join(tmpdir(), "dsh-mcviseron-auth-cookie.log"),
|
|
11597
|
+
(/* @__PURE__ */ new Date()).toISOString() + " pruned=" + pruned + " authority=" + authority + "\n",
|
|
11598
|
+
"utf8"
|
|
11599
|
+
);
|
|
11600
|
+
} catch {
|
|
11601
|
+
}
|
|
11602
|
+
}
|
|
11603
|
+
function authCookieName(authority) {
|
|
11604
|
+
return AUTH_COOKIE_PREFIX + createHash("sha256").update(authority).digest("base64url");
|
|
11605
|
+
}
|
|
11606
|
+
function requestAuthority(host, secure) {
|
|
11607
|
+
if (typeof host !== "string" || host === "") return void 0;
|
|
11608
|
+
try {
|
|
11609
|
+
const url = new URL((secure ? "https:" : "http:") + "//" + host);
|
|
11610
|
+
return secure ? url.origin : url.host;
|
|
11611
|
+
} catch {
|
|
11612
|
+
return void 0;
|
|
11613
|
+
}
|
|
11614
|
+
}
|
|
11615
|
+
function validAuthCookieName(name) {
|
|
11616
|
+
if (!name.startsWith(AUTH_COOKIE_PREFIX)) return false;
|
|
11617
|
+
return /^[A-Za-z0-9_-]+$/.test(name.slice(AUTH_COOKIE_PREFIX.length));
|
|
11618
|
+
}
|
|
11619
|
+
function authCookieNames(header) {
|
|
11620
|
+
if (typeof header !== "string" || header === "") return [];
|
|
11621
|
+
const names = /* @__PURE__ */ new Set();
|
|
11622
|
+
for (const segment of header.split(";")) {
|
|
11623
|
+
const at = segment.indexOf("=");
|
|
11624
|
+
const name = (at === -1 ? segment : segment.slice(0, at)).trim();
|
|
11625
|
+
if (validAuthCookieName(name)) names.add(name);
|
|
11626
|
+
}
|
|
11627
|
+
return [...names];
|
|
11628
|
+
}
|
|
11629
|
+
function staleAuthCookieNames(header, currentName) {
|
|
11630
|
+
return authCookieNames(header).filter((name) => name !== currentName);
|
|
11631
|
+
}
|
|
11632
|
+
function expiredAuthCookie(name, secure) {
|
|
11633
|
+
return name + "=; Max-Age=0; Path=/; Expires=" + EXPIRED_AT + "; HttpOnly; SameSite=Strict" + (secure ? "; Secure" : "");
|
|
11634
|
+
}
|
|
11635
|
+
function pruneCookieHeaders(req, secure) {
|
|
11636
|
+
const authority = requestAuthority(req.headers.host, secure);
|
|
11637
|
+
if (authority === void 0) return [];
|
|
11638
|
+
const current = authCookieName(authority);
|
|
11639
|
+
return staleAuthCookieNames(req.headers.cookie, current).map((name) => expiredAuthCookie(name, secure));
|
|
11640
|
+
}
|
|
11641
|
+
function pruneScript() {
|
|
11642
|
+
return "(function(){try{fetch(" + JSON.stringify(AUTH_COOKIE_API.prune) + ',{method:"POST",credentials:"same-origin",cache:"no-store"}).catch(function(){})}catch(e){}})()';
|
|
11643
|
+
}
|
|
11644
|
+
function json2(res, status, body, extra = {}) {
|
|
11645
|
+
res.writeHead(status, {
|
|
11646
|
+
"content-type": "application/json; charset=utf-8",
|
|
11647
|
+
"cache-control": "no-store",
|
|
11648
|
+
...extra
|
|
11649
|
+
});
|
|
11650
|
+
res.end(JSON.stringify(body));
|
|
11651
|
+
}
|
|
11652
|
+
function makeAuthCookieRoutes(options) {
|
|
11653
|
+
const route = {
|
|
11654
|
+
kind: "exact",
|
|
11655
|
+
path: AUTH_COOKIE_API.prune,
|
|
11656
|
+
handler: (req, res) => {
|
|
11657
|
+
if (req.method !== "POST") {
|
|
11658
|
+
json2(res, 405, { ok: false, error: "method-not-allowed" });
|
|
11659
|
+
return;
|
|
11660
|
+
}
|
|
11661
|
+
if (!isLoopbackRequest(req)) {
|
|
11662
|
+
json2(res, 403, { ok: false, error: "forbidden" });
|
|
11663
|
+
return;
|
|
11664
|
+
}
|
|
11665
|
+
const secure = options.secure();
|
|
11666
|
+
const authority = requestAuthority(req.headers.host, secure);
|
|
11667
|
+
if (authority === void 0) {
|
|
11668
|
+
json2(res, 400, { ok: false, error: "host-required" });
|
|
11669
|
+
return;
|
|
11670
|
+
}
|
|
11671
|
+
const stale = staleAuthCookieNames(req.headers.cookie, authCookieName(authority));
|
|
11672
|
+
logPrune(authority, stale.length);
|
|
11673
|
+
const extra = stale.length === 0 ? {} : { "set-cookie": stale.map((name) => expiredAuthCookie(name, secure)) };
|
|
11674
|
+
json2(res, 200, { ok: true, pruned: stale.length }, extra);
|
|
11675
|
+
}
|
|
11676
|
+
};
|
|
11677
|
+
return [route];
|
|
11678
|
+
}
|
|
11679
|
+
function eventBusOf(ctx) {
|
|
11680
|
+
const root = ctx.root;
|
|
11681
|
+
return root ?? ctx;
|
|
11682
|
+
}
|
|
11683
|
+
function installIndexInjection(ctx) {
|
|
11684
|
+
const bus = eventBusOf(ctx);
|
|
11685
|
+
if (typeof bus.on !== "function") return;
|
|
11686
|
+
try {
|
|
11687
|
+
ctx.effect(() => {
|
|
11688
|
+
const dispose = bus.on?.("webserver/index-inject", (table) => {
|
|
11689
|
+
if (!Array.isArray(table)) return;
|
|
11690
|
+
table.push({ kind: "script", placement: "head", text: pruneScript() });
|
|
11691
|
+
});
|
|
11692
|
+
return () => {
|
|
11693
|
+
if (typeof dispose === "function") dispose();
|
|
11694
|
+
};
|
|
11695
|
+
}, "mcviseron-auth-cookie: index injection");
|
|
11696
|
+
} catch {
|
|
11697
|
+
}
|
|
11698
|
+
}
|
|
11699
|
+
var inject2 = ["webServer"];
|
|
11700
|
+
function apply2(ctx) {
|
|
11701
|
+
const secure = () => {
|
|
11702
|
+
try {
|
|
11703
|
+
return ctx.webServer.protocol === "https:";
|
|
11704
|
+
} catch {
|
|
11705
|
+
return false;
|
|
11706
|
+
}
|
|
11707
|
+
};
|
|
11708
|
+
const routes = makeAuthCookieRoutes({ secure });
|
|
11709
|
+
ctx.effect(() => {
|
|
11710
|
+
const disposers = routes.map((route) => ctx.webServer.register(route));
|
|
11711
|
+
return () => {
|
|
11712
|
+
for (const dispose of disposers) dispose();
|
|
11713
|
+
};
|
|
11714
|
+
}, "mcviseron-auth-cookie: prune route");
|
|
11715
|
+
installIndexInjection(ctx);
|
|
11716
|
+
}
|
|
11717
|
+
|
|
11568
11718
|
// src/auto-review-fix/index.ts
|
|
11569
11719
|
var auto_review_fix_exports = {};
|
|
11570
11720
|
__export(auto_review_fix_exports, {
|
|
11571
11721
|
Config: () => Config2,
|
|
11572
11722
|
DEFAULT_AUTO_REVIEW_CONFIG: () => DEFAULT_AUTO_REVIEW_CONFIG,
|
|
11573
|
-
apply: () =>
|
|
11723
|
+
apply: () => apply3
|
|
11574
11724
|
});
|
|
11575
11725
|
import z2 from "@deepseek-ai/schemastery";
|
|
11576
11726
|
|
|
11577
11727
|
// src/components/auto-review-fix/index.ts
|
|
11578
11728
|
import { randomUUID } from "node:crypto";
|
|
11579
11729
|
|
|
11730
|
+
// src/components/auto-review-fix/review-context.ts
|
|
11731
|
+
import { appendFileSync as appendFileSync2 } from "node:fs";
|
|
11732
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
11733
|
+
import { join as join2 } from "node:path";
|
|
11734
|
+
var REVIEW_MARKER = "REVIEW_POLICY";
|
|
11735
|
+
var REVIEW_MARKER_2 = "final authorization reviewer";
|
|
11736
|
+
var HISTORY_HEADER = "FILTERED_HISTORY\n\n";
|
|
11737
|
+
var PROJECT_HEADER = "PROJECT_INSTRUCTIONS\n\n";
|
|
11738
|
+
var ACTION_HEADER = "\n\nPENDING_ACTION\n\n";
|
|
11739
|
+
var USER_TEXT_CHARS = 4e3;
|
|
11740
|
+
var TOOL_ARGUMENT_CHARS = 2e3;
|
|
11741
|
+
var PROJECT_MAX_CHARS = 4e4;
|
|
11742
|
+
function record(value) {
|
|
11743
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
11744
|
+
}
|
|
11745
|
+
function textOf(message) {
|
|
11746
|
+
if (!record(message) || !Array.isArray(message.content)) return void 0;
|
|
11747
|
+
const texts = [];
|
|
11748
|
+
for (const block of message.content) {
|
|
11749
|
+
if (!record(block) || block.type !== "text" || typeof block.text !== "string") return void 0;
|
|
11750
|
+
texts.push(block.text);
|
|
11751
|
+
}
|
|
11752
|
+
return texts.join("");
|
|
11753
|
+
}
|
|
11754
|
+
function isAutoReviewRequest(options) {
|
|
11755
|
+
if (!record(options)) return false;
|
|
11756
|
+
const system = options.system;
|
|
11757
|
+
if (typeof system !== "string" || !system.includes(REVIEW_MARKER) || !system.includes(REVIEW_MARKER_2)) return false;
|
|
11758
|
+
if (!Array.isArray(options.messages) || options.messages.length === 0) return false;
|
|
11759
|
+
const text2 = textOf(options.messages[0]);
|
|
11760
|
+
return text2 !== void 0 && text2.includes(HISTORY_HEADER) && text2.includes(ACTION_HEADER);
|
|
11761
|
+
}
|
|
11762
|
+
function truncateText(text2, limit) {
|
|
11763
|
+
if (text2.length <= limit) return text2;
|
|
11764
|
+
return text2.slice(0, limit) + "\n\u2026[" + String(text2.length - limit) + " characters omitted]";
|
|
11765
|
+
}
|
|
11766
|
+
function compactBlock(block) {
|
|
11767
|
+
if (!record(block)) return { type: "text", text: "[non-text history block omitted from reviewer context]" };
|
|
11768
|
+
if (block.type === "text" && typeof block.text === "string") {
|
|
11769
|
+
return { ...block, text: truncateText(block.text, USER_TEXT_CHARS) };
|
|
11770
|
+
}
|
|
11771
|
+
return {
|
|
11772
|
+
type: "text",
|
|
11773
|
+
text: "[" + String(block.type ?? "attachment") + " omitted from reviewer context]"
|
|
11774
|
+
};
|
|
11775
|
+
}
|
|
11776
|
+
function compactEntry(entry) {
|
|
11777
|
+
if (!record(entry)) return { kind: "summary", role: "fact", content: [{ type: "text", text: "[invalid history entry omitted]" }] };
|
|
11778
|
+
if (entry.kind === "user-message" && Array.isArray(entry.content)) {
|
|
11779
|
+
return { ...entry, content: entry.content.map(compactBlock) };
|
|
11780
|
+
}
|
|
11781
|
+
if (entry.kind === "tool-call") {
|
|
11782
|
+
const value = entry.arguments;
|
|
11783
|
+
if (typeof value === "string") {
|
|
11784
|
+
return { ...entry, arguments: truncateText(value, TOOL_ARGUMENT_CHARS) };
|
|
11785
|
+
}
|
|
11786
|
+
if (value !== void 0) {
|
|
11787
|
+
let rendered;
|
|
11788
|
+
try {
|
|
11789
|
+
rendered = JSON.stringify(value) ?? "";
|
|
11790
|
+
} catch {
|
|
11791
|
+
rendered = "";
|
|
11792
|
+
}
|
|
11793
|
+
return { ...entry, arguments: truncateText(rendered, TOOL_ARGUMENT_CHARS) };
|
|
11794
|
+
}
|
|
11795
|
+
}
|
|
11796
|
+
return entry;
|
|
11797
|
+
}
|
|
11798
|
+
function protectedEntry(entry) {
|
|
11799
|
+
if (!record(entry)) return false;
|
|
11800
|
+
return entry.role === "human-instruction" || entry.role === "direct-parent-instruction";
|
|
11801
|
+
}
|
|
11802
|
+
function summaryEntry(omitted, originalChars) {
|
|
11803
|
+
return {
|
|
11804
|
+
kind: "summary",
|
|
11805
|
+
role: "fact",
|
|
11806
|
+
content: [{
|
|
11807
|
+
type: "text",
|
|
11808
|
+
text: "[auto-review-fix] " + String(omitted) + " earlier history entries omitted from the reviewer context (original history " + String(originalChars) + " chars). Current action and human instructions are retained."
|
|
11809
|
+
}]
|
|
11810
|
+
};
|
|
11811
|
+
}
|
|
11812
|
+
function jsonLength(value) {
|
|
11813
|
+
try {
|
|
11814
|
+
return JSON.stringify(value)?.length ?? 0;
|
|
11815
|
+
} catch {
|
|
11816
|
+
return Number.MAX_SAFE_INTEGER;
|
|
11817
|
+
}
|
|
11818
|
+
}
|
|
11819
|
+
function boundEntries(entries, maxChars, keepRecent) {
|
|
11820
|
+
const normalized = entries.map(compactEntry);
|
|
11821
|
+
const originalChars = jsonLength(normalized);
|
|
11822
|
+
const recentStart = Math.max(0, normalized.length - Math.max(1, keepRecent));
|
|
11823
|
+
const selected = normalized.filter((entry, index) => protectedEntry(entry) || index >= recentStart);
|
|
11824
|
+
let omitted = normalized.length - selected.length;
|
|
11825
|
+
while (selected.length > 1 && jsonLength(selected) > maxChars) {
|
|
11826
|
+
const at = selected.findIndex((entry) => !protectedEntry(entry));
|
|
11827
|
+
if (at < 0) selected.shift();
|
|
11828
|
+
else selected.splice(at, 1);
|
|
11829
|
+
omitted += 1;
|
|
11830
|
+
}
|
|
11831
|
+
if (omitted > 0) selected.unshift(summaryEntry(omitted, originalChars));
|
|
11832
|
+
return selected;
|
|
11833
|
+
}
|
|
11834
|
+
function parseArray(text2) {
|
|
11835
|
+
try {
|
|
11836
|
+
const value = JSON.parse(text2);
|
|
11837
|
+
return Array.isArray(value) ? value : void 0;
|
|
11838
|
+
} catch {
|
|
11839
|
+
return void 0;
|
|
11840
|
+
}
|
|
11841
|
+
}
|
|
11842
|
+
function logTrim(originalChars, nextChars, originalEntries, nextEntries) {
|
|
11843
|
+
try {
|
|
11844
|
+
appendFileSync2(
|
|
11845
|
+
join2(tmpdir2(), "dsh-mcviseron-auto-review.log"),
|
|
11846
|
+
(/* @__PURE__ */ new Date()).toISOString() + " review context trimmed: " + String(originalChars) + " -> " + String(nextChars) + " chars, history " + String(originalEntries) + " -> " + String(nextEntries) + "\n",
|
|
11847
|
+
"utf8"
|
|
11848
|
+
);
|
|
11849
|
+
} catch {
|
|
11850
|
+
}
|
|
11851
|
+
}
|
|
11852
|
+
function trimReviewRequest(options, settings) {
|
|
11853
|
+
if (!settings.enabled || !isAutoReviewRequest(options)) return options;
|
|
11854
|
+
const messages = options.messages;
|
|
11855
|
+
const message = messages[0];
|
|
11856
|
+
const text2 = textOf(message);
|
|
11857
|
+
if (text2 === void 0) return options;
|
|
11858
|
+
const projectAt = text2.indexOf(PROJECT_HEADER);
|
|
11859
|
+
const historyAt = text2.indexOf(HISTORY_HEADER, projectAt + 1);
|
|
11860
|
+
const actionAt = text2.indexOf(ACTION_HEADER, historyAt + 1);
|
|
11861
|
+
if (projectAt < 0 || historyAt < 0 || actionAt < 0) return options;
|
|
11862
|
+
const projectJson = text2.slice(projectAt + PROJECT_HEADER.length, historyAt - 2);
|
|
11863
|
+
const historyJson = text2.slice(historyAt + HISTORY_HEADER.length, actionAt);
|
|
11864
|
+
const project = parseArray(projectJson);
|
|
11865
|
+
const history = parseArray(historyJson);
|
|
11866
|
+
if (project === void 0 || history === void 0) return options;
|
|
11867
|
+
const nextProject = boundEntries(project, PROJECT_MAX_CHARS, 4);
|
|
11868
|
+
const nextHistory = boundEntries(history, settings.maxHistoryChars, settings.keepRecentEntries);
|
|
11869
|
+
const nextText = text2.slice(0, projectAt) + PROJECT_HEADER + JSON.stringify(nextProject) + HISTORY_HEADER + JSON.stringify(nextHistory) + text2.slice(actionAt);
|
|
11870
|
+
if (nextText === text2) return options;
|
|
11871
|
+
logTrim(text2.length, nextText.length, history.length, nextHistory.length);
|
|
11872
|
+
const content = [{ type: "text", text: nextText }];
|
|
11873
|
+
return {
|
|
11874
|
+
...options,
|
|
11875
|
+
messages: [
|
|
11876
|
+
{ ...message, content },
|
|
11877
|
+
...messages.slice(1)
|
|
11878
|
+
]
|
|
11879
|
+
};
|
|
11880
|
+
}
|
|
11881
|
+
var guardedLlms = /* @__PURE__ */ new WeakMap();
|
|
11882
|
+
function whenService(ctx, name, run) {
|
|
11883
|
+
try {
|
|
11884
|
+
const inject5 = ctx.inject;
|
|
11885
|
+
if (typeof inject5 === "function") {
|
|
11886
|
+
inject5.call(ctx, [name], run);
|
|
11887
|
+
return;
|
|
11888
|
+
}
|
|
11889
|
+
const get = ctx.get;
|
|
11890
|
+
if (typeof get === "function" && get.call(ctx, name) !== void 0) run(ctx);
|
|
11891
|
+
} catch {
|
|
11892
|
+
}
|
|
11893
|
+
}
|
|
11894
|
+
function serviceOf(scope, name) {
|
|
11895
|
+
try {
|
|
11896
|
+
const direct = scope[name];
|
|
11897
|
+
if (direct !== void 0) return direct;
|
|
11898
|
+
} catch {
|
|
11899
|
+
}
|
|
11900
|
+
try {
|
|
11901
|
+
const get = scope.get;
|
|
11902
|
+
return typeof get === "function" ? get.call(scope, name) : void 0;
|
|
11903
|
+
} catch {
|
|
11904
|
+
return void 0;
|
|
11905
|
+
}
|
|
11906
|
+
}
|
|
11907
|
+
function effectOf(scope, setup, label) {
|
|
11908
|
+
try {
|
|
11909
|
+
const effect = scope.effect;
|
|
11910
|
+
if (typeof effect === "function") effect.call(scope, setup, label);
|
|
11911
|
+
} catch {
|
|
11912
|
+
}
|
|
11913
|
+
}
|
|
11914
|
+
function installReviewContextGuard(ctx, settings) {
|
|
11915
|
+
if (!settings.enabled) return;
|
|
11916
|
+
whenService(ctx, "llm", (scope) => {
|
|
11917
|
+
const llm = serviceOf(scope, "llm");
|
|
11918
|
+
if (llm === null || typeof llm !== "object" || typeof llm.stream !== "function") return;
|
|
11919
|
+
const existing = guardedLlms.get(llm);
|
|
11920
|
+
if (existing !== void 0) {
|
|
11921
|
+
existing.settings = settings;
|
|
11922
|
+
return;
|
|
11923
|
+
}
|
|
11924
|
+
const original = llm.stream;
|
|
11925
|
+
const state = { settings };
|
|
11926
|
+
const wrapper = function(options) {
|
|
11927
|
+
let next = options;
|
|
11928
|
+
try {
|
|
11929
|
+
next = trimReviewRequest(options, state.settings);
|
|
11930
|
+
} catch {
|
|
11931
|
+
next = options;
|
|
11932
|
+
}
|
|
11933
|
+
return original.call(this, next);
|
|
11934
|
+
};
|
|
11935
|
+
try {
|
|
11936
|
+
llm.stream = wrapper;
|
|
11937
|
+
guardedLlms.set(llm, state);
|
|
11938
|
+
} catch {
|
|
11939
|
+
return;
|
|
11940
|
+
}
|
|
11941
|
+
effectOf(scope, () => () => {
|
|
11942
|
+
if (llm.stream === wrapper) llm.stream = original;
|
|
11943
|
+
guardedLlms.delete(llm);
|
|
11944
|
+
}, "mcviseron: restore llm.stream");
|
|
11945
|
+
});
|
|
11946
|
+
}
|
|
11947
|
+
|
|
11580
11948
|
// src/components/auto-review-fix/translate.ts
|
|
11581
11949
|
var TRANSLATION_LABEL = "\u3010\u5BA1\u67E5\u7406\u7531 \xB7 \u4E2D\u6587\u7FFB\u8BD1\u3011";
|
|
11582
11950
|
var SYSTEM_PROMPT = [
|
|
@@ -11743,14 +12111,19 @@ function normalizeConfig(config) {
|
|
|
11743
12111
|
timeoutMs: numberSetting(source, "translateTimeoutMs", 6e3, 500, 6e4),
|
|
11744
12112
|
maxChars: numberSetting(source, "translateMaxChars", 4e3, 100, 2e4),
|
|
11745
12113
|
provider: stringSetting(source, "translateProvider", ""),
|
|
11746
|
-
model: stringSetting(source, "translateModel", "")
|
|
12114
|
+
model: stringSetting(source, "translateModel", ""),
|
|
12115
|
+
reviewContext: {
|
|
12116
|
+
enabled: boolSetting(source, "reviewContextGuard", true),
|
|
12117
|
+
maxHistoryChars: numberSetting(source, "reviewMaxHistoryChars", 12e4, 2e4, 6e5),
|
|
12118
|
+
keepRecentEntries: numberSetting(source, "reviewKeepRecentEntries", 16, 4, 64)
|
|
12119
|
+
}
|
|
11747
12120
|
};
|
|
11748
12121
|
}
|
|
11749
|
-
function
|
|
12122
|
+
function whenService2(ctx, name, run) {
|
|
11750
12123
|
try {
|
|
11751
|
-
const
|
|
11752
|
-
if (typeof
|
|
11753
|
-
|
|
12124
|
+
const inject5 = ctx.inject;
|
|
12125
|
+
if (typeof inject5 === "function") {
|
|
12126
|
+
inject5.call(ctx, [name], run);
|
|
11754
12127
|
return;
|
|
11755
12128
|
}
|
|
11756
12129
|
const get = ctx.get;
|
|
@@ -11759,7 +12132,7 @@ function whenService(ctx, name, run) {
|
|
|
11759
12132
|
} catch {
|
|
11760
12133
|
}
|
|
11761
12134
|
}
|
|
11762
|
-
function
|
|
12135
|
+
function serviceOf2(scope, name) {
|
|
11763
12136
|
try {
|
|
11764
12137
|
const direct = scope[name];
|
|
11765
12138
|
if (direct !== void 0) return direct;
|
|
@@ -11772,7 +12145,7 @@ function serviceOf(scope, name) {
|
|
|
11772
12145
|
return void 0;
|
|
11773
12146
|
}
|
|
11774
12147
|
}
|
|
11775
|
-
function
|
|
12148
|
+
function effectOf2(scope, setup, label) {
|
|
11776
12149
|
try {
|
|
11777
12150
|
const effect = scope.effect;
|
|
11778
12151
|
if (typeof effect === "function") effect.call(scope, setup, label);
|
|
@@ -11790,8 +12163,8 @@ function rootIsActive(root) {
|
|
|
11790
12163
|
}
|
|
11791
12164
|
}
|
|
11792
12165
|
function installPresetGuard(ctx) {
|
|
11793
|
-
|
|
11794
|
-
const presets =
|
|
12166
|
+
whenService2(ctx, "permissionPresets", (scope) => {
|
|
12167
|
+
const presets = serviceOf2(scope, "permissionPresets");
|
|
11795
12168
|
if (presets === null || typeof presets !== "object") return;
|
|
11796
12169
|
if (typeof presets.set !== "function") return;
|
|
11797
12170
|
if (guardedPresets.has(presets)) return;
|
|
@@ -11812,18 +12185,18 @@ async function decorateApprovalRequest(scope, settings, request, translate = tra
|
|
|
11812
12185
|
if (!settings.enabled || request === null || typeof request !== "object") return request;
|
|
11813
12186
|
const display = request.displayReason;
|
|
11814
12187
|
if (display === null || typeof display !== "object" || Array.isArray(display)) return request;
|
|
11815
|
-
const
|
|
11816
|
-
const key = chineseKey(
|
|
12188
|
+
const record2 = display;
|
|
12189
|
+
const key = chineseKey(record2);
|
|
11817
12190
|
if (key === void 0) return request;
|
|
11818
|
-
const english = englishText(
|
|
12191
|
+
const english = englishText(record2);
|
|
11819
12192
|
if (english === void 0 || !isAutoReviewText(english)) return request;
|
|
11820
|
-
const localized =
|
|
12193
|
+
const localized = record2[key];
|
|
11821
12194
|
if (typeof localized !== "string" || hasTranslation(localized)) return request;
|
|
11822
12195
|
const excerpt = reviewerExcerpt(english);
|
|
11823
12196
|
if (excerpt.length === 0 || excerpt.length > settings.maxChars) return request;
|
|
11824
12197
|
if (isPredominantlyChinese(excerpt)) return request;
|
|
11825
12198
|
if (translationRoute(settings, request) === void 0) return request;
|
|
11826
|
-
const llm =
|
|
12199
|
+
const llm = serviceOf2(scope, "llm");
|
|
11827
12200
|
const translated = await translate(llm, settings, request, excerpt);
|
|
11828
12201
|
if (translated === void 0) return request;
|
|
11829
12202
|
const cleaned = cleanTranslation(translated);
|
|
@@ -11834,7 +12207,7 @@ async function decorateApprovalRequest(scope, settings, request, translate = tra
|
|
|
11834
12207
|
return {
|
|
11835
12208
|
...request,
|
|
11836
12209
|
...reasonWithTranslation !== originalReason ? { reason: reasonWithTranslation } : {},
|
|
11837
|
-
displayReason: { ...
|
|
12210
|
+
displayReason: { ...record2, [key]: withTranslation(localized, cleaned) }
|
|
11838
12211
|
};
|
|
11839
12212
|
}
|
|
11840
12213
|
function sessionIdOf(agent) {
|
|
@@ -11851,8 +12224,8 @@ function rejectionKey(agent, callId) {
|
|
|
11851
12224
|
return sessionId === "" ? "" : sessionId + ":" + callId;
|
|
11852
12225
|
}
|
|
11853
12226
|
function approvalReasonText(request) {
|
|
11854
|
-
const
|
|
11855
|
-
const display =
|
|
12227
|
+
const record2 = request;
|
|
12228
|
+
const display = record2.displayReason;
|
|
11856
12229
|
if (display !== null && typeof display === "object" && !Array.isArray(display)) {
|
|
11857
12230
|
const key = chineseKey(display);
|
|
11858
12231
|
if (key !== void 0) {
|
|
@@ -11862,12 +12235,12 @@ function approvalReasonText(request) {
|
|
|
11862
12235
|
const english = englishText(display);
|
|
11863
12236
|
if (english !== void 0 && english !== "") return english;
|
|
11864
12237
|
}
|
|
11865
|
-
return typeof
|
|
12238
|
+
return typeof record2.reason === "string" ? record2.reason : "";
|
|
11866
12239
|
}
|
|
11867
12240
|
function isAutoReviewApproval(request) {
|
|
11868
|
-
const
|
|
11869
|
-
if (typeof
|
|
11870
|
-
const display =
|
|
12241
|
+
const record2 = request;
|
|
12242
|
+
if (typeof record2.reason === "string" && isAutoReviewText(record2.reason)) return true;
|
|
12243
|
+
const display = record2.displayReason;
|
|
11871
12244
|
if (display !== null && typeof display === "object" && !Array.isArray(display)) {
|
|
11872
12245
|
const english = englishText(display);
|
|
11873
12246
|
if (english !== void 0 && isAutoReviewText(english)) return true;
|
|
@@ -11938,8 +12311,8 @@ function installRejectionRelay(ctx, relay) {
|
|
|
11938
12311
|
});
|
|
11939
12312
|
}
|
|
11940
12313
|
function installApprovalTranslation(ctx, settings, relay) {
|
|
11941
|
-
|
|
11942
|
-
const approval =
|
|
12314
|
+
whenService2(ctx, "approval", (scope) => {
|
|
12315
|
+
const approval = serviceOf2(scope, "approval");
|
|
11943
12316
|
if (approval === null || typeof approval !== "object") return;
|
|
11944
12317
|
const original = approval.request;
|
|
11945
12318
|
if (typeof original !== "function") return;
|
|
@@ -11967,7 +12340,7 @@ function installApprovalTranslation(ctx, settings, relay) {
|
|
|
11967
12340
|
} catch {
|
|
11968
12341
|
return;
|
|
11969
12342
|
}
|
|
11970
|
-
|
|
12343
|
+
effectOf2(scope, () => () => {
|
|
11971
12344
|
if (approval.request === wrapper) approval.request = call;
|
|
11972
12345
|
}, "mcviseron: restore approval.request");
|
|
11973
12346
|
});
|
|
@@ -11975,6 +12348,7 @@ function installApprovalTranslation(ctx, settings, relay) {
|
|
|
11975
12348
|
function installAutoReview(ctx, config) {
|
|
11976
12349
|
const settings = normalizeConfig(config);
|
|
11977
12350
|
if (settings.keepPresetGuard) installPresetGuard(ctx);
|
|
12351
|
+
if (settings.reviewContext.enabled) installReviewContextGuard(ctx, settings.reviewContext);
|
|
11978
12352
|
if (settings.enabled) {
|
|
11979
12353
|
const relay = createRejectionRelay();
|
|
11980
12354
|
installRejectionRelay(ctx, relay);
|
|
@@ -11989,7 +12363,10 @@ var DEFAULT_AUTO_REVIEW_CONFIG = {
|
|
|
11989
12363
|
translateTimeoutMs: 6e3,
|
|
11990
12364
|
translateMaxChars: 4e3,
|
|
11991
12365
|
translateProvider: "",
|
|
11992
|
-
translateModel: ""
|
|
12366
|
+
translateModel: "",
|
|
12367
|
+
reviewContextGuard: true,
|
|
12368
|
+
reviewMaxHistoryChars: 12e4,
|
|
12369
|
+
reviewKeepRecentEntries: 16
|
|
11993
12370
|
};
|
|
11994
12371
|
var Config2 = z2.object({
|
|
11995
12372
|
keepPresetGuard: z2.boolean().default(DEFAULT_AUTO_REVIEW_CONFIG.keepPresetGuard).volatile(),
|
|
@@ -11997,9 +12374,12 @@ var Config2 = z2.object({
|
|
|
11997
12374
|
translateTimeoutMs: z2.number().min(500).max(6e4).default(DEFAULT_AUTO_REVIEW_CONFIG.translateTimeoutMs).volatile(),
|
|
11998
12375
|
translateMaxChars: z2.number().min(100).max(2e4).default(DEFAULT_AUTO_REVIEW_CONFIG.translateMaxChars).volatile(),
|
|
11999
12376
|
translateProvider: z2.string().default(DEFAULT_AUTO_REVIEW_CONFIG.translateProvider).volatile(),
|
|
12000
|
-
translateModel: z2.string().default(DEFAULT_AUTO_REVIEW_CONFIG.translateModel).volatile()
|
|
12377
|
+
translateModel: z2.string().default(DEFAULT_AUTO_REVIEW_CONFIG.translateModel).volatile(),
|
|
12378
|
+
reviewContextGuard: z2.boolean().default(DEFAULT_AUTO_REVIEW_CONFIG.reviewContextGuard).volatile(),
|
|
12379
|
+
reviewMaxHistoryChars: z2.number().min(2e4).max(6e5).default(DEFAULT_AUTO_REVIEW_CONFIG.reviewMaxHistoryChars).volatile(),
|
|
12380
|
+
reviewKeepRecentEntries: z2.number().min(4).max(64).default(DEFAULT_AUTO_REVIEW_CONFIG.reviewKeepRecentEntries).volatile()
|
|
12001
12381
|
}).default(DEFAULT_AUTO_REVIEW_CONFIG);
|
|
12002
|
-
function
|
|
12382
|
+
function apply3(ctx, config) {
|
|
12003
12383
|
installAutoReview(ctx, toPlain(config));
|
|
12004
12384
|
}
|
|
12005
12385
|
|
|
@@ -12009,19 +12389,19 @@ __export(restart_exports, {
|
|
|
12009
12389
|
Config: () => Config3,
|
|
12010
12390
|
DEFAULT_RESTART_CONFIG: () => DEFAULT_RESTART_CONFIG,
|
|
12011
12391
|
RESTART_API: () => RESTART_API,
|
|
12012
|
-
apply: () =>
|
|
12392
|
+
apply: () => apply4,
|
|
12013
12393
|
closeDesktop: () => closeDesktop,
|
|
12014
12394
|
deriveDesktopAppPath: () => deriveDesktopAppPath,
|
|
12015
|
-
inject: () =>
|
|
12395
|
+
inject: () => inject3,
|
|
12016
12396
|
launchRestart: () => launchRestart,
|
|
12017
12397
|
makeRestartRoutes: () => makeRestartRoutes,
|
|
12018
12398
|
makeTaskScript: () => makeTaskScript,
|
|
12019
12399
|
resolveRestartTarget: () => resolveRestartTarget
|
|
12020
12400
|
});
|
|
12021
12401
|
import { execFileSync } from "node:child_process";
|
|
12022
|
-
import { appendFileSync, existsSync } from "node:fs";
|
|
12023
|
-
import { tmpdir } from "node:os";
|
|
12024
|
-
import { basename, dirname, join, resolve } from "node:path";
|
|
12402
|
+
import { appendFileSync as appendFileSync3, existsSync } from "node:fs";
|
|
12403
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
12404
|
+
import { basename, dirname, join as join3, resolve } from "node:path";
|
|
12025
12405
|
import z3 from "@deepseek-ai/schemastery";
|
|
12026
12406
|
var DEFAULT_RESTART_CONFIG = { enabled: true, appPath: "" };
|
|
12027
12407
|
var Config3 = z3.object({
|
|
@@ -12050,13 +12430,13 @@ function deriveDesktopAppPath(execPath, argv, exists) {
|
|
|
12050
12430
|
if (argv0 !== "" && argv0 !== execPath && !isNode(argv0) && exists(argv0)) return argv0;
|
|
12051
12431
|
const runtimeDir = argv[2] ?? "";
|
|
12052
12432
|
if (runtimeDir === "") return execPath;
|
|
12053
|
-
const candidate =
|
|
12433
|
+
const candidate = join3(resolve(runtimeDir, "../../.."), "DeepSeek Harness.exe");
|
|
12054
12434
|
return exists(candidate) ? candidate : execPath;
|
|
12055
12435
|
}
|
|
12056
12436
|
var RESTART_TASK_NAME = "DSH-MCviseron-Restart";
|
|
12057
12437
|
var RESTART_DELAY_SECONDS = 6;
|
|
12058
12438
|
function restartLogPath() {
|
|
12059
|
-
return
|
|
12439
|
+
return join3(tmpdir3(), "dsh-mcviseron-restart.log");
|
|
12060
12440
|
}
|
|
12061
12441
|
function makeTaskScript(target, taskName, delaySeconds) {
|
|
12062
12442
|
const quote = (value) => "'" + value.replace(/'/g, "''") + "'";
|
|
@@ -12097,26 +12477,26 @@ function launchHelper(target) {
|
|
|
12097
12477
|
"-Command",
|
|
12098
12478
|
makeTaskScript(target, RESTART_TASK_NAME, RESTART_DELAY_SECONDS)
|
|
12099
12479
|
], { windowsHide: true, timeout: 2e4, encoding: "utf8" });
|
|
12100
|
-
|
|
12480
|
+
appendFileSync3(logFile, `${(/* @__PURE__ */ new Date()).toISOString()} host: scheduled ${target.exePath} in ${RESTART_DELAY_SECONDS}s
|
|
12101
12481
|
`, "utf8");
|
|
12102
12482
|
} catch (error) {
|
|
12103
12483
|
const message = error instanceof Error ? error.message : String(error);
|
|
12104
|
-
|
|
12484
|
+
appendFileSync3(logFile, `${(/* @__PURE__ */ new Date()).toISOString()} host: task registration failed: ${message}
|
|
12105
12485
|
`, "utf8");
|
|
12106
12486
|
throw new Error("cannot schedule the restart task: " + message, { cause: error });
|
|
12107
12487
|
}
|
|
12108
12488
|
setTimeout(() => {
|
|
12109
12489
|
try {
|
|
12110
12490
|
process.kill(target.mainPid);
|
|
12111
|
-
|
|
12491
|
+
appendFileSync3(logFile, `${(/* @__PURE__ */ new Date()).toISOString()} host: kill sent to ${target.mainPid}
|
|
12112
12492
|
`, "utf8");
|
|
12113
12493
|
} catch (error) {
|
|
12114
|
-
|
|
12494
|
+
appendFileSync3(logFile, `${(/* @__PURE__ */ new Date()).toISOString()} host: kill failed: ${error instanceof Error ? error.message : String(error)}
|
|
12115
12495
|
`, "utf8");
|
|
12116
12496
|
}
|
|
12117
12497
|
}, 700);
|
|
12118
12498
|
}
|
|
12119
|
-
function
|
|
12499
|
+
function json3(res, status, body) {
|
|
12120
12500
|
res.writeHead(status, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" });
|
|
12121
12501
|
res.end(JSON.stringify(body));
|
|
12122
12502
|
}
|
|
@@ -12143,12 +12523,12 @@ function makeRestartRoutes(deps) {
|
|
|
12143
12523
|
path: RESTART_API.status,
|
|
12144
12524
|
handler: async (req, res) => {
|
|
12145
12525
|
try {
|
|
12146
|
-
if (req.method !== "GET" && req.method !== "POST") return
|
|
12147
|
-
if (!isLoopbackRequest(req)) return
|
|
12526
|
+
if (req.method !== "GET" && req.method !== "POST") return json3(res, 405, { ok: false, error: "method-not-allowed" });
|
|
12527
|
+
if (!isLoopbackRequest(req)) return json3(res, 403, { ok: false, error: "forbidden" });
|
|
12148
12528
|
const target = deps.target();
|
|
12149
|
-
|
|
12529
|
+
json3(res, 200, target === void 0 ? { ok: true, available: false, reason: "desktop-app-unavailable" } : { ok: true, available: true, appPath: target.exePath, mainPid: target.mainPid });
|
|
12150
12530
|
} catch (error) {
|
|
12151
|
-
|
|
12531
|
+
json3(res, 500, { ok: false, error: error instanceof Error ? error.message : String(error) });
|
|
12152
12532
|
}
|
|
12153
12533
|
}
|
|
12154
12534
|
};
|
|
@@ -12157,28 +12537,28 @@ function makeRestartRoutes(deps) {
|
|
|
12157
12537
|
path: RESTART_API.execute,
|
|
12158
12538
|
handler: async (req, res) => {
|
|
12159
12539
|
try {
|
|
12160
|
-
if (req.method !== "POST") return
|
|
12161
|
-
if (!isLoopbackRequest(req)) return
|
|
12540
|
+
if (req.method !== "POST") return json3(res, 405, { ok: false, error: "method-not-allowed" });
|
|
12541
|
+
if (!isLoopbackRequest(req)) return json3(res, 403, { ok: false, error: "forbidden" });
|
|
12162
12542
|
const body = await readJsonBody2(req);
|
|
12163
12543
|
if (body === void 0 || typeof body !== "object" || body === null || body.confirm !== true) {
|
|
12164
|
-
return
|
|
12544
|
+
return json3(res, 400, { ok: false, error: "confirmation-required" });
|
|
12165
12545
|
}
|
|
12166
12546
|
const latest = now();
|
|
12167
|
-
if (latest - lastLaunch < 5e3) return
|
|
12547
|
+
if (latest - lastLaunch < 5e3) return json3(res, 429, { ok: false, error: "restart-already-scheduled" });
|
|
12168
12548
|
const target = deps.target();
|
|
12169
|
-
if (target === void 0) return
|
|
12549
|
+
if (target === void 0) return json3(res, 409, { ok: false, error: "desktop-app-unavailable" });
|
|
12170
12550
|
deps.launch(target);
|
|
12171
12551
|
lastLaunch = latest;
|
|
12172
|
-
|
|
12552
|
+
json3(res, 200, { ok: true, restarting: true, appPath: target.exePath });
|
|
12173
12553
|
} catch (error) {
|
|
12174
|
-
|
|
12554
|
+
json3(res, 500, { ok: false, error: error instanceof Error ? error.message : String(error) });
|
|
12175
12555
|
}
|
|
12176
12556
|
}
|
|
12177
12557
|
};
|
|
12178
12558
|
return [status, execute];
|
|
12179
12559
|
}
|
|
12180
|
-
var
|
|
12181
|
-
function
|
|
12560
|
+
var inject3 = ["webServer"];
|
|
12561
|
+
function apply4(ctx, config) {
|
|
12182
12562
|
const plain = toPlain(config) ?? {};
|
|
12183
12563
|
if (plain.enabled === false) return;
|
|
12184
12564
|
const appPath = typeof plain.appPath === "string" ? plain.appPath : "";
|
|
@@ -12199,9 +12579,9 @@ var session_end_exports = {};
|
|
|
12199
12579
|
__export(session_end_exports, {
|
|
12200
12580
|
Config: () => Config4,
|
|
12201
12581
|
DEFAULT_SESSION_END_CONFIG: () => DEFAULT_SESSION_END_CONFIG,
|
|
12202
|
-
apply: () =>
|
|
12582
|
+
apply: () => apply5,
|
|
12203
12583
|
createSessionEndController: () => createSessionEndController,
|
|
12204
|
-
inject: () =>
|
|
12584
|
+
inject: () => inject4,
|
|
12205
12585
|
inspectRunningTasks: () => inspectRunningTasks,
|
|
12206
12586
|
isSessionEndMode: () => isSessionEndMode,
|
|
12207
12587
|
makeSessionEndRoutes: () => makeSessionEndRoutes,
|
|
@@ -12209,9 +12589,9 @@ __export(session_end_exports, {
|
|
|
12209
12589
|
shutdownComputer: () => shutdownComputer
|
|
12210
12590
|
});
|
|
12211
12591
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
12212
|
-
import { appendFileSync as
|
|
12213
|
-
import { tmpdir as
|
|
12214
|
-
import { join as
|
|
12592
|
+
import { appendFileSync as appendFileSync4, existsSync as existsSync2 } from "node:fs";
|
|
12593
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
12594
|
+
import { join as join4 } from "node:path";
|
|
12215
12595
|
import z4 from "@deepseek-ai/schemastery";
|
|
12216
12596
|
|
|
12217
12597
|
// src/session-end/email.ts
|
|
@@ -12323,6 +12703,13 @@ var DEFAULT_SESSION_END_CONFIG = {
|
|
|
12323
12703
|
"\u7406\u7531\uFF1A{{reason}}"
|
|
12324
12704
|
].join("\n")
|
|
12325
12705
|
};
|
|
12706
|
+
var SESSION_END_GUIDANCE = [
|
|
12707
|
+
"[session-end action] set_session_end_action arms one one-shot action after this turn.",
|
|
12708
|
+
"Use it only when this turn changed DSH plugin host/client source, build output (lib/), cordis.patch.yml, profile loader entries, or a setting that is read only at startup, and the change has been built and verified.",
|
|
12709
|
+
"Do not arm it for ordinary project files, docs/README, tests-only changes, live-applied settings, EDA/MATLAB/STM32 project work, or todo-only changes. Do not arm it when nothing was built, installed, or loaded.",
|
|
12710
|
+
"Arm it during the turn, after verification and before the final answer. It runs after the final reply is fully displayed and waits for all running agent turns and background jobs.",
|
|
12711
|
+
"Use close only when the user explicitly asks to close DSH. Shutdown is user-only. If you are unsure whether a restart is required, ask the user instead of arming."
|
|
12712
|
+
].join(" ");
|
|
12326
12713
|
var Config4 = z4.object({
|
|
12327
12714
|
enabled: z4.boolean().default(DEFAULT_SESSION_END_CONFIG.enabled).volatile(),
|
|
12328
12715
|
graceMs: z4.number().min(0).max(15e3).default(DEFAULT_SESSION_END_CONFIG.graceMs).volatile(),
|
|
@@ -12336,11 +12723,11 @@ function isSessionEndMode(value) {
|
|
|
12336
12723
|
return value === "off" || value === "restart" || value === "close" || value === "shutdown";
|
|
12337
12724
|
}
|
|
12338
12725
|
function sessionLogPath() {
|
|
12339
|
-
return
|
|
12726
|
+
return join4(tmpdir4(), "dsh-mcviseron-session-end.log");
|
|
12340
12727
|
}
|
|
12341
12728
|
function defaultLog(message) {
|
|
12342
12729
|
try {
|
|
12343
|
-
|
|
12730
|
+
appendFileSync4(sessionLogPath(), (/* @__PURE__ */ new Date()).toISOString() + " " + message + "\n", "utf8");
|
|
12344
12731
|
} catch {
|
|
12345
12732
|
}
|
|
12346
12733
|
}
|
|
@@ -12403,6 +12790,7 @@ function createSessionEndController(deps = {}) {
|
|
|
12403
12790
|
const log = deps.log ?? defaultLog;
|
|
12404
12791
|
const entries = /* @__PURE__ */ new Map();
|
|
12405
12792
|
const timers = /* @__PURE__ */ new Map();
|
|
12793
|
+
let dispatching = false;
|
|
12406
12794
|
const resolveTarget = deps.resolveTarget ?? (() => resolveRestartTarget(
|
|
12407
12795
|
process.execPath,
|
|
12408
12796
|
process.ppid,
|
|
@@ -12453,7 +12841,16 @@ function createSessionEndController(deps = {}) {
|
|
|
12453
12841
|
};
|
|
12454
12842
|
const fire = (sessionId, entry) => {
|
|
12455
12843
|
cancel(sessionId);
|
|
12456
|
-
|
|
12844
|
+
if (dispatching) {
|
|
12845
|
+
entries.delete(sessionId);
|
|
12846
|
+
return;
|
|
12847
|
+
}
|
|
12848
|
+
dispatching = true;
|
|
12849
|
+
for (const [id, timer] of timers) {
|
|
12850
|
+
clearTimeout(timer);
|
|
12851
|
+
timers.delete(id);
|
|
12852
|
+
}
|
|
12853
|
+
entries.clear();
|
|
12457
12854
|
const mode = entry.mode;
|
|
12458
12855
|
try {
|
|
12459
12856
|
if (mode === "restart") {
|
|
@@ -12498,7 +12895,15 @@ function createSessionEndController(deps = {}) {
|
|
|
12498
12895
|
get(sessionId) {
|
|
12499
12896
|
return view(sessionId);
|
|
12500
12897
|
},
|
|
12501
|
-
|
|
12898
|
+
list() {
|
|
12899
|
+
return [...entries.entries()].map(([sessionId, entry]) => ({
|
|
12900
|
+
sessionId,
|
|
12901
|
+
label: entry.label ?? "",
|
|
12902
|
+
armedAt: entry.armedAt,
|
|
12903
|
+
...view(sessionId)
|
|
12904
|
+
}));
|
|
12905
|
+
},
|
|
12906
|
+
set(sessionId, mode, requestedBy, label) {
|
|
12502
12907
|
if (sessionId === "") throw new TypeError("sessionId must be non-empty");
|
|
12503
12908
|
if (!enabled) throw new Error("session-end actions are disabled");
|
|
12504
12909
|
if (!isSessionEndMode(mode)) throw new TypeError("unknown session-end mode: " + String(mode));
|
|
@@ -12513,6 +12918,8 @@ function createSessionEndController(deps = {}) {
|
|
|
12513
12918
|
entries.set(sessionId, {
|
|
12514
12919
|
mode,
|
|
12515
12920
|
requestedBy,
|
|
12921
|
+
...label === void 0 || label === "" ? {} : { label },
|
|
12922
|
+
armedAt: Date.now(),
|
|
12516
12923
|
waiting: false,
|
|
12517
12924
|
runningAgents: 0,
|
|
12518
12925
|
runningJobs: 0
|
|
@@ -12520,9 +12927,13 @@ function createSessionEndController(deps = {}) {
|
|
|
12520
12927
|
return view(sessionId);
|
|
12521
12928
|
},
|
|
12522
12929
|
onTurnStart(sessionId) {
|
|
12523
|
-
|
|
12930
|
+
const entry = entries.get(sessionId);
|
|
12931
|
+
if (entry !== void 0) {
|
|
12932
|
+
entry.waiting = false;
|
|
12933
|
+
entry.runningAgents = 0;
|
|
12934
|
+
entry.runningJobs = 0;
|
|
12935
|
+
}
|
|
12524
12936
|
cancel(sessionId);
|
|
12525
|
-
entries.delete(sessionId);
|
|
12526
12937
|
},
|
|
12527
12938
|
onTurnEnd(sessionId) {
|
|
12528
12939
|
const entry = entries.get(sessionId);
|
|
@@ -12533,10 +12944,11 @@ function createSessionEndController(deps = {}) {
|
|
|
12533
12944
|
for (const timer of timers.values()) clearTimeout(timer);
|
|
12534
12945
|
timers.clear();
|
|
12535
12946
|
entries.clear();
|
|
12947
|
+
dispatching = false;
|
|
12536
12948
|
}
|
|
12537
12949
|
};
|
|
12538
12950
|
}
|
|
12539
|
-
function
|
|
12951
|
+
function json4(res, status, body) {
|
|
12540
12952
|
res.writeHead(status, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" });
|
|
12541
12953
|
res.end(JSON.stringify(body));
|
|
12542
12954
|
}
|
|
@@ -12561,18 +12973,23 @@ function bodySessionId(body) {
|
|
|
12561
12973
|
return typeof value === "string" && value !== "" ? value : void 0;
|
|
12562
12974
|
}
|
|
12563
12975
|
function makeSessionEndRoutes(controller) {
|
|
12976
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12564
12977
|
const state = {
|
|
12565
12978
|
kind: "exact",
|
|
12566
12979
|
path: SESSION_END_API.state,
|
|
12567
12980
|
handler: async (req, res) => {
|
|
12568
12981
|
try {
|
|
12569
|
-
if (req.method !== "POST") return
|
|
12570
|
-
if (!isLoopbackRequest(req)) return
|
|
12982
|
+
if (req.method !== "POST") return json4(res, 405, { ok: false, error: "method-not-allowed" });
|
|
12983
|
+
if (!isLoopbackRequest(req)) return json4(res, 403, { ok: false, error: "forbidden" });
|
|
12571
12984
|
const sessionId = bodySessionId(await readJsonBody3(req));
|
|
12572
|
-
if (sessionId === void 0) return
|
|
12573
|
-
|
|
12985
|
+
if (sessionId === void 0) return json4(res, 400, { ok: false, error: "sessionId-required" });
|
|
12986
|
+
if (!seen.has(sessionId)) {
|
|
12987
|
+
seen.add(sessionId);
|
|
12988
|
+
defaultLog("state request: session=" + sessionId);
|
|
12989
|
+
}
|
|
12990
|
+
json4(res, 200, { ok: true, ...controller.get(sessionId) });
|
|
12574
12991
|
} catch (error) {
|
|
12575
|
-
|
|
12992
|
+
json4(res, 500, { ok: false, error: error instanceof Error ? error.message : String(error) });
|
|
12576
12993
|
}
|
|
12577
12994
|
}
|
|
12578
12995
|
};
|
|
@@ -12581,22 +12998,40 @@ function makeSessionEndRoutes(controller) {
|
|
|
12581
12998
|
path: SESSION_END_API.set,
|
|
12582
12999
|
handler: async (req, res) => {
|
|
12583
13000
|
try {
|
|
12584
|
-
if (req.method !== "POST") return
|
|
12585
|
-
if (!isLoopbackRequest(req)) return
|
|
13001
|
+
if (req.method !== "POST") return json4(res, 405, { ok: false, error: "method-not-allowed" });
|
|
13002
|
+
if (!isLoopbackRequest(req)) return json4(res, 403, { ok: false, error: "forbidden" });
|
|
12586
13003
|
const body = await readJsonBody3(req);
|
|
12587
13004
|
const sessionId = bodySessionId(body);
|
|
12588
|
-
if (sessionId === void 0) return
|
|
13005
|
+
if (sessionId === void 0) return json4(res, 400, { ok: false, error: "sessionId-required" });
|
|
12589
13006
|
const mode = body.mode;
|
|
12590
|
-
if (!isSessionEndMode(mode)) return
|
|
12591
|
-
|
|
13007
|
+
if (!isSessionEndMode(mode)) return json4(res, 400, { ok: false, error: "mode-invalid" });
|
|
13008
|
+
json4(res, 200, { ok: true, ...controller.set(sessionId, mode, "user") });
|
|
12592
13009
|
} catch (error) {
|
|
12593
|
-
|
|
13010
|
+
json4(res, 400, { ok: false, error: error instanceof Error ? error.message : String(error) });
|
|
12594
13011
|
}
|
|
12595
13012
|
}
|
|
12596
13013
|
};
|
|
12597
|
-
|
|
13014
|
+
const global = {
|
|
13015
|
+
kind: "exact",
|
|
13016
|
+
path: SESSION_END_API.global,
|
|
13017
|
+
handler: (req, res) => {
|
|
13018
|
+
if (req.method !== "POST" && req.method !== "GET") {
|
|
13019
|
+
json4(res, 405, { ok: false, error: "method-not-allowed" });
|
|
13020
|
+
return;
|
|
13021
|
+
}
|
|
13022
|
+
if (!isLoopbackRequest(req)) {
|
|
13023
|
+
json4(res, 403, { ok: false, error: "forbidden" });
|
|
13024
|
+
return;
|
|
13025
|
+
}
|
|
13026
|
+
json4(res, 200, {
|
|
13027
|
+
ok: true,
|
|
13028
|
+
actions: controller.list().filter((action) => action.requestedBy === "ai" && action.mode !== "off")
|
|
13029
|
+
});
|
|
13030
|
+
}
|
|
13031
|
+
};
|
|
13032
|
+
return [state, set, global];
|
|
12598
13033
|
}
|
|
12599
|
-
function
|
|
13034
|
+
function serviceOf3(ctx, name) {
|
|
12600
13035
|
try {
|
|
12601
13036
|
const direct = ctx[name];
|
|
12602
13037
|
if (direct !== void 0) return direct;
|
|
@@ -12609,21 +13044,43 @@ function serviceOf2(ctx, name) {
|
|
|
12609
13044
|
return void 0;
|
|
12610
13045
|
}
|
|
12611
13046
|
}
|
|
13047
|
+
function installGuidance(ctx) {
|
|
13048
|
+
const inject5 = ctx.inject;
|
|
13049
|
+
if (typeof inject5 !== "function") return;
|
|
13050
|
+
try {
|
|
13051
|
+
inject5.call(ctx, ["systemPrompt"], (scope) => {
|
|
13052
|
+
const systemPrompt = serviceOf3(scope, "systemPrompt");
|
|
13053
|
+
if (systemPrompt === void 0 || typeof systemPrompt.section !== "function") return;
|
|
13054
|
+
try {
|
|
13055
|
+
systemPrompt.section({
|
|
13056
|
+
name: "plugin:mcviseron-session-end",
|
|
13057
|
+
order: 230,
|
|
13058
|
+
text: SESSION_END_GUIDANCE
|
|
13059
|
+
});
|
|
13060
|
+
} catch (error) {
|
|
13061
|
+
defaultLog("guidance registration failed: " + (error instanceof Error ? error.message : String(error)));
|
|
13062
|
+
}
|
|
13063
|
+
});
|
|
13064
|
+
} catch (error) {
|
|
13065
|
+
defaultLog("guidance injection failed: " + (error instanceof Error ? error.message : String(error)));
|
|
13066
|
+
}
|
|
13067
|
+
}
|
|
12612
13068
|
var emailed = /* @__PURE__ */ new Map();
|
|
12613
13069
|
function installAgentTool(ctx, controller, options, log) {
|
|
12614
|
-
const
|
|
12615
|
-
if (typeof
|
|
13070
|
+
const inject5 = ctx.inject;
|
|
13071
|
+
if (typeof inject5 !== "function") return;
|
|
12616
13072
|
try {
|
|
12617
|
-
|
|
12618
|
-
const tools =
|
|
13073
|
+
inject5.call(ctx, ["tools"], (scope) => {
|
|
13074
|
+
const tools = serviceOf3(scope, "tools");
|
|
12619
13075
|
if (tools === void 0 || typeof tools.register !== "function") return;
|
|
12620
13076
|
const definition = {
|
|
12621
13077
|
name: "set_session_end_action",
|
|
12622
13078
|
description: [
|
|
12623
13079
|
"Set the action DSH performs after the current turn has fully finished.",
|
|
12624
|
-
"
|
|
12625
|
-
"
|
|
12626
|
-
"
|
|
13080
|
+
"WHEN TO USE: this turn changed DSH plugin host/client source, build output (lib/), cordis.patch.yml, profile loader entries, or a setting read only at startup, and the change is built and verified.",
|
|
13081
|
+
"WHEN NOT TO USE: ordinary project files, docs/README, tests-only changes, live-applied settings, EDA/MATLAB/STM32 work, todo-only changes, or when nothing was built/installed/loaded.",
|
|
13082
|
+
"Arm restart during the turn, after verification and before the final answer. It runs after the final reply is fully displayed and waits for all running agent turns and background jobs.",
|
|
13083
|
+
"Use close only when the user explicitly asks to close DSH. Shutdown is user-only. If unsure whether a restart is required, ask the user instead of arming."
|
|
12627
13084
|
].join(" "),
|
|
12628
13085
|
parameters: {
|
|
12629
13086
|
action: {
|
|
@@ -12641,11 +13098,12 @@ function installAgentTool(ctx, controller, options, log) {
|
|
|
12641
13098
|
schema: {
|
|
12642
13099
|
type: "object",
|
|
12643
13100
|
additionalProperties: false,
|
|
13101
|
+
required: ["ok", "action", "requestedBy", "message"],
|
|
12644
13102
|
properties: {
|
|
12645
|
-
ok: { type: "boolean"
|
|
12646
|
-
action: { type: "string",
|
|
12647
|
-
requestedBy: { type: "string",
|
|
12648
|
-
message: { type: "string"
|
|
13103
|
+
ok: { type: "boolean" },
|
|
13104
|
+
action: { type: "string", enum: ["off", "restart", "close"] },
|
|
13105
|
+
requestedBy: { type: "string", enum: ["ai"] },
|
|
13106
|
+
message: { type: "string" }
|
|
12649
13107
|
}
|
|
12650
13108
|
},
|
|
12651
13109
|
render: (_args, value) => [{
|
|
@@ -12669,18 +13127,28 @@ function installAgentTool(ctx, controller, options, log) {
|
|
|
12669
13127
|
if (action === "close" && !before.available.close) {
|
|
12670
13128
|
throw new Error("close is unavailable in this host");
|
|
12671
13129
|
}
|
|
12672
|
-
|
|
13130
|
+
const session = exec.agent?.session;
|
|
13131
|
+
const title = session?.header?.title ?? session?.header?.name ?? session?.title;
|
|
13132
|
+
let label = typeof title === "string" && title !== "" ? title : "";
|
|
13133
|
+
if (label === "") {
|
|
13134
|
+
try {
|
|
13135
|
+
const titles = serviceOf3(ctx, "sessionTitle");
|
|
13136
|
+
const snapshot = titles?.get?.(session);
|
|
13137
|
+
const folded = snapshot !== null && typeof snapshot === "object" ? snapshot.title : void 0;
|
|
13138
|
+
if (typeof folded === "string" && folded !== "") label = folded;
|
|
13139
|
+
} catch {
|
|
13140
|
+
}
|
|
13141
|
+
}
|
|
13142
|
+
controller.set(sessionId, action, "ai", label);
|
|
12673
13143
|
if (action !== "off" && options.notifyEmailOnAi) {
|
|
12674
13144
|
const key = sessionId + ":" + action;
|
|
12675
13145
|
const now = Date.now();
|
|
12676
13146
|
const previous = emailed.get(key) ?? 0;
|
|
12677
13147
|
if (now - previous > 6e4) {
|
|
12678
13148
|
emailed.set(key, now);
|
|
12679
|
-
const
|
|
12680
|
-
const title = session?.header?.title ?? session?.header?.name ?? session?.title;
|
|
12681
|
-
const sessionName = typeof title === "string" && title !== "" ? title : sessionId;
|
|
13149
|
+
const sessionName = label === "" ? sessionId : label;
|
|
12682
13150
|
void sendSessionEndEmail({
|
|
12683
|
-
settings:
|
|
13151
|
+
settings: serviceOf3(ctx, "settings"),
|
|
12684
13152
|
template: options,
|
|
12685
13153
|
sessionId,
|
|
12686
13154
|
sessionName,
|
|
@@ -12738,15 +13206,15 @@ function normalizeSessionEndOptions(input) {
|
|
|
12738
13206
|
appPath: string("appPath", "")
|
|
12739
13207
|
};
|
|
12740
13208
|
}
|
|
12741
|
-
var
|
|
12742
|
-
function
|
|
13209
|
+
var inject4 = ["webServer"];
|
|
13210
|
+
function apply5(ctx, config) {
|
|
12743
13211
|
const options = normalizeSessionEndOptions(config);
|
|
12744
13212
|
const log = defaultLog;
|
|
12745
13213
|
const controller = createSessionEndController({
|
|
12746
13214
|
enabled: options.enabled,
|
|
12747
13215
|
graceMs: options.graceMs,
|
|
12748
13216
|
appPath: options.appPath,
|
|
12749
|
-
hasRunningTasks: () => inspectRunningTasks(
|
|
13217
|
+
hasRunningTasks: () => inspectRunningTasks(serviceOf3(ctx, "agents"), serviceOf3(ctx, "jobs"))
|
|
12750
13218
|
});
|
|
12751
13219
|
const routes = makeSessionEndRoutes(controller);
|
|
12752
13220
|
ctx.effect(() => {
|
|
@@ -12756,13 +13224,22 @@ function apply4(ctx, config) {
|
|
|
12756
13224
|
};
|
|
12757
13225
|
}, "mcviseron-session-end: routes");
|
|
12758
13226
|
if (options.enabled) {
|
|
12759
|
-
;
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
13227
|
+
const root = ctx.root;
|
|
13228
|
+
const eventBus = root ?? ctx;
|
|
13229
|
+
if (typeof eventBus.on === "function") {
|
|
13230
|
+
ctx.effect(() => {
|
|
13231
|
+
const dispose = eventBus.on?.("session/event", (session, event) => {
|
|
13232
|
+
const sessionId = sessionIdOf2(session);
|
|
13233
|
+
if (sessionId === "") return;
|
|
13234
|
+
if (event?.type === "turn/start") controller.onTurnStart(sessionId);
|
|
13235
|
+
else if (event?.type === "turn/end") controller.onTurnEnd(sessionId);
|
|
13236
|
+
});
|
|
13237
|
+
return () => {
|
|
13238
|
+
if (typeof dispose === "function") dispose();
|
|
13239
|
+
};
|
|
13240
|
+
}, "mcviseron-session-end: session events");
|
|
13241
|
+
}
|
|
13242
|
+
installGuidance(ctx);
|
|
12766
13243
|
installAgentTool(ctx, controller, options, log);
|
|
12767
13244
|
}
|
|
12768
13245
|
try {
|
|
@@ -12776,7 +13253,7 @@ var task_guard_exports = {};
|
|
|
12776
13253
|
__export(task_guard_exports, {
|
|
12777
13254
|
Config: () => Config5,
|
|
12778
13255
|
DEFAULT_TASK_GUARD_CONFIG: () => DEFAULT_TASK_GUARD_CONFIG,
|
|
12779
|
-
apply: () =>
|
|
13256
|
+
apply: () => apply6
|
|
12780
13257
|
});
|
|
12781
13258
|
import z5 from "@deepseek-ai/schemastery";
|
|
12782
13259
|
|
|
@@ -12939,7 +13416,7 @@ function completionPayload(todos, matched) {
|
|
|
12939
13416
|
}));
|
|
12940
13417
|
return JSON.stringify({ todos: updated });
|
|
12941
13418
|
}
|
|
12942
|
-
function
|
|
13419
|
+
function serviceOf4(scope, name) {
|
|
12943
13420
|
try {
|
|
12944
13421
|
const direct = scope[name];
|
|
12945
13422
|
if (direct !== void 0) return direct;
|
|
@@ -12968,7 +13445,7 @@ function sessionRoute2(agent) {
|
|
|
12968
13445
|
}
|
|
12969
13446
|
function noticeContext(agent, config, ctx) {
|
|
12970
13447
|
const route = sessionRoute2(agent);
|
|
12971
|
-
const llm =
|
|
13448
|
+
const llm = serviceOf4(ctx, "llm");
|
|
12972
13449
|
return {
|
|
12973
13450
|
llm,
|
|
12974
13451
|
route,
|
|
@@ -13287,12 +13764,12 @@ function isTracked(toolName, config) {
|
|
|
13287
13764
|
}
|
|
13288
13765
|
function readTodos(value) {
|
|
13289
13766
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
13290
|
-
const
|
|
13291
|
-
if (Object.keys(
|
|
13292
|
-
if (!Array.isArray(
|
|
13767
|
+
const record2 = value;
|
|
13768
|
+
if (Object.keys(record2).some((key) => key !== "todos")) return null;
|
|
13769
|
+
if (!Array.isArray(record2.todos)) return null;
|
|
13293
13770
|
const todos = [];
|
|
13294
13771
|
const seen = /* @__PURE__ */ new Set();
|
|
13295
|
-
for (const item of
|
|
13772
|
+
for (const item of record2.todos) {
|
|
13296
13773
|
if (item === null || typeof item !== "object" || Array.isArray(item)) return null;
|
|
13297
13774
|
const entry = item;
|
|
13298
13775
|
if (Object.keys(entry).some((key) => key !== "content" && key !== "status")) return null;
|
|
@@ -13488,7 +13965,7 @@ var Config5 = z5.object({
|
|
|
13488
13965
|
include: z5.array(z5.string()).default(DEFAULT_TASK_GUARD_CONFIG.include).volatile(),
|
|
13489
13966
|
exclude: z5.array(z5.string()).default(DEFAULT_TASK_GUARD_CONFIG.exclude).volatile()
|
|
13490
13967
|
}).default(DEFAULT_TASK_GUARD_CONFIG);
|
|
13491
|
-
function
|
|
13968
|
+
function apply6(ctx, config) {
|
|
13492
13969
|
installTaskGuard(ctx, toPlain(config));
|
|
13493
13970
|
}
|
|
13494
13971
|
|
|
@@ -13518,8 +13995,9 @@ function mount(ctx, component, config) {
|
|
|
13518
13995
|
logger?.warn?.(new Error("mcviseron: cannot mount a component", { cause: error }));
|
|
13519
13996
|
}
|
|
13520
13997
|
}
|
|
13521
|
-
function
|
|
13998
|
+
function apply7(ctx, rawConfig) {
|
|
13522
13999
|
const config = toPlain(rawConfig) ?? {};
|
|
14000
|
+
mount(ctx, auth_cookie_exports, {});
|
|
13523
14001
|
mount(ctx, appearance_exports, {
|
|
13524
14002
|
enabled: config.enabled ?? DEFAULT_SCHEDULE_CONFIG.enabled,
|
|
13525
14003
|
lightStart: config.lightStart ?? DEFAULT_SCHEDULE_CONFIG.lightStart,
|
|
@@ -13537,5 +14015,5 @@ function apply6(ctx, rawConfig) {
|
|
|
13537
14015
|
}
|
|
13538
14016
|
export {
|
|
13539
14017
|
Config6 as Config,
|
|
13540
|
-
|
|
14018
|
+
apply7 as apply
|
|
13541
14019
|
};
|