@cortexkit/opencode-magic-context 0.42.0 → 0.42.2
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/config/project-security.d.ts +3 -2
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +20 -0
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +8 -4
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/expire-memories.d.ts +15 -0
- package/dist/features/magic-context/dreamer/expire-memories.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/module-apply.d.ts +4 -2
- package/dist/features/magic-context/dreamer/module-apply.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-gates.d.ts +6 -1
- package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-model-match.d.ts +41 -0
- package/dist/features/magic-context/memory/embedding-model-match.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-openai.d.ts +7 -20
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-provider.d.ts +2 -2
- package/dist/features/magic-context/memory/embedding-provider.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-synapse.d.ts +5 -4
- package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
- package/dist/features/magic-context/pi-content-decisions.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +4 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +4 -6
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/embed-session-state.d.ts +1 -1
- package/dist/hooks/magic-context/embed-session-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-status.d.ts +2 -0
- package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/format-embed-failure.d.ts +2 -1
- package/dist/hooks/magic-context/format-embed-failure.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +2 -0
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/maintenance-authority.d.ts +2 -2
- package/dist/hooks/magic-context/maintenance-authority.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +1 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/{index-c9hamh36.js → index-953x7a79.js} +564 -143
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +579 -217
- package/dist/plugin/dream-timer-module-client.d.ts +2 -2
- package/dist/plugin/dream-timer-module-client.d.ts.map +1 -1
- package/dist/plugin/embedding-bootstrap-helpers.d.ts.map +1 -1
- package/dist/plugin/embedding-routing.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{recomp-orchestrator-3atsasjy.js → recomp-orchestrator-5g8f5rhy.js} +1 -1
- package/dist/shared/rpc-types.d.ts +10 -0
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/status-detail-text.d.ts +3 -1
- package/dist/shared/status-detail-text.d.ts.map +1 -1
- package/dist/shared/status-summary.d.ts +30 -0
- package/dist/shared/status-summary.d.ts.map +1 -0
- package/dist/shared/tail-hygiene-status.d.ts +1 -0
- package/dist/shared/tail-hygiene-status.d.ts.map +1 -1
- package/dist/shared/transcript.d.ts +2 -1
- package/dist/shared/transcript.d.ts.map +1 -1
- package/dist/shared/user-facing-codes.d.ts +191 -0
- package/dist/shared/user-facing-codes.d.ts.map +1 -0
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/config/project-security.test.ts +10 -2
- package/src/config/project-security.ts +12 -5
- package/src/config/schema/magic-context.test.ts +29 -0
- package/src/config/schema/magic-context.ts +24 -0
- package/src/shared/rpc-types.ts +10 -0
- package/src/shared/status-detail-text.test.ts +93 -24
- package/src/shared/status-detail-text.ts +9 -2
- package/src/shared/status-summary.ts +167 -0
- package/src/shared/tag-transcript.ts +14 -7
- package/src/shared/tail-hygiene-status.ts +8 -0
- package/src/shared/transcript.ts +2 -1
- package/src/shared/user-facing-codes.test.ts +140 -0
- package/src/shared/user-facing-codes.ts +276 -0
- package/src/tui/index.tsx +41 -8
- package/src/tui-compiled/index.tsx +660 -647
|
@@ -15771,6 +15771,28 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
15771
15771
|
return payload;
|
|
15772
15772
|
};
|
|
15773
15773
|
});
|
|
15774
|
+
var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
15775
|
+
$ZodType.init(inst, def);
|
|
15776
|
+
if (def.values.length === 0) {
|
|
15777
|
+
throw new Error("Cannot create literal schema with no valid values");
|
|
15778
|
+
}
|
|
15779
|
+
const values = new Set(def.values);
|
|
15780
|
+
inst._zod.values = values;
|
|
15781
|
+
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
|
15782
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
15783
|
+
const input = payload.value;
|
|
15784
|
+
if (values.has(input)) {
|
|
15785
|
+
return payload;
|
|
15786
|
+
}
|
|
15787
|
+
payload.issues.push({
|
|
15788
|
+
code: "invalid_value",
|
|
15789
|
+
values: def.values,
|
|
15790
|
+
input,
|
|
15791
|
+
inst
|
|
15792
|
+
});
|
|
15793
|
+
return payload;
|
|
15794
|
+
};
|
|
15795
|
+
});
|
|
15774
15796
|
var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
15775
15797
|
$ZodType.init(inst, def);
|
|
15776
15798
|
inst._zod.optin = "optional";
|
|
@@ -16976,6 +16998,44 @@ var enumProcessor = (schema, _ctx, json, _params) => {
|
|
|
16976
16998
|
json.type = "string";
|
|
16977
16999
|
json.enum = values;
|
|
16978
17000
|
};
|
|
17001
|
+
var literalProcessor = (schema, ctx, json, _params) => {
|
|
17002
|
+
const def = schema._zod.def;
|
|
17003
|
+
const vals = [];
|
|
17004
|
+
for (const val of def.values) {
|
|
17005
|
+
if (val === undefined) {
|
|
17006
|
+
if (ctx.unrepresentable === "throw") {
|
|
17007
|
+
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
17008
|
+
}
|
|
17009
|
+
} else if (typeof val === "bigint") {
|
|
17010
|
+
if (ctx.unrepresentable === "throw") {
|
|
17011
|
+
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
17012
|
+
} else {
|
|
17013
|
+
vals.push(Number(val));
|
|
17014
|
+
}
|
|
17015
|
+
} else {
|
|
17016
|
+
vals.push(val);
|
|
17017
|
+
}
|
|
17018
|
+
}
|
|
17019
|
+
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
17020
|
+
const val = vals[0];
|
|
17021
|
+
json.type = val === null ? "null" : typeof val;
|
|
17022
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
17023
|
+
json.enum = [val];
|
|
17024
|
+
} else {
|
|
17025
|
+
json.const = val;
|
|
17026
|
+
}
|
|
17027
|
+
} else {
|
|
17028
|
+
if (vals.every((v) => typeof v === "number"))
|
|
17029
|
+
json.type = "number";
|
|
17030
|
+
if (vals.every((v) => typeof v === "string"))
|
|
17031
|
+
json.type = "string";
|
|
17032
|
+
if (vals.every((v) => typeof v === "boolean"))
|
|
17033
|
+
json.type = "boolean";
|
|
17034
|
+
if (vals.every((v) => v === null))
|
|
17035
|
+
json.type = "null";
|
|
17036
|
+
json.enum = vals;
|
|
17037
|
+
}
|
|
17038
|
+
};
|
|
16979
17039
|
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
16980
17040
|
if (ctx.unrepresentable === "throw") {
|
|
16981
17041
|
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
@@ -17914,6 +17974,27 @@ function _enum(values, params) {
|
|
|
17914
17974
|
...normalizeParams(params)
|
|
17915
17975
|
});
|
|
17916
17976
|
}
|
|
17977
|
+
var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
17978
|
+
$ZodLiteral.init(inst, def);
|
|
17979
|
+
ZodType.init(inst, def);
|
|
17980
|
+
inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
|
|
17981
|
+
inst.values = new Set(def.values);
|
|
17982
|
+
Object.defineProperty(inst, "value", {
|
|
17983
|
+
get() {
|
|
17984
|
+
if (def.values.length > 1) {
|
|
17985
|
+
throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
17986
|
+
}
|
|
17987
|
+
return def.values[0];
|
|
17988
|
+
}
|
|
17989
|
+
});
|
|
17990
|
+
});
|
|
17991
|
+
function literal(value, params) {
|
|
17992
|
+
return new ZodLiteral({
|
|
17993
|
+
type: "literal",
|
|
17994
|
+
values: Array.isArray(value) ? value : [value],
|
|
17995
|
+
...normalizeParams(params)
|
|
17996
|
+
});
|
|
17997
|
+
}
|
|
17917
17998
|
var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
17918
17999
|
$ZodTransform.init(inst, def);
|
|
17919
18000
|
ZodType.init(inst, def);
|
|
@@ -18604,6 +18685,8 @@ var BaseEmbeddingConfigSchema = object({
|
|
|
18604
18685
|
api_key: string().optional().describe("API key for remote embedding provider (optional)"),
|
|
18605
18686
|
input_type: string().optional().describe("Default input_type for stored/indexed (passage) embeddings in the request body. Required by some openai-compatible providers (e.g. NVIDIA NIM). Omitted from the request when unset."),
|
|
18606
18687
|
query_input_type: string().optional().describe("Optional input_type for query (search) embeddings on asymmetric models (e.g. NVIDIA NIM 'query'). When unset, query embeddings use embedding.input_type. Passage/stored content always uses embedding.input_type."),
|
|
18688
|
+
query_instruction: union([string(), literal(false)]).optional().describe("OpenAI-compatible query prefix override. A string is prepended verbatim to search queries; false disables the built-in model-family instruction. Qwen3-Embedding, gte-Qwen instruct, e5 instruct, and Nomic families have built-in recipes. Query-only changes do not re-embed stored content. User-level only; project values are ignored."),
|
|
18689
|
+
document_prefix: string().optional().describe("OpenAI-compatible stored-document prefix override, prepended verbatim. Defaults to the model-family recipe (empty for Qwen3/gte/e5 instruct; 'search_document: ' for Nomic). Changing it changes stored vectors and triggers re-embedding. User-level only; project values are ignored."),
|
|
18607
18690
|
truncate: string().optional().describe("Optional truncate mode sent in the embedding request body (e.g. NVIDIA NIM accepts 'NONE' | 'START' | 'END'). Omitted from the request when unset."),
|
|
18608
18691
|
max_input_tokens: number2().int().positive().optional().describe("Optional maximum input tokens for chunk embeddings. Defaults conservatively to 512 when omitted."),
|
|
18609
18692
|
local_runtime: _enum(["auto", "native", "wasm"]).default("auto").describe("Local provider only: ONNX runtime selection. 'auto' uses native under Node and uses WASM under Bun versions before 1.4.0, where Bun's NAPI teardown race can panic on quit; native is restored automatically on Bun 1.4.0+. Set 'native' only to prefer speed while accepting that pre-1.4.0 Bun crash risk, or 'wasm' to avoid loading the native addon."),
|
|
@@ -18655,6 +18738,8 @@ var EmbeddingConfigSchema = BaseEmbeddingConfigSchema.transform((data) => {
|
|
|
18655
18738
|
...apiKey ? { api_key: apiKey } : {},
|
|
18656
18739
|
...inputType ? { input_type: inputType } : {},
|
|
18657
18740
|
...queryInputType ? { query_input_type: queryInputType } : {},
|
|
18741
|
+
...data.query_instruction !== undefined ? { query_instruction: data.query_instruction } : {},
|
|
18742
|
+
...data.document_prefix !== undefined ? { document_prefix: data.document_prefix } : {},
|
|
18658
18743
|
...truncate ? { truncate } : {},
|
|
18659
18744
|
...data.max_input_tokens ? { max_input_tokens: data.max_input_tokens } : {}
|
|
18660
18745
|
};
|
|
@@ -18680,6 +18765,8 @@ var EmbeddingConfigSchema = BaseEmbeddingConfigSchema.transform((data) => {
|
|
|
18680
18765
|
...apiKey ? { api_key: apiKey } : {},
|
|
18681
18766
|
...inputType ? { input_type: inputType } : {},
|
|
18682
18767
|
...queryInputType ? { query_input_type: queryInputType } : {},
|
|
18768
|
+
...data.query_instruction !== undefined ? { query_instruction: data.query_instruction } : {},
|
|
18769
|
+
...data.document_prefix !== undefined ? { document_prefix: data.document_prefix } : {},
|
|
18683
18770
|
...truncate ? { truncate } : {},
|
|
18684
18771
|
...data.max_input_tokens ? { max_input_tokens: data.max_input_tokens } : {}
|
|
18685
18772
|
};
|
|
@@ -20088,9 +20175,27 @@ function getPersistedCompactionMarkerState(db, sessionId) {
|
|
|
20088
20175
|
return parsePersistedCompactionMarkerState(row?.compaction_marker_state, row?.compaction_marker_target_end_message_id);
|
|
20089
20176
|
}
|
|
20090
20177
|
function setPersistedCompactionMarkerState(db, sessionId, state) {
|
|
20091
|
-
|
|
20092
|
-
|
|
20093
|
-
|
|
20178
|
+
db.transaction(() => {
|
|
20179
|
+
ensureSessionMetaRow(db, sessionId);
|
|
20180
|
+
const previous = state === null ? getPersistedCompactionMarkerState(db, sessionId) ?? getDeferredClearedCompactionMarkerState(db, sessionId) : null;
|
|
20181
|
+
const json = state ? JSON.stringify(state) : previous ? JSON.stringify({ deferredClear: previous }) : "";
|
|
20182
|
+
db.prepare("UPDATE session_meta SET compaction_marker_state = ?, compaction_marker_target_end_message_id = ? WHERE session_id = ?").run(json, state?.targetEndMessageId ?? null, sessionId);
|
|
20183
|
+
})();
|
|
20184
|
+
}
|
|
20185
|
+
function getDeferredClearedCompactionMarkerState(db, sessionId) {
|
|
20186
|
+
const row = db.prepare("SELECT compaction_marker_state FROM session_meta WHERE session_id = ?").get(sessionId);
|
|
20187
|
+
try {
|
|
20188
|
+
const parsed = JSON.parse(row?.compaction_marker_state || "null");
|
|
20189
|
+
return parsePersistedCompactionMarkerState(JSON.stringify(parsed?.deferredClear));
|
|
20190
|
+
} catch {
|
|
20191
|
+
return null;
|
|
20192
|
+
}
|
|
20193
|
+
}
|
|
20194
|
+
function retireDeferredClearedCompactionMarkerState(db, sessionId) {
|
|
20195
|
+
const previous = getDeferredClearedCompactionMarkerState(db, sessionId);
|
|
20196
|
+
if (!previous)
|
|
20197
|
+
return;
|
|
20198
|
+
db.prepare("UPDATE session_meta SET compaction_marker_state = '' WHERE session_id = ? AND compaction_marker_state = ?").run(sessionId, JSON.stringify({ deferredClear: previous }));
|
|
20094
20199
|
}
|
|
20095
20200
|
var MAX_STRIPPED_PLACEHOLDER_IDS = 4096;
|
|
20096
20201
|
function parseStrippedPlaceholderState(raw) {
|
|
@@ -23846,6 +23951,242 @@ async function runMemoryMigration(deps) {
|
|
|
23846
23951
|
}
|
|
23847
23952
|
}
|
|
23848
23953
|
|
|
23954
|
+
// src/shared/user-facing-codes.ts
|
|
23955
|
+
var USER_FACING_FAILURES = {
|
|
23956
|
+
historian_unavailable: {
|
|
23957
|
+
code: "MC-H01",
|
|
23958
|
+
sentence: "History compression could not finish this turn.",
|
|
23959
|
+
action: "It will retry automatically."
|
|
23960
|
+
},
|
|
23961
|
+
recomp_unavailable: {
|
|
23962
|
+
code: "MC-R01",
|
|
23963
|
+
sentence: "History compression could not be rebuilt.",
|
|
23964
|
+
action: "Run /ctx-recomp again."
|
|
23965
|
+
},
|
|
23966
|
+
dream_provider_timeout: {
|
|
23967
|
+
code: "MC-D01",
|
|
23968
|
+
sentence: "Memory maintenance took too long to respond.",
|
|
23969
|
+
action: "Run /ctx-dream again."
|
|
23970
|
+
},
|
|
23971
|
+
dream_provider_error: {
|
|
23972
|
+
code: "MC-D02",
|
|
23973
|
+
sentence: "Memory maintenance could not reach its model.",
|
|
23974
|
+
action: "Check the model connection, then run /ctx-dream again."
|
|
23975
|
+
},
|
|
23976
|
+
dream_empty_completion: {
|
|
23977
|
+
code: "MC-D03",
|
|
23978
|
+
sentence: "Memory maintenance received no usable response.",
|
|
23979
|
+
action: "Run /ctx-dream again."
|
|
23980
|
+
},
|
|
23981
|
+
dream_no_models: {
|
|
23982
|
+
code: "MC-D04",
|
|
23983
|
+
sentence: "Memory maintenance has no model available.",
|
|
23984
|
+
action: "Check the model settings, then run /ctx-dream again."
|
|
23985
|
+
},
|
|
23986
|
+
dream_child_aborted: {
|
|
23987
|
+
code: "MC-D05",
|
|
23988
|
+
sentence: "Memory maintenance was interrupted.",
|
|
23989
|
+
action: "Run /ctx-dream again."
|
|
23990
|
+
},
|
|
23991
|
+
dream_parse_failed: {
|
|
23992
|
+
code: "MC-D06",
|
|
23993
|
+
sentence: "Memory maintenance could not use the model response.",
|
|
23994
|
+
action: "Run /ctx-dream again."
|
|
23995
|
+
},
|
|
23996
|
+
dream_unknown: {
|
|
23997
|
+
code: "MC-D07",
|
|
23998
|
+
sentence: "Memory maintenance could not finish.",
|
|
23999
|
+
action: "Run /ctx-dream again."
|
|
24000
|
+
},
|
|
24001
|
+
embedding_substitution_rejected: {
|
|
24002
|
+
code: "MC-E01",
|
|
24003
|
+
sentence: "Search indexing could not use the selected model.",
|
|
24004
|
+
action: "Check the embedding model setting, then run /ctx-embed start again."
|
|
24005
|
+
},
|
|
24006
|
+
embedding_http_error: {
|
|
24007
|
+
code: "MC-E02",
|
|
24008
|
+
sentence: "The search indexing provider refused the request.",
|
|
24009
|
+
action: "Check the provider connection and credentials, then run /ctx-embed start again."
|
|
24010
|
+
},
|
|
24011
|
+
embedding_transport_error: {
|
|
24012
|
+
code: "MC-E03",
|
|
24013
|
+
sentence: "Search indexing could not reach its provider.",
|
|
24014
|
+
action: "Check the connection, then run /ctx-embed start again."
|
|
24015
|
+
},
|
|
24016
|
+
embedding_invalid_envelope: {
|
|
24017
|
+
code: "MC-E04",
|
|
24018
|
+
sentence: "Search indexing received an unsupported response.",
|
|
24019
|
+
action: "Check the embedding endpoint, then run /ctx-embed start again."
|
|
24020
|
+
},
|
|
24021
|
+
embedding_empty_result: {
|
|
24022
|
+
code: "MC-E05",
|
|
24023
|
+
sentence: "Search indexing received no usable result.",
|
|
24024
|
+
action: "Run /ctx-embed start again."
|
|
24025
|
+
},
|
|
24026
|
+
embedding_certification_refusal: {
|
|
24027
|
+
code: "MC-E06",
|
|
24028
|
+
sentence: "Search indexing is not ready for this provider.",
|
|
24029
|
+
action: "Finish the provider setup, or set a fallback provider in the embedding settings, then run /ctx-embed start again."
|
|
24030
|
+
},
|
|
24031
|
+
embedding_credential_required: {
|
|
24032
|
+
code: "MC-E07",
|
|
24033
|
+
sentence: "Search indexing needs provider credentials.",
|
|
24034
|
+
action: "Sign in to the provider, then run /ctx-embed start again."
|
|
24035
|
+
},
|
|
24036
|
+
embedding_local_binding_missing: {
|
|
24037
|
+
code: "MC-E08",
|
|
24038
|
+
sentence: "Local search indexing is unavailable on this system.",
|
|
24039
|
+
action: "Run `npx @cortexkit/magic-context doctor`, then retry."
|
|
24040
|
+
},
|
|
24041
|
+
embedding_local_fs_unavailable: {
|
|
24042
|
+
code: "MC-E09",
|
|
24043
|
+
sentence: "Local search indexing cannot save its model files.",
|
|
24044
|
+
action: "Update or reinstall Magic Context, then retry."
|
|
24045
|
+
},
|
|
24046
|
+
embedding_local_download_failure: {
|
|
24047
|
+
code: "MC-E10",
|
|
24048
|
+
sentence: "Local search indexing could not download its model.",
|
|
24049
|
+
action: "Check the network connection, then retry."
|
|
24050
|
+
},
|
|
24051
|
+
embedding_local_runtime_error: {
|
|
24052
|
+
code: "MC-E11",
|
|
24053
|
+
sentence: "Local search indexing could not start.",
|
|
24054
|
+
action: "Run `npx @cortexkit/magic-context doctor`, then retry."
|
|
24055
|
+
},
|
|
24056
|
+
embedding_unavailable: {
|
|
24057
|
+
code: "MC-E12",
|
|
24058
|
+
sentence: "Search indexing could not finish.",
|
|
24059
|
+
action: "Run /ctx-embed start again."
|
|
24060
|
+
},
|
|
24061
|
+
status_unavailable: {
|
|
24062
|
+
code: "MC-S01",
|
|
24063
|
+
sentence: "Magic Context status is temporarily unavailable.",
|
|
24064
|
+
action: "Retry /ctx-status in a moment."
|
|
24065
|
+
},
|
|
24066
|
+
transform_update_failed: {
|
|
24067
|
+
code: "MC-S02",
|
|
24068
|
+
sentence: "The last context update did not finish.",
|
|
24069
|
+
action: "Send another message to retry."
|
|
24070
|
+
},
|
|
24071
|
+
configuration_warning: {
|
|
24072
|
+
code: "MC-S03",
|
|
24073
|
+
sentence: "Some configuration settings could not be applied.",
|
|
24074
|
+
action: "Fix the configuration warning shown in /ctx-status diagnostics, then restart."
|
|
24075
|
+
},
|
|
24076
|
+
status_log_unavailable: {
|
|
24077
|
+
code: "MC-S04",
|
|
24078
|
+
sentence: "Some diagnostic details could not be saved.",
|
|
24079
|
+
action: "Retry /ctx-status in a moment."
|
|
24080
|
+
},
|
|
24081
|
+
memory_writes_paused: {
|
|
24082
|
+
code: "MC-C01",
|
|
24083
|
+
sentence: "Memory writes are paused while the engine syncs.",
|
|
24084
|
+
action: "Retry in a moment."
|
|
24085
|
+
},
|
|
24086
|
+
memory_access_unavailable: {
|
|
24087
|
+
code: "MC-C02",
|
|
24088
|
+
sentence: "Memory access is temporarily unavailable.",
|
|
24089
|
+
action: "Retry in a moment."
|
|
24090
|
+
},
|
|
24091
|
+
note_changes_paused: {
|
|
24092
|
+
code: "MC-C03",
|
|
24093
|
+
sentence: "Note changes are paused while the engine syncs.",
|
|
24094
|
+
action: "Retry in a moment."
|
|
24095
|
+
},
|
|
24096
|
+
note_access_unavailable: {
|
|
24097
|
+
code: "MC-C04",
|
|
24098
|
+
sentence: "Notes are temporarily unavailable.",
|
|
24099
|
+
action: "Retry in a moment."
|
|
24100
|
+
},
|
|
24101
|
+
context_cleanup_paused: {
|
|
24102
|
+
code: "MC-C05",
|
|
24103
|
+
sentence: "Context cleanup is paused while the engine syncs.",
|
|
24104
|
+
action: "Retry in a moment."
|
|
24105
|
+
},
|
|
24106
|
+
partial_history_unavailable: {
|
|
24107
|
+
code: "MC-C06",
|
|
24108
|
+
sentence: "Partial history compression is not available in the current mode.",
|
|
24109
|
+
action: "Run /ctx-recomp without a range."
|
|
24110
|
+
},
|
|
24111
|
+
session_upgrade_unavailable: {
|
|
24112
|
+
code: "MC-C07",
|
|
24113
|
+
sentence: "Session upgrade is not available in the current mode.",
|
|
24114
|
+
action: "Run /ctx-recomp instead."
|
|
24115
|
+
},
|
|
24116
|
+
smart_note_conditions_unavailable: {
|
|
24117
|
+
code: "MC-C08",
|
|
24118
|
+
sentence: "Conditional notes are not available in the current mode.",
|
|
24119
|
+
action: "Save a regular note without a condition."
|
|
24120
|
+
},
|
|
24121
|
+
history_compression_paused: {
|
|
24122
|
+
code: "MC-C09",
|
|
24123
|
+
sentence: "History compression is paused while the engine syncs.",
|
|
24124
|
+
action: "Retry in a moment."
|
|
24125
|
+
},
|
|
24126
|
+
context_service_unavailable: {
|
|
24127
|
+
code: "MC-C10",
|
|
24128
|
+
sentence: "Magic Context is temporarily unavailable.",
|
|
24129
|
+
action: "Retry in a moment."
|
|
24130
|
+
}
|
|
24131
|
+
};
|
|
24132
|
+
function renderUserFacingFailure(key, style = "markdown") {
|
|
24133
|
+
const failure = USER_FACING_FAILURES[key];
|
|
24134
|
+
const action = style === "plain" ? failure.action.replaceAll("`", "") : failure.action;
|
|
24135
|
+
return `${failure.sentence} ${action} (${failure.code})`;
|
|
24136
|
+
}
|
|
24137
|
+
function userFacingFailureCode(key) {
|
|
24138
|
+
return USER_FACING_FAILURES[key].code;
|
|
24139
|
+
}
|
|
24140
|
+
var CAPABILITY_FAILURES = {
|
|
24141
|
+
memory_write: "memory_writes_paused",
|
|
24142
|
+
memory_access: "memory_access_unavailable",
|
|
24143
|
+
note_change: "note_changes_paused",
|
|
24144
|
+
note_access: "note_access_unavailable",
|
|
24145
|
+
context_cleanup: "context_cleanup_paused",
|
|
24146
|
+
partial_history: "partial_history_unavailable",
|
|
24147
|
+
session_upgrade: "session_upgrade_unavailable",
|
|
24148
|
+
smart_note_condition: "smart_note_conditions_unavailable",
|
|
24149
|
+
history_compression: "history_compression_paused",
|
|
24150
|
+
context_service: "context_service_unavailable"
|
|
24151
|
+
};
|
|
24152
|
+
function renderCapabilityRefusal(capability) {
|
|
24153
|
+
return renderUserFacingFailure(CAPABILITY_FAILURES[capability]);
|
|
24154
|
+
}
|
|
24155
|
+
function capabilityRefusalCode(capability) {
|
|
24156
|
+
return userFacingFailureCode(CAPABILITY_FAILURES[capability]);
|
|
24157
|
+
}
|
|
24158
|
+
var DREAM_FAILURE_KEYS = {
|
|
24159
|
+
provider_timeout: "dream_provider_timeout",
|
|
24160
|
+
provider_error: "dream_provider_error",
|
|
24161
|
+
empty_completion: "dream_empty_completion",
|
|
24162
|
+
no_models: "dream_no_models",
|
|
24163
|
+
child_aborted: "dream_child_aborted",
|
|
24164
|
+
parse_failed: "dream_parse_failed",
|
|
24165
|
+
unknown: "dream_unknown"
|
|
24166
|
+
};
|
|
24167
|
+
var EMBEDDING_FAILURE_KEYS = {
|
|
24168
|
+
substitution_rejected: "embedding_substitution_rejected",
|
|
24169
|
+
http_error: "embedding_http_error",
|
|
24170
|
+
transport_error: "embedding_transport_error",
|
|
24171
|
+
invalid_envelope: "embedding_invalid_envelope",
|
|
24172
|
+
empty_result: "embedding_empty_result",
|
|
24173
|
+
certification_refusal: "embedding_certification_refusal",
|
|
24174
|
+
credential_required: "embedding_credential_required",
|
|
24175
|
+
local_binding_missing: "embedding_local_binding_missing",
|
|
24176
|
+
local_fs_unavailable: "embedding_local_fs_unavailable",
|
|
24177
|
+
local_download_failure: "embedding_local_download_failure",
|
|
24178
|
+
local_runtime_error: "embedding_local_runtime_error"
|
|
24179
|
+
};
|
|
24180
|
+
function renderDreamFailure(failureClass, style = "markdown") {
|
|
24181
|
+
return renderUserFacingFailure(DREAM_FAILURE_KEYS[failureClass], style);
|
|
24182
|
+
}
|
|
24183
|
+
function dreamFailureCode(failureClass) {
|
|
24184
|
+
return userFacingFailureCode(DREAM_FAILURE_KEYS[failureClass]);
|
|
24185
|
+
}
|
|
24186
|
+
function renderEmbeddingFailure(failureClass, style = "markdown") {
|
|
24187
|
+
return renderUserFacingFailure(EMBEDDING_FAILURE_KEYS[failureClass], style);
|
|
24188
|
+
}
|
|
24189
|
+
|
|
23849
24190
|
// src/features/magic-context/compartment-chunk-embedding.ts
|
|
23850
24191
|
import { createHash as createHash14 } from "node:crypto";
|
|
23851
24192
|
|
|
@@ -25628,7 +25969,8 @@ function getSynapseBatchRequestKey(args) {
|
|
|
25628
25969
|
allow_equivalent: false,
|
|
25629
25970
|
accept_declared: false,
|
|
25630
25971
|
ids: args.items.map((item) => item.id),
|
|
25631
|
-
content_sha256: args.items.map((item) => item.contentSha256)
|
|
25972
|
+
content_sha256: args.items.map((item) => item.contentSha256),
|
|
25973
|
+
...args.purpose === "query" ? { purpose: args.purpose } : {}
|
|
25632
25974
|
}));
|
|
25633
25975
|
}
|
|
25634
25976
|
function hashContent(text) {
|
|
@@ -25889,7 +26231,7 @@ class SynapseEmbeddingProvider {
|
|
|
25889
26231
|
})();
|
|
25890
26232
|
return this.initializing;
|
|
25891
26233
|
}
|
|
25892
|
-
async embed(text, signal) {
|
|
26234
|
+
async embed(text, signal, purpose = "passage") {
|
|
25893
26235
|
if (!await this.initialize() || signal?.aborted || !this.metadata)
|
|
25894
26236
|
return null;
|
|
25895
26237
|
if (estimateTokens(text) > this.metadata.max_tokens)
|
|
@@ -25899,6 +26241,7 @@ class SynapseEmbeddingProvider {
|
|
|
25899
26241
|
const value = await this.callWithRetry("embed.query", this.requestConstraints({
|
|
25900
26242
|
id,
|
|
25901
26243
|
text,
|
|
26244
|
+
purpose,
|
|
25902
26245
|
deadline_ms: this.options.queryTimeoutMs ?? SYNAPSE_DEFAULT_QUERY_TIMEOUT_MS
|
|
25903
26246
|
}), this.options.queryTimeoutMs ?? SYNAPSE_DEFAULT_QUERY_TIMEOUT_MS, true, signal);
|
|
25904
26247
|
const extracted = extractVector(value);
|
|
@@ -25918,7 +26261,7 @@ class SynapseEmbeddingProvider {
|
|
|
25918
26261
|
return null;
|
|
25919
26262
|
}
|
|
25920
26263
|
}
|
|
25921
|
-
async embedBatch(texts, signal) {
|
|
26264
|
+
async embedBatch(texts, signal, purpose = "passage") {
|
|
25922
26265
|
if (texts.length === 0)
|
|
25923
26266
|
return [];
|
|
25924
26267
|
const items = texts.map((text, index) => ({
|
|
@@ -25926,10 +26269,10 @@ class SynapseEmbeddingProvider {
|
|
|
25926
26269
|
text,
|
|
25927
26270
|
contentSha256: hashContent(text)
|
|
25928
26271
|
}));
|
|
25929
|
-
const map = await this.embedItems(items, signal);
|
|
26272
|
+
const map = await this.embedItems(items, signal, purpose);
|
|
25930
26273
|
return items.map((item) => map.get(item.id) ?? null);
|
|
25931
26274
|
}
|
|
25932
|
-
async embedItems(items, signal) {
|
|
26275
|
+
async embedItems(items, signal, purpose = "passage") {
|
|
25933
26276
|
const output = new Map;
|
|
25934
26277
|
if (items.length === 0 || !await this.initialize() || !this.metadata || signal?.aborted) {
|
|
25935
26278
|
return output;
|
|
@@ -25942,12 +26285,12 @@ class SynapseEmbeddingProvider {
|
|
|
25942
26285
|
const page = this.nextPage(eligibleItems, start);
|
|
25943
26286
|
start += page.length;
|
|
25944
26287
|
try {
|
|
25945
|
-
const requestKey = this.requestKey(page);
|
|
26288
|
+
const requestKey = this.requestKey(page, purpose);
|
|
25946
26289
|
let body = {};
|
|
25947
26290
|
let restarted = false;
|
|
25948
26291
|
for (;; ) {
|
|
25949
26292
|
try {
|
|
25950
|
-
body = await this.callWithRetry("embed.batch", this.batchRequest(page, requestKey), this.options.batchTimeoutMs ?? SYNAPSE_DEFAULT_BATCH_TIMEOUT_MS, true, signal);
|
|
26293
|
+
body = await this.callWithRetry("embed.batch", this.batchRequest(page, requestKey, purpose), this.options.batchTimeoutMs ?? SYNAPSE_DEFAULT_BATCH_TIMEOUT_MS, true, signal);
|
|
25951
26294
|
const first = responseBody(body);
|
|
25952
26295
|
const jobId = typeof first.job_id === "string" ? first.job_id : null;
|
|
25953
26296
|
if (jobId)
|
|
@@ -26017,24 +26360,26 @@ class SynapseEmbeddingProvider {
|
|
|
26017
26360
|
accept_declared: false
|
|
26018
26361
|
};
|
|
26019
26362
|
}
|
|
26020
|
-
batchRequest(items, requestKey) {
|
|
26363
|
+
batchRequest(items, requestKey, purpose) {
|
|
26021
26364
|
return this.requestConstraints({
|
|
26022
26365
|
items: items.map((item) => ({
|
|
26023
26366
|
id: item.id,
|
|
26024
26367
|
text: item.text,
|
|
26025
26368
|
content_sha256: item.contentSha256
|
|
26026
26369
|
})),
|
|
26027
|
-
request_key: requestKey
|
|
26370
|
+
request_key: requestKey,
|
|
26371
|
+
purpose
|
|
26028
26372
|
});
|
|
26029
26373
|
}
|
|
26030
|
-
requestKey(items) {
|
|
26374
|
+
requestKey(items, purpose) {
|
|
26031
26375
|
if (!this.metadata)
|
|
26032
26376
|
throw new SynapseEmbeddingError("transport", "Synapse metadata is unavailable");
|
|
26033
26377
|
return getSynapseBatchRequestKey({
|
|
26034
26378
|
model: this.metadata.model,
|
|
26035
26379
|
fingerprint: this.metadata.fingerprint,
|
|
26036
26380
|
tableEpoch: this.metadata.table_epoch,
|
|
26037
|
-
items
|
|
26381
|
+
items,
|
|
26382
|
+
purpose
|
|
26038
26383
|
});
|
|
26039
26384
|
}
|
|
26040
26385
|
async pollBatch(jobId, requestKey, signal) {
|
|
@@ -26244,6 +26589,7 @@ var existingHashStatements = new WeakMap;
|
|
|
26244
26589
|
var existingHashByProjectStatements = new WeakMap;
|
|
26245
26590
|
var deleteByCompartmentStatements = new WeakMap;
|
|
26246
26591
|
var insertEmbeddingStatements = new WeakMap;
|
|
26592
|
+
var renumberEmbeddingWindowStatements = new WeakMap;
|
|
26247
26593
|
var searchRowsStatements = new WeakMap;
|
|
26248
26594
|
var searchRowsByModelStatements = new WeakMap;
|
|
26249
26595
|
var searchPoolProbeStatements = new WeakMap;
|
|
@@ -26294,6 +26640,19 @@ function getInsertEmbeddingStatement(db) {
|
|
|
26294
26640
|
}
|
|
26295
26641
|
return stmt;
|
|
26296
26642
|
}
|
|
26643
|
+
function getRenumberEmbeddingWindowStatement(db) {
|
|
26644
|
+
let stmt = renumberEmbeddingWindowStatements.get(db);
|
|
26645
|
+
if (!stmt) {
|
|
26646
|
+
stmt = db.prepare(`UPDATE compartment_chunk_embeddings
|
|
26647
|
+
SET window_index = ?
|
|
26648
|
+
WHERE compartment_id = ?
|
|
26649
|
+
AND model_id = ?
|
|
26650
|
+
AND project_path = ?
|
|
26651
|
+
AND window_index = ?`);
|
|
26652
|
+
renumberEmbeddingWindowStatements.set(db, stmt);
|
|
26653
|
+
}
|
|
26654
|
+
return stmt;
|
|
26655
|
+
}
|
|
26297
26656
|
function getSearchPoolProbeStatement(db) {
|
|
26298
26657
|
let stmt = searchPoolProbeStatements.get(db);
|
|
26299
26658
|
if (!stmt) {
|
|
@@ -26455,6 +26814,11 @@ function parseCanonicalLineRange(line) {
|
|
|
26455
26814
|
return null;
|
|
26456
26815
|
return { start, end };
|
|
26457
26816
|
}
|
|
26817
|
+
function assertOrdinalRangeWithinCompartment(rangeStart, rangeEnd, compartmentStart, compartmentEnd) {
|
|
26818
|
+
if (rangeStart < compartmentStart || rangeEnd > compartmentEnd || rangeEnd < rangeStart) {
|
|
26819
|
+
throw new RangeError(`Canonical chunk range ${rangeStart}-${rangeEnd} lies outside compartment ${compartmentStart}-${compartmentEnd}`);
|
|
26820
|
+
}
|
|
26821
|
+
}
|
|
26458
26822
|
function hashChunkText(text) {
|
|
26459
26823
|
return createHash14("sha256").update(text).digest("hex");
|
|
26460
26824
|
}
|
|
@@ -26543,6 +26907,10 @@ function canonicalizeInMemoryChunkTextForEmbedding(chunkText, startOrdinal, endO
|
|
|
26543
26907
|
lines.push(`${formatOrdinalRange(retainedStart, retainedEnd)} ${roleLabel} ${retained.map(({ part }) => part).join(" / ")}`);
|
|
26544
26908
|
continue;
|
|
26545
26909
|
}
|
|
26910
|
+
const clipsRequestedRange = startOrdinal != null && lineStart < startOrdinal || endOrdinal != null && lineEnd > endOrdinal;
|
|
26911
|
+
if (clipsRequestedRange) {
|
|
26912
|
+
return "";
|
|
26913
|
+
}
|
|
26546
26914
|
const parts = rawParts.filter((part) => !part.startsWith("TC:"));
|
|
26547
26915
|
if (parts.length === 0)
|
|
26548
26916
|
continue;
|
|
@@ -26555,6 +26923,12 @@ function chunkCanonicalText(canonicalText, startOrdinal, endOrdinal, maxInputTok
|
|
|
26555
26923
|
const lines = canonicalText.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
26556
26924
|
if (lines.length === 0 || endOrdinal < startOrdinal)
|
|
26557
26925
|
return [];
|
|
26926
|
+
for (const line of lines) {
|
|
26927
|
+
const range = parseCanonicalLineRange(line);
|
|
26928
|
+
if (range) {
|
|
26929
|
+
assertOrdinalRangeWithinCompartment(range.start, range.end, startOrdinal, endOrdinal);
|
|
26930
|
+
}
|
|
26931
|
+
}
|
|
26558
26932
|
const normalizedMax = normalizeCompartmentChunkMaxInputTokens(maxInputTokens);
|
|
26559
26933
|
const effectiveMax = Math.max(1, Math.floor(normalizedMax * CHUNK_WINDOW_SAFETY_RATIO));
|
|
26560
26934
|
const fullText = lines.join(`
|
|
@@ -26580,8 +26954,9 @@ function chunkCanonicalText(canonicalText, startOrdinal, endOrdinal, maxInputTok
|
|
|
26580
26954
|
return;
|
|
26581
26955
|
const text = currentLines.join(`
|
|
26582
26956
|
`);
|
|
26957
|
+
assertOrdinalRangeWithinCompartment(currentStart, currentEnd, startOrdinal, endOrdinal);
|
|
26583
26958
|
windows.push({
|
|
26584
|
-
windowIndex: windows.length
|
|
26959
|
+
windowIndex: windows.length,
|
|
26585
26960
|
startOrdinal: currentStart,
|
|
26586
26961
|
endOrdinal: currentEnd,
|
|
26587
26962
|
text,
|
|
@@ -26600,8 +26975,9 @@ function chunkCanonicalText(canonicalText, startOrdinal, endOrdinal, maxInputTok
|
|
|
26600
26975
|
if (lineTokens > effectiveMax) {
|
|
26601
26976
|
flush();
|
|
26602
26977
|
for (const slice of splitOversizedLine(line, effectiveMax)) {
|
|
26978
|
+
assertOrdinalRangeWithinCompartment(lineStart, lineEnd, startOrdinal, endOrdinal);
|
|
26603
26979
|
windows.push({
|
|
26604
|
-
windowIndex: windows.length
|
|
26980
|
+
windowIndex: windows.length,
|
|
26605
26981
|
startOrdinal: lineStart,
|
|
26606
26982
|
endOrdinal: lineEnd,
|
|
26607
26983
|
text: slice,
|
|
@@ -26751,34 +27127,57 @@ function mapBackfillCandidateRows(rows) {
|
|
|
26751
27127
|
title: row.title
|
|
26752
27128
|
}));
|
|
26753
27129
|
}
|
|
27130
|
+
function renumberOneBasedChunkWindows(db, candidate, projectPath, modelId, windows) {
|
|
27131
|
+
const update = getRenumberEmbeddingWindowStatement(db);
|
|
27132
|
+
db.transaction(() => {
|
|
27133
|
+
for (const window of windows) {
|
|
27134
|
+
const result = update.run(window.windowIndex, candidate.id, modelId, projectPath, window.windowIndex + 1);
|
|
27135
|
+
if (result.changes !== 1) {
|
|
27136
|
+
throw new Error(`Failed to renumber compartment ${candidate.id} window ${window.windowIndex + 1}`);
|
|
27137
|
+
}
|
|
27138
|
+
}
|
|
27139
|
+
})();
|
|
27140
|
+
invalidateDecodedSearchPools(db, ([sessionId, cachedProjectPath, cachedModelId]) => sessionId === candidate.sessionId && cachedProjectPath === projectPath && cachedModelId === modelId);
|
|
27141
|
+
}
|
|
26754
27142
|
function classifyChunkCoverageDefect(db, projectPath, modelId, candidate, maxInputTokens) {
|
|
26755
27143
|
const mappedText = buildCanonicalChunkTextFromFts(db, candidate.sessionId, candidate.startMessage, candidate.endMessage);
|
|
26756
27144
|
if (mappedText === null)
|
|
26757
|
-
return "deferred";
|
|
27145
|
+
return { defect: "deferred", windows: [] };
|
|
26758
27146
|
const canonicalText = mappedText || buildCompartmentSummaryFallbackText(db, candidate.id);
|
|
26759
27147
|
const windows = chunkCanonicalText(canonicalText, candidate.startMessage, candidate.endMessage, maxInputTokens);
|
|
26760
27148
|
const existing = getExistingChunkHashes(db, candidate.id, modelId, projectPath);
|
|
26761
|
-
|
|
26762
|
-
|
|
27149
|
+
const isMatchingOneBasedSet = windows.length > 0 && existing.size === windows.length && windows.every((window) => existing.get(window.windowIndex + 1) === window.chunkHash);
|
|
27150
|
+
if (isMatchingOneBasedSet)
|
|
27151
|
+
return { defect: "renumber", windows };
|
|
27152
|
+
const expectedWindowIndexes = new Set(windows.map((window) => window.windowIndex));
|
|
27153
|
+
if ([...existing.keys()].some((windowIndex) => !expectedWindowIndexes.has(windowIndex))) {
|
|
27154
|
+
return { defect: "stale", windows };
|
|
27155
|
+
}
|
|
27156
|
+
if (windows.some((window) => !existing.has(window.windowIndex))) {
|
|
27157
|
+
return { defect: "missing", windows };
|
|
27158
|
+
}
|
|
26763
27159
|
if (existing.size !== windows.length || windows.some((window) => existing.get(window.windowIndex) !== window.chunkHash)) {
|
|
26764
|
-
return "stale";
|
|
27160
|
+
return { defect: "stale", windows };
|
|
26765
27161
|
}
|
|
26766
|
-
return null;
|
|
27162
|
+
return { defect: null, windows };
|
|
26767
27163
|
}
|
|
26768
|
-
function selectHashIncompleteChunkCandidates(db, projectPath, modelId, candidates, limit, maxInputTokens) {
|
|
27164
|
+
function selectHashIncompleteChunkCandidates(db, projectPath, modelId, candidates, limit, maxInputTokens, leaseHeldRenumber = false) {
|
|
26769
27165
|
const missing = [];
|
|
26770
27166
|
const stale = [];
|
|
26771
27167
|
for (const candidate of candidates) {
|
|
26772
|
-
const defect = classifyChunkCoverageDefect(db, projectPath, modelId, candidate, maxInputTokens);
|
|
27168
|
+
const { defect, windows } = classifyChunkCoverageDefect(db, projectPath, modelId, candidate, maxInputTokens);
|
|
26773
27169
|
if (defect === "missing")
|
|
26774
27170
|
missing.push(candidate);
|
|
26775
27171
|
else if (defect === "stale")
|
|
26776
27172
|
stale.push(candidate);
|
|
27173
|
+
else if (defect === "renumber" && leaseHeldRenumber) {
|
|
27174
|
+
renumberOneBasedChunkWindows(db, candidate, projectPath, modelId, windows);
|
|
27175
|
+
}
|
|
26777
27176
|
}
|
|
26778
27177
|
return [...missing, ...stale].slice(0, limit);
|
|
26779
27178
|
}
|
|
26780
27179
|
var sessionBackfillCandidateStatements = new WeakMap;
|
|
26781
|
-
function loadUnembeddedSessionChunkCandidates(db, projectPath, sessionId, modelId, limit, excludeIds, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS) {
|
|
27180
|
+
function loadUnembeddedSessionChunkCandidates(db, projectPath, sessionId, modelId, limit, excludeIds, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS, leaseHeldRenumber = false) {
|
|
26782
27181
|
const exclusions = excludeIds && excludeIds.length > 0 ? excludeIds : [];
|
|
26783
27182
|
const exclusionSql = exclusions.length > 0 ? `AND c.id NOT IN (${exclusions.map(() => "?").join(", ")})` : "";
|
|
26784
27183
|
const stmt = exclusions.length > 0 ? db.prepare(`SELECT c.id AS id,
|
|
@@ -26817,7 +27216,7 @@ function loadUnembeddedSessionChunkCandidates(db, projectPath, sessionId, modelI
|
|
|
26817
27216
|
return cached;
|
|
26818
27217
|
})();
|
|
26819
27218
|
const rows = stmt.all(projectPath, sessionId, ...exclusions);
|
|
26820
|
-
return selectHashIncompleteChunkCandidates(db, projectPath, modelId, mapBackfillCandidateRows(rows), Math.max(1, limit), maxInputTokens);
|
|
27219
|
+
return selectHashIncompleteChunkCandidates(db, projectPath, modelId, mapBackfillCandidateRows(rows), Math.max(1, limit), maxInputTokens, leaseHeldRenumber);
|
|
26821
27220
|
}
|
|
26822
27221
|
function countUnembeddedSessionCompartments(db, projectPath, sessionId, modelId, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS) {
|
|
26823
27222
|
return loadUnembeddedSessionChunkCandidates(db, projectPath, sessionId, modelId, Number.MAX_SAFE_INTEGER, undefined, maxInputTokens).length;
|
|
@@ -26840,9 +27239,9 @@ function countSessionCompartmentEmbedCoverage(db, projectPath, sessionId, modelI
|
|
|
26840
27239
|
const candidates = mapBackfillCandidateRows(rows);
|
|
26841
27240
|
let embedded = 0;
|
|
26842
27241
|
for (const candidate of candidates) {
|
|
26843
|
-
|
|
27242
|
+
const { defect } = classifyChunkCoverageDefect(db, projectPath, modelId, candidate, maxInputTokens);
|
|
27243
|
+
if (defect === null || defect === "renumber")
|
|
26844
27244
|
embedded += 1;
|
|
26845
|
-
}
|
|
26846
27245
|
}
|
|
26847
27246
|
return { embedded, total: candidates.length };
|
|
26848
27247
|
}
|
|
@@ -27262,6 +27661,78 @@ function dominantEmbeddingFailure(failures) {
|
|
|
27262
27661
|
return dominant?.failure;
|
|
27263
27662
|
}
|
|
27264
27663
|
|
|
27664
|
+
// src/features/magic-context/memory/embedding-model-match.ts
|
|
27665
|
+
function parseEmbeddingModel(model) {
|
|
27666
|
+
const lastColon = model.lastIndexOf(":");
|
|
27667
|
+
if (lastColon > model.lastIndexOf("/")) {
|
|
27668
|
+
return { base: model.slice(0, lastColon), tag: model.slice(lastColon + 1) };
|
|
27669
|
+
}
|
|
27670
|
+
return { base: model };
|
|
27671
|
+
}
|
|
27672
|
+
function normalizeEmbeddingModelId(model) {
|
|
27673
|
+
return parseEmbeddingModel(model.trim().toLowerCase()).base;
|
|
27674
|
+
}
|
|
27675
|
+
function matchNormalizedEmbeddingModels(a, b) {
|
|
27676
|
+
if (a.length === 0 || b.length === 0)
|
|
27677
|
+
return true;
|
|
27678
|
+
if (a === b)
|
|
27679
|
+
return true;
|
|
27680
|
+
const longer = a.length >= b.length ? a : b;
|
|
27681
|
+
const shorter = a.length >= b.length ? b : a;
|
|
27682
|
+
const isBoundary = (ch) => ch === "-" || ch === "/";
|
|
27683
|
+
if (longer.startsWith(shorter) && isBoundary(longer.charAt(shorter.length)))
|
|
27684
|
+
return true;
|
|
27685
|
+
if (longer.endsWith(shorter) && isBoundary(longer.charAt(longer.length - shorter.length - 1)))
|
|
27686
|
+
return true;
|
|
27687
|
+
return false;
|
|
27688
|
+
}
|
|
27689
|
+
function embeddingModelsMatch(served, requested) {
|
|
27690
|
+
const servedNormalized = served.trim().toLowerCase();
|
|
27691
|
+
const requestedNormalized = requested.trim().toLowerCase();
|
|
27692
|
+
const servedModel = parseEmbeddingModel(servedNormalized);
|
|
27693
|
+
const requestedModel = parseEmbeddingModel(requestedNormalized);
|
|
27694
|
+
if (servedModel.tag !== undefined && requestedModel.tag !== undefined && servedModel.tag !== requestedModel.tag) {
|
|
27695
|
+
return false;
|
|
27696
|
+
}
|
|
27697
|
+
return matchNormalizedEmbeddingModels(servedModel.base, requestedModel.base);
|
|
27698
|
+
}
|
|
27699
|
+
var QWEN3_QUERY_INSTRUCTION = `Instruct: Given a web search query, retrieve relevant passages that answer the query
|
|
27700
|
+
Query: `;
|
|
27701
|
+
var INSTRUCT_WEB_SEARCH_QUERY_PREFIX = QWEN3_QUERY_INSTRUCTION;
|
|
27702
|
+
var EMBEDDING_MODEL_PREFIX_FAMILIES = [
|
|
27703
|
+
{
|
|
27704
|
+
family: "qwen3-embedding",
|
|
27705
|
+
basenamePattern: /^qwen3-embedding(?:-|$)/,
|
|
27706
|
+
prefixes: { queryPrefix: QWEN3_QUERY_INSTRUCTION, documentPrefix: "" }
|
|
27707
|
+
},
|
|
27708
|
+
{
|
|
27709
|
+
family: "gte-qwen-instruct",
|
|
27710
|
+
basenamePattern: /^gte-qwen.*-instruct(?:-|$)/,
|
|
27711
|
+
prefixes: { queryPrefix: INSTRUCT_WEB_SEARCH_QUERY_PREFIX, documentPrefix: "" }
|
|
27712
|
+
},
|
|
27713
|
+
{
|
|
27714
|
+
family: "e5-instruct",
|
|
27715
|
+
basenamePattern: /^(?:multilingual-)?e5-.*-instruct(?:-|$)/,
|
|
27716
|
+
prefixes: { queryPrefix: INSTRUCT_WEB_SEARCH_QUERY_PREFIX, documentPrefix: "" }
|
|
27717
|
+
},
|
|
27718
|
+
{
|
|
27719
|
+
family: "nomic-embed-text",
|
|
27720
|
+
basenamePattern: /^nomic-embed-text(?:-|$)/,
|
|
27721
|
+
prefixes: { queryPrefix: "search_query: ", documentPrefix: "search_document: " }
|
|
27722
|
+
}
|
|
27723
|
+
];
|
|
27724
|
+
function modelBasename(model) {
|
|
27725
|
+
const normalized = normalizeEmbeddingModelId(model);
|
|
27726
|
+
return normalized.slice(normalized.lastIndexOf("/") + 1);
|
|
27727
|
+
}
|
|
27728
|
+
function resolveEmbeddingTextPrefixes(model, queryInstruction, documentPrefix) {
|
|
27729
|
+
const family = EMBEDDING_MODEL_PREFIX_FAMILIES.find(({ basenamePattern }) => basenamePattern.test(modelBasename(model)));
|
|
27730
|
+
return {
|
|
27731
|
+
queryPrefix: queryInstruction === false ? "" : queryInstruction !== undefined ? queryInstruction : family?.prefixes.queryPrefix ?? "",
|
|
27732
|
+
documentPrefix: documentPrefix ?? family?.prefixes.documentPrefix ?? ""
|
|
27733
|
+
};
|
|
27734
|
+
}
|
|
27735
|
+
|
|
27265
27736
|
// src/features/magic-context/memory/embedding-identity.ts
|
|
27266
27737
|
function normalizeEndpoint(endpoint) {
|
|
27267
27738
|
return endpoint?.trim().replace(/\/+$/, "") ?? "";
|
|
@@ -27280,6 +27751,7 @@ function getEmbeddingProviderIdentity(config) {
|
|
|
27280
27751
|
throw new Error("Unknown embedding provider");
|
|
27281
27752
|
}
|
|
27282
27753
|
const truncate = config.provider === "openai-compatible" ? config.truncate?.trim() : undefined;
|
|
27754
|
+
const documentPrefix = config.provider === "openai-compatible" ? resolveEmbeddingTextPrefixes(config.model, config.query_instruction, config.document_prefix).documentPrefix : "";
|
|
27283
27755
|
const localDtype = config.provider === "local" && config.local_dtype && config.local_dtype !== "fp32" ? config.local_dtype : undefined;
|
|
27284
27756
|
const identityInput = config.provider === "openai-compatible" ? {
|
|
27285
27757
|
provider: "openai-compatible",
|
|
@@ -27287,6 +27759,7 @@ function getEmbeddingProviderIdentity(config) {
|
|
|
27287
27759
|
endpoint: normalizeEndpoint(config.endpoint),
|
|
27288
27760
|
apiKeyPresent: Boolean(config.api_key?.trim()),
|
|
27289
27761
|
inputType: config.input_type?.trim() || "",
|
|
27762
|
+
...documentPrefix ? { documentPrefix } : {},
|
|
27290
27763
|
...truncate ? { truncate } : {}
|
|
27291
27764
|
} : {
|
|
27292
27765
|
provider: "local",
|
|
@@ -27968,37 +28441,6 @@ function blockedEmbeddingEndpointReason(endpoint) {
|
|
|
27968
28441
|
function normalizeEndpoint2(endpoint) {
|
|
27969
28442
|
return endpoint?.trim().replace(/\/+$/, "") ?? "";
|
|
27970
28443
|
}
|
|
27971
|
-
function parseEmbeddingModel(model) {
|
|
27972
|
-
const lastColon = model.lastIndexOf(":");
|
|
27973
|
-
if (lastColon > model.lastIndexOf("/")) {
|
|
27974
|
-
return { base: model.slice(0, lastColon), tag: model.slice(lastColon + 1) };
|
|
27975
|
-
}
|
|
27976
|
-
return { base: model };
|
|
27977
|
-
}
|
|
27978
|
-
function matchNormalizedEmbeddingModels(a, b) {
|
|
27979
|
-
if (a.length === 0 || b.length === 0)
|
|
27980
|
-
return true;
|
|
27981
|
-
if (a === b)
|
|
27982
|
-
return true;
|
|
27983
|
-
const longer = a.length >= b.length ? a : b;
|
|
27984
|
-
const shorter = a.length >= b.length ? b : a;
|
|
27985
|
-
const isBoundary = (ch) => ch === "-" || ch === "/";
|
|
27986
|
-
if (longer.startsWith(shorter) && isBoundary(longer.charAt(shorter.length)))
|
|
27987
|
-
return true;
|
|
27988
|
-
if (longer.endsWith(shorter) && isBoundary(longer.charAt(longer.length - shorter.length - 1)))
|
|
27989
|
-
return true;
|
|
27990
|
-
return false;
|
|
27991
|
-
}
|
|
27992
|
-
function embeddingModelsMatch(served, requested) {
|
|
27993
|
-
const a = served.trim().toLowerCase();
|
|
27994
|
-
const b = requested.trim().toLowerCase();
|
|
27995
|
-
const servedModel = parseEmbeddingModel(a);
|
|
27996
|
-
const requestedModel = parseEmbeddingModel(b);
|
|
27997
|
-
if (servedModel.tag !== undefined && requestedModel.tag !== undefined && servedModel.tag !== requestedModel.tag) {
|
|
27998
|
-
return false;
|
|
27999
|
-
}
|
|
28000
|
-
return matchNormalizedEmbeddingModels(servedModel.base, requestedModel.base);
|
|
28001
|
-
}
|
|
28002
28444
|
var FAILURE_THRESHOLD = 3;
|
|
28003
28445
|
var FAILURE_WINDOW_MS = 60000;
|
|
28004
28446
|
var OPEN_DURATION_MS = 5 * 60000;
|
|
@@ -28012,6 +28454,8 @@ class OpenAICompatibleEmbeddingProvider {
|
|
|
28012
28454
|
apiKey;
|
|
28013
28455
|
inputType;
|
|
28014
28456
|
queryInputType;
|
|
28457
|
+
queryPrefix;
|
|
28458
|
+
documentPrefix;
|
|
28015
28459
|
truncate;
|
|
28016
28460
|
initialized = false;
|
|
28017
28461
|
failureTimes = [];
|
|
@@ -28026,6 +28470,9 @@ class OpenAICompatibleEmbeddingProvider {
|
|
|
28026
28470
|
this.apiKey = options.apiKey?.trim() ?? "";
|
|
28027
28471
|
this.inputType = options.inputType?.trim() ?? "";
|
|
28028
28472
|
this.queryInputType = options.queryInputType?.trim() ?? "";
|
|
28473
|
+
const prefixes = resolveEmbeddingTextPrefixes(this.model, options.queryInstruction, options.documentPrefix);
|
|
28474
|
+
this.queryPrefix = prefixes.queryPrefix;
|
|
28475
|
+
this.documentPrefix = prefixes.documentPrefix;
|
|
28029
28476
|
this.truncate = options.truncate?.trim() ?? "";
|
|
28030
28477
|
this.maxInputTokens = typeof options.maxInputTokens === "number" && Number.isFinite(options.maxInputTokens) ? Math.max(1, Math.floor(options.maxInputTokens)) : 512;
|
|
28031
28478
|
this.modelId = getEmbeddingProviderIdentity({
|
|
@@ -28034,6 +28481,7 @@ class OpenAICompatibleEmbeddingProvider {
|
|
|
28034
28481
|
model: this.model,
|
|
28035
28482
|
...this.apiKey ? { api_key: this.apiKey } : {},
|
|
28036
28483
|
...this.inputType ? { input_type: this.inputType } : {},
|
|
28484
|
+
...options.documentPrefix !== undefined ? { document_prefix: options.documentPrefix } : {},
|
|
28037
28485
|
...this.truncate ? { truncate: this.truncate } : {}
|
|
28038
28486
|
});
|
|
28039
28487
|
}
|
|
@@ -28068,7 +28516,8 @@ class OpenAICompatibleEmbeddingProvider {
|
|
|
28068
28516
|
if (texts.length === 0) {
|
|
28069
28517
|
return [];
|
|
28070
28518
|
}
|
|
28071
|
-
const
|
|
28519
|
+
const textPrefix = purpose === "query" ? this.queryPrefix : this.documentPrefix;
|
|
28520
|
+
const requestTexts = texts.map((text) => `${textPrefix}${text.trim().length === 0 ? " " : text}`);
|
|
28072
28521
|
if (!await this.initialize()) {
|
|
28073
28522
|
return Array.from({ length: texts.length }, () => null);
|
|
28074
28523
|
}
|
|
@@ -28624,6 +29073,8 @@ function resolveEmbeddingConfig(config) {
|
|
|
28624
29073
|
...apiKey ? { api_key: apiKey } : {},
|
|
28625
29074
|
...inputType ? { input_type: inputType } : {},
|
|
28626
29075
|
...queryInputType ? { query_input_type: queryInputType } : {},
|
|
29076
|
+
...config.query_instruction !== undefined ? { query_instruction: config.query_instruction } : {},
|
|
29077
|
+
...config.document_prefix !== undefined ? { document_prefix: config.document_prefix } : {},
|
|
28627
29078
|
...truncate ? { truncate } : {},
|
|
28628
29079
|
...config.max_input_tokens ? {
|
|
28629
29080
|
max_input_tokens: normalizeCompartmentChunkMaxInputTokens(config.max_input_tokens)
|
|
@@ -28671,6 +29122,8 @@ function createProvider(config, context) {
|
|
|
28671
29122
|
apiKey: config.api_key,
|
|
28672
29123
|
inputType: config.input_type,
|
|
28673
29124
|
queryInputType: config.query_input_type,
|
|
29125
|
+
queryInstruction: config.query_instruction,
|
|
29126
|
+
documentPrefix: config.document_prefix,
|
|
28674
29127
|
truncate: config.truncate,
|
|
28675
29128
|
maxInputTokens: config.max_input_tokens
|
|
28676
29129
|
});
|
|
@@ -29971,8 +30424,6 @@ async function embedSessionCompartmentChunks(db, projectIdentity, sessionId, opt
|
|
|
29971
30424
|
recordSessionProjectIdentity(db, sessionId, projectIdentity);
|
|
29972
30425
|
const maxInputTokens = getProjectEmbeddingMaxInputTokens(projectIdentity);
|
|
29973
30426
|
const total = countUnembeddedSessionCompartments(db, projectIdentity, sessionId, snapshot.chunkModelId, maxInputTokens);
|
|
29974
|
-
if (total === 0)
|
|
29975
|
-
return { status: "nothing", embedded: 0, total: 0 };
|
|
29976
30427
|
const holderId = `session-embed-${randomUUID2()}`;
|
|
29977
30428
|
const lease = acquireGitSweepLease(db, projectIdentity, holderId, { ignoreCooldown: true });
|
|
29978
30429
|
if (!lease.acquired)
|
|
@@ -30008,7 +30459,7 @@ async function embedSessionCompartmentChunks(db, projectIdentity, sessionId, opt
|
|
|
30008
30459
|
aborted = true;
|
|
30009
30460
|
break;
|
|
30010
30461
|
}
|
|
30011
|
-
const candidates = loadUnembeddedSessionChunkCandidates(db, projectIdentity, sessionId, snapshot.chunkModelId, batchSize, [...skipIds, ...failedIds], maxInputTokens);
|
|
30462
|
+
const candidates = loadUnembeddedSessionChunkCandidates(db, projectIdentity, sessionId, snapshot.chunkModelId, batchSize, [...skipIds, ...failedIds], maxInputTokens, true);
|
|
30012
30463
|
if (candidates.length === 0)
|
|
30013
30464
|
break;
|
|
30014
30465
|
const {
|
|
@@ -30050,6 +30501,8 @@ async function embedSessionCompartmentChunks(db, projectIdentity, sessionId, opt
|
|
|
30050
30501
|
log("[magic-context] embed drain: lease release failed (will TTL-expire):", error);
|
|
30051
30502
|
}
|
|
30052
30503
|
}
|
|
30504
|
+
if (total === 0)
|
|
30505
|
+
return { status: "nothing", embedded: 0, total: 0 };
|
|
30053
30506
|
if (aborted)
|
|
30054
30507
|
return { status: "aborted", embedded, total, failed: failedIds.length };
|
|
30055
30508
|
if (providerDown || failedIds.length > 0) {
|
|
@@ -30243,6 +30696,8 @@ function createProvider2(config) {
|
|
|
30243
30696
|
apiKey: config.api_key,
|
|
30244
30697
|
inputType: config.input_type,
|
|
30245
30698
|
queryInputType: config.query_input_type,
|
|
30699
|
+
queryInstruction: config.query_instruction,
|
|
30700
|
+
documentPrefix: config.document_prefix,
|
|
30246
30701
|
truncate: config.truncate,
|
|
30247
30702
|
maxInputTokens: config.max_input_tokens
|
|
30248
30703
|
});
|
|
@@ -31490,16 +31945,16 @@ function checkCompactionMarkerConsistency(db) {
|
|
|
31490
31945
|
try {
|
|
31491
31946
|
opencodeDb = new Database(opencodeDbPath, { readonly: true });
|
|
31492
31947
|
} catch (error) {
|
|
31493
|
-
log(`[magic-context] compaction-marker consistency check
|
|
31948
|
+
log(`[magic-context] compaction-marker consistency check SKIPPED retaining state path=${opencodeDbPath} source=${resolution.source} mode=readonly wal=aware: ${error instanceof Error ? error.message : String(error)}`);
|
|
31494
31949
|
return;
|
|
31495
31950
|
}
|
|
31496
31951
|
try {
|
|
31497
31952
|
const persistedRows = db.prepare("SELECT session_id, compaction_marker_state FROM session_meta WHERE compaction_marker_state IS NOT NULL AND compaction_marker_state != ''").all();
|
|
31498
31953
|
if (persistedRows.length === 0)
|
|
31499
31954
|
return;
|
|
31955
|
+
log(`[magic-context] compaction-marker consistency probe path=${opencodeDbPath} source=${resolution.source} mode=readonly wal=aware sessions=${persistedRows.length}; diagnostic-only, no startup bust permission`);
|
|
31500
31956
|
const checkMessage = opencodeDb.prepare("SELECT 1 FROM message WHERE id = ? LIMIT 1");
|
|
31501
31957
|
const checkPart = opencodeDb.prepare("SELECT 1 FROM part WHERE id = ? LIMIT 1");
|
|
31502
|
-
let reconciledCount = 0;
|
|
31503
31958
|
for (const row of persistedRows) {
|
|
31504
31959
|
const state = getPersistedCompactionMarkerState(db, row.session_id);
|
|
31505
31960
|
if (!state)
|
|
@@ -31511,25 +31966,10 @@ function checkCompactionMarkerConsistency(db) {
|
|
|
31511
31966
|
const allPresent = boundaryExists && summaryMessageExists && compactionPartExists && summaryPartExists;
|
|
31512
31967
|
if (allPresent)
|
|
31513
31968
|
continue;
|
|
31514
|
-
|
|
31515
|
-
try {
|
|
31516
|
-
removedOk = removeCompactionMarker(state);
|
|
31517
|
-
} catch (error) {
|
|
31518
|
-
sessionLog(row.session_id, "compaction-marker consistency: partial cleanup of half-written marker failed:", error);
|
|
31519
|
-
}
|
|
31520
|
-
if (removedOk) {
|
|
31521
|
-
setPersistedCompactionMarkerState(db, row.session_id, null);
|
|
31522
|
-
sessionLog(row.session_id, `compaction-marker consistency: cleared orphaned state (boundary=${boundaryExists} summary=${summaryMessageExists} cPart=${compactionPartExists} sPart=${summaryPartExists}); next publication will re-inject`);
|
|
31523
|
-
reconciledCount++;
|
|
31524
|
-
} else {
|
|
31525
|
-
sessionLog(row.session_id, `compaction-marker consistency: cleanup failed for orphaned state (boundary=${boundaryExists} summary=${summaryMessageExists} cPart=${compactionPartExists} sPart=${summaryPartExists}); will retry on next startup`);
|
|
31526
|
-
}
|
|
31527
|
-
}
|
|
31528
|
-
if (reconciledCount > 0) {
|
|
31529
|
-
log(`[magic-context] compaction-marker consistency: reconciled ${reconciledCount} session(s) with orphaned marker state at startup`);
|
|
31969
|
+
sessionLog(row.session_id, `compaction-marker consistency: SKIPPED destructive reconciliation reason=unproven_writer_and_no_bust_permission path=${opencodeDbPath} source=${resolution.source} mode=readonly wal=aware boundary=${boundaryExists} summary=${summaryMessageExists} cPart=${compactionPartExists} sPart=${summaryPartExists}; retaining state until priced publication`);
|
|
31530
31970
|
}
|
|
31531
31971
|
} catch (error) {
|
|
31532
|
-
log(`[magic-context] compaction-marker consistency check
|
|
31972
|
+
log(`[magic-context] compaction-marker consistency check SKIPPED retaining state path=${opencodeDbPath} source=${resolution.source} mode=readonly wal=aware: ${error instanceof Error ? error.message : String(error)}`);
|
|
31533
31973
|
} finally {
|
|
31534
31974
|
try {
|
|
31535
31975
|
closeQuietly(opencodeDb);
|
|
@@ -32689,24 +33129,9 @@ function validateHistorianOutput(text, _sessionId, chunk, _priorCompartments, se
|
|
|
32689
33129
|
};
|
|
32690
33130
|
}
|
|
32691
33131
|
var HISTORIAN_PERSISTENT_FAILURE_THRESHOLD = 3;
|
|
32692
|
-
function buildHistorianFailureNotice(failureCount,
|
|
32693
|
-
|
|
32694
|
-
|
|
32695
|
-
"## Magic Context — history comparting needs attention",
|
|
32696
|
-
"",
|
|
32697
|
-
`Magic Context has been unable to compart this session's history ${failureCount} times in a row. This usually means the configured historian model is misconfigured or unreachable (Magic Context already retried every fallback model automatically).`,
|
|
32698
|
-
"",
|
|
32699
|
-
`Last error: ${lastError}`,
|
|
32700
|
-
"",
|
|
32701
|
-
"Check your historian model in magic-context.jsonc, then restart. Your conversation keeps working normally in the meantime — this only affects how older history is summarized."
|
|
32702
|
-
].join(`
|
|
32703
|
-
`);
|
|
32704
|
-
}
|
|
32705
|
-
return [
|
|
32706
|
-
"## Magic Context",
|
|
32707
|
-
"",
|
|
32708
|
-
"Hit a transient issue comparting history this turn — Magic Context will retry automatically on the next turn. Nothing is lost and your conversation continues normally. You'll only be alerted again if this keeps happening."
|
|
32709
|
-
].join(`
|
|
33132
|
+
function buildHistorianFailureNotice(failureCount, _lastError) {
|
|
33133
|
+
const heading = failureCount >= HISTORIAN_PERSISTENT_FAILURE_THRESHOLD ? "## Magic Context — History compression" : "## Magic Context";
|
|
33134
|
+
return [heading, "", renderUserFacingFailure("historian_unavailable")].join(`
|
|
32710
33135
|
`);
|
|
32711
33136
|
}
|
|
32712
33137
|
function buildHistorianRepairPrompt(originalPrompt, previousOutput, validationError, language) {
|
|
@@ -39571,10 +39996,10 @@ Found ${existingStaging.compartments.length} staged compartment(s) from ${existi
|
|
|
39571
39996
|
}
|
|
39572
39997
|
}
|
|
39573
39998
|
}
|
|
39999
|
+
sessionLog(sessionId, `recomp partial code=${userFacingFailureCode("recomp_unavailable")} reason="${reason}"`);
|
|
39574
40000
|
return [
|
|
39575
|
-
`
|
|
39576
|
-
|
|
39577
|
-
`Remaining messages ${lastCompartmentEnd + 1}-${protectedTailStart - 1} were not rebuilt (${reason}).`
|
|
40001
|
+
`Rebuilt ${promoted.compartments.length} history block${promoted.compartments.length === 1 ? "" : "s"} across ${passCount} successful pass${passCount === 1 ? "" : "es"}.`,
|
|
40002
|
+
renderUserFacingFailure("recomp_unavailable")
|
|
39578
40003
|
].join(`
|
|
39579
40004
|
`);
|
|
39580
40005
|
}
|
|
@@ -39599,11 +40024,10 @@ Recomp stopped because raw history ${offset}-${protectedTailStart - 1} could not
|
|
|
39599
40024
|
|
|
39600
40025
|
${partial}`;
|
|
39601
40026
|
}
|
|
40027
|
+
sessionLog(sessionId, `recomp failed code=${userFacingFailureCode("recomp_unavailable")} reason="${chunkCoverageError}"`);
|
|
39602
40028
|
return `## Magic Recomp — Failed
|
|
39603
40029
|
|
|
39604
|
-
|
|
39605
|
-
|
|
39606
|
-
Nothing was written.`;
|
|
40030
|
+
${renderUserFacingFailure("recomp_unavailable")}`;
|
|
39607
40031
|
}
|
|
39608
40032
|
const references = buildReferenceBlocks({
|
|
39609
40033
|
sessionId,
|
|
@@ -39645,11 +40069,10 @@ Historian pass ${passCount + 1}, attempt ${passAttempt} started for messages ${c
|
|
|
39645
40069
|
callbacks: {
|
|
39646
40070
|
onRepairRetry: async (error) => {
|
|
39647
40071
|
emitProgress(`Repair retry (pass ${passCount + 1})…`);
|
|
40072
|
+
sessionLog(sessionId, `recomp retry code=${userFacingFailureCode("recomp_unavailable")} reason="${error}"`);
|
|
39648
40073
|
await sendStatusNotification2(client, sessionId, `## Magic Recomp
|
|
39649
40074
|
|
|
39650
|
-
|
|
39651
|
-
|
|
39652
|
-
The previous output did not validate: ${error}`, notifParams());
|
|
40075
|
+
History compression is retrying this pass. ${renderUserFacingFailure("recomp_unavailable")}`, notifParams());
|
|
39653
40076
|
},
|
|
39654
40077
|
onModelFallback: (modelId, index, total) => {
|
|
39655
40078
|
const short = modelId.includes("/") ? modelId.split("/").pop() : modelId;
|
|
@@ -39664,9 +40087,7 @@ The previous output did not validate: ${error}`, notifParams());
|
|
|
39664
40087
|
if (smallerChunk.messageCount > 0 && smallerChunk.endIndex < chunk.endIndex) {
|
|
39665
40088
|
await sendStatusNotification2(client, sessionId, `## Magic Recomp
|
|
39666
40089
|
|
|
39667
|
-
|
|
39668
|
-
|
|
39669
|
-
Validator result: ${validatedPass.error}`, notifParams());
|
|
40090
|
+
History compression is retrying with a smaller set of messages. ${renderUserFacingFailure("recomp_unavailable")}`, notifParams());
|
|
39670
40091
|
currentTokenBudget = reducedBudget;
|
|
39671
40092
|
passAttempt += 1;
|
|
39672
40093
|
continue;
|
|
@@ -39683,7 +40104,8 @@ Validator result: ${validatedPass.error}`, notifParams());
|
|
|
39683
40104
|
chunkEndOrdinal: chunk.endIndex,
|
|
39684
40105
|
compartmentsProduced: 0
|
|
39685
40106
|
});
|
|
39686
|
-
|
|
40107
|
+
sessionLog(sessionId, `recomp failed code=${userFacingFailureCode("recomp_unavailable")} reason="${validatedPass.error}" messageRange=${chunk.startIndex}-${chunk.endIndex}`);
|
|
40108
|
+
const partial = await promoteAndFinalize(`history model response did not validate for messages ${chunk.startIndex}-${chunk.endIndex}`);
|
|
39687
40109
|
if (partial) {
|
|
39688
40110
|
return `## Magic Recomp — Partial
|
|
39689
40111
|
|
|
@@ -39691,9 +40113,7 @@ ${partial}`;
|
|
|
39691
40113
|
}
|
|
39692
40114
|
return `## Magic Recomp — Failed
|
|
39693
40115
|
|
|
39694
|
-
|
|
39695
|
-
|
|
39696
|
-
Nothing was written.`;
|
|
40116
|
+
${renderUserFacingFailure("recomp_unavailable")}`;
|
|
39697
40117
|
}
|
|
39698
40118
|
{
|
|
39699
40119
|
const passComps = validatedPass.compartments ?? [];
|
|
@@ -39744,11 +40164,10 @@ Recomp made no forward progress after messages ${chunk.startIndex}-${chunk.endIn
|
|
|
39744
40164
|
const mergedValidationError = validateStoredCompartments(candidateCompartments);
|
|
39745
40165
|
if (mergedValidationError) {
|
|
39746
40166
|
clearRecompStaging(db, sessionId);
|
|
40167
|
+
sessionLog(sessionId, `recomp failed code=${userFacingFailureCode("recomp_unavailable")} reason="${mergedValidationError}"`);
|
|
39747
40168
|
return `## Magic Recomp — Failed
|
|
39748
40169
|
|
|
39749
|
-
|
|
39750
|
-
|
|
39751
|
-
Nothing was written.`;
|
|
40170
|
+
${renderUserFacingFailure("recomp_unavailable")}`;
|
|
39752
40171
|
}
|
|
39753
40172
|
saveRecompStagingPass(db, sessionId, passCount, candidateCompartments, candidateFacts);
|
|
39754
40173
|
const lastCompartmentEnd = candidateCompartments[candidateCompartments.length - 1]?.endMessage ?? 0;
|
|
@@ -39800,11 +40219,10 @@ Another process acquired the compartment-state lease before recomp could publish
|
|
|
39800
40219
|
`);
|
|
39801
40220
|
} catch (error) {
|
|
39802
40221
|
const message = getErrorMessage(error);
|
|
40222
|
+
sessionLog(sessionId, `recomp failed code=${userFacingFailureCode("recomp_unavailable")} reason="${message}"`);
|
|
39803
40223
|
return `## Magic Recomp — Failed
|
|
39804
40224
|
|
|
39805
|
-
|
|
39806
|
-
|
|
39807
|
-
Staging data preserved for resume on next attempt.`;
|
|
40225
|
+
${renderUserFacingFailure("recomp_unavailable")}`;
|
|
39808
40226
|
} finally {
|
|
39809
40227
|
updateSessionMeta2(db, sessionId, { compartmentInProgress: false });
|
|
39810
40228
|
cleanupHistorianStateFile(currentStateFilePath);
|
|
@@ -40022,11 +40440,10 @@ Recomp stopped because raw history ${offset}-${snapEnd} could not be turned into
|
|
|
40022
40440
|
}
|
|
40023
40441
|
const chunkCoverageError = validateChunkCoverage(chunk);
|
|
40024
40442
|
if (chunkCoverageError) {
|
|
40443
|
+
log(`[magic-context] partial recomp failed session=${sessionId} code=${userFacingFailureCode("recomp_unavailable")} reason="${chunkCoverageError}"`);
|
|
40025
40444
|
return `## Magic Recomp — Failed
|
|
40026
40445
|
|
|
40027
|
-
|
|
40028
|
-
|
|
40029
|
-
Original state preserved (staging kept for retry).`;
|
|
40446
|
+
${renderUserFacingFailure("recomp_unavailable")}`;
|
|
40030
40447
|
}
|
|
40031
40448
|
const references = buildReferenceBlocks({
|
|
40032
40449
|
sessionId,
|
|
@@ -40066,11 +40483,10 @@ Historian pass ${passCount + 1}, attempt ${passAttempt} started for messages ${c
|
|
|
40066
40483
|
language: deps.language,
|
|
40067
40484
|
callbacks: {
|
|
40068
40485
|
onRepairRetry: async (error) => {
|
|
40486
|
+
log(`[magic-context] partial recomp retry session=${sessionId} code=${userFacingFailureCode("recomp_unavailable")} reason="${error}"`);
|
|
40069
40487
|
await sendStatusNotification2(client, sessionId, `## Magic Recomp — Partial
|
|
40070
40488
|
|
|
40071
|
-
|
|
40072
|
-
|
|
40073
|
-
The previous output did not validate: ${error}`, notifParams());
|
|
40489
|
+
History compression is retrying this pass. ${renderUserFacingFailure("recomp_unavailable")}`, notifParams());
|
|
40074
40490
|
}
|
|
40075
40491
|
}
|
|
40076
40492
|
});
|
|
@@ -40081,19 +40497,16 @@ The previous output did not validate: ${error}`, notifParams());
|
|
|
40081
40497
|
if (smallerChunk.messageCount > 0 && smallerChunk.endIndex < chunk.endIndex) {
|
|
40082
40498
|
await sendStatusNotification2(client, sessionId, `## Magic Recomp — Partial
|
|
40083
40499
|
|
|
40084
|
-
|
|
40085
|
-
|
|
40086
|
-
Validator result: ${validatedPass.error}`, notifParams());
|
|
40500
|
+
History compression is retrying with a smaller set of messages. ${renderUserFacingFailure("recomp_unavailable")}`, notifParams());
|
|
40087
40501
|
currentTokenBudget = reducedBudget;
|
|
40088
40502
|
passAttempt += 1;
|
|
40089
40503
|
continue;
|
|
40090
40504
|
}
|
|
40091
40505
|
}
|
|
40506
|
+
log(`[magic-context] partial recomp failed session=${sessionId} code=${userFacingFailureCode("recomp_unavailable")} reason="${validatedPass.error}" messageRange=${chunk.startIndex}-${chunk.endIndex}`);
|
|
40092
40507
|
return `## Magic Recomp — Failed
|
|
40093
40508
|
|
|
40094
|
-
|
|
40095
|
-
|
|
40096
|
-
Original state preserved (staging kept for retry).`;
|
|
40509
|
+
${renderUserFacingFailure("recomp_unavailable")}`;
|
|
40097
40510
|
}
|
|
40098
40511
|
candidateCompartments = [
|
|
40099
40512
|
...candidateCompartments,
|
|
@@ -40128,11 +40541,10 @@ Partial recomp completed historian passes but the final compartment set failed v
|
|
|
40128
40541
|
`);
|
|
40129
40542
|
} catch (error) {
|
|
40130
40543
|
const message = getErrorMessage(error);
|
|
40544
|
+
log(`[magic-context] partial recomp failed session=${sessionId} code=${userFacingFailureCode("recomp_unavailable")} reason="${message}"`);
|
|
40131
40545
|
return `## Magic Recomp — Failed
|
|
40132
40546
|
|
|
40133
|
-
|
|
40134
|
-
|
|
40135
|
-
Staging preserved for resume on next attempt.`;
|
|
40547
|
+
${renderUserFacingFailure("recomp_unavailable")}`;
|
|
40136
40548
|
} finally {
|
|
40137
40549
|
updateSessionMeta2(db, sessionId, { compartmentInProgress: false });
|
|
40138
40550
|
const leftoverStaging = getRecompStaging(db, sessionId);
|
|
@@ -40329,7 +40741,8 @@ function beginLkgPass(sessionId) {
|
|
|
40329
40741
|
}
|
|
40330
40742
|
function slotBytes(slot) {
|
|
40331
40743
|
const digestBytes = slot.inputContentDigests.reduce((total, digest) => total + 2 * digest.length, 0);
|
|
40332
|
-
|
|
40744
|
+
const ownershipBytes = slot.piOutputEntryIds?.reduce((total, id) => total + (id?.length ?? 0) * 2 + 8, 0) ?? 0;
|
|
40745
|
+
return 2 * slot.jsonPrefix.length + digestBytes + ownershipBytes + LKG_METADATA_BYTES;
|
|
40333
40746
|
}
|
|
40334
40747
|
var LKG_SNAPSHOT_ARRAY = Symbol("array");
|
|
40335
40748
|
var LKG_SNAPSHOT_OBJECT = Symbol("object");
|
|
@@ -40560,6 +40973,7 @@ function captureSlot(sessionId, slot) {
|
|
|
40560
40973
|
const entry = {
|
|
40561
40974
|
slot: {
|
|
40562
40975
|
...slot,
|
|
40976
|
+
...slot.piOutputEntryIds ? { piOutputEntryIds: [...slot.piOutputEntryIds] } : {},
|
|
40563
40977
|
inputIdSeq: [...slot.inputIdSeq],
|
|
40564
40978
|
inputContentDigests: [...slot.inputContentDigests],
|
|
40565
40979
|
inputContentSignatures: slot.inputContentSignatures ? [...slot.inputContentSignatures] : undefined
|
|
@@ -40598,6 +41012,7 @@ function installHydratedSlot(sessionId, slot) {
|
|
|
40598
41012
|
const entry = {
|
|
40599
41013
|
slot: {
|
|
40600
41014
|
...slot,
|
|
41015
|
+
...slot.piOutputEntryIds ? { piOutputEntryIds: [...slot.piOutputEntryIds] } : {},
|
|
40601
41016
|
inputIdSeq: [...slot.inputIdSeq],
|
|
40602
41017
|
inputContentDigests: [...slot.inputContentDigests],
|
|
40603
41018
|
inputContentSignatures: slot.inputContentSignatures ? [...slot.inputContentSignatures] : undefined
|
|
@@ -40630,6 +41045,7 @@ function hydrateSlotFromPersistence(sessionId) {
|
|
|
40630
41045
|
function copySlotForRead(slot) {
|
|
40631
41046
|
return {
|
|
40632
41047
|
...slot,
|
|
41048
|
+
...slot.piOutputEntryIds ? { piOutputEntryIds: [...slot.piOutputEntryIds] } : {},
|
|
40633
41049
|
inputIdSeq: [...slot.inputIdSeq],
|
|
40634
41050
|
inputContentDigests: [...slot.inputContentDigests],
|
|
40635
41051
|
inputContentSignatures: slot.inputContentSignatures ? [...slot.inputContentSignatures] : undefined
|
|
@@ -40834,10 +41250,12 @@ async function runManagedRecomp2(ctx, sessionId, options) {
|
|
|
40834
41250
|
setRecompTerminal2(ctx.liveSessionState, sessionId, terminalPhase, extractRecompReason(message));
|
|
40835
41251
|
return message;
|
|
40836
41252
|
} catch (error) {
|
|
40837
|
-
|
|
41253
|
+
const failure = renderUserFacingFailure("recomp_unavailable");
|
|
41254
|
+
sessionLog(sessionId, `recomp failed code=${userFacingFailureCode("recomp_unavailable")}`, error);
|
|
41255
|
+
setRecompTerminal2(ctx.liveSessionState, sessionId, "failed", failure);
|
|
40838
41256
|
return `## Magic Recomp — Failed
|
|
40839
41257
|
|
|
40840
|
-
|
|
41258
|
+
${failure}`;
|
|
40841
41259
|
}
|
|
40842
41260
|
}
|
|
40843
41261
|
async function runManagedUpgrade2(ctx, sessionId) {
|
|
@@ -40896,10 +41314,12 @@ ${migrationSummary}` : ""
|
|
|
40896
41314
|
].join(`
|
|
40897
41315
|
`);
|
|
40898
41316
|
} catch (error) {
|
|
40899
|
-
|
|
41317
|
+
const failure = renderUserFacingFailure("recomp_unavailable");
|
|
41318
|
+
sessionLog(sessionId, `session upgrade failed code=${userFacingFailureCode("recomp_unavailable")}`, error);
|
|
41319
|
+
setRecompTerminal2(ctx.liveSessionState, sessionId, "failed", failure);
|
|
40900
41320
|
return `## Session Upgrade — Failed
|
|
40901
41321
|
|
|
40902
|
-
|
|
41322
|
+
${failure}`;
|
|
40903
41323
|
}
|
|
40904
41324
|
}
|
|
40905
41325
|
async function runUpgradeMemoryMigration(ctx, sessionId, migrationDirectory) {
|
|
@@ -40930,8 +41350,9 @@ async function runUpgradeMemoryMigration(ctx, sessionId, migrationDirectory) {
|
|
|
40930
41350
|
});
|
|
40931
41351
|
return outcome.summary;
|
|
40932
41352
|
} catch (error) {
|
|
40933
|
-
|
|
41353
|
+
sessionLog(sessionId, `memory migration failed code=${userFacingFailureCode("dream_unknown")}`, error);
|
|
41354
|
+
return renderUserFacingFailure("dream_unknown");
|
|
40934
41355
|
}
|
|
40935
41356
|
}
|
|
40936
41357
|
|
|
40937
|
-
export { withContentLanguageDirective, buildPrimaryLanguageDirective, setJsoncValue, removeJsoncValue, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, resolveLegacyConfigSourcesForHarness, migrateMagicContextConfigLocations, string, unknown, array, object, union, tuple, record, parseCron, nextOccurrence, nextDueAtMs, promptSurfaceConfigIdentity, resolveModelConfigValue, resolvePromptSurface, resolveModelConfigOrDefault, DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE, DEFAULT_HISTORIAN_TIMEOUT_MS, DEFAULT_LOCAL_EMBEDDING_MODEL, PER_HARNESS_MIGRATION_INVENTORY, PER_HARNESS_MODEL_KEYS, ConfigProfilesSchema, MagicContextConfigSchema, isFailClosedBlockingError, shouldBypassFailClosedBlock, resolveAgentNameFromMessages, createFailClosedController, recordHookInitFailure, clearHookInitFailure, getLastHookInitFailure, ProjectIdentityError, resolveProjectIdentityStrict, takeDubiousOwnershipProjectIdentityWarning, resolveProjectIdentity, directoryHasGitMetadata, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, isLinkedGitWorktree, recordSessionProjectIdentity, beginBootQuietPeriod, bootQuietRemainingMs, scheduleAfterBootQuiet, rpcPortDir, rpcPortFilePath, isPidAlive, parseRpcPortFile, observeAuthorityRouting, registerModuleNoteEvaluationBridge, getModuleNoteEvaluationBridge, getContextStoreUuid, ensureContextStoreUuid, getAuthorityManagedMarker, reconcileAuthorityProject, checksumAuthoritySeedRows, prepareAuthority, drainAuthority, applyMirroredNoteCompileFields, drainMirrorPages, pullMemoryMirrorOnce, V2_MEMORY_CATEGORIES, CATEGORY_PRIORITY, resolveWorkspaceShareCategories, resolveWorkspaceIdentitySet, expandWorkspaceIdentitySetWithAliases, resolveStoredPathWorkspaceIdentity, storedPathBelongsToWorkspace, sourceNameForMemory, computeWorkspaceEpochFingerprint, textMentionsRecentCommit, hasMeaningfulUserText, extractTexts, extractToolCallSummaries, getTokenizerNativeMemoryStats, preloadTokenizer, estimateTokens, normalizeText, getCurrentToolSetHash, recordToolDefinition, getMeasuredToolDefinitionTokens, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, runSqliteOptimize, openDatabase, openDatabaseAsync, isDatabasePersisted, getDatabasePersistenceError, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, Priority, AdmissionClass, SocketClosedError, SocketTimeoutError, StaleRouteHandleError, SubcClient, isConsumerReconnectTransient, connectionFileExists, isRecord, CTX_REDUCE_KEEP, newestCtxReduceTagNumbers, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, prependTag, isThinkingPart, estimateImageTokensFromDataUrl, normalizeTodoStateJson, buildSyntheticTodoPart, computeSyntheticCallId, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchanged, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, reclaimableToolOutputCount, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, getRecentTagOwnerMessageIds, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, getActiveTagTokenTotalsByMessage, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, markWhitespaceAssistantTagInert, getInertWhitespaceAssistantTags, updateTagDropMode, updateCavemanDepth, updateTagMessageId, markTagsCompactedByMessageIds, deleteTagsByMessageId, getMaxTagNumberBySession, getTagNumberByMessageId, getAssignableTagNumberByMessageId, deriveTagLoadFloor, getTagsBySession, getActiveTagsBySession, getTailHygieneTags, getDroppedTagsBySession, getTagsByNumbers, getDroppedTagsByNumbers, getMaxDroppedTagNumber, getTagById, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, getCandidateToolOwners, pickNearestPriorOwner, isRawCompactionSummaryInfo, extractInMemoryMessageViews, buildInMemoryTailRawMessages, estimateTrueRawMessageTokens, invalidateTrueRawTokenCache, isTextPart, isToolPartWithOutput, isFilePart, buildFileSourceContent, createDroppedInputToolExecuteBeforeHook, isEditTool, partHasCompletedResult, extractToolCallObservation, ToolMutationBatch, createToolDropTarget, setRawMessageProvider, cleanUserText, withRawSessionMessageCache, readRawSessionMessages, primeTailRawMessageCache, primeInMemoryTailRawMessageCache, readRawSessionMessageOrdinalPage, getRawSessionStoredMessageCount, readRawSessionMessagePartsById, readRawSessionMessageOrdinalById, readRawSessionMessageById, readSessionChunk, readRawSessionSeedTail, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, HAS_COMPARTMENT_CONTENT_SQL, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, clearRecompStaging, getMessageIndexSourceIdentity, isMessageIndexSourceCurrent, getLastIndexedOrdinal, getIndexedMessageCorpusSize, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, deleteIndexedMessage, clearIndexedMessages, indexSingleMessage, indexMessagesAfterOrdinal, sweepOrphanedOpenCodeMessageIndexes, recordEmbeddingMeasurement, getMaxM0MutationId, queueMemoryMutation, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationIdForProjects, MAX_EXECUTE_THRESHOLD, escalationBands, MERGED_REASONING_PARTS_PREFIX, readFrozenMergedReasoningParts, getProtectionWindowForSession, isEmergencyRecoveryArmed, isProviderOverflowReconfirmed, isProviderOverflowFailClosedProven, getEmergencyRecoveryArmedAt, loadPersistedUsage, loadProtectedTailMeta, resetProtectedTailNoEligibleHead, getWrapupInProgressState, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, getPersistedReasoningWatermark, setPersistedReasoningWatermark, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, getNoteNudgeAnchors, getAutoSearchHintDecisions, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, pruneAutoSearchHintDecisions, removeNoteNudgeAnchorByMessageId, removeAutoSearchHintDecisionByMessageId, getPersistedTodoPermissionDenied, setPersistedTodoPermissionDenied, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, setNoteLastReadAt, getHistorianFailureState, clearHistorianFailureState, getOverflowState, loadTransformPassStateSnapshot, recordOverflowDetected, recordDetectedContextLimit, clearEmergencyRecovery, clearDetectedContextLimit, getPersistedCompactionMarkerState, setPersistedCompactionMarkerState, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, removeStrippedPlaceholderId, NEWEST_REASONING_BEARING_ASSISTANT, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, thinkingBindingRecoveryFrozenId, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getTrailingBlankDecisions, addTrailingBlankDecisions, demoteTrailingBlankKeepDecisions, getStaleReduceStrippedIds, addStaleReduceStrippedIds, getProcessedImageStrippedIds, addProcessedImageStrippedIds, getPendingCompactionMarkerState, loadPostprocessReplaySnapshot, setPendingCompactionMarkerState, clearPendingCompactionMarkerStateIf, getSessionsWithPendingMarker, setSessionWorkMetrics, getObservedEpochFloor, resolveEpochFloorForPass, getNotes, addNote, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, updateNote, dismissNotes, dismissNote, markNoteReady, markNoteChecked, queuePendingOp, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectMemoryEpoch, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, createChildSessionWithFence, detectThinkingBindingMismatch, isFable51ThinkingBindingModel, detectOverflow, modelBodyField, toModelEntry, getPromptFailureDetail, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, extractLatestAssistantText, hasLengthCappedOutput, setKeepSubagents, teardownChildSession, getCompartmentEvents, SYNAPSE_DEFAULT_MODEL, toSynapseLaneDescriptor, formatSynapseLaneDescriptor, SynapseEmbeddingProvider, loadCompartmentChunkEmbeddingsForSearch, cosineSimilarity, computeNormalizedHash, getLocalEmbeddingNativeMemoryStats, saveCommitEmbedding, loadProjectCommitEmbeddings, loadUnembeddedCommits, countEmbeddedCommits, upsertCommits, getLatestIndexedCommitTimeMs, enforceProjectCap, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease, saveEmbeddingIfHashMatches, getProjectEmbeddings, peekProjectEmbeddings, invalidateProject, invalidateMemory, describeShadowBackfillWriteRefusal, markProjectLoadUntrusted, contentSha256, sweepStaleEmbeddingIdentitiesForProject, registerProjectEmbedding, registerProjectShadowEmbedding, getShadowEmbeddingMeasurementCohort, getPrimaryEmbeddingMeasurementCohort, embedShadowTextForProject, enqueueShadowEmbeddingItems, registerProjectInObservationMode, getProjectEmbeddingSnapshot, embedTextForProject, embedBatchForProject, embedItemsForProject, embedUnembeddedMemoriesForProject, drainCommitBacklogForProject, embedSessionCompartmentChunks, getEmbeddingCoverageStatus, isEmbeddingEnabled, embedText, ensureMemoryEmbeddings, computeCueContentHash, hasMuralCueColumns, getMuralCueState, memoryNeedsCue, setMuralCue, recordMuralCueRejection, hasMemoryShareableColumn, hasMemoryClassifiedAtColumn, getUnclassifiedMemoryIds, ModuleMemoryAuthorityError, insertMemory, insertMemoryIdempotent, getMemoryByHash, getMemoriesByProject, buildWorkspaceMemorySqlFilter, getMemoriesByProjects, getMaxMemoryIdForProjects, readNewMemoriesForM1Union, getMemoryById, getMemoriesByIds, updateMemorySeenCount, updateMemoryRetrievalCount, setMemoryClassification, supersededMemory, mergeMemoryStats, archiveMemory, getMemoryCountsByStatus, sanitizeFtsQuery, searchMemoriesFTS, searchMemoriesFTSUnion, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, recordChildInvocation, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getMural, BoundedSessionMap, registerLkgPersistence, beginLkgPass, visitMessageContentFields, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgContentDigest, captureSlot, getInMemorySlot, getSlot, dropSlot, noteEntry, getLkgSlotHeapStats, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, getOpenCodeDbPath, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, modelKeyAcceptsImages, resolveMuralWire, extractM0Block, formatDate, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, setRecompStarting2, setRecompTerminal2, runManagedRecomp2, runManagedUpgrade2 };
|
|
41358
|
+
export { withContentLanguageDirective, buildPrimaryLanguageDirective, setJsoncValue, removeJsoncValue, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, resolveLegacyConfigSourcesForHarness, migrateMagicContextConfigLocations, string, unknown, array, object, union, tuple, record, parseCron, nextOccurrence, nextDueAtMs, promptSurfaceConfigIdentity, resolveModelConfigValue, resolvePromptSurface, resolveModelConfigOrDefault, DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE, DEFAULT_HISTORIAN_TIMEOUT_MS, DEFAULT_LOCAL_EMBEDDING_MODEL, PER_HARNESS_MIGRATION_INVENTORY, PER_HARNESS_MODEL_KEYS, ConfigProfilesSchema, MagicContextConfigSchema, isFailClosedBlockingError, shouldBypassFailClosedBlock, resolveAgentNameFromMessages, createFailClosedController, recordHookInitFailure, clearHookInitFailure, getLastHookInitFailure, ProjectIdentityError, resolveProjectIdentityStrict, takeDubiousOwnershipProjectIdentityWarning, resolveProjectIdentity, directoryHasGitMetadata, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, isLinkedGitWorktree, recordSessionProjectIdentity, beginBootQuietPeriod, bootQuietRemainingMs, scheduleAfterBootQuiet, rpcPortDir, rpcPortFilePath, isPidAlive, parseRpcPortFile, observeAuthorityRouting, registerModuleNoteEvaluationBridge, getModuleNoteEvaluationBridge, getContextStoreUuid, ensureContextStoreUuid, getAuthorityManagedMarker, reconcileAuthorityProject, checksumAuthoritySeedRows, prepareAuthority, drainAuthority, applyMirroredNoteCompileFields, drainMirrorPages, pullMemoryMirrorOnce, V2_MEMORY_CATEGORIES, CATEGORY_PRIORITY, resolveWorkspaceShareCategories, resolveWorkspaceIdentitySet, expandWorkspaceIdentitySetWithAliases, resolveStoredPathWorkspaceIdentity, storedPathBelongsToWorkspace, sourceNameForMemory, computeWorkspaceEpochFingerprint, textMentionsRecentCommit, hasMeaningfulUserText, extractTexts, extractToolCallSummaries, getTokenizerNativeMemoryStats, preloadTokenizer, estimateTokens, normalizeText, getCurrentToolSetHash, recordToolDefinition, getMeasuredToolDefinitionTokens, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, runSqliteOptimize, openDatabase, openDatabaseAsync, isDatabasePersisted, getDatabasePersistenceError, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, Priority, AdmissionClass, SocketClosedError, SocketTimeoutError, StaleRouteHandleError, SubcClient, isConsumerReconnectTransient, connectionFileExists, isRecord, CTX_REDUCE_KEEP, newestCtxReduceTagNumbers, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, prependTag, isThinkingPart, estimateImageTokensFromDataUrl, normalizeTodoStateJson, buildSyntheticTodoPart, computeSyntheticCallId, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchanged, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, reclaimableToolOutputCount, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, getRecentTagOwnerMessageIds, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, getActiveTagTokenTotalsByMessage, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, markWhitespaceAssistantTagInert, getInertWhitespaceAssistantTags, updateTagDropMode, updateCavemanDepth, updateTagMessageId, markTagsCompactedByMessageIds, deleteTagsByMessageId, getMaxTagNumberBySession, getTagNumberByMessageId, getAssignableTagNumberByMessageId, deriveTagLoadFloor, getTagsBySession, getActiveTagsBySession, getTailHygieneTags, getDroppedTagsBySession, getTagsByNumbers, getDroppedTagsByNumbers, getMaxDroppedTagNumber, getTagById, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, getCandidateToolOwners, pickNearestPriorOwner, isRawCompactionSummaryInfo, extractInMemoryMessageViews, buildInMemoryTailRawMessages, estimateTrueRawMessageTokens, invalidateTrueRawTokenCache, isTextPart, isToolPartWithOutput, isFilePart, buildFileSourceContent, createDroppedInputToolExecuteBeforeHook, isEditTool, partHasCompletedResult, extractToolCallObservation, ToolMutationBatch, createToolDropTarget, setRawMessageProvider, cleanUserText, withRawSessionMessageCache, readRawSessionMessages, primeTailRawMessageCache, primeInMemoryTailRawMessageCache, readRawSessionMessageOrdinalPage, getRawSessionStoredMessageCount, readRawSessionMessagePartsById, readRawSessionMessageOrdinalById, readRawSessionMessageById, readSessionChunk, readRawSessionSeedTail, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, HAS_COMPARTMENT_CONTENT_SQL, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, clearRecompStaging, getMessageIndexSourceIdentity, isMessageIndexSourceCurrent, getLastIndexedOrdinal, getIndexedMessageCorpusSize, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, deleteIndexedMessage, clearIndexedMessages, indexSingleMessage, indexMessagesAfterOrdinal, sweepOrphanedOpenCodeMessageIndexes, recordEmbeddingMeasurement, getMaxM0MutationId, queueMemoryMutation, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationIdForProjects, MAX_EXECUTE_THRESHOLD, escalationBands, MERGED_REASONING_PARTS_PREFIX, readFrozenMergedReasoningParts, getProtectionWindowForSession, isEmergencyRecoveryArmed, isProviderOverflowReconfirmed, isProviderOverflowFailClosedProven, getEmergencyRecoveryArmedAt, loadPersistedUsage, loadProtectedTailMeta, resetProtectedTailNoEligibleHead, getWrapupInProgressState, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, getPersistedReasoningWatermark, setPersistedReasoningWatermark, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, getNoteNudgeAnchors, getAutoSearchHintDecisions, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, pruneAutoSearchHintDecisions, removeNoteNudgeAnchorByMessageId, removeAutoSearchHintDecisionByMessageId, getPersistedTodoPermissionDenied, setPersistedTodoPermissionDenied, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, setNoteLastReadAt, getHistorianFailureState, clearHistorianFailureState, getOverflowState, loadTransformPassStateSnapshot, recordOverflowDetected, recordDetectedContextLimit, clearEmergencyRecovery, clearDetectedContextLimit, getPersistedCompactionMarkerState, setPersistedCompactionMarkerState, getDeferredClearedCompactionMarkerState, retireDeferredClearedCompactionMarkerState, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, removeStrippedPlaceholderId, NEWEST_REASONING_BEARING_ASSISTANT, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, thinkingBindingRecoveryFrozenId, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getTrailingBlankDecisions, addTrailingBlankDecisions, demoteTrailingBlankKeepDecisions, getStaleReduceStrippedIds, addStaleReduceStrippedIds, getProcessedImageStrippedIds, addProcessedImageStrippedIds, getPendingCompactionMarkerState, loadPostprocessReplaySnapshot, setPendingCompactionMarkerState, clearPendingCompactionMarkerStateIf, getSessionsWithPendingMarker, setSessionWorkMetrics, getObservedEpochFloor, resolveEpochFloorForPass, getNotes, addNote, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, updateNote, dismissNotes, dismissNote, markNoteReady, markNoteChecked, queuePendingOp, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectMemoryEpoch, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, createChildSessionWithFence, detectThinkingBindingMismatch, isFable51ThinkingBindingModel, detectOverflow, modelBodyField, toModelEntry, getPromptFailureDetail, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, extractLatestAssistantText, hasLengthCappedOutput, setKeepSubagents, teardownChildSession, renderUserFacingFailure, userFacingFailureCode, renderCapabilityRefusal, capabilityRefusalCode, renderDreamFailure, dreamFailureCode, renderEmbeddingFailure, getCompartmentEvents, SYNAPSE_DEFAULT_MODEL, toSynapseLaneDescriptor, formatSynapseLaneDescriptor, SynapseEmbeddingProvider, loadCompartmentChunkEmbeddingsForSearch, cosineSimilarity, computeNormalizedHash, getLocalEmbeddingNativeMemoryStats, saveCommitEmbedding, loadProjectCommitEmbeddings, loadUnembeddedCommits, countEmbeddedCommits, upsertCommits, getLatestIndexedCommitTimeMs, enforceProjectCap, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease, saveEmbeddingIfHashMatches, getProjectEmbeddings, peekProjectEmbeddings, invalidateProject, invalidateMemory, describeShadowBackfillWriteRefusal, markProjectLoadUntrusted, contentSha256, sweepStaleEmbeddingIdentitiesForProject, registerProjectEmbedding, registerProjectShadowEmbedding, getShadowEmbeddingMeasurementCohort, getPrimaryEmbeddingMeasurementCohort, embedShadowTextForProject, enqueueShadowEmbeddingItems, registerProjectInObservationMode, getProjectEmbeddingSnapshot, embedTextForProject, embedBatchForProject, embedItemsForProject, embedUnembeddedMemoriesForProject, drainCommitBacklogForProject, embedSessionCompartmentChunks, getEmbeddingCoverageStatus, isEmbeddingEnabled, embedText, ensureMemoryEmbeddings, computeCueContentHash, hasMuralCueColumns, getMuralCueState, memoryNeedsCue, setMuralCue, recordMuralCueRejection, hasMemoryShareableColumn, hasMemoryClassifiedAtColumn, getUnclassifiedMemoryIds, ModuleMemoryAuthorityError, insertMemory, insertMemoryIdempotent, getMemoryByHash, getMemoriesByProject, buildWorkspaceMemorySqlFilter, getMemoriesByProjects, getMaxMemoryIdForProjects, readNewMemoriesForM1Union, getMemoryById, getMemoriesByIds, updateMemorySeenCount, updateMemoryRetrievalCount, setMemoryClassification, supersededMemory, mergeMemoryStats, archiveMemory, getMemoryCountsByStatus, sanitizeFtsQuery, searchMemoriesFTS, searchMemoriesFTSUnion, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, recordChildInvocation, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getMural, BoundedSessionMap, registerLkgPersistence, beginLkgPass, visitMessageContentFields, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgContentDigest, captureSlot, getInMemorySlot, getSlot, dropSlot, noteEntry, getLkgSlotHeapStats, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, getOpenCodeDbPath, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, modelKeyAcceptsImages, resolveMuralWire, extractM0Block, formatDate, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, setRecompStarting2, setRecompTerminal2, runManagedRecomp2, runManagedUpgrade2 };
|