@cortexkit/magic-context 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +76 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27529,7 +27529,7 @@ function migrateLegacyExperimental(rawConfig, warnings) {
|
|
|
27529
27529
|
patched.dreamer = dreamer;
|
|
27530
27530
|
return patched;
|
|
27531
27531
|
}
|
|
27532
|
-
function parsePluginConfig(rawConfig) {
|
|
27532
|
+
function parsePluginConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
27533
27533
|
const preMigrationWarnings = [];
|
|
27534
27534
|
const migrated = migrateLegacyExperimental(rawConfig, preMigrationWarnings);
|
|
27535
27535
|
const parsed = MagicContextConfigSchema.safeParse(migrated);
|
|
@@ -27554,6 +27554,7 @@ function parsePluginConfig(rawConfig) {
|
|
|
27554
27554
|
}
|
|
27555
27555
|
const patched = { ...rawConfig };
|
|
27556
27556
|
for (const key of errorPaths) {
|
|
27557
|
+
recoveredTopLevelKeys.push(key);
|
|
27557
27558
|
const isAgentConfig = key === "historian" || key === "dreamer" || key === "sidekick";
|
|
27558
27559
|
if (isAgentConfig) {
|
|
27559
27560
|
delete patched[key];
|
|
@@ -162340,6 +162341,52 @@ var init_migrations = __esm(async () => {
|
|
|
162340
162341
|
db.exec("ALTER TABLE session_meta ADD COLUMN deferred_execute_state TEXT");
|
|
162341
162342
|
}
|
|
162342
162343
|
}
|
|
162344
|
+
},
|
|
162345
|
+
{
|
|
162346
|
+
version: 16,
|
|
162347
|
+
description: "Add context-limit cache regression sentinels",
|
|
162348
|
+
up: (db) => {
|
|
162349
|
+
const cols = db.prepare("PRAGMA table_info(session_meta)").all();
|
|
162350
|
+
if (!cols.some((c2) => c2.name === "observed_safe_input_tokens")) {
|
|
162351
|
+
db.exec("ALTER TABLE session_meta ADD COLUMN observed_safe_input_tokens INTEGER NOT NULL DEFAULT 0");
|
|
162352
|
+
}
|
|
162353
|
+
if (!cols.some((c2) => c2.name === "cache_alert_sent")) {
|
|
162354
|
+
db.exec("ALTER TABLE session_meta ADD COLUMN cache_alert_sent INTEGER NOT NULL DEFAULT 0");
|
|
162355
|
+
}
|
|
162356
|
+
}
|
|
162357
|
+
},
|
|
162358
|
+
{
|
|
162359
|
+
version: 17,
|
|
162360
|
+
description: "Multi-anchor JSON storage for note-nudge and auto-search-hint persistence",
|
|
162361
|
+
up: (db) => {
|
|
162362
|
+
const cols = db.prepare("PRAGMA table_info(session_meta)").all();
|
|
162363
|
+
if (!cols.some((c2) => c2.name === "note_nudge_anchors")) {
|
|
162364
|
+
db.exec("ALTER TABLE session_meta ADD COLUMN note_nudge_anchors TEXT NOT NULL DEFAULT '[]'");
|
|
162365
|
+
}
|
|
162366
|
+
if (!cols.some((c2) => c2.name === "auto_search_hint_decisions")) {
|
|
162367
|
+
db.exec("ALTER TABLE session_meta ADD COLUMN auto_search_hint_decisions TEXT NOT NULL DEFAULT '[]'");
|
|
162368
|
+
}
|
|
162369
|
+
db.exec(`
|
|
162370
|
+
UPDATE session_meta
|
|
162371
|
+
SET note_nudge_anchors = json_array(
|
|
162372
|
+
json_object(
|
|
162373
|
+
'messageId', note_nudge_sticky_message_id,
|
|
162374
|
+
'text', note_nudge_sticky_text
|
|
162375
|
+
)
|
|
162376
|
+
)
|
|
162377
|
+
WHERE COALESCE(note_nudge_sticky_text, '') != ''
|
|
162378
|
+
AND COALESCE(note_nudge_sticky_message_id, '') != ''
|
|
162379
|
+
AND (note_nudge_anchors IS NULL OR note_nudge_anchors = '[]')
|
|
162380
|
+
`);
|
|
162381
|
+
db.exec(`
|
|
162382
|
+
UPDATE session_meta SET note_nudge_anchors = '[]'
|
|
162383
|
+
WHERE note_nudge_anchors IS NULL
|
|
162384
|
+
`);
|
|
162385
|
+
db.exec(`
|
|
162386
|
+
UPDATE session_meta SET auto_search_hint_decisions = '[]'
|
|
162387
|
+
WHERE auto_search_hint_decisions IS NULL
|
|
162388
|
+
`);
|
|
162389
|
+
}
|
|
162343
162390
|
}
|
|
162344
162391
|
];
|
|
162345
162392
|
});
|
|
@@ -162877,6 +162924,8 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
|
|
|
162877
162924
|
note_nudge_trigger_message_id TEXT DEFAULT '',
|
|
162878
162925
|
note_nudge_sticky_text TEXT DEFAULT '',
|
|
162879
162926
|
note_nudge_sticky_message_id TEXT DEFAULT '',
|
|
162927
|
+
note_nudge_anchors TEXT NOT NULL DEFAULT '[]',
|
|
162928
|
+
auto_search_hint_decisions TEXT NOT NULL DEFAULT '[]',
|
|
162880
162929
|
last_todo_state TEXT DEFAULT '',
|
|
162881
162930
|
todo_synthetic_call_id TEXT DEFAULT '',
|
|
162882
162931
|
todo_synthetic_anchor_message_id TEXT DEFAULT '',
|
|
@@ -162884,6 +162933,8 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
|
|
|
162884
162933
|
is_subagent INTEGER DEFAULT 0,
|
|
162885
162934
|
last_context_percentage REAL DEFAULT 0,
|
|
162886
162935
|
last_input_tokens INTEGER DEFAULT 0,
|
|
162936
|
+
observed_safe_input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
162937
|
+
cache_alert_sent INTEGER NOT NULL DEFAULT 0,
|
|
162887
162938
|
times_execute_threshold_reached INTEGER DEFAULT 0,
|
|
162888
162939
|
compartment_in_progress INTEGER DEFAULT 0,
|
|
162889
162940
|
historian_failure_count INTEGER DEFAULT 0,
|
|
@@ -162955,12 +163006,16 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
|
|
|
162955
163006
|
ensureColumn(db, "session_meta", "note_nudge_trigger_message_id", "TEXT DEFAULT ''");
|
|
162956
163007
|
ensureColumn(db, "session_meta", "note_nudge_sticky_text", "TEXT DEFAULT ''");
|
|
162957
163008
|
ensureColumn(db, "session_meta", "note_nudge_sticky_message_id", "TEXT DEFAULT ''");
|
|
163009
|
+
ensureColumn(db, "session_meta", "note_nudge_anchors", "TEXT NOT NULL DEFAULT '[]'");
|
|
163010
|
+
ensureColumn(db, "session_meta", "auto_search_hint_decisions", "TEXT NOT NULL DEFAULT '[]'");
|
|
162958
163011
|
ensureColumn(db, "session_meta", "last_todo_state", "TEXT DEFAULT ''");
|
|
162959
163012
|
ensureColumn(db, "session_meta", "todo_synthetic_call_id", "TEXT DEFAULT ''");
|
|
162960
163013
|
ensureColumn(db, "session_meta", "todo_synthetic_anchor_message_id", "TEXT DEFAULT ''");
|
|
162961
163014
|
ensureColumn(db, "session_meta", "todo_synthetic_state_json", "TEXT DEFAULT ''");
|
|
162962
163015
|
ensureColumn(db, "session_meta", "note_last_read_at", "INTEGER DEFAULT 0");
|
|
162963
163016
|
ensureColumn(db, "session_meta", "times_execute_threshold_reached", "INTEGER DEFAULT 0");
|
|
163017
|
+
ensureColumn(db, "session_meta", "observed_safe_input_tokens", "INTEGER NOT NULL DEFAULT 0");
|
|
163018
|
+
ensureColumn(db, "session_meta", "cache_alert_sent", "INTEGER NOT NULL DEFAULT 0");
|
|
162964
163019
|
ensureColumn(db, "session_meta", "compartment_in_progress", "INTEGER DEFAULT 0");
|
|
162965
163020
|
ensureColumn(db, "session_meta", "historian_failure_count", "INTEGER DEFAULT 0");
|
|
162966
163021
|
ensureColumn(db, "session_meta", "historian_last_error", "TEXT DEFAULT NULL");
|
|
@@ -163052,7 +163107,9 @@ function healNullIntegerColumns(db) {
|
|
|
163052
163107
|
["system_prompt_tokens", 0],
|
|
163053
163108
|
["conversation_tokens", 0],
|
|
163054
163109
|
["tool_call_tokens", 0],
|
|
163055
|
-
["note_nudge_trigger_pending", 0]
|
|
163110
|
+
["note_nudge_trigger_pending", 0],
|
|
163111
|
+
["observed_safe_input_tokens", 0],
|
|
163112
|
+
["cache_alert_sent", 0]
|
|
163056
163113
|
];
|
|
163057
163114
|
for (const [column, fallback] of columns) {
|
|
163058
163115
|
try {
|
|
@@ -163061,7 +163118,7 @@ function healNullIntegerColumns(db) {
|
|
|
163061
163118
|
}
|
|
163062
163119
|
}
|
|
163063
163120
|
function ensureColumn(db, table, column, definition) {
|
|
163064
|
-
if (!/^[a-z_]+$/.test(table) || !/^[a-z_]+$/.test(column) || !/^[A-Z0-9_'()
|
|
163121
|
+
if (!/^[a-z_]+$/.test(table) || !/^[a-z_]+$/.test(column) || !/^[A-Z0-9_'(),[\]\s]+$/i.test(definition)) {
|
|
163065
163122
|
throw new Error(`Unsafe schema identifier: ${table}.${column} ${definition}`);
|
|
163066
163123
|
}
|
|
163067
163124
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
@@ -163148,13 +163205,22 @@ var init_storage_db = __esm(async () => {
|
|
|
163148
163205
|
// ../plugin/src/features/magic-context/storage-meta-shared.ts
|
|
163149
163206
|
var BOOLEAN_META_KEYS;
|
|
163150
163207
|
var init_storage_meta_shared = __esm(() => {
|
|
163151
|
-
BOOLEAN_META_KEYS = new Set(["isSubagent", "compartmentInProgress"]);
|
|
163208
|
+
BOOLEAN_META_KEYS = new Set(["isSubagent", "compartmentInProgress", "cacheAlertSent"]);
|
|
163152
163209
|
});
|
|
163153
163210
|
|
|
163154
163211
|
// ../plugin/src/features/magic-context/storage-meta-persisted.ts
|
|
163212
|
+
var AUTO_SEARCH_NO_HINT_REASONS;
|
|
163155
163213
|
var init_storage_meta_persisted = __esm(() => {
|
|
163156
163214
|
init_logger();
|
|
163157
163215
|
init_storage_meta_shared();
|
|
163216
|
+
AUTO_SEARCH_NO_HINT_REASONS = new Set([
|
|
163217
|
+
"below-threshold",
|
|
163218
|
+
"timeout",
|
|
163219
|
+
"empty",
|
|
163220
|
+
"error",
|
|
163221
|
+
"stacked",
|
|
163222
|
+
"too-short"
|
|
163223
|
+
]);
|
|
163158
163224
|
});
|
|
163159
163225
|
|
|
163160
163226
|
// ../plugin/src/features/magic-context/resolve-subagent-fallback.ts
|
|
@@ -163263,7 +163329,8 @@ function loadConfigFile2(path4, scope) {
|
|
|
163263
163329
|
path: path4,
|
|
163264
163330
|
scope,
|
|
163265
163331
|
config: import_comment_json10.parse(substituted.text),
|
|
163266
|
-
warnings: substituted.warnings.map((warning) => `${path4}: ${warning}`)
|
|
163332
|
+
warnings: substituted.warnings.map((warning) => `${path4}: ${warning}`),
|
|
163333
|
+
loadOutcome: substituted.warnings.length > 0 ? "substitution-failure" : "ok"
|
|
163267
163334
|
};
|
|
163268
163335
|
} catch (error51) {
|
|
163269
163336
|
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -163273,7 +163340,8 @@ function loadConfigFile2(path4, scope) {
|
|
|
163273
163340
|
config: {},
|
|
163274
163341
|
warnings: [
|
|
163275
163342
|
`${path4}: failed to load config: ${message}; using defaults for this file.`
|
|
163276
|
-
]
|
|
163343
|
+
],
|
|
163344
|
+
loadOutcome: typeof error51.code === "string" ? "project-file-io-error" : "project-file-parse-error"
|
|
163277
163345
|
};
|
|
163278
163346
|
}
|
|
163279
163347
|
}
|
|
@@ -163308,7 +163376,7 @@ function mergeRawConfigs(base, override) {
|
|
|
163308
163376
|
}
|
|
163309
163377
|
return merged;
|
|
163310
163378
|
}
|
|
163311
|
-
function parsePiConfig(rawConfig) {
|
|
163379
|
+
function parsePiConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
163312
163380
|
const parsed = MagicContextConfigSchema.safeParse(rawConfig);
|
|
163313
163381
|
if (parsed.success) {
|
|
163314
163382
|
return { config: parsed.data, warnings: [] };
|
|
@@ -163324,6 +163392,7 @@ function parsePiConfig(rawConfig) {
|
|
|
163324
163392
|
const patched = { ...rawConfig };
|
|
163325
163393
|
const warnings = [];
|
|
163326
163394
|
for (const key of errorPaths) {
|
|
163395
|
+
recoveredTopLevelKeys.push(key);
|
|
163327
163396
|
const isAgentConfig = key === "historian" || key === "dreamer" || key === "sidekick";
|
|
163328
163397
|
delete patched[key];
|
|
163329
163398
|
if (isAgentConfig) {
|