@cortexkit/pi-magic-context 0.38.0 → 0.38.1
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/dist/{emscripten-module-ap8t3st0.js → emscripten-module-49k43zfy.js} +1 -1
- package/dist/{emscripten-module-682pfzaa.js → emscripten-module-ex4v0x4z.js} +1 -1
- package/dist/{emscripten-module-r5h7aghp.js → emscripten-module-jfs3d1dq.js} +1 -1
- package/dist/{emscripten-module-bkktz927.js → emscripten-module-ss4g4spn.js} +1 -1
- package/dist/{ffi-d8pnn3mn.js → ffi-bbm9vkfa.js} +1 -1
- package/dist/{ffi-04jzypzk.js → ffi-kb5r0x1j.js} +1 -1
- package/dist/{ffi-t8b862vx.js → ffi-qnrt0y78.js} +1 -1
- package/dist/{ffi-9wvt2wwz.js → ffi-yx2hpf4p.js} +1 -1
- package/dist/{index-wckvcay0.js → index-1yh8g550.js} +8 -6
- package/dist/{index-6hs6yh6r.js → index-8e0zezh7.js} +1689 -2500
- package/dist/{index-3pnd4qh9.js → index-8sseka65.js} +50 -50
- package/dist/{index-ayd60xnw.js → index-rgdqj8nj.js} +3 -3
- package/dist/index.js +98 -37
- package/dist/{module-ES6BEMUI-atfbtnbp.js → module-ES6BEMUI-1yjdz59c.js} +4 -4
- package/dist/{module-asyncify-2EFITU5U-7xckhw8w.js → module-asyncify-2EFITU5U-fdkx4fhy.js} +1 -1
- package/dist/{prompt-context-602yq94t.js → prompt-context-3kjq9ejq.js} +1 -1
- package/dist/{rpc-notifications-s2rw51c6.js → rpc-notifications-gmhvmfpy.js} +6 -6
- package/dist/{safe-notification-target-7n7s6xv7.js → safe-notification-target-q00qgjm6.js} +3 -3
- package/dist/subagent-entry.js +2 -2
- package/package.json +1 -1
|
@@ -34,17 +34,17 @@ import {
|
|
|
34
34
|
} from "./index-9xexf8s7.js";
|
|
35
35
|
import {
|
|
36
36
|
__require
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-1yh8g550.js";
|
|
38
38
|
|
|
39
39
|
// ../../node_modules/.bun/quickjs-emscripten-core@0.32.0/node_modules/quickjs-emscripten-core/dist/index.mjs
|
|
40
40
|
async function newQuickJSWASMModuleFromVariant(variantOrPromise) {
|
|
41
|
-
let variant = smartUnwrap(await variantOrPromise), [wasmModuleLoader, QuickJSFFI, { QuickJSWASMModule: QuickJSWASMModule2 }] = await Promise.all([variant.importModuleLoader().then(smartUnwrap), variant.importFFI(), import("./module-ES6BEMUI-
|
|
41
|
+
let variant = smartUnwrap(await variantOrPromise), [wasmModuleLoader, QuickJSFFI, { QuickJSWASMModule: QuickJSWASMModule2 }] = await Promise.all([variant.importModuleLoader().then(smartUnwrap), variant.importFFI(), import("./module-ES6BEMUI-1yjdz59c.js").then(smartUnwrap)]), wasmModule = await wasmModuleLoader();
|
|
42
42
|
wasmModule.type = "sync";
|
|
43
43
|
let ffi = new QuickJSFFI(wasmModule);
|
|
44
44
|
return new QuickJSWASMModule2(wasmModule, ffi);
|
|
45
45
|
}
|
|
46
46
|
async function newQuickJSAsyncWASMModuleFromVariant(variantOrPromise) {
|
|
47
|
-
let variant = smartUnwrap(await variantOrPromise), [wasmModuleLoader, QuickJSAsyncFFI, { QuickJSAsyncWASMModule: QuickJSAsyncWASMModule2 }] = await Promise.all([variant.importModuleLoader().then(smartUnwrap), variant.importFFI(), import("./module-asyncify-2EFITU5U-
|
|
47
|
+
let variant = smartUnwrap(await variantOrPromise), [wasmModuleLoader, QuickJSAsyncFFI, { QuickJSAsyncWASMModule: QuickJSAsyncWASMModule2 }] = await Promise.all([variant.importModuleLoader().then(smartUnwrap), variant.importFFI(), import("./module-asyncify-2EFITU5U-fdkx4fhy.js").then(smartUnwrap)]), wasmModule = await wasmModuleLoader();
|
|
48
48
|
wasmModule.type = "async";
|
|
49
49
|
let ffi = new QuickJSAsyncFFI(wasmModule);
|
|
50
50
|
return new QuickJSAsyncWASMModule2(wasmModule, ffi);
|
|
@@ -163,19 +163,19 @@ var TestQuickJSWASMModule = class {
|
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
// ../../node_modules/.bun/@jitl+quickjs-wasmfile-debug-sync@0.32.0/node_modules/@jitl/quickjs-wasmfile-debug-sync/dist/index.mjs
|
|
166
|
-
var variant = { type: "sync", importFFI: () => import("./ffi-
|
|
166
|
+
var variant = { type: "sync", importFFI: () => import("./ffi-yx2hpf4p.js").then((mod) => mod.QuickJSFFI), importModuleLoader: () => import("./emscripten-module-ss4g4spn.js").then((mod) => mod.default) };
|
|
167
167
|
var src_default = variant;
|
|
168
168
|
|
|
169
169
|
// ../../node_modules/.bun/@jitl+quickjs-wasmfile-release-sync@0.32.0/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.mjs
|
|
170
|
-
var variant2 = { type: "sync", importFFI: () => import("./ffi-
|
|
170
|
+
var variant2 = { type: "sync", importFFI: () => import("./ffi-qnrt0y78.js").then((mod) => mod.QuickJSFFI), importModuleLoader: () => import("./emscripten-module-49k43zfy.js").then((mod) => mod.default) };
|
|
171
171
|
var src_default2 = variant2;
|
|
172
172
|
|
|
173
173
|
// ../../node_modules/.bun/@jitl+quickjs-wasmfile-debug-asyncify@0.32.0/node_modules/@jitl/quickjs-wasmfile-debug-asyncify/dist/index.mjs
|
|
174
|
-
var variant3 = { type: "async", importFFI: () => import("./ffi-
|
|
174
|
+
var variant3 = { type: "async", importFFI: () => import("./ffi-bbm9vkfa.js").then((mod) => mod.QuickJSAsyncFFI), importModuleLoader: () => import("./emscripten-module-jfs3d1dq.js").then((mod) => mod.default) };
|
|
175
175
|
var src_default3 = variant3;
|
|
176
176
|
|
|
177
177
|
// ../../node_modules/.bun/@jitl+quickjs-wasmfile-release-asyncify@0.32.0/node_modules/@jitl/quickjs-wasmfile-release-asyncify/dist/index.mjs
|
|
178
|
-
var variant4 = { type: "async", importFFI: () => import("./ffi-
|
|
178
|
+
var variant4 = { type: "async", importFFI: () => import("./ffi-kb5r0x1j.js").then((mod) => mod.QuickJSAsyncFFI), importModuleLoader: () => import("./emscripten-module-ex4v0x4z.js").then((mod) => mod.default) };
|
|
179
179
|
var src_default4 = variant4;
|
|
180
180
|
|
|
181
181
|
// ../../node_modules/.bun/quickjs-emscripten@0.32.0/node_modules/quickjs-emscripten/dist/chunk-OHAYRCBA.mjs
|
|
@@ -204,48 +204,48 @@ async function newAsyncContext(options) {
|
|
|
204
204
|
return (await newQuickJSAsyncWASMModule()).newContext(options);
|
|
205
205
|
}
|
|
206
206
|
export {
|
|
207
|
-
|
|
208
|
-
setDebugMode,
|
|
209
|
-
newVariant,
|
|
210
|
-
newQuickJSWASMModuleFromVariant,
|
|
211
|
-
newQuickJSWASMModule,
|
|
212
|
-
newQuickJSAsyncWASMModuleFromVariant,
|
|
213
|
-
newQuickJSAsyncWASMModule,
|
|
214
|
-
newAsyncRuntime,
|
|
215
|
-
newAsyncContext,
|
|
216
|
-
memoizePromiseFactory,
|
|
217
|
-
isSuccess,
|
|
218
|
-
isFail,
|
|
219
|
-
getQuickJSSync,
|
|
220
|
-
getQuickJS,
|
|
221
|
-
errors_exports as errors,
|
|
222
|
-
debugLog,
|
|
223
|
-
createDisposableArray,
|
|
224
|
-
assertSync,
|
|
225
|
-
WeakLifetime,
|
|
226
|
-
UsingDisposable,
|
|
227
|
-
TestQuickJSWASMModule,
|
|
228
|
-
StaticLifetime,
|
|
229
|
-
Scope,
|
|
230
|
-
src_default2 as RELEASE_SYNC,
|
|
231
|
-
src_default4 as RELEASE_ASYNC,
|
|
232
|
-
QuickJSWASMModule,
|
|
233
|
-
QuickJSRuntime,
|
|
234
|
-
QuickJSDeferredPromise,
|
|
235
|
-
QuickJSContext,
|
|
236
|
-
QuickJSAsyncWASMModule,
|
|
237
|
-
QuickJSAsyncRuntime,
|
|
238
|
-
QuickJSAsyncContext,
|
|
239
|
-
Lifetime,
|
|
240
|
-
JSPromiseStateEnum,
|
|
241
|
-
IsEqualOp,
|
|
242
|
-
IntrinsicsFlags,
|
|
243
|
-
GetOwnPropertyNamesFlags,
|
|
244
|
-
EvalFlags,
|
|
245
|
-
DisposableSuccess,
|
|
246
|
-
DisposableResult,
|
|
247
|
-
DisposableFail,
|
|
248
|
-
DefaultIntrinsics,
|
|
207
|
+
src_default3 as DEBUG_ASYNC,
|
|
249
208
|
src_default as DEBUG_SYNC,
|
|
250
|
-
|
|
209
|
+
DefaultIntrinsics,
|
|
210
|
+
DisposableFail,
|
|
211
|
+
DisposableResult,
|
|
212
|
+
DisposableSuccess,
|
|
213
|
+
EvalFlags,
|
|
214
|
+
GetOwnPropertyNamesFlags,
|
|
215
|
+
IntrinsicsFlags,
|
|
216
|
+
IsEqualOp,
|
|
217
|
+
JSPromiseStateEnum,
|
|
218
|
+
Lifetime,
|
|
219
|
+
QuickJSAsyncContext,
|
|
220
|
+
QuickJSAsyncRuntime,
|
|
221
|
+
QuickJSAsyncWASMModule,
|
|
222
|
+
QuickJSContext,
|
|
223
|
+
QuickJSDeferredPromise,
|
|
224
|
+
QuickJSRuntime,
|
|
225
|
+
QuickJSWASMModule,
|
|
226
|
+
src_default4 as RELEASE_ASYNC,
|
|
227
|
+
src_default2 as RELEASE_SYNC,
|
|
228
|
+
Scope,
|
|
229
|
+
StaticLifetime,
|
|
230
|
+
TestQuickJSWASMModule,
|
|
231
|
+
UsingDisposable,
|
|
232
|
+
WeakLifetime,
|
|
233
|
+
assertSync,
|
|
234
|
+
createDisposableArray,
|
|
235
|
+
debugLog,
|
|
236
|
+
errors_exports as errors,
|
|
237
|
+
getQuickJS,
|
|
238
|
+
getQuickJSSync,
|
|
239
|
+
isFail,
|
|
240
|
+
isSuccess,
|
|
241
|
+
memoizePromiseFactory,
|
|
242
|
+
newAsyncContext,
|
|
243
|
+
newAsyncRuntime,
|
|
244
|
+
newQuickJSAsyncWASMModule,
|
|
245
|
+
newQuickJSAsyncWASMModuleFromVariant,
|
|
246
|
+
newQuickJSWASMModule,
|
|
247
|
+
newQuickJSWASMModuleFromVariant,
|
|
248
|
+
newVariant,
|
|
249
|
+
setDebugMode,
|
|
250
|
+
shouldInterruptAfterDeadline
|
|
251
251
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__commonJS,
|
|
3
3
|
__require
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-1yh8g550.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
|
-
var require_dist = __commonJS((exports, module)
|
|
7
|
+
var require_dist = __commonJS(function(exports, module) {
|
|
8
8
|
var __defProp = Object.defineProperty;
|
|
9
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -39,7 +39,7 @@ var require_dist = __commonJS((exports, module) => {
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
// ../../node_modules/.bun/@jitl+quickjs-singlefile-cjs-release-asyncify@0.32.0/node_modules/@jitl/quickjs-singlefile-cjs-release-asyncify/dist/index.js
|
|
42
|
-
var require_dist2 = __commonJS((exports, module)
|
|
42
|
+
var require_dist2 = __commonJS(function(exports, module) {
|
|
43
43
|
var __filename = "/home/runner/work/magic-context/magic-context/node_modules/.bun/@jitl+quickjs-singlefile-cjs-release-asyncify@0.32.0/node_modules/@jitl/quickjs-singlefile-cjs-release-asyncify/dist/index.js";
|
|
44
44
|
var __create = Object.create;
|
|
45
45
|
var __defProp = Object.defineProperty;
|
package/dist/index.js
CHANGED
|
@@ -395,7 +395,7 @@ import {
|
|
|
395
395
|
withMigrationLanguageDirective,
|
|
396
396
|
withRawMessageProvider,
|
|
397
397
|
withRawSessionMessageCache
|
|
398
|
-
} from "./index-
|
|
398
|
+
} from "./index-8e0zezh7.js";
|
|
399
399
|
import {
|
|
400
400
|
pushNotification
|
|
401
401
|
} from "./index-hw34xmzk.js";
|
|
@@ -411,7 +411,7 @@ import {
|
|
|
411
411
|
import {
|
|
412
412
|
__require,
|
|
413
413
|
__toESM
|
|
414
|
-
} from "./index-
|
|
414
|
+
} from "./index-1yh8g550.js";
|
|
415
415
|
|
|
416
416
|
// src/index.ts
|
|
417
417
|
import { createRequire as createRequire3 } from "node:module";
|
|
@@ -3748,11 +3748,11 @@ async function trySendTuiToast(sessionId, text, params, forcePersist) {
|
|
|
3748
3748
|
const message = text.length > 200 ? `${text.slice(0, 200)}…` : text;
|
|
3749
3749
|
const toastVariant = inferToastVariant(text);
|
|
3750
3750
|
const duration = params.toastDurationMs ?? 5000;
|
|
3751
|
-
const { isTuiConnected: checkTui } = await import("./rpc-notifications-
|
|
3751
|
+
const { isTuiConnected: checkTui } = await import("./rpc-notifications-gmhvmfpy.js");
|
|
3752
3752
|
if (!checkTui(sessionId))
|
|
3753
3753
|
return false;
|
|
3754
3754
|
try {
|
|
3755
|
-
const { pushNotification: pushNotification2 } = await import("./rpc-notifications-
|
|
3755
|
+
const { pushNotification: pushNotification2 } = await import("./rpc-notifications-gmhvmfpy.js");
|
|
3756
3756
|
pushNotification2("toast", {
|
|
3757
3757
|
title,
|
|
3758
3758
|
message,
|
|
@@ -3801,7 +3801,7 @@ async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersi
|
|
|
3801
3801
|
queueIgnoredNotification({ client, sessionId, text, params, forcePersist });
|
|
3802
3802
|
return "queued";
|
|
3803
3803
|
}
|
|
3804
|
-
const { waitForSafeNotificationTarget } = await import("./safe-notification-target-
|
|
3804
|
+
const { waitForSafeNotificationTarget } = await import("./safe-notification-target-q00qgjm6.js");
|
|
3805
3805
|
if (await waitForSafeNotificationTarget(client, sessionId) === "skip") {
|
|
3806
3806
|
sessionLog(sessionId, "notification skipped (session not titled yet)");
|
|
3807
3807
|
return "skipped";
|
|
@@ -3820,7 +3820,7 @@ async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersi
|
|
|
3820
3820
|
let model = params.providerId && params.modelId ? { providerID: params.providerId, modelID: params.modelId } : undefined;
|
|
3821
3821
|
if (!agent || !model || !variant) {
|
|
3822
3822
|
try {
|
|
3823
|
-
const { resolvePromptContext } = await import("./prompt-context-
|
|
3823
|
+
const { resolvePromptContext } = await import("./prompt-context-3kjq9ejq.js");
|
|
3824
3824
|
const resolved = await resolvePromptContext(client, sessionId);
|
|
3825
3825
|
if (resolved) {
|
|
3826
3826
|
agent = agent ?? resolved.agent;
|
|
@@ -6882,8 +6882,8 @@ var asyncModulePromise = null;
|
|
|
6882
6882
|
function getAsyncModule() {
|
|
6883
6883
|
asyncModulePromise ??= (async () => {
|
|
6884
6884
|
const [{ default: singlefileAsyncifyVariant }, { newQuickJSAsyncWASMModuleFromVariant }] = await Promise.all([
|
|
6885
|
-
import("./index-
|
|
6886
|
-
import("./index-
|
|
6885
|
+
import("./index-rgdqj8nj.js").then((m)=>__toESM(m.default,1)),
|
|
6886
|
+
import("./index-8sseka65.js")
|
|
6887
6887
|
]);
|
|
6888
6888
|
return newQuickJSAsyncWASMModuleFromVariant(singlefileAsyncifyVariant);
|
|
6889
6889
|
})();
|
|
@@ -10951,6 +10951,7 @@ async function runDueTasksForProject(deps) {
|
|
|
10951
10951
|
import { statSync as statSync2 } from "node:fs";
|
|
10952
10952
|
|
|
10953
10953
|
// ../plugin/src/features/magic-context/dreamer/retrospective-orphan-sweep.ts
|
|
10954
|
+
var HISTORIAN_CHILD_TITLE = "magic-context-compartment";
|
|
10954
10955
|
var RETROSPECTIVE_CHILD_TITLE = "magic-context-dream-retrospective";
|
|
10955
10956
|
var USER_MEMORIES_CHILD_TITLE = "magic-context-dream-user-memories";
|
|
10956
10957
|
var CURATE_CHILD_TITLE = "magic-context-dream-curate";
|
|
@@ -10976,16 +10977,34 @@ var PRIVACY_SENSITIVE_CHILD_TITLE_MATCHES = {
|
|
|
10976
10977
|
],
|
|
10977
10978
|
prefixes: [SMART_NOTE_COMPILE_CHILD_TITLE_PREFIX, SMART_NOTE_CONFIRM_CHILD_TITLE_PREFIX]
|
|
10978
10979
|
};
|
|
10980
|
+
var HISTORIAN_CHILD_TITLE_MATCHES = {
|
|
10981
|
+
exact: [HISTORIAN_CHILD_TITLE],
|
|
10982
|
+
prefixes: []
|
|
10983
|
+
};
|
|
10984
|
+
var INTERNAL_CHILD_TITLE_MATCHES = {
|
|
10985
|
+
exact: [HISTORIAN_CHILD_TITLE, ...PRIVACY_SENSITIVE_CHILD_TITLE_MATCHES.exact],
|
|
10986
|
+
prefixes: PRIVACY_SENSITIVE_CHILD_TITLE_MATCHES.prefixes
|
|
10987
|
+
};
|
|
10979
10988
|
function retrospectiveOrphanStaleMs(taskTimeoutMinutes) {
|
|
10980
10989
|
const timeoutCandidates = Array.isArray(taskTimeoutMinutes) ? taskTimeoutMinutes : [taskTimeoutMinutes];
|
|
10981
10990
|
const maxTimeoutMinutes = Math.max(...timeoutCandidates.map((minutes) => Math.max(1, minutes ?? 20)), 20);
|
|
10982
10991
|
const timeoutMs = maxTimeoutMinutes * 60000;
|
|
10983
10992
|
return Math.max(60 * 60000, timeoutMs * 3);
|
|
10984
10993
|
}
|
|
10994
|
+
var HISTORIAN_OUTER_ATTEMPTS = 3;
|
|
10995
|
+
var HISTORIAN_MODEL_SUGGESTION_ATTEMPTS = 2;
|
|
10996
|
+
var HISTORIAN_MAX_RETRY_BACKOFF_MS = 11000;
|
|
10997
|
+
var HISTORIAN_DETACHED_WRITER_GRACE_MS = 15 * 60000;
|
|
10998
|
+
function historianOrphanStaleMs(timeoutMs, fallbackModelCount) {
|
|
10999
|
+
const timeout = Math.max(60000, timeoutMs);
|
|
11000
|
+
const fallbackCount = Math.max(0, Math.floor(fallbackModelCount));
|
|
11001
|
+
const fullAttemptBudget = timeout * HISTORIAN_OUTER_ATTEMPTS * HISTORIAN_MODEL_SUGGESTION_ATTEMPTS * (fallbackCount + 1);
|
|
11002
|
+
return Math.max(60 * 60000, fullAttemptBudget + HISTORIAN_MAX_RETRY_BACKOFF_MS + HISTORIAN_DETACHED_WRITER_GRACE_MS);
|
|
11003
|
+
}
|
|
10985
11004
|
async function sweepOrphanedRetrospectiveChildren(args) {
|
|
10986
11005
|
const { opencodeDb, client, sessionDirectory, staleMs } = args;
|
|
10987
|
-
const titleMatches = args.titleMatches ??
|
|
10988
|
-
if (!opencodeDb)
|
|
11006
|
+
const titleMatches = args.titleMatches ?? INTERNAL_CHILD_TITLE_MATCHES;
|
|
11007
|
+
if (!opencodeDb || args.keepSubagents === true)
|
|
10989
11008
|
return 0;
|
|
10990
11009
|
const now = args.now ?? Date.now();
|
|
10991
11010
|
const cutoff = now - staleMs;
|
|
@@ -11008,7 +11027,7 @@ async function sweepOrphanedRetrospectiveChildren(args) {
|
|
|
11008
11027
|
ORDER BY time_created ASC
|
|
11009
11028
|
LIMIT 200`).all(...titleParams, sessionDirectory, cutoff);
|
|
11010
11029
|
} catch (error) {
|
|
11011
|
-
log(`[
|
|
11030
|
+
log(`[magic-context] internal child orphan sweep: read skipped (${String(error)})`);
|
|
11012
11031
|
return 0;
|
|
11013
11032
|
}
|
|
11014
11033
|
if (rows.length === 0)
|
|
@@ -11023,7 +11042,7 @@ async function sweepOrphanedRetrospectiveChildren(args) {
|
|
|
11023
11042
|
}
|
|
11024
11043
|
}
|
|
11025
11044
|
if (deleted > 0) {
|
|
11026
|
-
log(`[
|
|
11045
|
+
log(`[magic-context] swept ${deleted} stale internal child session(s)`);
|
|
11027
11046
|
}
|
|
11028
11047
|
return deleted;
|
|
11029
11048
|
}
|
|
@@ -11163,7 +11182,7 @@ function scheduleInitialProjectRun(reg, db) {
|
|
|
11163
11182
|
startupTimers.set(reg.directory, timer);
|
|
11164
11183
|
}
|
|
11165
11184
|
async function runProjectMaintenance(reg, origin, db) {
|
|
11166
|
-
const projectMaintenanceEnabled = Boolean(reg.dreamerConfig && reg.dreamerConfig.disable !== true) || reg.memoryEnabled === true || reg.gitCommitIndexing?.enabled === true;
|
|
11185
|
+
const projectMaintenanceEnabled = Boolean(reg.dreamerConfig && reg.dreamerConfig.disable !== true) || reg.memoryEnabled === true || reg.gitCommitIndexing?.enabled === true || reg.historianChildSweep !== undefined;
|
|
11167
11186
|
if (!projectMaintenanceEnabled)
|
|
11168
11187
|
return;
|
|
11169
11188
|
await reg.ensureRegistered(reg.directory, db);
|
|
@@ -11200,6 +11219,7 @@ async function sweepProject(reg, origin, db, gitCommitEnabled) {
|
|
|
11200
11219
|
if (gcDeleted > 0) {
|
|
11201
11220
|
log(`[magic-context] GC'd ${gcDeleted} stale embedding row(s) for ${reg.projectIdentity} ` + `(memory=${gc.memoryRowsDeleted} commit=${gc.commitRowsDeleted} chunk=${gc.chunkRowsDeleted})`);
|
|
11202
11221
|
}
|
|
11222
|
+
await sweepOrphanedHistorianChildren(reg);
|
|
11203
11223
|
const dreamerConfig = reg.dreamerConfig;
|
|
11204
11224
|
const dreamingEnabled = Boolean(dreamerConfig && dreamerConfig.disable !== true);
|
|
11205
11225
|
if (commitIndexingEnabled && reg.gitCommitIndexing) {
|
|
@@ -11263,6 +11283,27 @@ async function sweepProject(reg, origin, db, gitCommitEnabled) {
|
|
|
11263
11283
|
log(`[dreamer] timer-triggered task scheduling failed for ${reg.projectIdentity}:`, error);
|
|
11264
11284
|
}
|
|
11265
11285
|
}
|
|
11286
|
+
async function sweepOrphanedHistorianChildren(reg) {
|
|
11287
|
+
const config = reg.historianChildSweep;
|
|
11288
|
+
if (!config || config.keepSubagents)
|
|
11289
|
+
return;
|
|
11290
|
+
const ocDb = openOpenCodeDb();
|
|
11291
|
+
if (!ocDb)
|
|
11292
|
+
return;
|
|
11293
|
+
try {
|
|
11294
|
+
await sweepOrphanedRetrospectiveChildren({
|
|
11295
|
+
opencodeDb: ocDb,
|
|
11296
|
+
client: reg.client,
|
|
11297
|
+
sessionDirectory: reg.directory,
|
|
11298
|
+
staleMs: historianOrphanStaleMs(config.timeoutMs, config.fallbackModelCount),
|
|
11299
|
+
titleMatches: HISTORIAN_CHILD_TITLE_MATCHES
|
|
11300
|
+
});
|
|
11301
|
+
} catch (error) {
|
|
11302
|
+
log(`[magic-context] historian child orphan sweep failed for ${reg.projectIdentity}:`, error);
|
|
11303
|
+
} finally {
|
|
11304
|
+
closeQuietly(ocDb);
|
|
11305
|
+
}
|
|
11306
|
+
}
|
|
11266
11307
|
async function runCompiledSmartNoteSweep(reg, db) {
|
|
11267
11308
|
const leaseKey = leaseKeyFor("evaluate-smart-notes", reg.projectIdentity);
|
|
11268
11309
|
const holderId = crypto.randomUUID();
|
|
@@ -12916,10 +12957,16 @@ function writeTransformDecisionRow(dbPath, row) {
|
|
|
12916
12957
|
function writeTransformDecisionRowOnDatabase(db, row, configureBusyTimeout) {
|
|
12917
12958
|
if (configureBusyTimeout)
|
|
12918
12959
|
db.exec("PRAGMA busy_timeout=0");
|
|
12960
|
+
const systemHashPrev = row.materialized ? row.systemHashPrev : null;
|
|
12961
|
+
const systemHashNew = row.materialized ? row.systemHashNew : null;
|
|
12962
|
+
const m0ModelKeyPrev = row.materialized ? row.m0ModelKeyPrev : null;
|
|
12963
|
+
const m0ModelKeyNew = row.materialized ? row.m0ModelKeyNew : null;
|
|
12919
12964
|
db.prepare(`INSERT OR REPLACE INTO transform_decisions (
|
|
12920
12965
|
session_id, harness, message_id, ts_ms, decision, materialized,
|
|
12921
|
-
materialize_reason,
|
|
12922
|
-
|
|
12966
|
+
materialize_reason, system_hash_prev, system_hash_new,
|
|
12967
|
+
m0_model_key_prev, m0_model_key_new, emergency, dropped_tokens,
|
|
12968
|
+
dropped_count, input_tokens
|
|
12969
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(row.sessionId, row.harness, row.messageId, row.tsMs, row.decision, row.materialized ? 1 : 0, row.materializeReason, systemHashPrev, systemHashNew, m0ModelKeyPrev, m0ModelKeyNew, row.emergency ? 1 : 0, Math.max(0, Math.floor(row.droppedTokens)), Math.max(0, Math.floor(row.droppedCount)), Math.max(0, Math.floor(row.inputTokens)));
|
|
12923
12970
|
db.prepare(`DELETE FROM transform_decisions
|
|
12924
12971
|
WHERE session_id = ? AND harness = ?
|
|
12925
12972
|
AND rowid NOT IN (
|
|
@@ -17694,6 +17741,11 @@ function injectM0M1Pi(state2, db, piMessages, entryIds, recomputeM1ThisPass = fa
|
|
|
17694
17741
|
m0 = stripMemoryMuralBlock(m0);
|
|
17695
17742
|
prependM0M1Messages(piMessages, m0, m1, muralWire);
|
|
17696
17743
|
sessionLog(state2.sessionId, `injected m[0]/m[1] into Pi messages (${m0.length} + ${m1.length} bytes, materialized=${materialized}${decision.reason ? ` reason=${decision.reason}` : ""})`);
|
|
17744
|
+
const comparison = decision.mismatch;
|
|
17745
|
+
const systemHashPrev = comparison?.signal === "systemHash" && typeof comparison.cached === "string" ? comparison.cached : null;
|
|
17746
|
+
const systemHashNew = comparison?.signal === "systemHash" && typeof comparison.current === "string" ? comparison.current : null;
|
|
17747
|
+
const m0ModelKeyPrev = comparison?.signal === "modelKey" && typeof comparison.cached === "string" ? comparison.cached : null;
|
|
17748
|
+
const m0ModelKeyNew = comparison?.signal === "modelKey" && typeof comparison.current === "string" ? comparison.current : null;
|
|
17697
17749
|
const memPath = memoryProjectPath(state2);
|
|
17698
17750
|
const workspace = resolveWorkspaceRenderContextPi(state2, db);
|
|
17699
17751
|
const memoryCount = memPath ? workspace.isWorkspaced ? getMemoriesByProjects(db, workspace.expandedIdentities, ["active", "permanent"], Date.now(), workspace.ownIdentities, workspace.shareCategories).length : getMemoriesByProject(db, memPath, ["active", "permanent"]).length : 0;
|
|
@@ -17705,6 +17757,10 @@ function injectM0M1Pi(state2, db, piMessages, entryIds, recomputeM1ThisPass = fa
|
|
|
17705
17757
|
skippedVisibleMessages,
|
|
17706
17758
|
m0Materialized: materialized,
|
|
17707
17759
|
m0Reason: decision.reason,
|
|
17760
|
+
systemHashPrev: materialized ? systemHashPrev : null,
|
|
17761
|
+
systemHashNew: materialized ? systemHashNew : null,
|
|
17762
|
+
m0ModelKeyPrev: materialized ? m0ModelKeyPrev : null,
|
|
17763
|
+
m0ModelKeyNew: materialized ? m0ModelKeyNew : null,
|
|
17708
17764
|
m0Bytes: m0.length,
|
|
17709
17765
|
m1Bytes: m1.length,
|
|
17710
17766
|
contentionExhausted,
|
|
@@ -20860,7 +20916,7 @@ function buildReferenceBlocks(args) {
|
|
|
20860
20916
|
|
|
20861
20917
|
// src/pi-historian-runner.ts
|
|
20862
20918
|
var HISTORIAN_AGENT_NAME = "magic-context-historian";
|
|
20863
|
-
var DEFAULT_HISTORIAN_TIMEOUT_MS2 =
|
|
20919
|
+
var DEFAULT_HISTORIAN_TIMEOUT_MS2 = 600000;
|
|
20864
20920
|
var MAX_HISTORIAN_RETRIES = 2;
|
|
20865
20921
|
var HISTORIAN_ALERT_COOLDOWN_MS = 60 * 1000;
|
|
20866
20922
|
var lastHistorianAlertBySession = new Map;
|
|
@@ -24324,6 +24380,10 @@ function registerPiContextHandler(pi, baseOptions) {
|
|
|
24324
24380
|
decision: schedulerDecision,
|
|
24325
24381
|
materialized: result.materialized,
|
|
24326
24382
|
materializeReason: normalizeMaterializeReason("pi", result.materializeReason, result.materialized),
|
|
24383
|
+
systemHashPrev: result.materialized ? result.injectionResult?.systemHashPrev ?? null : null,
|
|
24384
|
+
systemHashNew: result.materialized ? result.injectionResult?.systemHashNew ?? null : null,
|
|
24385
|
+
m0ModelKeyPrev: result.materialized ? result.injectionResult?.m0ModelKeyPrev ?? null : null,
|
|
24386
|
+
m0ModelKeyNew: result.materialized ? result.injectionResult?.m0ModelKeyNew ?? null : null,
|
|
24327
24387
|
emergency: result.emergency,
|
|
24328
24388
|
droppedTokens: result.droppedTokens,
|
|
24329
24389
|
droppedCount: result.droppedCount,
|
|
@@ -25425,7 +25485,11 @@ async function runPipeline(args) {
|
|
|
25425
25485
|
injectionResult = preFoldInjectionResult?.m0Materialized ? {
|
|
25426
25486
|
...wireInjectionResult,
|
|
25427
25487
|
m0Materialized: true,
|
|
25428
|
-
m0Reason: preFoldInjectionResult.m0Reason ?? wireInjectionResult.m0Reason
|
|
25488
|
+
m0Reason: preFoldInjectionResult.m0Reason ?? wireInjectionResult.m0Reason,
|
|
25489
|
+
systemHashPrev: preFoldInjectionResult.systemHashPrev ?? null,
|
|
25490
|
+
systemHashNew: preFoldInjectionResult.systemHashNew ?? null,
|
|
25491
|
+
m0ModelKeyPrev: preFoldInjectionResult.m0ModelKeyPrev ?? null,
|
|
25492
|
+
m0ModelKeyNew: preFoldInjectionResult.m0ModelKeyNew ?? null
|
|
25429
25493
|
} : wireInjectionResult;
|
|
25430
25494
|
if (args.temporalAwareness && injectionResult.skippedVisibleMessages > 0) {
|
|
25431
25495
|
const firstRetainedMessage = args.messages[injectionResult.syntheticLeadingCount];
|
|
@@ -26051,12 +26115,9 @@ async function runHistorianPrompt(args) {
|
|
|
26051
26115
|
error: `Historian failed while processing this session: ${desc.brief}`
|
|
26052
26116
|
};
|
|
26053
26117
|
} finally {
|
|
26054
|
-
if (agentSessionId
|
|
26055
|
-
|
|
26056
|
-
|
|
26057
|
-
});
|
|
26058
|
-
} else if (agentSessionId && (!outcomeOk || shouldKeepSubagents())) {
|
|
26059
|
-
sessionLog(parentSessionId, `historian: KEEPING child session ${agentSessionId} (${outcomeOk ? "keep_subagents" : "failed"}) — not deleted`);
|
|
26118
|
+
if (agentSessionId) {
|
|
26119
|
+
const retentionReason = shouldKeepSubagents() ? "keep_subagents" : outcomeOk ? "prompt completed; cleanup deferred to the age-gated sweep" : "failed; cleanup deferred to the age-gated sweep";
|
|
26120
|
+
sessionLog(parentSessionId, `historian: KEEPING child session ${agentSessionId} (${retentionReason}) — not deleted inline`);
|
|
26060
26121
|
}
|
|
26061
26122
|
}
|
|
26062
26123
|
}
|
|
@@ -28096,7 +28157,7 @@ function executeStatus(db, sessionId, protectedTags, executeThresholdPercentageC
|
|
|
28096
28157
|
"### Cache TTL",
|
|
28097
28158
|
`- Configured: ${meta.cacheTtl}`,
|
|
28098
28159
|
`- Last response: ${meta.lastResponseTime > 0 ? `${Math.round(elapsed / 1000)}s ago` : "never"}`,
|
|
28099
|
-
`- Remaining: ${cacheExpired ? "expired" : ttlMs === Number.POSITIVE_INFINITY ? "never
|
|
28160
|
+
`- Remaining: ${cacheExpired ? "expired" : ttlMs === Number.POSITIVE_INFINITY ? "never (MC never assumes expiry — external cache-keep)" : `${Math.round(remainingMs / 1000)}s`}`,
|
|
28100
28161
|
`- Queue will auto-execute: ${cacheExpired ? "yes (cache expired)" : ttlMs === Number.POSITIVE_INFINITY ? `when context >= ${executeThresholdPercentage}%` : `when TTL expires or context >= ${executeThresholdPercentage}%`}`,
|
|
28101
28162
|
"",
|
|
28102
28163
|
"### Execute Threshold",
|
|
@@ -28216,7 +28277,7 @@ ${c.content}
|
|
|
28216
28277
|
// package.json
|
|
28217
28278
|
var package_default = {
|
|
28218
28279
|
name: "@cortexkit/pi-magic-context",
|
|
28219
|
-
version: "0.38.
|
|
28280
|
+
version: "0.38.1",
|
|
28220
28281
|
type: "module",
|
|
28221
28282
|
description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
28222
28283
|
main: "dist/index.js",
|
|
@@ -28411,7 +28472,7 @@ function renderInner(s, theme, innerWidth) {
|
|
|
28411
28472
|
lines.push(`Upgrade: ${theme.fg("accent", "up to date")}`);
|
|
28412
28473
|
}
|
|
28413
28474
|
lines.push(`Pending drops: ${s.pendingOpsCount}`);
|
|
28414
|
-
lines.push(`Cache TTL: ${s.cacheTtl} · last response ${s.lastResponseTime > 0 ? `${Math.round((Date.now() - s.lastResponseTime) / 1000)}s ago` : "never"} · ${s.cacheExpired ? theme.fg("warning", "expired") : s.cacheRemainingMs === Number.POSITIVE_INFINITY ? "never
|
|
28475
|
+
lines.push(`Cache TTL: ${s.cacheTtl} · last response ${s.lastResponseTime > 0 ? `${Math.round((Date.now() - s.lastResponseTime) / 1000)}s ago` : "never"} · ${s.cacheExpired ? theme.fg("warning", "expired") : s.cacheRemainingMs === Number.POSITIVE_INFINITY ? "never (MC never assumes expiry — external cache-keep)" : `${Math.round(s.cacheRemainingMs / 1000)}s remaining`}`);
|
|
28415
28476
|
lines.push("");
|
|
28416
28477
|
lines.push(theme.fg("muted", "Tags"));
|
|
28417
28478
|
lines.push(`Active ${s.activeTags} (~${formatBytes(s.activeBytes)}) · Dropped ${s.droppedTags} · Total ${s.totalTags}`);
|
|
@@ -30447,16 +30508,16 @@ function formatExecuteThresholdForLog(value) {
|
|
|
30447
30508
|
return overrides.length > 0 ? `${base} (${overrides.join(", ")})` : base;
|
|
30448
30509
|
}
|
|
30449
30510
|
export {
|
|
30450
|
-
|
|
30451
|
-
resolveSidekickFromConfig,
|
|
30452
|
-
resolveHistorianFromConfig,
|
|
30453
|
-
resolveDreamerFromConfig,
|
|
30454
|
-
persistPiPressureFromMessageEnd,
|
|
30455
|
-
persistPiMessageEndModelMeta,
|
|
30456
|
-
handlePiSessionBeforeCompact,
|
|
30457
|
-
src_default as default,
|
|
30458
|
-
capturePiTodowriteMessageIfCompatible,
|
|
30459
|
-
capturePiTodowriteArgsIfCompatible,
|
|
30511
|
+
__test,
|
|
30460
30512
|
canonicalPiModelKey,
|
|
30461
|
-
|
|
30513
|
+
capturePiTodowriteArgsIfCompatible,
|
|
30514
|
+
capturePiTodowriteMessageIfCompatible,
|
|
30515
|
+
src_default as default,
|
|
30516
|
+
handlePiSessionBeforeCompact,
|
|
30517
|
+
persistPiMessageEndModelMeta,
|
|
30518
|
+
persistPiPressureFromMessageEnd,
|
|
30519
|
+
resolveDreamerFromConfig,
|
|
30520
|
+
resolveHistorianFromConfig,
|
|
30521
|
+
resolveSidekickFromConfig,
|
|
30522
|
+
signalPiDeferredCompactionMarkerDrain
|
|
30462
30523
|
};
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
applyModuleEvalRuntimeOptions
|
|
6
6
|
} from "./index-dynqfgx1.js";
|
|
7
7
|
import"./index-9xexf8s7.js";
|
|
8
|
-
import"./index-
|
|
8
|
+
import"./index-1yh8g550.js";
|
|
9
9
|
export {
|
|
10
|
-
|
|
11
|
-
applyBaseRuntimeOptions,
|
|
10
|
+
QuickJSModuleCallbacks,
|
|
12
11
|
QuickJSWASMModule,
|
|
13
|
-
|
|
12
|
+
applyBaseRuntimeOptions,
|
|
13
|
+
applyModuleEvalRuntimeOptions
|
|
14
14
|
};
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
pushNotification,
|
|
7
7
|
registerNotificationSink
|
|
8
8
|
} from "./index-hw34xmzk.js";
|
|
9
|
-
import"./index-
|
|
9
|
+
import"./index-1yh8g550.js";
|
|
10
10
|
export {
|
|
11
|
-
|
|
12
|
-
pushNotification,
|
|
13
|
-
isTuiConnected,
|
|
14
|
-
drainNotifications,
|
|
11
|
+
__resetNotificationStateForTests,
|
|
15
12
|
acknowledgeNotifications,
|
|
16
|
-
|
|
13
|
+
drainNotifications,
|
|
14
|
+
isTuiConnected,
|
|
15
|
+
pushNotification,
|
|
16
|
+
registerNotificationSink
|
|
17
17
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
log
|
|
3
3
|
} from "./index-hk6sj7dn.js";
|
|
4
|
-
import"./index-
|
|
4
|
+
import"./index-1yh8g550.js";
|
|
5
5
|
|
|
6
6
|
// ../plugin/src/shared/safe-notification-target.ts
|
|
7
7
|
var DEFAULT_TITLE_RE = /^(New session - |Child session - )\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
@@ -38,6 +38,6 @@ async function waitForSafeNotificationTarget(client, sessionId, options) {
|
|
|
38
38
|
return "skip";
|
|
39
39
|
}
|
|
40
40
|
export {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
isDefaultSessionTitle,
|
|
42
|
+
waitForSafeNotificationTarget
|
|
43
43
|
};
|
package/dist/subagent-entry.js
CHANGED
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
registerMagicContextTools,
|
|
6
6
|
resolveProjectIdentityForSession,
|
|
7
7
|
setStoragePrivatePermissionEnforcement
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-8e0zezh7.js";
|
|
9
9
|
import {
|
|
10
10
|
log,
|
|
11
11
|
setHarness
|
|
12
12
|
} from "./index-hk6sj7dn.js";
|
|
13
|
-
import"./index-
|
|
13
|
+
import"./index-1yh8g550.js";
|
|
14
14
|
|
|
15
15
|
// src/subagent-entry.ts
|
|
16
16
|
var SUBAGENT_DREAMER_ACTIONS_FLAG = "magic-context-dreamer-actions";
|
package/package.json
CHANGED