@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
|
@@ -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,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-avwt563y.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";
|
|
@@ -554,7 +554,7 @@ function setCachedModelMetadata(cache, key, model) {
|
|
|
554
554
|
if (rawLimit === undefined)
|
|
555
555
|
return;
|
|
556
556
|
const values = [model?.capabilities, model?.modalities, model?.input, model?.attachment];
|
|
557
|
-
const vision = values.some((
|
|
557
|
+
const vision = values.some((value) => JSON.stringify(value ?? "").toLowerCase().includes("image") || JSON.stringify(value ?? "").toLowerCase().includes("vision"));
|
|
558
558
|
const value = {
|
|
559
559
|
limit: rawLimit,
|
|
560
560
|
contextLimit: isSaneLimit(contextLimit) ? contextLimit : undefined,
|
|
@@ -702,7 +702,7 @@ var HISTORIAN_CHUNK_PERCENTAGE = 0.25;
|
|
|
702
702
|
var HISTORIAN_CHUNK_MIN = 8000;
|
|
703
703
|
var HISTORIAN_CHUNK_MAX = 50000;
|
|
704
704
|
var DEFAULT_HISTORIAN_CONTEXT_FALLBACK = 128000;
|
|
705
|
-
function
|
|
705
|
+
function deriveTriggerBudget2(mainContextLimit, executeThresholdPercentage) {
|
|
706
706
|
if (!Number.isFinite(mainContextLimit) || mainContextLimit <= 0) {
|
|
707
707
|
return TRIGGER_BUDGET_MIN;
|
|
708
708
|
}
|
|
@@ -711,23 +711,27 @@ function deriveTriggerBudget(mainContextLimit, executeThresholdPercentage) {
|
|
|
711
711
|
const derived = Math.round(usable * TRIGGER_BUDGET_PERCENTAGE);
|
|
712
712
|
return Math.max(TRIGGER_BUDGET_MIN, Math.min(TRIGGER_BUDGET_MAX, derived));
|
|
713
713
|
}
|
|
714
|
-
function
|
|
714
|
+
function deriveHistorianChunkTokens2(historianContextLimit) {
|
|
715
715
|
if (!Number.isFinite(historianContextLimit) || historianContextLimit <= 0) {
|
|
716
716
|
return HISTORIAN_CHUNK_MIN;
|
|
717
717
|
}
|
|
718
718
|
const derived = Math.round(historianContextLimit * HISTORIAN_CHUNK_PERCENTAGE);
|
|
719
719
|
return Math.max(HISTORIAN_CHUNK_MIN, Math.min(HISTORIAN_CHUNK_MAX, derived));
|
|
720
720
|
}
|
|
721
|
-
function
|
|
721
|
+
function resolveKnownHistorianContextLimit2(historianModelOverride) {
|
|
722
|
+
if (typeof historianModelOverride !== "string" || !historianModelOverride.includes("/")) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
const [providerID, ...rest] = historianModelOverride.split("/");
|
|
726
|
+
const modelID = rest.join("/");
|
|
727
|
+
if (!providerID || !modelID)
|
|
728
|
+
return;
|
|
729
|
+
const limit = getSdkContextLimit(providerID, modelID, undefined, { reservation: "none" });
|
|
730
|
+
return typeof limit === "number" && limit > 0 ? limit : undefined;
|
|
731
|
+
}
|
|
732
|
+
function resolveHistorianContextLimit2(historianModelOverride) {
|
|
722
733
|
if (typeof historianModelOverride === "string" && historianModelOverride.includes("/")) {
|
|
723
|
-
|
|
724
|
-
const modelID = rest.join("/");
|
|
725
|
-
if (providerID && modelID) {
|
|
726
|
-
const limit = getSdkContextLimit(providerID, modelID);
|
|
727
|
-
if (typeof limit === "number" && limit > 0)
|
|
728
|
-
return limit;
|
|
729
|
-
}
|
|
730
|
-
return DEFAULT_HISTORIAN_CONTEXT_FALLBACK;
|
|
734
|
+
return resolveKnownHistorianContextLimit2(historianModelOverride) ?? DEFAULT_HISTORIAN_CONTEXT_FALLBACK;
|
|
731
735
|
}
|
|
732
736
|
if (typeof historianModelOverride === "string" && historianModelOverride.trim() !== "") {
|
|
733
737
|
console.warn(`[magic-context] historian.model "${historianModelOverride}" lacks provider prefix ("provider/model-id"); using the default context limit for chunk-budget derivation.`);
|
|
@@ -735,4 +739,4 @@ function resolveHistorianContextLimit(historianModelOverride) {
|
|
|
735
739
|
return DEFAULT_HISTORIAN_CONTEXT_FALLBACK;
|
|
736
740
|
}
|
|
737
741
|
|
|
738
|
-
export { setStoragePrivatePermissionEnforcement, shouldEnforcePrivateStoragePermissions, setWindowOverlayPath, reloadWindowOverlay, formatWindowDerivationLine, isSaneLimit, setOutputReserveConfig, refreshModelLimitsFromApi, refreshModelLimitsAfterAuthOnce, getSdkWindowGeometry, getSdkContextLimit, modelSupportsVision,
|
|
742
|
+
export { setStoragePrivatePermissionEnforcement, shouldEnforcePrivateStoragePermissions, setWindowOverlayPath, reloadWindowOverlay, formatWindowDerivationLine, isSaneLimit, setOutputReserveConfig, refreshModelLimitsFromApi, refreshModelLimitsAfterAuthOnce, getSdkWindowGeometry, getSdkContextLimit, modelSupportsVision, deriveTriggerBudget2, deriveHistorianChunkTokens2, resolveKnownHistorianContextLimit2, resolveHistorianContextLimit2 };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isMidTurn
|
|
3
|
-
} from "./index-b9j85d29.js";
|
|
4
1
|
import {
|
|
5
2
|
sessionLog
|
|
6
|
-
} from "./index-
|
|
3
|
+
} from "./index-dkv2dn46.js";
|
|
7
4
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./index-
|
|
5
|
+
shouldHoldIgnoredNotification
|
|
6
|
+
} from "./index-raatkvw5.js";
|
|
10
7
|
|
|
11
8
|
// src/shared/error-message.ts
|
|
12
9
|
function getErrorMessage(error) {
|
|
@@ -88,7 +85,14 @@ function safeString(value) {
|
|
|
88
85
|
var MAX_QUEUED_IGNORED_NOTIFICATIONS = 16;
|
|
89
86
|
var queuedIgnoredNotifications = new Map;
|
|
90
87
|
var flushingIgnoredNotifications = new Set;
|
|
91
|
-
var midTurnDetector = (sessionId) =>
|
|
88
|
+
var midTurnDetector = (sessionId) => shouldHoldIgnoredNotification(sessionId);
|
|
89
|
+
var notificationServerUrl;
|
|
90
|
+
var noticeDeleter;
|
|
91
|
+
var notificationDiagnosticObserverForTests;
|
|
92
|
+
function notificationDiagnostic(sessionId, message) {
|
|
93
|
+
notificationDiagnosticObserverForTests?.(message);
|
|
94
|
+
sessionLog(sessionId, message);
|
|
95
|
+
}
|
|
92
96
|
function queueIgnoredNotification(notification) {
|
|
93
97
|
const queued = queuedIgnoredNotifications.get(notification.sessionId) ?? [];
|
|
94
98
|
queued.push(notification);
|
|
@@ -98,6 +102,10 @@ function queueIgnoredNotification(notification) {
|
|
|
98
102
|
}
|
|
99
103
|
queuedIgnoredNotifications.set(notification.sessionId, queued);
|
|
100
104
|
}
|
|
105
|
+
function holdIgnoredNotification(notification, checkpoint) {
|
|
106
|
+
queueIgnoredNotification(notification);
|
|
107
|
+
notificationDiagnostic(notification.sessionId, `ignored notification held ${checkpoint} (session active); queued`);
|
|
108
|
+
}
|
|
101
109
|
async function trySendTuiToast(sessionId, text, params, forcePersist) {
|
|
102
110
|
if (forcePersist)
|
|
103
111
|
return false;
|
|
@@ -105,11 +113,11 @@ async function trySendTuiToast(sessionId, text, params, forcePersist) {
|
|
|
105
113
|
const message = text.length > 200 ? `${text.slice(0, 200)}…` : text;
|
|
106
114
|
const toastVariant = inferToastVariant(text);
|
|
107
115
|
const duration = params.toastDurationMs ?? 5000;
|
|
108
|
-
const { isTuiConnected: checkTui } = await import("./rpc-notifications-
|
|
116
|
+
const { isTuiConnected: checkTui } = await import("./rpc-notifications-4amf6mf4.js");
|
|
109
117
|
if (!checkTui(sessionId))
|
|
110
118
|
return false;
|
|
111
119
|
try {
|
|
112
|
-
const { pushNotification } = await import("./rpc-notifications-
|
|
120
|
+
const { pushNotification } = await import("./rpc-notifications-4amf6mf4.js");
|
|
113
121
|
pushNotification("toast", {
|
|
114
122
|
title,
|
|
115
123
|
message,
|
|
@@ -122,19 +130,16 @@ async function trySendTuiToast(sessionId, text, params, forcePersist) {
|
|
|
122
130
|
return false;
|
|
123
131
|
}
|
|
124
132
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
},
|
|
134
|
-
setMidTurnDetector(detector) {
|
|
135
|
-
midTurnDetector = detector;
|
|
133
|
+
function setNotificationServerUrl2(url) {
|
|
134
|
+
notificationServerUrl = typeof url === "string" && url.length > 0 ? url.replace(/\/$/, "") : undefined;
|
|
135
|
+
}
|
|
136
|
+
function notifyDelivered(sessionId, params) {
|
|
137
|
+
try {
|
|
138
|
+
params.onDelivered?.();
|
|
139
|
+
} catch (error) {
|
|
140
|
+
sessionLog(sessionId, "notification delivery callback failed:", getErrorMessage(error));
|
|
136
141
|
}
|
|
137
|
-
}
|
|
142
|
+
}
|
|
138
143
|
function hasNotificationSessionClient(client) {
|
|
139
144
|
if (client === null || typeof client !== "object")
|
|
140
145
|
return false;
|
|
@@ -168,16 +173,16 @@ function extractToastTitle(text) {
|
|
|
168
173
|
}
|
|
169
174
|
async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersist) {
|
|
170
175
|
if (midTurnDetector(sessionId)) {
|
|
171
|
-
|
|
176
|
+
holdIgnoredNotification({ client, sessionId, text, params, forcePersist }, "during target checks");
|
|
172
177
|
return "queued";
|
|
173
178
|
}
|
|
174
|
-
const { waitForSafeNotificationTarget } = await import("./safe-notification-target-
|
|
179
|
+
const { waitForSafeNotificationTarget } = await import("./safe-notification-target-q9z81zt3.js");
|
|
175
180
|
if (await waitForSafeNotificationTarget(client, sessionId) === "skip") {
|
|
176
181
|
sessionLog(sessionId, "notification skipped (session not titled yet)");
|
|
177
182
|
return "skipped";
|
|
178
183
|
}
|
|
179
184
|
if (midTurnDetector(sessionId)) {
|
|
180
|
-
|
|
185
|
+
holdIgnoredNotification({ client, sessionId, text, params, forcePersist }, "during target checks");
|
|
181
186
|
return "queued";
|
|
182
187
|
}
|
|
183
188
|
if (!hasNotificationSessionClient(client)) {
|
|
@@ -190,7 +195,7 @@ async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersi
|
|
|
190
195
|
let model = params.providerId && params.modelId ? { providerID: params.providerId, modelID: params.modelId } : undefined;
|
|
191
196
|
if (!agent || !model || !variant) {
|
|
192
197
|
try {
|
|
193
|
-
const { resolvePromptContext } = await import("./prompt-context-
|
|
198
|
+
const { resolvePromptContext } = await import("./prompt-context-5y5ms8f9.js");
|
|
194
199
|
const resolved = await resolvePromptContext(client, sessionId);
|
|
195
200
|
if (resolved) {
|
|
196
201
|
agent = agent ?? resolved.agent;
|
|
@@ -200,7 +205,7 @@ async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersi
|
|
|
200
205
|
} catch {}
|
|
201
206
|
}
|
|
202
207
|
if (midTurnDetector(sessionId)) {
|
|
203
|
-
|
|
208
|
+
holdIgnoredNotification({ client, sessionId, text, params, forcePersist }, "before append");
|
|
204
209
|
return "queued";
|
|
205
210
|
}
|
|
206
211
|
const input = {
|
|
@@ -220,32 +225,108 @@ async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersi
|
|
|
220
225
|
}
|
|
221
226
|
};
|
|
222
227
|
try {
|
|
228
|
+
let result;
|
|
223
229
|
if (typeof c.session?.prompt === "function") {
|
|
224
|
-
await Promise.resolve(c.session.prompt(input));
|
|
225
|
-
|
|
230
|
+
result = await Promise.resolve(c.session.prompt(input));
|
|
231
|
+
} else if (typeof c.session?.promptAsync === "function") {
|
|
232
|
+
result = await c.session.promptAsync(input);
|
|
233
|
+
} else {
|
|
234
|
+
sessionLog(sessionId, "session prompt API unavailable for notification");
|
|
235
|
+
return "failed";
|
|
226
236
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
237
|
+
const messageId = extractPromptedMessageId(result);
|
|
238
|
+
if (await revertNoticeIfUnsafe({
|
|
239
|
+
client,
|
|
240
|
+
sessionId,
|
|
241
|
+
text,
|
|
242
|
+
params,
|
|
243
|
+
forcePersist,
|
|
244
|
+
messageId
|
|
245
|
+
})) {
|
|
246
|
+
return "queued";
|
|
230
247
|
}
|
|
231
|
-
|
|
232
|
-
return "
|
|
248
|
+
notifyDelivered(sessionId, params);
|
|
249
|
+
return "sent";
|
|
233
250
|
} catch (error) {
|
|
234
251
|
const msg = getErrorMessage(error);
|
|
235
252
|
sessionLog(sessionId, "failed to send notification:", msg);
|
|
236
253
|
return "failed";
|
|
237
254
|
}
|
|
238
255
|
}
|
|
239
|
-
|
|
240
|
-
if (
|
|
256
|
+
function extractPromptedMessageId(result) {
|
|
257
|
+
if (result === null || typeof result !== "object")
|
|
258
|
+
return;
|
|
259
|
+
const root = result;
|
|
260
|
+
const data = root.data !== null && typeof root.data === "object" ? root.data : root;
|
|
261
|
+
const info = data.info !== null && typeof data.info === "object" ? data.info : data;
|
|
262
|
+
return typeof info.id === "string" && info.id.length > 0 ? info.id : undefined;
|
|
263
|
+
}
|
|
264
|
+
function getServerAuth() {
|
|
265
|
+
const password = process.env.OPENCODE_SERVER_PASSWORD;
|
|
266
|
+
if (!password)
|
|
267
|
+
return;
|
|
268
|
+
const username = process.env.OPENCODE_SERVER_USERNAME ?? "opencode";
|
|
269
|
+
return `Basic ${Buffer.from(`${username}:${password}`, "utf8").toString("base64")}`;
|
|
270
|
+
}
|
|
271
|
+
async function deleteNoticeMessage(sessionId, messageId) {
|
|
272
|
+
if (noticeDeleter)
|
|
273
|
+
return noticeDeleter(sessionId, messageId);
|
|
274
|
+
if (!notificationServerUrl) {
|
|
275
|
+
sessionLog(sessionId, "cannot roll back notice: no server URL for session.message.delete");
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
const url = `${notificationServerUrl}/session/${encodeURIComponent(sessionId)}/message/${encodeURIComponent(messageId)}`;
|
|
279
|
+
try {
|
|
280
|
+
const auth = getServerAuth();
|
|
281
|
+
const response = await fetch(url, {
|
|
282
|
+
method: "DELETE",
|
|
283
|
+
headers: auth ? { Authorization: auth } : {},
|
|
284
|
+
signal: AbortSignal.timeout(1e4)
|
|
285
|
+
});
|
|
286
|
+
if (!response.ok) {
|
|
287
|
+
sessionLog(sessionId, `notice rollback DELETE failed status=${response.status} url=${url}`);
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
return true;
|
|
291
|
+
} catch (error) {
|
|
292
|
+
sessionLog(sessionId, "notice rollback DELETE error:", getErrorMessage(error));
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
async function revertNoticeIfUnsafe(notification) {
|
|
297
|
+
if (!midTurnDetector(notification.sessionId))
|
|
298
|
+
return false;
|
|
299
|
+
if (notification.messageId) {
|
|
300
|
+
const deleted = await deleteNoticeMessage(notification.sessionId, notification.messageId);
|
|
301
|
+
if (deleted) {
|
|
302
|
+
notificationDiagnostic(notification.sessionId, `notice rolled back (deleted row ${notification.messageId}); queued for idle delivery`);
|
|
303
|
+
} else {
|
|
304
|
+
sessionLog(notification.sessionId, "failed to roll back a notice that landed while a run was active");
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
sessionLog(notification.sessionId, "notice landed while a run was active but the new row id was not returned");
|
|
308
|
+
}
|
|
309
|
+
queueIgnoredNotification({
|
|
310
|
+
client: notification.client,
|
|
311
|
+
sessionId: notification.sessionId,
|
|
312
|
+
text: notification.text,
|
|
313
|
+
params: notification.params,
|
|
314
|
+
forcePersist: notification.forcePersist
|
|
315
|
+
});
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
async function sendIgnoredMessage2(client, sessionId, text, params, forcePersist = false) {
|
|
319
|
+
if (await trySendTuiToast(sessionId, text, params, forcePersist)) {
|
|
320
|
+
notifyDelivered(sessionId, params);
|
|
241
321
|
return "sent";
|
|
322
|
+
}
|
|
242
323
|
if (midTurnDetector(sessionId)) {
|
|
243
|
-
|
|
324
|
+
holdIgnoredNotification({ client, sessionId, text, params, forcePersist }, "before target checks");
|
|
244
325
|
return "queued";
|
|
245
326
|
}
|
|
246
327
|
return sendIgnoredMessageNow(client, sessionId, text, params, forcePersist);
|
|
247
328
|
}
|
|
248
|
-
async function
|
|
329
|
+
async function flushIgnoredMessages2(sessionId) {
|
|
249
330
|
if (flushingIgnoredNotifications.has(sessionId) || midTurnDetector(sessionId))
|
|
250
331
|
return;
|
|
251
332
|
const queued = queuedIgnoredNotifications.get(sessionId);
|
|
@@ -255,7 +336,7 @@ async function flushIgnoredMessages(sessionId) {
|
|
|
255
336
|
flushingIgnoredNotifications.add(sessionId);
|
|
256
337
|
try {
|
|
257
338
|
for (const notification of queued) {
|
|
258
|
-
const disposition = await
|
|
339
|
+
const disposition = await sendIgnoredMessage2(notification.client, notification.sessionId, notification.text, notification.params, notification.forcePersist);
|
|
259
340
|
if (disposition === "queued") {
|
|
260
341
|
for (const remaining of queued.slice(queued.indexOf(notification) + 1)) {
|
|
261
342
|
queueIgnoredNotification(remaining);
|
|
@@ -267,11 +348,11 @@ async function flushIgnoredMessages(sessionId) {
|
|
|
267
348
|
flushingIgnoredNotifications.delete(sessionId);
|
|
268
349
|
}
|
|
269
350
|
}
|
|
270
|
-
function
|
|
351
|
+
function clearIgnoredMessages2(sessionId) {
|
|
271
352
|
queuedIgnoredNotifications.delete(sessionId);
|
|
272
353
|
flushingIgnoredNotifications.delete(sessionId);
|
|
273
354
|
}
|
|
274
|
-
async function
|
|
355
|
+
async function sendUserPrompt2(client, sessionId, text) {
|
|
275
356
|
if (!hasNotificationSessionClient(client)) {
|
|
276
357
|
sessionLog(sessionId, "session prompt API unavailable for user prompt");
|
|
277
358
|
return;
|
|
@@ -297,4 +378,4 @@ async function sendUserPrompt(client, sessionId, text) {
|
|
|
297
378
|
}
|
|
298
379
|
}
|
|
299
380
|
|
|
300
|
-
export { getErrorMessage, describeError,
|
|
381
|
+
export { getErrorMessage, describeError, setNotificationServerUrl2, sendIgnoredMessage2, flushIgnoredMessages2, clearIgnoredMessages2, sendUserPrompt2 };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
log
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-dkv2dn46.js";
|
|
4
4
|
import {
|
|
5
5
|
getDataDir
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-3fe78beq.js";
|
|
7
7
|
|
|
8
8
|
// src/shared/sqlite-helpers.ts
|
|
9
9
|
function closeQuietly(db) {
|
|
@@ -223,15 +223,29 @@ function isMidTurn(_deps, sessionId) {
|
|
|
223
223
|
return false;
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
|
+
function shouldHoldIgnoredNotificationFromOpenCodeDb(db, sessionId) {
|
|
227
|
+
if (isMidTurnFromOpenCodeDb(db, sessionId))
|
|
228
|
+
return true;
|
|
229
|
+
if (hasUnfinishedAssistant(db, sessionId))
|
|
230
|
+
return true;
|
|
231
|
+
if (hasUnansweredRealUser(db, sessionId))
|
|
232
|
+
return true;
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
function shouldHoldIgnoredNotification(sessionId) {
|
|
236
|
+
if (process.env.MAGIC_CONTEXT_NOTICE_GATE === "bypass")
|
|
237
|
+
return false;
|
|
238
|
+
if (process.env.MAGIC_CONTEXT_NOTICE_GATE === "hold")
|
|
239
|
+
return true;
|
|
240
|
+
try {
|
|
241
|
+
return withReadOnlySessionDb((db) => shouldHoldIgnoredNotificationFromOpenCodeDb(db, sessionId));
|
|
242
|
+
} catch (error) {
|
|
243
|
+
log("[magic-context] failed to inspect notice-hold state:", error);
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
226
247
|
function isMidTurnFromOpenCodeDb(db, sessionId) {
|
|
227
|
-
const latestAssistant = db
|
|
228
|
-
json_extract(data, '$.finish') as finish,
|
|
229
|
-
time_created as timeCreated
|
|
230
|
-
FROM message
|
|
231
|
-
WHERE session_id = ?
|
|
232
|
-
AND json_extract(data, '$.role') = 'assistant'
|
|
233
|
-
ORDER BY time_created DESC
|
|
234
|
-
LIMIT 1`).get(sessionId);
|
|
248
|
+
const latestAssistant = latestAssistantRow(db, sessionId);
|
|
235
249
|
if (typeof latestAssistant?.id !== "string")
|
|
236
250
|
return false;
|
|
237
251
|
if (hasNewerRealUserMessage(db, sessionId, latestAssistant.timeCreated))
|
|
@@ -271,6 +285,30 @@ function hasNewerRealUserMessage(db, sessionId, latestAssistantTimeCreated) {
|
|
|
271
285
|
LIMIT 1`).get(sessionId, latestAssistantTimeCreated);
|
|
272
286
|
return row?.one === 1;
|
|
273
287
|
}
|
|
288
|
+
function latestAssistantRow(db, sessionId) {
|
|
289
|
+
return db.prepare(`SELECT id,
|
|
290
|
+
json_extract(data, '$.finish') as finish,
|
|
291
|
+
time_created as timeCreated
|
|
292
|
+
FROM message
|
|
293
|
+
WHERE session_id = ?
|
|
294
|
+
AND json_extract(data, '$.role') = 'assistant'
|
|
295
|
+
ORDER BY time_created DESC
|
|
296
|
+
LIMIT 1`).get(sessionId);
|
|
297
|
+
}
|
|
298
|
+
function hasUnfinishedAssistant(db, sessionId) {
|
|
299
|
+
const latestAssistant = latestAssistantRow(db, sessionId);
|
|
300
|
+
if (typeof latestAssistant?.id !== "string")
|
|
301
|
+
return false;
|
|
302
|
+
const finish = latestAssistant.finish;
|
|
303
|
+
if (typeof finish !== "string" || finish.length === 0)
|
|
304
|
+
return true;
|
|
305
|
+
return finish === "tool-calls" || finish === "unknown";
|
|
306
|
+
}
|
|
307
|
+
function hasUnansweredRealUser(db, sessionId) {
|
|
308
|
+
const latestAssistant = latestAssistantRow(db, sessionId);
|
|
309
|
+
const latestAssistantTime = typeof latestAssistant?.timeCreated === "number" ? latestAssistant.timeCreated : -1;
|
|
310
|
+
return hasNewerRealUserMessage(db, sessionId, latestAssistantTime);
|
|
311
|
+
}
|
|
274
312
|
function getMessageTimesFromOpenCodeDb(sessionId, messageIds) {
|
|
275
313
|
const result = new Map;
|
|
276
314
|
if (messageIds.length === 0)
|
|
@@ -319,4 +357,4 @@ function findLastAssistantModelFromOpenCodeDb(sessionId) {
|
|
|
319
357
|
}
|
|
320
358
|
}
|
|
321
359
|
|
|
322
|
-
export { Database, withPrivilegedWriter, closeQuietly, openCodeDbExists, withReadOnlySessionDb, getRawSessionMessageCountFromDb, isMidTurn, getMessageTimesFromOpenCodeDb, findLastAssistantModelFromOpenCodeDb };
|
|
360
|
+
export { detectSqliteRuntime, Database, withPrivilegedWriter, closeQuietly, openCodeDbExists, withReadOnlySessionDb, getRawSessionMessageCountFromDb, isMidTurn, shouldHoldIgnoredNotification, getMessageTimesFromOpenCodeDb, findLastAssistantModelFromOpenCodeDb };
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
// ../../node_modules/.bun/@jitl+quickjs-ffi-types@0.32.0/node_modules/@jitl/quickjs-ffi-types/dist/index.mjs
|
|
2
|
-
function assertSync(fn) {
|
|
3
|
-
return function(...args) {
|
|
4
|
-
let result = fn(...args);
|
|
5
|
-
if (result && typeof result == "object" && result instanceof Promise)
|
|
6
|
-
throw new Error("Function unexpectedly returned a Promise");
|
|
7
|
-
return result;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
2
|
var EvalFlags = { JS_EVAL_TYPE_GLOBAL: 0, JS_EVAL_TYPE_MODULE: 1, JS_EVAL_TYPE_DIRECT: 2, JS_EVAL_TYPE_INDIRECT: 3, JS_EVAL_TYPE_MASK: 3, JS_EVAL_FLAG_STRICT: 8, JS_EVAL_FLAG_STRIP: 16, JS_EVAL_FLAG_COMPILE_ONLY: 32, JS_EVAL_FLAG_BACKTRACE_BARRIER: 64 };
|
|
11
3
|
var IntrinsicsFlags = { BaseObjects: 1, Date: 2, Eval: 4, StringNormalize: 8, RegExp: 16, RegExpCompiler: 32, JSON: 64, Proxy: 128, MapSet: 256, TypedArrays: 512, Promise: 1024, BigInt: 2048, BigFloat: 4096, BigDecimal: 8192, OperatorOverloading: 16384, BignumExt: 32768 };
|
|
12
4
|
var JSPromiseStateEnum = { Pending: 0, Fulfilled: 1, Rejected: 2 };
|
|
13
5
|
var GetOwnPropertyNamesFlags = { JS_GPN_STRING_MASK: 1, JS_GPN_SYMBOL_MASK: 2, JS_GPN_PRIVATE_MASK: 4, JS_GPN_ENUM_ONLY: 16, JS_GPN_SET_ENUM: 32, QTS_GPN_NUMBER_MASK: 64, QTS_STANDARD_COMPLIANT_NUMBER: 128 };
|
|
14
6
|
var IsEqualOp = { IsStrictlyEqual: 0, IsSameValue: 1, IsSameValueZero: 2 };
|
|
15
7
|
|
|
16
|
-
export {
|
|
8
|
+
export { EvalFlags, IntrinsicsFlags, JSPromiseStateEnum, GetOwnPropertyNamesFlags, IsEqualOp };
|