@cortexkit/opencode-magic-context 0.35.1 → 0.36.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/README.md +9 -5
- package/dist/agents/permissions.d.ts +17 -0
- package/dist/agents/permissions.d.ts.map +1 -1
- package/dist/{announcement-gms2nhya.js → announcement-6c1g4es4.js} +2 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +10 -0
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-p2pmhvn7.js → conflict-warning-hook-mt0ttc4x.js} +5 -5
- package/dist/{derive-budgets-9crp0cvd.js → derive-budgets-88mxk2w1.js} +3 -3
- package/dist/features/magic-context/context-authority.d.ts +12 -0
- package/dist/features/magic-context/context-authority.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/classify.d.ts +2 -0
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts +4 -0
- package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/lease.d.ts +10 -3
- package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts +2 -0
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/module-apply.d.ts +5 -0
- package/dist/features/magic-context/dreamer/module-apply.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/promote-primers.d.ts +2 -0
- package/dist/features/magic-context/dreamer/promote-primers.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts +2 -0
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts +1 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +5 -2
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts +2 -0
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/mural/compress-cues.d.ts +2 -0
- package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/schema-fence-probe.d.ts +1 -0
- package/dist/features/magic-context/schema-fence-probe.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/condition-compiler.d.ts +38 -0
- package/dist/features/magic-context/smart-notes/condition-compiler.d.ts.map +1 -0
- package/dist/features/magic-context/smart-notes/runner.d.ts +1 -0
- package/dist/features/magic-context/smart-notes/runner.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/storage.d.ts +3 -3
- package/dist/features/magic-context/smart-notes/storage.d.ts.map +1 -1
- package/dist/features/magic-context/storage-clone.d.ts +6 -0
- package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +2 -2
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-identity-merge.d.ts.map +1 -1
- package/dist/features/magic-context/storage-notes.d.ts +13 -0
- package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +2 -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/user-memory/review-user-memories.d.ts +2 -0
- package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
- package/dist/hooks/magic-context/child-session-spawn.d.ts +1 -0
- package/dist/hooks/magic-context/child-session-spawn.d.ts.map +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-off-transition.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts +5 -3
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts.map +1 -1
- package/dist/hooks/magic-context/embed-session-state.d.ts +1 -1
- package/dist/hooks/magic-context/embed-session-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +3 -0
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +8 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts +5 -2
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +15 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-state-sync.d.ts +7 -0
- package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts +29 -3
- package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-fallback-context-limit.d.ts +10 -0
- package/dist/hooks/magic-context/raw-fallback-context-limit.d.ts.map +1 -0
- package/dist/hooks/magic-context/read-session-formatting.d.ts +1 -0
- package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +10 -2
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-content.d.ts +6 -1
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +1 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-fkyamz2w.js → index-1skzp4dc.js} +444 -98
- package/dist/{index-w0nygb4p.js → index-3tnkymva.js} +2 -2
- package/dist/{index-dpdnjawy.js → index-3zqcdwqr.js} +140 -13
- package/dist/{index-0c9dmw9m.js → index-8mtsfhyg.js} +33 -3
- package/dist/{index-k1esqfwk.js → index-f1tnb3vm.js} +1 -1
- package/dist/{index-kvrcg31b.js → index-mmrhhk9a.js} +8 -1
- package/dist/{index-h5zjfesc.js → index-nsx2n9eg.js} +3 -3
- package/dist/{index-dmr999a2.js → index-qf20mv7e.js} +1 -1
- package/dist/{index-73xz0247.js → index-tsgs7td8.js} +1 -1
- package/dist/{index-ry8rh8cv.js → index-wgvxkqpx.js} +5 -4
- package/dist/{index-8aaadh98.js → index-zp6x6s6a.js} +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1556 -619
- package/dist/plugin/dream-timer.d.ts +1 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +3 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/messages-transform.d.ts +5 -5
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/plugin/rust-tool-backends.d.ts +4 -0
- package/dist/plugin/rust-tool-backends.d.ts.map +1 -1
- package/dist/{recomp-orchestrator-29f4rqax.js → recomp-orchestrator-a0g9b52q.js} +8 -8
- package/dist/{safe-notification-target-q9jk5n44.js → safe-notification-target-c11fdda2.js} +3 -3
- package/dist/{send-session-notification-sr5g06hz.js → send-session-notification-bgtf4853.js} +4 -4
- package/dist/shared/conflict-fixer.d.ts.map +1 -1
- package/dist/shared/data-path.d.ts +27 -0
- package/dist/shared/data-path.d.ts.map +1 -1
- package/dist/shared/harness-provider-map.d.ts +23 -20
- package/dist/shared/harness-provider-map.d.ts.map +1 -1
- package/dist/shared/jsonc-edit.d.ts +18 -0
- package/dist/shared/jsonc-edit.d.ts.map +1 -0
- package/dist/shared/jsonc-parser.d.ts +11 -1
- package/dist/shared/jsonc-parser.d.ts.map +1 -1
- package/dist/shared/prompt-surface-runtime.d.ts +15 -2
- package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
- package/dist/shared/prompt-surface.d.ts +5 -3
- package/dist/shared/prompt-surface.d.ts.map +1 -1
- package/dist/shared/rpc-utils.d.ts +16 -0
- package/dist/shared/rpc-utils.d.ts.map +1 -1
- package/dist/shared/tui-preferences.d.ts +9 -0
- package/dist/shared/tui-preferences.d.ts.map +1 -1
- package/dist/{storage-meta-session-ev8b55a9.js → storage-meta-session-df9tstzr.js} +4 -4
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/agents/permissions.ts +87 -0
- package/src/config/compaction-accessor-guard.test.ts +9 -4
- package/src/config/index.test.ts +23 -0
- package/src/config/index.ts +41 -9
- package/src/config/schema/magic-context.test.ts +4 -1
- package/src/config/schema/magic-context.ts +18 -3
- package/src/shared/conflict-fixer.test.ts +174 -0
- package/src/shared/conflict-fixer.ts +66 -70
- package/src/shared/data-path.test.ts +65 -9
- package/src/shared/data-path.ts +66 -1
- package/src/shared/harness-provider-map.test.ts +42 -1
- package/src/shared/harness-provider-map.ts +48 -26
- package/src/shared/jsonc-edit.ts +295 -0
- package/src/shared/jsonc-parser.test.ts +33 -0
- package/src/shared/jsonc-parser.ts +54 -2
- package/src/shared/prompt-surface-runtime.ts +13 -5
- package/src/shared/prompt-surface.test.ts +53 -2
- package/src/shared/prompt-surface.ts +20 -9
- package/src/shared/rpc-utils.test.ts +36 -0
- package/src/shared/rpc-utils.ts +71 -0
- package/src/shared/tui-preferences.test.ts +52 -2
- package/src/shared/tui-preferences.ts +42 -17
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
modelSupportsVision,
|
|
4
4
|
piModelRefToCanonical,
|
|
5
5
|
shouldEnforcePrivateStoragePermissions
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-wgvxkqpx.js";
|
|
7
7
|
import {
|
|
8
8
|
parseProviderModel
|
|
9
9
|
} from "./index-td9depx5.js";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
describeError,
|
|
12
12
|
getErrorMessage,
|
|
13
13
|
sendIgnoredMessage
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-nsx2n9eg.js";
|
|
15
15
|
import {
|
|
16
16
|
buildToolArcs,
|
|
17
17
|
buildTrueRawTokenIndex,
|
|
@@ -35,23 +35,23 @@ import {
|
|
|
35
35
|
readSessionChunk,
|
|
36
36
|
stableStringify,
|
|
37
37
|
updateSessionMeta
|
|
38
|
-
} from "./index-
|
|
38
|
+
} from "./index-3zqcdwqr.js";
|
|
39
39
|
import {
|
|
40
40
|
Database,
|
|
41
41
|
closeQuietly,
|
|
42
42
|
getMessageTimesFromOpenCodeDb,
|
|
43
43
|
withPrivilegedWriter
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-3tnkymva.js";
|
|
45
45
|
import {
|
|
46
46
|
detectConfigFile
|
|
47
|
-
} from "./index-
|
|
47
|
+
} from "./index-8mtsfhyg.js";
|
|
48
48
|
import {
|
|
49
49
|
pushNotification
|
|
50
50
|
} from "./index-d62ypazr.js";
|
|
51
51
|
import {
|
|
52
52
|
log,
|
|
53
53
|
sessionLog
|
|
54
|
-
} from "./index-
|
|
54
|
+
} from "./index-f1tnb3vm.js";
|
|
55
55
|
import {
|
|
56
56
|
ensureCortexKitArtifactGitignore,
|
|
57
57
|
getDataDir,
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
getLegacyOpenCodeMagicContextStorageDir,
|
|
60
60
|
getMagicContextStorageDir,
|
|
61
61
|
getProjectMagicContextHistorianDir
|
|
62
|
-
} from "./index-
|
|
62
|
+
} from "./index-mmrhhk9a.js";
|
|
63
63
|
import {
|
|
64
64
|
__export,
|
|
65
65
|
__require
|
|
@@ -389,6 +389,171 @@ function buildPrimaryLanguageDirective(language) {
|
|
|
389
389
|
return `Use ${target} for your natural-language replies to the user unless the user explicitly asks for another language. Keep code, identifiers, file paths, commands, logs, and quoted text verbatim.`;
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
+
// src/features/magic-context/fail-closed-block.ts
|
|
393
|
+
var FAIL_CLOSED_DOCTOR_COMMAND = "npx @cortexkit/magic-context@latest doctor";
|
|
394
|
+
var FAIL_CLOSED_REPROBE_EVERY_N = 5;
|
|
395
|
+
|
|
396
|
+
class FailClosedBlockingError extends Error {
|
|
397
|
+
code = "FAIL_CLOSED_BLOCKING";
|
|
398
|
+
reason;
|
|
399
|
+
constructor(message, reason, options) {
|
|
400
|
+
super(message, options);
|
|
401
|
+
this.name = "FailClosedBlockingError";
|
|
402
|
+
this.reason = reason;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
var OPENCODE_INTERNAL_AGENT_NAMES = new Set(["title", "summary", "compaction"]);
|
|
406
|
+
function isMagicContextHiddenAgentName(agent) {
|
|
407
|
+
if (agent === "sidekick" || agent === "smart-note-compiler" || agent.startsWith("smart-note-")) {
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
if (agent === "historian" || agent.startsWith("historian-"))
|
|
411
|
+
return true;
|
|
412
|
+
if (agent === "dreamer" || agent.startsWith("dreamer-"))
|
|
413
|
+
return true;
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
var MAX_FORMATTED_BLOCKING_PROCESSES = 8;
|
|
417
|
+
function formatFailClosedBlockingProcesses(processes) {
|
|
418
|
+
const uniqueProcesses = new Map;
|
|
419
|
+
for (const process2 of processes) {
|
|
420
|
+
if (!process2.harness.trim() || !Number.isInteger(process2.pid) || process2.pid <= 0)
|
|
421
|
+
continue;
|
|
422
|
+
uniqueProcesses.set(`${process2.harness}\x00${process2.pid}`, {
|
|
423
|
+
harness: process2.harness.trim(),
|
|
424
|
+
pid: process2.pid
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
const entries = [...uniqueProcesses.values()];
|
|
428
|
+
const visible = entries.slice(0, MAX_FORMATTED_BLOCKING_PROCESSES);
|
|
429
|
+
const rendered = visible.map(({ harness, pid }) => `${harness} (PID ${pid})`);
|
|
430
|
+
const omitted = entries.length - visible.length;
|
|
431
|
+
if (omitted > 0)
|
|
432
|
+
rendered.push(`${omitted} more blocking process(es)`);
|
|
433
|
+
if (rendered.length === 0)
|
|
434
|
+
return "a live harness process";
|
|
435
|
+
if (rendered.length === 1)
|
|
436
|
+
return rendered[0];
|
|
437
|
+
const last = rendered.pop();
|
|
438
|
+
return `${rendered.join(", ")}, and ${last}`;
|
|
439
|
+
}
|
|
440
|
+
function formatFailClosedBlockingMessage(reason) {
|
|
441
|
+
if (reason.kind === "migration_guard") {
|
|
442
|
+
if (reason.unreadableFile) {
|
|
443
|
+
const arm = reason.unreadableArm ?? "io";
|
|
444
|
+
const recovery = arm === "io" ? `If no OpenCode server is running, it is safe to delete ${reason.unreadableFile} and retry.` : `The file may be a recent incomplete write; retry after the file is older than the ten-minute grace window, or stop OpenCode before deleting it.`;
|
|
445
|
+
return [
|
|
446
|
+
`Magic Context cannot migrate the shared database because RPC discovery file ${reason.unreadableFile} is uncertain (${arm} arm), so the absence of a live OpenCode server cannot be proven.`,
|
|
447
|
+
recovery,
|
|
448
|
+
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
449
|
+
].join(" ");
|
|
450
|
+
}
|
|
451
|
+
return [
|
|
452
|
+
`Magic Context cannot migrate the shared database because ${formatFailClosedBlockingProcesses(reason.blockingProcesses)} may be running an older Magic Context build that would fail against the migrated database.`,
|
|
453
|
+
"Restart the blocking process (it will pick up the new build and migrate on start), or shut it down and retry.",
|
|
454
|
+
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
455
|
+
].join(" ");
|
|
456
|
+
}
|
|
457
|
+
if (reason.kind === "schema_fence") {
|
|
458
|
+
return [
|
|
459
|
+
`Magic Context cannot operate: this Magic Context build is older than the database; upgrade/restart this harness (upstream migration lane v${reason.persistedVersion}, build supports through v${reason.supportedVersion}).`,
|
|
460
|
+
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
461
|
+
].join(" ");
|
|
462
|
+
}
|
|
463
|
+
const cause = reason.cause.trim().length > 0 ? reason.cause.trim() : "unknown storage error";
|
|
464
|
+
return [
|
|
465
|
+
`Magic Context cannot operate: persistent storage failed (${cause}).`,
|
|
466
|
+
"The plugin will not silently degrade to native compaction while enabled.",
|
|
467
|
+
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
468
|
+
].join(" ");
|
|
469
|
+
}
|
|
470
|
+
function createFailClosedBlockingError(reason, options) {
|
|
471
|
+
return new FailClosedBlockingError(formatFailClosedBlockingMessage(reason), reason, options);
|
|
472
|
+
}
|
|
473
|
+
function isFailClosedBlockingError(error) {
|
|
474
|
+
return error instanceof FailClosedBlockingError || typeof error === "object" && error !== null && error.name === "FailClosedBlockingError" && error.code === "FAIL_CLOSED_BLOCKING";
|
|
475
|
+
}
|
|
476
|
+
function shouldBypassFailClosedBlock(input) {
|
|
477
|
+
if (input.isPiSubagentEnv === true)
|
|
478
|
+
return true;
|
|
479
|
+
if (input.isInternalChildSession === true)
|
|
480
|
+
return true;
|
|
481
|
+
const agent = typeof input.agent === "string" ? input.agent.trim() : "";
|
|
482
|
+
if (agent.length === 0)
|
|
483
|
+
return false;
|
|
484
|
+
if (OPENCODE_INTERNAL_AGENT_NAMES.has(agent))
|
|
485
|
+
return true;
|
|
486
|
+
if (isMagicContextHiddenAgentName(agent))
|
|
487
|
+
return true;
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
function resolveAgentNameFromMessages(messages) {
|
|
491
|
+
for (let i = messages.length - 1;i >= 0; i -= 1) {
|
|
492
|
+
const info = messages[i]?.info;
|
|
493
|
+
if (!info || typeof info !== "object")
|
|
494
|
+
continue;
|
|
495
|
+
const agent = info.agent;
|
|
496
|
+
if (typeof agent === "string" && agent.length > 0)
|
|
497
|
+
return agent;
|
|
498
|
+
}
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
function createFailClosedController(options) {
|
|
502
|
+
const reprobeEveryN = Math.max(1, options?.reprobeEveryN ?? FAIL_CLOSED_REPROBE_EVERY_N);
|
|
503
|
+
let reason = null;
|
|
504
|
+
let blockedPassCount = 0;
|
|
505
|
+
return {
|
|
506
|
+
arm(next) {
|
|
507
|
+
reason = next;
|
|
508
|
+
blockedPassCount = 0;
|
|
509
|
+
},
|
|
510
|
+
clear() {
|
|
511
|
+
reason = null;
|
|
512
|
+
blockedPassCount = 0;
|
|
513
|
+
},
|
|
514
|
+
isArmed() {
|
|
515
|
+
return reason !== null;
|
|
516
|
+
},
|
|
517
|
+
getReason() {
|
|
518
|
+
return reason;
|
|
519
|
+
},
|
|
520
|
+
async enforce(input) {
|
|
521
|
+
if (!reason)
|
|
522
|
+
return;
|
|
523
|
+
if (!input.blockingEnabled)
|
|
524
|
+
return;
|
|
525
|
+
if (input.exempt)
|
|
526
|
+
return;
|
|
527
|
+
blockedPassCount += 1;
|
|
528
|
+
const shouldReprobe = typeof input.tryReopen === "function" && (blockedPassCount === 1 || blockedPassCount % reprobeEveryN === 0);
|
|
529
|
+
if (shouldReprobe) {
|
|
530
|
+
try {
|
|
531
|
+
const healed = await input.tryReopen?.();
|
|
532
|
+
if (healed) {
|
|
533
|
+
reason = null;
|
|
534
|
+
blockedPassCount = 0;
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
} catch {}
|
|
538
|
+
}
|
|
539
|
+
const blockedReason = reason;
|
|
540
|
+
if (!blockedReason)
|
|
541
|
+
return;
|
|
542
|
+
throw createFailClosedBlockingError(blockedReason);
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
var lastHookInitFailure = null;
|
|
547
|
+
function recordHookInitFailure(failure) {
|
|
548
|
+
lastHookInitFailure = failure;
|
|
549
|
+
}
|
|
550
|
+
function clearHookInitFailure() {
|
|
551
|
+
lastHookInitFailure = null;
|
|
552
|
+
}
|
|
553
|
+
function getLastHookInitFailure() {
|
|
554
|
+
return lastHookInitFailure;
|
|
555
|
+
}
|
|
556
|
+
|
|
392
557
|
// src/features/magic-context/storage-db.ts
|
|
393
558
|
import {
|
|
394
559
|
chmodSync,
|
|
@@ -396,7 +561,6 @@ import {
|
|
|
396
561
|
cpSync,
|
|
397
562
|
existsSync as existsSync3,
|
|
398
563
|
mkdirSync,
|
|
399
|
-
mkdtempSync,
|
|
400
564
|
readdirSync,
|
|
401
565
|
readFileSync as readFileSync2,
|
|
402
566
|
statSync as statSync2,
|
|
@@ -452,6 +616,7 @@ var PS_PROBE_TIMEOUT_MS = 1000;
|
|
|
452
616
|
var OPEN_CODE_COMMAND_MARKERS = ["opencode", "node", "bun", "electron"];
|
|
453
617
|
var rpcIdentityReadFileSync = readFileSync;
|
|
454
618
|
var rpcIdentityExecFileSync = execFileSync;
|
|
619
|
+
var rpcProcessListExecFileSync = execFileSync;
|
|
455
620
|
var rpcIdentityPlatform = process.platform;
|
|
456
621
|
var rpcIdentityNowMs = () => Date.now();
|
|
457
622
|
function parseLinuxProcessStartTime(statContent, uptimeContent) {
|
|
@@ -524,6 +689,49 @@ function isPidIdentityPlausible(record) {
|
|
|
524
689
|
return true;
|
|
525
690
|
return commandLooksLikeOpenCode(command);
|
|
526
691
|
}
|
|
692
|
+
function commandLooksLikePi(command) {
|
|
693
|
+
const normalized = command.trim().toLowerCase().replaceAll("\\", "/");
|
|
694
|
+
const tokens = normalized.split(/\s+/).filter(Boolean);
|
|
695
|
+
const executableName = (token) => (token ?? "").split("/").at(-1) ?? "";
|
|
696
|
+
const first = executableName(tokens[0]).replace(/\.exe$/, "");
|
|
697
|
+
if (["pi", "pi.cmd", "omp", "oh-my-pi"].includes(first))
|
|
698
|
+
return true;
|
|
699
|
+
if (["node", "bun", "deno"].includes(first)) {
|
|
700
|
+
const script = executableName(tokens[1]);
|
|
701
|
+
return ["pi", "pi.js", "pi.mjs", "pi.cjs"].includes(script) || normalized.includes("pi-coding-agent");
|
|
702
|
+
}
|
|
703
|
+
return false;
|
|
704
|
+
}
|
|
705
|
+
function inspectLivePiProcesses() {
|
|
706
|
+
if (false) {}
|
|
707
|
+
try {
|
|
708
|
+
const output = String(rpcProcessListExecFileSync("ps", ["-axo", "pid=,command="], {
|
|
709
|
+
encoding: "utf8",
|
|
710
|
+
timeout: PS_PROBE_TIMEOUT_MS
|
|
711
|
+
}));
|
|
712
|
+
const pids = new Set;
|
|
713
|
+
for (const line of output.split(/\r?\n/)) {
|
|
714
|
+
const match = /^\s*(\d+)\s+(.+)$/.exec(line);
|
|
715
|
+
if (!match)
|
|
716
|
+
continue;
|
|
717
|
+
const pid = Number(match[1]);
|
|
718
|
+
if (!Number.isInteger(pid) || pid <= 0 || pid === process.pid)
|
|
719
|
+
continue;
|
|
720
|
+
if (commandLooksLikePi(match[2]))
|
|
721
|
+
pids.add(pid);
|
|
722
|
+
}
|
|
723
|
+
return { state: "known", processIds: [...pids].sort((left, right) => left - right) };
|
|
724
|
+
} catch (error) {
|
|
725
|
+
return {
|
|
726
|
+
state: "unreadable",
|
|
727
|
+
processIds: [],
|
|
728
|
+
error: error instanceof Error ? error.message : String(error)
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
function discoverLivePiProcessIds() {
|
|
733
|
+
return inspectLivePiProcesses().processIds;
|
|
734
|
+
}
|
|
527
735
|
function parseRpcPortFile(content, fallbackPid = 0) {
|
|
528
736
|
const trimmed = content.trim();
|
|
529
737
|
if (!trimmed)
|
|
@@ -1252,7 +1460,8 @@ function prepareMirrorPageStatements(db) {
|
|
|
1252
1460
|
deleteNote: db.prepare("DELETE FROM notes WHERE id = ?"),
|
|
1253
1461
|
deleteNoteRevisions: db.prepare("DELETE FROM mirror_note_revisions WHERE module_project = ? AND module_row_id = ?"),
|
|
1254
1462
|
updateNote: db.prepare(`UPDATE notes SET type = ?, status = ?, project_path = ?, session_id = ?, content = ?,
|
|
1255
|
-
surface_condition = ?,
|
|
1463
|
+
surface_condition = ?, compiled_provider = ?, compiled_config = ?, compiled_at = ?, compile_status = ?,
|
|
1464
|
+
ready_at = ?, ready_reason = ?, manifest_json = ?, compiled_check = ?,
|
|
1256
1465
|
check_hash = ?, check_cron = ?, check_failure_count = ?, check_network_failure_count = ?,
|
|
1257
1466
|
check_quarantined_until = ?, check_next_due_at = ?, check_compiled_at = ?, check_false_since_at = ?,
|
|
1258
1467
|
check_last_liveness_at = ?, last_checked_at = ?, check_status = ?, check_version = ?,
|
|
@@ -1326,6 +1535,18 @@ function prepareMirrorPageStatements(db) {
|
|
|
1326
1535
|
function mirrorIdentity(db, domain, moduleProject, moduleRowId, statements) {
|
|
1327
1536
|
return (statements?.identityByModule ?? db.prepare("SELECT context_row_id FROM mirror_identity WHERE domain = ? AND module_project = ? AND module_row_id = ?")).get(domain, moduleProject, moduleRowId) ?? null;
|
|
1328
1537
|
}
|
|
1538
|
+
function applyMirroredNoteCompileFields(args) {
|
|
1539
|
+
return withPrivilegedWriter(args.db, () => {
|
|
1540
|
+
const result = args.db.prepare(`UPDATE notes
|
|
1541
|
+
SET compiled_provider = ?, compiled_config = ?, compiled_at = ?, compile_status = ?
|
|
1542
|
+
WHERE id = (
|
|
1543
|
+
SELECT context_row_id
|
|
1544
|
+
FROM mirror_identity
|
|
1545
|
+
WHERE domain = 'notes' AND module_project = ? AND module_row_id = ?
|
|
1546
|
+
)`).run(args.fields.compiledProvider, args.fields.compiledConfig, args.fields.compiledAt, args.fields.compileStatus, args.moduleProject, args.moduleRowId);
|
|
1547
|
+
return result.changes === 1;
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1329
1550
|
function rememberIdentity(db, domain, moduleProject, moduleRowId, contextRowId, statements) {
|
|
1330
1551
|
const existing = mirrorIdentity(db, domain, moduleProject, moduleRowId, statements);
|
|
1331
1552
|
if (existing)
|
|
@@ -1508,7 +1729,7 @@ function applyNoteRow(db, feed, statements) {
|
|
|
1508
1729
|
}
|
|
1509
1730
|
const moduleStatus = rowString(effectiveRow, "status", "active");
|
|
1510
1731
|
const contextStatus = moduleStatus === "surfaced" || moduleStatus === "surfacing" ? "ready" : moduleStatus;
|
|
1511
|
-
statements.updateNote.run(rowString(effectiveRow, "type", "smart"), contextStatus, moduleProject, rowNullableString(effectiveRow, "session_id"), rowString(effectiveRow, "content"), rowNullableString(effectiveRow, "surface_condition"), typeof effectiveRow.ready_at === "number" ? effectiveRow.ready_at : null, rowNullableString(effectiveRow, "ready_reason"), rowNullableString(effectiveRow, "manifest_json"), rowNullableString(effectiveRow, "compiled_check"), rowNullableString(effectiveRow, "check_hash"), rowNullableString(effectiveRow, "check_cron"), rowNumber(effectiveRow, "check_failure_count"), rowNumber(effectiveRow, "check_network_failure_count"), typeof effectiveRow.check_quarantined_until === "number" ? effectiveRow.check_quarantined_until : null, typeof effectiveRow.check_next_due_at === "number" ? effectiveRow.check_next_due_at : null, typeof effectiveRow.check_compiled_at === "number" ? effectiveRow.check_compiled_at : null, typeof effectiveRow.check_false_since_at === "number" ? effectiveRow.check_false_since_at : null, typeof effectiveRow.check_last_liveness_at === "number" ? effectiveRow.check_last_liveness_at : null, typeof effectiveRow.last_checked_at === "number" ? effectiveRow.last_checked_at : null, rowString(effectiveRow, "check_status", "uncompiled"), rowNumber(effectiveRow, "check_version"), rowNumber(effectiveRow, "policy_version", 1), rowNullableString(effectiveRow, "anchor_block_id"), typeof effectiveRow.anchor_ordinal === "number" ? effectiveRow.anchor_ordinal : null, rowNumber(effectiveRow, "created_at_ms"), rowNumber(effectiveRow, "updated_at_ms"), contextId);
|
|
1732
|
+
statements.updateNote.run(rowString(effectiveRow, "type", "smart"), contextStatus, moduleProject, rowNullableString(effectiveRow, "session_id"), rowString(effectiveRow, "content"), rowNullableString(effectiveRow, "surface_condition"), rowNullableString(effectiveRow, "compiled_provider"), rowNullableString(effectiveRow, "compiled_config"), typeof effectiveRow.compiled_at === "number" ? effectiveRow.compiled_at : null, rowNullableString(effectiveRow, "compile_status"), typeof effectiveRow.ready_at === "number" ? effectiveRow.ready_at : null, rowNullableString(effectiveRow, "ready_reason"), rowNullableString(effectiveRow, "manifest_json"), rowNullableString(effectiveRow, "compiled_check"), rowNullableString(effectiveRow, "check_hash"), rowNullableString(effectiveRow, "check_cron"), rowNumber(effectiveRow, "check_failure_count"), rowNumber(effectiveRow, "check_network_failure_count"), typeof effectiveRow.check_quarantined_until === "number" ? effectiveRow.check_quarantined_until : null, typeof effectiveRow.check_next_due_at === "number" ? effectiveRow.check_next_due_at : null, typeof effectiveRow.check_compiled_at === "number" ? effectiveRow.check_compiled_at : null, typeof effectiveRow.check_false_since_at === "number" ? effectiveRow.check_false_since_at : null, typeof effectiveRow.check_last_liveness_at === "number" ? effectiveRow.check_last_liveness_at : null, typeof effectiveRow.last_checked_at === "number" ? effectiveRow.last_checked_at : null, rowString(effectiveRow, "check_status", "uncompiled"), rowNumber(effectiveRow, "check_version"), rowNumber(effectiveRow, "policy_version", 1), rowNullableString(effectiveRow, "anchor_block_id"), typeof effectiveRow.anchor_ordinal === "number" ? effectiveRow.anchor_ordinal : null, rowNumber(effectiveRow, "created_at_ms"), rowNumber(effectiveRow, "updated_at_ms"), contextId);
|
|
1512
1733
|
statements.upsertNoteRevision.run(moduleProject, feed.module_row_id, contextId, rowNumber(effectiveRow, "status_version"));
|
|
1513
1734
|
}
|
|
1514
1735
|
function applyMirrorPage(args) {
|
|
@@ -2772,7 +2993,11 @@ var MIGRATIONS = [
|
|
|
2772
2993
|
updated_at INTEGER NOT NULL,
|
|
2773
2994
|
last_checked_at INTEGER,
|
|
2774
2995
|
ready_at INTEGER,
|
|
2775
|
-
ready_reason TEXT
|
|
2996
|
+
ready_reason TEXT,
|
|
2997
|
+
compiled_provider TEXT,
|
|
2998
|
+
compiled_config TEXT,
|
|
2999
|
+
compiled_at INTEGER,
|
|
3000
|
+
compile_status TEXT CHECK(compile_status IN ('compiled', 'plain', 'refused'))
|
|
2776
3001
|
);
|
|
2777
3002
|
CREATE INDEX IF NOT EXISTS idx_notes_session_status ON notes(session_id, status);
|
|
2778
3003
|
CREATE INDEX IF NOT EXISTS idx_notes_project_status ON notes(project_path, status);
|
|
@@ -4681,6 +4906,18 @@ var MIGRATIONS = [
|
|
|
4681
4906
|
return;
|
|
4682
4907
|
ensureColumn(db, "memories", "mural_cue_rejection_count", "INTEGER NOT NULL DEFAULT 0");
|
|
4683
4908
|
}
|
|
4909
|
+
},
|
|
4910
|
+
{
|
|
4911
|
+
version: 76,
|
|
4912
|
+
description: "persist retina provider compilation for smart-note conditions",
|
|
4913
|
+
up(db) {
|
|
4914
|
+
if (!tableExists2(db, "notes"))
|
|
4915
|
+
return;
|
|
4916
|
+
ensureColumn(db, "notes", "compiled_provider", "TEXT");
|
|
4917
|
+
ensureColumn(db, "notes", "compiled_config", "TEXT");
|
|
4918
|
+
ensureColumn(db, "notes", "compiled_at", "INTEGER");
|
|
4919
|
+
ensureColumn(db, "notes", "compile_status", "TEXT CHECK(compile_status IN ('compiled', 'plain', 'refused'))");
|
|
4920
|
+
}
|
|
4684
4921
|
}
|
|
4685
4922
|
];
|
|
4686
4923
|
var LATEST_MIGRATION_VERSION = MIGRATIONS.reduce((max, m) => Math.max(max, m.version), 0);
|
|
@@ -5148,7 +5385,7 @@ function getSchemaFenceRejection() {
|
|
|
5148
5385
|
function getMigrationOnOpenRefusal() {
|
|
5149
5386
|
return lastMigrationOnOpenRefusal;
|
|
5150
5387
|
}
|
|
5151
|
-
var LATEST_SUPPORTED_VERSION =
|
|
5388
|
+
var LATEST_SUPPORTED_VERSION = 76;
|
|
5152
5389
|
var PERMISSIONS_ENFORCEABLE = process.platform !== "win32";
|
|
5153
5390
|
var defaultStoragePermissionFs = { chmodSync, mkdirSync };
|
|
5154
5391
|
var storagePermissionFs = defaultStoragePermissionFs;
|
|
@@ -5184,12 +5421,6 @@ function resolveDatabasePath(dbPathOverride) {
|
|
|
5184
5421
|
if (dbPathOverride) {
|
|
5185
5422
|
return { dbDir: dirname(dbPathOverride), dbPath: dbPathOverride };
|
|
5186
5423
|
}
|
|
5187
|
-
const testDataDir = process.env.MAGIC_CONTEXT_TEST_DATA_DIR;
|
|
5188
|
-
if (testDataDir && !process.env.XDG_DATA_HOME) {
|
|
5189
|
-
const dbDir2 = join3(testDataDir, "cortexkit", "magic-context");
|
|
5190
|
-
return { dbDir: dbDir2, dbPath: join3(dbDir2, "context.db") };
|
|
5191
|
-
}
|
|
5192
|
-
if (false) {}
|
|
5193
5424
|
const dbDir = getMagicContextStorageDir();
|
|
5194
5425
|
return { dbDir, dbPath: join3(dbDir, "context.db") };
|
|
5195
5426
|
}
|
|
@@ -5398,14 +5629,16 @@ function enforceMigrationOnOpenGuard(db, dbPath, dbDir, latestSupportedVersion)
|
|
|
5398
5629
|
return true;
|
|
5399
5630
|
}
|
|
5400
5631
|
const discovery = inspectRpcServerDiscovery(dbDir);
|
|
5401
|
-
|
|
5632
|
+
const piPids = discoverLivePiProcessIds();
|
|
5633
|
+
if ((discovery.state === "absent" || discovery.state === "stale") && piPids.length === 0) {
|
|
5402
5634
|
lastMigrationOnOpenRefusal = null;
|
|
5403
5635
|
return true;
|
|
5404
5636
|
}
|
|
5637
|
+
const blockingPids = [...new Set([...discovery.serverPids, ...piPids])].sort((left, right) => left - right);
|
|
5405
5638
|
lastMigrationOnOpenRefusal = {
|
|
5406
5639
|
persistedVersion,
|
|
5407
5640
|
supportedVersion: latestSupportedVersion,
|
|
5408
|
-
serverPids:
|
|
5641
|
+
serverPids: blockingPids,
|
|
5409
5642
|
...discovery.unreadableFile ? { unreadableFile: discovery.unreadableFile } : {},
|
|
5410
5643
|
...discovery.unreadableArm ? { unreadableArm: discovery.unreadableArm } : {}
|
|
5411
5644
|
};
|
|
@@ -5415,7 +5648,11 @@ function enforceMigrationOnOpenGuard(db, dbPath, dbDir, latestSupportedVersion)
|
|
|
5415
5648
|
const recovery = arm === "io" ? `If no OpenCode server is running, it is safe to delete ${unreadableFile} and retry.` : `Retry after the file is older than the ten-minute grace window, or stop OpenCode before deleting it.`;
|
|
5416
5649
|
log(`[magic-context] storage fatal: refusing to migrate ${dbPath} from upstream migration v${persistedVersion} to v${latestSupportedVersion} because RPC discovery file ${unreadableFile} is uncertain (${arm} arm), so the absence of a live OpenCode server cannot be proven. ${recovery}`);
|
|
5417
5650
|
} else {
|
|
5418
|
-
|
|
5651
|
+
const blockers = [
|
|
5652
|
+
...discovery.serverPids.map((pid) => `OpenCode server PID ${pid}`),
|
|
5653
|
+
...piPids.map((pid) => `Pi harness PID ${pid}`)
|
|
5654
|
+
];
|
|
5655
|
+
log(`[magic-context] storage fatal: refusing to migrate ${dbPath} from upstream migration v${persistedVersion} to v${latestSupportedVersion} while ${blockers.join(", ")} may still use the old plugin build. Restart the blocking harness, then retry this process.`);
|
|
5419
5656
|
}
|
|
5420
5657
|
return false;
|
|
5421
5658
|
}
|
|
@@ -6689,13 +6926,14 @@ var state = {
|
|
|
6689
6926
|
noticeEmitted: false,
|
|
6690
6927
|
failure: null
|
|
6691
6928
|
};
|
|
6692
|
-
function recordStaleFence(persistedVersion, supportedVersion) {
|
|
6929
|
+
function recordStaleFence(persistedVersion, supportedVersion, reason = "newer_schema") {
|
|
6693
6930
|
state.consecutiveFailures += 1;
|
|
6694
6931
|
state.totalFailures += 1;
|
|
6695
6932
|
const latched = state.consecutiveFailures >= STALE_CHILD_SPAWN_LATCH_THRESHOLD;
|
|
6696
6933
|
state.latched ||= latched;
|
|
6697
6934
|
const failure = {
|
|
6698
6935
|
failureClass: STALE_CHILD_SPAWN_FAILURE,
|
|
6936
|
+
reason,
|
|
6699
6937
|
persistedVersion,
|
|
6700
6938
|
supportedVersion,
|
|
6701
6939
|
consecutiveFailures: state.consecutiveFailures,
|
|
@@ -6722,7 +6960,7 @@ function probeChildSpawnFence(db) {
|
|
|
6722
6960
|
return recordStaleFence(persistedVersion, LATEST_SUPPORTED_VERSION);
|
|
6723
6961
|
}
|
|
6724
6962
|
} catch {
|
|
6725
|
-
return
|
|
6963
|
+
return recordStaleFence(LATEST_SUPPORTED_VERSION, LATEST_SUPPORTED_VERSION, "read_error");
|
|
6726
6964
|
}
|
|
6727
6965
|
state.consecutiveFailures = 0;
|
|
6728
6966
|
state.latched = false;
|
|
@@ -8250,6 +8488,11 @@ var NOTE_CHECK_STATUSES = new Set([
|
|
|
8250
8488
|
"failing",
|
|
8251
8489
|
"fallback"
|
|
8252
8490
|
]);
|
|
8491
|
+
var CONDITION_COMPILE_STATUSES = new Set([
|
|
8492
|
+
"compiled",
|
|
8493
|
+
"plain",
|
|
8494
|
+
"refused"
|
|
8495
|
+
]);
|
|
8253
8496
|
var DEFAULT_SMART_STATUSES = ["pending", "ready"];
|
|
8254
8497
|
function toNullableString(value) {
|
|
8255
8498
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
@@ -8272,6 +8515,10 @@ function toNote(row) {
|
|
|
8272
8515
|
sessionId: toNullableString(row.session_id),
|
|
8273
8516
|
projectPath: toNullableString(row.project_path),
|
|
8274
8517
|
surfaceCondition: toNullableString(row.surface_condition),
|
|
8518
|
+
compiledProvider: toNullableString(row.compiled_provider),
|
|
8519
|
+
compiledConfig: toNullableString(row.compiled_config),
|
|
8520
|
+
compiledAt: toNullableNumber(row.compiled_at),
|
|
8521
|
+
compileStatus: typeof row.compile_status === "string" && CONDITION_COMPILE_STATUSES.has(row.compile_status) ? row.compile_status : null,
|
|
8275
8522
|
createdAt: row.created_at,
|
|
8276
8523
|
updatedAt: row.updated_at,
|
|
8277
8524
|
lastCheckedAt: toNullableNumber(row.last_checked_at),
|
|
@@ -8351,7 +8598,7 @@ function getNotes(db, options = {}) {
|
|
|
8351
8598
|
}
|
|
8352
8599
|
function addNote(db, type, options) {
|
|
8353
8600
|
const now = Date.now();
|
|
8354
|
-
const result = type === "session" ? db.prepare("INSERT INTO notes (type, status, content, session_id, created_at, updated_at, harness, anchor_ordinal) VALUES ('session', 'active', ?, ?, ?, ?, ?, ?) RETURNING *").get(options.content, options.sessionId, now, now, getHarness(), options.anchorOrdinal ?? null) : db.prepare("INSERT INTO notes (type, status, content, session_id, project_path, surface_condition, created_at, updated_at, harness, anchor_ordinal) VALUES ('smart', 'pending', ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *").get(options.content, options.sessionId ?? null, options.projectPath, options.surfaceCondition, now, now, getHarness(), options.anchorOrdinal ?? null);
|
|
8601
|
+
const result = type === "session" ? db.prepare("INSERT INTO notes (type, status, content, session_id, created_at, updated_at, harness, anchor_ordinal) VALUES ('session', 'active', ?, ?, ?, ?, ?, ?) RETURNING *").get(options.content, options.sessionId, now, now, getHarness(), options.anchorOrdinal ?? null) : db.prepare("INSERT INTO notes (type, status, content, session_id, project_path, surface_condition, compiled_provider, compiled_config, compiled_at, compile_status, created_at, updated_at, harness, anchor_ordinal) VALUES ('smart', 'pending', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *").get(options.content, options.sessionId ?? null, options.projectPath, options.surfaceCondition, options.compiledProvider ?? null, options.compiledConfig ?? null, options.compiledAt ?? null, options.compileStatus ?? null, now, now, getHarness(), options.anchorOrdinal ?? null);
|
|
8355
8602
|
if (!isNoteRow(result)) {
|
|
8356
8603
|
throw new Error("[notes] failed to insert note");
|
|
8357
8604
|
}
|
|
@@ -8405,6 +8652,8 @@ function updateNote(db, noteId, updates, scope) {
|
|
|
8405
8652
|
}
|
|
8406
8653
|
if (smartConditionChanged) {
|
|
8407
8654
|
sets.push("status = 'pending'", "last_checked_at = NULL", "ready_at = NULL", "ready_reason = NULL");
|
|
8655
|
+
sets.push("compiled_provider = ?", "compiled_config = ?", "compiled_at = ?", "compile_status = ?");
|
|
8656
|
+
params.push(updates.compiledProvider ?? null, updates.compiledConfig ?? null, updates.compiledAt ?? null, updates.compileStatus ?? null);
|
|
8408
8657
|
if (noteCheckColumnsExist(db)) {
|
|
8409
8658
|
sets.push("compiled_check = NULL", "manifest_json = NULL", "check_hash = NULL", "check_cron = NULL", "check_version = 0", "check_status = 'uncompiled'", "check_failure_count = 0", "check_network_failure_count = 0", "check_quarantined_until = NULL", "check_next_due_at = NULL", "check_compiled_at = NULL", "check_false_since_at = NULL", "check_last_liveness_at = NULL");
|
|
8410
8659
|
}
|
|
@@ -9316,25 +9565,31 @@ var ERROR_CLASSES = new Set([
|
|
|
9316
9565
|
]);
|
|
9317
9566
|
// src/hooks/magic-context/child-session-spawn.ts
|
|
9318
9567
|
var STALE_PLUGIN_RESTART_NOTICE = "Magic Context: plugin build is older than its database — restart OpenCode";
|
|
9319
|
-
|
|
9568
|
+
var SCHEMA_PROBE_FAILURE_NOTICE = `Magic Context: unable to verify the database schema before spawning a child — run ${FAIL_CLOSED_DOCTOR_COMMAND}`;
|
|
9569
|
+
async function surfaceSchemaFenceFailure(args, failure) {
|
|
9320
9570
|
if (!args.parentSessionId)
|
|
9321
9571
|
return;
|
|
9322
|
-
|
|
9323
|
-
|
|
9572
|
+
const notice = failure.reason === "read_error" ? SCHEMA_PROBE_FAILURE_NOTICE : STALE_PLUGIN_RESTART_NOTICE;
|
|
9573
|
+
if (args.db) {
|
|
9574
|
+
try {
|
|
9324
9575
|
updateSessionMeta(args.db, args.parentSessionId, {
|
|
9325
|
-
lastTransformError:
|
|
9576
|
+
lastTransformError: notice
|
|
9326
9577
|
});
|
|
9578
|
+
} catch (error) {
|
|
9579
|
+
sessionLog(args.parentSessionId, `schema-fence warning persistence failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
9327
9580
|
}
|
|
9581
|
+
}
|
|
9582
|
+
try {
|
|
9328
9583
|
pushNotification("toast", {
|
|
9329
9584
|
title: "Magic Context",
|
|
9330
|
-
message:
|
|
9585
|
+
message: notice,
|
|
9331
9586
|
variant: "error",
|
|
9332
9587
|
duration: 1e4
|
|
9333
9588
|
}, args.parentSessionId);
|
|
9334
9589
|
pushNotification("action", { action: "refresh-sidebar" }, args.parentSessionId);
|
|
9335
|
-
await sendIgnoredMessage(args.client, args.parentSessionId,
|
|
9590
|
+
await sendIgnoredMessage(args.client, args.parentSessionId, notice, args.notificationParams ?? {}, true);
|
|
9336
9591
|
} catch (error) {
|
|
9337
|
-
sessionLog(args.parentSessionId, `
|
|
9592
|
+
sessionLog(args.parentSessionId, `schema-fence warning delivery failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
9338
9593
|
}
|
|
9339
9594
|
}
|
|
9340
9595
|
async function createChildSessionWithFence(args) {
|
|
@@ -9347,7 +9602,7 @@ async function createChildSessionWithFence(args) {
|
|
|
9347
9602
|
if (args.onFenceLatched)
|
|
9348
9603
|
await args.onFenceLatched(verdict.failure);
|
|
9349
9604
|
else
|
|
9350
|
-
await
|
|
9605
|
+
await surfaceSchemaFenceFailure(args, verdict.failure);
|
|
9351
9606
|
}
|
|
9352
9607
|
return null;
|
|
9353
9608
|
}
|
|
@@ -9764,11 +10019,21 @@ function normalizeSDKResponse(response, fallback, options) {
|
|
|
9764
10019
|
return fallback;
|
|
9765
10020
|
}
|
|
9766
10021
|
// src/shared/prompt-surface.ts
|
|
10022
|
+
function promptSurfaceConfigIdentity(config) {
|
|
10023
|
+
return JSON.stringify({
|
|
10024
|
+
default: config?.default ?? "full",
|
|
10025
|
+
models: Object.entries(config?.models ?? {}).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0),
|
|
10026
|
+
guidanceOverridePath: config?.guidance_override_path ?? null,
|
|
10027
|
+
toolDescriptions: Object.entries(config?.tool_descriptions ?? {}).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0)
|
|
10028
|
+
});
|
|
10029
|
+
}
|
|
9767
10030
|
function isValidPromptSurfaceModelKey(key) {
|
|
9768
10031
|
if (key.length === 0 || key.trim() !== key)
|
|
9769
10032
|
return false;
|
|
9770
10033
|
const slash = key.indexOf("/");
|
|
9771
|
-
if (slash
|
|
10034
|
+
if (slash < 0)
|
|
10035
|
+
return !key.includes("*");
|
|
10036
|
+
if (slash === 0 || slash === key.length - 1)
|
|
9772
10037
|
return false;
|
|
9773
10038
|
const provider = key.slice(0, slash);
|
|
9774
10039
|
const modelID = key.slice(slash + 1);
|
|
@@ -9819,7 +10084,7 @@ function resolveModelConfigValue(values, modelKey) {
|
|
|
9819
10084
|
function resolvePromptSurface(config, modelKey) {
|
|
9820
10085
|
const fallback = config?.default ?? "full";
|
|
9821
10086
|
const match = resolveModelConfigValue(config?.models, modelKey);
|
|
9822
|
-
if (match
|
|
10087
|
+
if (match) {
|
|
9823
10088
|
return { preset: match.value, source: match.source };
|
|
9824
10089
|
}
|
|
9825
10090
|
return { preset: fallback, source: "default" };
|
|
@@ -10219,7 +10484,7 @@ var CTX_SEARCH_LIGHT_DESCRIPTION = `For ctx_search users, retrieve only hidden r
|
|
|
10219
10484
|
// src/shared/prompt-surface-runtime.ts
|
|
10220
10485
|
var GUIDANCE_MARKER = "## Magic Context";
|
|
10221
10486
|
var GUIDANCE_MARKER_LINE = /^## Magic Context[\t ]*\r?$/gm;
|
|
10222
|
-
var
|
|
10487
|
+
var ACTIVE_TOOL_IDS = [
|
|
10223
10488
|
"ctx_reduce",
|
|
10224
10489
|
"ctx_expand",
|
|
10225
10490
|
"ctx_note",
|
|
@@ -10237,7 +10502,7 @@ function promptSurfaceHashMaterial(systemContent, preset = "full") {
|
|
|
10237
10502
|
return preset === "full" ? systemContent : `${systemContent}
|
|
10238
10503
|
\x00magic-context-prompt-surface:${preset}`;
|
|
10239
10504
|
}
|
|
10240
|
-
var PROMPT_SURFACE_TOOL_ID_SET = new Set(
|
|
10505
|
+
var PROMPT_SURFACE_TOOL_ID_SET = new Set(ACTIVE_TOOL_IDS);
|
|
10241
10506
|
function resolveUserConfigDirectory(options) {
|
|
10242
10507
|
if (options.userConfigDirectory)
|
|
10243
10508
|
return resolve(options.userConfigDirectory);
|
|
@@ -26783,14 +27048,14 @@ var PiConfigSchema = exports_external.object({
|
|
|
26783
27048
|
}).optional();
|
|
26784
27049
|
var PromptSurfacePresetSchema = exports_external.enum(["full", "light"]);
|
|
26785
27050
|
var PromptSurfaceModelKeySchema = exports_external.string().refine(isValidPromptSurfaceModelKey, {
|
|
26786
|
-
message: "Use a non-empty provider/model key or the literal provider/* wildcard; model IDs may contain additional slashes and matching is case-sensitive."
|
|
27051
|
+
message: "Use a non-empty bare model key, provider/model key, or the literal provider/* wildcard; model IDs may contain additional slashes and matching is case-sensitive."
|
|
26787
27052
|
});
|
|
26788
27053
|
var PromptSurfaceToolKeySchema = exports_external.string().refine((value) => value.trim().length > 0, {
|
|
26789
27054
|
message: "tool description keys must not be empty or whitespace-only"
|
|
26790
27055
|
});
|
|
26791
27056
|
var PromptSurfaceConfigSchema = exports_external.object({
|
|
26792
27057
|
default: PromptSurfacePresetSchema.default("full").describe('Fallback prompt-surface preset ("full" or "light").'),
|
|
26793
|
-
models: exports_external.record(PromptSurfaceModelKeySchema, PromptSurfacePresetSchema).optional().describe("Literal per-model routing. Keys are provider/model or provider/*; matching is case-sensitive and preserves additional slashes in model IDs."),
|
|
27058
|
+
models: exports_external.record(PromptSurfaceModelKeySchema, PromptSurfacePresetSchema).optional().describe("Literal per-model routing. Keys are bare model IDs, provider/model, or provider/*; matching is case-sensitive and preserves additional slashes in model IDs."),
|
|
26794
27059
|
guidance_override_path: exports_external.string().refine((value) => value.trim().length > 0, {
|
|
26795
27060
|
message: "guidance_override_path must not be empty or whitespace-only"
|
|
26796
27061
|
}).optional().describe("USER-LEVEL ONLY path to a complete primary guidance section. Relative paths resolve from the user config file."),
|
|
@@ -26979,8 +27244,11 @@ var MagicContextConfigSchema = exports_external.object({
|
|
|
26979
27244
|
language: exports_external.string().trim().toLowerCase().refine((s) => isValidLanguageCode(s), 'language must be a 2-letter ISO 639-1 code (e.g. "tr", "es", "de")').optional().describe("Output language for Magic Context's generated content and guidance, as a " + '2-letter ISO 639-1 code (e.g. "tr", "es", "de", "ja", "pt"). When set, the ' + "historian, dreamer, sidekick, and the agent-guidance block instruct the model to " + "write its PROSE in this language while keeping all structural tokens (XML tags, " + "the five memory category names, code identifiers, file paths) in English. " + "USER-LEVEL ONLY (ignored in project config for security). Unset = today's " + "behavior (model mirrors the conversation; English scaffolding). Changing it " + "triggers one cache re-materialization; existing compartments/memories keep their " + "original language until naturally rewritten."),
|
|
26980
27245
|
historian: HistorianConfigSchema.describe("Historian agent configuration (model, fallback_models, variant, temperature, maxTokens, permission, two_pass, etc.)"),
|
|
26981
27246
|
dreamer: DreamerConfigSchema.optional().describe("Dreamer agent + scheduling configuration (model, fallback_models, disable, schedule, tasks, etc.)"),
|
|
27247
|
+
smart_notes: exports_external.object({
|
|
27248
|
+
retina_handoff: exports_external.boolean().default(false).describe("When true, dreamer skips smart notes whose surface conditions compiled to retina provider configs at authoring time. Default false keeps both paths active until the retina consumer is deployed.")
|
|
27249
|
+
}).default({ retina_handoff: false }).describe("Smart-note ownership transition controls."),
|
|
26982
27250
|
cache_ttl: exports_external.union([exports_external.string(), exports_external.object({ default: exports_external.string() }).catchall(exports_external.string())]).default("5m").describe('Cache TTL: string (e.g. "5m", "1h", "30s") or per-model object ({ default: "5m", "model-id": "10m" }). Set to "never" for lanes kept warm by an external keepwarm proxy — disables the idle-TTL heuristic so MC never initiates a rebuild based on elapsed time.'),
|
|
26983
|
-
prompt_surface: PromptSurfaceConfigSchema.default({ default: "full" }).describe("Prompt-surface presets: default is full; models use
|
|
27251
|
+
prompt_surface: PromptSurfaceConfigSchema.default({ default: "full" }).describe("Prompt-surface presets: default is full; models use bare model IDs, provider/model, or provider/* routing keys. Guidance and tool-description overrides are user-level only. On OpenCode and Pi, per-model routing applies to the guidance block only: tool descriptions are registered once per process, so they follow the default preset (a v1 plugin-surface limitation; per-model tool descriptions are planned for the OpenCode v2 plugin API once the SDK stabilizes)."),
|
|
26984
27252
|
output_reserve: exports_external.union([
|
|
26985
27253
|
exports_external.number().min(0),
|
|
26986
27254
|
exports_external.object({ default: exports_external.number().min(0) }).catchall(exports_external.number().min(0))
|
|
@@ -31356,7 +31624,11 @@ function registerProjectShadowEmbedding(db, projectIdentity, config2, sourceDire
|
|
|
31356
31624
|
const prior = shadowRegistrations.get(projectIdentity);
|
|
31357
31625
|
if (prior && prior.providerIdentity === providerIdentity) {
|
|
31358
31626
|
provider.dispose();
|
|
31627
|
+
dbForShadowQueue.set(projectIdentity, db);
|
|
31359
31628
|
persistShadowDescriptor(db, prior);
|
|
31629
|
+
const backfillAlreadyArmed = hasPendingShadowBackfill(projectIdentity) || shadowQueue.some((item) => item.projectIdentity === projectIdentity);
|
|
31630
|
+
if (!backfillAlreadyArmed)
|
|
31631
|
+
maybeArmShadowBackfill(db, projectIdentity, prior);
|
|
31360
31632
|
return {
|
|
31361
31633
|
...snapshotFor({
|
|
31362
31634
|
projectIdentity,
|
|
@@ -35976,24 +36248,52 @@ class BoundedSessionMap {
|
|
|
35976
36248
|
// src/hooks/magic-context/compartment-render-epoch.ts
|
|
35977
36249
|
var COMPARTMENT_RENDER_EPOCH = "cre2";
|
|
35978
36250
|
var EPOCH_COMPONENT_PREFIX = "|compartment-render:";
|
|
35979
|
-
|
|
35980
|
-
|
|
35981
|
-
|
|
35982
|
-
|
|
36251
|
+
var MURAL_COMPONENT_PREFIX = "|mural-enabled:";
|
|
36252
|
+
var BUDGET_COMPONENT_PREFIX = "|render-budgets:";
|
|
36253
|
+
function encodeCachedM0UpgradeIdentity(upgradeState, compartmentRenderEpoch = COMPARTMENT_RENDER_EPOCH, muralEnabled = null, renderBudgetIdentity = null) {
|
|
36254
|
+
let encoded = upgradeState ?? "";
|
|
36255
|
+
if (compartmentRenderEpoch !== null) {
|
|
36256
|
+
encoded += `${EPOCH_COMPONENT_PREFIX}${compartmentRenderEpoch}`;
|
|
36257
|
+
}
|
|
36258
|
+
if (muralEnabled !== null) {
|
|
36259
|
+
encoded += `${MURAL_COMPONENT_PREFIX}${muralEnabled ? "1" : "0"}`;
|
|
36260
|
+
}
|
|
36261
|
+
if (renderBudgetIdentity !== null) {
|
|
36262
|
+
encoded += `${BUDGET_COMPONENT_PREFIX}${renderBudgetIdentity}`;
|
|
36263
|
+
}
|
|
36264
|
+
return encoded.length > 0 ? encoded : null;
|
|
36265
|
+
}
|
|
36266
|
+
function component(value, prefix) {
|
|
36267
|
+
const start = value.lastIndexOf(prefix);
|
|
36268
|
+
if (start < 0)
|
|
36269
|
+
return null;
|
|
36270
|
+
const valueStart = start + prefix.length;
|
|
36271
|
+
const end = value.indexOf("|", valueStart);
|
|
36272
|
+
const result = value.slice(valueStart, end < 0 ? value.length : end);
|
|
36273
|
+
return result.length > 0 ? result : null;
|
|
35983
36274
|
}
|
|
35984
36275
|
function decodeCachedM0UpgradeIdentity(value) {
|
|
35985
36276
|
if (value === null) {
|
|
35986
|
-
return {
|
|
35987
|
-
|
|
35988
|
-
|
|
35989
|
-
|
|
35990
|
-
|
|
36277
|
+
return {
|
|
36278
|
+
upgradeState: null,
|
|
36279
|
+
compartmentRenderEpoch: null,
|
|
36280
|
+
muralEnabled: null,
|
|
36281
|
+
renderBudgetIdentity: null
|
|
36282
|
+
};
|
|
35991
36283
|
}
|
|
35992
|
-
const
|
|
35993
|
-
|
|
36284
|
+
const componentIndexes = [
|
|
36285
|
+
value.indexOf(EPOCH_COMPONENT_PREFIX),
|
|
36286
|
+
value.indexOf(MURAL_COMPONENT_PREFIX),
|
|
36287
|
+
value.indexOf(BUDGET_COMPONENT_PREFIX)
|
|
36288
|
+
].filter((index) => index >= 0);
|
|
36289
|
+
const identityEnd = componentIndexes.length > 0 ? Math.min(...componentIndexes) : value.length;
|
|
36290
|
+
const upgradeState = value.slice(0, identityEnd);
|
|
36291
|
+
const muralComponent = component(value, MURAL_COMPONENT_PREFIX);
|
|
35994
36292
|
return {
|
|
35995
36293
|
upgradeState: upgradeState.length > 0 ? upgradeState : null,
|
|
35996
|
-
compartmentRenderEpoch:
|
|
36294
|
+
compartmentRenderEpoch: component(value, EPOCH_COMPONENT_PREFIX),
|
|
36295
|
+
muralEnabled: muralComponent === "1" ? true : muralComponent === "0" ? false : null,
|
|
36296
|
+
renderBudgetIdentity: component(value, BUDGET_COMPONENT_PREFIX)
|
|
35997
36297
|
};
|
|
35998
36298
|
}
|
|
35999
36299
|
|
|
@@ -36680,6 +36980,9 @@ function lastCompartmentBoundaryId(compartments) {
|
|
|
36680
36980
|
}
|
|
36681
36981
|
var DEFAULT_HISTORY_BUDGET_TOKENS = 60000;
|
|
36682
36982
|
var DEFAULT_MEMORY_BUDGET_TOKENS = 8000;
|
|
36983
|
+
function renderBudgetIdentity(memoryBudget, historyBudget) {
|
|
36984
|
+
return `m${memoryBudget ?? DEFAULT_MEMORY_BUDGET_TOKENS}-h${historyBudget ?? DEFAULT_HISTORY_BUDGET_TOKENS}`;
|
|
36985
|
+
}
|
|
36683
36986
|
var DEFAULT_USER_PROFILE_BUDGET_TOKENS = 4000;
|
|
36684
36987
|
var MAX_FORCED_MEMORIES_PER_DELTA = 10;
|
|
36685
36988
|
var M0_EMPTY_BODY = "<session-history></session-history>";
|
|
@@ -36953,7 +37256,9 @@ function readCurrentM0SnapshotMarkersUncached(args) {
|
|
|
36953
37256
|
compartmentRenderEpoch: COMPARTMENT_RENDER_EPOCH,
|
|
36954
37257
|
systemHash: hard.systemHash,
|
|
36955
37258
|
modelKey: hard.modelKey,
|
|
36956
|
-
projectIdentity: args.projectPath ?? null
|
|
37259
|
+
projectIdentity: args.projectPath ?? null,
|
|
37260
|
+
muralEnabled: args.muralEnabled === true,
|
|
37261
|
+
renderBudgetIdentity: renderBudgetIdentity(args.memoryInjectionBudgetTokens, args.historyBudgetTokens)
|
|
36957
37262
|
}
|
|
36958
37263
|
};
|
|
36959
37264
|
}
|
|
@@ -36966,7 +37271,9 @@ function refreshVolatileMarkerInputs(markers, args) {
|
|
|
36966
37271
|
materializedAt: Date.now(),
|
|
36967
37272
|
systemHash: hard.systemHash,
|
|
36968
37273
|
modelKey: hard.modelKey,
|
|
36969
|
-
projectIdentity: args.projectPath ?? null
|
|
37274
|
+
projectIdentity: args.projectPath ?? null,
|
|
37275
|
+
muralEnabled: args.muralEnabled === true,
|
|
37276
|
+
renderBudgetIdentity: renderBudgetIdentity(args.memoryInjectionBudgetTokens, args.historyBudgetTokens)
|
|
36970
37277
|
};
|
|
36971
37278
|
}
|
|
36972
37279
|
function readCurrentM0SnapshotMarkers(args) {
|
|
@@ -37032,7 +37339,9 @@ function snapshotMarkersFromCachedM0(state2) {
|
|
|
37032
37339
|
systemHash: state2.cachedM0SystemHash ?? "",
|
|
37033
37340
|
modelKey: state2.cachedM0ModelKey ?? "",
|
|
37034
37341
|
projectIdentity: state2.cachedM0ProjectIdentity ?? null,
|
|
37035
|
-
muralHash: state2.cachedM0MuralHash ?? null
|
|
37342
|
+
muralHash: state2.cachedM0MuralHash ?? null,
|
|
37343
|
+
muralEnabled: cachedUpgradeIdentity.muralEnabled,
|
|
37344
|
+
renderBudgetIdentity: cachedUpgradeIdentity.renderBudgetIdentity
|
|
37036
37345
|
};
|
|
37037
37346
|
}
|
|
37038
37347
|
function mustMaterialize(args) {
|
|
@@ -37046,6 +37355,9 @@ function mustMaterialize(args) {
|
|
|
37046
37355
|
if (cachedUpgradeIdentity.compartmentRenderEpoch !== current.compartmentRenderEpoch) {
|
|
37047
37356
|
return { value: true, reason: "compartment_render_epoch" };
|
|
37048
37357
|
}
|
|
37358
|
+
if (cachedUpgradeIdentity.muralEnabled !== null && cachedUpgradeIdentity.muralEnabled !== current.muralEnabled || cachedUpgradeIdentity.renderBudgetIdentity !== null && cachedUpgradeIdentity.renderBudgetIdentity !== current.renderBudgetIdentity) {
|
|
37359
|
+
return { value: true, reason: "render_config" };
|
|
37360
|
+
}
|
|
37049
37361
|
if (hard.modelKey !== "" && hard.modelKey !== (args.state.cachedM0ModelKey ?? "")) {
|
|
37050
37362
|
return { value: true, reason: "model_change" };
|
|
37051
37363
|
}
|
|
@@ -37362,7 +37674,7 @@ function applyMarkersToState(state2, m0Bytes, markers, m1Bytes) {
|
|
|
37362
37674
|
state2.cachedM0ProjectDocsHash = markers.projectDocsHash;
|
|
37363
37675
|
state2.cachedM0MaterializedAt = markers.materializedAt;
|
|
37364
37676
|
state2.cachedM0SessionFactsVersion = markers.sessionFactsVersion;
|
|
37365
|
-
state2.cachedM0UpgradeState = encodeCachedM0UpgradeIdentity(markers.upgradeState, markers.compartmentRenderEpoch);
|
|
37677
|
+
state2.cachedM0UpgradeState = encodeCachedM0UpgradeIdentity(markers.upgradeState, markers.compartmentRenderEpoch, markers.muralEnabled, markers.renderBudgetIdentity);
|
|
37366
37678
|
state2.cachedM0SystemHash = markers.systemHash;
|
|
37367
37679
|
state2.cachedM0ModelKey = markers.modelKey;
|
|
37368
37680
|
state2.cachedM0ProjectIdentity = markers.projectIdentity;
|
|
@@ -37409,6 +37721,9 @@ function materializeM0(options) {
|
|
|
37409
37721
|
projectPath,
|
|
37410
37722
|
projectDirectory,
|
|
37411
37723
|
injectDocs: options.injectDocs,
|
|
37724
|
+
muralEnabled: options.muralEnabled,
|
|
37725
|
+
memoryInjectionBudgetTokens: options.memoryInjectionBudgetTokens,
|
|
37726
|
+
historyBudgetTokens: options.historyBudgetTokens,
|
|
37412
37727
|
hardSignals: options.hardSignals,
|
|
37413
37728
|
workspaceIdentitySet: {
|
|
37414
37729
|
identities: workspace.identities,
|
|
@@ -37504,7 +37819,9 @@ function materializeM0(options) {
|
|
|
37504
37819
|
compartmentRenderEpoch: COMPARTMENT_RENDER_EPOCH,
|
|
37505
37820
|
systemHash: snapshotMarkers.systemHash,
|
|
37506
37821
|
modelKey: snapshotMarkers.modelKey,
|
|
37507
|
-
projectIdentity: projectPath ?? null
|
|
37822
|
+
projectIdentity: projectPath ?? null,
|
|
37823
|
+
muralEnabled: snapshotMarkers.muralEnabled,
|
|
37824
|
+
renderBudgetIdentity: snapshotMarkers.renderBudgetIdentity
|
|
37508
37825
|
};
|
|
37509
37826
|
const memoryEpochStale = current.workspaceFingerprint !== null || snapshotMarkers.workspaceFingerprint !== null ? current.workspaceFingerprint !== snapshotMarkers.workspaceFingerprint : current.projectMemoryEpoch !== snapshotMarkers.projectMemoryEpoch;
|
|
37510
37827
|
const stale = memoryEpochStale || current.projectUserProfileVersion !== snapshotMarkers.projectUserProfileVersion || current.maxCompartmentSeq !== snapshotMarkers.maxCompartmentSeq || current.maxMutationId !== snapshotMarkers.maxMutationId || current.maxMemoryMutationId !== snapshotMarkers.maxMemoryMutationId || current.sessionFactsVersion !== snapshotMarkers.sessionFactsVersion || current.upgradeState !== snapshotMarkers.upgradeState || (current.projectIdentity ?? null) !== (snapshotMarkers.projectIdentity ?? null);
|
|
@@ -37539,7 +37856,7 @@ function materializeM0(options) {
|
|
|
37539
37856
|
projectDocsHash: snapshotMarkers.projectDocsHash,
|
|
37540
37857
|
materializedAt: snapshotMarkers.materializedAt,
|
|
37541
37858
|
sessionFactsVersion: snapshotMarkers.sessionFactsVersion,
|
|
37542
|
-
upgradeState: encodeCachedM0UpgradeIdentity(snapshotMarkers.upgradeState, snapshotMarkers.compartmentRenderEpoch),
|
|
37859
|
+
upgradeState: encodeCachedM0UpgradeIdentity(snapshotMarkers.upgradeState, snapshotMarkers.compartmentRenderEpoch, snapshotMarkers.muralEnabled, snapshotMarkers.renderBudgetIdentity),
|
|
37543
37860
|
systemHash: snapshotMarkers.systemHash,
|
|
37544
37861
|
modelKey: snapshotMarkers.modelKey,
|
|
37545
37862
|
projectIdentity: snapshotMarkers.projectIdentity
|
|
@@ -37779,7 +38096,9 @@ function markersFromCachedRow(row) {
|
|
|
37779
38096
|
systemHash: row.cached_m0_system_hash ?? "",
|
|
37780
38097
|
modelKey: row.cached_m0_model_key ?? "",
|
|
37781
38098
|
projectIdentity: row.cached_m0_project_identity ?? null,
|
|
37782
|
-
muralHash: row.cached_m0_mural_hash ?? null
|
|
38099
|
+
muralHash: row.cached_m0_mural_hash ?? null,
|
|
38100
|
+
muralEnabled: cachedUpgradeIdentity.muralEnabled,
|
|
38101
|
+
renderBudgetIdentity: cachedUpgradeIdentity.renderBudgetIdentity
|
|
37783
38102
|
};
|
|
37784
38103
|
}
|
|
37785
38104
|
function cachedRowMatchesState(row, state2) {
|
|
@@ -37804,7 +38123,7 @@ function applyCachedRowToState(state2, row) {
|
|
|
37804
38123
|
state2.cachedM0ProjectDocsHash = markers.projectDocsHash;
|
|
37805
38124
|
state2.cachedM0MaterializedAt = markers.materializedAt;
|
|
37806
38125
|
state2.cachedM0SessionFactsVersion = markers.sessionFactsVersion;
|
|
37807
|
-
state2.cachedM0UpgradeState = encodeCachedM0UpgradeIdentity(markers.upgradeState, markers.compartmentRenderEpoch);
|
|
38126
|
+
state2.cachedM0UpgradeState = encodeCachedM0UpgradeIdentity(markers.upgradeState, markers.compartmentRenderEpoch, markers.muralEnabled, markers.renderBudgetIdentity);
|
|
37808
38127
|
state2.cachedM0SystemHash = markers.systemHash;
|
|
37809
38128
|
state2.cachedM0ModelKey = markers.modelKey;
|
|
37810
38129
|
state2.cachedM0ProjectIdentity = markers.projectIdentity;
|
|
@@ -37890,6 +38209,10 @@ function renderFreshM0NonPersisted(options) {
|
|
|
37890
38209
|
projectPath,
|
|
37891
38210
|
projectDirectory,
|
|
37892
38211
|
injectDocs: options.injectDocs,
|
|
38212
|
+
muralEnabled: options.muralEnabled,
|
|
38213
|
+
memoryInjectionBudgetTokens: options.memoryInjectionBudgetTokens,
|
|
38214
|
+
historyBudgetTokens: options.historyBudgetTokens,
|
|
38215
|
+
hardSignals: options.hardSignals,
|
|
37893
38216
|
workspaceIdentitySet: {
|
|
37894
38217
|
identities: workspace.identities,
|
|
37895
38218
|
namesByIdentity: workspace.namesByIdentity
|
|
@@ -37986,7 +38309,10 @@ function injectM0M1(options) {
|
|
|
37986
38309
|
projectDirectory: options.projectDirectory,
|
|
37987
38310
|
hardSignals: options.hardSignals,
|
|
37988
38311
|
workspaceIdentitySet: options.workspaceIdentitySet,
|
|
37989
|
-
injectDocs: options.injectDocs
|
|
38312
|
+
injectDocs: options.injectDocs,
|
|
38313
|
+
muralEnabled: options.muralEnabled,
|
|
38314
|
+
memoryInjectionBudgetTokens: options.memoryInjectionBudgetTokens,
|
|
38315
|
+
historyBudgetTokens: options.historyBudgetTokens
|
|
37990
38316
|
});
|
|
37991
38317
|
let rematerialized = false;
|
|
37992
38318
|
let contentionExhausted = false;
|
|
@@ -41941,52 +42267,69 @@ function slotBytes(slot) {
|
|
|
41941
42267
|
const digestBytes = slot.inputContentDigests.reduce((total, digest) => total + 2 * digest.length, 0);
|
|
41942
42268
|
return 2 * slot.jsonPrefix.length + digestBytes + LKG_METADATA_BYTES;
|
|
41943
42269
|
}
|
|
41944
|
-
|
|
41945
|
-
|
|
42270
|
+
var LKG_SNAPSHOT_ARRAY = Symbol("array");
|
|
42271
|
+
var LKG_SNAPSHOT_OBJECT = Symbol("object");
|
|
42272
|
+
var LKG_SNAPSHOT_KEY = Symbol("key");
|
|
42273
|
+
var LKG_SNAPSHOT_STRING = Symbol("string");
|
|
42274
|
+
var LKG_SNAPSHOT_NUMBER = Symbol("number");
|
|
42275
|
+
var LKG_SNAPSHOT_BOOLEAN = Symbol("boolean");
|
|
42276
|
+
var LKG_SNAPSHOT_NULL = Symbol("null");
|
|
42277
|
+
var LKG_SNAPSHOT_UNDEFINED = Symbol("undefined");
|
|
42278
|
+
function lkgContentFields(value) {
|
|
42279
|
+
const fields = [];
|
|
41946
42280
|
const seen = new WeakSet;
|
|
41947
|
-
const visit = (
|
|
41948
|
-
if (
|
|
41949
|
-
|
|
41950
|
-
|
|
41951
|
-
|
|
41952
|
-
|
|
41953
|
-
|
|
41954
|
-
|
|
41955
|
-
|
|
41956
|
-
|
|
41957
|
-
|
|
41958
|
-
} else if (Array.isArray(
|
|
41959
|
-
if (seen.has(
|
|
42281
|
+
const visit = (child) => {
|
|
42282
|
+
if (child === null)
|
|
42283
|
+
fields.push(LKG_SNAPSHOT_NULL);
|
|
42284
|
+
else if (typeof child === "string")
|
|
42285
|
+
fields.push(LKG_SNAPSHOT_STRING, child);
|
|
42286
|
+
else if (typeof child === "number")
|
|
42287
|
+
fields.push(LKG_SNAPSHOT_NUMBER, child);
|
|
42288
|
+
else if (typeof child === "boolean")
|
|
42289
|
+
fields.push(LKG_SNAPSHOT_BOOLEAN, child);
|
|
42290
|
+
else if (child === undefined || typeof child === "function" || typeof child === "symbol") {
|
|
42291
|
+
fields.push(LKG_SNAPSHOT_UNDEFINED);
|
|
42292
|
+
} else if (Array.isArray(child)) {
|
|
42293
|
+
if (seen.has(child))
|
|
41960
42294
|
throw new Error("cyclic message");
|
|
41961
|
-
seen.add(
|
|
41962
|
-
|
|
41963
|
-
for (const
|
|
41964
|
-
visit(
|
|
41965
|
-
|
|
41966
|
-
|
|
41967
|
-
|
|
41968
|
-
if (seen.has(value))
|
|
42295
|
+
seen.add(child);
|
|
42296
|
+
fields.push(LKG_SNAPSHOT_ARRAY, child.length);
|
|
42297
|
+
for (const item of child)
|
|
42298
|
+
visit(item);
|
|
42299
|
+
seen.delete(child);
|
|
42300
|
+
} else if (typeof child === "object") {
|
|
42301
|
+
if (seen.has(child))
|
|
41969
42302
|
throw new Error("cyclic message");
|
|
41970
|
-
seen.add(
|
|
41971
|
-
const entries = Object.entries(
|
|
41972
|
-
|
|
41973
|
-
for (const [key,
|
|
41974
|
-
|
|
41975
|
-
visit(
|
|
41976
|
-
}
|
|
41977
|
-
|
|
41978
|
-
|
|
41979
|
-
|
|
41980
|
-
hash2.update(`X${typeof value};`);
|
|
41981
|
-
}
|
|
42303
|
+
seen.add(child);
|
|
42304
|
+
const entries = Object.entries(child).filter(([, entry]) => entry !== undefined && typeof entry !== "function" && typeof entry !== "symbol");
|
|
42305
|
+
fields.push(LKG_SNAPSHOT_OBJECT, entries.length);
|
|
42306
|
+
for (const [key, entry] of entries) {
|
|
42307
|
+
fields.push(LKG_SNAPSHOT_KEY, key);
|
|
42308
|
+
visit(entry);
|
|
42309
|
+
}
|
|
42310
|
+
seen.delete(child);
|
|
42311
|
+
} else
|
|
42312
|
+
fields.push(LKG_SNAPSHOT_UNDEFINED);
|
|
41982
42313
|
};
|
|
41983
42314
|
try {
|
|
41984
|
-
visit(
|
|
41985
|
-
return
|
|
42315
|
+
visit(value);
|
|
42316
|
+
return fields;
|
|
41986
42317
|
} catch {
|
|
41987
42318
|
return null;
|
|
41988
42319
|
}
|
|
41989
42320
|
}
|
|
42321
|
+
function lkgContentDigestFromFields(fields) {
|
|
42322
|
+
const hash2 = createHash15("sha256");
|
|
42323
|
+
for (const field of fields) {
|
|
42324
|
+
const value = typeof field === "symbol" ? field.description ?? "" : String(field);
|
|
42325
|
+
hash2.update(`${typeof field}:${value.length}:`).update(value).update("\x00");
|
|
42326
|
+
}
|
|
42327
|
+
return hash2.digest("base64url");
|
|
42328
|
+
}
|
|
42329
|
+
function lkgContentDigest(message) {
|
|
42330
|
+
const fields = lkgContentFields(message);
|
|
42331
|
+
return fields ? lkgContentDigestFromFields(fields) : null;
|
|
42332
|
+
}
|
|
41990
42333
|
function touch(sessionId, entry) {
|
|
41991
42334
|
slots.delete(sessionId);
|
|
41992
42335
|
slots.set(sessionId, entry);
|
|
@@ -41999,6 +42342,9 @@ function captureSlot(sessionId, slot) {
|
|
|
41999
42342
|
if (bytes > LKG_SINGLE_SLOT_BYTES)
|
|
42000
42343
|
return false;
|
|
42001
42344
|
const prior = slots.get(sessionId);
|
|
42345
|
+
if (prior?.slot.rowVersion !== undefined && slot.rowVersion !== undefined && (slot.rowVersion < prior.slot.rowVersion || slot.rowVersion === prior.slot.rowVersion && (slot.captureSequence ?? 0) < (prior.slot.captureSequence ?? 0))) {
|
|
42346
|
+
return false;
|
|
42347
|
+
}
|
|
42002
42348
|
if (prior)
|
|
42003
42349
|
totalBytes -= prior.bytes;
|
|
42004
42350
|
slots.delete(sessionId);
|
|
@@ -42308,4 +42654,4 @@ async function runUpgradeMemoryMigration(ctx, sessionId, migrationDirectory) {
|
|
|
42308
42654
|
}
|
|
42309
42655
|
}
|
|
42310
42656
|
|
|
42311
|
-
export { withContentLanguageDirective, buildPrimaryLanguageDirective, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, resolveLegacyConfigSourcesForHarness, migrateMagicContextConfigLocations, exports_external, DEFAULT_PROTECTED_TAGS, parseCron, nextOccurrence, nextDueAtMs, resolvePromptSurface, resolveModelConfigOrDefault, DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE, DEFAULT_HISTORIAN_TIMEOUT_MS, DEFAULT_LOCAL_EMBEDDING_MODEL, MagicContextConfigSchema, getOpenCodeDbPath, removeMcOwnedCompactionMarkers, ProjectIdentityError, resolveProjectIdentityStrict, takeDubiousOwnershipProjectIdentityWarning, resolveProjectIdentity, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, recordSessionProjectIdentity, beginBootQuietPeriod, bootQuietRemainingMs, scheduleAfterBootQuiet, rpcPortDir, rpcPortFilePath, isPidAlive, parseRpcPortFile, registerModuleNoteEvaluationBridge, getModuleNoteEvaluationBridge, getContextStoreUuid, ensureContextStoreUuid, getAuthorityManagedMarker, reconcileAuthorityProject, checksumAuthoritySeedRows, prepareAuthority, drainAuthority, getMirrorCursor, applyMirrorPage, pullMemoryMirrorOnce, V2_MEMORY_CATEGORIES, CATEGORY_PRIORITY, resolveWorkspaceShareCategories, resolveWorkspaceIdentitySet, expandWorkspaceIdentitySetWithAliases, resolveStoredPathWorkspaceIdentity, storedPathBelongsToWorkspace, sourceNameForMemory, computeWorkspaceEpochFingerprint, recordToolDefinition, getMeasuredToolDefinitionTokens, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, runSqliteOptimize, openDatabase, openDatabaseAsync, isDatabasePersisted, getDatabasePersistenceError, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, clearRecompStaging, recordEmbeddingMeasurement, getMaxM0MutationId, queueMemoryMutation, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationIdForProjects, MAX_EXECUTE_THRESHOLD, escalationBands, isEmergencyRecoveryArmed, isProviderOverflowReconfirmed, getEmergencyRecoveryArmedAt, loadPersistedUsage, loadProtectedTailMeta, resetProtectedTailNoEligibleHead, getWrapupInProgressState, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, getPersistedReasoningWatermark, setPersistedReasoningWatermark, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getLastNudgeLevel, setLastNudgeLevel, resetLastNudgeCycle, resetLastNudgeCycleIfTailShrank, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, getNoteNudgeAnchors, getAutoSearchHintDecisions, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, pruneAutoSearchHintDecisions, removeNoteNudgeAnchorByMessageId, removeAutoSearchHintDecisionByMessageId, getPersistedTodoPermissionDenied, setPersistedTodoPermissionDenied, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, setNoteLastReadAt, getHistorianFailureState, clearHistorianFailureState, getOverflowState, recordOverflowDetected, recordDetectedContextLimit, clearEmergencyRecovery, clearDetectedContextLimit, getPersistedCompactionMarkerState, setPersistedCompactionMarkerState, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, removeStrippedPlaceholderId, getStaleReduceStrippedIds, addStaleReduceStrippedIds, getProcessedImageStrippedIds, addProcessedImageStrippedIds, getPendingCompactionMarkerState, clearPendingCompactionMarkerStateIf, peekDeferredExecutePending, setDeferredExecutePendingIfAbsent, clearDeferredExecutePendingIfMatches, getSessionsWithPendingMarker, setSessionWorkMetrics, getNotes, addNote, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, updateNote, dismissNote, markNoteReady, markNoteChecked, queuePendingOp, getPendingOps, clearPendingOps, removePendingOp, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectMemoryEpoch, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, getActiveTagTokenAggregate, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, getActiveTagTokenTotalsByMessage, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, updateTagDropMode, updateCavemanDepth, updateTagMessageId, deleteTagsByMessageId, getMaxTagNumberBySession, getTagNumberByMessageId, deriveTagLoadFloor, getTagsBySession, getActiveTagsBySession, getDroppedTagsBySession, getTagsByNumbers, getMaxDroppedTagNumber, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, getCandidateToolOwners, pickNearestPriorOwner, createChildSessionWithFence, detectOverflow, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, extractLatestAssistantText, hasLengthCappedOutput, setKeepSubagents, shouldKeepSubagents, recordChildInvocation, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, Priority, AdmissionClass, StaleRouteHandleError, SocketClosedError, SocketTimeoutError, SubcClient, isConsumerReconnectTransient, getCompartmentEvents, loadCompartmentChunkEmbeddingsForSearch, cosineSimilarity, SYNAPSE_DEFAULT_MODEL, SynapseEmbeddingProvider, computeNormalizedHash, saveCommitEmbedding, loadProjectCommitEmbeddings, loadUnembeddedCommits, countEmbeddedCommits, upsertCommits, getLatestIndexedCommitTimeMs, enforceProjectCap, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease, saveEmbeddingIfHashMatches, getProjectEmbeddings, peekProjectEmbeddings, invalidateProject, invalidateMemory, markProjectLoadUntrusted, contentSha256, sweepStaleEmbeddingIdentitiesForProject, registerProjectEmbedding, registerProjectShadowEmbedding, getShadowEmbeddingMeasurementCohort, getPrimaryEmbeddingMeasurementCohort, embedShadowTextForProject, enqueueShadowEmbeddingItems, registerProjectInObservationMode, getProjectEmbeddingSnapshot, embedTextForProject, embedBatchForProject, embedItemsForProject, embedUnembeddedMemoriesForProject, drainCommitBacklogForProject, embedSessionCompartmentChunks, getEmbeddingCoverageStatus, isEmbeddingEnabled, embedText, ensureMemoryEmbeddings, computeCueContentHash, hasMuralCueColumns, getMuralCueState, memoryNeedsCue, setMuralCue, recordMuralCueRejection, hasMemoryShareableColumn, hasMemoryClassifiedAtColumn, getUnclassifiedMemoryIds, ModuleMemoryAuthorityError, insertMemory, insertMemoryIdempotent, getMemoryByHash, getMemoriesByProject, buildWorkspaceMemorySqlFilter, getMemoriesByProjects, getMaxMemoryIdForProjects, readNewMemoriesForM1Union, getMemoryById, getMemoriesByIds, updateMemorySeenCount, updateMemoryRetrievalCount, setMemoryClassification, supersededMemory, mergeMemoryStats, archiveMemory, getMemoryCountsByStatus, sanitizeFtsQuery, searchMemoriesFTS, searchMemoriesFTSUnion, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, MARKER_SUMMARY_TEXT, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, getMural, BoundedSessionMap, extractM0Block, formatDate, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, prepareCompartmentInjection, renderCompartmentInjection, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, injectM0M1, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, RECOVERY_NO_HEAD_LIMIT, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, runCompartmentAgent, snapRangeToCompartments, lkgContentDigest, captureSlot, getSlot, dropSlot, noteEntry, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, isRecompFailure, isRecompSkip, isRecompComplete, extractRecompReason, contextualizeUpgradeReason, setRecompStarting, setRecompNote, setRecompTerminal, runManagedRecomp, runManagedUpgrade };
|
|
42657
|
+
export { withContentLanguageDirective, buildPrimaryLanguageDirective, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, resolveLegacyConfigSourcesForHarness, migrateMagicContextConfigLocations, exports_external, DEFAULT_PROTECTED_TAGS, parseCron, nextOccurrence, nextDueAtMs, promptSurfaceConfigIdentity, resolvePromptSurface, resolveModelConfigOrDefault, DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE, DEFAULT_HISTORIAN_TIMEOUT_MS, DEFAULT_LOCAL_EMBEDDING_MODEL, MagicContextConfigSchema, getOpenCodeDbPath, removeMcOwnedCompactionMarkers, isFailClosedBlockingError, shouldBypassFailClosedBlock, resolveAgentNameFromMessages, createFailClosedController, recordHookInitFailure, clearHookInitFailure, getLastHookInitFailure, ProjectIdentityError, resolveProjectIdentityStrict, takeDubiousOwnershipProjectIdentityWarning, resolveProjectIdentity, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, recordSessionProjectIdentity, beginBootQuietPeriod, bootQuietRemainingMs, scheduleAfterBootQuiet, rpcPortDir, rpcPortFilePath, isPidAlive, parseRpcPortFile, registerModuleNoteEvaluationBridge, getModuleNoteEvaluationBridge, getContextStoreUuid, ensureContextStoreUuid, getAuthorityManagedMarker, reconcileAuthorityProject, checksumAuthoritySeedRows, prepareAuthority, drainAuthority, getMirrorCursor, applyMirroredNoteCompileFields, applyMirrorPage, pullMemoryMirrorOnce, V2_MEMORY_CATEGORIES, CATEGORY_PRIORITY, resolveWorkspaceShareCategories, resolveWorkspaceIdentitySet, expandWorkspaceIdentitySetWithAliases, resolveStoredPathWorkspaceIdentity, storedPathBelongsToWorkspace, sourceNameForMemory, computeWorkspaceEpochFingerprint, recordToolDefinition, getMeasuredToolDefinitionTokens, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, runSqliteOptimize, openDatabase, openDatabaseAsync, isDatabasePersisted, getDatabasePersistenceError, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, clearRecompStaging, recordEmbeddingMeasurement, getMaxM0MutationId, queueMemoryMutation, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationIdForProjects, MAX_EXECUTE_THRESHOLD, escalationBands, isEmergencyRecoveryArmed, isProviderOverflowReconfirmed, getEmergencyRecoveryArmedAt, loadPersistedUsage, loadProtectedTailMeta, resetProtectedTailNoEligibleHead, getWrapupInProgressState, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, getPersistedReasoningWatermark, setPersistedReasoningWatermark, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getLastNudgeLevel, setLastNudgeLevel, resetLastNudgeCycle, resetLastNudgeCycleIfTailShrank, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, getNoteNudgeAnchors, getAutoSearchHintDecisions, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, pruneAutoSearchHintDecisions, removeNoteNudgeAnchorByMessageId, removeAutoSearchHintDecisionByMessageId, getPersistedTodoPermissionDenied, setPersistedTodoPermissionDenied, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, setNoteLastReadAt, getHistorianFailureState, clearHistorianFailureState, getOverflowState, recordOverflowDetected, recordDetectedContextLimit, clearEmergencyRecovery, clearDetectedContextLimit, getPersistedCompactionMarkerState, setPersistedCompactionMarkerState, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, removeStrippedPlaceholderId, getStaleReduceStrippedIds, addStaleReduceStrippedIds, getProcessedImageStrippedIds, addProcessedImageStrippedIds, getPendingCompactionMarkerState, clearPendingCompactionMarkerStateIf, peekDeferredExecutePending, setDeferredExecutePendingIfAbsent, clearDeferredExecutePendingIfMatches, getSessionsWithPendingMarker, setSessionWorkMetrics, getNotes, addNote, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, updateNote, dismissNote, markNoteReady, markNoteChecked, queuePendingOp, getPendingOps, clearPendingOps, removePendingOp, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectMemoryEpoch, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, getActiveTagTokenAggregate, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, getActiveTagTokenTotalsByMessage, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, updateTagDropMode, updateCavemanDepth, updateTagMessageId, deleteTagsByMessageId, getMaxTagNumberBySession, getTagNumberByMessageId, deriveTagLoadFloor, getTagsBySession, getActiveTagsBySession, getDroppedTagsBySession, getTagsByNumbers, getMaxDroppedTagNumber, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, getCandidateToolOwners, pickNearestPriorOwner, createChildSessionWithFence, detectOverflow, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, extractLatestAssistantText, hasLengthCappedOutput, setKeepSubagents, shouldKeepSubagents, recordChildInvocation, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, Priority, AdmissionClass, StaleRouteHandleError, SocketClosedError, SocketTimeoutError, SubcClient, isConsumerReconnectTransient, getCompartmentEvents, loadCompartmentChunkEmbeddingsForSearch, cosineSimilarity, SYNAPSE_DEFAULT_MODEL, SynapseEmbeddingProvider, computeNormalizedHash, saveCommitEmbedding, loadProjectCommitEmbeddings, loadUnembeddedCommits, countEmbeddedCommits, upsertCommits, getLatestIndexedCommitTimeMs, enforceProjectCap, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease, saveEmbeddingIfHashMatches, getProjectEmbeddings, peekProjectEmbeddings, invalidateProject, invalidateMemory, markProjectLoadUntrusted, contentSha256, sweepStaleEmbeddingIdentitiesForProject, registerProjectEmbedding, registerProjectShadowEmbedding, getShadowEmbeddingMeasurementCohort, getPrimaryEmbeddingMeasurementCohort, embedShadowTextForProject, enqueueShadowEmbeddingItems, registerProjectInObservationMode, getProjectEmbeddingSnapshot, embedTextForProject, embedBatchForProject, embedItemsForProject, embedUnembeddedMemoriesForProject, drainCommitBacklogForProject, embedSessionCompartmentChunks, getEmbeddingCoverageStatus, isEmbeddingEnabled, embedText, ensureMemoryEmbeddings, computeCueContentHash, hasMuralCueColumns, getMuralCueState, memoryNeedsCue, setMuralCue, recordMuralCueRejection, hasMemoryShareableColumn, hasMemoryClassifiedAtColumn, getUnclassifiedMemoryIds, ModuleMemoryAuthorityError, insertMemory, insertMemoryIdempotent, getMemoryByHash, getMemoriesByProject, buildWorkspaceMemorySqlFilter, getMemoriesByProjects, getMaxMemoryIdForProjects, readNewMemoriesForM1Union, getMemoryById, getMemoriesByIds, updateMemorySeenCount, updateMemoryRetrievalCount, setMemoryClassification, supersededMemory, mergeMemoryStats, archiveMemory, getMemoryCountsByStatus, sanitizeFtsQuery, searchMemoriesFTS, searchMemoriesFTSUnion, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, MARKER_SUMMARY_TEXT, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, getMural, BoundedSessionMap, extractM0Block, formatDate, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, prepareCompartmentInjection, renderCompartmentInjection, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, injectM0M1, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, RECOVERY_NO_HEAD_LIMIT, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, runCompartmentAgent, snapRangeToCompartments, LKG_SNAPSHOT_ARRAY, LKG_SNAPSHOT_OBJECT, LKG_SNAPSHOT_KEY, LKG_SNAPSHOT_STRING, LKG_SNAPSHOT_NUMBER, LKG_SNAPSHOT_BOOLEAN, LKG_SNAPSHOT_NULL, LKG_SNAPSHOT_UNDEFINED, lkgContentDigestFromFields, lkgContentDigest, captureSlot, getSlot, dropSlot, noteEntry, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, isRecompFailure, isRecompSkip, isRecompComplete, extractRecompReason, contextualizeUpgradeReason, setRecompStarting, setRecompNote, setRecompTerminal, runManagedRecomp, runManagedUpgrade };
|