@cortexkit/opencode-magic-context 0.41.1 → 0.41.3
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/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-z5sd697e.js +16 -0
- package/dist/derive-budgets-901a0pk0.js +11 -0
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +4 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-embedding.d.ts.map +1 -1
- 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/curate-memory-safety.d.ts +21 -0
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +1 -6
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-failure.d.ts +10 -2
- package/dist/features/magic-context/memory/embedding-failure.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts +7 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/onnxruntime-node-wasm-shim.d.ts +3 -0
- package/dist/features/magic-context/memory/onnxruntime-node-wasm-shim.d.ts.map +1 -0
- package/dist/features/magic-context/memory/sharp-wasm-shim.d.ts +2 -0
- package/dist/features/magic-context/memory/sharp-wasm-shim.d.ts.map +1 -0
- package/dist/features/magic-context/memory/transformers-node-wasm-entry.d.ts +3 -0
- package/dist/features/magic-context/memory/transformers-node-wasm-entry.d.ts.map +1 -0
- package/dist/features/magic-context/message-fts-rowid-map.d.ts +28 -0
- package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -0
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +15 -2
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +20 -2
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +30 -14
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-session.d.ts +3 -2
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +2 -2
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage-schema-helpers.d.ts.map +1 -1
- package/dist/features/magic-context/storage-session-tables.d.ts +9 -1
- package/dist/features/magic-context/storage-session-tables.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 +19 -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/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.d.ts +2 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts +4 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/format-embed-failure.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts +3 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +4 -1
- 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/live-session-state.d.ts +3 -1
- package/dist/hooks/magic-context/live-session-state.d.ts.map +1 -1
- 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/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/rust-mode-transform.d.ts +19 -1
- 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 +18 -53
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-content.d.ts +12 -5
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-id-fallback.d.ts +3 -1
- package/dist/hooks/magic-context/tag-id-fallback.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +57 -2
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-z893kjyt.js → index-0bycg0np.js} +90 -26
- package/dist/{index-1yh8g550.js → index-22jkk6wg.js} +2 -15
- package/dist/{index-dmvy29z0.js → index-3wzdwt6p.js} +11 -15
- package/dist/{index-d1mxrd3p.js → index-7k55qm8a.js} +17 -12
- package/dist/{index-4x691bz5.js → index-dkv2dn46.js} +5 -2
- package/dist/{index-2d4kf2ve.js → index-dn1rwpd8.js} +16 -11
- package/dist/{index-rgdqj8nj.js → index-e7vx3byk.js} +1 -1
- package/dist/{index-szf8w1p5.js → index-fmsr7v69.js} +2 -2
- package/dist/{index-d62ypazr.js → index-jdxxq8cz.js} +6 -11
- package/dist/{index-9j3tx8hy.js → index-may8skc8.js} +6 -25
- package/dist/{index-eq9wr75c.js → index-npx8vhmy.js} +57 -108
- 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-v6t0tg85.js +13 -0
- package/dist/{index-dh0vfghk.js → index-vmmjdpc0.js} +2594 -11271
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3414 -2620
- 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/dream-timer.d.ts +4 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +4 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/prompt-context-5y5ms8f9.js +6 -0
- package/dist/recomp-orchestrator-f5m2wk74.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/conflict-detector.d.ts +3 -1
- package/dist/shared/conflict-detector.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/index.d.ts +1 -0
- package/dist/shared/index.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/prompt-surface-runtime.d.ts +2 -2
- package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
- package/dist/shared/rpc-utils.d.ts +3 -1
- package/dist/shared/rpc-utils.d.ts.map +1 -1
- package/dist/shared/summarize-child-stderr.d.ts +2 -0
- package/dist/shared/summarize-child-stderr.d.ts.map +1 -0
- 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/shared/window-geometry.d.ts +2 -0
- package/dist/shared/window-geometry.d.ts.map +1 -1
- package/dist/storage-meta-session-3rxx9ekm.js +20 -0
- package/dist/task-config-hnv93r7p.js +9 -0
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-memory/types.d.ts +2 -0
- package/dist/tools/ctx-memory/types.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
- package/dist/transformers-node-wasm.js +25676 -0
- package/dist/transformers-web.js +72 -72
- package/dist/{transformers.node-b1wa0hgx.js → transformers.node-dpmf3wpx.js} +74 -74
- package/package.json +4 -3
- package/src/config/index.test.ts +69 -0
- package/src/config/latch-permanence-guard.test.ts +5 -0
- 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/conflict-detector.test.ts +24 -0
- package/src/shared/conflict-detector.ts +25 -7
- package/src/shared/harness.ts +3 -3
- package/src/shared/index.ts +1 -0
- package/src/shared/model-resolution.test.ts +78 -13
- package/src/shared/model-resolution.ts +14 -5
- package/src/shared/prompt-surface-runtime.ts +3 -3
- package/src/shared/rpc-utils.test.ts +246 -5
- package/src/shared/rpc-utils.ts +340 -49
- package/src/shared/summarize-child-stderr.test.ts +55 -0
- package/src/shared/summarize-child-stderr.ts +33 -0
- package/src/shared/tag-transcript.ts +11 -0
- package/src/shared/transcript.ts +3 -1
- package/src/shared/window-geometry.ts +9 -0
- package/dist/announcement-3g9xg433.js +0 -18
- package/dist/conflict-warning-hook-rf17b6et.js +0 -17
- package/dist/derive-budgets-bb7mrpzs.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-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-w7xg48e3.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-gr4zn7sq.js +0 -21
- package/dist/task-config-gv6s04fp.js +0 -18
- /package/dist/{index-37yzyeca.js → index-3fe78beq.js} +0 -0
- /package/dist/{index-8mtsfhyg.js → index-jfpk81yt.js} +0 -0
- /package/dist/{index-2wchnyk6.js → index-kby1sng5.js} +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
modelRefLookupOrder
|
|
3
|
-
} from "./index-2wchnyk6.js";
|
|
4
1
|
import {
|
|
5
2
|
sessionLog
|
|
6
|
-
} from "./index-
|
|
3
|
+
} from "./index-dkv2dn46.js";
|
|
4
|
+
import {
|
|
5
|
+
modelRefLookupOrder
|
|
6
|
+
} from "./index-kby1sng5.js";
|
|
7
7
|
import {
|
|
8
|
-
getDataDir,
|
|
9
8
|
getHarness,
|
|
9
|
+
getDataDir,
|
|
10
10
|
getMagicContextStorageDir
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-3fe78beq.js";
|
|
12
12
|
|
|
13
13
|
// src/shared/models-dev-cache.ts
|
|
14
14
|
import { mkdirSync, readFileSync as readFileSync2, renameSync, writeFileSync } from "node:fs";
|
|
@@ -215,6 +215,11 @@ function readWindowOverlayFile(path, log = (message) => sessionLog("global", mes
|
|
|
215
215
|
return parsed.overlay;
|
|
216
216
|
}
|
|
217
217
|
function setWindowOverlayPath(path) {
|
|
218
|
+
if (configuredOverlayPath === path)
|
|
219
|
+
return;
|
|
220
|
+
reloadWindowOverlay(path);
|
|
221
|
+
}
|
|
222
|
+
function reloadWindowOverlay(path) {
|
|
218
223
|
configuredOverlayPath = path;
|
|
219
224
|
loadedOverlayPath = undefined;
|
|
220
225
|
loadedOverlay = undefined;
|
|
@@ -549,7 +554,7 @@ function setCachedModelMetadata(cache, key, model) {
|
|
|
549
554
|
if (rawLimit === undefined)
|
|
550
555
|
return;
|
|
551
556
|
const values = [model?.capabilities, model?.modalities, model?.input, model?.attachment];
|
|
552
|
-
const vision = values.some((
|
|
557
|
+
const vision = values.some((value) => JSON.stringify(value ?? "").toLowerCase().includes("image") || JSON.stringify(value ?? "").toLowerCase().includes("vision"));
|
|
553
558
|
const value = {
|
|
554
559
|
limit: rawLimit,
|
|
555
560
|
contextLimit: isSaneLimit(contextLimit) ? contextLimit : undefined,
|
|
@@ -697,7 +702,7 @@ var HISTORIAN_CHUNK_PERCENTAGE = 0.25;
|
|
|
697
702
|
var HISTORIAN_CHUNK_MIN = 8000;
|
|
698
703
|
var HISTORIAN_CHUNK_MAX = 50000;
|
|
699
704
|
var DEFAULT_HISTORIAN_CONTEXT_FALLBACK = 128000;
|
|
700
|
-
function
|
|
705
|
+
function deriveTriggerBudget2(mainContextLimit, executeThresholdPercentage) {
|
|
701
706
|
if (!Number.isFinite(mainContextLimit) || mainContextLimit <= 0) {
|
|
702
707
|
return TRIGGER_BUDGET_MIN;
|
|
703
708
|
}
|
|
@@ -706,14 +711,14 @@ function deriveTriggerBudget(mainContextLimit, executeThresholdPercentage) {
|
|
|
706
711
|
const derived = Math.round(usable * TRIGGER_BUDGET_PERCENTAGE);
|
|
707
712
|
return Math.max(TRIGGER_BUDGET_MIN, Math.min(TRIGGER_BUDGET_MAX, derived));
|
|
708
713
|
}
|
|
709
|
-
function
|
|
714
|
+
function deriveHistorianChunkTokens2(historianContextLimit) {
|
|
710
715
|
if (!Number.isFinite(historianContextLimit) || historianContextLimit <= 0) {
|
|
711
716
|
return HISTORIAN_CHUNK_MIN;
|
|
712
717
|
}
|
|
713
718
|
const derived = Math.round(historianContextLimit * HISTORIAN_CHUNK_PERCENTAGE);
|
|
714
719
|
return Math.max(HISTORIAN_CHUNK_MIN, Math.min(HISTORIAN_CHUNK_MAX, derived));
|
|
715
720
|
}
|
|
716
|
-
function
|
|
721
|
+
function resolveHistorianContextLimit2(historianModelOverride) {
|
|
717
722
|
if (typeof historianModelOverride === "string" && historianModelOverride.includes("/")) {
|
|
718
723
|
const [providerID, ...rest] = historianModelOverride.split("/");
|
|
719
724
|
const modelID = rest.join("/");
|
|
@@ -730,4 +735,4 @@ function resolveHistorianContextLimit(historianModelOverride) {
|
|
|
730
735
|
return DEFAULT_HISTORIAN_CONTEXT_FALLBACK;
|
|
731
736
|
}
|
|
732
737
|
|
|
733
|
-
export { setStoragePrivatePermissionEnforcement, shouldEnforcePrivateStoragePermissions, setWindowOverlayPath, formatWindowDerivationLine, isSaneLimit, setOutputReserveConfig, refreshModelLimitsFromApi, refreshModelLimitsAfterAuthOnce, getSdkWindowGeometry, getSdkContextLimit, modelSupportsVision,
|
|
738
|
+
export { setStoragePrivatePermissionEnforcement, shouldEnforcePrivateStoragePermissions, setWindowOverlayPath, reloadWindowOverlay, formatWindowDerivationLine, isSaneLimit, setOutputReserveConfig, refreshModelLimitsFromApi, refreshModelLimitsAfterAuthOnce, getSdkWindowGeometry, getSdkContextLimit, modelSupportsVision, deriveTriggerBudget2, deriveHistorianChunkTokens2, resolveHistorianContextLimit2 };
|
|
@@ -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 };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var queue = [];
|
|
3
3
|
var nextNotificationId = 1;
|
|
4
4
|
var sinks = new Set;
|
|
5
|
-
function
|
|
5
|
+
function registerNotificationSink2(sink) {
|
|
6
6
|
sinks.add(sink);
|
|
7
7
|
return () => {
|
|
8
8
|
sinks.delete(sink);
|
|
@@ -15,7 +15,7 @@ function notificationMatchesSink(notification, sink) {
|
|
|
15
15
|
return notification.sessionId === sink.sessionId;
|
|
16
16
|
return sink.protocol !== 2;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function pushNotification2(type, payload, sessionId) {
|
|
19
19
|
const notification = { id: nextNotificationId++, type, payload, sessionId };
|
|
20
20
|
queue.push(notification);
|
|
21
21
|
for (const sink of sinks) {
|
|
@@ -40,21 +40,16 @@ function pushNotification(type, payload, sessionId) {
|
|
|
40
40
|
queue.splice(evictionIndex >= 0 ? evictionIndex : 0, 1);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function acknowledgeNotifications2(ids) {
|
|
44
44
|
const acknowledged = new Set(ids.filter((id) => Number.isSafeInteger(id) && id > 0));
|
|
45
45
|
if (acknowledged.size === 0)
|
|
46
46
|
return;
|
|
47
47
|
queue = queue.filter((notification) => !acknowledged.has(notification.id));
|
|
48
48
|
}
|
|
49
|
-
function __resetNotificationStateForTests() {
|
|
50
|
-
queue = [];
|
|
51
|
-
nextNotificationId = 1;
|
|
52
|
-
sinks.clear();
|
|
53
|
-
}
|
|
54
49
|
function cursor(value) {
|
|
55
50
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
|
|
56
51
|
}
|
|
57
|
-
function
|
|
52
|
+
function drainNotifications2(lastReceivedId = 0, sessionId, options = {}) {
|
|
58
53
|
const sessionCursor = cursor(lastReceivedId);
|
|
59
54
|
if (options.globalOnly) {
|
|
60
55
|
queue = queue.filter((notification) => notification.sessionId !== undefined || notification.id > sessionCursor);
|
|
@@ -87,7 +82,7 @@ function drainNotifications(lastReceivedId = 0, sessionId, options = {}) {
|
|
|
87
82
|
}
|
|
88
83
|
return queue.filter((notification) => notification.id > sessionCursor && matchesClient(notification));
|
|
89
84
|
}
|
|
90
|
-
function
|
|
85
|
+
function isTuiConnected2(sessionId) {
|
|
91
86
|
if (sinks.size === 0)
|
|
92
87
|
return false;
|
|
93
88
|
if (sessionId === undefined)
|
|
@@ -101,4 +96,4 @@ function isTuiConnected(sessionId) {
|
|
|
101
96
|
return false;
|
|
102
97
|
}
|
|
103
98
|
|
|
104
|
-
export {
|
|
99
|
+
export { registerNotificationSink2, pushNotification2, acknowledgeNotifications2, drainNotifications2, isTuiConnected2 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./index-
|
|
2
|
+
resolveDreamerTaskModel2
|
|
3
|
+
} from "./index-7k55qm8a.js";
|
|
4
4
|
|
|
5
5
|
// src/features/magic-context/dreamer/task-registry.ts
|
|
6
6
|
var CANONICAL_DREAM_TASKS = [
|
|
@@ -68,9 +68,9 @@ function compareTaskOrder(a, b) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
// src/features/magic-context/dreamer/task-config.ts
|
|
71
|
-
function
|
|
71
|
+
function buildDreamTaskRuntimeConfigs2(dreamer, harness, language, muralModel) {
|
|
72
72
|
return CANONICAL_DREAM_TASKS.map((task) => {
|
|
73
|
-
const resolved =
|
|
73
|
+
const resolved = resolveDreamerTaskModel2({
|
|
74
74
|
config: { dreamer },
|
|
75
75
|
harness,
|
|
76
76
|
task,
|
|
@@ -88,27 +88,8 @@ function buildDreamTaskRuntimeConfigs(dreamer, harness, language, muralModel) {
|
|
|
88
88
|
};
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function userMemoryCollectionEnabled2(dreamer) {
|
|
92
92
|
const schedule = dreamer?.tasks?.["review-user-memories"]?.schedule;
|
|
93
93
|
return typeof schedule === "string" && schedule.trim() !== "";
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
return dreamer?.tasks?.["review-user-memories"]?.promotion_threshold ?? 3;
|
|
97
|
-
}
|
|
98
|
-
function dreamTaskScheduled(dreamer, task) {
|
|
99
|
-
const schedule = dreamer?.tasks?.[task]?.schedule;
|
|
100
|
-
return typeof schedule === "string" && schedule.trim() !== "";
|
|
101
|
-
}
|
|
102
|
-
function enabledDreamTasks(dreamer) {
|
|
103
|
-
if (!dreamer?.tasks)
|
|
104
|
-
return [];
|
|
105
|
-
return CANONICAL_DREAM_TASKS.filter((t) => dreamer.tasks[t]?.schedule?.trim());
|
|
106
|
-
}
|
|
107
|
-
function summarizeDreamSchedule(dreamer) {
|
|
108
|
-
const enabled = enabledDreamTasks(dreamer);
|
|
109
|
-
if (enabled.length === 0)
|
|
110
|
-
return "manual-only";
|
|
111
|
-
return enabled.map((t) => `${t} ${dreamer?.tasks[t]?.schedule}`).join(", ");
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export { CANONICAL_DREAM_TASKS, formatDreamTaskBacklogs, processedDreamTaskItems, leaseKindFor, leaseKeyFor, isCanonicalDreamTask, compareTaskOrder, buildDreamTaskRuntimeConfigs, userMemoryCollectionEnabled, userMemoryPromotionThreshold, dreamTaskScheduled, enabledDreamTasks, summarizeDreamSchedule };
|
|
95
|
+
export { CANONICAL_DREAM_TASKS, formatDreamTaskBacklogs, processedDreamTaskItems, leaseKindFor, leaseKeyFor, isCanonicalDreamTask, compareTaskOrder, buildDreamTaskRuntimeConfigs2, userMemoryCollectionEnabled2 };
|
|
@@ -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-jfpk81yt.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 };
|