@cortexkit/opencode-magic-context 0.41.2 → 0.41.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/dist/announcement-3c1vertn.js +14 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +756 -4
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/conflict-warning-hook-ejkc9sjn.js +16 -0
- package/dist/derive-budgets-bc366cz8.js +13 -0
- package/dist/features/magic-context/compartment-lease.d.ts +6 -0
- package/dist/features/magic-context/compartment-lease.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +13 -0
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +3 -0
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +18 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +13 -14
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +1 -1
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage-subagent-invocations.d.ts +3 -2
- package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +6 -0
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +2 -2
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/features/magic-context/subagent-token-capture.d.ts +2 -1
- package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts +5 -1
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +6 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +4 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts +2 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/derive-budgets.d.ts +1 -0
- package/dist/hooks/magic-context/derive-budgets.d.ts.map +1 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts +3 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-status.d.ts +7 -1
- package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts +4 -3
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts +2 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +9 -5
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +6 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/issue-423-fixture.d.ts +37 -0
- package/dist/hooks/magic-context/issue-423-fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/issue-424-fixture.d.ts +11 -0
- package/dist/hooks/magic-context/issue-424-fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/module-state-sync.d.ts +2 -1
- package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts +11 -4
- package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-wire.d.ts +6 -1
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/producer-window-guard.d.ts +8 -0
- package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +59 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +2 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-db.d.ts +15 -0
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts +4 -1
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +2 -0
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +15 -2
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/send-session-notification.d.ts +6 -0
- package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
- package/dist/hooks/magic-context/sentinel.d.ts +8 -19
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +2 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +8 -3
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts +1 -0
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +2 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +32 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +4 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
- package/dist/{index-j8r0ejb3.js → index-0y2mcg5y.js} +1971 -11203
- package/dist/{index-1yh8g550.js → index-22jkk6wg.js} +2 -15
- package/dist/{index-dmvy29z0.js → index-3wzdwt6p.js} +11 -15
- package/dist/{index-eq9wr75c.js → index-4avmwfp5.js} +57 -108
- package/dist/{index-d1mxrd3p.js → index-7k55qm8a.js} +17 -12
- package/dist/{index-2wchnyk6.js → index-avwt563y.js} +8 -1
- package/dist/{index-4x691bz5.js → index-dkv2dn46.js} +5 -2
- package/dist/{index-rgdqj8nj.js → index-e7vx3byk.js} +1 -1
- package/dist/{index-szf8w1p5.js → index-fmsr7v69.js} +2 -2
- package/dist/{index-y1yr57fw.js → index-fz104x1j.js} +18 -18
- package/dist/{index-d62ypazr.js → index-jdxxq8cz.js} +6 -11
- package/dist/{index-9j3tx8hy.js → index-may8skc8.js} +6 -25
- package/dist/{index-cvda5jb3.js → index-mjv9je4e.js} +23 -19
- package/dist/{index-zwjhba2r.js → index-q264erdp.js} +122 -41
- package/dist/{index-b9j85d29.js → index-raatkvw5.js} +49 -11
- package/dist/{index-9xexf8s7.js → index-rn7gafjr.js} +1 -9
- package/dist/index-sd3egckz.js +1583 -0
- package/dist/index-v6t0tg85.js +13 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2660 -3255
- package/dist/model-resolution-dxatzjde.js +12 -0
- package/dist/{index-dynqfgx1.js → module-asyncify-2EFITU5U-rkqjhjxd.js} +69 -8
- package/dist/plugin/boot-deadline.d.ts +47 -0
- package/dist/plugin/boot-deadline.d.ts.map +1 -0
- package/dist/plugin/conflict-warning-hook.d.ts +10 -0
- package/dist/plugin/conflict-warning-hook.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +5 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/prompt-context-5y5ms8f9.js +6 -0
- package/dist/recomp-orchestrator-q98r6rga.js +19 -0
- package/dist/rpc-notifications-4amf6mf4.js +14 -0
- package/dist/{index-vnz6jvdc.js → safe-notification-target-q9z81zt3.js} +4 -3
- package/dist/send-session-notification-hdh02wy9.js +16 -0
- package/dist/shared/cache-ttl-display.d.ts +23 -0
- package/dist/shared/cache-ttl-display.d.ts.map +1 -0
- package/dist/shared/cache-ttl-seed.d.ts +10 -0
- package/dist/shared/cache-ttl-seed.d.ts.map +1 -0
- package/dist/shared/config-diagnostics.d.ts +30 -0
- package/dist/shared/config-diagnostics.d.ts.map +1 -0
- package/dist/shared/config-warning-surface.d.ts +3 -0
- package/dist/shared/config-warning-surface.d.ts.map +1 -0
- package/dist/shared/conflict-detector.d.ts +3 -1
- package/dist/shared/conflict-detector.d.ts.map +1 -1
- package/dist/shared/data-path.d.ts +10 -9
- package/dist/shared/data-path.d.ts.map +1 -1
- package/dist/shared/harness-provider-map.d.ts +7 -0
- package/dist/shared/harness-provider-map.d.ts.map +1 -1
- package/dist/shared/harness.d.ts +3 -3
- package/dist/shared/harness.d.ts.map +1 -1
- package/dist/shared/jsonc-parser.d.ts +12 -0
- package/dist/shared/jsonc-parser.d.ts.map +1 -1
- package/dist/shared/model-resolution.d.ts +3 -3
- package/dist/shared/model-resolution.d.ts.map +1 -1
- package/dist/shared/model-suggestion-retry.d.ts +14 -10
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/pi-executable.d.ts +6 -0
- package/dist/shared/pi-executable.d.ts.map +1 -0
- package/dist/shared/prompt-surface-runtime.d.ts +2 -2
- package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
- package/dist/shared/rpc-types.d.ts +6 -0
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/rpc-utils.d.ts.map +1 -1
- package/dist/shared/status-detail-text.d.ts.map +1 -1
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/shared/transcript.d.ts +2 -1
- package/dist/shared/transcript.d.ts.map +1 -1
- package/dist/storage-meta-session-dvwfw778.js +20 -0
- package/dist/task-config-hnv93r7p.js +9 -0
- package/dist/transformers-node-wasm.js +328 -328
- package/dist/transformers-web.js +72 -72
- package/dist/{transformers.node-b1wa0hgx.js → transformers.node-dpmf3wpx.js} +74 -74
- package/package.json +1 -1
- package/src/config/index.test.ts +72 -0
- package/src/config/index.ts +96 -15
- package/src/config/project-security.hostile-matrix.test.ts +78 -9
- package/src/config/project-security.ts +4 -3
- package/src/config/schema/magic-context.test.ts +64 -0
- package/src/config/schema/magic-context.ts +100 -6
- package/src/shared/cache-ttl-display.test.ts +84 -0
- package/src/shared/cache-ttl-display.ts +64 -0
- package/src/shared/cache-ttl-seed.ts +23 -0
- package/src/shared/config-diagnostics.test.ts +29 -0
- package/src/shared/config-diagnostics.ts +64 -0
- package/src/shared/config-warning-surface.ts +28 -0
- package/src/shared/conflict-detector.test.ts +24 -0
- package/src/shared/conflict-detector.ts +25 -7
- package/src/shared/data-path.ts +10 -9
- package/src/shared/harness-provider-map.test.ts +16 -0
- package/src/shared/harness-provider-map.ts +15 -0
- package/src/shared/harness.ts +3 -3
- package/src/shared/jsonc-parser.test.ts +14 -1
- package/src/shared/jsonc-parser.ts +93 -0
- package/src/shared/model-resolution.test.ts +61 -0
- package/src/shared/model-resolution.ts +14 -5
- package/src/shared/model-suggestion-retry.ts +143 -28
- package/src/shared/pi-executable.ts +20 -0
- package/src/shared/prompt-surface-runtime.ts +3 -3
- package/src/shared/rpc-types.ts +6 -0
- package/src/shared/rpc-utils.ts +2 -3
- package/src/shared/status-detail-text.test.ts +2 -1
- package/src/shared/status-detail-text.ts +5 -1
- package/src/shared/tag-transcript.ts +32 -2
- package/src/shared/transcript.ts +3 -1
- package/src/tui/index.tsx +15 -1
- package/src/tui-compiled/index.tsx +234 -222
- package/dist/announcement-3g9xg433.js +0 -18
- package/dist/conflict-warning-hook-rf17b6et.js +0 -17
- package/dist/derive-budgets-9q2d3r93.js +0 -14
- package/dist/emscripten-module-49k43zfy.js +0 -507
- package/dist/emscripten-module-ex4v0x4z.js +0 -606
- package/dist/emscripten-module-jfs3d1dq.js +0 -1536
- package/dist/emscripten-module-ss4g4spn.js +0 -4563
- package/dist/ffi-bbm9vkfa.js +0 -92
- package/dist/ffi-kb5r0x1j.js +0 -92
- package/dist/ffi-qnrt0y78.js +0 -80
- package/dist/ffi-yx2hpf4p.js +0 -80
- package/dist/index-8mtsfhyg.js +0 -146
- package/dist/index-8sseka65.js +0 -251
- package/dist/index-ss632za9.js +0 -77
- package/dist/model-resolution-6w6wzw18.js +0 -17
- package/dist/module-ES6BEMUI-1yjdz59c.js +0 -14
- package/dist/module-asyncify-2EFITU5U-fdkx4fhy.js +0 -9
- package/dist/prompt-context-29qkb28f.js +0 -7
- package/dist/recomp-orchestrator-m37p3fq6.js +0 -34
- package/dist/rpc-notifications-1ffm755w.js +0 -17
- package/dist/safe-notification-target-2a8py95v.js +0 -11
- package/dist/send-session-notification-bw7eex6w.js +0 -20
- package/dist/storage-meta-session-dse3qv6s.js +0 -23
- package/dist/task-config-gv6s04fp.js +0 -18
- /package/dist/{index-37yzyeca.js → index-3fe78beq.js} +0 -0
|
@@ -18,7 +18,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
18
18
|
return cached;
|
|
19
19
|
}
|
|
20
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
22
|
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
23
23
|
for (let key of __getOwnPropNames(mod))
|
|
24
24
|
if (!__hasOwnProp.call(to, key))
|
|
@@ -32,19 +32,6 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
32
32
|
return to;
|
|
33
33
|
};
|
|
34
34
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
35
|
-
var __returnValue = (v) => v;
|
|
36
|
-
function __exportSetter(name, newValue) {
|
|
37
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
38
|
-
}
|
|
39
|
-
var __export = (target, all) => {
|
|
40
|
-
for (var name in all)
|
|
41
|
-
__defProp(target, name, {
|
|
42
|
-
get: all[name],
|
|
43
|
-
enumerable: true,
|
|
44
|
-
configurable: true,
|
|
45
|
-
set: __exportSetter.bind(all, name)
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
35
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
49
36
|
|
|
50
|
-
export { __toESM, __commonJS,
|
|
37
|
+
export { __toESM, __commonJS, __require };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMagicContextStorageDir
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-3fe78beq.js";
|
|
4
4
|
|
|
5
5
|
// src/shared/announcement.ts
|
|
6
6
|
import * as fs from "node:fs";
|
|
@@ -20,14 +20,14 @@ function compareSemverCore(a, b) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// src/shared/announcement.ts
|
|
23
|
-
var
|
|
24
|
-
var
|
|
23
|
+
var ANNOUNCEMENT_VERSION2 = "0.31.0";
|
|
24
|
+
var ANNOUNCEMENT_FEATURES2 = [
|
|
25
25
|
"New /ctx-wrapup command: compact older history on demand, keeping the newest N messages raw. Run it before switching to a smaller-context model.",
|
|
26
26
|
"ctx_search now also searches your session notes and smart notes.",
|
|
27
27
|
"Project identity now survives transient git failures (slow disks, dubious ownership) without splitting your project memory.",
|
|
28
28
|
"Removed the ctx_reduce_enabled setting; agent-controlled reduction is always on. Caveman text compression is now independent (caveman_text_compression.enabled)."
|
|
29
29
|
];
|
|
30
|
-
var
|
|
30
|
+
var ANNOUNCEMENT_FOOTER2 = "Join us on Discord: https://discord.gg/F2uWxjGnU";
|
|
31
31
|
var STATE_FILENAME = "last_announced_version";
|
|
32
32
|
function getStateFilePath() {
|
|
33
33
|
return path.join(getMagicContextStorageDir(), STATE_FILENAME);
|
|
@@ -45,11 +45,7 @@ function readAnnouncementState() {
|
|
|
45
45
|
return { status: "error" };
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const state = readAnnouncementState();
|
|
50
|
-
return state.status === "valid" ? state.version : "";
|
|
51
|
-
}
|
|
52
|
-
function markAnnouncementSeen(version) {
|
|
48
|
+
function markAnnouncementSeen2(version) {
|
|
53
49
|
if (!version)
|
|
54
50
|
return;
|
|
55
51
|
try {
|
|
@@ -58,22 +54,22 @@ function markAnnouncementSeen(version) {
|
|
|
58
54
|
fs.writeFileSync(getStateFilePath(), version);
|
|
59
55
|
} catch {}
|
|
60
56
|
}
|
|
61
|
-
function
|
|
62
|
-
if (!
|
|
57
|
+
function shouldShowAnnouncement2() {
|
|
58
|
+
if (!ANNOUNCEMENT_VERSION2 || ANNOUNCEMENT_FEATURES2.length === 0)
|
|
63
59
|
return false;
|
|
64
60
|
const state = readAnnouncementState();
|
|
65
61
|
if (state.status === "missing") {
|
|
66
|
-
|
|
62
|
+
markAnnouncementSeen2(ANNOUNCEMENT_VERSION2);
|
|
67
63
|
return false;
|
|
68
64
|
}
|
|
69
65
|
if (state.status === "error") {
|
|
70
66
|
return false;
|
|
71
67
|
}
|
|
72
|
-
const ordering = compareSemverCore(
|
|
68
|
+
const ordering = compareSemverCore(ANNOUNCEMENT_VERSION2, state.version);
|
|
73
69
|
if (ordering === null) {
|
|
74
|
-
return state.version !==
|
|
70
|
+
return state.version !== ANNOUNCEMENT_VERSION2;
|
|
75
71
|
}
|
|
76
72
|
return ordering > 0;
|
|
77
73
|
}
|
|
78
74
|
|
|
79
|
-
export { isValidSemver, compareSemverCore,
|
|
75
|
+
export { isValidSemver, compareSemverCore, ANNOUNCEMENT_VERSION2, ANNOUNCEMENT_FEATURES2, ANNOUNCEMENT_FOOTER2, markAnnouncementSeen2, shouldShowAnnouncement2 };
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
readJsoncFile
|
|
3
|
-
} from "./index-8mtsfhyg.js";
|
|
4
|
-
import {
|
|
5
|
-
waitForSafeNotificationTarget
|
|
6
|
-
} from "./index-vnz6jvdc.js";
|
|
7
1
|
import {
|
|
8
2
|
log
|
|
9
|
-
} from "./index-
|
|
3
|
+
} from "./index-dkv2dn46.js";
|
|
10
4
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./index-
|
|
5
|
+
sendIgnoredMessage2
|
|
6
|
+
} from "./index-q264erdp.js";
|
|
7
|
+
import {
|
|
8
|
+
readJsoncFile
|
|
9
|
+
} from "./index-sd3egckz.js";
|
|
13
10
|
|
|
14
11
|
// src/plugin/conflict-warning-hook.ts
|
|
15
12
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -97,11 +94,20 @@ function detectConflicts(directory, options) {
|
|
|
97
94
|
};
|
|
98
95
|
}
|
|
99
96
|
async function resolveCompactionForBoot(client, timeoutMs = 2000) {
|
|
97
|
+
const controller = new AbortController;
|
|
98
|
+
let timer;
|
|
100
99
|
try {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
const timeout = new Promise((resolve) => {
|
|
101
|
+
timer = setTimeout(() => {
|
|
102
|
+
controller.abort(new Error("config.get() timed out"));
|
|
103
|
+
resolve(null);
|
|
104
|
+
}, Math.max(0, timeoutMs));
|
|
105
|
+
timer.unref?.();
|
|
106
|
+
});
|
|
107
|
+
const request = Promise.resolve().then(() => client.config.get({ signal: controller.signal }));
|
|
108
|
+
const result = await Promise.race([request, timeout]);
|
|
109
|
+
if (result === null)
|
|
110
|
+
return null;
|
|
105
111
|
const compaction = result?.data?.compaction;
|
|
106
112
|
if (typeof compaction?.auto !== "boolean" || typeof compaction?.prune !== "boolean") {
|
|
107
113
|
log(`[magic-context] conflict-detector: resolved config carried no explicit compaction block (${JSON.stringify(compaction) ?? "absent"}); falling back to file-based detection`);
|
|
@@ -110,6 +116,9 @@ async function resolveCompactionForBoot(client, timeoutMs = 2000) {
|
|
|
110
116
|
return { auto: compaction.auto, prune: compaction.prune };
|
|
111
117
|
} catch {
|
|
112
118
|
return null;
|
|
119
|
+
} finally {
|
|
120
|
+
if (timer)
|
|
121
|
+
clearTimeout(timer);
|
|
113
122
|
}
|
|
114
123
|
}
|
|
115
124
|
function checkCompaction(directory) {
|
|
@@ -392,43 +401,21 @@ async function getSessionMessages(client, sessionId) {
|
|
|
392
401
|
}
|
|
393
402
|
return [];
|
|
394
403
|
}
|
|
395
|
-
async function
|
|
404
|
+
async function sendConflictWarning2(client, directory, conflictResult) {
|
|
396
405
|
const { sessionId } = getDesktopState(directory);
|
|
397
406
|
if (!sessionId) {
|
|
398
407
|
log("[magic-context] conflict-warning: could not find active session for Desktop warning");
|
|
399
408
|
return;
|
|
400
409
|
}
|
|
401
|
-
if (await waitForSafeNotificationTarget(client, sessionId) === "skip")
|
|
402
|
-
return;
|
|
403
410
|
const warningText = formatConflictShort(conflictResult);
|
|
404
411
|
log(`[magic-context] sending conflict warning to session ${sessionId}: ${conflictResult.reasons.join(", ")}`);
|
|
405
412
|
try {
|
|
406
|
-
|
|
407
|
-
const promptInput = {
|
|
408
|
-
path: { id: sessionId },
|
|
409
|
-
body: {
|
|
410
|
-
noReply: true,
|
|
411
|
-
parts: [
|
|
412
|
-
{
|
|
413
|
-
type: "text",
|
|
414
|
-
text: warningText,
|
|
415
|
-
ignored: true
|
|
416
|
-
}
|
|
417
|
-
]
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
if (typeof c.session?.prompt === "function") {
|
|
421
|
-
await Promise.resolve(c.session.prompt(promptInput));
|
|
422
|
-
} else if (typeof c.session?.promptAsync === "function") {
|
|
423
|
-
await c.session.promptAsync(promptInput);
|
|
424
|
-
} else {
|
|
425
|
-
log("[magic-context] conflict-warning: session prompt API unavailable");
|
|
426
|
-
}
|
|
413
|
+
await sendIgnoredMessage2(client, sessionId, warningText, {});
|
|
427
414
|
} catch (error) {
|
|
428
415
|
log(`[magic-context] conflict-warning: failed to send: ${error instanceof Error ? error.message : String(error)}`);
|
|
429
416
|
}
|
|
430
417
|
}
|
|
431
|
-
async function
|
|
418
|
+
async function cleanupConflictWarnings2(client, directory, serverUrl) {
|
|
432
419
|
const { sessionId } = getDesktopState(directory);
|
|
433
420
|
if (!sessionId) {
|
|
434
421
|
log("[magic-context] cleanup: no active Desktop session found");
|
|
@@ -467,43 +454,33 @@ async function cleanupConflictWarnings(client, directory, serverUrl) {
|
|
|
467
454
|
log(`[magic-context] deleted conflict warning message ${messageId}`);
|
|
468
455
|
}
|
|
469
456
|
}
|
|
470
|
-
if (await waitForSafeNotificationTarget(client, sessionId) === "skip")
|
|
471
|
-
return;
|
|
472
457
|
const enabledText = `${ENABLED_MARKER}. Enjoy! ✨`;
|
|
458
|
+
const scheduleEnabledCleanup = () => {
|
|
459
|
+
setTimeout(async () => {
|
|
460
|
+
try {
|
|
461
|
+
const freshMessages = await getSessionMessages(client, sessionId);
|
|
462
|
+
for (let i = freshMessages.length - 1;i >= 0; i--) {
|
|
463
|
+
const msg = freshMessages[i];
|
|
464
|
+
const msgId = msg.info?.id;
|
|
465
|
+
const msgRole = msg.info?.role;
|
|
466
|
+
if (!msgId || msgRole !== "user")
|
|
467
|
+
break;
|
|
468
|
+
const parts = msg.parts ?? [];
|
|
469
|
+
const isEnabled = parts.length > 0 && parts.every((p) => p.ignored === true && p.type === "text" && typeof p.text === "string" && p.text.startsWith(ENABLED_MARKER));
|
|
470
|
+
if (isEnabled) {
|
|
471
|
+
await deleteMessage(serverUrl, sessionId, msgId);
|
|
472
|
+
} else {
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
} catch {}
|
|
477
|
+
}, 1000);
|
|
478
|
+
};
|
|
473
479
|
try {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
body: {
|
|
478
|
-
noReply: true,
|
|
479
|
-
parts: [{ type: "text", text: enabledText, ignored: true }]
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
if (typeof c.session?.prompt === "function") {
|
|
483
|
-
await Promise.resolve(c.session.prompt(promptInput));
|
|
484
|
-
} else if (typeof c.session?.promptAsync === "function") {
|
|
485
|
-
await c.session.promptAsync(promptInput);
|
|
486
|
-
}
|
|
480
|
+
await sendIgnoredMessage2(client, sessionId, enabledText, {
|
|
481
|
+
onDelivered: scheduleEnabledCleanup
|
|
482
|
+
});
|
|
487
483
|
} catch {}
|
|
488
|
-
setTimeout(async () => {
|
|
489
|
-
try {
|
|
490
|
-
const freshMessages = await getSessionMessages(client, sessionId);
|
|
491
|
-
for (let i = freshMessages.length - 1;i >= 0; i--) {
|
|
492
|
-
const msg = freshMessages[i];
|
|
493
|
-
const msgId = msg.info?.id;
|
|
494
|
-
const msgRole = msg.info?.role;
|
|
495
|
-
if (!msgId || msgRole !== "user")
|
|
496
|
-
break;
|
|
497
|
-
const parts = msg.parts ?? [];
|
|
498
|
-
const isEnabled = parts.length > 0 && parts.every((p) => p.ignored === true && p.type === "text" && typeof p.text === "string" && p.text.startsWith(ENABLED_MARKER));
|
|
499
|
-
if (isEnabled) {
|
|
500
|
-
await deleteMessage(serverUrl, sessionId, msgId);
|
|
501
|
-
} else {
|
|
502
|
-
break;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
} catch {}
|
|
506
|
-
}, 1000);
|
|
507
484
|
}
|
|
508
485
|
async function cleanupEnabledMessages(messages, serverUrl, sessionId) {
|
|
509
486
|
if (!serverUrl)
|
|
@@ -523,12 +500,10 @@ async function cleanupEnabledMessages(messages, serverUrl, sessionId) {
|
|
|
523
500
|
}
|
|
524
501
|
}
|
|
525
502
|
}
|
|
526
|
-
async function
|
|
503
|
+
async function sendSchemaFenceWarning2(client, directory, detail) {
|
|
527
504
|
const { sessionId } = getDesktopState(directory);
|
|
528
505
|
if (!sessionId)
|
|
529
506
|
return;
|
|
530
|
-
if (await waitForSafeNotificationTarget(client, sessionId) === "skip")
|
|
531
|
-
return;
|
|
532
507
|
const text = [
|
|
533
508
|
`${SCHEMA_FENCE_MARKER}`,
|
|
534
509
|
"",
|
|
@@ -546,32 +521,21 @@ async function sendSchemaFenceWarning(client, directory, detail) {
|
|
|
546
521
|
].join(`
|
|
547
522
|
`);
|
|
548
523
|
try {
|
|
549
|
-
|
|
550
|
-
const promptInput = {
|
|
551
|
-
path: { id: sessionId },
|
|
552
|
-
body: { noReply: true, parts: [{ type: "text", text, ignored: true }] }
|
|
553
|
-
};
|
|
554
|
-
if (typeof c.session?.prompt === "function") {
|
|
555
|
-
await Promise.resolve(c.session.prompt(promptInput));
|
|
556
|
-
} else if (typeof c.session?.promptAsync === "function") {
|
|
557
|
-
await c.session.promptAsync(promptInput);
|
|
558
|
-
}
|
|
524
|
+
await sendIgnoredMessage2(client, sessionId, text, {});
|
|
559
525
|
} catch {
|
|
560
526
|
return;
|
|
561
527
|
}
|
|
562
528
|
}
|
|
563
|
-
async function
|
|
529
|
+
async function sendStartupAnnouncement2(client, directory, version, features, footer, markSeen) {
|
|
564
530
|
if (!version || features.length === 0)
|
|
565
531
|
return;
|
|
566
532
|
const { sessionId } = getDesktopState(directory);
|
|
567
533
|
if (!sessionId) {
|
|
568
534
|
return;
|
|
569
535
|
}
|
|
570
|
-
const { isTuiConnected } = await import("./rpc-notifications-
|
|
536
|
+
const { isTuiConnected } = await import("./rpc-notifications-4amf6mf4.js");
|
|
571
537
|
if (isTuiConnected(sessionId) || isTuiConnected())
|
|
572
538
|
return;
|
|
573
|
-
if (await waitForSafeNotificationTarget(client, sessionId) === "skip")
|
|
574
|
-
return;
|
|
575
539
|
const bullets = features.map((line) => ` • ${line}`).join(`
|
|
576
540
|
`);
|
|
577
541
|
const sections = [`${ANNOUNCEMENT_MARKER} v${version}:`, "", bullets];
|
|
@@ -582,27 +546,12 @@ async function sendStartupAnnouncement(client, directory, version, features, foo
|
|
|
582
546
|
`);
|
|
583
547
|
log(`[magic-context] sending startup announcement for v${version} to session ${sessionId}`);
|
|
584
548
|
try {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
body: {
|
|
589
|
-
noReply: true,
|
|
590
|
-
parts: [{ type: "text", text, ignored: true }]
|
|
591
|
-
}
|
|
592
|
-
};
|
|
593
|
-
if (typeof c.session?.prompt === "function") {
|
|
594
|
-
await Promise.resolve(c.session.prompt(promptInput));
|
|
595
|
-
} else if (typeof c.session?.promptAsync === "function") {
|
|
596
|
-
await c.session.promptAsync(promptInput);
|
|
597
|
-
} else {
|
|
598
|
-
log("[magic-context] announcement: session prompt API unavailable");
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
549
|
+
await sendIgnoredMessage2(client, sessionId, text, {
|
|
550
|
+
onDelivered: () => markSeen(version)
|
|
551
|
+
});
|
|
601
552
|
} catch (error) {
|
|
602
553
|
log(`[magic-context] announcement: failed to send: ${error instanceof Error ? error.message : String(error)}`);
|
|
603
|
-
return;
|
|
604
554
|
}
|
|
605
|
-
markSeen(version);
|
|
606
555
|
}
|
|
607
556
|
|
|
608
|
-
export { detectConflicts, resolveCompactionForBoot,
|
|
557
|
+
export { detectConflicts, resolveCompactionForBoot, sendConflictWarning2, cleanupConflictWarnings2, sendSchemaFenceWarning2, sendStartupAnnouncement2 };
|
|
@@ -11,10 +11,14 @@ function readString(value) {
|
|
|
11
11
|
function hasOwn(record, key) {
|
|
12
12
|
return Object.hasOwn(record, key);
|
|
13
13
|
}
|
|
14
|
+
function resolveHarnessBlock(container, harness) {
|
|
15
|
+
const selected = harness === "omp" ? container?.omp ?? container?.pi : container?.[harness];
|
|
16
|
+
return asRecord(selected);
|
|
17
|
+
}
|
|
14
18
|
function normalizeModelEntry(entry, harness) {
|
|
15
19
|
if (typeof entry === "string") {
|
|
16
|
-
const
|
|
17
|
-
return
|
|
20
|
+
const model = readString(entry);
|
|
21
|
+
return model ? { model } : undefined;
|
|
18
22
|
}
|
|
19
23
|
const objectEntry = asRecord(entry);
|
|
20
24
|
if (!objectEntry)
|
|
@@ -35,8 +39,8 @@ function sameAttempt(a, b) {
|
|
|
35
39
|
function resolveFallbackEntries(value, harness) {
|
|
36
40
|
const values = Array.isArray(value) ? value : value === undefined ? [] : [value];
|
|
37
41
|
const resolved = [];
|
|
38
|
-
for (const
|
|
39
|
-
const entry = normalizeModelEntry(
|
|
42
|
+
for (const value of values) {
|
|
43
|
+
const entry = normalizeModelEntry(value, harness);
|
|
40
44
|
if (!entry || !isValidModelReference(entry))
|
|
41
45
|
continue;
|
|
42
46
|
if (resolved.some((candidate) => sameAttempt(candidate, entry)))
|
|
@@ -52,9 +56,9 @@ function resolvePrimaryEntry(args) {
|
|
|
52
56
|
const qualifier = entry.qualifier ?? readString(args.defaultQualifier);
|
|
53
57
|
return qualifier ? { ...entry, qualifier } : entry;
|
|
54
58
|
}
|
|
55
|
-
function
|
|
59
|
+
function resolveHistorianModel2(config, harness) {
|
|
56
60
|
const historian = asRecord(asRecord(config)?.historian);
|
|
57
|
-
const block =
|
|
61
|
+
const block = resolveHarnessBlock(historian, harness);
|
|
58
62
|
if (!block)
|
|
59
63
|
return { fallbacks: [] };
|
|
60
64
|
return {
|
|
@@ -66,9 +70,9 @@ function resolveHistorianModel(config, harness) {
|
|
|
66
70
|
fallbacks: resolveFallbackEntries(block.fallback_models, harness)
|
|
67
71
|
};
|
|
68
72
|
}
|
|
69
|
-
function
|
|
73
|
+
function resolveDreamerTaskModel2(args) {
|
|
70
74
|
const dreamer = asRecord(asRecord(args.config)?.dreamer);
|
|
71
|
-
const harnessBlock =
|
|
75
|
+
const harnessBlock = resolveHarnessBlock(dreamer, args.harness);
|
|
72
76
|
const taskBlock = asRecord(asRecord(harnessBlock?.tasks)?.[args.task]);
|
|
73
77
|
const schedulingTask = asRecord(asRecord(dreamer?.tasks)?.[args.task]);
|
|
74
78
|
if (!harnessBlock) {
|
|
@@ -97,7 +101,7 @@ function resolveDreamerTaskModel(args) {
|
|
|
97
101
|
promotionThreshold: typeof schedulingTask?.promotion_threshold === "number" ? schedulingTask.promotion_threshold : undefined
|
|
98
102
|
};
|
|
99
103
|
}
|
|
100
|
-
function
|
|
104
|
+
function resolveOpenCodeAgentOverrides2(agent) {
|
|
101
105
|
const source = asRecord(agent);
|
|
102
106
|
if (!source)
|
|
103
107
|
return {};
|
|
@@ -108,6 +112,7 @@ function resolveOpenCodeAgentOverrides(agent) {
|
|
|
108
112
|
thinking_level: _thinking,
|
|
109
113
|
opencode,
|
|
110
114
|
pi,
|
|
115
|
+
omp,
|
|
111
116
|
tasks,
|
|
112
117
|
...rest
|
|
113
118
|
} = source;
|
|
@@ -122,11 +127,11 @@ function resolveOpenCodeAgentOverrides(agent) {
|
|
|
122
127
|
...primary?.qualifier ? { variant: primary.qualifier } : {}
|
|
123
128
|
};
|
|
124
129
|
}
|
|
125
|
-
function
|
|
130
|
+
function resolveHistorianAgentOverrides2(agent) {
|
|
126
131
|
return {
|
|
127
132
|
maxTokens: 32000,
|
|
128
|
-
...
|
|
133
|
+
...resolveOpenCodeAgentOverrides2(agent)
|
|
129
134
|
};
|
|
130
135
|
}
|
|
131
136
|
|
|
132
|
-
export {
|
|
137
|
+
export { resolveHistorianModel2, resolveDreamerTaskModel2, resolveOpenCodeAgentOverrides2, resolveHistorianAgentOverrides2 };
|
|
@@ -17,6 +17,9 @@ var OMP_TO_CANONICAL_PROVIDER = {
|
|
|
17
17
|
"google-antigravity": "google",
|
|
18
18
|
"opencode-zen": "opencode"
|
|
19
19
|
};
|
|
20
|
+
var CANONICAL_MODEL_IDENTITY_ALIASES = {
|
|
21
|
+
"github-copilot/gpt-6-astra": "openai/gpt-6-astra"
|
|
22
|
+
};
|
|
20
23
|
function remapProviderPrefix(ref, map) {
|
|
21
24
|
if (typeof ref !== "string")
|
|
22
25
|
return ref;
|
|
@@ -28,6 +31,10 @@ function remapProviderPrefix(ref, map) {
|
|
|
28
31
|
return ref;
|
|
29
32
|
return `${map[provider]}${ref.slice(slash)}`;
|
|
30
33
|
}
|
|
34
|
+
function canonicalModelIdentity(ref) {
|
|
35
|
+
const harnessCanonical = piModelRefToCanonical(ompModelRefToCanonical(ref));
|
|
36
|
+
return CANONICAL_MODEL_IDENTITY_ALIASES[harnessCanonical.toLowerCase()] ?? harnessCanonical;
|
|
37
|
+
}
|
|
31
38
|
function piModelRefToCanonical(ref) {
|
|
32
39
|
return remapProviderPrefix(ref, PI_TO_CANONICAL_PROVIDER);
|
|
33
40
|
}
|
|
@@ -52,4 +59,4 @@ function resolveModelRefForOmp(ref) {
|
|
|
52
59
|
return remapProviderPrefix(ompModelRefToCanonical(ref), CANONICAL_TO_OMP_PROVIDER);
|
|
53
60
|
}
|
|
54
61
|
|
|
55
|
-
export { piModelRefToCanonical, modelRefLookupOrder };
|
|
62
|
+
export { canonicalModelIdentity, piModelRefToCanonical, modelRefLookupOrder };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMagicContextLogPath
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-3fe78beq.js";
|
|
4
4
|
|
|
5
5
|
// src/shared/logger.ts
|
|
6
6
|
import * as fs from "node:fs";
|
|
@@ -362,8 +362,11 @@ function getLoggerDiagnostics() {
|
|
|
362
362
|
lastErrorTime
|
|
363
363
|
};
|
|
364
364
|
}
|
|
365
|
+
function flushLogger() {
|
|
366
|
+
flush();
|
|
367
|
+
}
|
|
365
368
|
if (!isTestEnv) {
|
|
366
369
|
process.on("exit", flush);
|
|
367
370
|
}
|
|
368
371
|
|
|
369
|
-
export { sanitizeDiagnosticText, hasShareabilitySensitiveText, log, sessionLog, getLoggerDiagnostics };
|
|
372
|
+
export { sanitizeDiagnosticText, hasShareabilitySensitiveText, log, sessionLog, getLoggerDiagnostics, flushLogger };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__commonJS,
|
|
3
3
|
__require
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-22jkk6wg.js";
|
|
5
5
|
|
|
6
6
|
// ../../node_modules/.bun/@jitl+quickjs-ffi-types@0.32.0/node_modules/@jitl/quickjs-ffi-types/dist/index.js
|
|
7
7
|
var require_dist = __commonJS(function(exports, module) {
|
|
@@ -40,7 +40,7 @@ function isComplete(ctx) {
|
|
|
40
40
|
return Boolean(ctx.agent && ctx.model && ctx.variant);
|
|
41
41
|
}
|
|
42
42
|
var PROMPT_CONTEXT_MESSAGE_LIMIT = 50;
|
|
43
|
-
async function
|
|
43
|
+
async function resolvePromptContext2(client, sessionId) {
|
|
44
44
|
if (!client || !sessionId)
|
|
45
45
|
return null;
|
|
46
46
|
const c = client;
|
|
@@ -72,4 +72,4 @@ async function resolvePromptContext(client, sessionId) {
|
|
|
72
72
|
return result;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
export {
|
|
75
|
+
export { resolvePromptContext2 };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./index-
|
|
2
|
+
log
|
|
3
|
+
} from "./index-dkv2dn46.js";
|
|
4
4
|
import {
|
|
5
5
|
withReadOnlySessionDb
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-raatkvw5.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./index-
|
|
8
|
+
piModelRefToCanonical
|
|
9
|
+
} from "./index-avwt563y.js";
|
|
10
10
|
import {
|
|
11
11
|
getHarness
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-3fe78beq.js";
|
|
13
13
|
|
|
14
14
|
// src/features/magic-context/storage-meta-session.ts
|
|
15
15
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
@@ -429,11 +429,11 @@ function deleteSessionScopedRows(db, sessionIds, harness, options = {}) {
|
|
|
429
429
|
return 0;
|
|
430
430
|
let deletableSessionIds = [...sessionIds];
|
|
431
431
|
if (options.rustModuleCleanupAcknowledged !== true) {
|
|
432
|
-
const
|
|
432
|
+
const placeholders = sessionIds.map(() => "?").join(", ");
|
|
433
433
|
const harnessPredicate = harness === undefined ? "" : " AND harness = ?";
|
|
434
434
|
const protectedRows = db.prepare(`SELECT session_id
|
|
435
435
|
FROM pending_session_cleanup
|
|
436
|
-
WHERE session_id IN (${
|
|
436
|
+
WHERE session_id IN (${placeholders})
|
|
437
437
|
AND harness LIKE '%:rust'${harnessPredicate}`).all(...sessionIds, ...harness === undefined ? [] : [`${harness}:rust`]);
|
|
438
438
|
const protectedSessionIds = new Set(protectedRows.map((row) => row.session_id));
|
|
439
439
|
deletableSessionIds = sessionIds.filter((sessionId) => !protectedSessionIds.has(sessionId));
|
|
@@ -511,7 +511,7 @@ function getSessionMetaSelectColumns(db) {
|
|
|
511
511
|
sessionMetaSelectColumnsCache.set(db, projection);
|
|
512
512
|
return projection;
|
|
513
513
|
}
|
|
514
|
-
function
|
|
514
|
+
function getOrCreateSessionMeta2(db, sessionId) {
|
|
515
515
|
const result = db.prepare(`SELECT ${getSessionMetaSelectColumns(db)} FROM session_meta WHERE session_id = ?`).get(sessionId);
|
|
516
516
|
if (isSessionMetaRow(result)) {
|
|
517
517
|
return toSessionMeta(result);
|
|
@@ -527,7 +527,7 @@ function getOrCreateSessionMeta(db, sessionId) {
|
|
|
527
527
|
}
|
|
528
528
|
return defaults;
|
|
529
529
|
}
|
|
530
|
-
function
|
|
530
|
+
function updateSessionMeta2(db, sessionId, updates) {
|
|
531
531
|
const setClauses = [];
|
|
532
532
|
const values = [];
|
|
533
533
|
for (const [key, column] of Object.entries(META_COLUMNS)) {
|
|
@@ -556,7 +556,7 @@ function updateSessionMeta(db, sessionId, updates) {
|
|
|
556
556
|
db.prepare(`UPDATE session_meta SET ${setClauses.join(", ")} WHERE session_id = ?`).run(...values, sessionId);
|
|
557
557
|
})();
|
|
558
558
|
}
|
|
559
|
-
function
|
|
559
|
+
function advanceToolReclaimWatermark2(db, sessionId, maxTagNumber) {
|
|
560
560
|
if (maxTagNumber <= 0)
|
|
561
561
|
return;
|
|
562
562
|
db.transaction(() => {
|
|
@@ -567,7 +567,7 @@ function advanceToolReclaimWatermark(db, sessionId, maxTagNumber) {
|
|
|
567
567
|
function rustCleanupHarness() {
|
|
568
568
|
return `${getHarness()}:rust`;
|
|
569
569
|
}
|
|
570
|
-
function
|
|
570
|
+
function markSessionCleanupPending2(db, sessionId, rustModuleCleanupRequired = false) {
|
|
571
571
|
const row = db.prepare(`INSERT INTO pending_session_cleanup (session_id, harness, requested_at, last_attempt_at)
|
|
572
572
|
VALUES (?, ?, ?, NULL)
|
|
573
573
|
ON CONFLICT(session_id) DO UPDATE SET
|
|
@@ -580,7 +580,7 @@ function markSessionCleanupPending(db, sessionId, rustModuleCleanupRequired = fa
|
|
|
580
580
|
RETURNING harness`).get(sessionId, rustModuleCleanupRequired ? rustCleanupHarness() : getHarness(), Date.now());
|
|
581
581
|
return row.harness.endsWith(":rust");
|
|
582
582
|
}
|
|
583
|
-
function
|
|
583
|
+
function retryPendingSessionCleanups2(db, limit = 200) {
|
|
584
584
|
const rows = db.prepare(`SELECT session_id
|
|
585
585
|
FROM pending_session_cleanup
|
|
586
586
|
WHERE harness NOT LIKE '%:rust'
|
|
@@ -591,7 +591,7 @@ function retryPendingSessionCleanups(db, limit = 200) {
|
|
|
591
591
|
for (const row of rows) {
|
|
592
592
|
try {
|
|
593
593
|
db.prepare("UPDATE pending_session_cleanup SET last_attempt_at = ? WHERE session_id = ?").run(Date.now(), row.session_id);
|
|
594
|
-
|
|
594
|
+
clearSession2(db, row.session_id);
|
|
595
595
|
cleared += 1;
|
|
596
596
|
} catch {
|
|
597
597
|
failedSessionIds.push(row.session_id);
|
|
@@ -599,7 +599,7 @@ function retryPendingSessionCleanups(db, limit = 200) {
|
|
|
599
599
|
}
|
|
600
600
|
return { attempted: rows.length, cleared, failedSessionIds };
|
|
601
601
|
}
|
|
602
|
-
async function
|
|
602
|
+
async function retryPendingRustSessionCleanupsForProject2(db, projectPath, deleteSession, limit = 200) {
|
|
603
603
|
const harness = getHarness();
|
|
604
604
|
const rows = db.prepare(`SELECT pending.session_id
|
|
605
605
|
FROM pending_session_cleanup pending
|
|
@@ -616,7 +616,7 @@ async function retryPendingRustSessionCleanupsForProject(db, projectPath, delete
|
|
|
616
616
|
try {
|
|
617
617
|
db.prepare("UPDATE pending_session_cleanup SET last_attempt_at = ? WHERE session_id = ?").run(Date.now(), row.session_id);
|
|
618
618
|
await deleteSession(row.session_id);
|
|
619
|
-
|
|
619
|
+
clearSession2(db, row.session_id, true);
|
|
620
620
|
cleared += 1;
|
|
621
621
|
} catch {
|
|
622
622
|
failedSessionIds.push(row.session_id);
|
|
@@ -624,7 +624,7 @@ async function retryPendingRustSessionCleanupsForProject(db, projectPath, delete
|
|
|
624
624
|
}
|
|
625
625
|
return { attempted: rows.length, cleared, failedSessionIds };
|
|
626
626
|
}
|
|
627
|
-
function
|
|
627
|
+
function clearSession2(db, sessionId, rustModuleCleanupAcknowledged = false) {
|
|
628
628
|
const transactionStartedAt = performance.now();
|
|
629
629
|
db.transaction(() => {
|
|
630
630
|
deleteSessionScopedRows(db, [sessionId], undefined, {
|
|
@@ -634,4 +634,4 @@ function clearSession(db, sessionId, rustModuleCleanupAcknowledged = false) {
|
|
|
634
634
|
logSlowWriteTransaction("clear-session", transactionStartedAt);
|
|
635
635
|
}
|
|
636
636
|
|
|
637
|
-
export { logSlowWriteTransaction, ensureSessionMetaRow, persistCachedM0, clearCachedM0M1, SESSION_SCOPED_TABLES, deleteSessionScopedRows,
|
|
637
|
+
export { logSlowWriteTransaction, ensureSessionMetaRow, persistCachedM0, clearCachedM0M1, SESSION_SCOPED_TABLES, deleteSessionScopedRows, getOrCreateSessionMeta2, updateSessionMeta2, advanceToolReclaimWatermark2, markSessionCleanupPending2, retryPendingSessionCleanups2, retryPendingRustSessionCleanupsForProject2, clearSession2 };
|