@cortexkit/magic-context 0.48.0 → 0.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +443 -99
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2212,8 +2212,12 @@ function flush() {
|
|
|
2212
2212
|
let currentSize = getCurrentLogSize(logFile);
|
|
2213
2213
|
const dataSize = Buffer.byteLength(data);
|
|
2214
2214
|
if (currentSize > 0 && currentSize + dataSize > MAX_LOG_FILE_BYTES) {
|
|
2215
|
-
|
|
2216
|
-
currentSize =
|
|
2215
|
+
flushesSinceSizeCheck = SIZE_CHECK_INTERVAL_FLUSHES;
|
|
2216
|
+
currentSize = getCurrentLogSize(logFile);
|
|
2217
|
+
if (currentSize > 0 && currentSize + dataSize > MAX_LOG_FILE_BYTES) {
|
|
2218
|
+
rotateLogFile(logFile, currentSize);
|
|
2219
|
+
currentSize = 0;
|
|
2220
|
+
}
|
|
2217
2221
|
}
|
|
2218
2222
|
fs.appendFileSync(logFile, data, { encoding: "utf8", mode: 384 });
|
|
2219
2223
|
buffer = [];
|
|
@@ -2323,6 +2327,7 @@ import {
|
|
|
2323
2327
|
chmodSync as chmodSync2,
|
|
2324
2328
|
closeSync as closeSync2,
|
|
2325
2329
|
createWriteStream,
|
|
2330
|
+
fsyncSync,
|
|
2326
2331
|
lstatSync,
|
|
2327
2332
|
mkdirSync as mkdirSync2,
|
|
2328
2333
|
openSync as openSync2,
|
|
@@ -2460,44 +2465,9 @@ var enforcePrivateStoragePermissions = true;
|
|
|
2460
2465
|
var init_storage_permissions = () => {};
|
|
2461
2466
|
|
|
2462
2467
|
// ../plugin/src/shared/window-geometry.ts
|
|
2463
|
-
|
|
2464
|
-
if (configuredOverlayPath === path)
|
|
2465
|
-
return;
|
|
2466
|
-
reloadWindowOverlay(path);
|
|
2467
|
-
}
|
|
2468
|
-
function reloadWindowOverlay(path) {
|
|
2469
|
-
configuredOverlayPath = path;
|
|
2470
|
-
loadedOverlayPath = undefined;
|
|
2471
|
-
loadedOverlay = undefined;
|
|
2472
|
-
}
|
|
2473
|
-
var GRADES, UNITS, BOUNDARIES, UNKNOWN_REASONS, NUMERIC_FACT_KEYS, configuredOverlayPath, loadedOverlayPath, loadedOverlay, geometryClampLogSeen;
|
|
2468
|
+
var geometryClampLogSeen;
|
|
2474
2469
|
var init_window_geometry = __esm(() => {
|
|
2475
|
-
init_data_path();
|
|
2476
|
-
init_harness_provider_map();
|
|
2477
2470
|
init_logger();
|
|
2478
|
-
GRADES = new Set([
|
|
2479
|
-
"provider_asserted_runtime",
|
|
2480
|
-
"measured",
|
|
2481
|
-
"provider_asserted_doc",
|
|
2482
|
-
"catalog",
|
|
2483
|
-
"unknown"
|
|
2484
|
-
]);
|
|
2485
|
-
UNITS = new Set(["provider", "estimate"]);
|
|
2486
|
-
BOUNDARIES = new Set(["Observed", "Asserted", "Corrected"]);
|
|
2487
|
-
UNKNOWN_REASONS = new Set([
|
|
2488
|
-
"placeholder_output_equals_context",
|
|
2489
|
-
"placeholder_zero",
|
|
2490
|
-
"never_measured",
|
|
2491
|
-
"not_single_valued_at_key",
|
|
2492
|
-
"retracted"
|
|
2493
|
-
]);
|
|
2494
|
-
NUMERIC_FACT_KEYS = new Set([
|
|
2495
|
-
"window.advertised",
|
|
2496
|
-
"window.enforced",
|
|
2497
|
-
"output.advertised",
|
|
2498
|
-
"output.enforced",
|
|
2499
|
-
"output.default"
|
|
2500
|
-
]);
|
|
2501
2471
|
geometryClampLogSeen = new Set;
|
|
2502
2472
|
});
|
|
2503
2473
|
|
|
@@ -2561,6 +2531,21 @@ function migrateLegacyAgentEnabledInMemory(rawConfig, warnings) {
|
|
|
2561
2531
|
}
|
|
2562
2532
|
var init_agent_disable = () => {};
|
|
2563
2533
|
|
|
2534
|
+
// ../plugin/src/config/deprecated-config.ts
|
|
2535
|
+
function warnDeprecatedMuralModel(config, warnings) {
|
|
2536
|
+
const mural = config.mural;
|
|
2537
|
+
if (typeof mural === "object" && mural !== null && Object.hasOwn(mural, "model")) {
|
|
2538
|
+
warnings.push(MURAL_MODEL_DEPRECATION_WARNING);
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
function warnDeprecatedWindowOverlayPath(config, warnings) {
|
|
2542
|
+
const models = config.models;
|
|
2543
|
+
if (typeof models === "object" && models !== null && Object.hasOwn(models, "window_overlay_path") && !warnings.includes(WINDOW_OVERLAY_PATH_DEPRECATION_WARNING)) {
|
|
2544
|
+
warnings.push(WINDOW_OVERLAY_PATH_DEPRECATION_WARNING);
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
var MURAL_MODEL_DEPRECATION_WARNING = "mural.model is deprecated and ignored; compress-cues now uses the dreamer model for each harness, like every other dreamer task. To override it, set dreamer.opencode.tasks.compress-cues.model (or the pi/omp equivalent). This key no longer does anything; remove it.", WINDOW_OVERLAY_PATH_DEPRECATION_WARNING = "models.window_overlay_path is deprecated and ignored; Fusiform no longer publishes window-overlay data, so this setting no longer changes model window geometry. Remove this key.";
|
|
2548
|
+
|
|
2564
2549
|
// ../plugin/src/shared/jsonc-edit.ts
|
|
2565
2550
|
function parseDocument(text) {
|
|
2566
2551
|
const errors = [];
|
|
@@ -3476,15 +3461,6 @@ function migrateLegacyExperimental(rawConfig, warnings) {
|
|
|
3476
3461
|
return patched;
|
|
3477
3462
|
}
|
|
3478
3463
|
|
|
3479
|
-
// ../plugin/src/config/mural-model-deprecation.ts
|
|
3480
|
-
function warnDeprecatedMuralModel(config, warnings) {
|
|
3481
|
-
const mural = config.mural;
|
|
3482
|
-
if (typeof mural === "object" && mural !== null && Object.hasOwn(mural, "model")) {
|
|
3483
|
-
warnings.push(MURAL_MODEL_DEPRECATION_WARNING);
|
|
3484
|
-
}
|
|
3485
|
-
}
|
|
3486
|
-
var MURAL_MODEL_DEPRECATION_WARNING = "mural.model is deprecated and ignored; compress-cues now uses the dreamer model for each harness, like every other dreamer task. To override it, set dreamer.opencode.tasks.compress-cues.model (or the pi/omp equivalent). This key no longer does anything; remove it.";
|
|
3487
|
-
|
|
3488
3464
|
// ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/core.js
|
|
3489
3465
|
function $constructor(name, initializer, params) {
|
|
3490
3466
|
function init(inst, def) {
|
|
@@ -9235,7 +9211,7 @@ var init_magic_context = __esm(() => {
|
|
|
9235
9211
|
document_prefix: string2().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."),
|
|
9236
9212
|
truncate: string2().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."),
|
|
9237
9213
|
max_input_tokens: number2().int().positive().optional().describe("Optional maximum input tokens for chunk embeddings. Defaults conservatively to 512 when omitted."),
|
|
9238
|
-
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+. Inference runs in a dedicated worker. On Bun before 1.4.0, even explicit 'native' uses WASM because native worker teardown can crash the process. Set 'wasm' to avoid loading the native addon on newer hosts too."),
|
|
9214
|
+
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+. Inference runs in a dedicated worker after disabling POSIX telemetry in the native process environment. Compiled Bun hosts and hosts without a verified in-process opt-out use a subprocess instead. Windows native ONNX emits OS-controlled ETW diagnostics, not direct uploads. On Bun before 1.4.0, even explicit 'native' uses WASM because native worker teardown can crash the process. Set 'wasm' to avoid loading the native addon on newer hosts too."),
|
|
9239
9215
|
local_dtype: _enum([
|
|
9240
9216
|
"auto",
|
|
9241
9217
|
"fp32",
|
|
@@ -9344,8 +9320,8 @@ var init_magic_context = __esm(() => {
|
|
|
9344
9320
|
object({ default: number2().min(0) }).catchall(number2().min(0))
|
|
9345
9321
|
]).optional().describe('User-only output-token reservation override. Number or per-model object ({ default: 16384, "provider/model": 8192 }); 0 disables reservation. Takes precedence over every derived source: an explicit value here always wins against catalog output limits, provider window-geometry facts, and the 25%-of-context fallback (usable window = context window minus this reserve). When unset, Magic Context reserves the catalog output limit (capped at 25% of context) for shared-window providers and keeps proven separate-quota Google/Gemini windows unchanged.'),
|
|
9346
9322
|
models: object({
|
|
9347
|
-
window_overlay_path:
|
|
9348
|
-
}).optional().describe("
|
|
9323
|
+
window_overlay_path: unknown().optional().describe("Deprecated: ignored. Fusiform no longer publishes window-overlay data, so this setting no longer changes model window geometry. Remove this key.").meta({ deprecated: true })
|
|
9324
|
+
}).optional().describe("Deprecated user-only Fusiform window-overlay settings; ignored."),
|
|
9349
9325
|
toast_duration_ms: number2().min(0).max(60000).default(5000).describe("TUI toast lifetime in milliseconds for Magic Context notifications. Set to 0 to disable Magic Context toasts entirely (min: 0, max: 60000, default: 5000)"),
|
|
9350
9326
|
execute_threshold_percentage: union([
|
|
9351
9327
|
number2().min(20).max(90, EXECUTE_THRESHOLD_CAP_MESSAGE),
|
|
@@ -9746,7 +9722,7 @@ function stripUnsafeProjectConfigFields(projectRaw) {
|
|
|
9746
9722
|
const models = projectRaw.models;
|
|
9747
9723
|
if (isPlainObject2(models) && "window_overlay_path" in models) {
|
|
9748
9724
|
delete models.window_overlay_path;
|
|
9749
|
-
warnings.push("Ignoring models.window_overlay_path from project config (
|
|
9725
|
+
warnings.push("Ignoring models.window_overlay_path from project config (deprecated; this setting no longer changes model window geometry).");
|
|
9750
9726
|
}
|
|
9751
9727
|
if ("language" in projectRaw) {
|
|
9752
9728
|
delete projectRaw.language;
|
|
@@ -10913,6 +10889,7 @@ function parsePluginConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
|
10913
10889
|
preMigrationWarnings.push(...misplacedAgentModelWarnings(rawConfig));
|
|
10914
10890
|
const migratedExperimental = migrateLegacyExperimental(configWithoutRemovedAgent, preMigrationWarnings);
|
|
10915
10891
|
warnDeprecatedMuralModel(migratedExperimental, preMigrationWarnings);
|
|
10892
|
+
warnDeprecatedWindowOverlayPath(migratedExperimental, preMigrationWarnings);
|
|
10916
10893
|
const migratedDreamer = migrateDreamerV2(migratedExperimental, preMigrationWarnings);
|
|
10917
10894
|
const migrated = migrateLegacyAgentEnabledInMemory(migratedDreamer, preMigrationWarnings);
|
|
10918
10895
|
const parsed = MagicContextConfigSchema.safeParse(migrated);
|
|
@@ -11164,7 +11141,6 @@ function loadPluginConfigDetailed(directory, applyRuntimeGlobals = true) {
|
|
|
11164
11141
|
config.profile = profileResolution.activeProfile;
|
|
11165
11142
|
if (applyRuntimeGlobals) {
|
|
11166
11143
|
setOutputReserveConfig(config.output_reserve);
|
|
11167
|
-
setWindowOverlayPath(config.models?.window_overlay_path);
|
|
11168
11144
|
}
|
|
11169
11145
|
const leafValidationWarnings = [...config.configWarnings ?? []];
|
|
11170
11146
|
if (config.configWarnings?.length) {
|
|
@@ -11230,7 +11206,6 @@ var init_config = __esm(() => {
|
|
|
11230
11206
|
init_jsonc_parser();
|
|
11231
11207
|
init_logger();
|
|
11232
11208
|
init_models_dev_cache();
|
|
11233
|
-
init_window_geometry();
|
|
11234
11209
|
init_agent_disable();
|
|
11235
11210
|
init_migrate_config_location();
|
|
11236
11211
|
init_migrate_dreamer_v2();
|
|
@@ -28995,11 +28970,75 @@ var init_migrations = __esm(async () => {
|
|
|
28995
28970
|
|
|
28996
28971
|
// ../plugin/src/features/magic-context/storage-tag-identity-revision.ts
|
|
28997
28972
|
function installTagIdentityRevisionTrigger(db) {
|
|
28973
|
+
db.exec(`DROP TRIGGER IF EXISTS temp.mc_tag_identity_revision_au;
|
|
28974
|
+
DROP TRIGGER IF EXISTS temp.mc_tag_revision_bi;
|
|
28975
|
+
DROP TRIGGER IF EXISTS temp.mc_tag_revision_ai;
|
|
28976
|
+
DROP TRIGGER IF EXISTS temp.mc_tag_revision_au;
|
|
28977
|
+
DROP TRIGGER IF EXISTS temp.mc_tag_revision_ad;
|
|
28978
|
+
DROP TRIGGER IF EXISTS temp.mc_tag_revision_seed_ai;`);
|
|
28979
|
+
db.exec(`CREATE TEMP TRIGGER mc_tag_revision_seed_ai AFTER INSERT ON main.schema_migrations_meta
|
|
28980
|
+
WHEN INSTR(NEW.value, ':') = 0 AND (
|
|
28981
|
+
SUBSTR(NEW.key, 1, ${TAG_REVISION_PREFIX.length}) = '${TAG_REVISION_PREFIX}'
|
|
28982
|
+
OR SUBSTR(NEW.key, 1, ${TAG_IDENTITY_REVISION_PREFIX.length}) = '${TAG_IDENTITY_REVISION_PREFIX}')
|
|
28983
|
+
BEGIN
|
|
28984
|
+
INSERT INTO schema_migrations_meta (key, value) VALUES ('${TAG_REVISION_INCARNATION_KEY}', '1')
|
|
28985
|
+
ON CONFLICT(key) DO UPDATE SET value = CAST(CASE
|
|
28986
|
+
WHEN CAST(value AS INTEGER) < 9223372036854775807 THEN CAST(value AS INTEGER) + 1
|
|
28987
|
+
ELSE NULL END AS TEXT);
|
|
28988
|
+
UPDATE schema_migrations_meta SET value =
|
|
28989
|
+
(SELECT value FROM schema_migrations_meta WHERE key = '${TAG_REVISION_INCARNATION_KEY}')
|
|
28990
|
+
|| ':' || CAST(NEW.value AS TEXT) WHERE key = NEW.key;
|
|
28991
|
+
INSERT INTO schema_migrations_meta (key, value)
|
|
28992
|
+
SELECT '${TAG_REVISION_INCARNATION_KEY}', '1'
|
|
28993
|
+
WHERE SUBSTR(NEW.key, 1, ${TAG_REVISION_PREFIX.length}) = '${TAG_REVISION_PREFIX}'
|
|
28994
|
+
AND NOT EXISTS (SELECT 1 FROM schema_migrations_meta
|
|
28995
|
+
WHERE key = '${TAG_IDENTITY_REVISION_PREFIX}' || SUBSTR(NEW.key, ${TAG_REVISION_PREFIX.length + 1}))
|
|
28996
|
+
ON CONFLICT(key) DO UPDATE SET value = CAST(CASE
|
|
28997
|
+
WHEN CAST(value AS INTEGER) < 9223372036854775807 THEN CAST(value AS INTEGER) + 1
|
|
28998
|
+
ELSE NULL END AS TEXT);
|
|
28999
|
+
INSERT INTO schema_migrations_meta (key, value)
|
|
29000
|
+
SELECT '${TAG_IDENTITY_REVISION_PREFIX}' || SUBSTR(NEW.key, ${TAG_REVISION_PREFIX.length + 1}),
|
|
29001
|
+
(SELECT value FROM schema_migrations_meta WHERE key = '${TAG_REVISION_INCARNATION_KEY}') || ':0'
|
|
29002
|
+
WHERE SUBSTR(NEW.key, 1, ${TAG_REVISION_PREFIX.length}) = '${TAG_REVISION_PREFIX}'
|
|
29003
|
+
AND NOT EXISTS (SELECT 1 FROM schema_migrations_meta
|
|
29004
|
+
WHERE key = '${TAG_IDENTITY_REVISION_PREFIX}' || SUBSTR(NEW.key, ${TAG_REVISION_PREFIX.length + 1}));
|
|
29005
|
+
END;`);
|
|
28998
29006
|
db.exec(TRIGGER_SQL);
|
|
28999
|
-
|
|
29000
|
-
|
|
29001
|
-
|
|
29002
|
-
|
|
29007
|
+
db.exec(`CREATE TEMP TRIGGER IF NOT EXISTS mc_tag_revision_bi BEFORE INSERT ON main.tags BEGIN
|
|
29008
|
+
${BUMP_INSERT_CONFLICTS(TAG_REVISION_PREFIX)};
|
|
29009
|
+
${BUMP_INSERT_CONFLICTS(TAG_IDENTITY_REVISION_PREFIX)};
|
|
29010
|
+
UPDATE session_meta SET tags_version = tags_version + 1
|
|
29011
|
+
WHERE session_id IN (SELECT session_id FROM (${TAG_INSERT_CONFLICT_ROWS}));
|
|
29012
|
+
END;`);
|
|
29013
|
+
db.exec(`CREATE TEMP TRIGGER IF NOT EXISTS mc_tag_revision_ai AFTER INSERT ON main.tags BEGIN
|
|
29014
|
+
${BUMP("NEW.session_id", TAG_REVISION_PREFIX)};
|
|
29015
|
+
END;
|
|
29016
|
+
CREATE TEMP TRIGGER IF NOT EXISTS mc_tag_revision_au AFTER UPDATE ON main.tags BEGIN
|
|
29017
|
+
${BUMP("OLD.session_id", TAG_REVISION_PREFIX)};
|
|
29018
|
+
INSERT INTO schema_migrations_meta (key, value)
|
|
29019
|
+
SELECT '${TAG_REVISION_PREFIX}' || NEW.session_id, '1'
|
|
29020
|
+
WHERE NEW.session_id IS NOT OLD.session_id
|
|
29021
|
+
ON CONFLICT(key) DO UPDATE SET value = ${ADVANCE()};
|
|
29022
|
+
END;
|
|
29023
|
+
CREATE TEMP TRIGGER IF NOT EXISTS mc_tag_revision_ad AFTER DELETE ON main.tags BEGIN
|
|
29024
|
+
${BUMP("OLD.session_id", TAG_REVISION_PREFIX)};
|
|
29025
|
+
END;`);
|
|
29026
|
+
}
|
|
29027
|
+
var TAG_IDENTITY_REVISION_PREFIX = "tag_identity_revision:", TAG_REVISION_PREFIX = "tag_revision:", TAG_REVISION_INCARNATION_KEY = "tag_revision_incarnation", tagRevisionIncarnationSql = (value) => `CASE WHEN INSTR(${value}, ':') > 0 THEN SUBSTR(${value}, 1, INSTR(${value}, ':') - 1) ELSE '0' END`, tagRevisionCountSql = (value) => `CAST(CASE WHEN INSTR(${value}, ':') > 0 THEN SUBSTR(${value}, INSTR(${value}, ':') + 1) ELSE ${value} END AS INTEGER)`, ADVANCE = (delta = "1") => `CASE
|
|
29028
|
+
WHEN ${tagRevisionCountSql("value")} <= 9223372036854775807 - ${delta}
|
|
29029
|
+
THEN (${tagRevisionIncarnationSql("value")}) || ':' || CAST(${tagRevisionCountSql("value")} + ${delta} AS TEXT)
|
|
29030
|
+
ELSE NULL END`, BUMP = (session, prefix = TAG_IDENTITY_REVISION_PREFIX) => `INSERT INTO schema_migrations_meta (key, value)
|
|
29031
|
+
VALUES ('${prefix}' || ${session}, '1')
|
|
29032
|
+
ON CONFLICT(key) DO UPDATE SET value = ${ADVANCE()}`, TAG_INSERT_CONFLICT_ROWS = `SELECT id, session_id, tag_number FROM tags WHERE id = NEW.id
|
|
29033
|
+
UNION SELECT id, session_id, tag_number FROM tags WHERE session_id = NEW.session_id AND tag_number = NEW.tag_number
|
|
29034
|
+
UNION SELECT id, session_id, tag_number FROM tags
|
|
29035
|
+
WHERE NEW.type = 'tool' AND NEW.tool_owner_message_id IS NOT NULL
|
|
29036
|
+
AND type = 'tool' AND tool_owner_message_id IS NOT NULL
|
|
29037
|
+
AND session_id = NEW.session_id AND message_id = NEW.message_id
|
|
29038
|
+
AND tool_owner_message_id = NEW.tool_owner_message_id`, BUMP_INSERT_CONFLICTS = (prefix) => `INSERT INTO schema_migrations_meta (key, value)
|
|
29039
|
+
SELECT '${prefix}' || session_id, CAST(COUNT(*) AS TEXT)
|
|
29040
|
+
FROM (${TAG_INSERT_CONFLICT_ROWS}) GROUP BY session_id
|
|
29041
|
+
ON CONFLICT(key) DO UPDATE SET value = ${ADVANCE("CAST(excluded.value AS INTEGER)")}`, TRIGGER_SQL;
|
|
29003
29042
|
var init_storage_tag_identity_revision = __esm(() => {
|
|
29004
29043
|
TRIGGER_SQL = `CREATE TEMP TRIGGER IF NOT EXISTS mc_tag_identity_revision_au
|
|
29005
29044
|
AFTER UPDATE OF id, session_id, message_id, tag_number, type, tool_owner_message_id, reasoning_token_count
|
|
@@ -29009,7 +29048,7 @@ var init_storage_tag_identity_revision = __esm(() => {
|
|
|
29009
29048
|
INSERT INTO schema_migrations_meta (key, value)
|
|
29010
29049
|
SELECT '${TAG_IDENTITY_REVISION_PREFIX}' || NEW.session_id, '1'
|
|
29011
29050
|
WHERE NEW.session_id IS NOT OLD.session_id
|
|
29012
|
-
ON CONFLICT(key) DO UPDATE SET value =
|
|
29051
|
+
ON CONFLICT(key) DO UPDATE SET value = ${ADVANCE()};
|
|
29013
29052
|
END`;
|
|
29014
29053
|
});
|
|
29015
29054
|
|
|
@@ -30381,7 +30420,7 @@ function pickNearestPriorOwner(candidates, currentMessageId, times) {
|
|
|
30381
30420
|
}
|
|
30382
30421
|
return best?.id ?? null;
|
|
30383
30422
|
}
|
|
30384
|
-
var insertTagStatements, updateTagStatusStatements, updateTagDropModeStatements, updateTagMessageIdStatements, getTagNumbersByMessageIdStatements, deleteTagsByMessageIdStatements, getMaxTagNumberBySessionStatements, getTagNumberByMessageIdStatements, getAssignableTagNumberByMessageIdStatements, hasPiFallbackMessageTagStatements, updateTagByteSizeStatements, updateTagInputByteSizeStatements, recentTagOwnerStatements, RECLAIM_HINT_EXCLUDED_TOOLS, getActiveToolTagsForAgeReclaimStatements, scopedActiveTokenTotalStatements, updateTagTokenCountStatements, updateTagInputTokenCountStatements, tagOwnerSummaries, TAG_OWNER_COLUMNS = "id, type, message_id, tool_owner_message_id, tag_number, reasoning_token_count", TAG_OWNER_APPENDED_WITH_SHAPE_SQL, inertWhitespaceStatements, foldStatements, getOwnerScopedToolTagNumbersStatements, getMinMessageTagNumberForRawIdStatements, getActiveTagsBySessionStatements, getNullOwnerToolTagsBySessionStatements, getDroppedTagsBySessionStatements, getMaxDroppedTagNumberStatements, newestToolTagNumberStatements, droppedNumberStatements, tagByIdStatements, getToolTagNumberByOwnerStatements, getNullOwnerToolTagStatements, adoptNullOwnerToolTagStatements, getToolOwnerByTagIdStatements, deleteToolTagsByOwnerStatements;
|
|
30423
|
+
var insertTagStatements, updateTagStatusStatements, updateTagDropModeStatements, updateTagMessageIdStatements, getTagNumbersByMessageIdStatements, deleteTagsByMessageIdStatements, getMaxTagNumberBySessionStatements, getTagNumberByMessageIdStatements, getAssignableTagNumberByMessageIdStatements, hasPiFallbackMessageTagStatements, updateTagByteSizeStatements, updateTagInputByteSizeStatements, recentTagOwnerStatements, RECLAIM_HINT_EXCLUDED_TOOLS, getActiveToolTagsForAgeReclaimStatements, scopedActiveTokenTotalStatements, updateTagTokenCountStatements, updateTagInputTokenCountStatements, tagOwnerSummaries, TAG_OWNER_COLUMNS = "id, type, message_id, tool_owner_message_id, tag_number, reasoning_token_count", TAG_OWNER_APPENDED_WITH_SHAPE_SQL, inertWhitespaceStatements, inertWhitespaceByNumberStatements, foldStatements, getOwnerScopedToolTagNumbersStatements, getMinMessageTagNumberForRawIdStatements, getActiveTagsBySessionStatements, getNullOwnerToolTagsBySessionStatements, getDroppedTagsBySessionStatements, getMaxDroppedTagNumberStatements, newestToolTagNumberStatements, droppedNumberStatements, tagByIdStatements, getToolTagNumberByOwnerStatements, getNullOwnerToolTagStatements, adoptNullOwnerToolTagStatements, getToolOwnerByTagIdStatements, deleteToolTagsByOwnerStatements;
|
|
30385
30424
|
var init_storage_tags = __esm(async () => {
|
|
30386
30425
|
init_emergency_drop();
|
|
30387
30426
|
init_tag_owner_id();
|
|
@@ -30423,6 +30462,7 @@ var init_storage_tags = __esm(async () => {
|
|
|
30423
30462
|
SELECT NULL, NULL, NULL, NULL, NULL, NULL, 1, COUNT(*), MAX(id), (SELECT value FROM schema_migrations_meta WHERE key = ?)
|
|
30424
30463
|
FROM tags WHERE session_id = ?`;
|
|
30425
30464
|
inertWhitespaceStatements = new WeakMap;
|
|
30465
|
+
inertWhitespaceByNumberStatements = new WeakMap;
|
|
30426
30466
|
foldStatements = new WeakMap;
|
|
30427
30467
|
getOwnerScopedToolTagNumbersStatements = new WeakMap;
|
|
30428
30468
|
getMinMessageTagNumberForRawIdStatements = new WeakMap;
|
|
@@ -30665,29 +30705,44 @@ function readRawMessagePageRows(db, sessionId, afterOrdinal, limit, finalWaterma
|
|
|
30665
30705
|
const pageSize = Math.min(Math.max(1, Math.floor(limit)), remaining);
|
|
30666
30706
|
if (pageSize === 0)
|
|
30667
30707
|
return [];
|
|
30668
|
-
|
|
30669
|
-
|
|
30670
|
-
|
|
30671
|
-
|
|
30672
|
-
|
|
30673
|
-
|
|
30674
|
-
|
|
30675
|
-
|
|
30676
|
-
|
|
30677
|
-
|
|
30678
|
-
|
|
30679
|
-
|
|
30680
|
-
|
|
30681
|
-
|
|
30682
|
-
|
|
30683
|
-
|
|
30684
|
-
|
|
30685
|
-
|
|
30686
|
-
|
|
30687
|
-
|
|
30688
|
-
|
|
30689
|
-
|
|
30690
|
-
|
|
30708
|
+
return withReadSnapshot(db, () => {
|
|
30709
|
+
const ordinal = Math.max(0, Math.floor(afterOrdinal));
|
|
30710
|
+
const points = currentOrdinalCheckpoints(db, sessionId)?.scan.checkpoints ?? [];
|
|
30711
|
+
let low = 0;
|
|
30712
|
+
let high = points.length;
|
|
30713
|
+
while (low < high) {
|
|
30714
|
+
const middle = Math.floor((low + high) / 2);
|
|
30715
|
+
if (points[middle].ordinal <= ordinal)
|
|
30716
|
+
low = middle + 1;
|
|
30717
|
+
else
|
|
30718
|
+
high = middle;
|
|
30719
|
+
}
|
|
30720
|
+
const floor = points[low - 1];
|
|
30721
|
+
const useFloor = floor && (!after || compareOrdinalKeys(floor, after) > 0);
|
|
30722
|
+
const anchor = useFloor ? floor : after;
|
|
30723
|
+
const skip = anchor === after && after ? 0 : ordinal - (floor?.ordinal ?? 0);
|
|
30724
|
+
if (skip > ORDINAL_LOOKUP_LIMIT) {
|
|
30725
|
+
prewarmRawSessionOrdinalsForDb(db, sessionId);
|
|
30726
|
+
throw new RawOrdinalsNotReady;
|
|
30727
|
+
}
|
|
30728
|
+
const rawLimit = skip + pageSize + ORDINAL_LOOKUP_LIMIT;
|
|
30729
|
+
const rows = db.prepare(`SELECT id, data, time_created, time_updated, ${EXCLUDED_ROW_SQL} AS excluded
|
|
30730
|
+
FROM message WHERE id IN (
|
|
30731
|
+
SELECT id FROM message WHERE session_id = ?
|
|
30732
|
+
${anchor ? "AND (time_created, id) > (?, ?)" : ""}
|
|
30733
|
+
ORDER BY time_created, id LIMIT ?)
|
|
30734
|
+
ORDER BY time_created, id`).all(sessionId, ...anchor ? [anchor.timeCreated, anchor.id] : [], rawLimit);
|
|
30735
|
+
rawMessagePageRowsVisited += rows.length;
|
|
30736
|
+
const eligible = rows.filter((row) => row.excluded !== 1);
|
|
30737
|
+
if (eligible.length <= skip && rows.length === rawLimit) {
|
|
30738
|
+
prewarmRawSessionOrdinalsForDb(db, sessionId);
|
|
30739
|
+
throw new RawOrdinalsNotReady;
|
|
30740
|
+
}
|
|
30741
|
+
return eligible.slice(skip, skip + pageSize).filter(isRawMessageRow).map((row, index) => ({
|
|
30742
|
+
...row,
|
|
30743
|
+
ordinal: ordinal + index + 1
|
|
30744
|
+
}));
|
|
30745
|
+
});
|
|
30691
30746
|
}
|
|
30692
30747
|
function assembleRawMessagePage(messageRows, partRows) {
|
|
30693
30748
|
const partsByMessageId = new Map;
|
|
@@ -31349,11 +31404,124 @@ function readRawSeedTailFromDb(db, sessionId, boundaryId) {
|
|
|
31349
31404
|
throw new Error("state_sync materialized boundary is missing from raw storage");
|
|
31350
31405
|
return messages;
|
|
31351
31406
|
}
|
|
31352
|
-
|
|
31407
|
+
function readBoundaryEndpointRows(db, sessionId, ids, blockIds, into) {
|
|
31408
|
+
if (ids.length > 0) {
|
|
31409
|
+
boundaryEndpointRowsRead += ids.length;
|
|
31410
|
+
const wanted = JSON.stringify(ids);
|
|
31411
|
+
const ordinals = new Map;
|
|
31412
|
+
for (const row of db.prepare(BOUNDARY_ORDINAL_SQL).all(sessionId, wanted)) {
|
|
31413
|
+
ordinals.set(row.id, row.ordinal);
|
|
31414
|
+
}
|
|
31415
|
+
const rows = db.prepare(BOUNDARY_MESSAGE_SQL).all(sessionId, wanted);
|
|
31416
|
+
for (const id of ids)
|
|
31417
|
+
into.set(id, null);
|
|
31418
|
+
for (const row of rows) {
|
|
31419
|
+
if (!isRawMessageRow(row) || typeof row.time_created !== "number")
|
|
31420
|
+
continue;
|
|
31421
|
+
const info = parseJsonRecord(row.data);
|
|
31422
|
+
if (!info || isRawCompactionSummaryInfo(info))
|
|
31423
|
+
continue;
|
|
31424
|
+
into.set(row.id, {
|
|
31425
|
+
ordinal: ordinals.get(row.id) ?? null,
|
|
31426
|
+
createdAt: row.time_created
|
|
31427
|
+
});
|
|
31428
|
+
}
|
|
31429
|
+
}
|
|
31430
|
+
const servable = blockIds.filter((id) => {
|
|
31431
|
+
const endpoint = into.get(id);
|
|
31432
|
+
return endpoint && endpoint.lastBlockIndex === undefined;
|
|
31433
|
+
});
|
|
31434
|
+
if (servable.length === 0)
|
|
31435
|
+
return;
|
|
31436
|
+
const counts = new Map;
|
|
31437
|
+
for (const row of db.prepare(BOUNDARY_BLOCK_COUNT_SQL).all(sessionId, JSON.stringify(servable))) {
|
|
31438
|
+
counts.set(row.id, row.blocks);
|
|
31439
|
+
}
|
|
31440
|
+
for (const id of servable) {
|
|
31441
|
+
const endpoint = into.get(id);
|
|
31442
|
+
if (!endpoint)
|
|
31443
|
+
continue;
|
|
31444
|
+
const blocks = counts.get(id) ?? 0;
|
|
31445
|
+
into.set(id, { ...endpoint, lastBlockIndex: blocks > 0 ? blocks - 1 : 0 });
|
|
31446
|
+
}
|
|
31447
|
+
}
|
|
31448
|
+
function readRawSessionBoundaryEndpointsFromDb(db, sessionId, ids, blockIds = []) {
|
|
31449
|
+
const wanted = [...new Set(ids)];
|
|
31450
|
+
const wantedBlocks = [...new Set(blockIds)];
|
|
31451
|
+
let sessions = boundaryEndpointCaches.get(db);
|
|
31452
|
+
if (!sessions) {
|
|
31453
|
+
sessions = new Map;
|
|
31454
|
+
boundaryEndpointCaches.set(db, sessions);
|
|
31455
|
+
}
|
|
31456
|
+
for (let attempt = 1;; attempt += 1) {
|
|
31457
|
+
const before = readStoreStamp(db);
|
|
31458
|
+
const cached = sessions.get(sessionId);
|
|
31459
|
+
const reuse = attempt === 1 && cached && sameStoreStamp(cached.stamp, before);
|
|
31460
|
+
const endpoints = new Map(reuse ? cached.endpoints : []);
|
|
31461
|
+
const missing = wanted.filter((id) => !endpoints.has(id));
|
|
31462
|
+
withReadSnapshot(db, () => readBoundaryEndpointRows(db, sessionId, missing, wantedBlocks, endpoints));
|
|
31463
|
+
const unchanged = before !== null && sameStoreStamp(before, readStoreStamp(db));
|
|
31464
|
+
if (unchanged) {
|
|
31465
|
+
sessions.delete(sessionId);
|
|
31466
|
+
sessions.set(sessionId, { stamp: before, endpoints });
|
|
31467
|
+
while (sessions.size > BOUNDARY_ENDPOINT_CACHE_SESSIONS) {
|
|
31468
|
+
const oldest = sessions.keys().next().value;
|
|
31469
|
+
if (oldest === undefined)
|
|
31470
|
+
break;
|
|
31471
|
+
sessions.delete(oldest);
|
|
31472
|
+
}
|
|
31473
|
+
} else if (reuse) {
|
|
31474
|
+
continue;
|
|
31475
|
+
}
|
|
31476
|
+
return new Map(wanted.map((id) => [id, endpoints.get(id) ?? null]));
|
|
31477
|
+
}
|
|
31478
|
+
}
|
|
31479
|
+
var RAW_MESSAGE_PARTS_BY_ID_SQL = "SELECT message_id, data, time_updated FROM part WHERE +session_id = ? AND likelihood(message_id = ?, 0.000001) ORDER BY time_created ASC, id ASC", RAW_METADATA_KEEP_CHARS = 16384, RAW_METADATA_KEPT_KEYS, RAW_PART_DATA_SQL, rawMessagePageRowsVisited = 0, RAW_SUMMARY_TEXT_MAX_CHARS = 8192, RAW_SUMMARY_ARG_MAX_CHARS = 512, RAW_SUMMARY_TOOL_INPUT_KEYS, RAW_SUMMARY_PART_DATA_SQL, ORDINAL_SUMMARY_FLAG_SQL = `(CASE WHEN json_valid(data) = 1
|
|
31353
31480
|
THEN COALESCE(json_extract(data, '$.summary'), 0)
|
|
31354
31481
|
ELSE 0 END = 1)`, ORDINAL_STOP_FLAG_SQL = `(CASE WHEN json_valid(data) = 1
|
|
31355
31482
|
THEN COALESCE(json_extract(data, '$.finish'), '')
|
|
31356
|
-
ELSE '' END = 'stop')`, ORDINAL_RANGE_FROM_START_SQL, ORDINAL_RANGE_BETWEEN_SQL, ordinalWatermarks, ordinalWatermarkEpochs, ordinalRowsVisited = 0, STABLE_STORE_ATTEMPTS = 3, EXCLUDED_ROW_SQL, SUMMARY_ANCHOR_SPAN = 256, SUMMARY_ANCHOR_LIMIT = 64, summaryCandidateSets, summaryCandidateEpochs, writtenSummaryIds, indexedCountUnsupported, ordinalJsonRowsRead = 0, summaryFullScans = 0, ANCHOR_ROWS_SQL, SUMMARY_FULL_SCAN_SQL, SUMMARY_SCAN_AFTER_SQL, ANCHOR_CHECK_SQL = "SELECT rowid AS rid, id FROM message WHERE rowid IN (SELECT value FROM json_each(?))", ordinalCheckpoints, ordinalSummarySeeds, ORDINAL_LOOKUP_LIMIT = 512, RawOrdinalsNotReady, CANONICAL_COUNT_SQL
|
|
31483
|
+
ELSE '' END = 'stop')`, ORDINAL_RANGE_FROM_START_SQL, ORDINAL_RANGE_BETWEEN_SQL, ordinalWatermarks, ordinalWatermarkEpochs, ordinalRowsVisited = 0, STABLE_STORE_ATTEMPTS = 3, EXCLUDED_ROW_SQL, SUMMARY_ANCHOR_SPAN = 256, SUMMARY_ANCHOR_LIMIT = 64, summaryCandidateSets, summaryCandidateEpochs, writtenSummaryIds, indexedCountUnsupported, ordinalJsonRowsRead = 0, summaryFullScans = 0, ANCHOR_ROWS_SQL, SUMMARY_FULL_SCAN_SQL, SUMMARY_SCAN_AFTER_SQL, ANCHOR_CHECK_SQL = "SELECT rowid AS rid, id FROM message WHERE rowid IN (SELECT value FROM json_each(?))", ordinalCheckpoints, ordinalSummarySeeds, ORDINAL_LOOKUP_LIMIT = 512, RawOrdinalsNotReady, CANONICAL_COUNT_SQL, BOUNDARY_ORDINAL_SQL = `
|
|
31484
|
+
SELECT id, ordinal FROM (
|
|
31485
|
+
SELECT id, ROW_NUMBER() OVER (ORDER BY time_created, id) AS ordinal
|
|
31486
|
+
FROM message
|
|
31487
|
+
WHERE session_id = ?
|
|
31488
|
+
AND typeof(id) = 'text' AND typeof(data) = 'text'
|
|
31489
|
+
AND CASE WHEN json_valid(data) THEN NOT (
|
|
31490
|
+
COALESCE(json_type(data, '$.summary'), '') = 'true'
|
|
31491
|
+
AND COALESCE(json_extract(data, '$.finish'), '') = 'stop'
|
|
31492
|
+
) ELSE 1 END
|
|
31493
|
+
)
|
|
31494
|
+
WHERE id IN (SELECT value FROM json_each(?))`, BOUNDARY_MESSAGE_SQL = `
|
|
31495
|
+
SELECT id, data, time_created FROM message
|
|
31496
|
+
WHERE +session_id = ? AND id IN (SELECT value FROM json_each(?))`, BOUNDARY_BLOCK_COUNT_SQL = `
|
|
31497
|
+
SELECT message_id AS id, SUM(
|
|
31498
|
+
CASE
|
|
31499
|
+
WHEN NOT json_valid(data) OR json_type(data) <> 'object' THEN 0
|
|
31500
|
+
ELSE CASE (CASE WHEN json_type(data, '$.type') = 'text'
|
|
31501
|
+
THEN json_extract(data, '$.type') ELSE 'unknown' END)
|
|
31502
|
+
WHEN 'text' THEN CASE WHEN json_type(data, '$.ignored') = 'true' THEN 0 ELSE 1 END
|
|
31503
|
+
WHEN 'reasoning' THEN 1
|
|
31504
|
+
WHEN 'thinking' THEN 1
|
|
31505
|
+
WHEN 'redacted_thinking' THEN 1
|
|
31506
|
+
WHEN 'tool' THEN 1 + CASE
|
|
31507
|
+
WHEN json_type(data, '$.state') = 'object'
|
|
31508
|
+
AND json_type(data, '$.state.status') = 'text'
|
|
31509
|
+
AND json_extract(data, '$.state.status') IN ('completed', 'error')
|
|
31510
|
+
THEN 1 ELSE 0 END
|
|
31511
|
+
WHEN 'compaction' THEN 0
|
|
31512
|
+
WHEN 'step-finish' THEN 0
|
|
31513
|
+
WHEN 'snapshot' THEN 0
|
|
31514
|
+
WHEN 'patch' THEN 0
|
|
31515
|
+
WHEN 'agent' THEN 0
|
|
31516
|
+
WHEN 'retry' THEN 0
|
|
31517
|
+
ELSE 1
|
|
31518
|
+
END
|
|
31519
|
+
END) AS blocks
|
|
31520
|
+
FROM part
|
|
31521
|
+
WHERE +session_id = ?
|
|
31522
|
+
AND message_id IN (SELECT value FROM json_each(?))
|
|
31523
|
+
AND typeof(message_id) = 'text' AND typeof(data) = 'text'
|
|
31524
|
+
GROUP BY message_id`, boundaryEndpointCaches, BOUNDARY_ENDPOINT_CACHE_SESSIONS = 16, boundaryEndpointRowsRead = 0;
|
|
31357
31525
|
var init_read_session_raw = __esm(async () => {
|
|
31358
31526
|
await __promiseAll([
|
|
31359
31527
|
init_sqlite(),
|
|
@@ -31429,6 +31597,7 @@ END`;
|
|
|
31429
31597
|
}
|
|
31430
31598
|
};
|
|
31431
31599
|
CANONICAL_COUNT_SQL = new Map;
|
|
31600
|
+
boundaryEndpointCaches = new WeakMap;
|
|
31432
31601
|
});
|
|
31433
31602
|
|
|
31434
31603
|
// ../plugin/src/hooks/magic-context/raw-ordinal-warmup.ts
|
|
@@ -31641,7 +31810,7 @@ function getMessageTimesFromOpenCodeDb(sessionId, messageIds) {
|
|
|
31641
31810
|
try {
|
|
31642
31811
|
withReadOnlySessionDb((db) => {
|
|
31643
31812
|
const placeholders = messageIds.map(() => "?").join(",");
|
|
31644
|
-
const rows = db.prepare(`SELECT id, time_created FROM message WHERE session_id = ? AND id IN (${placeholders})`).all(sessionId, ...messageIds);
|
|
31813
|
+
const rows = db.prepare(`SELECT id, time_created FROM message WHERE +session_id = ? AND id IN (${placeholders})`).all(sessionId, ...messageIds);
|
|
31645
31814
|
for (const row of rows) {
|
|
31646
31815
|
if (typeof row.id === "string" && typeof row.time_created === "number") {
|
|
31647
31816
|
result.set(row.id, row.time_created);
|
|
@@ -31878,15 +32047,111 @@ var init_edit_marker = __esm(() => {
|
|
|
31878
32047
|
DIFF_KEYS = new Set(["oldString", "newString", "content", "old_string", "new_string"]);
|
|
31879
32048
|
});
|
|
31880
32049
|
|
|
31881
|
-
// ../plugin/src/
|
|
31882
|
-
var
|
|
31883
|
-
var
|
|
31884
|
-
|
|
32050
|
+
// ../plugin/src/features/magic-context/merged-reasoning-decisions.ts
|
|
32051
|
+
var decodedDecisions, MAX_DECODED_DECISION_BYTES;
|
|
32052
|
+
var init_merged_reasoning_decisions = __esm(() => {
|
|
32053
|
+
decodedDecisions = new Map;
|
|
32054
|
+
MAX_DECODED_DECISION_BYTES = 32 * 1024 * 1024;
|
|
32055
|
+
});
|
|
32056
|
+
// ../plugin/src/features/magic-context/session-decision-calibration.ts
|
|
32057
|
+
var init_session_decision_calibration = __esm(() => {
|
|
31885
32058
|
init_decision_calibration();
|
|
31886
|
-
|
|
31887
|
-
|
|
31888
|
-
|
|
31889
|
-
|
|
32059
|
+
init_harness_provider_map();
|
|
32060
|
+
});
|
|
32061
|
+
|
|
32062
|
+
// ../plugin/src/features/magic-context/protection-window.ts
|
|
32063
|
+
var init_protection_window = __esm(async () => {
|
|
32064
|
+
init_session_decision_calibration();
|
|
32065
|
+
await init_storage_tags();
|
|
32066
|
+
});
|
|
32067
|
+
|
|
32068
|
+
// ../plugin/src/features/magic-context/storage-meta-shared.ts
|
|
32069
|
+
var BOOLEAN_META_KEYS, NULL_BIND_META_KEYS, sessionMetaExistsStatements;
|
|
32070
|
+
var init_storage_meta_shared = __esm(async () => {
|
|
32071
|
+
init_harness_provider_map();
|
|
32072
|
+
await init_sqlite();
|
|
32073
|
+
BOOLEAN_META_KEYS = new Set(["isSubagent", "compartmentInProgress", "cacheAlertSent"]);
|
|
32074
|
+
NULL_BIND_META_KEYS = new Set([
|
|
32075
|
+
"cachedM0Bytes",
|
|
32076
|
+
"cachedM0MuralDataUrl",
|
|
32077
|
+
"cachedM0MuralHash",
|
|
32078
|
+
"cachedM1Bytes",
|
|
32079
|
+
"cachedM0ProjectMemoryEpoch",
|
|
32080
|
+
"cachedM0WorkspaceFingerprint",
|
|
32081
|
+
"cachedM0ProjectUserProfileVersion",
|
|
32082
|
+
"cachedM0MaxCompartmentSeq",
|
|
32083
|
+
"cachedM0MaxMemoryId",
|
|
32084
|
+
"cachedM0MaxMutationId",
|
|
32085
|
+
"cachedM0MaxMemoryMutationId",
|
|
32086
|
+
"cachedM0ProjectDocsHash",
|
|
32087
|
+
"cachedM0MaterializedAt",
|
|
32088
|
+
"cachedM0SessionFactsVersion",
|
|
32089
|
+
"cachedM0UpgradeState",
|
|
32090
|
+
"cachedM0ProjectIdentity",
|
|
32091
|
+
"lastObservedModelKey",
|
|
32092
|
+
"upgradeRemindedAt",
|
|
32093
|
+
"upgradeReminderLastSentAt",
|
|
32094
|
+
"piStableIdScheme"
|
|
32095
|
+
]);
|
|
32096
|
+
sessionMetaExistsStatements = new WeakMap;
|
|
32097
|
+
});
|
|
32098
|
+
|
|
32099
|
+
// ../plugin/src/features/magic-context/storage-replay-document.ts
|
|
32100
|
+
var MISSING_REPLAY_DOCUMENT_COLUMN, decisionTablePresent, trailingBlankReadCache, TRAILING_BLANK_CACHE_MAX_CHARS, DECISION_CONFLICT;
|
|
32101
|
+
var init_storage_replay_document = __esm(async () => {
|
|
32102
|
+
init_logger();
|
|
32103
|
+
await init_storage_meta_shared();
|
|
32104
|
+
MISSING_REPLAY_DOCUMENT_COLUMN = Symbol("missing replay document column");
|
|
32105
|
+
decisionTablePresent = new WeakMap;
|
|
32106
|
+
trailingBlankReadCache = new WeakMap;
|
|
32107
|
+
TRAILING_BLANK_CACHE_MAX_CHARS = 4 * 1024 * 1024;
|
|
32108
|
+
DECISION_CONFLICT = Symbol("replay decision changed concurrently");
|
|
32109
|
+
});
|
|
32110
|
+
|
|
32111
|
+
// ../plugin/src/features/magic-context/storage-meta-persisted.ts
|
|
32112
|
+
var emergencyRecoveryArmedSessions, emergencyRecoveryArmedAtBySession, providerOverflowReconfirmedSessions, providerOverflowKnownLimitSessions, AUTO_SEARCH_NO_HINT_REASONS, DRAIN_WINDOW_MS, WRAPUP_IN_PROGRESS_TTL_MS, COMPACTION_MODE_RECORD_VALUES, EMERGENCY_DRAIN_MAX_LATCH_MS, pendingAutoSearchRetirements, COMPACTION_MARKER_PENDING_BUDGET_MS, preSnapshotSessions, warnedProtectedTokenTierOverrides;
|
|
32113
|
+
var init_storage_meta_persisted = __esm(async () => {
|
|
32114
|
+
init_magic_context();
|
|
32115
|
+
init_harness_provider_map();
|
|
32116
|
+
init_logger();
|
|
32117
|
+
init_write_transaction_timing();
|
|
32118
|
+
init_merged_reasoning_decisions();
|
|
32119
|
+
await __promiseAll([
|
|
32120
|
+
init_protection_window(),
|
|
32121
|
+
init_storage_meta_shared(),
|
|
32122
|
+
init_storage_replay_document()
|
|
32123
|
+
]);
|
|
32124
|
+
emergencyRecoveryArmedSessions = new Set;
|
|
32125
|
+
emergencyRecoveryArmedAtBySession = new Map;
|
|
32126
|
+
providerOverflowReconfirmedSessions = new Set;
|
|
32127
|
+
providerOverflowKnownLimitSessions = new Set;
|
|
32128
|
+
AUTO_SEARCH_NO_HINT_REASONS = new Set([
|
|
32129
|
+
"below-threshold",
|
|
32130
|
+
"timeout",
|
|
32131
|
+
"empty",
|
|
32132
|
+
"error",
|
|
32133
|
+
"stacked",
|
|
32134
|
+
"too-short"
|
|
32135
|
+
]);
|
|
32136
|
+
DRAIN_WINDOW_MS = 10 * 60 * 1000;
|
|
32137
|
+
WRAPUP_IN_PROGRESS_TTL_MS = 5 * 60 * 1000;
|
|
32138
|
+
COMPACTION_MODE_RECORD_VALUES = new Set([
|
|
32139
|
+
"on",
|
|
32140
|
+
"off",
|
|
32141
|
+
"on_notice_pending",
|
|
32142
|
+
"off_notice_pending",
|
|
32143
|
+
"off_cleanup_pending"
|
|
32144
|
+
]);
|
|
32145
|
+
EMERGENCY_DRAIN_MAX_LATCH_MS = 30 * 60 * 1000;
|
|
32146
|
+
pendingAutoSearchRetirements = new WeakMap;
|
|
32147
|
+
COMPACTION_MARKER_PENDING_BUDGET_MS = 5 * 60000;
|
|
32148
|
+
preSnapshotSessions = new Map;
|
|
32149
|
+
warnedProtectedTokenTierOverrides = new WeakSet;
|
|
32150
|
+
});
|
|
32151
|
+
|
|
32152
|
+
// ../plugin/src/features/magic-context/storage-reasoning-removal.ts
|
|
32153
|
+
var init_storage_reasoning_removal = __esm(async () => {
|
|
32154
|
+
await init_storage_replay_document();
|
|
31890
32155
|
});
|
|
31891
32156
|
|
|
31892
32157
|
// ../plugin/src/features/magic-context/overflow-detection.ts
|
|
@@ -31910,6 +32175,74 @@ var init_sentinel = __esm(() => {
|
|
|
31910
32175
|
NEUTRALIZED_ORIGINALS = new WeakMap;
|
|
31911
32176
|
});
|
|
31912
32177
|
|
|
32178
|
+
// ../plugin/src/hooks/magic-context/active-anthropic-turn.ts
|
|
32179
|
+
var init_active_anthropic_turn = __esm(() => {
|
|
32180
|
+
init_sentinel();
|
|
32181
|
+
});
|
|
32182
|
+
|
|
32183
|
+
// ../plugin/src/hooks/magic-context/strip-content.ts
|
|
32184
|
+
var METADATA_PART_TYPES, CLEARED_REASONING_TYPES, REASONING_IGNORED_PART_TYPES, REASONING_PART_TYPES;
|
|
32185
|
+
var init_strip_content = __esm(() => {
|
|
32186
|
+
init_merged_reasoning_decisions();
|
|
32187
|
+
init_sentinel();
|
|
32188
|
+
init_tag_content_primitives();
|
|
32189
|
+
METADATA_PART_TYPES = new Set([
|
|
32190
|
+
"step-start",
|
|
32191
|
+
"step-finish",
|
|
32192
|
+
"snapshot",
|
|
32193
|
+
"patch",
|
|
32194
|
+
"agent",
|
|
32195
|
+
"retry",
|
|
32196
|
+
"subtask",
|
|
32197
|
+
"compaction"
|
|
32198
|
+
]);
|
|
32199
|
+
CLEARED_REASONING_TYPES = new Set(["thinking", "reasoning"]);
|
|
32200
|
+
REASONING_IGNORED_PART_TYPES = new Set([
|
|
32201
|
+
"step-start",
|
|
32202
|
+
"step-finish",
|
|
32203
|
+
"snapshot",
|
|
32204
|
+
"patch",
|
|
32205
|
+
"agent",
|
|
32206
|
+
"retry",
|
|
32207
|
+
"subtask",
|
|
32208
|
+
"compaction"
|
|
32209
|
+
]);
|
|
32210
|
+
REASONING_PART_TYPES = new Set(["reasoning", "thinking", "redacted_thinking"]);
|
|
32211
|
+
});
|
|
32212
|
+
|
|
32213
|
+
// ../plugin/src/hooks/magic-context/reasoning-budget.ts
|
|
32214
|
+
var init_reasoning_budget = __esm(async () => {
|
|
32215
|
+
init_merged_reasoning_decisions();
|
|
32216
|
+
init_prompt_surface();
|
|
32217
|
+
init_active_anthropic_turn();
|
|
32218
|
+
init_read_session_formatting();
|
|
32219
|
+
init_sentinel();
|
|
32220
|
+
init_strip_content();
|
|
32221
|
+
await __promiseAll([
|
|
32222
|
+
init_storage_meta_persisted(),
|
|
32223
|
+
init_storage_reasoning_removal(),
|
|
32224
|
+
init_storage_tags()
|
|
32225
|
+
]);
|
|
32226
|
+
});
|
|
32227
|
+
|
|
32228
|
+
// ../plugin/src/hooks/magic-context/opaque-thinking.ts
|
|
32229
|
+
var init_opaque_thinking = __esm(async () => {
|
|
32230
|
+
await init_reasoning_budget();
|
|
32231
|
+
});
|
|
32232
|
+
|
|
32233
|
+
// ../plugin/src/hooks/magic-context/final-wire-token-estimate.ts
|
|
32234
|
+
var wireTextTokens;
|
|
32235
|
+
var init_final_wire_token_estimate = __esm(async () => {
|
|
32236
|
+
init_tool_definition_tokens();
|
|
32237
|
+
init_decision_calibration();
|
|
32238
|
+
init_image_token_estimate();
|
|
32239
|
+
init_read_session_formatting();
|
|
32240
|
+
init_tokenizer_calibration();
|
|
32241
|
+
init_logger();
|
|
32242
|
+
await init_opaque_thinking();
|
|
32243
|
+
wireTextTokens = createTokenCountMemo(1e5, 128 * 1024 * 1024);
|
|
32244
|
+
});
|
|
32245
|
+
|
|
31913
32246
|
// ../plugin/src/hooks/magic-context/tool-input-size.ts
|
|
31914
32247
|
var encoder2;
|
|
31915
32248
|
var init_tool_input_size = __esm(() => {
|
|
@@ -31938,14 +32271,14 @@ function extractToolCallObservation(part) {
|
|
|
31938
32271
|
return null;
|
|
31939
32272
|
}
|
|
31940
32273
|
var IGNORE_PART_TYPES;
|
|
31941
|
-
var init_tool_drop_target = __esm(() => {
|
|
32274
|
+
var init_tool_drop_target = __esm(async () => {
|
|
31942
32275
|
init_user_answer();
|
|
31943
32276
|
init_dropped_input_guard();
|
|
31944
32277
|
init_edit_marker();
|
|
31945
|
-
init_final_wire_token_estimate();
|
|
31946
32278
|
init_sentinel();
|
|
31947
32279
|
init_tag_content_primitives();
|
|
31948
32280
|
init_tool_input_size();
|
|
32281
|
+
await init_final_wire_token_estimate();
|
|
31949
32282
|
IGNORE_PART_TYPES = new Set([
|
|
31950
32283
|
"thinking",
|
|
31951
32284
|
"reasoning",
|
|
@@ -31978,6 +32311,7 @@ __export(exports_read_session_chunk, {
|
|
|
31978
32311
|
prepareRawSessionOrdinals: () => prepareRawSessionOrdinals,
|
|
31979
32312
|
primeInMemoryTailRawMessageCache: () => primeInMemoryTailRawMessageCache,
|
|
31980
32313
|
primeTailRawMessageCache: () => primeTailRawMessageCache,
|
|
32314
|
+
readRawSessionBoundaryEndpoints: () => readRawSessionBoundaryEndpoints,
|
|
31981
32315
|
readRawSessionMessageById: () => readRawSessionMessageById,
|
|
31982
32316
|
readRawSessionMessageIdOrdinals: () => readRawSessionMessageIdOrdinals,
|
|
31983
32317
|
readRawSessionMessageIdOrdinalsForRange: () => readRawSessionMessageIdOrdinalsForRange,
|
|
@@ -32390,6 +32724,13 @@ function readRawSessionMessagePartsById(sessionId, messageId, onQuery) {
|
|
|
32390
32724
|
return null;
|
|
32391
32725
|
return withReadOnlySessionDb((db) => readRawSessionMessagePartsByIdFromDb(db, sessionId, messageId, onQuery));
|
|
32392
32726
|
}
|
|
32727
|
+
function readRawSessionBoundaryEndpoints(sessionId, ids, blockIds) {
|
|
32728
|
+
if (sessionProviders.get(sessionId)?.provider)
|
|
32729
|
+
return null;
|
|
32730
|
+
if (!openCodeDbExists())
|
|
32731
|
+
return new Map(ids.map((id) => [id, null]));
|
|
32732
|
+
return withReadOnlySessionDb((db) => readRawSessionBoundaryEndpointsFromDb(db, sessionId, ids, blockIds));
|
|
32733
|
+
}
|
|
32393
32734
|
function hasRawSessionMessageById(sessionId, messageId) {
|
|
32394
32735
|
const provider = sessionProviders.get(sessionId)?.provider;
|
|
32395
32736
|
if (provider?.hasMessageById)
|
|
@@ -32916,13 +33257,13 @@ var init_read_session_chunk = __esm(async () => {
|
|
|
32916
33257
|
init_read_session_true_raw_tokens();
|
|
32917
33258
|
init_system_injection_stripper();
|
|
32918
33259
|
init_tag_part_guards();
|
|
32919
|
-
init_tool_drop_target();
|
|
32920
33260
|
init_read_session_formatting();
|
|
32921
33261
|
await __promiseAll([
|
|
32922
33262
|
init_storage_tags(),
|
|
32923
33263
|
init_raw_ordinal_warmup(),
|
|
32924
33264
|
init_read_session_db(),
|
|
32925
|
-
init_read_session_raw()
|
|
33265
|
+
init_read_session_raw(),
|
|
33266
|
+
init_tool_drop_target()
|
|
32926
33267
|
]);
|
|
32927
33268
|
blockTokenMemo = new Map;
|
|
32928
33269
|
sessionProviders = new Map;
|
|
@@ -44022,6 +44363,7 @@ function parsePiConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
|
44022
44363
|
const agentMigrated = migrateLegacyAgentEnabledInMemory(configToMigrate, preMigrationWarnings);
|
|
44023
44364
|
const migratedExperimental = migrateLegacyExperimental(agentMigrated, preMigrationWarnings);
|
|
44024
44365
|
warnDeprecatedMuralModel(migratedExperimental, preMigrationWarnings);
|
|
44366
|
+
warnDeprecatedWindowOverlayPath(migratedExperimental, preMigrationWarnings);
|
|
44025
44367
|
const migrated = migrateDreamerV2(migratedExperimental, preMigrationWarnings);
|
|
44026
44368
|
const parsed = MagicContextConfigSchema.safeParse(migrated);
|
|
44027
44369
|
if (parsed.success) {
|
|
@@ -44264,7 +44606,6 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
|
|
|
44264
44606
|
parsed.config.profile = profileResolution.activeProfile;
|
|
44265
44607
|
if (applyRuntimeGlobals) {
|
|
44266
44608
|
setOutputReserveConfig(parsed.config.output_reserve);
|
|
44267
|
-
setWindowOverlayPath(parsed.config.models?.window_overlay_path);
|
|
44268
44609
|
}
|
|
44269
44610
|
warnings.push(...parsed.warnings.map((warning) => `[merged config] ${warning}`));
|
|
44270
44611
|
const substitutionFailures = loadedFiles.flatMap(bindSubstitutionFailures2);
|
|
@@ -44314,7 +44655,6 @@ var init_config2 = __esm(() => {
|
|
|
44314
44655
|
init_config_diagnostics();
|
|
44315
44656
|
init_jsonc_parser();
|
|
44316
44657
|
init_models_dev_cache();
|
|
44317
|
-
init_window_geometry();
|
|
44318
44658
|
});
|
|
44319
44659
|
|
|
44320
44660
|
// src/lib/database-repair-guidance.ts
|
|
@@ -46811,9 +47151,13 @@ var init_embedding_identity = __esm(() => {
|
|
|
46811
47151
|
init_normalize_hash();
|
|
46812
47152
|
});
|
|
46813
47153
|
|
|
47154
|
+
// ../plugin/src/features/magic-context/memory/onnx-telemetry.ts
|
|
47155
|
+
var init_onnx_telemetry = () => {};
|
|
47156
|
+
|
|
46814
47157
|
// ../plugin/src/features/magic-context/memory/embedding-worker-client.ts
|
|
46815
47158
|
var init_embedding_worker_client = __esm(() => {
|
|
46816
47159
|
init_logger();
|
|
47160
|
+
init_onnx_telemetry();
|
|
46817
47161
|
});
|
|
46818
47162
|
// ../plugin/src/features/magic-context/memory/embedding-local.ts
|
|
46819
47163
|
function currentLocalEmbeddingHost() {
|