@cortexkit/pi-magic-context 0.29.0 → 0.29.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 +2632 -2608
- package/dist/subagent-entry.js +97 -96
- package/package.json +1 -1
package/dist/subagent-entry.js
CHANGED
|
@@ -8080,6 +8080,102 @@ function closeQuietly(db) {
|
|
|
8080
8080
|
// ../plugin/src/features/magic-context/migrations.ts
|
|
8081
8081
|
init_logger();
|
|
8082
8082
|
|
|
8083
|
+
// ../plugin/src/features/magic-context/storage-schema-helpers.ts
|
|
8084
|
+
function ensureColumn(db, table, column, definition) {
|
|
8085
|
+
if (!/^[a-z][a-z0-9_]*$/.test(table) || !/^[a-z][a-z0-9_]*$/.test(column) || !/^[A-Z0-9_"'(),[\]\s]+$/i.test(definition)) {
|
|
8086
|
+
throw new Error(`Unsafe schema identifier: ${table}.${column} ${definition}`);
|
|
8087
|
+
}
|
|
8088
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
8089
|
+
if (rows.some((row) => row.name === column)) {
|
|
8090
|
+
return;
|
|
8091
|
+
}
|
|
8092
|
+
try {
|
|
8093
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
8094
|
+
} catch (err) {
|
|
8095
|
+
const recheck = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
8096
|
+
if (recheck.some((row) => row.name === column)) {
|
|
8097
|
+
return;
|
|
8098
|
+
}
|
|
8099
|
+
throw err;
|
|
8100
|
+
}
|
|
8101
|
+
}
|
|
8102
|
+
function healAllNullColumns(db) {
|
|
8103
|
+
healNullTextColumns(db);
|
|
8104
|
+
healNullIntegerColumns(db);
|
|
8105
|
+
healMissingMemoryBlockIds(db);
|
|
8106
|
+
}
|
|
8107
|
+
function healMissingMemoryBlockIds(db) {
|
|
8108
|
+
try {
|
|
8109
|
+
db.prepare("UPDATE session_meta SET memory_block_cache = '' WHERE memory_block_cache != '' AND (memory_block_ids IS NULL OR memory_block_ids = '') AND memory_block_count > 0").run();
|
|
8110
|
+
} catch {}
|
|
8111
|
+
}
|
|
8112
|
+
function healNullTextColumns(db) {
|
|
8113
|
+
const columns = [
|
|
8114
|
+
["cache_ttl", ""],
|
|
8115
|
+
["last_nudge_band", ""],
|
|
8116
|
+
["last_nudge_level", ""],
|
|
8117
|
+
["last_transform_error", ""],
|
|
8118
|
+
["nudge_anchor_message_id", ""],
|
|
8119
|
+
["nudge_anchor_text", ""],
|
|
8120
|
+
["sticky_turn_reminder_text", ""],
|
|
8121
|
+
["sticky_turn_reminder_message_id", ""],
|
|
8122
|
+
["note_nudge_trigger_message_id", ""],
|
|
8123
|
+
["note_nudge_sticky_text", ""],
|
|
8124
|
+
["note_nudge_sticky_message_id", ""],
|
|
8125
|
+
["last_todo_state", ""],
|
|
8126
|
+
["todo_synthetic_call_id", ""],
|
|
8127
|
+
["todo_synthetic_anchor_message_id", ""],
|
|
8128
|
+
["todo_synthetic_state_json", ""],
|
|
8129
|
+
["system_prompt_hash", ""],
|
|
8130
|
+
["stripped_placeholder_ids", ""],
|
|
8131
|
+
["stale_reduce_stripped_ids", ""],
|
|
8132
|
+
["processed_image_stripped_ids", ""],
|
|
8133
|
+
["memory_block_cache", ""],
|
|
8134
|
+
["memory_block_ids", ""],
|
|
8135
|
+
["compaction_marker_state", ""],
|
|
8136
|
+
["key_files", ""]
|
|
8137
|
+
];
|
|
8138
|
+
for (const [column, fallback] of columns) {
|
|
8139
|
+
try {
|
|
8140
|
+
db.prepare(`UPDATE session_meta SET ${column} = ? WHERE ${column} IS NULL`).run(fallback);
|
|
8141
|
+
} catch (_error) {}
|
|
8142
|
+
}
|
|
8143
|
+
}
|
|
8144
|
+
function healNullIntegerColumns(db) {
|
|
8145
|
+
const columns = [
|
|
8146
|
+
["times_execute_threshold_reached", 0],
|
|
8147
|
+
["compartment_in_progress", 0],
|
|
8148
|
+
["historian_failure_count", 0],
|
|
8149
|
+
["cleared_reasoning_through_tag", 0],
|
|
8150
|
+
["memory_block_count", 0],
|
|
8151
|
+
["system_prompt_tokens", 0],
|
|
8152
|
+
["conversation_tokens", 0],
|
|
8153
|
+
["tool_call_tokens", 0],
|
|
8154
|
+
["note_nudge_trigger_pending", 0],
|
|
8155
|
+
["observed_safe_input_tokens", 0],
|
|
8156
|
+
["cache_alert_sent", 0],
|
|
8157
|
+
["new_work_tokens", 0],
|
|
8158
|
+
["total_input_tokens", 0],
|
|
8159
|
+
["last_emergency_input_sample", 0],
|
|
8160
|
+
["channel2_nudge_claimed_at", 0],
|
|
8161
|
+
["last_usage_context_limit", 0],
|
|
8162
|
+
["prior_boundary_ordinal", 1],
|
|
8163
|
+
["protected_tail_policy_version", 0],
|
|
8164
|
+
["protected_tail_drain_window_started_at", 0],
|
|
8165
|
+
["protected_tail_drain_tokens", 0],
|
|
8166
|
+
["recovery_no_eligible_head_count", 0],
|
|
8167
|
+
["force_emergency_bypass_window_start", 0],
|
|
8168
|
+
["force_emergency_bypass_used", 0],
|
|
8169
|
+
["emergency_drain_active", 0],
|
|
8170
|
+
["historian_drain_failure_at", 0]
|
|
8171
|
+
];
|
|
8172
|
+
for (const [column, fallback] of columns) {
|
|
8173
|
+
try {
|
|
8174
|
+
db.prepare(`UPDATE session_meta SET ${column} = ? WHERE ${column} IS NULL`).run(fallback);
|
|
8175
|
+
} catch (_error) {}
|
|
8176
|
+
}
|
|
8177
|
+
}
|
|
8178
|
+
|
|
8083
8179
|
// ../plugin/src/features/magic-context/workspaces.ts
|
|
8084
8180
|
import { createHash as createHash2 } from "node:crypto";
|
|
8085
8181
|
|
|
@@ -143916,11 +144012,6 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
|
|
|
143916
144012
|
ensureColumn(db, "message_history_index", "harness", "TEXT NOT NULL DEFAULT 'opencode'");
|
|
143917
144013
|
ensureColumn(db, "workspaces", "share_categories", `TEXT NOT NULL DEFAULT '["CONSTRAINTS"]'`);
|
|
143918
144014
|
}
|
|
143919
|
-
function healAllNullColumns(db) {
|
|
143920
|
-
healNullTextColumns(db);
|
|
143921
|
-
healNullIntegerColumns(db);
|
|
143922
|
-
healMissingMemoryBlockIds(db);
|
|
143923
|
-
}
|
|
143924
144015
|
var CHANNEL2_CLAIM_TTL_MS = 120000;
|
|
143925
144016
|
function healWedgedChannel2Claims(db) {
|
|
143926
144017
|
try {
|
|
@@ -143928,95 +144019,6 @@ function healWedgedChannel2Claims(db) {
|
|
|
143928
144019
|
db.prepare("UPDATE session_meta SET channel2_nudge_state = 'pending', channel2_nudge_claimed_at = 0 WHERE channel2_nudge_state = 'claimed' AND (channel2_nudge_claimed_at IS NULL OR channel2_nudge_claimed_at = 0 OR channel2_nudge_claimed_at <= ?)").run(staleBefore);
|
|
143929
144020
|
} catch {}
|
|
143930
144021
|
}
|
|
143931
|
-
function healMissingMemoryBlockIds(db) {
|
|
143932
|
-
try {
|
|
143933
|
-
db.prepare("UPDATE session_meta SET memory_block_cache = '' WHERE memory_block_cache != '' AND (memory_block_ids IS NULL OR memory_block_ids = '') AND memory_block_count > 0").run();
|
|
143934
|
-
} catch {}
|
|
143935
|
-
}
|
|
143936
|
-
function healNullTextColumns(db) {
|
|
143937
|
-
const columns = [
|
|
143938
|
-
["cache_ttl", ""],
|
|
143939
|
-
["last_nudge_band", ""],
|
|
143940
|
-
["last_nudge_level", ""],
|
|
143941
|
-
["last_transform_error", ""],
|
|
143942
|
-
["nudge_anchor_message_id", ""],
|
|
143943
|
-
["nudge_anchor_text", ""],
|
|
143944
|
-
["sticky_turn_reminder_text", ""],
|
|
143945
|
-
["sticky_turn_reminder_message_id", ""],
|
|
143946
|
-
["note_nudge_trigger_message_id", ""],
|
|
143947
|
-
["note_nudge_sticky_text", ""],
|
|
143948
|
-
["note_nudge_sticky_message_id", ""],
|
|
143949
|
-
["last_todo_state", ""],
|
|
143950
|
-
["todo_synthetic_call_id", ""],
|
|
143951
|
-
["todo_synthetic_anchor_message_id", ""],
|
|
143952
|
-
["todo_synthetic_state_json", ""],
|
|
143953
|
-
["system_prompt_hash", ""],
|
|
143954
|
-
["stripped_placeholder_ids", ""],
|
|
143955
|
-
["stale_reduce_stripped_ids", ""],
|
|
143956
|
-
["processed_image_stripped_ids", ""],
|
|
143957
|
-
["memory_block_cache", ""],
|
|
143958
|
-
["memory_block_ids", ""],
|
|
143959
|
-
["compaction_marker_state", ""],
|
|
143960
|
-
["key_files", ""]
|
|
143961
|
-
];
|
|
143962
|
-
for (const [column, fallback] of columns) {
|
|
143963
|
-
try {
|
|
143964
|
-
db.prepare(`UPDATE session_meta SET ${column} = ? WHERE ${column} IS NULL`).run(fallback);
|
|
143965
|
-
} catch (_error) {}
|
|
143966
|
-
}
|
|
143967
|
-
}
|
|
143968
|
-
function healNullIntegerColumns(db) {
|
|
143969
|
-
const columns = [
|
|
143970
|
-
["times_execute_threshold_reached", 0],
|
|
143971
|
-
["compartment_in_progress", 0],
|
|
143972
|
-
["historian_failure_count", 0],
|
|
143973
|
-
["cleared_reasoning_through_tag", 0],
|
|
143974
|
-
["memory_block_count", 0],
|
|
143975
|
-
["system_prompt_tokens", 0],
|
|
143976
|
-
["conversation_tokens", 0],
|
|
143977
|
-
["tool_call_tokens", 0],
|
|
143978
|
-
["note_nudge_trigger_pending", 0],
|
|
143979
|
-
["observed_safe_input_tokens", 0],
|
|
143980
|
-
["cache_alert_sent", 0],
|
|
143981
|
-
["new_work_tokens", 0],
|
|
143982
|
-
["total_input_tokens", 0],
|
|
143983
|
-
["last_emergency_input_sample", 0],
|
|
143984
|
-
["channel2_nudge_claimed_at", 0],
|
|
143985
|
-
["last_usage_context_limit", 0],
|
|
143986
|
-
["prior_boundary_ordinal", 1],
|
|
143987
|
-
["protected_tail_policy_version", 0],
|
|
143988
|
-
["protected_tail_drain_window_started_at", 0],
|
|
143989
|
-
["protected_tail_drain_tokens", 0],
|
|
143990
|
-
["recovery_no_eligible_head_count", 0],
|
|
143991
|
-
["force_emergency_bypass_window_start", 0],
|
|
143992
|
-
["force_emergency_bypass_used", 0],
|
|
143993
|
-
["emergency_drain_active", 0],
|
|
143994
|
-
["historian_drain_failure_at", 0]
|
|
143995
|
-
];
|
|
143996
|
-
for (const [column, fallback] of columns) {
|
|
143997
|
-
try {
|
|
143998
|
-
db.prepare(`UPDATE session_meta SET ${column} = ? WHERE ${column} IS NULL`).run(fallback);
|
|
143999
|
-
} catch (_error) {}
|
|
144000
|
-
}
|
|
144001
|
-
}
|
|
144002
|
-
function ensureColumn(db, table, column, definition) {
|
|
144003
|
-
if (!/^[a-z][a-z0-9_]*$/.test(table) || !/^[a-z][a-z0-9_]*$/.test(column) || !/^[A-Z0-9_"'(),[\]\s]+$/i.test(definition)) {
|
|
144004
|
-
throw new Error(`Unsafe schema identifier: ${table}.${column} ${definition}`);
|
|
144005
|
-
}
|
|
144006
|
-
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
144007
|
-
if (rows.some((row) => row.name === column)) {
|
|
144008
|
-
return;
|
|
144009
|
-
}
|
|
144010
|
-
try {
|
|
144011
|
-
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
144012
|
-
} catch (err) {
|
|
144013
|
-
const recheck = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
144014
|
-
if (recheck.some((row) => row.name === column)) {
|
|
144015
|
-
return;
|
|
144016
|
-
}
|
|
144017
|
-
throw err;
|
|
144018
|
-
}
|
|
144019
|
-
}
|
|
144020
144022
|
function openDatabase(dbPathOrOptions) {
|
|
144021
144023
|
const options = typeof dbPathOrOptions === "string" ? { dbPath: dbPathOrOptions } : dbPathOrOptions;
|
|
144022
144024
|
const explicitDbPath = options?.dbPath !== undefined;
|
|
@@ -159440,7 +159442,6 @@ var CANONICAL_DREAM_TASKS = [
|
|
|
159440
159442
|
"refresh-primers"
|
|
159441
159443
|
];
|
|
159442
159444
|
var AGENTIC_DREAM_TASKS = ["curate", "maintain-docs"];
|
|
159443
|
-
var AGENTIC_SET = new Set(AGENTIC_DREAM_TASKS);
|
|
159444
159445
|
var MEMORY_DOMAIN_TASKS = [
|
|
159445
159446
|
"map-memories",
|
|
159446
159447
|
"verify",
|
|
@@ -172653,7 +172654,7 @@ function createCtxNoteTool(deps) {
|
|
|
172653
172654
|
parameters: ParamsSchema3,
|
|
172654
172655
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
172655
172656
|
const sessionId = ctx.sessionManager.getSessionId();
|
|
172656
|
-
const action2 = params.action ?? (
|
|
172657
|
+
const action2 = params.action ?? (params.content?.trim() ? "write" : "read");
|
|
172657
172658
|
if (action2 === "write") {
|
|
172658
172659
|
const content = params.content?.trim();
|
|
172659
172660
|
if (!content)
|
package/package.json
CHANGED