@cortexkit/magic-context 0.21.7 → 0.21.8
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 +73 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -162724,6 +162724,49 @@ var init_migrations = __esm(async () => {
|
|
|
162724
162724
|
ON compartment_state_lease(expires_at);
|
|
162725
162725
|
`);
|
|
162726
162726
|
}
|
|
162727
|
+
},
|
|
162728
|
+
{
|
|
162729
|
+
version: 20,
|
|
162730
|
+
description: "Add subagent invocation token accounting",
|
|
162731
|
+
up: (db) => {
|
|
162732
|
+
db.exec(`
|
|
162733
|
+
CREATE TABLE IF NOT EXISTS subagent_invocations (
|
|
162734
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
162735
|
+
session_id TEXT NOT NULL,
|
|
162736
|
+
harness TEXT NOT NULL,
|
|
162737
|
+
subagent TEXT NOT NULL,
|
|
162738
|
+
task TEXT,
|
|
162739
|
+
provider_id TEXT,
|
|
162740
|
+
model_id TEXT,
|
|
162741
|
+
started_at INTEGER NOT NULL,
|
|
162742
|
+
ended_at INTEGER,
|
|
162743
|
+
status TEXT NOT NULL,
|
|
162744
|
+
input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
162745
|
+
output_tokens INTEGER NOT NULL DEFAULT 0,
|
|
162746
|
+
cache_read_tokens INTEGER NOT NULL DEFAULT 0,
|
|
162747
|
+
cache_write_tokens INTEGER NOT NULL DEFAULT 0,
|
|
162748
|
+
error TEXT,
|
|
162749
|
+
parent_invocation_id INTEGER
|
|
162750
|
+
);
|
|
162751
|
+
CREATE INDEX IF NOT EXISTS idx_sai_session_started
|
|
162752
|
+
ON subagent_invocations(session_id, started_at DESC);
|
|
162753
|
+
CREATE INDEX IF NOT EXISTS idx_sai_subagent
|
|
162754
|
+
ON subagent_invocations(subagent, started_at DESC);
|
|
162755
|
+
`);
|
|
162756
|
+
}
|
|
162757
|
+
},
|
|
162758
|
+
{
|
|
162759
|
+
version: 21,
|
|
162760
|
+
description: "Add session lifetime work metrics",
|
|
162761
|
+
up: (db) => {
|
|
162762
|
+
const cols = db.prepare("PRAGMA table_info(session_meta)").all();
|
|
162763
|
+
if (!cols.some((c2) => c2.name === "new_work_tokens")) {
|
|
162764
|
+
db.exec("ALTER TABLE session_meta ADD COLUMN new_work_tokens INTEGER NOT NULL DEFAULT 0");
|
|
162765
|
+
}
|
|
162766
|
+
if (!cols.some((c2) => c2.name === "total_input_tokens")) {
|
|
162767
|
+
db.exec("ALTER TABLE session_meta ADD COLUMN total_input_tokens INTEGER NOT NULL DEFAULT 0");
|
|
162768
|
+
}
|
|
162769
|
+
}
|
|
162727
162770
|
}
|
|
162728
162771
|
];
|
|
162729
162772
|
});
|
|
@@ -163301,12 +163344,37 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
|
|
|
163301
163344
|
-- is a valid JSON blob written via setPendingPiCompactionMarkerState.
|
|
163302
163345
|
-- Excluded from healNullTextColumns.
|
|
163303
163346
|
pending_pi_compaction_marker_state TEXT,
|
|
163347
|
+
new_work_tokens INTEGER NOT NULL DEFAULT 0,
|
|
163348
|
+
total_input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
163304
163349
|
-- deferred_execute_state: intentionally NULLABLE without a default.
|
|
163305
163350
|
-- Absence is SQL NULL; presence is a JSON blob written via
|
|
163306
163351
|
-- setDeferredExecutePendingIfAbsent. Excluded from healNullTextColumns.
|
|
163307
163352
|
deferred_execute_state TEXT
|
|
163308
163353
|
);
|
|
163309
163354
|
|
|
163355
|
+
CREATE TABLE IF NOT EXISTS subagent_invocations (
|
|
163356
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
163357
|
+
session_id TEXT NOT NULL,
|
|
163358
|
+
harness TEXT NOT NULL,
|
|
163359
|
+
subagent TEXT NOT NULL,
|
|
163360
|
+
task TEXT,
|
|
163361
|
+
provider_id TEXT,
|
|
163362
|
+
model_id TEXT,
|
|
163363
|
+
started_at INTEGER NOT NULL,
|
|
163364
|
+
ended_at INTEGER,
|
|
163365
|
+
status TEXT NOT NULL,
|
|
163366
|
+
input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
163367
|
+
output_tokens INTEGER NOT NULL DEFAULT 0,
|
|
163368
|
+
cache_read_tokens INTEGER NOT NULL DEFAULT 0,
|
|
163369
|
+
cache_write_tokens INTEGER NOT NULL DEFAULT 0,
|
|
163370
|
+
error TEXT,
|
|
163371
|
+
parent_invocation_id INTEGER
|
|
163372
|
+
);
|
|
163373
|
+
CREATE INDEX IF NOT EXISTS idx_sai_session_started
|
|
163374
|
+
ON subagent_invocations(session_id, started_at DESC);
|
|
163375
|
+
CREATE INDEX IF NOT EXISTS idx_sai_subagent
|
|
163376
|
+
ON subagent_invocations(subagent, started_at DESC);
|
|
163377
|
+
|
|
163310
163378
|
CREATE INDEX IF NOT EXISTS idx_tags_session_tag_number ON tags(session_id, tag_number);
|
|
163311
163379
|
CREATE INDEX IF NOT EXISTS idx_tags_session_message_id ON tags(session_id, message_id);
|
|
163312
163380
|
CREATE INDEX IF NOT EXISTS idx_pending_ops_session ON pending_ops(session_id);
|
|
@@ -163398,6 +163466,8 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
|
|
|
163398
163466
|
ensureColumn(db, "session_meta", "needs_emergency_recovery", "INTEGER DEFAULT 0");
|
|
163399
163467
|
ensureColumn(db, "session_meta", "pending_compaction_marker_state", "TEXT");
|
|
163400
163468
|
ensureColumn(db, "session_meta", "pending_pi_compaction_marker_state", "TEXT");
|
|
163469
|
+
ensureColumn(db, "session_meta", "new_work_tokens", "INTEGER NOT NULL DEFAULT 0");
|
|
163470
|
+
ensureColumn(db, "session_meta", "total_input_tokens", "INTEGER NOT NULL DEFAULT 0");
|
|
163401
163471
|
ensureColumn(db, "session_meta", "deferred_execute_state", "TEXT");
|
|
163402
163472
|
ensureColumn(db, "tags", "harness", "TEXT NOT NULL DEFAULT 'opencode'");
|
|
163403
163473
|
ensureColumn(db, "pending_ops", "harness", "TEXT NOT NULL DEFAULT 'opencode'");
|
|
@@ -163461,7 +163531,9 @@ function healNullIntegerColumns(db) {
|
|
|
163461
163531
|
["tool_call_tokens", 0],
|
|
163462
163532
|
["note_nudge_trigger_pending", 0],
|
|
163463
163533
|
["observed_safe_input_tokens", 0],
|
|
163464
|
-
["cache_alert_sent", 0]
|
|
163534
|
+
["cache_alert_sent", 0],
|
|
163535
|
+
["new_work_tokens", 0],
|
|
163536
|
+
["total_input_tokens", 0]
|
|
163465
163537
|
];
|
|
163466
163538
|
for (const [column, fallback] of columns) {
|
|
163467
163539
|
try {
|
|
@@ -163616,7 +163688,6 @@ var init_storage_ops = __esm(() => {
|
|
|
163616
163688
|
|
|
163617
163689
|
// ../plugin/src/features/magic-context/storage-source.ts
|
|
163618
163690
|
var init_storage_source = () => {};
|
|
163619
|
-
|
|
163620
163691
|
// ../plugin/src/features/magic-context/storage-tags.ts
|
|
163621
163692
|
var insertTagStatements, updateTagStatusStatements, updateTagDropModeStatements, updateTagMessageIdStatements, getTagNumbersByMessageIdStatements, deleteTagsByMessageIdStatements, getMaxTagNumberBySessionStatements, getTagNumberByMessageIdStatements, updateTagByteSizeStatements, updateTagInputByteSizeStatements, getOwnerScopedToolTagNumbersStatements, getActiveTagsBySessionStatements, getMaxDroppedTagNumberStatements, getToolTagNumberByOwnerStatements, getNullOwnerToolTagStatements, adoptNullOwnerToolTagStatements, deleteToolTagsByOwnerStatements;
|
|
163622
163693
|
var init_storage_tags = __esm(() => {
|