@cortexkit/pi-magic-context 0.43.1 → 0.44.0
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/{index-822b3fcs.js → index-2kj55q4e.js} +155 -28
- package/dist/{index-kyrajahw.js → index-8ytss1hp.js} +308 -190
- package/dist/{index-5v60m046.js → index-jscq7067.js} +1 -1
- package/dist/{index-17102c1m.js → index-mmkdxa5j.js} +1 -1
- package/dist/{index-bfd52y8p.js → index-tfzybajk.js} +22 -6
- package/dist/index.js +1202 -367
- package/dist/{message-time-backfill-f0v3yvza.js → message-time-backfill-3rp0w2z9.js} +3 -3
- package/dist/{read-session-chunk-4s09z8f5.js → read-session-chunk-2s116ah5.js} +6 -2
- package/dist/{safe-notification-target-d7f3t5qk.js → safe-notification-target-pd09ybr0.js} +2 -2
- package/dist/subagent-entry.js +4 -4
- package/package.json +4 -2
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
sanitizeDiagnosticText,
|
|
7
7
|
log,
|
|
8
8
|
sessionLog
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-tfzybajk.js";
|
|
10
10
|
import {
|
|
11
11
|
removeSystemReminders,
|
|
12
12
|
hasMeaningfulUserText2,
|
|
@@ -41,10 +41,10 @@ import {
|
|
|
41
41
|
cleanUserText2,
|
|
42
42
|
readRawSessionMessages2,
|
|
43
43
|
readSessionChunk2
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-2kj55q4e.js";
|
|
45
45
|
import {
|
|
46
46
|
logSlowWriteTransaction
|
|
47
|
-
} from "./index-
|
|
47
|
+
} from "./index-mmkdxa5j.js";
|
|
48
48
|
|
|
49
49
|
// ../plugin/src/config/agent-disable.ts
|
|
50
50
|
var COMPACTION_ENABLED_PATH = `compaction${"."}enabled`;
|
|
@@ -7715,6 +7715,7 @@ var AgentMetadataSchema = AgentOverrideConfigSchema.pick({
|
|
|
7715
7715
|
maxTokens: true
|
|
7716
7716
|
});
|
|
7717
7717
|
var DreamerConfigSchema = AgentMetadataSchema.extend({
|
|
7718
|
+
runner: _enum(["broca", "host"]).optional().describe(`Which side runs the dreamer completions the Rust module routes (classify-memories) in Rust transform mode: "host" runs them on this process's carrier, "broca" routes them to the Broca module. When unset, historian.runner applies, and when that is unset too the harness decides the same way it does for the historian. User-level config only.`),
|
|
7718
7719
|
opencode: DreamerOpenCodeHarnessBlockSchema.optional(),
|
|
7719
7720
|
pi: DreamerPiHarnessBlockSchema.optional(),
|
|
7720
7721
|
omp: DreamerOmpHarnessBlockSchema.optional(),
|
|
@@ -7725,6 +7726,10 @@ var HistorianConfigSchema = AgentMetadataSchema.extend({
|
|
|
7725
7726
|
opencode: OpenCodeHarnessBlockSchema.optional(),
|
|
7726
7727
|
pi: PiHarnessBlockSchema.optional(),
|
|
7727
7728
|
omp: OmpHarnessBlockSchema.optional(),
|
|
7729
|
+
runner: _enum(["broca", "host"]).optional().describe('Which side runs the historian completion in Rust transform mode: "host" queues it for this process to run on the configured historian model, "broca" routes it to the Broca module. When unset the harness decides: OpenCode 1 and OpenCode 2 use "host", Claude Code (through the Thalamus gateway, which has no host to run a completion) uses "broca". User-level config only — it decides whose provider account pays for the call.'),
|
|
7730
|
+
host_runner: object({
|
|
7731
|
+
enabled: boolean2().optional().describe("Whether this process answers historian runs queued for a claimant (default true). Setting it to false stops the pull loop without changing historian.runner, so an operator can take one machine out of the lane and leave the queued runs for another claimant or for the runner setting to be changed deliberately.")
|
|
7732
|
+
}).optional().describe("Controls for this process's historian pull loop, which answers runs the Rust module queues for the host runner (`historian.runner: \"host\"`, or unset on OpenCode 1 and OpenCode 2). User-level config only — it decides whether this machine's provider account is spent on folds."),
|
|
7728
7733
|
two_pass: boolean2().default(false).describe("Run a second editor pass over historian output to clean low-signal U: lines and cross-compartment duplicates. Adds ~1 extra API call and ~1.3x cost per historian run. Useful for models without extended thinking support. (default: false)"),
|
|
7729
7734
|
disallowed_tools: array(_enum(["*", "read", "aft_outline", "aft_zoom", "aft_search"])).default([]).describe(`OpenCode only. Tools to REMOVE from the historian's default allow-list [read, aft_outline, aft_zoom, aft_search]. Applies to both historian and historian-editor agents. Use ["*"] to strip all tool definitions from the model request — this prevents weak instruction-following models (e.g. mistral-small-latest) from entering tool-calling loops. Individual tool names remove just that tool. Note: a user-supplied historian.permission override can re-allow a tool that disallowed_tools removed — disallowed_tools sets the baseline, permission overrides take precedence. (default: [])`)
|
|
7730
7735
|
}).optional();
|
|
@@ -7738,7 +7743,7 @@ function expandConfigPath(value) {
|
|
|
7738
7743
|
return trimmed;
|
|
7739
7744
|
}
|
|
7740
7745
|
var BaseEmbeddingConfigSchema = object({
|
|
7741
|
-
provider: _enum(["local", "openai-compatible", "off", "synapse"]).default("local").describe("Embedding provider. 'local' uses Xenova/all-MiniLM-L6-v2, 'openai-compatible' requires endpoint and model, 'synapse' uses the certified local Synapse lane with an explicit fallback provider, and 'off' disables embeddings."),
|
|
7746
|
+
provider: _enum(["local", "openai-compatible", "off", "synapse"]).default("local").describe("Embedding provider. 'local' uses Xenova/all-MiniLM-L6-v2, 'openai-compatible' requires endpoint and model, 'synapse' uses the certified local Synapse lane with an explicit fallback provider, and 'off' disables embeddings. Session history is embedded for semantic ctx_search whenever the provider is not 'off', regardless of memory.enabled; memories are embedded only while memory.enabled is true."),
|
|
7742
7747
|
fallback_provider: EmbeddingFallbackProviderSchema.optional().describe("Fallback provider for the Synapse lane. Required when provider is 'synapse'; local, openai-compatible, and off are valid."),
|
|
7743
7748
|
model: string2().optional().describe("Embedding model name. Required for openai-compatible, ignored for local."),
|
|
7744
7749
|
endpoint: string2().optional().describe("API endpoint URL. Required when provider is openai-compatible."),
|
|
@@ -7919,7 +7924,7 @@ var MagicContextConfigSchema = object({
|
|
|
7919
7924
|
min_chars: number2().min(100).max(1e4).default(500).describe("Text parts shorter than this (characters) stay untouched. Min 100, max 10000. Default: 500.")
|
|
7920
7925
|
}).default({ enabled: false, min_chars: 500 }).describe("Age-tier caveman compression for long user/assistant text parts. Active for primary sessions when enabled; never for subagents. Oldest 20% of eligible tags (outside protected tail) go to ultra, next 20% to full, next 20% to lite, newest 40% untouched. Graduated from experimental.caveman_text_compression; opt-in, default off (lossy)."),
|
|
7921
7926
|
memory: object({
|
|
7922
|
-
enabled: boolean2().default(true).describe("Enable cross-session memory (default: true)"),
|
|
7927
|
+
enabled: boolean2().default(true).describe("Enable cross-session memory (default: true). Does not affect history embedding or semantic ctx_search over session history; set embedding.provider to 'off' to stop all embedding."),
|
|
7923
7928
|
injection_budget_tokens: number2().min(500).max(20000).default(4000).describe("Token budget for memory injection on session start (min: 500, max: 20000, default: 4000)"),
|
|
7924
7929
|
auto_promote: boolean2().default(true).describe("Automatically promote eligible session facts into memory (default: true)"),
|
|
7925
7930
|
retrieval_count_promotion_threshold: number2().min(1).default(3).describe("retrieval_count threshold for promoting memory to permanent status (min: 1, default: 3)"),
|
|
@@ -8018,7 +8023,11 @@ function deriveDefaultProtectedTokens(usableSoft) {
|
|
|
8018
8023
|
// ../plugin/src/config/project-security.ts
|
|
8019
8024
|
var HIDDEN_AGENT_KEYS = ["historian", "dreamer"];
|
|
8020
8025
|
var HARNESS_KEYS = PER_HARNESS_MODEL_KEYS;
|
|
8021
|
-
var HISTORIAN_USER_ONLY_FIELDS =
|
|
8026
|
+
var HISTORIAN_USER_ONLY_FIELDS = [
|
|
8027
|
+
...PER_HARNESS_MIGRATION_INVENTORY.historian.migrated_execution,
|
|
8028
|
+
"runner",
|
|
8029
|
+
"host_runner"
|
|
8030
|
+
];
|
|
8022
8031
|
var PROMPT_SURFACE_USER_ONLY_FIELDS = ["guidance_override_path", "tool_descriptions"];
|
|
8023
8032
|
var AGENT_ESCALATION_FIELDS = ["prompt", "permission", "tools"];
|
|
8024
8033
|
var EMBEDDING_USER_ONLY_FIELDS = [
|
|
@@ -8327,6 +8336,11 @@ function stripUnsafeProjectConfigFields(projectRaw) {
|
|
|
8327
8336
|
warnings.push(`Ignoring ${removed.map((path) => `historian.${path}`).join(", ")} from project config ` + "(security: historian model selection is user-level only; a repository cannot force extra compaction cost).");
|
|
8328
8337
|
}
|
|
8329
8338
|
}
|
|
8339
|
+
const dreamer = projectRaw.dreamer;
|
|
8340
|
+
if (isPlainObject2(dreamer) && "runner" in dreamer) {
|
|
8341
|
+
delete dreamer.runner;
|
|
8342
|
+
warnings.push("Ignoring dreamer.runner from project config (security: which process and provider account run dreamer completions is a user-level setting).");
|
|
8343
|
+
}
|
|
8330
8344
|
const mural = projectRaw.mural;
|
|
8331
8345
|
if (isPlainObject2(mural) && "model" in mural) {
|
|
8332
8346
|
delete mural.model;
|
|
@@ -8643,7 +8657,9 @@ function formatFailClosedBlockingMessage(reason) {
|
|
|
8643
8657
|
}
|
|
8644
8658
|
return [
|
|
8645
8659
|
`Magic Context cannot migrate the shared database (one database serves every project on this machine) because ${formatFailClosedBlockingProcesses(reason.blockingProcesses)} may be running an older Magic Context build that would fail against the migrated database.`,
|
|
8660
|
+
`The database is at upstream migration v${reason.persistedVersion}; this build needs v${reason.supportedVersion}.`,
|
|
8646
8661
|
"Restart the blocking process — even one from a different project — and it will pick up the new build and migrate on start; or shut it down and retry.",
|
|
8662
|
+
"If that host loads a pinned or cached older Magic Context build, a restart alone is not enough: stop it or update its Magic Context build, then start this host once so it migrates the database with nothing older attached.",
|
|
8647
8663
|
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
8648
8664
|
].join(" ");
|
|
8649
8665
|
}
|
|
@@ -9313,7 +9329,7 @@ function transitionSessionHygieneUnits(db, sessionId, bustPermitted, calibration
|
|
|
9313
9329
|
hygieneUnitsVersion: HYGIENE_PROVIDER_UNITS_VERSION
|
|
9314
9330
|
});
|
|
9315
9331
|
return HYGIENE_PROVIDER_UNITS_VERSION;
|
|
9316
|
-
})();
|
|
9332
|
+
}).immediate();
|
|
9317
9333
|
}
|
|
9318
9334
|
|
|
9319
9335
|
// ../plugin/src/features/magic-context/protection-window.ts
|
|
@@ -10144,7 +10160,7 @@ function markProtectedTailPolicyV3Seeded(db, sessionId, priorBoundaryOrdinal) {
|
|
|
10144
10160
|
WHERE session_id = ? AND protected_tail_policy_version < 3`).run(Math.max(1, Math.floor(priorBoundaryOrdinal)), sessionId);
|
|
10145
10161
|
seeded = true;
|
|
10146
10162
|
}
|
|
10147
|
-
})();
|
|
10163
|
+
}).immediate();
|
|
10148
10164
|
return { ...loadProtectedTailMeta(db, sessionId), seeded };
|
|
10149
10165
|
}
|
|
10150
10166
|
function recordProtectedTailPublicationFloor(db, sessionId, floorOrdinal) {
|
|
@@ -10154,7 +10170,7 @@ function recordProtectedTailPublicationFloor(db, sessionId, floorOrdinal) {
|
|
|
10154
10170
|
SET prior_boundary_ordinal = MAX(COALESCE(prior_boundary_ordinal, 1), ?),
|
|
10155
10171
|
recovery_no_eligible_head_count = 0
|
|
10156
10172
|
WHERE session_id = ?`).run(Math.max(1, Math.floor(floorOrdinal)), sessionId);
|
|
10157
|
-
})();
|
|
10173
|
+
}).immediate();
|
|
10158
10174
|
}
|
|
10159
10175
|
function recordProtectedTailNoEligibleHead(db, sessionId) {
|
|
10160
10176
|
db.transaction(() => {
|
|
@@ -10162,7 +10178,7 @@ function recordProtectedTailNoEligibleHead(db, sessionId) {
|
|
|
10162
10178
|
db.prepare(`UPDATE session_meta
|
|
10163
10179
|
SET recovery_no_eligible_head_count = COALESCE(recovery_no_eligible_head_count, 0) + 1
|
|
10164
10180
|
WHERE session_id = ?`).run(sessionId);
|
|
10165
|
-
})();
|
|
10181
|
+
}).immediate();
|
|
10166
10182
|
return loadProtectedTailMeta(db, sessionId).recoveryNoEligibleHeadCount;
|
|
10167
10183
|
}
|
|
10168
10184
|
var DRAIN_WINDOW_MS = 10 * 60 * 1000;
|
|
@@ -10453,27 +10469,27 @@ function reserveProtectedTailDrainTokens(args) {
|
|
|
10453
10469
|
reservation: { sessionId: args.sessionId, runId: args.runId, tokens: reserved },
|
|
10454
10470
|
budgetState: budgetState(meta.protectedTailDrainTokens + reserved)
|
|
10455
10471
|
};
|
|
10456
|
-
})();
|
|
10472
|
+
}).immediate();
|
|
10457
10473
|
return result;
|
|
10458
10474
|
}
|
|
10459
10475
|
function clearEmergencyDrainLatch(db, sessionId) {
|
|
10460
10476
|
db.transaction(() => {
|
|
10461
10477
|
ensureSessionMetaRow(db, sessionId);
|
|
10462
10478
|
db.prepare("UPDATE session_meta SET emergency_drain_active = 0 WHERE session_id = ?").run(sessionId);
|
|
10463
|
-
})();
|
|
10479
|
+
}).immediate();
|
|
10464
10480
|
}
|
|
10465
10481
|
function recordHistorianDrainFailure(db, sessionId, now) {
|
|
10466
10482
|
const ts = now ?? Date.now();
|
|
10467
10483
|
db.transaction(() => {
|
|
10468
10484
|
ensureSessionMetaRow(db, sessionId);
|
|
10469
10485
|
db.prepare("UPDATE session_meta SET historian_drain_failure_at = ? WHERE session_id = ?").run(ts, sessionId);
|
|
10470
|
-
})();
|
|
10486
|
+
}).immediate();
|
|
10471
10487
|
}
|
|
10472
10488
|
function clearHistorianDrainFailure(db, sessionId) {
|
|
10473
10489
|
db.transaction(() => {
|
|
10474
10490
|
ensureSessionMetaRow(db, sessionId);
|
|
10475
10491
|
db.prepare("UPDATE session_meta SET historian_drain_failure_at = 0 WHERE session_id = ?").run(sessionId);
|
|
10476
|
-
})();
|
|
10492
|
+
}).immediate();
|
|
10477
10493
|
}
|
|
10478
10494
|
function rollbackProtectedTailDrainReservation(db, reservation) {
|
|
10479
10495
|
if (!reservation || reservation.tokens <= 0)
|
|
@@ -10483,7 +10499,7 @@ function rollbackProtectedTailDrainReservation(db, reservation) {
|
|
|
10483
10499
|
db.prepare(`UPDATE session_meta
|
|
10484
10500
|
SET protected_tail_drain_tokens = MAX(0, COALESCE(protected_tail_drain_tokens, 0) - ?)
|
|
10485
10501
|
WHERE session_id = ?`).run(reservation.tokens, reservation.sessionId);
|
|
10486
|
-
})();
|
|
10502
|
+
}).immediate();
|
|
10487
10503
|
}
|
|
10488
10504
|
function setPersistedReasoningWatermark(db, sessionId, tagNumber) {
|
|
10489
10505
|
ensureSessionMetaRow(db, sessionId);
|
|
@@ -10503,13 +10519,13 @@ function setEmergencyDropSample(db, sessionId, inputSample) {
|
|
|
10503
10519
|
db.transaction(() => {
|
|
10504
10520
|
ensureSessionMetaRow(db, sessionId);
|
|
10505
10521
|
db.prepare("UPDATE session_meta SET last_emergency_input_sample = ? WHERE session_id = ?").run(Math.max(0, Math.round(inputSample)), sessionId);
|
|
10506
|
-
})();
|
|
10522
|
+
}).immediate();
|
|
10507
10523
|
}
|
|
10508
10524
|
function clearEmergencyDropSample(db, sessionId) {
|
|
10509
10525
|
db.transaction(() => {
|
|
10510
10526
|
ensureSessionMetaRow(db, sessionId);
|
|
10511
10527
|
db.prepare("UPDATE session_meta SET last_emergency_input_sample = 0 WHERE session_id = ?").run(sessionId);
|
|
10512
|
-
})();
|
|
10528
|
+
}).immediate();
|
|
10513
10529
|
}
|
|
10514
10530
|
var EMPTY_CHANNEL1_NUDGE_STATE = { level: "", ordinal: 0 };
|
|
10515
10531
|
function isLastNudgeUndroppedRow(row) {
|
|
@@ -10566,7 +10582,7 @@ function setLastNudgeUndropped(db, sessionId, value) {
|
|
|
10566
10582
|
db.transaction(() => {
|
|
10567
10583
|
ensureSessionMetaRow(db, sessionId);
|
|
10568
10584
|
db.prepare("UPDATE session_meta SET last_nudge_undropped = ? WHERE session_id = ?").run(Math.max(0, Math.round(value)), sessionId);
|
|
10569
|
-
})();
|
|
10585
|
+
}).immediate();
|
|
10570
10586
|
}
|
|
10571
10587
|
function getChannel1NudgeState(db, sessionId) {
|
|
10572
10588
|
const result = db.prepare("SELECT last_nudge_level FROM session_meta WHERE session_id = ?").get(sessionId);
|
|
@@ -10576,7 +10592,7 @@ function setChannel1NudgeState(db, sessionId, value) {
|
|
|
10576
10592
|
db.transaction(() => {
|
|
10577
10593
|
ensureSessionMetaRow(db, sessionId);
|
|
10578
10594
|
db.prepare("UPDATE session_meta SET last_nudge_level = ? WHERE session_id = ?").run(serializeChannel1NudgeState(value), sessionId);
|
|
10579
|
-
})();
|
|
10595
|
+
}).immediate();
|
|
10580
10596
|
}
|
|
10581
10597
|
function markChannel1PostReduceGracePending(db, sessionId) {
|
|
10582
10598
|
return db.transaction(() => {
|
|
@@ -10590,7 +10606,7 @@ function markChannel1PostReduceGracePending(db, sessionId) {
|
|
|
10590
10606
|
};
|
|
10591
10607
|
db.prepare("UPDATE session_meta SET last_nudge_level = ? WHERE session_id = ?").run(serializeChannel1NudgeState(next), sessionId);
|
|
10592
10608
|
return next;
|
|
10593
|
-
})();
|
|
10609
|
+
}).immediate();
|
|
10594
10610
|
}
|
|
10595
10611
|
function captureChannel1PostReduceGraceBaseline(db, sessionId, measuredUndropped) {
|
|
10596
10612
|
return db.transaction(() => {
|
|
@@ -10607,7 +10623,7 @@ function captureChannel1PostReduceGraceBaseline(db, sessionId, measuredUndropped
|
|
|
10607
10623
|
};
|
|
10608
10624
|
db.prepare("UPDATE session_meta SET last_nudge_level = ? WHERE session_id = ?").run(serializeChannel1NudgeState(next), sessionId);
|
|
10609
10625
|
return next;
|
|
10610
|
-
})();
|
|
10626
|
+
}).immediate();
|
|
10611
10627
|
}
|
|
10612
10628
|
function isChannel2StateRow(row) {
|
|
10613
10629
|
return typeof row === "object" && row !== null && typeof row.channel2_nudge_state === "string";
|
|
@@ -10634,7 +10650,7 @@ function setChannel2NudgeState(db, sessionId, state) {
|
|
|
10634
10650
|
ensureSessionMetaRow(db, sessionId);
|
|
10635
10651
|
const claimedAt = state === "claimed" ? Date.now() : 0;
|
|
10636
10652
|
db.prepare("UPDATE session_meta SET channel2_nudge_state = ?, channel2_nudge_claimed_at = ?, channel2_nudge_claim_token = '' WHERE session_id = ?").run(state, claimedAt, sessionId);
|
|
10637
|
-
})();
|
|
10653
|
+
}).immediate();
|
|
10638
10654
|
}
|
|
10639
10655
|
function casChannel2NudgeState(db, sessionId, from, to) {
|
|
10640
10656
|
let changed = false;
|
|
@@ -10643,7 +10659,7 @@ function casChannel2NudgeState(db, sessionId, from, to) {
|
|
|
10643
10659
|
const claimedAt = to === "claimed" ? Date.now() : 0;
|
|
10644
10660
|
const result = db.prepare("UPDATE session_meta SET channel2_nudge_state = ?, channel2_nudge_claimed_at = ?, channel2_nudge_claim_token = '' WHERE session_id = ? AND channel2_nudge_state = ?").run(to, claimedAt, sessionId, from);
|
|
10645
10661
|
changed = (result.changes ?? 0) > 0;
|
|
10646
|
-
})();
|
|
10662
|
+
}).immediate();
|
|
10647
10663
|
return changed;
|
|
10648
10664
|
}
|
|
10649
10665
|
function claimChannel2NudgeState(db, sessionId, claimToken) {
|
|
@@ -10652,7 +10668,7 @@ function claimChannel2NudgeState(db, sessionId, claimToken) {
|
|
|
10652
10668
|
ensureSessionMetaRow(db, sessionId);
|
|
10653
10669
|
const result = db.prepare("UPDATE session_meta SET channel2_nudge_state = 'claimed', channel2_nudge_claimed_at = ?, channel2_nudge_claim_token = ? WHERE session_id = ? AND channel2_nudge_state = 'pending'").run(Date.now(), claimToken, sessionId);
|
|
10654
10670
|
changed = (result.changes ?? 0) > 0;
|
|
10655
|
-
})();
|
|
10671
|
+
}).immediate();
|
|
10656
10672
|
return changed;
|
|
10657
10673
|
}
|
|
10658
10674
|
function casChannel2NudgeClaim(db, sessionId, to, claimToken) {
|
|
@@ -10663,7 +10679,7 @@ function casChannel2NudgeClaim(db, sessionId, to, claimToken) {
|
|
|
10663
10679
|
const nextClaimToken = to === "claimed" ? claimToken : "";
|
|
10664
10680
|
const result = db.prepare("UPDATE session_meta SET channel2_nudge_state = ?, channel2_nudge_claimed_at = ?, channel2_nudge_claim_token = ? WHERE session_id = ? AND channel2_nudge_state = 'claimed' AND channel2_nudge_claim_token = ?").run(to, claimedAt, nextClaimToken, sessionId, claimToken);
|
|
10665
10681
|
changed = (result.changes ?? 0) > 0;
|
|
10666
|
-
})();
|
|
10682
|
+
}).immediate();
|
|
10667
10683
|
return changed;
|
|
10668
10684
|
}
|
|
10669
10685
|
function getPersistedNoteNudge(db, sessionId) {
|
|
@@ -10682,13 +10698,13 @@ function setPersistedNoteNudgeTrigger(db, sessionId, triggerMessageId = "") {
|
|
|
10682
10698
|
db.transaction(() => {
|
|
10683
10699
|
ensureSessionMetaRow(db, sessionId);
|
|
10684
10700
|
db.prepare("UPDATE session_meta SET note_nudge_trigger_pending = 1, note_nudge_trigger_message_id = ? WHERE session_id = ?").run(triggerMessageId, sessionId);
|
|
10685
|
-
})();
|
|
10701
|
+
}).immediate();
|
|
10686
10702
|
}
|
|
10687
10703
|
function setPersistedNoteNudgeTriggerMessageId(db, sessionId, triggerMessageId) {
|
|
10688
10704
|
db.transaction(() => {
|
|
10689
10705
|
ensureSessionMetaRow(db, sessionId);
|
|
10690
10706
|
db.prepare("UPDATE session_meta SET note_nudge_trigger_message_id = ? WHERE session_id = ?").run(triggerMessageId, sessionId);
|
|
10691
|
-
})();
|
|
10707
|
+
}).immediate();
|
|
10692
10708
|
}
|
|
10693
10709
|
function getNoteNudgeAnchors(db, sessionId) {
|
|
10694
10710
|
const row = db.prepare("SELECT note_nudge_anchors FROM session_meta WHERE session_id = ?").get(sessionId);
|
|
@@ -10817,7 +10833,7 @@ function setPersistedTodoSyntheticAnchor(db, sessionId, callId, messageId, state
|
|
|
10817
10833
|
db.transaction(() => {
|
|
10818
10834
|
ensureSessionMetaRow(db, sessionId);
|
|
10819
10835
|
db.prepare("UPDATE session_meta SET todo_synthetic_call_id = ?, todo_synthetic_anchor_message_id = ?, todo_synthetic_state_json = ? WHERE session_id = ?").run(callId, messageId, stateJson, sessionId);
|
|
10820
|
-
})();
|
|
10836
|
+
}).immediate();
|
|
10821
10837
|
}
|
|
10822
10838
|
function clearPersistedTodoSyntheticAnchor(db, sessionId) {
|
|
10823
10839
|
db.prepare("UPDATE session_meta SET todo_synthetic_call_id = '', todo_synthetic_anchor_message_id = '', todo_synthetic_state_json = '' WHERE session_id = ?").run(sessionId);
|
|
@@ -10837,7 +10853,7 @@ function setNoteLastReadAt(db, sessionId, at = Date.now()) {
|
|
|
10837
10853
|
db.transaction(() => {
|
|
10838
10854
|
ensureSessionMetaRow(db, sessionId);
|
|
10839
10855
|
db.prepare("UPDATE session_meta SET note_last_read_at = ? WHERE session_id = ?").run(at, sessionId);
|
|
10840
|
-
})();
|
|
10856
|
+
}).immediate();
|
|
10841
10857
|
}
|
|
10842
10858
|
function getHistorianFailureState(db, sessionId) {
|
|
10843
10859
|
const result = db.prepare("SELECT historian_failure_count, historian_last_error, historian_last_failure_at FROM session_meta WHERE session_id = ?").get(sessionId);
|
|
@@ -10852,14 +10868,14 @@ function incrementHistorianFailure(db, sessionId, error) {
|
|
|
10852
10868
|
db.prepare("UPDATE session_meta SET historian_failure_count = ?, historian_last_error = ?, historian_last_failure_at = ? WHERE session_id = ?").run(nextCount, error, Date.now(), sessionId);
|
|
10853
10869
|
const reason = error.replace(/\s+/g, " ").trim().slice(0, 300);
|
|
10854
10870
|
sessionLog(sessionId, `historian failure recorded: count=${nextCount} reason="${reason}"`);
|
|
10855
|
-
})();
|
|
10871
|
+
}).immediate();
|
|
10856
10872
|
return nextCount;
|
|
10857
10873
|
}
|
|
10858
10874
|
function clearHistorianFailureState(db, sessionId) {
|
|
10859
10875
|
db.transaction(() => {
|
|
10860
10876
|
ensureSessionMetaRow(db, sessionId);
|
|
10861
10877
|
db.prepare("UPDATE session_meta SET historian_failure_count = 0, historian_last_error = NULL, historian_last_failure_at = NULL WHERE session_id = ?").run(sessionId);
|
|
10862
|
-
})();
|
|
10878
|
+
}).immediate();
|
|
10863
10879
|
}
|
|
10864
10880
|
function normalizeDetectedLimitModelKey(modelKey) {
|
|
10865
10881
|
return typeof modelKey === "string" && modelKey.length > 0 ? piModelRefToCanonical(modelKey) : null;
|
|
@@ -10919,7 +10935,7 @@ function recordOverflowDetected(db, sessionId, reportedLimit, modelKey, origin =
|
|
|
10919
10935
|
const percentage = effectiveLimit > 0 ? reportedInputTokens / effectiveLimit * 100 : 100;
|
|
10920
10936
|
db.prepare("UPDATE session_meta SET last_input_tokens = ?, last_context_percentage = MAX(last_context_percentage, ?), last_response_time = ? WHERE session_id = ?").run(reportedInputTokens, percentage, Date.now(), sessionId);
|
|
10921
10937
|
}
|
|
10922
|
-
})();
|
|
10938
|
+
}).immediate();
|
|
10923
10939
|
}
|
|
10924
10940
|
function clearEmergencyRecovery(db, sessionId) {
|
|
10925
10941
|
db.transaction(() => {
|
|
@@ -10929,7 +10945,7 @@ function clearEmergencyRecovery(db, sessionId) {
|
|
|
10929
10945
|
} catch {
|
|
10930
10946
|
db.prepare("UPDATE session_meta SET needs_emergency_recovery = 0, emergency_recovery_origin = '' WHERE session_id = ?").run(sessionId);
|
|
10931
10947
|
}
|
|
10932
|
-
})();
|
|
10948
|
+
}).immediate();
|
|
10933
10949
|
emergencyRecoveryArmedSessions.delete(sessionId);
|
|
10934
10950
|
emergencyRecoveryArmedAtBySession.delete(sessionId);
|
|
10935
10951
|
providerOverflowReconfirmedSessions.delete(sessionId);
|
|
@@ -10939,7 +10955,7 @@ function clearDetectedContextLimit(db, sessionId) {
|
|
|
10939
10955
|
db.transaction(() => {
|
|
10940
10956
|
ensureSessionMetaRow(db, sessionId);
|
|
10941
10957
|
db.prepare("UPDATE session_meta SET detected_context_limit = 0, detected_context_limit_model_key = NULL, detected_context_limit_provenance = 'unknown' WHERE session_id = ?").run(sessionId);
|
|
10942
|
-
})();
|
|
10958
|
+
}).immediate();
|
|
10943
10959
|
}
|
|
10944
10960
|
function parsePersistedCompactionMarkerState(raw, storedTargetEndMessageId) {
|
|
10945
10961
|
if (!raw || raw.length === 0)
|
|
@@ -10966,7 +10982,7 @@ function setPersistedCompactionMarkerState(db, sessionId, state) {
|
|
|
10966
10982
|
const previous = state === null ? getPersistedCompactionMarkerState(db, sessionId) ?? getDeferredClearedCompactionMarkerState(db, sessionId) : null;
|
|
10967
10983
|
const json = state ? JSON.stringify(state) : previous ? JSON.stringify({ deferredClear: previous }) : "";
|
|
10968
10984
|
db.prepare("UPDATE session_meta SET compaction_marker_state = ?, compaction_marker_target_end_message_id = ? WHERE session_id = ?").run(json, state?.targetEndMessageId ?? null, sessionId);
|
|
10969
|
-
})();
|
|
10985
|
+
}).immediate();
|
|
10970
10986
|
}
|
|
10971
10987
|
function getDeferredClearedCompactionMarkerState(db, sessionId) {
|
|
10972
10988
|
const row = db.prepare("SELECT compaction_marker_state FROM session_meta WHERE session_id = ?").get(sessionId);
|
|
@@ -11058,8 +11074,9 @@ function applyStrippedPlaceholderDelta(db, sessionId, delta) {
|
|
|
11058
11074
|
sessionLog(sessionId, `stripped_placeholder_ids CAS: ${CAS_RETRY_LIMIT2} retries exhausted`);
|
|
11059
11075
|
return false;
|
|
11060
11076
|
}
|
|
11061
|
-
var
|
|
11077
|
+
var THINKING_BINDING_RECOVERY_ALL_ASSISTANTS = "all_reasoning_bearing_assistants";
|
|
11062
11078
|
var THINKING_BINDING_RECOVERY_FROZEN_PREFIX = "binding_mismatch:";
|
|
11079
|
+
var THINKING_BINDING_STRIP_ORDER_END_MARKER = "binding_mismatch_order:end";
|
|
11063
11080
|
function thinkingBindingRecoveryFrozenId(messageId) {
|
|
11064
11081
|
return `${THINKING_BINDING_RECOVERY_FROZEN_PREFIX}${messageId}`;
|
|
11065
11082
|
}
|
|
@@ -11068,14 +11085,9 @@ function getThinkingBindingRecoveryTarget(db, sessionId) {
|
|
|
11068
11085
|
const target = row?.thinking_binding_recovery_target;
|
|
11069
11086
|
return typeof target === "string" && target.length > 0 ? target : null;
|
|
11070
11087
|
}
|
|
11071
|
-
function armThinkingBindingRecovery(db, sessionId
|
|
11088
|
+
function armThinkingBindingRecovery(db, sessionId) {
|
|
11072
11089
|
ensureSessionMetaRow(db, sessionId);
|
|
11073
|
-
|
|
11074
|
-
if (target === NEWEST_REASONING_BEARING_ASSISTANT) {
|
|
11075
|
-
db.prepare("UPDATE session_meta SET thinking_binding_recovery_target = ? WHERE session_id = ? AND COALESCE(thinking_binding_recovery_target, '') = ''").run(target, sessionId);
|
|
11076
|
-
return;
|
|
11077
|
-
}
|
|
11078
|
-
db.prepare("UPDATE session_meta SET thinking_binding_recovery_target = ? WHERE session_id = ?").run(target, sessionId);
|
|
11090
|
+
db.prepare("UPDATE session_meta SET thinking_binding_recovery_target = ? WHERE session_id = ?").run(THINKING_BINDING_RECOVERY_ALL_ASSISTANTS, sessionId);
|
|
11079
11091
|
}
|
|
11080
11092
|
function clearThinkingBindingRecoveryIf(db, sessionId, expectedTarget) {
|
|
11081
11093
|
const result = db.prepare("UPDATE session_meta SET thinking_binding_recovery_target = '' WHERE session_id = ? AND thinking_binding_recovery_target = ?").run(sessionId, expectedTarget);
|
|
@@ -11448,6 +11460,10 @@ function piHarnessKindFromExecutable(value) {
|
|
|
11448
11460
|
}
|
|
11449
11461
|
|
|
11450
11462
|
// ../plugin/src/shared/rpc-utils.ts
|
|
11463
|
+
var ownRpcServerInstanceIds = new Set;
|
|
11464
|
+
function isOwnRpcServerRecord(record) {
|
|
11465
|
+
return record.pid === process.pid && record.instance_id !== undefined && ownRpcServerInstanceIds.has(record.instance_id);
|
|
11466
|
+
}
|
|
11451
11467
|
function isPidAlive(pid) {
|
|
11452
11468
|
if (!Number.isInteger(pid) || pid <= 0)
|
|
11453
11469
|
return "dead";
|
|
@@ -12017,6 +12033,9 @@ function ensureContextStoreUuid(db) {
|
|
|
12017
12033
|
});
|
|
12018
12034
|
return getContextStoreUuid(db) ?? minted;
|
|
12019
12035
|
}
|
|
12036
|
+
function getAuthorityManagedMarker(db, projectPath) {
|
|
12037
|
+
return db.prepare("SELECT project_path, context_store_uuid, marked_at FROM authority_managed WHERE project_path = ?").get(projectPath) ?? null;
|
|
12038
|
+
}
|
|
12020
12039
|
function bumpDomainMutationEpoch(db, projectPath, domain) {
|
|
12021
12040
|
db.prepare(`INSERT INTO domain_mutation_epoch(project_path, domain, epoch) VALUES (?, ?, 1)
|
|
12022
12041
|
ON CONFLICT(project_path, domain) DO UPDATE SET epoch = epoch + 1`).run(projectPath, domain);
|
|
@@ -12932,7 +12951,7 @@ function backfillMessageFtsRowidMapBatch(db, batchSize = MESSAGE_FTS_ROWID_MAP_B
|
|
|
12932
12951
|
watermarkRowid,
|
|
12933
12952
|
completed
|
|
12934
12953
|
};
|
|
12935
|
-
})();
|
|
12954
|
+
}).immediate();
|
|
12936
12955
|
logSlowWriteTransaction("message_fts_rowid_backfill", transactionStartedAt);
|
|
12937
12956
|
return progress;
|
|
12938
12957
|
}
|
|
@@ -12986,6 +13005,48 @@ function messageFtsOrdinalRangeIsMapped(db, sessionId, startOrdinal, endOrdinal)
|
|
|
12986
13005
|
return row?.sourceOrdinalCount === ordinalCount && row.expectedMapCount === row.mappedCount;
|
|
12987
13006
|
}
|
|
12988
13007
|
|
|
13008
|
+
// ../plugin/src/features/magic-context/memory/constants.ts
|
|
13009
|
+
var V2_MEMORY_CATEGORIES = [
|
|
13010
|
+
"PROJECT_RULES",
|
|
13011
|
+
"ARCHITECTURE",
|
|
13012
|
+
"CONSTRAINTS",
|
|
13013
|
+
"CONFIG_VALUES",
|
|
13014
|
+
"NAMING"
|
|
13015
|
+
];
|
|
13016
|
+
var PROMOTABLE_CATEGORIES = [
|
|
13017
|
+
...V2_MEMORY_CATEGORIES,
|
|
13018
|
+
"ARCHITECTURE_DECISIONS",
|
|
13019
|
+
"CONFIG_DEFAULTS",
|
|
13020
|
+
"USER_PREFERENCES",
|
|
13021
|
+
"USER_DIRECTIVES",
|
|
13022
|
+
"ENVIRONMENT",
|
|
13023
|
+
"WORKFLOW_RULES",
|
|
13024
|
+
"KNOWN_ISSUES"
|
|
13025
|
+
];
|
|
13026
|
+
var CATEGORY_PRIORITY = [
|
|
13027
|
+
...V2_MEMORY_CATEGORIES,
|
|
13028
|
+
"USER_DIRECTIVES",
|
|
13029
|
+
"USER_PREFERENCES",
|
|
13030
|
+
"CONFIG_DEFAULTS",
|
|
13031
|
+
"ARCHITECTURE_DECISIONS",
|
|
13032
|
+
"ENVIRONMENT",
|
|
13033
|
+
"WORKFLOW_RULES",
|
|
13034
|
+
"KNOWN_ISSUES"
|
|
13035
|
+
];
|
|
13036
|
+
var MEMORY_CATEGORY_ORDER_UNKNOWN = 99;
|
|
13037
|
+
var MEMORY_CATEGORY_ORDER_PRIORITY = CATEGORY_PRIORITY.reduce((acc, category, index) => {
|
|
13038
|
+
acc[category] = index;
|
|
13039
|
+
return acc;
|
|
13040
|
+
}, {});
|
|
13041
|
+
var MEMORY_CATEGORY_ORDER_SQL = `CASE category ${CATEGORY_PRIORITY.map((category, index) => `WHEN '${category}' THEN ${index}`).join(" ")} ELSE ${MEMORY_CATEGORY_ORDER_UNKNOWN} END`;
|
|
13042
|
+
function getMemoryCategoryOrder(category) {
|
|
13043
|
+
return MEMORY_CATEGORY_ORDER_PRIORITY[category] ?? MEMORY_CATEGORY_ORDER_UNKNOWN;
|
|
13044
|
+
}
|
|
13045
|
+
var CATEGORY_DEFAULT_TTL = {
|
|
13046
|
+
WORKFLOW_RULES: 90 * 24 * 60 * 60 * 1000,
|
|
13047
|
+
KNOWN_ISSUES: 30 * 24 * 60 * 60 * 1000
|
|
13048
|
+
};
|
|
13049
|
+
|
|
12989
13050
|
// ../plugin/src/hooks/magic-context/compartment-parser.ts
|
|
12990
13051
|
var COMPARTMENT_REGEX = /<compartment\s+([^>]*?)\s*>(.*?)<\/compartment>/gs;
|
|
12991
13052
|
var ATTR_START_REGEX = /\bstart="(\d+)"/;
|
|
@@ -13004,7 +13065,8 @@ var TIER_OPEN_REGEXES = [
|
|
|
13004
13065
|
];
|
|
13005
13066
|
var TIER_CLOSE_ANY_REGEX = /<\/p\d/;
|
|
13006
13067
|
var TIER_OPEN_ANY_REGEX = /<p\d/;
|
|
13007
|
-
var CATEGORY_BLOCK_REGEX = /<(
|
|
13068
|
+
var CATEGORY_BLOCK_REGEX = /<([A-Za-z_][A-Za-z0-9_-]*)>(.*?)<\/\1>/gs;
|
|
13069
|
+
var HISTORIAN_CATEGORIES = new Set(V2_MEMORY_CATEGORIES);
|
|
13008
13070
|
var FACT_ITEM_REGEX = /^\s*\*\s*(.+)$/gm;
|
|
13009
13071
|
var UNPROCESSED_REGEX = /<unprocessed_from>(\d+)<\/unprocessed_from>/;
|
|
13010
13072
|
var USER_OBSERVATIONS_REGEX = /<user_observations>(.*?)<\/user_observations>/s;
|
|
@@ -13041,6 +13103,8 @@ function extractTiersFromInner(inner) {
|
|
|
13041
13103
|
function parseCompartmentOutput(text) {
|
|
13042
13104
|
const compartments = [];
|
|
13043
13105
|
const facts = [];
|
|
13106
|
+
let droppedFactBlocks = 0;
|
|
13107
|
+
let droppedFacts = 0;
|
|
13044
13108
|
for (const match of text.matchAll(COMPARTMENT_REGEX)) {
|
|
13045
13109
|
const attrs = match[1];
|
|
13046
13110
|
const inner = match[2];
|
|
@@ -13090,16 +13154,21 @@ function parseCompartmentOutput(text) {
|
|
|
13090
13154
|
}
|
|
13091
13155
|
}
|
|
13092
13156
|
const factsBlockMatch = text.match(FACTS_BLOCK_REGEX);
|
|
13093
|
-
const factsScope = factsBlockMatch ? factsBlockMatch[1] : text.replace(EVENTS_BLOCK_REGEX, "").replace(/<compartment\s+[^>]*?\s*>.*?<\/compartment>/gs, "");
|
|
13157
|
+
const factsScope = factsBlockMatch ? factsBlockMatch[1] : text.replace(EVENTS_BLOCK_REGEX, "").replace(/<compartment\s+[^>]*?\s*>.*?<\/compartment>/gs, "").replace(/<(meta|user_observations|primer_candidates)>.*?<\/\1>/gs, "").replace(/<\/?(?:output|compartments)>/g, "");
|
|
13094
13158
|
for (const categoryMatch of factsScope.matchAll(CATEGORY_BLOCK_REGEX)) {
|
|
13095
13159
|
const category = categoryMatch[1];
|
|
13096
13160
|
const blockContent = categoryMatch[2];
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
if (
|
|
13100
|
-
|
|
13101
|
-
|
|
13161
|
+
const items = [...blockContent.matchAll(FACT_ITEM_REGEX)].map((match) => unescapeXml(match[1].trim())).filter(Boolean);
|
|
13162
|
+
if (!HISTORIAN_CATEGORIES.has(category)) {
|
|
13163
|
+
if (items.length === 0)
|
|
13164
|
+
continue;
|
|
13165
|
+
droppedFactBlocks++;
|
|
13166
|
+
droppedFacts += items.length;
|
|
13167
|
+
log(`[historian] Dropped <facts> category ${category} (${items.length} facts)`);
|
|
13168
|
+
continue;
|
|
13102
13169
|
}
|
|
13170
|
+
for (const content of items)
|
|
13171
|
+
facts.push({ category, content });
|
|
13103
13172
|
}
|
|
13104
13173
|
const unprocessedMatch = text.match(UNPROCESSED_REGEX);
|
|
13105
13174
|
const unprocessedFrom = unprocessedMatch ? parseInt(unprocessedMatch[1], 10) : null;
|
|
@@ -13137,7 +13206,16 @@ function parseCompartmentOutput(text) {
|
|
|
13137
13206
|
}
|
|
13138
13207
|
const events = parseEvents(text);
|
|
13139
13208
|
compartments.sort((a, b) => a.startMessage - b.startMessage);
|
|
13140
|
-
return {
|
|
13209
|
+
return {
|
|
13210
|
+
compartments,
|
|
13211
|
+
facts,
|
|
13212
|
+
droppedFactBlocks,
|
|
13213
|
+
droppedFacts,
|
|
13214
|
+
events,
|
|
13215
|
+
unprocessedFrom,
|
|
13216
|
+
userObservations,
|
|
13217
|
+
primerCandidates
|
|
13218
|
+
};
|
|
13141
13219
|
}
|
|
13142
13220
|
function parseEvents(text) {
|
|
13143
13221
|
const blockMatch = text.match(EVENTS_BLOCK_REGEX);
|
|
@@ -13476,57 +13554,6 @@ function healMissingMemoryBlockIds(db, columns) {
|
|
|
13476
13554
|
|
|
13477
13555
|
// ../plugin/src/features/magic-context/workspaces.ts
|
|
13478
13556
|
import { createHash as createHash4 } from "node:crypto";
|
|
13479
|
-
|
|
13480
|
-
// ../plugin/src/features/magic-context/memory/constants.ts
|
|
13481
|
-
var V2_MEMORY_CATEGORIES = [
|
|
13482
|
-
"PROJECT_RULES",
|
|
13483
|
-
"ARCHITECTURE",
|
|
13484
|
-
"CONSTRAINTS",
|
|
13485
|
-
"CONFIG_VALUES",
|
|
13486
|
-
"NAMING"
|
|
13487
|
-
];
|
|
13488
|
-
var PROMOTABLE_CATEGORIES = [
|
|
13489
|
-
"PROJECT_RULES",
|
|
13490
|
-
"ARCHITECTURE",
|
|
13491
|
-
"CONSTRAINTS",
|
|
13492
|
-
"CONFIG_VALUES",
|
|
13493
|
-
"NAMING",
|
|
13494
|
-
"ARCHITECTURE_DECISIONS",
|
|
13495
|
-
"CONFIG_DEFAULTS",
|
|
13496
|
-
"USER_PREFERENCES",
|
|
13497
|
-
"USER_DIRECTIVES",
|
|
13498
|
-
"ENVIRONMENT",
|
|
13499
|
-
"WORKFLOW_RULES",
|
|
13500
|
-
"KNOWN_ISSUES"
|
|
13501
|
-
];
|
|
13502
|
-
var CATEGORY_PRIORITY = [
|
|
13503
|
-
"PROJECT_RULES",
|
|
13504
|
-
"ARCHITECTURE",
|
|
13505
|
-
"CONSTRAINTS",
|
|
13506
|
-
"CONFIG_VALUES",
|
|
13507
|
-
"NAMING",
|
|
13508
|
-
"USER_DIRECTIVES",
|
|
13509
|
-
"USER_PREFERENCES",
|
|
13510
|
-
"CONFIG_DEFAULTS",
|
|
13511
|
-
"ARCHITECTURE_DECISIONS",
|
|
13512
|
-
"ENVIRONMENT",
|
|
13513
|
-
"WORKFLOW_RULES",
|
|
13514
|
-
"KNOWN_ISSUES"
|
|
13515
|
-
];
|
|
13516
|
-
var MEMORY_CATEGORY_ORDER_UNKNOWN = 99;
|
|
13517
|
-
var MEMORY_CATEGORY_ORDER_PRIORITY = CATEGORY_PRIORITY.reduce((acc, category, index) => {
|
|
13518
|
-
acc[category] = index;
|
|
13519
|
-
return acc;
|
|
13520
|
-
}, {});
|
|
13521
|
-
var MEMORY_CATEGORY_ORDER_SQL = `CASE category ${CATEGORY_PRIORITY.map((category, index) => `WHEN '${category}' THEN ${index}`).join(" ")} ELSE ${MEMORY_CATEGORY_ORDER_UNKNOWN} END`;
|
|
13522
|
-
function getMemoryCategoryOrder(category) {
|
|
13523
|
-
return MEMORY_CATEGORY_ORDER_PRIORITY[category] ?? MEMORY_CATEGORY_ORDER_UNKNOWN;
|
|
13524
|
-
}
|
|
13525
|
-
var CATEGORY_DEFAULT_TTL = {
|
|
13526
|
-
WORKFLOW_RULES: 90 * 24 * 60 * 60 * 1000,
|
|
13527
|
-
KNOWN_ISSUES: 30 * 24 * 60 * 60 * 1000
|
|
13528
|
-
};
|
|
13529
|
-
// ../plugin/src/features/magic-context/workspaces.ts
|
|
13530
13557
|
var VALID_SHARE_CATEGORIES = new Set(V2_MEMORY_CATEGORIES);
|
|
13531
13558
|
var DEFAULT_WORKSPACE_SHARE_CATEGORIES = ["CONSTRAINTS"];
|
|
13532
13559
|
function tableExists2(db, tableName) {
|
|
@@ -16084,6 +16111,20 @@ var MIGRATIONS = [
|
|
|
16084
16111
|
return;
|
|
16085
16112
|
ensureColumn(db, "compartment_state_lease", "owner_pid", "INTEGER");
|
|
16086
16113
|
}
|
|
16114
|
+
},
|
|
16115
|
+
{
|
|
16116
|
+
version: 91,
|
|
16117
|
+
description: "per-project embedding high-water mark for memories written outside this host",
|
|
16118
|
+
up(db) {
|
|
16119
|
+
db.exec(`
|
|
16120
|
+
CREATE TABLE IF NOT EXISTS memory_embedding_watermarks (
|
|
16121
|
+
project_path TEXT PRIMARY KEY,
|
|
16122
|
+
written_memory_id INTEGER NOT NULL DEFAULT 0,
|
|
16123
|
+
embedded_memory_id INTEGER NOT NULL DEFAULT 0,
|
|
16124
|
+
updated_at INTEGER NOT NULL DEFAULT 0
|
|
16125
|
+
);
|
|
16126
|
+
`);
|
|
16127
|
+
}
|
|
16087
16128
|
}
|
|
16088
16129
|
];
|
|
16089
16130
|
var LATEST_MIGRATION_VERSION = MIGRATIONS.reduce((max, m) => Math.max(max, m.version), 0);
|
|
@@ -16483,7 +16524,7 @@ function getSchemaFenceRejection() {
|
|
|
16483
16524
|
function getMigrationOnOpenRefusal() {
|
|
16484
16525
|
return lastMigrationOnOpenRefusal;
|
|
16485
16526
|
}
|
|
16486
|
-
var LATEST_SUPPORTED_VERSION =
|
|
16527
|
+
var LATEST_SUPPORTED_VERSION = 91;
|
|
16487
16528
|
var BOOT_SQLITE_BUSY_TIMEOUT_MS = 5000;
|
|
16488
16529
|
var PERMISSIONS_ENFORCEABLE = process.platform !== "win32";
|
|
16489
16530
|
var defaultStoragePermissionFs = { chmodSync, mkdirSync: mkdirSync2 };
|
|
@@ -16738,6 +16779,8 @@ function inspectRpcServerDiscovery(storageDir) {
|
|
|
16738
16779
|
return junk;
|
|
16739
16780
|
continue;
|
|
16740
16781
|
}
|
|
16782
|
+
if (isOwnRpcServerRecord(record))
|
|
16783
|
+
continue;
|
|
16741
16784
|
const liveness = isPidAlive(record.pid);
|
|
16742
16785
|
if (liveness === "dead") {
|
|
16743
16786
|
staleFiles.push(portFile);
|
|
@@ -16898,8 +16941,8 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
16898
16941
|
{ readRawSessionMessagePage, readRawSessionMessages },
|
|
16899
16942
|
{ startMessageTimeBackfill }
|
|
16900
16943
|
] = await Promise.all([
|
|
16901
|
-
import("./read-session-chunk-
|
|
16902
|
-
import("./message-time-backfill-
|
|
16944
|
+
import("./read-session-chunk-2s116ah5.js"),
|
|
16945
|
+
import("./message-time-backfill-3rp0w2z9.js")
|
|
16903
16946
|
]);
|
|
16904
16947
|
await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
|
|
16905
16948
|
readPage: readRawSessionMessagePage
|
|
@@ -17481,6 +17524,15 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
|
|
|
17481
17524
|
(id, cursor_session_id, cursor_ordinal, completed, updated_at)
|
|
17482
17525
|
VALUES (1, '', 0, 0, 0);
|
|
17483
17526
|
|
|
17527
|
+
-- Highest memory id another writer (the Rust module in single-store mode) put
|
|
17528
|
+
-- into memories for a project, and how far this host has embedded. Migration v91.
|
|
17529
|
+
CREATE TABLE IF NOT EXISTS memory_embedding_watermarks (
|
|
17530
|
+
project_path TEXT PRIMARY KEY,
|
|
17531
|
+
written_memory_id INTEGER NOT NULL DEFAULT 0,
|
|
17532
|
+
embedded_memory_id INTEGER NOT NULL DEFAULT 0,
|
|
17533
|
+
updated_at INTEGER NOT NULL DEFAULT 0
|
|
17534
|
+
);
|
|
17535
|
+
|
|
17484
17536
|
CREATE TABLE IF NOT EXISTS message_history_index (
|
|
17485
17537
|
session_id TEXT PRIMARY KEY,
|
|
17486
17538
|
last_indexed_ordinal INTEGER NOT NULL DEFAULT 0,
|
|
@@ -18460,7 +18512,7 @@ function updateSessionMeta(db, sessionId, updates) {
|
|
|
18460
18512
|
db.transaction(() => {
|
|
18461
18513
|
ensureSessionMetaRow(db, sessionId);
|
|
18462
18514
|
db.prepare(`UPDATE session_meta SET ${setClauses.join(", ")} WHERE session_id = ?`).run(...values, sessionId);
|
|
18463
|
-
})();
|
|
18515
|
+
}).immediate();
|
|
18464
18516
|
}
|
|
18465
18517
|
function advanceToolReclaimWatermark(db, sessionId, maxTagNumber) {
|
|
18466
18518
|
if (maxTagNumber <= 0)
|
|
@@ -18468,7 +18520,7 @@ function advanceToolReclaimWatermark(db, sessionId, maxTagNumber) {
|
|
|
18468
18520
|
db.transaction(() => {
|
|
18469
18521
|
ensureSessionMetaRow(db, sessionId);
|
|
18470
18522
|
db.prepare("UPDATE session_meta SET tool_reclaim_watermark = MAX(COALESCE(tool_reclaim_watermark, 0), ?) WHERE session_id = ?").run(maxTagNumber, sessionId);
|
|
18471
|
-
})();
|
|
18523
|
+
}).immediate();
|
|
18472
18524
|
}
|
|
18473
18525
|
function rustCleanupHarness() {
|
|
18474
18526
|
return `${getHarness()}:rust`;
|
|
@@ -18523,7 +18575,7 @@ function clearSession(db, sessionId, rustModuleCleanupAcknowledged = false) {
|
|
|
18523
18575
|
deleteSessionScopedRows(db, [sessionId], undefined, {
|
|
18524
18576
|
rustModuleCleanupAcknowledged
|
|
18525
18577
|
});
|
|
18526
|
-
})();
|
|
18578
|
+
}).immediate();
|
|
18527
18579
|
logSlowWriteTransaction("clear-session", transactionStartedAt);
|
|
18528
18580
|
}
|
|
18529
18581
|
// ../plugin/src/features/magic-context/compartment-lease.ts
|
|
@@ -18691,7 +18743,7 @@ function appendCompartments(db, sessionId, compartments) {
|
|
|
18691
18743
|
const now = Date.now();
|
|
18692
18744
|
db.transaction(() => {
|
|
18693
18745
|
insertCompartmentRows(db, sessionId, compartments, now);
|
|
18694
|
-
})();
|
|
18746
|
+
}).immediate();
|
|
18695
18747
|
}
|
|
18696
18748
|
function saveRecompStagingPass(db, sessionId, passNumber, compartments, facts) {
|
|
18697
18749
|
const now = Date.now();
|
|
@@ -18705,7 +18757,7 @@ function saveRecompStagingPass(db, sessionId, passNumber, compartments, facts) {
|
|
|
18705
18757
|
for (const f of facts) {
|
|
18706
18758
|
factStmt.run(sessionId, f.category, f.content, passNumber, now, getHarness());
|
|
18707
18759
|
}
|
|
18708
|
-
})();
|
|
18760
|
+
}).immediate();
|
|
18709
18761
|
}
|
|
18710
18762
|
function getRecompStaging(db, sessionId) {
|
|
18711
18763
|
const compartmentRows = db.prepare("SELECT * FROM recomp_compartments WHERE session_id = ? ORDER BY sequence ASC").all(sessionId).filter(isRecompCompartmentRow);
|
|
@@ -18743,7 +18795,7 @@ function clearRecompStaging(db, sessionId) {
|
|
|
18743
18795
|
try {
|
|
18744
18796
|
db.prepare("UPDATE session_meta SET recomp_partial_range_start = 0, recomp_partial_range_end = 0 WHERE session_id = ?").run(sessionId);
|
|
18745
18797
|
} catch {}
|
|
18746
|
-
})();
|
|
18798
|
+
}).immediate();
|
|
18747
18799
|
}
|
|
18748
18800
|
function getRecompPartialRange(db, sessionId) {
|
|
18749
18801
|
try {
|
|
@@ -18947,16 +18999,21 @@ function normalizeSourceVersion(version) {
|
|
|
18947
18999
|
return `string:${version}`;
|
|
18948
19000
|
return "null";
|
|
18949
19001
|
}
|
|
18950
|
-
function
|
|
19002
|
+
function toMessageIndexSource(message) {
|
|
18951
19003
|
const content = getIndexableContent(message.role, message.parts);
|
|
18952
19004
|
return {
|
|
19005
|
+
id: message.id,
|
|
18953
19006
|
ordinal: message.ordinal,
|
|
19007
|
+
role: message.role,
|
|
19008
|
+
createdAt: message.createdAt,
|
|
18954
19009
|
sourceVersion: normalizeSourceVersion(message.version),
|
|
18955
19010
|
contentHash: createHash5("sha256").update(content).digest("hex"),
|
|
18956
|
-
role: message.role,
|
|
18957
19011
|
content
|
|
18958
19012
|
};
|
|
18959
19013
|
}
|
|
19014
|
+
function getMessageSourceSnapshot(message) {
|
|
19015
|
+
return toMessageIndexSource(message);
|
|
19016
|
+
}
|
|
18960
19017
|
function getMessageIndexSourceIdentity(message) {
|
|
18961
19018
|
const source = getMessageSourceSnapshot(message);
|
|
18962
19019
|
return JSON.stringify([
|
|
@@ -18973,8 +19030,10 @@ function isMessageIndexSourceCurrent(db, sessionId, message) {
|
|
|
18973
19030
|
return row?.message_ordinal === source.ordinal && row.source_version === source.sourceVersion && row.normalized_content_hash === source.contentHash && row.role === source.role;
|
|
18974
19031
|
}
|
|
18975
19032
|
function setMessageSource(db, sessionId, message, now) {
|
|
18976
|
-
|
|
18977
|
-
|
|
19033
|
+
return writeMessageSource(db, sessionId, getMessageSourceSnapshot(message), now);
|
|
19034
|
+
}
|
|
19035
|
+
function writeMessageSource(db, sessionId, source, now) {
|
|
19036
|
+
getUpsertMessageSourceStatement(db).run(sessionId, source.id, source.ordinal, source.sourceVersion, source.contentHash, source.role, getHarness(), now);
|
|
18978
19037
|
return source.content;
|
|
18979
19038
|
}
|
|
18980
19039
|
function getLastIndexedOrdinal(db, sessionId) {
|
|
@@ -19079,6 +19138,9 @@ function indexSingleMessage(db, sessionId, message) {
|
|
|
19079
19138
|
}
|
|
19080
19139
|
}
|
|
19081
19140
|
function indexMessagesAfterOrdinal(db, sessionId, messages, _lastIndexedOrdinal, finalWatermark = messages.length) {
|
|
19141
|
+
return indexItemsAfterOrdinal(db, sessionId, messages, finalWatermark, toMessageIndexSource);
|
|
19142
|
+
}
|
|
19143
|
+
function indexItemsAfterOrdinal(db, sessionId, items, finalWatermark, toSource) {
|
|
19082
19144
|
const now = Date.now();
|
|
19083
19145
|
let inserted = 0;
|
|
19084
19146
|
const transactionStartedAt = performance.now();
|
|
@@ -19099,21 +19161,22 @@ function indexMessagesAfterOrdinal(db, sessionId, messages, _lastIndexedOrdinal,
|
|
|
19099
19161
|
getDeleteFtsMapRangeStatement(db).run(sessionId, dirtyFloor, finalWatermark);
|
|
19100
19162
|
getDeleteMessageSourceRangeStatement(db).run(sessionId, dirtyFloor, finalWatermark);
|
|
19101
19163
|
}
|
|
19102
|
-
const
|
|
19103
|
-
for (const
|
|
19104
|
-
if (
|
|
19105
|
-
|
|
19164
|
+
const itemsByOrdinal = new Map;
|
|
19165
|
+
for (const item of items) {
|
|
19166
|
+
if (item.ordinal > effectiveWatermark && item.ordinal <= finalWatermark) {
|
|
19167
|
+
itemsByOrdinal.set(item.ordinal, item);
|
|
19106
19168
|
}
|
|
19107
19169
|
}
|
|
19108
19170
|
let coveredWatermark = effectiveWatermark;
|
|
19109
|
-
while (coveredWatermark < finalWatermark &&
|
|
19171
|
+
while (coveredWatermark < finalWatermark && itemsByOrdinal.has(coveredWatermark + 1)) {
|
|
19110
19172
|
coveredWatermark += 1;
|
|
19111
19173
|
}
|
|
19112
19174
|
for (let ordinal = effectiveWatermark + 1;ordinal <= coveredWatermark; ordinal++) {
|
|
19113
|
-
const
|
|
19114
|
-
if (!
|
|
19175
|
+
const item = itemsByOrdinal.get(ordinal);
|
|
19176
|
+
if (!item)
|
|
19115
19177
|
continue;
|
|
19116
|
-
const
|
|
19178
|
+
const message = toSource(item);
|
|
19179
|
+
const content = writeMessageSource(db, sessionId, message, now);
|
|
19117
19180
|
if (content.length === 0 || message.role !== "user" && message.role !== "assistant" || isMessageAlreadyIndexed(db, sessionId, message.id)) {
|
|
19118
19181
|
continue;
|
|
19119
19182
|
}
|
|
@@ -19578,17 +19641,33 @@ function touch(sessionId, entry) {
|
|
|
19578
19641
|
lkgHeapHolder.entries.delete(sessionId);
|
|
19579
19642
|
lkgHeapHolder.entries.set(sessionId, entry);
|
|
19580
19643
|
}
|
|
19581
|
-
function
|
|
19582
|
-
if (slot.inputContentDigests.length !== slot.inputIdSeq.length
|
|
19583
|
-
return
|
|
19644
|
+
function lkgSlotRejection(sessionId, slot) {
|
|
19645
|
+
if (slot.inputContentDigests.length !== slot.inputIdSeq.length)
|
|
19646
|
+
return `digest_count=${slot.inputContentDigests.length} inputs=${slot.inputIdSeq.length}`;
|
|
19647
|
+
const emptyDigest = slot.inputContentDigests.findIndex((digest) => digest.length === 0);
|
|
19648
|
+
if (emptyDigest >= 0)
|
|
19649
|
+
return `empty_digest_at=${emptyDigest}`;
|
|
19650
|
+
if (slot.inputContentSignatures !== undefined) {
|
|
19651
|
+
if (slot.inputContentSignatures.length !== slot.inputIdSeq.length)
|
|
19652
|
+
return `signature_count=${slot.inputContentSignatures.length} inputs=${slot.inputIdSeq.length}`;
|
|
19653
|
+
const emptySignature = slot.inputContentSignatures.findIndex((signature) => signature.length === 0);
|
|
19654
|
+
if (emptySignature >= 0)
|
|
19655
|
+
return `empty_signature_at=${emptySignature}`;
|
|
19584
19656
|
}
|
|
19585
19657
|
const bytes = slotBytes(slot);
|
|
19586
19658
|
if (bytes > LKG_SINGLE_SLOT_BYTES)
|
|
19587
|
-
return
|
|
19659
|
+
return `slot_bytes=${bytes}`;
|
|
19588
19660
|
const prior = lkgHeapHolder.entries.get(sessionId);
|
|
19589
19661
|
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))) {
|
|
19590
|
-
return
|
|
19662
|
+
return `stale row_version=${slot.rowVersion}/${prior.slot.rowVersion} capture_sequence=${slot.captureSequence ?? 0}/${prior.slot.captureSequence ?? 0}`;
|
|
19591
19663
|
}
|
|
19664
|
+
return null;
|
|
19665
|
+
}
|
|
19666
|
+
function captureSlot(sessionId, slot) {
|
|
19667
|
+
if (lkgSlotRejection(sessionId, slot) !== null)
|
|
19668
|
+
return false;
|
|
19669
|
+
const bytes = slotBytes(slot);
|
|
19670
|
+
const prior = lkgHeapHolder.entries.get(sessionId);
|
|
19592
19671
|
if (prior)
|
|
19593
19672
|
totalBytes -= prior.bytes;
|
|
19594
19673
|
lkgHeapHolder.entries.delete(sessionId);
|
|
@@ -19746,7 +19825,10 @@ function noteEntry(sessionId, messages) {
|
|
|
19746
19825
|
|
|
19747
19826
|
// ../plugin/src/hooks/magic-context/tool-sweep-policy.ts
|
|
19748
19827
|
var TOOL_SWEEP_SCOPED_MARKER = "@tool-sweep-scoped";
|
|
19749
|
-
var RESERVED_LEDGER_CONTROL_ENTRIES = [
|
|
19828
|
+
var RESERVED_LEDGER_CONTROL_ENTRIES = [
|
|
19829
|
+
TOOL_SWEEP_SCOPED_MARKER,
|
|
19830
|
+
THINKING_BINDING_STRIP_ORDER_END_MARKER
|
|
19831
|
+
];
|
|
19750
19832
|
function isReservedLedgerControlEntry(entry) {
|
|
19751
19833
|
return RESERVED_LEDGER_CONTROL_ENTRIES.includes(entry);
|
|
19752
19834
|
}
|
|
@@ -20605,7 +20687,18 @@ function noteCheckColumnsExist(db) {
|
|
|
20605
20687
|
return false;
|
|
20606
20688
|
}
|
|
20607
20689
|
}
|
|
20690
|
+
var PENDING_SESSION_NOTE_HEAL = "UPDATE notes SET status = 'active', surface_condition = NULL WHERE type = 'session' AND status = 'pending' AND surface_condition IS NOT NULL";
|
|
20691
|
+
function healPendingSessionNotes(db) {
|
|
20692
|
+
try {
|
|
20693
|
+
db.prepare(`${PENDING_SESSION_NOTE_HEAL} AND NOT ${managedAuthorityNoteRow("notes")}`).run();
|
|
20694
|
+
} catch (error) {
|
|
20695
|
+
if (!(error instanceof Error) || !error.message.includes("no such table"))
|
|
20696
|
+
throw error;
|
|
20697
|
+
db.prepare(PENDING_SESSION_NOTE_HEAL).run();
|
|
20698
|
+
}
|
|
20699
|
+
}
|
|
20608
20700
|
function getNoteById(db, noteId) {
|
|
20701
|
+
healPendingSessionNotes(db);
|
|
20609
20702
|
const row = db.prepare("SELECT * FROM notes WHERE id = ?").get(noteId);
|
|
20610
20703
|
return isNoteRow(row) ? toNote(row) : null;
|
|
20611
20704
|
}
|
|
@@ -20634,6 +20727,7 @@ function buildStatusClause(status) {
|
|
|
20634
20727
|
};
|
|
20635
20728
|
}
|
|
20636
20729
|
function getNotes(db, options = {}) {
|
|
20730
|
+
healPendingSessionNotes(db);
|
|
20637
20731
|
const clauses = [];
|
|
20638
20732
|
const params = [];
|
|
20639
20733
|
if (options.sessionId !== undefined) {
|
|
@@ -20685,6 +20779,9 @@ function updateNote(db, noteId, updates, scope) {
|
|
|
20685
20779
|
if (!existing) {
|
|
20686
20780
|
return null;
|
|
20687
20781
|
}
|
|
20782
|
+
if (updates.surfaceCondition !== undefined && existing.type !== "smart") {
|
|
20783
|
+
return null;
|
|
20784
|
+
}
|
|
20688
20785
|
const now = Date.now();
|
|
20689
20786
|
const sets = ["updated_at = ?"];
|
|
20690
20787
|
const params = [now];
|
|
@@ -20756,7 +20853,7 @@ function dismissNotes(db, noteIds, scope) {
|
|
|
20756
20853
|
noteId,
|
|
20757
20854
|
outcome: result.changes > 0 ? "dismissed" : "already_dismissed"
|
|
20758
20855
|
};
|
|
20759
|
-
}))();
|
|
20856
|
+
})).immediate();
|
|
20760
20857
|
}
|
|
20761
20858
|
function dismissNote(db, noteId, scope) {
|
|
20762
20859
|
return dismissNotes(db, [noteId], scope)[0]?.outcome === "dismissed";
|
|
@@ -21034,7 +21131,7 @@ function insertPrimerCandidates(db, candidates) {
|
|
|
21034
21131
|
if (typeof row?.id === "number")
|
|
21035
21132
|
ids.push(row.id);
|
|
21036
21133
|
}
|
|
21037
|
-
})();
|
|
21134
|
+
}).immediate();
|
|
21038
21135
|
return ids;
|
|
21039
21136
|
}
|
|
21040
21137
|
function updatePrimerCandidateEmbedding(db, candidateId, vector, modelId) {
|
|
@@ -21075,7 +21172,7 @@ function createPrimer(db, input) {
|
|
|
21075
21172
|
source_candidate_ids, source_candidate_provenance, created_at, updated_at
|
|
21076
21173
|
) VALUES (?, ?, ?, ?, ?, 'active', ?, ?, NULL, ?, ?, ?, ?)`).run(input.projectPath, input.question, vectorBlob(input.questionEmbedding), input.questionEmbeddingModelId ?? null, input.answer ?? "", input.totalSupport, input.lastObservedAt, JSON.stringify(sourceCandidateIds), serializePrimerSourceProvenance(sourceProvenance, sourceCandidateIds), now, now);
|
|
21077
21174
|
return Number(info.lastInsertRowid);
|
|
21078
|
-
})();
|
|
21175
|
+
}).immediate();
|
|
21079
21176
|
}
|
|
21080
21177
|
function updatePrimerSupport(db, input) {
|
|
21081
21178
|
db.transaction(() => {
|
|
@@ -21101,7 +21198,7 @@ function updatePrimerSupport(db, input) {
|
|
|
21101
21198
|
source_candidate_provenance = ?,
|
|
21102
21199
|
updated_at = ?
|
|
21103
21200
|
WHERE id = ?`).run(vectorBlob(input.questionEmbedding), input.questionEmbeddingModelId ?? null, input.totalSupport, input.lastObservedAt, JSON.stringify(sourceCandidateIds), serializePrimerSourceProvenance(sourceProvenance, sourceCandidateIds), input.now ?? Date.now(), input.primerId);
|
|
21104
|
-
})();
|
|
21201
|
+
}).immediate();
|
|
21105
21202
|
}
|
|
21106
21203
|
function updatePrimerAnswer(db, primerId, answer, refreshedAt = Date.now()) {
|
|
21107
21204
|
db.prepare("UPDATE primers SET answer = ?, answer_refreshed_at = ?, updated_at = ? WHERE id = ?").run(answer, refreshedAt, refreshedAt, primerId);
|
|
@@ -26214,7 +26311,7 @@ function replaceCompartmentChunkEmbeddings(db, rows) {
|
|
|
26214
26311
|
for (const row of rows) {
|
|
26215
26312
|
insert.run(row.compartmentId, row.sessionId, row.projectPath, getHarness(), row.window.windowIndex, row.window.startOrdinal, row.window.endOrdinal, row.window.chunkHash, row.modelId, row.vector.length, vectorBlob2(row.vector), row.createdAt ?? now);
|
|
26216
26313
|
}
|
|
26217
|
-
})();
|
|
26314
|
+
}).immediate();
|
|
26218
26315
|
invalidateDecodedSearchPools(db, ([sessionId, projectPath, cachedModelId]) => sessionId === rows[0].sessionId && projectPath === rows[0].projectPath && cachedModelId === modelId);
|
|
26219
26316
|
}
|
|
26220
26317
|
function loadCompartmentChunkEmbeddingsForSearch(db, sessionId, projectPath, modelId, dateRange = null) {
|
|
@@ -26295,7 +26392,7 @@ function renumberOneBasedChunkWindows(db, candidate, projectPath, modelId, windo
|
|
|
26295
26392
|
throw new Error(`Failed to renumber compartment ${candidate.id} window ${window.windowIndex + 1}`);
|
|
26296
26393
|
}
|
|
26297
26394
|
}
|
|
26298
|
-
})();
|
|
26395
|
+
}).immediate();
|
|
26299
26396
|
invalidateDecodedSearchPools(db, ([sessionId, cachedProjectPath, cachedModelId]) => sessionId === candidate.sessionId && cachedProjectPath === projectPath && cachedModelId === modelId);
|
|
26300
26397
|
}
|
|
26301
26398
|
function classifyChunkCoverageDefect(db, projectPath, modelId, candidate, maxInputTokens) {
|
|
@@ -27744,7 +27841,7 @@ function upsertCommits(db, projectPath, commits) {
|
|
|
27744
27841
|
}
|
|
27745
27842
|
}
|
|
27746
27843
|
}
|
|
27747
|
-
})();
|
|
27844
|
+
}).immediate();
|
|
27748
27845
|
return { inserted, updated };
|
|
27749
27846
|
}
|
|
27750
27847
|
function getCommitCount(db, projectPath) {
|
|
@@ -28112,7 +28209,7 @@ function recordSessionProjectIdentity(db, sessionId, projectPath) {
|
|
|
28112
28209
|
db.transaction(() => {
|
|
28113
28210
|
getUpsertSessionProjectStatement(db).run(sessionId, harness, projectPath, now);
|
|
28114
28211
|
getRepairSessionChunkProjectStatement(db).run(projectPath, sessionId, harness, projectPath, SESSION_CHUNK_REPAIR_BATCH_SIZE);
|
|
28115
|
-
})();
|
|
28212
|
+
}).immediate();
|
|
28116
28213
|
}
|
|
28117
28214
|
function repairMisScopedCompartmentChunkEmbeddingsForProject(db, projectPath) {
|
|
28118
28215
|
if (!projectPath)
|
|
@@ -28506,7 +28603,8 @@ function sameFeatures(a, b) {
|
|
|
28506
28603
|
}
|
|
28507
28604
|
function snapshotFor(registration) {
|
|
28508
28605
|
const providerIsOn = registration.providerIdentity !== OFF_PROVIDER_IDENTITY;
|
|
28509
|
-
const
|
|
28606
|
+
const historyEnabled = !registration.observationMode && providerIsOn;
|
|
28607
|
+
const enabled = historyEnabled && registration.features.memoryEnabled;
|
|
28510
28608
|
const gitCommitEnabled = !registration.observationMode && providerIsOn && registration.features.gitCommitEnabled;
|
|
28511
28609
|
const configuredModel = "model" in registration.config && typeof registration.config.model === "string" ? registration.config.model.trim() : "";
|
|
28512
28610
|
const synapseDescriptor = !registration.observationMode && registration.config.provider === "synapse" ? synapseDescriptorFromConfig(registration.config) : undefined;
|
|
@@ -28518,6 +28616,7 @@ function snapshotFor(registration) {
|
|
|
28518
28616
|
generation: registration.generation,
|
|
28519
28617
|
features: { ...registration.features },
|
|
28520
28618
|
enabled,
|
|
28619
|
+
historyEnabled,
|
|
28521
28620
|
gitCommitEnabled,
|
|
28522
28621
|
modelId: registration.observationMode || !providerIsOn ? "off" : registration.modelId,
|
|
28523
28622
|
chunkModelId: registration.observationMode || !providerIsOn ? "off" : registration.chunkModelId,
|
|
@@ -28595,10 +28694,8 @@ function recordActiveEmbeddingIdentity(db, projectIdentity, currentProviderIdent
|
|
|
28595
28694
|
if (features.gitCommitEnabled) {
|
|
28596
28695
|
recordScopeActiveIdentity(db, projectIdentity, "commit", currentProviderIdentity, now);
|
|
28597
28696
|
}
|
|
28598
|
-
|
|
28599
|
-
|
|
28600
|
-
recordScopeActiveIdentity(db, projectIdentity, "chunk", currentChunkIdentity, now);
|
|
28601
|
-
}
|
|
28697
|
+
repairMisScopedCompartmentChunkEmbeddingsForProject(db, projectIdentity);
|
|
28698
|
+
recordScopeActiveIdentity(db, projectIdentity, "chunk", currentChunkIdentity, now);
|
|
28602
28699
|
db.exec("COMMIT");
|
|
28603
28700
|
logSlowWriteTransaction("embedding_identity_record", transactionStartedAt);
|
|
28604
28701
|
} catch (error) {
|
|
@@ -28717,7 +28814,7 @@ function sweepStaleEmbeddingIdentitiesForProject(db, projectIdentity, now = Date
|
|
|
28717
28814
|
},
|
|
28718
28815
|
{
|
|
28719
28816
|
scope: "chunk",
|
|
28720
|
-
enabled: snapshot.
|
|
28817
|
+
enabled: snapshot.historyEnabled && snapshot.chunkModelId !== "off",
|
|
28721
28818
|
currentModelId: snapshot.chunkModelId
|
|
28722
28819
|
}
|
|
28723
28820
|
];
|
|
@@ -28857,7 +28954,7 @@ function registerProjectShadowEmbedding(db, projectIdentity, config, sourceDirec
|
|
|
28857
28954
|
recordScopeActiveIdentity(db, projectIdentity, "commit", registration.modelId, now);
|
|
28858
28955
|
recordScopeActiveIdentity(db, projectIdentity, "chunk", registration.chunkModelId, now);
|
|
28859
28956
|
persistShadowDescriptor(db, registration);
|
|
28860
|
-
})();
|
|
28957
|
+
}).immediate();
|
|
28861
28958
|
maybeArmShadowBackfill(db, projectIdentity, registration, options.manualBackfill === true);
|
|
28862
28959
|
return {
|
|
28863
28960
|
projectIdentity,
|
|
@@ -28867,6 +28964,7 @@ function registerProjectShadowEmbedding(db, projectIdentity, config, sourceDirec
|
|
|
28867
28964
|
generation,
|
|
28868
28965
|
features: { memoryEnabled: true, gitCommitEnabled: true },
|
|
28869
28966
|
enabled: true,
|
|
28967
|
+
historyEnabled: true,
|
|
28870
28968
|
gitCommitEnabled: true,
|
|
28871
28969
|
modelId: registration.modelId,
|
|
28872
28970
|
chunkModelId: registration.chunkModelId,
|
|
@@ -29075,6 +29173,8 @@ function maybeArmShadowBackfill(db, projectIdentity, shadow, manualBackfill = fa
|
|
|
29075
29173
|
const stallKey = `${projectIdentity}:${scope}`;
|
|
29076
29174
|
if (primaryModelId === "off" || shadowModelId === "off")
|
|
29077
29175
|
continue;
|
|
29176
|
+
if (scope === "memory" && !primary.features.memoryEnabled)
|
|
29177
|
+
continue;
|
|
29078
29178
|
const batch = shadowBackfillCandidateBatch(db, projectIdentity, scope, primaryModelId, shadow, SHADOW_MAX_ITEMS_PER_TICK);
|
|
29079
29179
|
const persisted = getPersistedShadowBackfillState(db, projectIdentity, scope, shadowModelId);
|
|
29080
29180
|
if (batch.ids.length === 0) {
|
|
@@ -29211,7 +29311,7 @@ async function processShadowQueueItem(item) {
|
|
|
29211
29311
|
hashGuardRejected = true;
|
|
29212
29312
|
}
|
|
29213
29313
|
}
|
|
29214
|
-
})();
|
|
29314
|
+
}).immediate();
|
|
29215
29315
|
return {
|
|
29216
29316
|
writes,
|
|
29217
29317
|
...writes === 0 ? {
|
|
@@ -29245,7 +29345,7 @@ async function processShadowQueueItem(item) {
|
|
|
29245
29345
|
saveCommitEmbedding(db, row.sha, vector, registration.modelId);
|
|
29246
29346
|
writes += 1;
|
|
29247
29347
|
}
|
|
29248
|
-
})();
|
|
29348
|
+
}).immediate();
|
|
29249
29349
|
return {
|
|
29250
29350
|
writes,
|
|
29251
29351
|
...writes === 0 ? { refusalReason: embedded.refusalReason ?? "provider_returned_no_vectors" } : {}
|
|
@@ -29567,13 +29667,17 @@ function getLoadUnembeddedMemoriesStatement(db) {
|
|
|
29567
29667
|
return stmt;
|
|
29568
29668
|
}
|
|
29569
29669
|
async function embedUnembeddedMemoriesForProject(db, projectIdentity, batchSize = 10) {
|
|
29670
|
+
const outcome = await embedUnembeddedMemoriesForProjectOutcome(db, projectIdentity, batchSize);
|
|
29671
|
+
return outcome.kind === "embedded" ? outcome.count : 0;
|
|
29672
|
+
}
|
|
29673
|
+
async function embedUnembeddedMemoriesForProjectOutcome(db, projectIdentity, batchSize = 10) {
|
|
29570
29674
|
const snapshot = getProjectEmbeddingSnapshot(projectIdentity);
|
|
29571
29675
|
if (!snapshot?.enabled)
|
|
29572
|
-
return
|
|
29676
|
+
return { kind: "disabled" };
|
|
29573
29677
|
const normalizedBatchSize = Math.max(1, Math.floor(batchSize));
|
|
29574
29678
|
const memories = getLoadUnembeddedMemoriesStatement(db).all(snapshot.modelId, projectIdentity, normalizedBatchSize).filter(isUnembeddedMemoryRow);
|
|
29575
29679
|
if (memories.length === 0)
|
|
29576
|
-
return
|
|
29680
|
+
return { kind: "done" };
|
|
29577
29681
|
try {
|
|
29578
29682
|
const result = await embedItemsForProject(projectIdentity, memories.map((memory) => ({
|
|
29579
29683
|
id: `memory:${memory.id}`,
|
|
@@ -29581,7 +29685,7 @@ async function embedUnembeddedMemoriesForProject(db, projectIdentity, batchSize
|
|
|
29581
29685
|
contentSha256: contentSha256(memory.content)
|
|
29582
29686
|
})), undefined, db, projectIdentity);
|
|
29583
29687
|
if (!result)
|
|
29584
|
-
return
|
|
29688
|
+
return { kind: "unavailable" };
|
|
29585
29689
|
let embeddedCount = 0;
|
|
29586
29690
|
db.transaction(() => {
|
|
29587
29691
|
for (const memory of memories) {
|
|
@@ -29592,12 +29696,12 @@ async function embedUnembeddedMemoriesForProject(db, projectIdentity, batchSize
|
|
|
29592
29696
|
embeddedCount += 1;
|
|
29593
29697
|
}
|
|
29594
29698
|
}
|
|
29595
|
-
})();
|
|
29699
|
+
}).immediate();
|
|
29596
29700
|
enqueueShadowEmbeddingItems(projectIdentity, "memory", memories.filter((memory) => result.vectors.has(`memory:${memory.id}`)).map((memory) => String(memory.id)));
|
|
29597
|
-
return embeddedCount;
|
|
29701
|
+
return { kind: "embedded", count: embeddedCount };
|
|
29598
29702
|
} catch (error) {
|
|
29599
29703
|
log("[magic-context] failed to proactively embed missing memories:", error);
|
|
29600
|
-
return
|
|
29704
|
+
return { kind: "failed", error };
|
|
29601
29705
|
}
|
|
29602
29706
|
}
|
|
29603
29707
|
async function embedCommitBatch(db, projectIdentity, batchSize) {
|
|
@@ -29623,7 +29727,7 @@ async function embedCommitBatch(db, projectIdentity, batchSize) {
|
|
|
29623
29727
|
saveCommitEmbedding(db, commit.sha, embedding, result.modelId);
|
|
29624
29728
|
embeddedCount += 1;
|
|
29625
29729
|
}
|
|
29626
|
-
})();
|
|
29730
|
+
}).immediate();
|
|
29627
29731
|
enqueueShadowEmbeddingItems(projectIdentity, "commit", commits.filter((commit) => result.vectors.has(`commit:${commit.sha}`)).map((commit) => commit.sha));
|
|
29628
29732
|
return embeddedCount;
|
|
29629
29733
|
}
|
|
@@ -29774,7 +29878,7 @@ async function embedCandidateChunkBatch(db, projectIdentity, modelId, candidates
|
|
|
29774
29878
|
}
|
|
29775
29879
|
async function embedSessionCompartmentChunks(db, projectIdentity, sessionId, options) {
|
|
29776
29880
|
const snapshot = getProjectEmbeddingSnapshot(projectIdentity);
|
|
29777
|
-
if (!snapshot?.
|
|
29881
|
+
if (!snapshot?.historyEnabled || snapshot.chunkModelId === "off") {
|
|
29778
29882
|
return { status: "disabled", embedded: 0, total: 0 };
|
|
29779
29883
|
}
|
|
29780
29884
|
recordSessionProjectIdentity(db, sessionId, projectIdentity);
|
|
@@ -29878,7 +29982,7 @@ async function embedSessionCompartmentChunks(db, projectIdentity, sessionId, opt
|
|
|
29878
29982
|
}
|
|
29879
29983
|
function getEmbeddingCoverageStatus(db, projectIdentity, sessionId) {
|
|
29880
29984
|
const snapshot = getProjectEmbeddingSnapshot(projectIdentity);
|
|
29881
|
-
if (!snapshot?.
|
|
29985
|
+
if (!snapshot?.historyEnabled || snapshot.chunkModelId === "off") {
|
|
29882
29986
|
return {
|
|
29883
29987
|
enabled: false,
|
|
29884
29988
|
model: snapshot?.model ?? "off",
|
|
@@ -29891,7 +29995,7 @@ function getEmbeddingCoverageStatus(db, projectIdentity, sessionId) {
|
|
|
29891
29995
|
};
|
|
29892
29996
|
}
|
|
29893
29997
|
const session = countSessionCompartmentEmbedCoverage(db, projectIdentity, sessionId, snapshot.chunkModelId, getProjectEmbeddingMaxInputTokens(projectIdentity));
|
|
29894
|
-
const memories = getMemoryEmbedCoverage(db, projectIdentity, snapshot.modelId);
|
|
29998
|
+
const memories = snapshot.enabled ? getMemoryEmbedCoverage(db, projectIdentity, snapshot.modelId) : { embedded: 0, total: 0, memoryEnabled: false };
|
|
29895
29999
|
const gitEnabled = snapshot.gitCommitEnabled;
|
|
29896
30000
|
const commits = gitEnabled ? {
|
|
29897
30001
|
embedded: countEmbeddedCommits(db, projectIdentity, snapshot.modelId),
|
|
@@ -31803,13 +31907,7 @@ function recordRetrospectiveWindowProcessed(db, projectPath, windowKey) {
|
|
|
31803
31907
|
}
|
|
31804
31908
|
|
|
31805
31909
|
// ../plugin/src/features/magic-context/dreamer/curate-category-rotation.ts
|
|
31806
|
-
var CURATE_MEMORY_CATEGORIES =
|
|
31807
|
-
"PROJECT_RULES",
|
|
31808
|
-
"ARCHITECTURE",
|
|
31809
|
-
"CONSTRAINTS",
|
|
31810
|
-
"CONFIG_VALUES",
|
|
31811
|
-
"NAMING"
|
|
31812
|
-
];
|
|
31910
|
+
var CURATE_MEMORY_CATEGORIES = V2_MEMORY_CATEGORIES;
|
|
31813
31911
|
var LEGACY_CURATE_CATEGORY_BUCKETS = {
|
|
31814
31912
|
ARCHITECTURE_DECISIONS: "ARCHITECTURE",
|
|
31815
31913
|
CONFIG_DEFAULTS: "CONFIG_VALUES",
|
|
@@ -31907,7 +32005,7 @@ var BEHAVIORAL_WHEN_CLAUSE = /\bwhen\s+(?:you(?:'re|\s+are)?|we(?:'re|\s+are)?|t
|
|
|
31907
32005
|
var WORKFLOW_IMPERATIVE = /(?:^|[.!?]\s+|\n\s*)(?:[-*]\s+|\d+[.)]\s+)?(?:please\s+)?(?:run|use|check|ask|avoid|prefer|ensure|keep|follow|brief|report|inspect|search|open|read|review|validate|confirm|delegate|stop|start|remember)\b/i;
|
|
31908
32006
|
var DECISION_AUTHORITY = /\b(?:the\s+)?(?:user|operator|maintainer|owner)\s+(?:decides|chooses|approves|has\s+(?:the\s+)?final\s+say)\b/i;
|
|
31909
32007
|
function isDirectiveShapedProjectRule(category, content) {
|
|
31910
|
-
if (category !==
|
|
32008
|
+
if (category !== V2_MEMORY_CATEGORIES[0])
|
|
31911
32009
|
return false;
|
|
31912
32010
|
const text = content.trim();
|
|
31913
32011
|
if (!text)
|
|
@@ -31916,13 +32014,7 @@ function isDirectiveShapedProjectRule(category, content) {
|
|
|
31916
32014
|
}
|
|
31917
32015
|
|
|
31918
32016
|
// ../plugin/src/features/magic-context/dreamer/curate-memory-safety.ts
|
|
31919
|
-
var PROJECT_SCOPED_CATEGORIES = new Set(
|
|
31920
|
-
"PROJECT_RULES",
|
|
31921
|
-
"ARCHITECTURE",
|
|
31922
|
-
"CONSTRAINTS",
|
|
31923
|
-
"CONFIG_VALUES",
|
|
31924
|
-
"NAMING"
|
|
31925
|
-
]);
|
|
32017
|
+
var PROJECT_SCOPED_CATEGORIES = new Set(V2_MEMORY_CATEGORIES);
|
|
31926
32018
|
var USER_PROFILE_REFERENCE = /\buser(?:[\s_-]+)(?:profile|preferences?)\b|\bU\d+\b/i;
|
|
31927
32019
|
var refusalCountsBySession = new Map;
|
|
31928
32020
|
function isSurvivingConsolidationTarget(memory, successor, projectIdentity) {
|
|
@@ -32007,7 +32099,7 @@ async function ensureMemoryEmbeddings(args) {
|
|
|
32007
32099
|
staged.set(memory.id, { embedding, modelId: result.modelId });
|
|
32008
32100
|
}
|
|
32009
32101
|
}
|
|
32010
|
-
})();
|
|
32102
|
+
}).immediate();
|
|
32011
32103
|
const currentSnapshot = getProjectEmbeddingSnapshot(args.projectIdentity);
|
|
32012
32104
|
if (!currentSnapshot || currentSnapshot.generation !== result.generation) {
|
|
32013
32105
|
return args.existingEmbeddings;
|
|
@@ -32689,7 +32781,7 @@ function updateMemoryContent(db, id, content, normalizedHash) {
|
|
|
32689
32781
|
deleteEmbeddingOnContentUpdateStatements.set(db, stmt);
|
|
32690
32782
|
}
|
|
32691
32783
|
stmt.run(id);
|
|
32692
|
-
})();
|
|
32784
|
+
}).immediate();
|
|
32693
32785
|
if (memory) {
|
|
32694
32786
|
invalidateMemory(memory.projectPath, id);
|
|
32695
32787
|
}
|
|
@@ -32851,7 +32943,7 @@ async function embedAndStoreMemory(db, sessionId, projectPath, memoryId, content
|
|
|
32851
32943
|
if (result) {
|
|
32852
32944
|
db.transaction(() => {
|
|
32853
32945
|
saveEmbeddingIfHashMatches(db, memoryId, result.vector, result.modelId, hashBeforeEmbed);
|
|
32854
|
-
})();
|
|
32946
|
+
}).immediate();
|
|
32855
32947
|
}
|
|
32856
32948
|
} catch (error) {
|
|
32857
32949
|
sessionLog(sessionId, `memory embedding failed for memory ${memoryId}:`, error);
|
|
@@ -33027,7 +33119,7 @@ async function runGit(cwd, args) {
|
|
|
33027
33119
|
return String(result.stdout);
|
|
33028
33120
|
} catch (error) {
|
|
33029
33121
|
if (error.killed || error.code === "ETIMEDOUT") {
|
|
33030
|
-
throw new Error(`Git verification command timed out after ${GIT_TIMEOUT_MS2}ms`, {
|
|
33122
|
+
throw new Error(`Git verification command git ${args.join(" ")} timed out after ${GIT_TIMEOUT_MS2}ms`, {
|
|
33031
33123
|
cause: error
|
|
33032
33124
|
});
|
|
33033
33125
|
}
|
|
@@ -33690,7 +33782,7 @@ function createCtxMemoryTool(deps) {
|
|
|
33690
33782
|
newContent: content
|
|
33691
33783
|
});
|
|
33692
33784
|
}
|
|
33693
|
-
})();
|
|
33785
|
+
}).immediate();
|
|
33694
33786
|
queueEmbedding({
|
|
33695
33787
|
deps,
|
|
33696
33788
|
projectIdentity,
|
|
@@ -34628,6 +34720,13 @@ wake plane active — create a scheduled wake instead; stored as a plain note.`)
|
|
|
34628
34720
|
updates.content = params.content.trim();
|
|
34629
34721
|
let compilation;
|
|
34630
34722
|
if (params.surface_condition?.trim()) {
|
|
34723
|
+
const project = resolveProject(ctx.cwd);
|
|
34724
|
+
const existing = project ? getNoteByIdInScope(deps.db, noteId, {
|
|
34725
|
+
projectPath: project,
|
|
34726
|
+
sessionId
|
|
34727
|
+
}) : null;
|
|
34728
|
+
if (existing?.type === "session")
|
|
34729
|
+
return err3("Error: Only a note created with a condition can have one. Write a new note with surface_condition, and dismiss this one.");
|
|
34631
34730
|
const surfaceCondition = params.surface_condition.trim();
|
|
34632
34731
|
updates.surfaceCondition = surfaceCondition;
|
|
34633
34732
|
compilation = await compileSurfaceCondition(surfaceCondition, {
|
|
@@ -34855,7 +34954,7 @@ function createCtxReduceTool(deps) {
|
|
|
34855
34954
|
for (const id of dropIds) {
|
|
34856
34955
|
queuePendingOp(deps.db, sessionId, id, "drop", now);
|
|
34857
34956
|
}
|
|
34858
|
-
})();
|
|
34957
|
+
}).immediate();
|
|
34859
34958
|
} catch (error) {
|
|
34860
34959
|
return err4(`Error: Failed to queue ctx_reduce operations. ${getErrorMessage(error)}`);
|
|
34861
34960
|
}
|
|
@@ -35065,7 +35164,7 @@ async function embedUnembeddedCommits(db, projectPath) {
|
|
|
35065
35164
|
saveCommitEmbedding(db, row.sha, embedding, result.modelId);
|
|
35066
35165
|
embeddedThisBatch += 1;
|
|
35067
35166
|
}
|
|
35068
|
-
})();
|
|
35167
|
+
}).immediate();
|
|
35069
35168
|
enqueueShadowEmbeddingItems(projectPath, "commit", rows.filter((row) => result.vectors.has(`commit:${row.sha}`)).map((row) => row.sha));
|
|
35070
35169
|
} catch (error) {
|
|
35071
35170
|
log(`[git-commits] embed batch failed for ${projectPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -36513,7 +36612,7 @@ async function unifiedSearch(db, sessionId, projectPath, query, options = {}) {
|
|
|
36513
36612
|
}
|
|
36514
36613
|
const runPrimers = activeSources.has("primer") && memoryFeatureEnabled;
|
|
36515
36614
|
const runNotes = activeSources.has("note");
|
|
36516
|
-
const runCompartmentChunks = runMessages &&
|
|
36615
|
+
const runCompartmentChunks = runMessages && embeddingEnabled;
|
|
36517
36616
|
const needsEmbedding = (runMemory || runGitCommits || runCompartmentChunks || runPrimers) && embeddingEnabled && isEmbeddingRuntimeEnabled();
|
|
36518
36617
|
const queryEmbeddingPromise = needsEmbedding ? embedQuery(trimmedQuery, options.signal).catch((error) => {
|
|
36519
36618
|
log(`[search] query embedding failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -36635,7 +36734,7 @@ async function unifiedSearch(db, sessionId, projectPath, query, options = {}) {
|
|
|
36635
36734
|
throw error;
|
|
36636
36735
|
}
|
|
36637
36736
|
}
|
|
36638
|
-
})();
|
|
36737
|
+
}).immediate();
|
|
36639
36738
|
}
|
|
36640
36739
|
}
|
|
36641
36740
|
return results;
|
|
@@ -37480,7 +37579,7 @@ function insertUserMemoryCandidates(db, candidates) {
|
|
|
37480
37579
|
for (const c of candidates) {
|
|
37481
37580
|
stmt.run(c.content, c.sessionId, c.sourceCompartmentStart ?? null, c.sourceCompartmentEnd ?? null, now);
|
|
37482
37581
|
}
|
|
37483
|
-
})();
|
|
37582
|
+
}).immediate();
|
|
37484
37583
|
logSlowWriteTransaction("user_memory_candidate_insert", transactionStartedAt);
|
|
37485
37584
|
}
|
|
37486
37585
|
function getUserMemoryCandidates(db) {
|
|
@@ -37539,7 +37638,7 @@ function insertUserMemory(db, content, sourceCandidateIds) {
|
|
|
37539
37638
|
(content, status, promoted_at, source_candidate_ids, source_candidate_provenance, created_at, updated_at)
|
|
37540
37639
|
VALUES (?, 'active', ?, ?, ?, ?, ?)`).run(content, now, JSON.stringify(sourceCandidateIds), serializeUserMemorySourceProvenance(sourceProvenance, sourceCandidateIds), now, now);
|
|
37541
37640
|
return Number(result.lastInsertRowid);
|
|
37542
|
-
})();
|
|
37641
|
+
}).immediate();
|
|
37543
37642
|
}
|
|
37544
37643
|
function getActiveUserMemories(db) {
|
|
37545
37644
|
const rows = db.prepare("SELECT id, content, status, promoted_at, source_candidate_ids, source_candidate_provenance, created_at, updated_at FROM user_memories WHERE status = 'active' ORDER BY promoted_at ASC, id ASC").all();
|
|
@@ -37829,7 +37928,7 @@ function injectCompactionMarker(args) {
|
|
|
37829
37928
|
time_created = excluded.time_created,
|
|
37830
37929
|
time_updated = excluded.time_updated,
|
|
37831
37930
|
data = excluded.data`).run(summaryPartId, summaryMsgId, args.sessionId, boundaryTime + 1, boundaryTime + 1, JSON.stringify({ type: "text", text: args.summaryText }));
|
|
37832
|
-
})();
|
|
37931
|
+
}).immediate();
|
|
37833
37932
|
log(`[magic-context] compaction-marker: injected boundary at user msg ${boundary.id} (ordinal ~${args.endOrdinal}), summary msg ${summaryMsgId}`);
|
|
37834
37933
|
return {
|
|
37835
37934
|
boundaryMessageId: boundary.id,
|
|
@@ -37877,7 +37976,7 @@ function persistMarkerStateAndDropReplacedTag(db, sessionId, state, replacedSumm
|
|
|
37877
37976
|
if (replacedSummaryMessageId !== null) {
|
|
37878
37977
|
dropMarkerSummaryTag(db, sessionId, replacedSummaryMessageId);
|
|
37879
37978
|
}
|
|
37880
|
-
})();
|
|
37979
|
+
}).immediate();
|
|
37881
37980
|
logSlowWriteTransaction("marker-drain", transactionStartedAt);
|
|
37882
37981
|
}
|
|
37883
37982
|
function getCompartmentEndMessageIdForOrdinal(db, sessionId, endOrdinal) {
|
|
@@ -38509,6 +38608,9 @@ function stripMemoryMuralBlock(m0Text) {
|
|
|
38509
38608
|
|
|
38510
38609
|
`).trim();
|
|
38511
38610
|
}
|
|
38611
|
+
var absentBoundaryEpisodeBySession = new BoundedSessionMap(INJECTION_CACHE_MAX);
|
|
38612
|
+
var precedesVerdictBySession = new BoundedSessionMap(INJECTION_CACHE_MAX);
|
|
38613
|
+
var precedesWindowLoggedBySession = new BoundedSessionMap(INJECTION_CACHE_MAX);
|
|
38512
38614
|
|
|
38513
38615
|
// ../plugin/src/tools/ctx-search/constants.ts
|
|
38514
38616
|
var CTX_SEARCH_DESCRIPTION = `Search the archive — everything that ever happened in this project, not just what is on your desk.
|
|
@@ -38658,7 +38760,7 @@ function createCtxSearchTool(deps) {
|
|
|
38658
38760
|
await deps.ensureProjectRegistered?.(ctx.cwd, deps.db);
|
|
38659
38761
|
const snapshot = getProjectEmbeddingSnapshot(projectIdentity);
|
|
38660
38762
|
const memoryEnabled = snapshot?.features.memoryEnabled ?? deps.memoryEnabled;
|
|
38661
|
-
const embeddingEnabled = snapshot ? snapshot.
|
|
38763
|
+
const embeddingEnabled = snapshot ? snapshot.historyEnabled : deps.embeddingEnabled;
|
|
38662
38764
|
const gitCommitsEnabled = snapshot?.gitCommitEnabled ?? deps.gitCommitsEnabled ?? false;
|
|
38663
38765
|
const lastCompartmentEnd = getLastCompartmentEndMessage(deps.db, sessionId);
|
|
38664
38766
|
const messageOrdinalCutoff = lastCompartmentEnd >= 0 ? lastCompartmentEnd : 0;
|
|
@@ -38718,6 +38820,22 @@ function createCtxSearchTool(deps) {
|
|
|
38718
38820
|
};
|
|
38719
38821
|
}
|
|
38720
38822
|
|
|
38823
|
+
// src/tools/pi-tool-errors.ts
|
|
38824
|
+
function throwReturnedToolErrors(tool) {
|
|
38825
|
+
const execute = tool.execute.bind(tool);
|
|
38826
|
+
return {
|
|
38827
|
+
...tool,
|
|
38828
|
+
async execute(...args) {
|
|
38829
|
+
const result = await execute(...args);
|
|
38830
|
+
if ("isError" in result && result.isError) {
|
|
38831
|
+
throw new Error(result.content.filter((block) => block.type === "text").map((block) => block.text).join(`
|
|
38832
|
+
`));
|
|
38833
|
+
}
|
|
38834
|
+
return result;
|
|
38835
|
+
}
|
|
38836
|
+
};
|
|
38837
|
+
}
|
|
38838
|
+
|
|
38721
38839
|
// src/tools/todowrite.ts
|
|
38722
38840
|
var TodoItem = _Object_({
|
|
38723
38841
|
content: String2({ description: "Brief description of the task" }),
|
|
@@ -38790,11 +38908,11 @@ function registerMagicContextTools(pi, opts) {
|
|
|
38790
38908
|
const surfaceTool = (definition) => {
|
|
38791
38909
|
const parameters = structuredClone(definition.parameters);
|
|
38792
38910
|
applyJsonSchemaParameterDescriptions(definition.name, parameters, registration.preset);
|
|
38793
|
-
return {
|
|
38911
|
+
return throwReturnedToolErrors({
|
|
38794
38912
|
...definition,
|
|
38795
38913
|
parameters,
|
|
38796
38914
|
description: registration.descriptionFor(definition.name, definition.description)
|
|
38797
|
-
};
|
|
38915
|
+
});
|
|
38798
38916
|
};
|
|
38799
38917
|
pi.registerTool(surfaceTool(createCtxSearchTool({
|
|
38800
38918
|
db: opts.db,
|
|
@@ -38815,7 +38933,7 @@ function registerMagicContextTools(pi, opts) {
|
|
|
38815
38933
|
};
|
|
38816
38934
|
pi.registerTool(surfaceTool(createCtxMemoryTool(memoryDeps)));
|
|
38817
38935
|
if (opts.allowDreamerActions === true) {
|
|
38818
|
-
pi.registerTool(createCtxMemoryListTool(memoryDeps));
|
|
38936
|
+
pi.registerTool(throwReturnedToolErrors(createCtxMemoryListTool(memoryDeps)));
|
|
38819
38937
|
}
|
|
38820
38938
|
}
|
|
38821
38939
|
if (!opts.sessionScopedToolsDisabled) {
|
|
@@ -38842,4 +38960,4 @@ function registerMagicContextTools(pi, opts) {
|
|
|
38842
38960
|
}
|
|
38843
38961
|
}
|
|
38844
38962
|
|
|
38845
|
-
export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, canonicalModelIdentity, piModelRefToCanonical, resolveModelRefForPi, modelRefLookupOrder, ompModelRefToCanonical, resolveModelRefForOmp, setStoragePrivatePermissionEnforcement, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, reloadWindowOverlay, getWindowOverlay, resolveWindowOverlayFacts, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, isSaneLimit, resolveOutputReserve, getSdkContextLimit, getSdkOutputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, withContentLanguageDirective, buildPrimaryLanguageDirective, parseCron, nextOccurrence, nextDueAtMs, resolveModelConfigValue, resolveModelConfigOrDefault, DEFAULT_HISTORIAN_TIMEOUT_MS, LIVE_RELOAD_CONFIG_PATHS, getProtectedTokensTierOverrides, FAIL_CLOSED_DOCTOR_COMMAND, formatFailClosedBlockingMessage, createFailClosedBlockingError, isFailClosedBlockingError, shouldBypassFailClosedBlock, createFailClosedController, ProjectIdentityError, resolveProjectIdentityStrict, resolveProjectIdentity, resolveProjectIdentityForSession, beginBootQuietPeriod, scheduleAfterBootQuiet, clearCompressionDepth, clearCompressionDepthRange, getMessageIndexSourceIdentity, isMessageIndexSourceCurrent, getLastIndexedOrdinal, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, indexSingleMessage, indexMessagesAfterOrdinal, sweepOrphanedOpenCodeMessageIndexes, recordSessionProjectIdentity, piHarnessKindFromExecutable, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, HAS_COMPARTMENT_CONTENT_SQL, persistCachedM0, clearCachedM0M1, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getModuleNoteEvaluationBridge, getContextStoreUuid, drainMirrorPages, parseCompartmentOutput, resolveWorkspaceShareCategories, resolveWorkspaceIdentitySet, expandWorkspaceIdentitySetWithAliases, sourceNameForMemory, computeWorkspaceEpochFingerprint, readProjectDocsCanonical, MAX_EXECUTE_THRESHOLD, escalationBands, HYGIENE_PROVIDER_UNITS_VERSION, sessionDecisionCalibration, transitionSessionHygieneUnits, computeProtectionWindow, readEpochFloorSnapshot, getProtectionWindowForSession, isProviderOverflowFailClosedProven, describeProtectedTailDrainBudgetSkip, loadProtectedTailMeta, markProtectedTailPolicyV3Seeded, recordProtectedTailPublicationFloor, recordProtectedTailNoEligibleHead, getWrapupInProgressState, isWrapupInProgress, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, reserveProtectedTailDrainTokens, clearEmergencyDrainLatch, recordHistorianDrainFailure, clearHistorianDrainFailure, rollbackProtectedTailDrainReservation, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, setPersistedNoteNudgeTrigger, setPersistedNoteNudgeTriggerMessageId, getNoteNudgeAnchors, getAutoSearchHintDecisions, deliverNoteNudgeAtomic, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, pruneAutoSearchHintDecisions, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, getNoteLastReadAt, incrementHistorianFailure, clearHistorianFailureState, getOverflowState, recordOverflowDetected, clearEmergencyRecovery, clearDetectedContextLimit, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, NEWEST_REASONING_BEARING_ASSISTANT, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, thinkingBindingRecoveryFrozenId, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getProcessedImageStrippedIds, addProcessedImageStrippedIds, getPendingCompactionMarkerState, getCompactionMarkerHealth, clearPendingCompactionMarkerStateIf, getPendingPiCompactionMarkerState, setPendingPiCompactionMarkerState, clearPendingPiCompactionMarkerStateIf, getSessionsWithPendingPiMarker, setSessionWorkMetrics, getSessionWorkMetrics, resolveEpochFloorForPass, BoundedSessionMap, registerLkgPersistence, signatureForFields, lkgContentFields, lkgContentDigestFromFields, exactReusablePrefix, incrementalLkgContentDigests, captureSlot, getSlot, dropSlot, noteEntry, encodePiContentDecision, getPiContentDecisions, freezePiContentDecision, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, getErrorMessage, describeError, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, applySqliteTuningPragmas, runSqliteOptimize, openDatabase, openDatabaseAsync, queueM0Mutation, getMaxM0MutationId, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, getNotes, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, markNoteReady, markNoteChecked, queuePendingOp, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, insertPrimerCandidates, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, noteTouchedAt, noteNudgePickIndex, formatNoteNudge, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, readPiSessionSnapshot, readPiSessionMessages, readPiSessionMessagePage, findLastModelKeyFromBranch, convertEntriesToRawMessages, convertEntriesToRawMessagePage, computeCueContentHash, hasMuralCueColumns, getMuralCueState, memoryNeedsCue, setMuralCue, recordMuralCueRejection, invalidateMemory, computeNormalizedHash, hasMemoryShareableColumn, hasMemoryClassifiedAtColumn, getUnclassifiedMemoryIds, insertMemory, getMemoryByHash, getMemoriesByProject, getMemoriesByProjects, getMaxMemoryIdForProjects, getMemoryById, setMemoryClassification, archiveMemory, getMemoryCountsByStatus, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getTaskScheduleState, getFailingDreamTasks, getMostRecentTaskRunAt, pruneNonCanonicalTaskRows, deleteTaskScheduleRowsForProject, seedTaskScheduleState, writeTaskScheduleState, isRetrospectiveWindowProcessed, recordRetrospectiveWindowProcessed, curateCategoryForMemoryCategory, peekCurateCategoryScope, beginCurateCategoryRun, curateTaskStateAfterSuccess, formatSynapseLaneDescriptor, buildCanonicalChunkTextFromFts, buildCompartmentSummaryFallbackText, canonicalizeInMemoryChunkTextForEmbedding, chunkCanonicalText, chunkEmbeddingWindowsAreCurrent, replaceCompartmentChunkEmbeddings, cosineSimilarity, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease, describeShadowBackfillWriteRefusal, contentSha256, sweepStaleEmbeddingIdentitiesForProject, enqueueShadowEmbeddingItems, getProjectEmbeddingSnapshot, getProjectChunkEmbeddingModelId, getProjectEmbeddingMaxInputTokens, embedTextForProject, embedBatchForProject, embedItemsForProject, embedUnembeddedMemoriesForProject, drainCommitBacklogForProject, embedSessionCompartmentChunks, getEmbeddingCoverageStatus, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, isDirectiveShapedProjectRule, takeCurateSafetyRefusalCount, wakePlaneStatus, indexCommitsForProject, embedUnembeddedCommits, loadPiConfig, loadPiConfigDetailed, ensureProjectRegisteredFromPiDirectory, resolvePiHarnessDetection, resolvePiHarnessKind, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, MEMORY_RENDER_FORMAT_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, temporalMarkerPrefix, clearInjectionCache, getVisibleMemoryIds, renderHistorianMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, unifiedSearch, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
|
|
38963
|
+
export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, canonicalModelIdentity, piModelRefToCanonical, resolveModelRefForPi, modelRefLookupOrder, ompModelRefToCanonical, resolveModelRefForOmp, setStoragePrivatePermissionEnforcement, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, reloadWindowOverlay, getWindowOverlay, resolveWindowOverlayFacts, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, isSaneLimit, resolveOutputReserve, getSdkContextLimit, getSdkOutputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, withContentLanguageDirective, buildPrimaryLanguageDirective, parseCron, nextOccurrence, nextDueAtMs, resolveModelConfigValue, resolveModelConfigOrDefault, DEFAULT_HISTORIAN_TIMEOUT_MS, LIVE_RELOAD_CONFIG_PATHS, getProtectedTokensTierOverrides, FAIL_CLOSED_DOCTOR_COMMAND, formatFailClosedBlockingMessage, createFailClosedBlockingError, isFailClosedBlockingError, shouldBypassFailClosedBlock, createFailClosedController, ProjectIdentityError, resolveProjectIdentityStrict, resolveProjectIdentity, resolveProjectIdentityForSession, beginBootQuietPeriod, scheduleAfterBootQuiet, clearCompressionDepth, clearCompressionDepthRange, getMessageIndexSourceIdentity, isMessageIndexSourceCurrent, getLastIndexedOrdinal, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, indexSingleMessage, indexMessagesAfterOrdinal, sweepOrphanedOpenCodeMessageIndexes, recordSessionProjectIdentity, piHarnessKindFromExecutable, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, HAS_COMPARTMENT_CONTENT_SQL, persistCachedM0, clearCachedM0M1, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getModuleNoteEvaluationBridge, getContextStoreUuid, getAuthorityManagedMarker, drainMirrorPages, V2_MEMORY_CATEGORIES, parseCompartmentOutput, resolveWorkspaceShareCategories, resolveWorkspaceIdentitySet, expandWorkspaceIdentitySetWithAliases, sourceNameForMemory, computeWorkspaceEpochFingerprint, readProjectDocsCanonical, MAX_EXECUTE_THRESHOLD, escalationBands, HYGIENE_PROVIDER_UNITS_VERSION, sessionDecisionCalibration, transitionSessionHygieneUnits, computeProtectionWindow, readEpochFloorSnapshot, getProtectionWindowForSession, isProviderOverflowFailClosedProven, describeProtectedTailDrainBudgetSkip, loadProtectedTailMeta, markProtectedTailPolicyV3Seeded, recordProtectedTailPublicationFloor, recordProtectedTailNoEligibleHead, getWrapupInProgressState, isWrapupInProgress, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, reserveProtectedTailDrainTokens, clearEmergencyDrainLatch, recordHistorianDrainFailure, clearHistorianDrainFailure, rollbackProtectedTailDrainReservation, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, setPersistedNoteNudgeTrigger, setPersistedNoteNudgeTriggerMessageId, getNoteNudgeAnchors, getAutoSearchHintDecisions, deliverNoteNudgeAtomic, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, pruneAutoSearchHintDecisions, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, getNoteLastReadAt, incrementHistorianFailure, clearHistorianFailureState, getOverflowState, recordOverflowDetected, clearEmergencyRecovery, clearDetectedContextLimit, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, THINKING_BINDING_STRIP_ORDER_END_MARKER, thinkingBindingRecoveryFrozenId, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getProcessedImageStrippedIds, addProcessedImageStrippedIds, getPendingCompactionMarkerState, getCompactionMarkerHealth, clearPendingCompactionMarkerStateIf, getPendingPiCompactionMarkerState, setPendingPiCompactionMarkerState, clearPendingPiCompactionMarkerStateIf, getSessionsWithPendingPiMarker, setSessionWorkMetrics, getSessionWorkMetrics, resolveEpochFloorForPass, BoundedSessionMap, registerLkgPersistence, signatureForFields, lkgContentFields, lkgContentDigestFromFields, exactReusablePrefix, incrementalLkgContentDigests, captureSlot, getSlot, dropSlot, noteEntry, encodePiContentDecision, getPiContentDecisions, freezePiContentDecision, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, getErrorMessage, describeError, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, applySqliteTuningPragmas, runSqliteOptimize, openDatabase, openDatabaseAsync, queueM0Mutation, getMaxM0MutationId, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, getNotes, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, markNoteReady, markNoteChecked, queuePendingOp, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, insertPrimerCandidates, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, noteTouchedAt, noteNudgePickIndex, formatNoteNudge, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, readPiSessionSnapshot, readPiSessionMessages, readPiSessionMessagePage, findLastModelKeyFromBranch, convertEntriesToRawMessages, convertEntriesToRawMessagePage, computeCueContentHash, hasMuralCueColumns, getMuralCueState, memoryNeedsCue, setMuralCue, recordMuralCueRejection, invalidateMemory, computeNormalizedHash, hasMemoryShareableColumn, hasMemoryClassifiedAtColumn, getUnclassifiedMemoryIds, insertMemory, getMemoryByHash, getMemoriesByProject, getMemoriesByProjects, getMaxMemoryIdForProjects, getMemoryById, setMemoryClassification, archiveMemory, getMemoryCountsByStatus, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getTaskScheduleState, getFailingDreamTasks, getMostRecentTaskRunAt, pruneNonCanonicalTaskRows, deleteTaskScheduleRowsForProject, seedTaskScheduleState, writeTaskScheduleState, isRetrospectiveWindowProcessed, recordRetrospectiveWindowProcessed, curateCategoryForMemoryCategory, peekCurateCategoryScope, beginCurateCategoryRun, curateTaskStateAfterSuccess, formatSynapseLaneDescriptor, buildCanonicalChunkTextFromFts, buildCompartmentSummaryFallbackText, canonicalizeInMemoryChunkTextForEmbedding, chunkCanonicalText, chunkEmbeddingWindowsAreCurrent, replaceCompartmentChunkEmbeddings, cosineSimilarity, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease, describeShadowBackfillWriteRefusal, contentSha256, sweepStaleEmbeddingIdentitiesForProject, enqueueShadowEmbeddingItems, getProjectEmbeddingSnapshot, getProjectChunkEmbeddingModelId, getProjectEmbeddingMaxInputTokens, embedTextForProject, embedBatchForProject, embedItemsForProject, embedUnembeddedMemoriesForProject, drainCommitBacklogForProject, embedSessionCompartmentChunks, getEmbeddingCoverageStatus, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, isDirectiveShapedProjectRule, takeCurateSafetyRefusalCount, wakePlaneStatus, indexCommitsForProject, embedUnembeddedCommits, loadPiConfig, loadPiConfigDetailed, ensureProjectRegisteredFromPiDirectory, resolvePiHarnessDetection, resolvePiHarnessKind, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, MEMORY_RENDER_FORMAT_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, temporalMarkerPrefix, clearInjectionCache, getVisibleMemoryIds, renderHistorianMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, unifiedSearch, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
|