@cortexkit/pi-magic-context 0.38.0 → 0.38.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.
@@ -11,10 +11,10 @@ import {
11
11
  __export,
12
12
  __require,
13
13
  __toESM
14
- } from "./index-wckvcay0.js";
14
+ } from "./index-1yh8g550.js";
15
15
 
16
16
  // ../../node_modules/.bun/esprima@4.0.1/node_modules/esprima/dist/esprima.js
17
- var require_esprima = __commonJS((exports, module) => {
17
+ var require_esprima = __commonJS(function(exports, module) {
18
18
  (function webpackUniversalModuleDefinition(root, factory) {
19
19
  if (typeof exports === "object" && typeof module === "object")
20
20
  module.exports = factory();
@@ -6154,7 +6154,7 @@ var require_esprima = __commonJS((exports, module) => {
6154
6154
  });
6155
6155
 
6156
6156
  // ../../node_modules/.bun/array-timsort@1.0.3/node_modules/array-timsort/src/index.js
6157
- var require_src = __commonJS((exports, module) => {
6157
+ var require_src = __commonJS(function(exports, module) {
6158
6158
  var DEFAULT_MIN_MERGE = 32;
6159
6159
  var DEFAULT_MIN_GALLOPING = 7;
6160
6160
  var DEFAULT_TMP_STORAGE_LENGTH = 256;
@@ -6797,7 +6797,7 @@ var require_src = __commonJS((exports, module) => {
6797
6797
  });
6798
6798
 
6799
6799
  // ../../node_modules/.bun/comment-json@5.0.0/node_modules/comment-json/src/common.js
6800
- var require_common = __commonJS((exports, module) => {
6800
+ var require_common = __commonJS(function(exports, module) {
6801
6801
  var PREFIX_BEFORE = "before";
6802
6802
  var PREFIX_AFTER_PROP = "after-prop";
6803
6803
  var PREFIX_AFTER_COLON = "after-colon";
@@ -7083,7 +7083,7 @@ var require_common = __commonJS((exports, module) => {
7083
7083
  });
7084
7084
 
7085
7085
  // ../../node_modules/.bun/comment-json@5.0.0/node_modules/comment-json/src/array.js
7086
- var require_array = __commonJS((exports, module) => {
7086
+ var require_array = __commonJS(function(exports, module) {
7087
7087
  var { sort } = require_src();
7088
7088
  var {
7089
7089
  PROP_SYMBOL_PREFIXES,
@@ -7241,7 +7241,7 @@ var require_array = __commonJS((exports, module) => {
7241
7241
  });
7242
7242
 
7243
7243
  // ../../node_modules/.bun/comment-json@5.0.0/node_modules/comment-json/src/parse.js
7244
- var require_parse = __commonJS((exports, module) => {
7244
+ var require_parse = __commonJS(function(exports, module) {
7245
7245
  var esprima = require_esprima();
7246
7246
  var {
7247
7247
  CommentArray
@@ -7607,7 +7607,7 @@ var require_parse = __commonJS((exports, module) => {
7607
7607
  });
7608
7608
 
7609
7609
  // ../../node_modules/.bun/comment-json@5.0.0/node_modules/comment-json/src/stringify.js
7610
- var require_stringify = __commonJS((exports, module) => {
7610
+ var require_stringify = __commonJS(function(exports, module) {
7611
7611
  var {
7612
7612
  PREFIX_BEFORE_ALL,
7613
7613
  PREFIX_BEFORE,
@@ -7815,7 +7815,7 @@ var require_stringify = __commonJS((exports, module) => {
7815
7815
  });
7816
7816
 
7817
7817
  // ../../node_modules/.bun/comment-json@5.0.0/node_modules/comment-json/src/index.js
7818
- var require_src2 = __commonJS((exports, module) => {
7818
+ var require_src2 = __commonJS(function(exports, module) {
7819
7819
  var { parse: parse5, tokenize } = require_parse();
7820
7820
  var stringify = require_stringify();
7821
7821
  var { CommentArray } = require_array();
@@ -8970,11 +8970,13 @@ var PI_TO_CANONICAL_PROVIDER = {
8970
8970
  };
8971
8971
  var CANONICAL_TO_OMP_PROVIDER = {
8972
8972
  openai: "openai-codex",
8973
- google: "google-antigravity"
8973
+ google: "google-antigravity",
8974
+ opencode: "opencode-zen"
8974
8975
  };
8975
8976
  var OMP_TO_CANONICAL_PROVIDER = {
8976
8977
  "openai-codex": "openai",
8977
- "google-antigravity": "google"
8978
+ "google-antigravity": "google",
8979
+ "opencode-zen": "opencode"
8978
8980
  };
8979
8981
  function remapProviderPrefix(ref, map) {
8980
8982
  if (typeof ref !== "string")
@@ -12284,6 +12286,18 @@ var MIGRATIONS = [
12284
12286
  );
12285
12287
  `);
12286
12288
  }
12289
+ },
12290
+ {
12291
+ version: 79,
12292
+ description: "record m[0] system-hash and model-key comparison telemetry",
12293
+ up(db) {
12294
+ if (!tableExists2(db, "transform_decisions"))
12295
+ return;
12296
+ ensureColumn(db, "transform_decisions", "system_hash_prev", "TEXT");
12297
+ ensureColumn(db, "transform_decisions", "system_hash_new", "TEXT");
12298
+ ensureColumn(db, "transform_decisions", "m0_model_key_prev", "TEXT");
12299
+ ensureColumn(db, "transform_decisions", "m0_model_key_new", "TEXT");
12300
+ }
12287
12301
  }
12288
12302
  ];
12289
12303
  var LATEST_MIGRATION_VERSION = MIGRATIONS.reduce((max, m) => Math.max(max, m.version), 0);
@@ -12718,7 +12732,7 @@ function getSchemaFenceRejection() {
12718
12732
  function getMigrationOnOpenRefusal() {
12719
12733
  return lastMigrationOnOpenRefusal;
12720
12734
  }
12721
- var LATEST_SUPPORTED_VERSION = 78;
12735
+ var LATEST_SUPPORTED_VERSION = 79;
12722
12736
  var PERMISSIONS_ENFORCEABLE = process.platform !== "win32";
12723
12737
  var defaultStoragePermissionFs = { chmodSync, mkdirSync: mkdirSync2 };
12724
12738
  var storagePermissionFs = defaultStoragePermissionFs;
@@ -13870,6 +13884,10 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
13870
13884
  decision TEXT NOT NULL,
13871
13885
  materialized INTEGER NOT NULL DEFAULT 0,
13872
13886
  materialize_reason TEXT,
13887
+ system_hash_prev TEXT,
13888
+ system_hash_new TEXT,
13889
+ m0_model_key_prev TEXT,
13890
+ m0_model_key_new TEXT,
13873
13891
  emergency INTEGER NOT NULL DEFAULT 0,
13874
13892
  dropped_tokens INTEGER NOT NULL DEFAULT 0,
13875
13893
  dropped_count INTEGER NOT NULL DEFAULT 0,
@@ -14207,6 +14225,10 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
14207
14225
  decision TEXT NOT NULL,
14208
14226
  materialized INTEGER NOT NULL DEFAULT 0,
14209
14227
  materialize_reason TEXT,
14228
+ system_hash_prev TEXT,
14229
+ system_hash_new TEXT,
14230
+ m0_model_key_prev TEXT,
14231
+ m0_model_key_new TEXT,
14210
14232
  emergency INTEGER NOT NULL DEFAULT 0,
14211
14233
  dropped_tokens INTEGER NOT NULL DEFAULT 0,
14212
14234
  dropped_count INTEGER NOT NULL DEFAULT 0,
@@ -14216,6 +14238,10 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
14216
14238
  CREATE INDEX IF NOT EXISTS idx_transform_decisions_session_harness
14217
14239
  ON transform_decisions(session_id, harness);
14218
14240
  `);
14241
+ ensureColumn(db, "transform_decisions", "system_hash_prev", "TEXT");
14242
+ ensureColumn(db, "transform_decisions", "system_hash_new", "TEXT");
14243
+ ensureColumn(db, "transform_decisions", "m0_model_key_prev", "TEXT");
14244
+ ensureColumn(db, "transform_decisions", "m0_model_key_new", "TEXT");
14219
14245
  ensureColumn(db, "tags", "harness", "TEXT NOT NULL DEFAULT 'opencode'");
14220
14246
  ensureColumn(db, "message_history_index", "dirty_floor_ordinal", "INTEGER NOT NULL DEFAULT 0");
14221
14247
  ensureColumn(db, "pending_ops", "harness", "TEXT NOT NULL DEFAULT 'opencode'");
@@ -15727,6 +15753,429 @@ function getSessionWorkMetrics(db, sessionId) {
15727
15753
  // ../plugin/src/features/magic-context/storage-meta-session.ts
15728
15754
  import { Buffer as Buffer3 } from "node:buffer";
15729
15755
 
15756
+ // ../plugin/src/hooks/magic-context/read-session-db.ts
15757
+ import { existsSync as existsSync6 } from "node:fs";
15758
+ import { join as join5 } from "node:path";
15759
+ function getOpenCodeDbPath() {
15760
+ return join5(getDataDir(), "opencode", "opencode.db");
15761
+ }
15762
+ function openCodeDbExists() {
15763
+ return existsSync6(getOpenCodeDbPath());
15764
+ }
15765
+ var cachedReadOnlyDb = null;
15766
+ function closeCachedReadOnlyDb() {
15767
+ if (!cachedReadOnlyDb) {
15768
+ return;
15769
+ }
15770
+ try {
15771
+ closeQuietly(cachedReadOnlyDb.db);
15772
+ } catch (error) {
15773
+ log("[magic-context] failed to close cached OpenCode read-only DB:", error);
15774
+ } finally {
15775
+ cachedReadOnlyDb = null;
15776
+ }
15777
+ }
15778
+ function getReadOnlySessionDb() {
15779
+ const dbPath = getOpenCodeDbPath();
15780
+ if (cachedReadOnlyDb?.path === dbPath) {
15781
+ return cachedReadOnlyDb.db;
15782
+ }
15783
+ closeCachedReadOnlyDb();
15784
+ const db = new Database(dbPath, { readonly: true });
15785
+ cachedReadOnlyDb = { path: dbPath, db };
15786
+ return db;
15787
+ }
15788
+ function withReadOnlySessionDb(fn) {
15789
+ return fn(getReadOnlySessionDb());
15790
+ }
15791
+ function getRawSessionMessageCountFromDb(db, sessionId) {
15792
+ const row = db.prepare(`SELECT COUNT(*) as count FROM message WHERE session_id = ?
15793
+ AND NOT (COALESCE(json_extract(data, '$.summary'), 0) = 1
15794
+ AND COALESCE(json_extract(data, '$.finish'), '') = 'stop')`).get(sessionId);
15795
+ return typeof row?.count === "number" ? row.count : 0;
15796
+ }
15797
+ function isMidTurn(_deps, sessionId) {
15798
+ try {
15799
+ return withReadOnlySessionDb((db) => isMidTurnFromOpenCodeDb(db, sessionId));
15800
+ } catch (error) {
15801
+ log("[magic-context] failed to inspect OpenCode mid-turn state:", error);
15802
+ return false;
15803
+ }
15804
+ }
15805
+ function isMidTurnFromOpenCodeDb(db, sessionId) {
15806
+ const latestAssistant = db.prepare(`SELECT id,
15807
+ json_extract(data, '$.finish') as finish,
15808
+ time_created as timeCreated
15809
+ FROM message
15810
+ WHERE session_id = ?
15811
+ AND json_extract(data, '$.role') = 'assistant'
15812
+ ORDER BY time_created DESC
15813
+ LIMIT 1`).get(sessionId);
15814
+ if (typeof latestAssistant?.id !== "string")
15815
+ return false;
15816
+ if (hasNewerRealUserMessage(db, sessionId, latestAssistant.timeCreated))
15817
+ return false;
15818
+ if (latestAssistant.finish === "tool-calls")
15819
+ return true;
15820
+ const partRows = db.prepare("SELECT data FROM part WHERE session_id = ? AND message_id = ?").all(sessionId, latestAssistant.id);
15821
+ return partRows.some((row) => {
15822
+ if (typeof row.data !== "string" || row.data.length === 0)
15823
+ return false;
15824
+ try {
15825
+ const part = JSON.parse(row.data);
15826
+ return part.type === "tool" && part.providerExecuted !== true;
15827
+ } catch {
15828
+ return false;
15829
+ }
15830
+ });
15831
+ }
15832
+ function hasNewerRealUserMessage(db, sessionId, latestAssistantTimeCreated) {
15833
+ if (typeof latestAssistantTimeCreated !== "number")
15834
+ return false;
15835
+ const row = db.prepare(`SELECT 1 as one
15836
+ FROM message m
15837
+ WHERE m.session_id = ?
15838
+ AND m.time_created > ?
15839
+ AND json_extract(m.data, '$.role') = 'user'
15840
+ AND NOT (
15841
+ EXISTS (SELECT 1 FROM part p WHERE p.message_id = m.id)
15842
+ AND NOT EXISTS (
15843
+ SELECT 1 FROM part p
15844
+ WHERE p.message_id = m.id
15845
+ AND COALESCE(json_extract(p.data, '$.synthetic'), 0) NOT IN (1, 'true')
15846
+ AND json_extract(p.data, '$.metadata.marker.kind') IS NULL
15847
+ AND COALESCE(json_extract(p.data, '$.ignored'), 0) NOT IN (1, 'true')
15848
+ )
15849
+ )
15850
+ LIMIT 1`).get(sessionId, latestAssistantTimeCreated);
15851
+ return row?.one === 1;
15852
+ }
15853
+
15854
+ // ../plugin/src/features/magic-context/resolve-subagent-fallback.ts
15855
+ function resolveIsSubagentFromOpenCodeDb(sessionId) {
15856
+ try {
15857
+ return withReadOnlySessionDb((openCodeDb) => {
15858
+ const row = openCodeDb.prepare("SELECT parent_id FROM session WHERE id = ?").get(sessionId);
15859
+ if (!row)
15860
+ return null;
15861
+ return typeof row.parent_id === "string" && row.parent_id.length > 0;
15862
+ });
15863
+ } catch (error) {
15864
+ log(`[magic-context] resolveIsSubagentFromOpenCodeDb failed for ${sessionId}:`, error);
15865
+ return null;
15866
+ }
15867
+ }
15868
+
15869
+ // ../plugin/src/features/magic-context/storage-session-tables.ts
15870
+ var SESSION_SCOPED_TABLES = [
15871
+ { table: "pending_ops", harnessScoped: true },
15872
+ { table: "source_contents", harnessScoped: true },
15873
+ { table: "tool_owner_backfill_state" },
15874
+ { table: "tags", harnessScoped: true },
15875
+ { table: "session_meta", harnessScoped: true },
15876
+ { table: "session_projects", harnessScoped: true },
15877
+ { table: "compartment_chunk_embeddings", harnessScoped: true },
15878
+ { table: "compartments", harnessScoped: true },
15879
+ { table: "compression_depth", harnessScoped: true },
15880
+ { table: "session_facts", harnessScoped: true },
15881
+ { table: "compartment_state_lease" },
15882
+ { table: "notes", harnessScoped: true, extraPredicate: "type = 'session'" },
15883
+ { table: "recomp_compartments", harnessScoped: true },
15884
+ { table: "recomp_facts", harnessScoped: true },
15885
+ { table: "user_memory_candidates" },
15886
+ { table: "primer_candidates", harnessScoped: true },
15887
+ { table: "m0_mutation_log" },
15888
+ { table: "compartment_events", harnessScoped: true },
15889
+ { table: "subagent_invocations", harnessScoped: true },
15890
+ { table: "historian_runs", harnessScoped: true },
15891
+ { table: "plugin_messages" },
15892
+ { table: "transform_decisions", harnessScoped: true },
15893
+ { table: "synapse_batch_ledger" },
15894
+ { table: "embedding_measurement_corpus" },
15895
+ { table: "pending_session_cleanup", harnessScoped: true },
15896
+ { table: "message_history_fts" },
15897
+ { table: "message_history_source", harnessScoped: true },
15898
+ { table: "message_history_index", harnessScoped: true }
15899
+ ];
15900
+ function deleteSessionScopedRows(db, sessionIds, harness) {
15901
+ if (sessionIds.length === 0)
15902
+ return;
15903
+ const placeholders2 = sessionIds.map(() => "?").join(", ");
15904
+ for (const definition of SESSION_SCOPED_TABLES) {
15905
+ const predicates = [`session_id IN (${placeholders2})`];
15906
+ if (definition.extraPredicate)
15907
+ predicates.push(definition.extraPredicate);
15908
+ const bindHarness = harness !== undefined && definition.harnessScoped === true;
15909
+ if (bindHarness)
15910
+ predicates.push("harness = ?");
15911
+ const statement = db.prepare(`DELETE FROM ${definition.table} WHERE ${predicates.join(" AND ")}`);
15912
+ if (bindHarness)
15913
+ statement.run(...sessionIds, harness);
15914
+ else
15915
+ statement.run(...sessionIds);
15916
+ }
15917
+ }
15918
+
15919
+ // ../plugin/src/features/magic-context/storage-meta-session.ts
15920
+ var SESSION_META_FALLBACK_SELECTS = {
15921
+ cache_ttl: "'5m' AS cache_ttl",
15922
+ last_nudge_band: "'' AS last_nudge_band",
15923
+ last_transform_error: "'' AS last_transform_error",
15924
+ system_prompt_hash: "'' AS system_prompt_hash",
15925
+ last_todo_state: "'' AS last_todo_state",
15926
+ tool_reclaim_watermark: "0 AS tool_reclaim_watermark",
15927
+ cached_m0_bytes: "NULL AS cached_m0_bytes",
15928
+ cached_m0_mural_data_url: "NULL AS cached_m0_mural_data_url",
15929
+ cached_m0_mural_hash: "NULL AS cached_m0_mural_hash",
15930
+ cached_m1_bytes: "NULL AS cached_m1_bytes",
15931
+ cached_m0_project_memory_epoch: "NULL AS cached_m0_project_memory_epoch",
15932
+ cached_m0_project_user_profile_version: "NULL AS cached_m0_project_user_profile_version",
15933
+ cached_m0_max_compartment_seq: "NULL AS cached_m0_max_compartment_seq",
15934
+ cached_m0_max_memory_id: "NULL AS cached_m0_max_memory_id",
15935
+ cached_m0_max_mutation_id: "NULL AS cached_m0_max_mutation_id",
15936
+ cached_m0_max_memory_mutation_id: "NULL AS cached_m0_max_memory_mutation_id",
15937
+ cached_m0_project_docs_hash: "NULL AS cached_m0_project_docs_hash",
15938
+ cached_m0_materialized_at: "NULL AS cached_m0_materialized_at",
15939
+ cached_m0_session_facts_version: "NULL AS cached_m0_session_facts_version",
15940
+ cached_m0_upgrade_state: "NULL AS cached_m0_upgrade_state",
15941
+ cached_m0_system_hash: "NULL AS cached_m0_system_hash",
15942
+ cached_m0_tool_set_hash: "NULL AS cached_m0_tool_set_hash",
15943
+ cached_m0_model_key: "NULL AS cached_m0_model_key",
15944
+ cached_m0_project_identity: "NULL AS cached_m0_project_identity",
15945
+ last_observed_model_key: "NULL AS last_observed_model_key",
15946
+ upgrade_reminded_at: "NULL AS upgrade_reminded_at",
15947
+ upgrade_reminder_last_sent_at: "NULL AS upgrade_reminder_last_sent_at",
15948
+ upgrade_reminder_count: "0 AS upgrade_reminder_count"
15949
+ };
15950
+ var sessionMetaSelectColumnsCache = new WeakMap;
15951
+ function getSessionMetaSelectColumns(db) {
15952
+ const cached = sessionMetaSelectColumnsCache.get(db);
15953
+ if (cached !== undefined)
15954
+ return cached;
15955
+ const existingColumns = new Set(db.prepare("PRAGMA table_info(session_meta)").all().map((column) => column.name));
15956
+ const projection = SESSION_META_SELECT_COLUMNS.map((column) => {
15957
+ if (existingColumns.has(column))
15958
+ return column;
15959
+ return SESSION_META_FALLBACK_SELECTS[column] ?? `0 AS ${column}`;
15960
+ }).join(", ");
15961
+ sessionMetaSelectColumnsCache.set(db, projection);
15962
+ return projection;
15963
+ }
15964
+ function getOrCreateSessionMeta(db, sessionId) {
15965
+ const result = db.prepare(`SELECT ${getSessionMetaSelectColumns(db)} FROM session_meta WHERE session_id = ?`).get(sessionId);
15966
+ if (isSessionMetaRow(result)) {
15967
+ return toSessionMeta(result);
15968
+ }
15969
+ const defaults = getDefaultSessionMeta(sessionId);
15970
+ const fallbackSubagent = getHarness() === "opencode" ? resolveIsSubagentFromOpenCodeDb(sessionId) : null;
15971
+ if (fallbackSubagent === true) {
15972
+ defaults.isSubagent = true;
15973
+ }
15974
+ ensureSessionMetaRow(db, sessionId);
15975
+ if (fallbackSubagent === true) {
15976
+ db.prepare("UPDATE session_meta SET is_subagent = 1 WHERE session_id = ?").run(sessionId);
15977
+ }
15978
+ return defaults;
15979
+ }
15980
+ function updateSessionMeta(db, sessionId, updates) {
15981
+ const setClauses = [];
15982
+ const values = [];
15983
+ for (const [key, column] of Object.entries(META_COLUMNS)) {
15984
+ const value = updates[key];
15985
+ if (value === undefined)
15986
+ continue;
15987
+ if (value === null) {
15988
+ setClauses.push(`${column} = ?`);
15989
+ values.push(NULL_BIND_META_KEYS.has(key) ? null : "");
15990
+ } else if ((key === "cachedM0Bytes" || key === "cachedM1Bytes") && value instanceof Uint8Array) {
15991
+ setClauses.push(`${column} = ?`);
15992
+ values.push(Buffer3.from(value.buffer, value.byteOffset, value.byteLength));
15993
+ } else if (BOOLEAN_META_KEYS.has(key)) {
15994
+ setClauses.push(`${column} = ?`);
15995
+ values.push(value ? 1 : 0);
15996
+ } else if (typeof value === "string" || typeof value === "number") {
15997
+ setClauses.push(`${column} = ?`);
15998
+ values.push(key === "lastObservedModelKey" && typeof value === "string" ? piModelRefToCanonical(value) : value);
15999
+ }
16000
+ }
16001
+ if (setClauses.length === 0) {
16002
+ return;
16003
+ }
16004
+ db.transaction(() => {
16005
+ ensureSessionMetaRow(db, sessionId);
16006
+ db.prepare(`UPDATE session_meta SET ${setClauses.join(", ")} WHERE session_id = ?`).run(...values, sessionId);
16007
+ })();
16008
+ }
16009
+ function advanceToolReclaimWatermark(db, sessionId, maxTagNumber) {
16010
+ if (maxTagNumber <= 0)
16011
+ return;
16012
+ db.transaction(() => {
16013
+ ensureSessionMetaRow(db, sessionId);
16014
+ db.prepare("UPDATE session_meta SET tool_reclaim_watermark = MAX(COALESCE(tool_reclaim_watermark, 0), ?) WHERE session_id = ?").run(maxTagNumber, sessionId);
16015
+ })();
16016
+ }
16017
+ function retryPendingSessionCleanups(db, limit = 200) {
16018
+ const rows = db.prepare("SELECT session_id FROM pending_session_cleanup ORDER BY requested_at ASC, session_id ASC LIMIT ?").all(Math.max(1, Math.floor(limit)));
16019
+ const failedSessionIds = [];
16020
+ let cleared = 0;
16021
+ for (const row of rows) {
16022
+ try {
16023
+ db.prepare("UPDATE pending_session_cleanup SET last_attempt_at = ? WHERE session_id = ?").run(Date.now(), row.session_id);
16024
+ clearSession(db, row.session_id);
16025
+ cleared += 1;
16026
+ } catch {
16027
+ failedSessionIds.push(row.session_id);
16028
+ }
16029
+ }
16030
+ return { attempted: rows.length, cleared, failedSessionIds };
16031
+ }
16032
+ function clearSession(db, sessionId) {
16033
+ db.transaction(() => {
16034
+ deleteSessionScopedRows(db, [sessionId]);
16035
+ })();
16036
+ }
16037
+ // ../plugin/src/hooks/magic-context/todo-view.ts
16038
+ import { createHash as createHash4 } from "node:crypto";
16039
+ var TODO_STATUS_PENDING = "pending";
16040
+ var TODO_STATUS_IN_PROGRESS = "in_progress";
16041
+ var TODO_STATUS_COMPLETED = "completed";
16042
+ var TODO_STATUS_CANCELLED = "cancelled";
16043
+ var TODO_PRIORITY_HIGH = "high";
16044
+ var TODO_PRIORITY_MEDIUM = "medium";
16045
+ var TODO_PRIORITY_LOW = "low";
16046
+ var TODO_STATUSES = [
16047
+ TODO_STATUS_PENDING,
16048
+ TODO_STATUS_IN_PROGRESS,
16049
+ TODO_STATUS_COMPLETED,
16050
+ TODO_STATUS_CANCELLED
16051
+ ];
16052
+ var TODO_PRIORITIES = [
16053
+ TODO_PRIORITY_HIGH,
16054
+ TODO_PRIORITY_MEDIUM,
16055
+ TODO_PRIORITY_LOW
16056
+ ];
16057
+ var TODO_STATUS_SET = new Set(TODO_STATUSES);
16058
+ var TODO_PRIORITY_SET = new Set(TODO_PRIORITIES);
16059
+ var TERMINAL_STATUSES = new Set([
16060
+ TODO_STATUS_COMPLETED,
16061
+ TODO_STATUS_CANCELLED
16062
+ ]);
16063
+ var TITLE_DONE_STATUSES = new Set([TODO_STATUS_COMPLETED]);
16064
+ var SYNTHETIC_CALL_ID_PREFIX = "mc_synthetic_todo_";
16065
+ function normalizeTodoStateJson(todos) {
16066
+ if (!Array.isArray(todos))
16067
+ return null;
16068
+ const normalized = [];
16069
+ for (const todo of todos) {
16070
+ if (!isTodoItem(todo))
16071
+ return null;
16072
+ normalized.push({
16073
+ content: todo.content,
16074
+ status: todo.status,
16075
+ priority: todo.priority ?? TODO_PRIORITY_MEDIUM
16076
+ });
16077
+ }
16078
+ return JSON.stringify(normalized);
16079
+ }
16080
+ function buildSyntheticTodoPart(stateJson) {
16081
+ const todos = parseTodoState(stateJson);
16082
+ if (todos === null || todos.length === 0)
16083
+ return null;
16084
+ if (todos.every((t) => TERMINAL_STATUSES.has(t.status)))
16085
+ return null;
16086
+ const callID = computeSyntheticCallId(stateJson);
16087
+ const activeCount = todos.filter((t) => !TITLE_DONE_STATUSES.has(t.status)).length;
16088
+ const output = JSON.stringify(todos, null, 2);
16089
+ const ts = 0;
16090
+ return {
16091
+ type: "tool",
16092
+ callID,
16093
+ tool: "todowrite",
16094
+ state: {
16095
+ status: "completed",
16096
+ input: { todos },
16097
+ output,
16098
+ title: `${activeCount} todos`,
16099
+ metadata: { todos, truncated: false },
16100
+ time: { start: ts, end: ts }
16101
+ },
16102
+ syntheticTodoMarker: true
16103
+ };
16104
+ }
16105
+ function computeSyntheticCallId(stateJson) {
16106
+ const hash = createHash4("sha256").update(stateJson).digest("hex").slice(0, 16);
16107
+ return `${SYNTHETIC_CALL_ID_PREFIX}${hash}`;
16108
+ }
16109
+ function parseTodoState(stateJson) {
16110
+ if (stateJson.length === 0)
16111
+ return null;
16112
+ try {
16113
+ const parsed = JSON.parse(stateJson);
16114
+ if (!Array.isArray(parsed))
16115
+ return null;
16116
+ const result = [];
16117
+ for (const item of parsed) {
16118
+ if (!isTodoItem(item))
16119
+ return null;
16120
+ result.push({
16121
+ content: item.content,
16122
+ status: item.status,
16123
+ priority: item.priority ?? TODO_PRIORITY_MEDIUM
16124
+ });
16125
+ }
16126
+ return result;
16127
+ } catch {
16128
+ return null;
16129
+ }
16130
+ }
16131
+ function isTodoStatus(value) {
16132
+ return typeof value === "string" && TODO_STATUS_SET.has(value);
16133
+ }
16134
+ function isTodoPriority(value) {
16135
+ return typeof value === "string" && TODO_PRIORITY_SET.has(value);
16136
+ }
16137
+ function isTodoItem(value) {
16138
+ if (value === null || typeof value !== "object")
16139
+ return false;
16140
+ const todo = value;
16141
+ return typeof todo.content === "string" && isTodoStatus(todo.status) && (todo.priority === undefined || isTodoPriority(todo.priority));
16142
+ }
16143
+
16144
+ // ../plugin/src/features/magic-context/compartment-lease.ts
16145
+ var COMPARTMENT_LEASE_TTL_MS = 5 * 60 * 1000;
16146
+ var COMPARTMENT_LEASE_RENEWAL_MS = 60 * 1000;
16147
+ function acquireCompartmentLease(db, sessionId, holderId) {
16148
+ const acquiredAt = Date.now();
16149
+ const expiresAt = acquiredAt + COMPARTMENT_LEASE_TTL_MS;
16150
+ const result = db.prepare(`INSERT INTO compartment_state_lease (session_id, holder_id, acquired_at, expires_at)
16151
+ VALUES (?, ?, ?, ?)
16152
+ ON CONFLICT(session_id) DO UPDATE SET
16153
+ holder_id = excluded.holder_id,
16154
+ acquired_at = excluded.acquired_at,
16155
+ expires_at = excluded.expires_at
16156
+ WHERE compartment_state_lease.holder_id = excluded.holder_id
16157
+ OR compartment_state_lease.expires_at <= ?`).run(sessionId, holderId, acquiredAt, expiresAt, acquiredAt);
16158
+ if (result.changes !== 1) {
16159
+ return null;
16160
+ }
16161
+ return { sessionId, holderId, acquiredAt, expiresAt };
16162
+ }
16163
+ function renewCompartmentLease(db, sessionId, holderId) {
16164
+ const now = Date.now();
16165
+ const expiresAt = now + COMPARTMENT_LEASE_TTL_MS;
16166
+ const result = db.prepare(`UPDATE compartment_state_lease
16167
+ SET expires_at = ?, acquired_at = ?
16168
+ WHERE session_id = ? AND holder_id = ? AND expires_at > ?`).run(expiresAt, now, sessionId, holderId, now);
16169
+ return result.changes === 1;
16170
+ }
16171
+ function releaseCompartmentLease(db, sessionId, holderId) {
16172
+ db.prepare("DELETE FROM compartment_state_lease WHERE session_id = ? AND holder_id = ?").run(sessionId, holderId);
16173
+ }
16174
+ function isCompartmentLeaseHeld(db, sessionId, holderId) {
16175
+ const row = db.prepare("SELECT 1 FROM compartment_state_lease WHERE session_id = ? AND holder_id = ? AND expires_at > ?").get(sessionId, holderId, Date.now());
16176
+ return row != null;
16177
+ }
16178
+
15730
16179
  // ../plugin/src/features/magic-context/compression-depth-storage.ts
15731
16180
  var incrementDepthStatements = new WeakMap;
15732
16181
  var totalDepthStatements = new WeakMap;
@@ -15750,106 +16199,172 @@ function clearCompressionDepthRange(db, sessionId, startOrdinal, endOrdinal) {
15750
16199
  db.prepare("DELETE FROM compression_depth WHERE session_id = ? AND message_ordinal BETWEEN ? AND ?").run(sessionId, startOrdinal, endOrdinal);
15751
16200
  }
15752
16201
 
15753
- // ../plugin/src/features/magic-context/message-index.ts
15754
- import { createHash as createHash4 } from "node:crypto";
15755
-
15756
- // ../plugin/src/hooks/magic-context/read-session-db.ts
15757
- import { existsSync as existsSync6 } from "node:fs";
15758
- import { join as join5 } from "node:path";
15759
- function getOpenCodeDbPath() {
15760
- return join5(getDataDir(), "opencode", "opencode.db");
16202
+ // ../plugin/src/features/magic-context/compartment-storage.ts
16203
+ var insertCompartmentStatements = new WeakMap;
16204
+ var insertFactStatements = new WeakMap;
16205
+ function getInsertCompartmentStatement(db) {
16206
+ let stmt = insertCompartmentStatements.get(db);
16207
+ if (!stmt) {
16208
+ stmt = db.prepare("INSERT INTO compartments (session_id, sequence, start_message, end_message, start_message_id, end_message_id, title, content, p1, p2, p3, p4, importance, episode_type, legacy, created_at, harness) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
16209
+ insertCompartmentStatements.set(db, stmt);
16210
+ }
16211
+ return stmt;
15761
16212
  }
15762
- function openCodeDbExists() {
15763
- return existsSync6(getOpenCodeDbPath());
16213
+ function isStringOrNullish(v) {
16214
+ return v === null || v === undefined || typeof v === "string";
15764
16215
  }
15765
- var cachedReadOnlyDb = null;
15766
- function closeCachedReadOnlyDb() {
15767
- if (!cachedReadOnlyDb) {
15768
- return;
15769
- }
15770
- try {
15771
- closeQuietly(cachedReadOnlyDb.db);
15772
- } catch (error) {
15773
- log("[magic-context] failed to close cached OpenCode read-only DB:", error);
15774
- } finally {
15775
- cachedReadOnlyDb = null;
15776
- }
16216
+ function isNumberOrNullish(v) {
16217
+ return v === null || v === undefined || typeof v === "number";
15777
16218
  }
15778
- function getReadOnlySessionDb() {
15779
- const dbPath = getOpenCodeDbPath();
15780
- if (cachedReadOnlyDb?.path === dbPath) {
15781
- return cachedReadOnlyDb.db;
16219
+ function isCompartmentRow(row) {
16220
+ if (row === null || typeof row !== "object")
16221
+ return false;
16222
+ const candidate = row;
16223
+ return typeof candidate.id === "number" && typeof candidate.session_id === "string" && typeof candidate.sequence === "number" && typeof candidate.start_message === "number" && typeof candidate.end_message === "number" && typeof candidate.start_message_id === "string" && typeof candidate.end_message_id === "string" && typeof candidate.title === "string" && typeof candidate.content === "string" && isStringOrNullish(candidate.p1) && isStringOrNullish(candidate.p2) && isStringOrNullish(candidate.p3) && isStringOrNullish(candidate.p4) && isNumberOrNullish(candidate.importance) && isStringOrNullish(candidate.episode_type) && isNumberOrNullish(candidate.legacy) && typeof candidate.created_at === "number";
16224
+ }
16225
+ function insertCompartmentRows(db, sessionId, compartments, now) {
16226
+ const stmt = getInsertCompartmentStatement(db);
16227
+ for (const compartment of compartments) {
16228
+ const hasTiers = typeof compartment.p1 === "string" && compartment.p1.length > 0;
16229
+ stmt.run(sessionId, compartment.sequence, compartment.startMessage, compartment.endMessage, compartment.startMessageId, compartment.endMessageId, compartment.title, compartment.content, compartment.p1 ?? null, compartment.p2 ?? null, compartment.p3 ?? null, compartment.p4 ?? null, typeof compartment.importance === "number" ? compartment.importance : 50, compartment.episodeType ?? null, hasTiers ? 0 : 1, now, getHarness());
15782
16230
  }
15783
- closeCachedReadOnlyDb();
15784
- const db = new Database(dbPath, { readonly: true });
15785
- cachedReadOnlyDb = { path: dbPath, db };
15786
- return db;
15787
16231
  }
15788
- function withReadOnlySessionDb(fn) {
15789
- return fn(getReadOnlySessionDb());
16232
+ function toCompartment(row) {
16233
+ return {
16234
+ id: row.id,
16235
+ sessionId: row.session_id,
16236
+ sequence: row.sequence,
16237
+ startMessage: row.start_message,
16238
+ endMessage: row.end_message,
16239
+ startMessageId: row.start_message_id,
16240
+ endMessageId: row.end_message_id,
16241
+ title: row.title,
16242
+ content: row.content,
16243
+ p1: row.p1 ?? null,
16244
+ p2: row.p2 ?? null,
16245
+ p3: row.p3 ?? null,
16246
+ p4: row.p4 ?? null,
16247
+ importance: typeof row.importance === "number" ? row.importance : 50,
16248
+ episodeType: row.episode_type ?? null,
16249
+ legacy: typeof row.legacy === "number" ? row.legacy : 0,
16250
+ createdAt: row.created_at
16251
+ };
15790
16252
  }
15791
- function getRawSessionMessageCountFromDb(db, sessionId) {
15792
- const row = db.prepare(`SELECT COUNT(*) as count FROM message WHERE session_id = ?
15793
- AND NOT (COALESCE(json_extract(data, '$.summary'), 0) = 1
15794
- AND COALESCE(json_extract(data, '$.finish'), '') = 'stop')`).get(sessionId);
15795
- return typeof row?.count === "number" ? row.count : 0;
16253
+ function getCompartments(db, sessionId) {
16254
+ const rows = db.prepare("SELECT * FROM compartments WHERE session_id = ? ORDER BY sequence ASC").all(sessionId).filter(isCompartmentRow);
16255
+ return rows.map(toCompartment);
15796
16256
  }
15797
- function isMidTurn(_deps, sessionId) {
16257
+ function getLastCompartmentEndMessage(db, sessionId) {
16258
+ const row = db.prepare("SELECT MAX(end_message) as max_end FROM compartments WHERE session_id = ?").get(sessionId);
16259
+ return row?.max_end ?? -1;
16260
+ }
16261
+ function getLastCompartmentEndMessageId(db, sessionId) {
16262
+ const row = db.prepare("SELECT end_message_id FROM compartments WHERE session_id = ? ORDER BY sequence DESC LIMIT 1").get(sessionId);
16263
+ const id = row?.end_message_id;
16264
+ return id && id.length > 0 ? id : null;
16265
+ }
16266
+ function getCompartmentsByEndMessageId(db, sessionId, endMessageId) {
16267
+ const rows = db.prepare("SELECT * FROM compartments WHERE session_id = ? AND end_message_id = ? ORDER BY sequence ASC").all(sessionId, endMessageId).filter(isCompartmentRow);
16268
+ return rows.map(toCompartment);
16269
+ }
16270
+ function appendCompartments(db, sessionId, compartments) {
16271
+ if (compartments.length === 0)
16272
+ return;
16273
+ const now = Date.now();
16274
+ db.transaction(() => {
16275
+ insertCompartmentRows(db, sessionId, compartments, now);
16276
+ })();
16277
+ }
16278
+ function saveRecompStagingPass(db, sessionId, passNumber, compartments, facts) {
16279
+ const now = Date.now();
16280
+ db.transaction(() => {
16281
+ db.prepare("DELETE FROM recomp_facts WHERE session_id = ?").run(sessionId);
16282
+ const compartmentStmt = db.prepare("INSERT OR REPLACE INTO recomp_compartments (session_id, sequence, start_message, end_message, start_message_id, end_message_id, title, content, p1, p2, p3, p4, importance, episode_type, pass_number, created_at, harness) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
16283
+ for (const c of compartments) {
16284
+ compartmentStmt.run(sessionId, c.sequence, c.startMessage, c.endMessage, c.startMessageId, c.endMessageId, c.title, c.content, c.p1 ?? null, c.p2 ?? null, c.p3 ?? null, c.p4 ?? null, typeof c.importance === "number" ? c.importance : 50, c.episodeType ?? null, passNumber, now, getHarness());
16285
+ }
16286
+ const factStmt = db.prepare("INSERT INTO recomp_facts (session_id, category, content, pass_number, created_at, harness) VALUES (?, ?, ?, ?, ?, ?)");
16287
+ for (const f of facts) {
16288
+ factStmt.run(sessionId, f.category, f.content, passNumber, now, getHarness());
16289
+ }
16290
+ })();
16291
+ }
16292
+ function getRecompStaging(db, sessionId) {
16293
+ const compartmentRows = db.prepare("SELECT * FROM recomp_compartments WHERE session_id = ? ORDER BY sequence ASC").all(sessionId).filter(isRecompCompartmentRow);
16294
+ if (compartmentRows.length === 0)
16295
+ return null;
16296
+ const compartments = compartmentRows.map((row) => ({
16297
+ sequence: row.sequence,
16298
+ startMessage: row.start_message,
16299
+ endMessage: row.end_message,
16300
+ startMessageId: row.start_message_id,
16301
+ endMessageId: row.end_message_id,
16302
+ title: row.title,
16303
+ content: row.content,
16304
+ p1: row.p1 ?? null,
16305
+ p2: row.p2 ?? null,
16306
+ p3: row.p3 ?? null,
16307
+ p4: row.p4 ?? null,
16308
+ importance: typeof row.importance === "number" ? row.importance : 50,
16309
+ episodeType: row.episode_type ?? null
16310
+ }));
16311
+ const factRows = db.prepare("SELECT category, content FROM recomp_facts WHERE session_id = ?").all(sessionId).filter(isRecompFactRow);
16312
+ const maxPass = compartmentRows.reduce((m, r) => Math.max(m, r.pass_number), 0);
16313
+ const lastEnd = compartmentRows[compartmentRows.length - 1]?.end_message ?? 0;
16314
+ return {
16315
+ compartments,
16316
+ facts: factRows,
16317
+ passCount: maxPass,
16318
+ lastEndMessage: lastEnd
16319
+ };
16320
+ }
16321
+ function clearRecompStaging(db, sessionId) {
16322
+ db.transaction(() => {
16323
+ db.prepare("DELETE FROM recomp_compartments WHERE session_id = ?").run(sessionId);
16324
+ db.prepare("DELETE FROM recomp_facts WHERE session_id = ?").run(sessionId);
16325
+ try {
16326
+ db.prepare("UPDATE session_meta SET recomp_partial_range_start = 0, recomp_partial_range_end = 0 WHERE session_id = ?").run(sessionId);
16327
+ } catch {}
16328
+ })();
16329
+ }
16330
+ function getRecompPartialRange(db, sessionId) {
15798
16331
  try {
15799
- return withReadOnlySessionDb((db) => isMidTurnFromOpenCodeDb(db, sessionId));
15800
- } catch (error) {
15801
- log("[magic-context] failed to inspect OpenCode mid-turn state:", error);
15802
- return false;
16332
+ const row = db.prepare("SELECT recomp_partial_range_start AS start, recomp_partial_range_end AS end FROM session_meta WHERE session_id = ?").get(sessionId);
16333
+ const start = typeof row?.start === "number" ? row.start : 0;
16334
+ const end = typeof row?.end === "number" ? row.end : 0;
16335
+ if (start <= 0 || end <= 0)
16336
+ return null;
16337
+ return { start, end };
16338
+ } catch {
16339
+ return null;
15803
16340
  }
15804
16341
  }
15805
- function isMidTurnFromOpenCodeDb(db, sessionId) {
15806
- const latestAssistant = db.prepare(`SELECT id,
15807
- json_extract(data, '$.finish') as finish,
15808
- time_created as timeCreated
15809
- FROM message
15810
- WHERE session_id = ?
15811
- AND json_extract(data, '$.role') = 'assistant'
15812
- ORDER BY time_created DESC
15813
- LIMIT 1`).get(sessionId);
15814
- if (typeof latestAssistant?.id !== "string")
15815
- return false;
15816
- if (hasNewerRealUserMessage(db, sessionId, latestAssistant.timeCreated))
16342
+ function setRecompPartialRange(db, sessionId, range) {
16343
+ const start = range ? range.start : 0;
16344
+ const end = range ? range.end : 0;
16345
+ db.prepare("INSERT OR IGNORE INTO session_meta (session_id) VALUES (?)").run(sessionId);
16346
+ db.prepare("UPDATE session_meta SET recomp_partial_range_start = ?, recomp_partial_range_end = ? WHERE session_id = ?").run(start, end, sessionId);
16347
+ }
16348
+ function isRecompCompartmentRow(row) {
16349
+ if (row === null || typeof row !== "object")
15817
16350
  return false;
15818
- if (latestAssistant.finish === "tool-calls")
15819
- return true;
15820
- const partRows = db.prepare("SELECT data FROM part WHERE session_id = ? AND message_id = ?").all(sessionId, latestAssistant.id);
15821
- return partRows.some((row) => {
15822
- if (typeof row.data !== "string" || row.data.length === 0)
15823
- return false;
15824
- try {
15825
- const part = JSON.parse(row.data);
15826
- return part.type === "tool" && part.providerExecuted !== true;
15827
- } catch {
15828
- return false;
15829
- }
15830
- });
16351
+ const candidate = row;
16352
+ return typeof candidate.id === "number" && typeof candidate.session_id === "string" && typeof candidate.sequence === "number" && typeof candidate.start_message === "number" && typeof candidate.end_message === "number" && typeof candidate.start_message_id === "string" && typeof candidate.end_message_id === "string" && typeof candidate.title === "string" && typeof candidate.content === "string" && isStringOrNullish(candidate.p1) && isStringOrNullish(candidate.p2) && isStringOrNullish(candidate.p3) && isStringOrNullish(candidate.p4) && isNumberOrNullish(candidate.importance) && isStringOrNullish(candidate.episode_type) && typeof candidate.pass_number === "number" && typeof candidate.created_at === "number";
15831
16353
  }
15832
- function hasNewerRealUserMessage(db, sessionId, latestAssistantTimeCreated) {
15833
- if (typeof latestAssistantTimeCreated !== "number")
16354
+ function isRecompFactRow(row) {
16355
+ if (row === null || typeof row !== "object")
15834
16356
  return false;
15835
- const row = db.prepare(`SELECT 1 as one
15836
- FROM message m
15837
- WHERE m.session_id = ?
15838
- AND m.time_created > ?
15839
- AND json_extract(m.data, '$.role') = 'user'
15840
- AND NOT (
15841
- EXISTS (SELECT 1 FROM part p WHERE p.message_id = m.id)
15842
- AND NOT EXISTS (
15843
- SELECT 1 FROM part p
15844
- WHERE p.message_id = m.id
15845
- AND COALESCE(json_extract(p.data, '$.synthetic'), 0) NOT IN (1, 'true')
15846
- AND json_extract(p.data, '$.metadata.marker.kind') IS NULL
15847
- AND COALESCE(json_extract(p.data, '$.ignored'), 0) NOT IN (1, 'true')
15848
- )
15849
- )
15850
- LIMIT 1`).get(sessionId, latestAssistantTimeCreated);
15851
- return row?.one === 1;
16357
+ const candidate = row;
16358
+ return typeof candidate.category === "string" && typeof candidate.content === "string";
15852
16359
  }
16360
+ function escapeXmlAttr(s) {
16361
+ return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&apos;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
16362
+ }
16363
+ function escapeXmlContent(s) {
16364
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
16365
+ }
16366
+ // ../plugin/src/features/magic-context/message-index.ts
16367
+ import { createHash as createHash5 } from "node:crypto";
15853
16368
 
15854
16369
  // ../plugin/src/hooks/magic-context/read-session-raw.ts
15855
16370
  function isRawMessageRow(row) {
@@ -16670,21 +17185,6 @@ var IGNORE_PART_TYPES = new Set([
16670
17185
  function isToolCallId(value) {
16671
17186
  return typeof value === "string" && value.length > 0;
16672
17187
  }
16673
- function hasMeaningfulPart(part) {
16674
- if (!isRecord(part))
16675
- return false;
16676
- const type = part.type;
16677
- if (type === "text") {
16678
- if (typeof part.text !== "string")
16679
- return false;
16680
- return stripTagPrefix(part.text).trim().length > 0;
16681
- }
16682
- if (typeof type !== "string")
16683
- return false;
16684
- if (IGNORE_PART_TYPES.has(type))
16685
- return false;
16686
- return true;
16687
- }
16688
17188
  function extractToolCallObservation(part) {
16689
17189
  if (!isRecord(part))
16690
17190
  return null;
@@ -16702,32 +17202,6 @@ function extractToolCallObservation(part) {
16702
17202
  }
16703
17203
  return null;
16704
17204
  }
16705
- class ToolMutationBatch {
16706
- partsToRemove = new Set;
16707
- affectedMessages = new Set;
16708
- messages;
16709
- constructor(messages) {
16710
- this.messages = messages;
16711
- }
16712
- markForRemoval(occurrence) {
16713
- this.partsToRemove.add(occurrence.part);
16714
- this.affectedMessages.add(occurrence.message);
16715
- }
16716
- finalize() {
16717
- if (this.partsToRemove.size === 0)
16718
- return;
16719
- for (const message of this.affectedMessages) {
16720
- message.parts = message.parts.filter((p) => !this.partsToRemove.has(p));
16721
- }
16722
- for (let i = this.messages.length - 1;i >= 0; i -= 1) {
16723
- if (!this.messages[i].parts.some(hasMeaningfulPart)) {
16724
- this.messages.splice(i, 1);
16725
- }
16726
- }
16727
- this.partsToRemove.clear();
16728
- this.affectedMessages.clear();
16729
- }
16730
- }
16731
17205
 
16732
17206
  // ../plugin/src/hooks/magic-context/read-session-chunk.ts
16733
17207
  var BLOCK_TOKEN_MEMO_MAX = 2048;
@@ -17139,14 +17613,6 @@ function getUpsertDirtyFloorStatement(db) {
17139
17613
  }
17140
17614
  return stmt;
17141
17615
  }
17142
- function getDeleteFtsStatement(db) {
17143
- let stmt = deleteFtsStatements.get(db);
17144
- if (!stmt) {
17145
- stmt = db.prepare("DELETE FROM message_history_fts WHERE session_id = ?");
17146
- deleteFtsStatements.set(db, stmt);
17147
- }
17148
- return stmt;
17149
- }
17150
17616
  function getDeleteFtsRangeStatement(db) {
17151
17617
  let stmt = deleteFtsRangeStatements.get(db);
17152
17618
  if (!stmt) {
@@ -17155,14 +17621,6 @@ function getDeleteFtsRangeStatement(db) {
17155
17621
  }
17156
17622
  return stmt;
17157
17623
  }
17158
- function getDeleteIndexStatement(db) {
17159
- let stmt = deleteIndexStatements.get(db);
17160
- if (!stmt) {
17161
- stmt = db.prepare("DELETE FROM message_history_index WHERE session_id = ?");
17162
- deleteIndexStatements.set(db, stmt);
17163
- }
17164
- return stmt;
17165
- }
17166
17624
  function getCountIndexedMessageStatement(db) {
17167
17625
  let stmt = countIndexedMessageStatements.get(db);
17168
17626
  if (!stmt) {
@@ -17197,14 +17655,6 @@ function getUpsertMessageSourceStatement(db) {
17197
17655
  }
17198
17656
  return stmt;
17199
17657
  }
17200
- function getDeleteMessageSourceStatement(db) {
17201
- let stmt = deleteMessageSourceStatements.get(db);
17202
- if (!stmt) {
17203
- stmt = db.prepare("DELETE FROM message_history_source WHERE session_id = ?");
17204
- deleteMessageSourceStatements.set(db, stmt);
17205
- }
17206
- return stmt;
17207
- }
17208
17658
  function getDeleteMessageSourceRangeStatement(db) {
17209
17659
  let stmt = deleteMessageSourceRangeStatements.get(db);
17210
17660
  if (!stmt) {
@@ -17233,7 +17683,7 @@ function getMessageSourceSnapshot(message) {
17233
17683
  return {
17234
17684
  ordinal: message.ordinal,
17235
17685
  sourceVersion: normalizeSourceVersion(message.version),
17236
- contentHash: createHash4("sha256").update(content).digest("hex"),
17686
+ contentHash: createHash5("sha256").update(content).digest("hex"),
17237
17687
  role: message.role,
17238
17688
  content
17239
17689
  };
@@ -17284,14 +17734,6 @@ function isMessageIndexReconciledThrough(db, sessionId, finalWatermark) {
17284
17734
  const dirtyFloor = getDirtyIndexFloor(db, sessionId);
17285
17735
  return getLastIndexedOrdinal(db, sessionId) >= finalWatermark && dirtyFloor === null;
17286
17736
  }
17287
- function clearIndexedMessages(db, sessionId) {
17288
- db.transaction(() => {
17289
- getDeleteFtsStatement(db).run(sessionId);
17290
- getDeleteMessageSourceStatement(db).run(sessionId);
17291
- getDeleteIndexStatement(db).run(sessionId);
17292
- clearCompressionDepth(db, sessionId);
17293
- })();
17294
- }
17295
17737
  function getIndexableContent(role, parts) {
17296
17738
  if (role === "user") {
17297
17739
  if (!hasMeaningfulUserText(parts)) {
@@ -17451,15 +17893,9 @@ function sweepOrphanedOpenCodeMessageIndexes(db, openReadableOpenCodeDb, options
17451
17893
  let deleted = 0;
17452
17894
  try {
17453
17895
  const stillEligible = db.prepare("SELECT 1 FROM message_history_index WHERE session_id = ? AND harness = 'opencode' AND updated_at <= ?");
17454
- for (const sessionId of missingSessionIds) {
17455
- if (!stillEligible.get(sessionId, cutoff))
17456
- continue;
17457
- getDeleteFtsStatement(db).run(sessionId);
17458
- getDeleteMessageSourceStatement(db).run(sessionId);
17459
- const result = db.prepare("DELETE FROM message_history_index WHERE session_id = ? AND harness = 'opencode' AND updated_at <= ?").run(sessionId, cutoff);
17460
- if (result.changes === 1)
17461
- deleted += 1;
17462
- }
17896
+ const eligibleSessionIds = missingSessionIds.filter((sessionId) => stillEligible.get(sessionId, cutoff));
17897
+ deleteSessionScopedRows(db, eligibleSessionIds, "opencode");
17898
+ deleted = eligibleSessionIds.length;
17463
17899
  persistMessageHistoryOrphanSweepState(db, nextCursor, completedAt);
17464
17900
  db.exec("COMMIT");
17465
17901
  committed = true;
@@ -17480,471 +17916,6 @@ function sweepOrphanedOpenCodeMessageIndexes(db, openReadableOpenCodeDb, options
17480
17916
  closeQuietly(openCodeDb);
17481
17917
  }
17482
17918
  }
17483
-
17484
- // ../plugin/src/features/magic-context/resolve-subagent-fallback.ts
17485
- function resolveIsSubagentFromOpenCodeDb(sessionId) {
17486
- try {
17487
- return withReadOnlySessionDb((openCodeDb) => {
17488
- const row = openCodeDb.prepare("SELECT parent_id FROM session WHERE id = ?").get(sessionId);
17489
- if (!row)
17490
- return null;
17491
- return typeof row.parent_id === "string" && row.parent_id.length > 0;
17492
- });
17493
- } catch (error) {
17494
- log(`[magic-context] resolveIsSubagentFromOpenCodeDb failed for ${sessionId}:`, error);
17495
- return null;
17496
- }
17497
- }
17498
-
17499
- // ../plugin/src/features/magic-context/storage-meta-session.ts
17500
- var SESSION_META_FALLBACK_SELECTS = {
17501
- cache_ttl: "'5m' AS cache_ttl",
17502
- last_nudge_band: "'' AS last_nudge_band",
17503
- last_transform_error: "'' AS last_transform_error",
17504
- system_prompt_hash: "'' AS system_prompt_hash",
17505
- last_todo_state: "'' AS last_todo_state",
17506
- tool_reclaim_watermark: "0 AS tool_reclaim_watermark",
17507
- cached_m0_bytes: "NULL AS cached_m0_bytes",
17508
- cached_m0_mural_data_url: "NULL AS cached_m0_mural_data_url",
17509
- cached_m0_mural_hash: "NULL AS cached_m0_mural_hash",
17510
- cached_m1_bytes: "NULL AS cached_m1_bytes",
17511
- cached_m0_project_memory_epoch: "NULL AS cached_m0_project_memory_epoch",
17512
- cached_m0_project_user_profile_version: "NULL AS cached_m0_project_user_profile_version",
17513
- cached_m0_max_compartment_seq: "NULL AS cached_m0_max_compartment_seq",
17514
- cached_m0_max_memory_id: "NULL AS cached_m0_max_memory_id",
17515
- cached_m0_max_mutation_id: "NULL AS cached_m0_max_mutation_id",
17516
- cached_m0_max_memory_mutation_id: "NULL AS cached_m0_max_memory_mutation_id",
17517
- cached_m0_project_docs_hash: "NULL AS cached_m0_project_docs_hash",
17518
- cached_m0_materialized_at: "NULL AS cached_m0_materialized_at",
17519
- cached_m0_session_facts_version: "NULL AS cached_m0_session_facts_version",
17520
- cached_m0_upgrade_state: "NULL AS cached_m0_upgrade_state",
17521
- cached_m0_system_hash: "NULL AS cached_m0_system_hash",
17522
- cached_m0_tool_set_hash: "NULL AS cached_m0_tool_set_hash",
17523
- cached_m0_model_key: "NULL AS cached_m0_model_key",
17524
- cached_m0_project_identity: "NULL AS cached_m0_project_identity",
17525
- last_observed_model_key: "NULL AS last_observed_model_key",
17526
- upgrade_reminded_at: "NULL AS upgrade_reminded_at",
17527
- upgrade_reminder_last_sent_at: "NULL AS upgrade_reminder_last_sent_at",
17528
- upgrade_reminder_count: "0 AS upgrade_reminder_count"
17529
- };
17530
- var sessionMetaSelectColumnsCache = new WeakMap;
17531
- function getSessionMetaSelectColumns(db) {
17532
- const cached = sessionMetaSelectColumnsCache.get(db);
17533
- if (cached !== undefined)
17534
- return cached;
17535
- const existingColumns = new Set(db.prepare("PRAGMA table_info(session_meta)").all().map((column) => column.name));
17536
- const projection = SESSION_META_SELECT_COLUMNS.map((column) => {
17537
- if (existingColumns.has(column))
17538
- return column;
17539
- return SESSION_META_FALLBACK_SELECTS[column] ?? `0 AS ${column}`;
17540
- }).join(", ");
17541
- sessionMetaSelectColumnsCache.set(db, projection);
17542
- return projection;
17543
- }
17544
- function getOrCreateSessionMeta(db, sessionId) {
17545
- const result = db.prepare(`SELECT ${getSessionMetaSelectColumns(db)} FROM session_meta WHERE session_id = ?`).get(sessionId);
17546
- if (isSessionMetaRow(result)) {
17547
- return toSessionMeta(result);
17548
- }
17549
- const defaults = getDefaultSessionMeta(sessionId);
17550
- const fallbackSubagent = getHarness() === "opencode" ? resolveIsSubagentFromOpenCodeDb(sessionId) : null;
17551
- if (fallbackSubagent === true) {
17552
- defaults.isSubagent = true;
17553
- }
17554
- ensureSessionMetaRow(db, sessionId);
17555
- if (fallbackSubagent === true) {
17556
- db.prepare("UPDATE session_meta SET is_subagent = 1 WHERE session_id = ?").run(sessionId);
17557
- }
17558
- return defaults;
17559
- }
17560
- function updateSessionMeta(db, sessionId, updates) {
17561
- const setClauses = [];
17562
- const values = [];
17563
- for (const [key, column] of Object.entries(META_COLUMNS)) {
17564
- const value = updates[key];
17565
- if (value === undefined)
17566
- continue;
17567
- if (value === null) {
17568
- setClauses.push(`${column} = ?`);
17569
- values.push(NULL_BIND_META_KEYS.has(key) ? null : "");
17570
- } else if ((key === "cachedM0Bytes" || key === "cachedM1Bytes") && value instanceof Uint8Array) {
17571
- setClauses.push(`${column} = ?`);
17572
- values.push(Buffer3.from(value.buffer, value.byteOffset, value.byteLength));
17573
- } else if (BOOLEAN_META_KEYS.has(key)) {
17574
- setClauses.push(`${column} = ?`);
17575
- values.push(value ? 1 : 0);
17576
- } else if (typeof value === "string" || typeof value === "number") {
17577
- setClauses.push(`${column} = ?`);
17578
- values.push(key === "lastObservedModelKey" && typeof value === "string" ? piModelRefToCanonical(value) : value);
17579
- }
17580
- }
17581
- if (setClauses.length === 0) {
17582
- return;
17583
- }
17584
- db.transaction(() => {
17585
- ensureSessionMetaRow(db, sessionId);
17586
- db.prepare(`UPDATE session_meta SET ${setClauses.join(", ")} WHERE session_id = ?`).run(...values, sessionId);
17587
- })();
17588
- }
17589
- function advanceToolReclaimWatermark(db, sessionId, maxTagNumber) {
17590
- if (maxTagNumber <= 0)
17591
- return;
17592
- db.transaction(() => {
17593
- ensureSessionMetaRow(db, sessionId);
17594
- db.prepare("UPDATE session_meta SET tool_reclaim_watermark = MAX(COALESCE(tool_reclaim_watermark, 0), ?) WHERE session_id = ?").run(maxTagNumber, sessionId);
17595
- })();
17596
- }
17597
- function retryPendingSessionCleanups(db, limit = 200) {
17598
- const rows = db.prepare("SELECT session_id FROM pending_session_cleanup ORDER BY requested_at ASC, session_id ASC LIMIT ?").all(Math.max(1, Math.floor(limit)));
17599
- const failedSessionIds = [];
17600
- let cleared = 0;
17601
- for (const row of rows) {
17602
- try {
17603
- db.prepare("UPDATE pending_session_cleanup SET last_attempt_at = ? WHERE session_id = ?").run(Date.now(), row.session_id);
17604
- clearSession(db, row.session_id);
17605
- cleared += 1;
17606
- } catch {
17607
- failedSessionIds.push(row.session_id);
17608
- }
17609
- }
17610
- return { attempted: rows.length, cleared, failedSessionIds };
17611
- }
17612
- function clearSession(db, sessionId) {
17613
- db.transaction(() => {
17614
- db.prepare("DELETE FROM pending_ops WHERE session_id = ?").run(sessionId);
17615
- db.prepare("DELETE FROM source_contents WHERE session_id = ?").run(sessionId);
17616
- db.prepare("DELETE FROM tool_owner_backfill_state WHERE session_id = ?").run(sessionId);
17617
- db.prepare("DELETE FROM tags WHERE session_id = ?").run(sessionId);
17618
- db.prepare("DELETE FROM session_meta WHERE session_id = ?").run(sessionId);
17619
- db.prepare("DELETE FROM session_projects WHERE session_id = ?").run(sessionId);
17620
- db.prepare("DELETE FROM compartment_chunk_embeddings WHERE session_id = ?").run(sessionId);
17621
- db.prepare("DELETE FROM compartments WHERE session_id = ?").run(sessionId);
17622
- clearCompressionDepth(db, sessionId);
17623
- db.prepare("DELETE FROM session_facts WHERE session_id = ?").run(sessionId);
17624
- db.prepare("DELETE FROM compartment_state_lease WHERE session_id = ?").run(sessionId);
17625
- db.prepare("DELETE FROM notes WHERE session_id = ? AND type = 'session'").run(sessionId);
17626
- db.prepare("DELETE FROM recomp_compartments WHERE session_id = ?").run(sessionId);
17627
- db.prepare("DELETE FROM recomp_facts WHERE session_id = ?").run(sessionId);
17628
- db.prepare("DELETE FROM user_memory_candidates WHERE session_id = ?").run(sessionId);
17629
- db.prepare("DELETE FROM primer_candidates WHERE session_id = ?").run(sessionId);
17630
- db.prepare("DELETE FROM m0_mutation_log WHERE session_id = ?").run(sessionId);
17631
- db.prepare("DELETE FROM compartment_events WHERE session_id = ?").run(sessionId);
17632
- db.prepare("DELETE FROM subagent_invocations WHERE session_id = ?").run(sessionId);
17633
- db.prepare("DELETE FROM historian_runs WHERE session_id = ?").run(sessionId);
17634
- db.prepare("DELETE FROM plugin_messages WHERE session_id = ?").run(sessionId);
17635
- db.prepare("DELETE FROM transform_decisions WHERE session_id = ?").run(sessionId);
17636
- db.prepare("DELETE FROM synapse_batch_ledger WHERE session_id = ?").run(sessionId);
17637
- db.prepare("DELETE FROM embedding_measurement_corpus WHERE session_id = ?").run(sessionId);
17638
- db.prepare("DELETE FROM pending_session_cleanup WHERE session_id = ?").run(sessionId);
17639
- clearIndexedMessages(db, sessionId);
17640
- })();
17641
- }
17642
- // ../plugin/src/hooks/magic-context/todo-view.ts
17643
- import { createHash as createHash5 } from "node:crypto";
17644
- var TODO_STATUS_PENDING = "pending";
17645
- var TODO_STATUS_IN_PROGRESS = "in_progress";
17646
- var TODO_STATUS_COMPLETED = "completed";
17647
- var TODO_STATUS_CANCELLED = "cancelled";
17648
- var TODO_PRIORITY_HIGH = "high";
17649
- var TODO_PRIORITY_MEDIUM = "medium";
17650
- var TODO_PRIORITY_LOW = "low";
17651
- var TODO_STATUSES = [
17652
- TODO_STATUS_PENDING,
17653
- TODO_STATUS_IN_PROGRESS,
17654
- TODO_STATUS_COMPLETED,
17655
- TODO_STATUS_CANCELLED
17656
- ];
17657
- var TODO_PRIORITIES = [
17658
- TODO_PRIORITY_HIGH,
17659
- TODO_PRIORITY_MEDIUM,
17660
- TODO_PRIORITY_LOW
17661
- ];
17662
- var TODO_STATUS_SET = new Set(TODO_STATUSES);
17663
- var TODO_PRIORITY_SET = new Set(TODO_PRIORITIES);
17664
- var TERMINAL_STATUSES = new Set([
17665
- TODO_STATUS_COMPLETED,
17666
- TODO_STATUS_CANCELLED
17667
- ]);
17668
- var TITLE_DONE_STATUSES = new Set([TODO_STATUS_COMPLETED]);
17669
- var SYNTHETIC_CALL_ID_PREFIX = "mc_synthetic_todo_";
17670
- function normalizeTodoStateJson(todos) {
17671
- if (!Array.isArray(todos))
17672
- return null;
17673
- const normalized = [];
17674
- for (const todo of todos) {
17675
- if (!isTodoItem(todo))
17676
- return null;
17677
- normalized.push({
17678
- content: todo.content,
17679
- status: todo.status,
17680
- priority: todo.priority ?? TODO_PRIORITY_MEDIUM
17681
- });
17682
- }
17683
- return JSON.stringify(normalized);
17684
- }
17685
- function buildSyntheticTodoPart(stateJson) {
17686
- const todos = parseTodoState(stateJson);
17687
- if (todos === null || todos.length === 0)
17688
- return null;
17689
- if (todos.every((t) => TERMINAL_STATUSES.has(t.status)))
17690
- return null;
17691
- const callID = computeSyntheticCallId(stateJson);
17692
- const activeCount = todos.filter((t) => !TITLE_DONE_STATUSES.has(t.status)).length;
17693
- const output = JSON.stringify(todos, null, 2);
17694
- const ts = 0;
17695
- return {
17696
- type: "tool",
17697
- callID,
17698
- tool: "todowrite",
17699
- state: {
17700
- status: "completed",
17701
- input: { todos },
17702
- output,
17703
- title: `${activeCount} todos`,
17704
- metadata: { todos, truncated: false },
17705
- time: { start: ts, end: ts }
17706
- },
17707
- syntheticTodoMarker: true
17708
- };
17709
- }
17710
- function computeSyntheticCallId(stateJson) {
17711
- const hash = createHash5("sha256").update(stateJson).digest("hex").slice(0, 16);
17712
- return `${SYNTHETIC_CALL_ID_PREFIX}${hash}`;
17713
- }
17714
- function parseTodoState(stateJson) {
17715
- if (stateJson.length === 0)
17716
- return null;
17717
- try {
17718
- const parsed = JSON.parse(stateJson);
17719
- if (!Array.isArray(parsed))
17720
- return null;
17721
- const result = [];
17722
- for (const item of parsed) {
17723
- if (!isTodoItem(item))
17724
- return null;
17725
- result.push({
17726
- content: item.content,
17727
- status: item.status,
17728
- priority: item.priority ?? TODO_PRIORITY_MEDIUM
17729
- });
17730
- }
17731
- return result;
17732
- } catch {
17733
- return null;
17734
- }
17735
- }
17736
- function isTodoStatus(value) {
17737
- return typeof value === "string" && TODO_STATUS_SET.has(value);
17738
- }
17739
- function isTodoPriority(value) {
17740
- return typeof value === "string" && TODO_PRIORITY_SET.has(value);
17741
- }
17742
- function isTodoItem(value) {
17743
- if (value === null || typeof value !== "object")
17744
- return false;
17745
- const todo = value;
17746
- return typeof todo.content === "string" && isTodoStatus(todo.status) && (todo.priority === undefined || isTodoPriority(todo.priority));
17747
- }
17748
-
17749
- // ../plugin/src/features/magic-context/compartment-lease.ts
17750
- var COMPARTMENT_LEASE_TTL_MS = 5 * 60 * 1000;
17751
- var COMPARTMENT_LEASE_RENEWAL_MS = 60 * 1000;
17752
- function acquireCompartmentLease(db, sessionId, holderId) {
17753
- const acquiredAt = Date.now();
17754
- const expiresAt = acquiredAt + COMPARTMENT_LEASE_TTL_MS;
17755
- const result = db.prepare(`INSERT INTO compartment_state_lease (session_id, holder_id, acquired_at, expires_at)
17756
- VALUES (?, ?, ?, ?)
17757
- ON CONFLICT(session_id) DO UPDATE SET
17758
- holder_id = excluded.holder_id,
17759
- acquired_at = excluded.acquired_at,
17760
- expires_at = excluded.expires_at
17761
- WHERE compartment_state_lease.holder_id = excluded.holder_id
17762
- OR compartment_state_lease.expires_at <= ?`).run(sessionId, holderId, acquiredAt, expiresAt, acquiredAt);
17763
- if (result.changes !== 1) {
17764
- return null;
17765
- }
17766
- return { sessionId, holderId, acquiredAt, expiresAt };
17767
- }
17768
- function renewCompartmentLease(db, sessionId, holderId) {
17769
- const now = Date.now();
17770
- const expiresAt = now + COMPARTMENT_LEASE_TTL_MS;
17771
- const result = db.prepare(`UPDATE compartment_state_lease
17772
- SET expires_at = ?, acquired_at = ?
17773
- WHERE session_id = ? AND holder_id = ? AND expires_at > ?`).run(expiresAt, now, sessionId, holderId, now);
17774
- return result.changes === 1;
17775
- }
17776
- function releaseCompartmentLease(db, sessionId, holderId) {
17777
- db.prepare("DELETE FROM compartment_state_lease WHERE session_id = ? AND holder_id = ?").run(sessionId, holderId);
17778
- }
17779
- function isCompartmentLeaseHeld(db, sessionId, holderId) {
17780
- const row = db.prepare("SELECT 1 FROM compartment_state_lease WHERE session_id = ? AND holder_id = ? AND expires_at > ?").get(sessionId, holderId, Date.now());
17781
- return row != null;
17782
- }
17783
-
17784
- // ../plugin/src/features/magic-context/compartment-storage.ts
17785
- var insertCompartmentStatements = new WeakMap;
17786
- var insertFactStatements = new WeakMap;
17787
- function getInsertCompartmentStatement(db) {
17788
- let stmt = insertCompartmentStatements.get(db);
17789
- if (!stmt) {
17790
- stmt = db.prepare("INSERT INTO compartments (session_id, sequence, start_message, end_message, start_message_id, end_message_id, title, content, p1, p2, p3, p4, importance, episode_type, legacy, created_at, harness) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
17791
- insertCompartmentStatements.set(db, stmt);
17792
- }
17793
- return stmt;
17794
- }
17795
- function isStringOrNullish(v) {
17796
- return v === null || v === undefined || typeof v === "string";
17797
- }
17798
- function isNumberOrNullish(v) {
17799
- return v === null || v === undefined || typeof v === "number";
17800
- }
17801
- function isCompartmentRow(row) {
17802
- if (row === null || typeof row !== "object")
17803
- return false;
17804
- const candidate = row;
17805
- return typeof candidate.id === "number" && typeof candidate.session_id === "string" && typeof candidate.sequence === "number" && typeof candidate.start_message === "number" && typeof candidate.end_message === "number" && typeof candidate.start_message_id === "string" && typeof candidate.end_message_id === "string" && typeof candidate.title === "string" && typeof candidate.content === "string" && isStringOrNullish(candidate.p1) && isStringOrNullish(candidate.p2) && isStringOrNullish(candidate.p3) && isStringOrNullish(candidate.p4) && isNumberOrNullish(candidate.importance) && isStringOrNullish(candidate.episode_type) && isNumberOrNullish(candidate.legacy) && typeof candidate.created_at === "number";
17806
- }
17807
- function insertCompartmentRows(db, sessionId, compartments, now) {
17808
- const stmt = getInsertCompartmentStatement(db);
17809
- for (const compartment of compartments) {
17810
- const hasTiers = typeof compartment.p1 === "string" && compartment.p1.length > 0;
17811
- stmt.run(sessionId, compartment.sequence, compartment.startMessage, compartment.endMessage, compartment.startMessageId, compartment.endMessageId, compartment.title, compartment.content, compartment.p1 ?? null, compartment.p2 ?? null, compartment.p3 ?? null, compartment.p4 ?? null, typeof compartment.importance === "number" ? compartment.importance : 50, compartment.episodeType ?? null, hasTiers ? 0 : 1, now, getHarness());
17812
- }
17813
- }
17814
- function toCompartment(row) {
17815
- return {
17816
- id: row.id,
17817
- sessionId: row.session_id,
17818
- sequence: row.sequence,
17819
- startMessage: row.start_message,
17820
- endMessage: row.end_message,
17821
- startMessageId: row.start_message_id,
17822
- endMessageId: row.end_message_id,
17823
- title: row.title,
17824
- content: row.content,
17825
- p1: row.p1 ?? null,
17826
- p2: row.p2 ?? null,
17827
- p3: row.p3 ?? null,
17828
- p4: row.p4 ?? null,
17829
- importance: typeof row.importance === "number" ? row.importance : 50,
17830
- episodeType: row.episode_type ?? null,
17831
- legacy: typeof row.legacy === "number" ? row.legacy : 0,
17832
- createdAt: row.created_at
17833
- };
17834
- }
17835
- function getCompartments(db, sessionId) {
17836
- const rows = db.prepare("SELECT * FROM compartments WHERE session_id = ? ORDER BY sequence ASC").all(sessionId).filter(isCompartmentRow);
17837
- return rows.map(toCompartment);
17838
- }
17839
- function getLastCompartmentEndMessage(db, sessionId) {
17840
- const row = db.prepare("SELECT MAX(end_message) as max_end FROM compartments WHERE session_id = ?").get(sessionId);
17841
- return row?.max_end ?? -1;
17842
- }
17843
- function getLastCompartmentEndMessageId(db, sessionId) {
17844
- const row = db.prepare("SELECT end_message_id FROM compartments WHERE session_id = ? ORDER BY sequence DESC LIMIT 1").get(sessionId);
17845
- const id = row?.end_message_id;
17846
- return id && id.length > 0 ? id : null;
17847
- }
17848
- function getCompartmentsByEndMessageId(db, sessionId, endMessageId) {
17849
- const rows = db.prepare("SELECT * FROM compartments WHERE session_id = ? AND end_message_id = ? ORDER BY sequence ASC").all(sessionId, endMessageId).filter(isCompartmentRow);
17850
- return rows.map(toCompartment);
17851
- }
17852
- function appendCompartments(db, sessionId, compartments) {
17853
- if (compartments.length === 0)
17854
- return;
17855
- const now = Date.now();
17856
- db.transaction(() => {
17857
- insertCompartmentRows(db, sessionId, compartments, now);
17858
- })();
17859
- }
17860
- function saveRecompStagingPass(db, sessionId, passNumber, compartments, facts) {
17861
- const now = Date.now();
17862
- db.transaction(() => {
17863
- db.prepare("DELETE FROM recomp_facts WHERE session_id = ?").run(sessionId);
17864
- const compartmentStmt = db.prepare("INSERT OR REPLACE INTO recomp_compartments (session_id, sequence, start_message, end_message, start_message_id, end_message_id, title, content, p1, p2, p3, p4, importance, episode_type, pass_number, created_at, harness) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
17865
- for (const c of compartments) {
17866
- compartmentStmt.run(sessionId, c.sequence, c.startMessage, c.endMessage, c.startMessageId, c.endMessageId, c.title, c.content, c.p1 ?? null, c.p2 ?? null, c.p3 ?? null, c.p4 ?? null, typeof c.importance === "number" ? c.importance : 50, c.episodeType ?? null, passNumber, now, getHarness());
17867
- }
17868
- const factStmt = db.prepare("INSERT INTO recomp_facts (session_id, category, content, pass_number, created_at, harness) VALUES (?, ?, ?, ?, ?, ?)");
17869
- for (const f of facts) {
17870
- factStmt.run(sessionId, f.category, f.content, passNumber, now, getHarness());
17871
- }
17872
- })();
17873
- }
17874
- function getRecompStaging(db, sessionId) {
17875
- const compartmentRows = db.prepare("SELECT * FROM recomp_compartments WHERE session_id = ? ORDER BY sequence ASC").all(sessionId).filter(isRecompCompartmentRow);
17876
- if (compartmentRows.length === 0)
17877
- return null;
17878
- const compartments = compartmentRows.map((row) => ({
17879
- sequence: row.sequence,
17880
- startMessage: row.start_message,
17881
- endMessage: row.end_message,
17882
- startMessageId: row.start_message_id,
17883
- endMessageId: row.end_message_id,
17884
- title: row.title,
17885
- content: row.content,
17886
- p1: row.p1 ?? null,
17887
- p2: row.p2 ?? null,
17888
- p3: row.p3 ?? null,
17889
- p4: row.p4 ?? null,
17890
- importance: typeof row.importance === "number" ? row.importance : 50,
17891
- episodeType: row.episode_type ?? null
17892
- }));
17893
- const factRows = db.prepare("SELECT category, content FROM recomp_facts WHERE session_id = ?").all(sessionId).filter(isRecompFactRow);
17894
- const maxPass = compartmentRows.reduce((m, r) => Math.max(m, r.pass_number), 0);
17895
- const lastEnd = compartmentRows[compartmentRows.length - 1]?.end_message ?? 0;
17896
- return {
17897
- compartments,
17898
- facts: factRows,
17899
- passCount: maxPass,
17900
- lastEndMessage: lastEnd
17901
- };
17902
- }
17903
- function clearRecompStaging(db, sessionId) {
17904
- db.transaction(() => {
17905
- db.prepare("DELETE FROM recomp_compartments WHERE session_id = ?").run(sessionId);
17906
- db.prepare("DELETE FROM recomp_facts WHERE session_id = ?").run(sessionId);
17907
- try {
17908
- db.prepare("UPDATE session_meta SET recomp_partial_range_start = 0, recomp_partial_range_end = 0 WHERE session_id = ?").run(sessionId);
17909
- } catch {}
17910
- })();
17911
- }
17912
- function getRecompPartialRange(db, sessionId) {
17913
- try {
17914
- const row = db.prepare("SELECT recomp_partial_range_start AS start, recomp_partial_range_end AS end FROM session_meta WHERE session_id = ?").get(sessionId);
17915
- const start = typeof row?.start === "number" ? row.start : 0;
17916
- const end = typeof row?.end === "number" ? row.end : 0;
17917
- if (start <= 0 || end <= 0)
17918
- return null;
17919
- return { start, end };
17920
- } catch {
17921
- return null;
17922
- }
17923
- }
17924
- function setRecompPartialRange(db, sessionId, range) {
17925
- const start = range ? range.start : 0;
17926
- const end = range ? range.end : 0;
17927
- db.prepare("INSERT OR IGNORE INTO session_meta (session_id) VALUES (?)").run(sessionId);
17928
- db.prepare("UPDATE session_meta SET recomp_partial_range_start = ?, recomp_partial_range_end = ? WHERE session_id = ?").run(start, end, sessionId);
17929
- }
17930
- function isRecompCompartmentRow(row) {
17931
- if (row === null || typeof row !== "object")
17932
- return false;
17933
- const candidate = row;
17934
- return typeof candidate.id === "number" && typeof candidate.session_id === "string" && typeof candidate.sequence === "number" && typeof candidate.start_message === "number" && typeof candidate.end_message === "number" && typeof candidate.start_message_id === "string" && typeof candidate.end_message_id === "string" && typeof candidate.title === "string" && typeof candidate.content === "string" && isStringOrNullish(candidate.p1) && isStringOrNullish(candidate.p2) && isStringOrNullish(candidate.p3) && isStringOrNullish(candidate.p4) && isNumberOrNullish(candidate.importance) && isStringOrNullish(candidate.episode_type) && typeof candidate.pass_number === "number" && typeof candidate.created_at === "number";
17935
- }
17936
- function isRecompFactRow(row) {
17937
- if (row === null || typeof row !== "object")
17938
- return false;
17939
- const candidate = row;
17940
- return typeof candidate.category === "string" && typeof candidate.content === "string";
17941
- }
17942
- function escapeXmlAttr(s) {
17943
- return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&apos;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
17944
- }
17945
- function escapeXmlContent(s) {
17946
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
17947
- }
17948
17919
  // ../plugin/src/features/magic-context/project-docs-hash.ts
17949
17920
  import { createHash as createHash6 } from "node:crypto";
17950
17921
  import { lstatSync, readFileSync as readFileSync5, statSync as statSync4 } from "node:fs";
@@ -18321,7 +18292,7 @@ function normalizedQueryHash(query) {
18321
18292
  return createHash7("sha256").update(normalized).digest("hex");
18322
18293
  }
18323
18294
  var MEASUREMENT_CORPUS_SESSION_ROW_CAP = 2000;
18324
- function recordEmbeddingMeasurement(db, input) {
18295
+ function recordEmbeddingMeasurement(db, input, cap = MEASUREMENT_CORPUS_SESSION_ROW_CAP) {
18325
18296
  const queryTextHash = normalizedQueryHash(input.queryText);
18326
18297
  const dedupKey = queryTextHash;
18327
18298
  const result = db.prepare(`INSERT OR IGNORE INTO embedding_measurement_corpus
@@ -18333,7 +18304,7 @@ function recordEmbeddingMeasurement(db, input) {
18333
18304
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(input.sessionId, input.projectPath, dedupKey, input.cohortKey, queryTextHash, JSON.stringify(input.primaryResultIds.slice(0, 10)), JSON.stringify(input.shadowResultIds.slice(0, 10)), input.primaryLatencyMs, input.shadowLatencyMs, input.primaryFailed ? 1 : 0, input.shadowFailed ? 1 : 0, input.primaryModelId, input.shadowModelId, input.primaryFingerprint, input.shadowFingerprint, input.primaryEpoch, input.shadowEpoch, input.corpusHash, JSON.stringify(input.coverage), Date.now());
18334
18305
  if (result.changes > 0) {
18335
18306
  const rowCount = db.prepare("SELECT COUNT(*) AS count FROM embedding_measurement_corpus WHERE session_id = ?").get(input.sessionId).count;
18336
- const overflow = rowCount - MEASUREMENT_CORPUS_SESSION_ROW_CAP;
18307
+ const overflow = rowCount - cap;
18337
18308
  if (overflow > 0) {
18338
18309
  db.prepare(`DELETE FROM embedding_measurement_corpus
18339
18310
  WHERE session_id = ?
@@ -21312,523 +21283,523 @@ import { homedir as homedir4 } from "node:os";
21312
21283
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/external.js
21313
21284
  var exports_external = {};
21314
21285
  __export(exports_external, {
21315
- xor: () => xor,
21316
- xid: () => xid2,
21317
- void: () => _void2,
21318
- uuidv7: () => uuidv7,
21319
- uuidv6: () => uuidv6,
21320
- uuidv4: () => uuidv4,
21321
- uuid: () => uuid2,
21322
- util: () => exports_util,
21323
- url: () => url,
21324
- uppercase: () => _uppercase,
21325
- unknown: () => unknown,
21326
- union: () => union,
21327
- undefined: () => _undefined3,
21328
- ulid: () => ulid2,
21329
- uint64: () => uint64,
21330
- uint32: () => uint32,
21331
- tuple: () => tuple,
21332
- trim: () => _trim,
21333
- treeifyError: () => treeifyError,
21334
- transform: () => transform,
21335
- toUpperCase: () => _toUpperCase,
21336
- toLowerCase: () => _toLowerCase,
21337
- toJSONSchema: () => toJSONSchema,
21338
- templateLiteral: () => templateLiteral,
21339
- symbol: () => symbol,
21340
- superRefine: () => superRefine,
21341
- success: () => success,
21342
- stringbool: () => stringbool,
21343
- stringFormat: () => stringFormat,
21344
- string: () => string2,
21345
- strictObject: () => strictObject,
21346
- startsWith: () => _startsWith,
21347
- slugify: () => _slugify,
21348
- size: () => _size,
21349
- setErrorMap: () => setErrorMap,
21350
- set: () => set,
21351
- safeParseAsync: () => safeParseAsync2,
21352
- safeParse: () => safeParse2,
21353
- safeEncodeAsync: () => safeEncodeAsync2,
21354
- safeEncode: () => safeEncode2,
21355
- safeDecodeAsync: () => safeDecodeAsync2,
21356
- safeDecode: () => safeDecode2,
21357
- registry: () => registry,
21358
- regexes: () => exports_regexes,
21359
- regex: () => _regex,
21360
- refine: () => refine,
21361
- record: () => record,
21362
- readonly: () => readonly,
21363
- property: () => _property,
21364
- promise: () => promise,
21365
- prettifyError: () => prettifyError,
21366
- preprocess: () => preprocess,
21367
- prefault: () => prefault,
21368
- positive: () => _positive,
21369
- pipe: () => pipe,
21370
- partialRecord: () => partialRecord,
21371
- parseAsync: () => parseAsync2,
21372
- parse: () => parse3,
21373
- overwrite: () => _overwrite,
21374
- optional: () => optional,
21375
- object: () => object,
21376
- number: () => number2,
21377
- nullish: () => nullish2,
21378
- nullable: () => nullable,
21379
- null: () => _null3,
21380
- normalize: () => _normalize,
21381
- nonpositive: () => _nonpositive,
21382
- nonoptional: () => nonoptional,
21383
- nonnegative: () => _nonnegative,
21384
- never: () => never,
21385
- negative: () => _negative,
21386
- nativeEnum: () => nativeEnum,
21387
- nanoid: () => nanoid2,
21388
- nan: () => nan,
21389
- multipleOf: () => _multipleOf,
21390
- minSize: () => _minSize,
21391
- minLength: () => _minLength,
21392
- mime: () => _mime,
21393
- meta: () => meta2,
21394
- maxSize: () => _maxSize,
21395
- maxLength: () => _maxLength,
21396
- map: () => map,
21397
- mac: () => mac2,
21398
- lte: () => _lte,
21399
- lt: () => _lt,
21400
- lowercase: () => _lowercase,
21401
- looseRecord: () => looseRecord,
21402
- looseObject: () => looseObject,
21403
- locales: () => exports_locales,
21404
- literal: () => literal,
21405
- length: () => _length,
21406
- lazy: () => lazy,
21407
- ksuid: () => ksuid2,
21408
- keyof: () => keyof,
21409
- jwt: () => jwt,
21410
- json: () => json,
21411
- iso: () => exports_iso,
21412
- ipv6: () => ipv62,
21413
- ipv4: () => ipv42,
21414
- invertCodec: () => invertCodec,
21415
- intersection: () => intersection,
21416
- int64: () => int64,
21417
- int32: () => int32,
21418
- int: () => int,
21419
- instanceof: () => _instanceof,
21420
- includes: () => _includes,
21421
- httpUrl: () => httpUrl,
21422
- hostname: () => hostname2,
21423
- hex: () => hex2,
21424
- hash: () => hash,
21425
- guid: () => guid2,
21426
- gte: () => _gte,
21427
- gt: () => _gt,
21428
- globalRegistry: () => globalRegistry,
21429
- getErrorMap: () => getErrorMap,
21430
- function: () => _function,
21431
- fromJSONSchema: () => fromJSONSchema,
21432
- formatError: () => formatError,
21433
- float64: () => float64,
21434
- float32: () => float32,
21435
- flattenError: () => flattenError,
21436
- file: () => file,
21437
- exactOptional: () => exactOptional,
21438
- enum: () => _enum2,
21439
- endsWith: () => _endsWith,
21440
- encodeAsync: () => encodeAsync2,
21441
- encode: () => encode2,
21442
- emoji: () => emoji2,
21443
- email: () => email2,
21444
- e164: () => e1642,
21445
- discriminatedUnion: () => discriminatedUnion,
21446
- describe: () => describe2,
21447
- decodeAsync: () => decodeAsync2,
21448
- decode: () => decode2,
21449
- date: () => date3,
21450
- custom: () => custom,
21451
- cuid2: () => cuid22,
21452
- cuid: () => cuid3,
21453
- core: () => exports_core2,
21454
- config: () => config,
21455
- coerce: () => exports_coerce,
21456
- codec: () => codec,
21457
- clone: () => clone,
21458
- cidrv6: () => cidrv62,
21459
- cidrv4: () => cidrv42,
21460
- check: () => check,
21461
- catch: () => _catch2,
21462
- boolean: () => boolean2,
21463
- bigint: () => bigint2,
21464
- base64url: () => base64url2,
21465
- base64: () => base642,
21466
- array: () => array,
21467
- any: () => any,
21468
- _function: () => _function,
21469
- _default: () => _default2,
21470
- _ZodString: () => _ZodString,
21471
- ZodXor: () => ZodXor,
21472
- ZodXID: () => ZodXID,
21473
- ZodVoid: () => ZodVoid,
21474
- ZodUnknown: () => ZodUnknown,
21475
- ZodUnion: () => ZodUnion,
21476
- ZodUndefined: () => ZodUndefined,
21477
- ZodUUID: () => ZodUUID,
21478
- ZodURL: () => ZodURL,
21479
- ZodULID: () => ZodULID,
21480
- ZodType: () => ZodType,
21481
- ZodTuple: () => ZodTuple,
21482
- ZodTransform: () => ZodTransform,
21483
- ZodTemplateLiteral: () => ZodTemplateLiteral,
21484
- ZodSymbol: () => ZodSymbol,
21485
- ZodSuccess: () => ZodSuccess,
21486
- ZodStringFormat: () => ZodStringFormat,
21487
- ZodString: () => ZodString,
21488
- ZodSet: () => ZodSet,
21489
- ZodRecord: () => ZodRecord,
21490
- ZodRealError: () => ZodRealError,
21491
- ZodReadonly: () => ZodReadonly,
21492
- ZodPromise: () => ZodPromise,
21493
- ZodPreprocess: () => ZodPreprocess,
21494
- ZodPrefault: () => ZodPrefault,
21495
- ZodPipe: () => ZodPipe,
21496
- ZodOptional: () => ZodOptional,
21497
- ZodObject: () => ZodObject,
21498
- ZodNumberFormat: () => ZodNumberFormat,
21499
- ZodNumber: () => ZodNumber,
21500
- ZodNullable: () => ZodNullable,
21501
- ZodNull: () => ZodNull,
21502
- ZodNonOptional: () => ZodNonOptional,
21503
- ZodNever: () => ZodNever,
21504
- ZodNanoID: () => ZodNanoID,
21505
- ZodNaN: () => ZodNaN,
21506
- ZodMap: () => ZodMap,
21507
- ZodMAC: () => ZodMAC,
21508
- ZodLiteral: () => ZodLiteral,
21509
- ZodLazy: () => ZodLazy,
21510
- ZodKSUID: () => ZodKSUID,
21511
- ZodJWT: () => ZodJWT,
21512
- ZodIssueCode: () => ZodIssueCode,
21513
- ZodIntersection: () => ZodIntersection,
21514
- ZodISOTime: () => ZodISOTime,
21515
- ZodISODuration: () => ZodISODuration,
21516
- ZodISODateTime: () => ZodISODateTime,
21517
- ZodISODate: () => ZodISODate,
21518
- ZodIPv6: () => ZodIPv6,
21519
- ZodIPv4: () => ZodIPv4,
21520
- ZodGUID: () => ZodGUID,
21521
- ZodFunction: () => ZodFunction,
21522
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
21523
- ZodFile: () => ZodFile,
21524
- ZodExactOptional: () => ZodExactOptional,
21525
- ZodError: () => ZodError,
21526
- ZodEnum: () => ZodEnum,
21527
- ZodEmoji: () => ZodEmoji,
21528
- ZodEmail: () => ZodEmail,
21529
- ZodE164: () => ZodE164,
21530
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
21531
- ZodDefault: () => ZodDefault,
21532
- ZodDate: () => ZodDate,
21533
- ZodCustomStringFormat: () => ZodCustomStringFormat,
21534
- ZodCustom: () => ZodCustom,
21535
- ZodCodec: () => ZodCodec,
21536
- ZodCatch: () => ZodCatch,
21537
- ZodCUID2: () => ZodCUID2,
21538
- ZodCUID: () => ZodCUID,
21539
- ZodCIDRv6: () => ZodCIDRv6,
21540
- ZodCIDRv4: () => ZodCIDRv4,
21541
- ZodBoolean: () => ZodBoolean,
21542
- ZodBigIntFormat: () => ZodBigIntFormat,
21543
- ZodBigInt: () => ZodBigInt,
21544
- ZodBase64URL: () => ZodBase64URL,
21545
- ZodBase64: () => ZodBase64,
21546
- ZodArray: () => ZodArray,
21547
- ZodAny: () => ZodAny,
21548
- TimePrecision: () => TimePrecision,
21549
- NEVER: () => NEVER,
21550
- $output: () => $output,
21286
+ $brand: () => $brand,
21551
21287
  $input: () => $input,
21552
- $brand: () => $brand
21288
+ $output: () => $output,
21289
+ NEVER: () => NEVER,
21290
+ TimePrecision: () => TimePrecision,
21291
+ ZodAny: () => ZodAny,
21292
+ ZodArray: () => ZodArray,
21293
+ ZodBase64: () => ZodBase64,
21294
+ ZodBase64URL: () => ZodBase64URL,
21295
+ ZodBigInt: () => ZodBigInt,
21296
+ ZodBigIntFormat: () => ZodBigIntFormat,
21297
+ ZodBoolean: () => ZodBoolean,
21298
+ ZodCIDRv4: () => ZodCIDRv4,
21299
+ ZodCIDRv6: () => ZodCIDRv6,
21300
+ ZodCUID: () => ZodCUID,
21301
+ ZodCUID2: () => ZodCUID2,
21302
+ ZodCatch: () => ZodCatch,
21303
+ ZodCodec: () => ZodCodec,
21304
+ ZodCustom: () => ZodCustom,
21305
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
21306
+ ZodDate: () => ZodDate,
21307
+ ZodDefault: () => ZodDefault,
21308
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
21309
+ ZodE164: () => ZodE164,
21310
+ ZodEmail: () => ZodEmail,
21311
+ ZodEmoji: () => ZodEmoji,
21312
+ ZodEnum: () => ZodEnum,
21313
+ ZodError: () => ZodError,
21314
+ ZodExactOptional: () => ZodExactOptional,
21315
+ ZodFile: () => ZodFile,
21316
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
21317
+ ZodFunction: () => ZodFunction,
21318
+ ZodGUID: () => ZodGUID,
21319
+ ZodIPv4: () => ZodIPv4,
21320
+ ZodIPv6: () => ZodIPv6,
21321
+ ZodISODate: () => ZodISODate,
21322
+ ZodISODateTime: () => ZodISODateTime,
21323
+ ZodISODuration: () => ZodISODuration,
21324
+ ZodISOTime: () => ZodISOTime,
21325
+ ZodIntersection: () => ZodIntersection,
21326
+ ZodIssueCode: () => ZodIssueCode,
21327
+ ZodJWT: () => ZodJWT,
21328
+ ZodKSUID: () => ZodKSUID,
21329
+ ZodLazy: () => ZodLazy,
21330
+ ZodLiteral: () => ZodLiteral,
21331
+ ZodMAC: () => ZodMAC,
21332
+ ZodMap: () => ZodMap,
21333
+ ZodNaN: () => ZodNaN,
21334
+ ZodNanoID: () => ZodNanoID,
21335
+ ZodNever: () => ZodNever,
21336
+ ZodNonOptional: () => ZodNonOptional,
21337
+ ZodNull: () => ZodNull,
21338
+ ZodNullable: () => ZodNullable,
21339
+ ZodNumber: () => ZodNumber,
21340
+ ZodNumberFormat: () => ZodNumberFormat,
21341
+ ZodObject: () => ZodObject,
21342
+ ZodOptional: () => ZodOptional,
21343
+ ZodPipe: () => ZodPipe,
21344
+ ZodPrefault: () => ZodPrefault,
21345
+ ZodPreprocess: () => ZodPreprocess,
21346
+ ZodPromise: () => ZodPromise,
21347
+ ZodReadonly: () => ZodReadonly,
21348
+ ZodRealError: () => ZodRealError,
21349
+ ZodRecord: () => ZodRecord,
21350
+ ZodSet: () => ZodSet,
21351
+ ZodString: () => ZodString,
21352
+ ZodStringFormat: () => ZodStringFormat,
21353
+ ZodSuccess: () => ZodSuccess,
21354
+ ZodSymbol: () => ZodSymbol,
21355
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
21356
+ ZodTransform: () => ZodTransform,
21357
+ ZodTuple: () => ZodTuple,
21358
+ ZodType: () => ZodType,
21359
+ ZodULID: () => ZodULID,
21360
+ ZodURL: () => ZodURL,
21361
+ ZodUUID: () => ZodUUID,
21362
+ ZodUndefined: () => ZodUndefined,
21363
+ ZodUnion: () => ZodUnion,
21364
+ ZodUnknown: () => ZodUnknown,
21365
+ ZodVoid: () => ZodVoid,
21366
+ ZodXID: () => ZodXID,
21367
+ ZodXor: () => ZodXor,
21368
+ _ZodString: () => _ZodString,
21369
+ _default: () => _default2,
21370
+ _function: () => _function,
21371
+ any: () => any,
21372
+ array: () => array,
21373
+ base64: () => base642,
21374
+ base64url: () => base64url2,
21375
+ bigint: () => bigint2,
21376
+ boolean: () => boolean2,
21377
+ catch: () => _catch2,
21378
+ check: () => check,
21379
+ cidrv4: () => cidrv42,
21380
+ cidrv6: () => cidrv62,
21381
+ clone: () => clone,
21382
+ codec: () => codec,
21383
+ coerce: () => exports_coerce,
21384
+ config: () => config,
21385
+ core: () => exports_core2,
21386
+ cuid: () => cuid3,
21387
+ cuid2: () => cuid22,
21388
+ custom: () => custom,
21389
+ date: () => date3,
21390
+ decode: () => decode2,
21391
+ decodeAsync: () => decodeAsync2,
21392
+ describe: () => describe2,
21393
+ discriminatedUnion: () => discriminatedUnion,
21394
+ e164: () => e1642,
21395
+ email: () => email2,
21396
+ emoji: () => emoji2,
21397
+ encode: () => encode2,
21398
+ encodeAsync: () => encodeAsync2,
21399
+ endsWith: () => _endsWith,
21400
+ enum: () => _enum2,
21401
+ exactOptional: () => exactOptional,
21402
+ file: () => file,
21403
+ flattenError: () => flattenError,
21404
+ float32: () => float32,
21405
+ float64: () => float64,
21406
+ formatError: () => formatError,
21407
+ fromJSONSchema: () => fromJSONSchema,
21408
+ function: () => _function,
21409
+ getErrorMap: () => getErrorMap,
21410
+ globalRegistry: () => globalRegistry,
21411
+ gt: () => _gt,
21412
+ gte: () => _gte,
21413
+ guid: () => guid2,
21414
+ hash: () => hash,
21415
+ hex: () => hex2,
21416
+ hostname: () => hostname2,
21417
+ httpUrl: () => httpUrl,
21418
+ includes: () => _includes,
21419
+ instanceof: () => _instanceof,
21420
+ int: () => int,
21421
+ int32: () => int32,
21422
+ int64: () => int64,
21423
+ intersection: () => intersection,
21424
+ invertCodec: () => invertCodec,
21425
+ ipv4: () => ipv42,
21426
+ ipv6: () => ipv62,
21427
+ iso: () => exports_iso,
21428
+ json: () => json,
21429
+ jwt: () => jwt,
21430
+ keyof: () => keyof,
21431
+ ksuid: () => ksuid2,
21432
+ lazy: () => lazy,
21433
+ length: () => _length,
21434
+ literal: () => literal,
21435
+ locales: () => exports_locales,
21436
+ looseObject: () => looseObject,
21437
+ looseRecord: () => looseRecord,
21438
+ lowercase: () => _lowercase,
21439
+ lt: () => _lt,
21440
+ lte: () => _lte,
21441
+ mac: () => mac2,
21442
+ map: () => map,
21443
+ maxLength: () => _maxLength,
21444
+ maxSize: () => _maxSize,
21445
+ meta: () => meta2,
21446
+ mime: () => _mime,
21447
+ minLength: () => _minLength,
21448
+ minSize: () => _minSize,
21449
+ multipleOf: () => _multipleOf,
21450
+ nan: () => nan,
21451
+ nanoid: () => nanoid2,
21452
+ nativeEnum: () => nativeEnum,
21453
+ negative: () => _negative,
21454
+ never: () => never,
21455
+ nonnegative: () => _nonnegative,
21456
+ nonoptional: () => nonoptional,
21457
+ nonpositive: () => _nonpositive,
21458
+ normalize: () => _normalize,
21459
+ null: () => _null3,
21460
+ nullable: () => nullable,
21461
+ nullish: () => nullish2,
21462
+ number: () => number2,
21463
+ object: () => object,
21464
+ optional: () => optional,
21465
+ overwrite: () => _overwrite,
21466
+ parse: () => parse3,
21467
+ parseAsync: () => parseAsync2,
21468
+ partialRecord: () => partialRecord,
21469
+ pipe: () => pipe,
21470
+ positive: () => _positive,
21471
+ prefault: () => prefault,
21472
+ preprocess: () => preprocess,
21473
+ prettifyError: () => prettifyError,
21474
+ promise: () => promise,
21475
+ property: () => _property,
21476
+ readonly: () => readonly,
21477
+ record: () => record,
21478
+ refine: () => refine,
21479
+ regex: () => _regex,
21480
+ regexes: () => exports_regexes,
21481
+ registry: () => registry,
21482
+ safeDecode: () => safeDecode2,
21483
+ safeDecodeAsync: () => safeDecodeAsync2,
21484
+ safeEncode: () => safeEncode2,
21485
+ safeEncodeAsync: () => safeEncodeAsync2,
21486
+ safeParse: () => safeParse2,
21487
+ safeParseAsync: () => safeParseAsync2,
21488
+ set: () => set,
21489
+ setErrorMap: () => setErrorMap,
21490
+ size: () => _size,
21491
+ slugify: () => _slugify,
21492
+ startsWith: () => _startsWith,
21493
+ strictObject: () => strictObject,
21494
+ string: () => string2,
21495
+ stringFormat: () => stringFormat,
21496
+ stringbool: () => stringbool,
21497
+ success: () => success,
21498
+ superRefine: () => superRefine,
21499
+ symbol: () => symbol,
21500
+ templateLiteral: () => templateLiteral,
21501
+ toJSONSchema: () => toJSONSchema,
21502
+ toLowerCase: () => _toLowerCase,
21503
+ toUpperCase: () => _toUpperCase,
21504
+ transform: () => transform,
21505
+ treeifyError: () => treeifyError,
21506
+ trim: () => _trim,
21507
+ tuple: () => tuple,
21508
+ uint32: () => uint32,
21509
+ uint64: () => uint64,
21510
+ ulid: () => ulid2,
21511
+ undefined: () => _undefined3,
21512
+ union: () => union,
21513
+ unknown: () => unknown,
21514
+ uppercase: () => _uppercase,
21515
+ url: () => url,
21516
+ util: () => exports_util,
21517
+ uuid: () => uuid2,
21518
+ uuidv4: () => uuidv4,
21519
+ uuidv6: () => uuidv6,
21520
+ uuidv7: () => uuidv7,
21521
+ void: () => _void2,
21522
+ xid: () => xid2,
21523
+ xor: () => xor
21553
21524
  });
21554
21525
 
21555
21526
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/index.js
21556
21527
  var exports_core2 = {};
21557
21528
  __export(exports_core2, {
21558
- version: () => version,
21559
- util: () => exports_util,
21560
- treeifyError: () => treeifyError,
21561
- toJSONSchema: () => toJSONSchema,
21562
- toDotPath: () => toDotPath,
21563
- safeParseAsync: () => safeParseAsync,
21564
- safeParse: () => safeParse,
21565
- safeEncodeAsync: () => safeEncodeAsync,
21566
- safeEncode: () => safeEncode,
21567
- safeDecodeAsync: () => safeDecodeAsync,
21568
- safeDecode: () => safeDecode,
21569
- registry: () => registry,
21570
- regexes: () => exports_regexes,
21571
- process: () => process2,
21572
- prettifyError: () => prettifyError,
21573
- parseAsync: () => parseAsync,
21574
- parse: () => parse,
21575
- meta: () => meta,
21576
- locales: () => exports_locales,
21577
- isValidJWT: () => isValidJWT,
21578
- isValidBase64URL: () => isValidBase64URL,
21579
- isValidBase64: () => isValidBase64,
21580
- initializeContext: () => initializeContext,
21581
- globalRegistry: () => globalRegistry,
21582
- globalConfig: () => globalConfig,
21583
- formatError: () => formatError,
21584
- flattenError: () => flattenError,
21585
- finalize: () => finalize,
21586
- extractDefs: () => extractDefs,
21587
- encodeAsync: () => encodeAsync,
21588
- encode: () => encode,
21589
- describe: () => describe,
21590
- decodeAsync: () => decodeAsync,
21591
- decode: () => decode,
21592
- createToJSONSchemaMethod: () => createToJSONSchemaMethod,
21593
- createStandardJSONSchemaMethod: () => createStandardJSONSchemaMethod,
21594
- config: () => config,
21595
- clone: () => clone,
21596
- _xor: () => _xor,
21597
- _xid: () => _xid,
21598
- _void: () => _void,
21599
- _uuidv7: () => _uuidv7,
21600
- _uuidv6: () => _uuidv6,
21601
- _uuidv4: () => _uuidv4,
21602
- _uuid: () => _uuid,
21603
- _url: () => _url,
21604
- _uppercase: () => _uppercase,
21605
- _unknown: () => _unknown,
21606
- _union: () => _union,
21607
- _undefined: () => _undefined2,
21608
- _ulid: () => _ulid,
21609
- _uint64: () => _uint64,
21610
- _uint32: () => _uint32,
21611
- _tuple: () => _tuple,
21612
- _trim: () => _trim,
21613
- _transform: () => _transform,
21614
- _toUpperCase: () => _toUpperCase,
21615
- _toLowerCase: () => _toLowerCase,
21616
- _templateLiteral: () => _templateLiteral,
21617
- _symbol: () => _symbol,
21618
- _superRefine: () => _superRefine,
21619
- _success: () => _success,
21620
- _stringbool: () => _stringbool,
21621
- _stringFormat: () => _stringFormat,
21622
- _string: () => _string,
21623
- _startsWith: () => _startsWith,
21624
- _slugify: () => _slugify,
21625
- _size: () => _size,
21626
- _set: () => _set,
21627
- _safeParseAsync: () => _safeParseAsync,
21628
- _safeParse: () => _safeParse,
21629
- _safeEncodeAsync: () => _safeEncodeAsync,
21630
- _safeEncode: () => _safeEncode,
21631
- _safeDecodeAsync: () => _safeDecodeAsync,
21632
- _safeDecode: () => _safeDecode,
21633
- _regex: () => _regex,
21634
- _refine: () => _refine,
21635
- _record: () => _record,
21636
- _readonly: () => _readonly,
21637
- _property: () => _property,
21638
- _promise: () => _promise,
21639
- _positive: () => _positive,
21640
- _pipe: () => _pipe,
21641
- _parseAsync: () => _parseAsync,
21642
- _parse: () => _parse,
21643
- _overwrite: () => _overwrite,
21644
- _optional: () => _optional,
21645
- _number: () => _number,
21646
- _nullable: () => _nullable,
21647
- _null: () => _null2,
21648
- _normalize: () => _normalize,
21649
- _nonpositive: () => _nonpositive,
21650
- _nonoptional: () => _nonoptional,
21651
- _nonnegative: () => _nonnegative,
21652
- _never: () => _never,
21653
- _negative: () => _negative,
21654
- _nativeEnum: () => _nativeEnum,
21655
- _nanoid: () => _nanoid,
21656
- _nan: () => _nan,
21657
- _multipleOf: () => _multipleOf,
21658
- _minSize: () => _minSize,
21659
- _minLength: () => _minLength,
21660
- _min: () => _gte,
21661
- _mime: () => _mime,
21662
- _maxSize: () => _maxSize,
21663
- _maxLength: () => _maxLength,
21664
- _max: () => _lte,
21665
- _map: () => _map,
21666
- _mac: () => _mac,
21667
- _lte: () => _lte,
21668
- _lt: () => _lt,
21669
- _lowercase: () => _lowercase,
21670
- _literal: () => _literal,
21671
- _length: () => _length,
21672
- _lazy: () => _lazy,
21673
- _ksuid: () => _ksuid,
21674
- _jwt: () => _jwt,
21675
- _isoTime: () => _isoTime,
21676
- _isoDuration: () => _isoDuration,
21677
- _isoDateTime: () => _isoDateTime,
21678
- _isoDate: () => _isoDate,
21679
- _ipv6: () => _ipv6,
21680
- _ipv4: () => _ipv4,
21681
- _intersection: () => _intersection,
21682
- _int64: () => _int64,
21683
- _int32: () => _int32,
21684
- _int: () => _int,
21685
- _includes: () => _includes,
21686
- _guid: () => _guid,
21687
- _gte: () => _gte,
21688
- _gt: () => _gt,
21689
- _float64: () => _float64,
21690
- _float32: () => _float32,
21691
- _file: () => _file,
21692
- _enum: () => _enum,
21693
- _endsWith: () => _endsWith,
21694
- _encodeAsync: () => _encodeAsync,
21695
- _encode: () => _encode,
21696
- _emoji: () => _emoji2,
21697
- _email: () => _email,
21698
- _e164: () => _e164,
21699
- _discriminatedUnion: () => _discriminatedUnion,
21700
- _default: () => _default,
21701
- _decodeAsync: () => _decodeAsync,
21702
- _decode: () => _decode,
21703
- _date: () => _date,
21704
- _custom: () => _custom,
21705
- _cuid2: () => _cuid2,
21706
- _cuid: () => _cuid,
21707
- _coercedString: () => _coercedString,
21708
- _coercedNumber: () => _coercedNumber,
21709
- _coercedDate: () => _coercedDate,
21710
- _coercedBoolean: () => _coercedBoolean,
21711
- _coercedBigint: () => _coercedBigint,
21712
- _cidrv6: () => _cidrv6,
21713
- _cidrv4: () => _cidrv4,
21714
- _check: () => _check,
21715
- _catch: () => _catch,
21716
- _boolean: () => _boolean,
21717
- _bigint: () => _bigint,
21718
- _base64url: () => _base64url,
21719
- _base64: () => _base64,
21720
- _array: () => _array,
21721
- _any: () => _any,
21722
- TimePrecision: () => TimePrecision,
21723
- NEVER: () => NEVER,
21724
- JSONSchemaGenerator: () => JSONSchemaGenerator,
21725
- JSONSchema: () => exports_json_schema,
21726
- Doc: () => Doc,
21727
- $output: () => $output,
21728
- $input: () => $input,
21729
- $constructor: () => $constructor,
21730
- $brand: () => $brand,
21731
- $ZodXor: () => $ZodXor,
21732
- $ZodXID: () => $ZodXID,
21733
- $ZodVoid: () => $ZodVoid,
21734
- $ZodUnknown: () => $ZodUnknown,
21735
- $ZodUnion: () => $ZodUnion,
21736
- $ZodUndefined: () => $ZodUndefined,
21737
- $ZodUUID: () => $ZodUUID,
21738
- $ZodURL: () => $ZodURL,
21739
- $ZodULID: () => $ZodULID,
21740
- $ZodType: () => $ZodType,
21741
- $ZodTuple: () => $ZodTuple,
21742
- $ZodTransform: () => $ZodTransform,
21743
- $ZodTemplateLiteral: () => $ZodTemplateLiteral,
21744
- $ZodSymbol: () => $ZodSymbol,
21745
- $ZodSuccess: () => $ZodSuccess,
21746
- $ZodStringFormat: () => $ZodStringFormat,
21747
- $ZodString: () => $ZodString,
21748
- $ZodSet: () => $ZodSet,
21749
- $ZodRegistry: () => $ZodRegistry,
21750
- $ZodRecord: () => $ZodRecord,
21751
- $ZodRealError: () => $ZodRealError,
21752
- $ZodReadonly: () => $ZodReadonly,
21753
- $ZodPromise: () => $ZodPromise,
21754
- $ZodPreprocess: () => $ZodPreprocess,
21755
- $ZodPrefault: () => $ZodPrefault,
21756
- $ZodPipe: () => $ZodPipe,
21757
- $ZodOptional: () => $ZodOptional,
21758
- $ZodObjectJIT: () => $ZodObjectJIT,
21759
- $ZodObject: () => $ZodObject,
21760
- $ZodNumberFormat: () => $ZodNumberFormat,
21761
- $ZodNumber: () => $ZodNumber,
21762
- $ZodNullable: () => $ZodNullable,
21763
- $ZodNull: () => $ZodNull,
21764
- $ZodNonOptional: () => $ZodNonOptional,
21765
- $ZodNever: () => $ZodNever,
21766
- $ZodNanoID: () => $ZodNanoID,
21767
- $ZodNaN: () => $ZodNaN,
21768
- $ZodMap: () => $ZodMap,
21769
- $ZodMAC: () => $ZodMAC,
21770
- $ZodLiteral: () => $ZodLiteral,
21771
- $ZodLazy: () => $ZodLazy,
21772
- $ZodKSUID: () => $ZodKSUID,
21773
- $ZodJWT: () => $ZodJWT,
21774
- $ZodIntersection: () => $ZodIntersection,
21775
- $ZodISOTime: () => $ZodISOTime,
21776
- $ZodISODuration: () => $ZodISODuration,
21777
- $ZodISODateTime: () => $ZodISODateTime,
21778
- $ZodISODate: () => $ZodISODate,
21779
- $ZodIPv6: () => $ZodIPv6,
21780
- $ZodIPv4: () => $ZodIPv4,
21781
- $ZodGUID: () => $ZodGUID,
21782
- $ZodFunction: () => $ZodFunction,
21783
- $ZodFile: () => $ZodFile,
21784
- $ZodExactOptional: () => $ZodExactOptional,
21785
- $ZodError: () => $ZodError,
21786
- $ZodEnum: () => $ZodEnum,
21787
- $ZodEncodeError: () => $ZodEncodeError,
21788
- $ZodEmoji: () => $ZodEmoji,
21789
- $ZodEmail: () => $ZodEmail,
21790
- $ZodE164: () => $ZodE164,
21791
- $ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
21792
- $ZodDefault: () => $ZodDefault,
21793
- $ZodDate: () => $ZodDate,
21794
- $ZodCustomStringFormat: () => $ZodCustomStringFormat,
21795
- $ZodCustom: () => $ZodCustom,
21796
- $ZodCodec: () => $ZodCodec,
21797
- $ZodCheckUpperCase: () => $ZodCheckUpperCase,
21798
- $ZodCheckStringFormat: () => $ZodCheckStringFormat,
21799
- $ZodCheckStartsWith: () => $ZodCheckStartsWith,
21800
- $ZodCheckSizeEquals: () => $ZodCheckSizeEquals,
21801
- $ZodCheckRegex: () => $ZodCheckRegex,
21802
- $ZodCheckProperty: () => $ZodCheckProperty,
21803
- $ZodCheckOverwrite: () => $ZodCheckOverwrite,
21804
- $ZodCheckNumberFormat: () => $ZodCheckNumberFormat,
21805
- $ZodCheckMultipleOf: () => $ZodCheckMultipleOf,
21806
- $ZodCheckMinSize: () => $ZodCheckMinSize,
21807
- $ZodCheckMinLength: () => $ZodCheckMinLength,
21808
- $ZodCheckMimeType: () => $ZodCheckMimeType,
21809
- $ZodCheckMaxSize: () => $ZodCheckMaxSize,
21810
- $ZodCheckMaxLength: () => $ZodCheckMaxLength,
21811
- $ZodCheckLowerCase: () => $ZodCheckLowerCase,
21812
- $ZodCheckLessThan: () => $ZodCheckLessThan,
21813
- $ZodCheckLengthEquals: () => $ZodCheckLengthEquals,
21814
- $ZodCheckIncludes: () => $ZodCheckIncludes,
21815
- $ZodCheckGreaterThan: () => $ZodCheckGreaterThan,
21816
- $ZodCheckEndsWith: () => $ZodCheckEndsWith,
21817
- $ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat,
21818
- $ZodCheck: () => $ZodCheck,
21819
- $ZodCatch: () => $ZodCatch,
21820
- $ZodCUID2: () => $ZodCUID2,
21821
- $ZodCUID: () => $ZodCUID,
21822
- $ZodCIDRv6: () => $ZodCIDRv6,
21823
- $ZodCIDRv4: () => $ZodCIDRv4,
21824
- $ZodBoolean: () => $ZodBoolean,
21825
- $ZodBigIntFormat: () => $ZodBigIntFormat,
21826
- $ZodBigInt: () => $ZodBigInt,
21827
- $ZodBase64URL: () => $ZodBase64URL,
21828
- $ZodBase64: () => $ZodBase64,
21829
- $ZodAsyncError: () => $ZodAsyncError,
21529
+ $ZodAny: () => $ZodAny,
21830
21530
  $ZodArray: () => $ZodArray,
21831
- $ZodAny: () => $ZodAny
21531
+ $ZodAsyncError: () => $ZodAsyncError,
21532
+ $ZodBase64: () => $ZodBase64,
21533
+ $ZodBase64URL: () => $ZodBase64URL,
21534
+ $ZodBigInt: () => $ZodBigInt,
21535
+ $ZodBigIntFormat: () => $ZodBigIntFormat,
21536
+ $ZodBoolean: () => $ZodBoolean,
21537
+ $ZodCIDRv4: () => $ZodCIDRv4,
21538
+ $ZodCIDRv6: () => $ZodCIDRv6,
21539
+ $ZodCUID: () => $ZodCUID,
21540
+ $ZodCUID2: () => $ZodCUID2,
21541
+ $ZodCatch: () => $ZodCatch,
21542
+ $ZodCheck: () => $ZodCheck,
21543
+ $ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat,
21544
+ $ZodCheckEndsWith: () => $ZodCheckEndsWith,
21545
+ $ZodCheckGreaterThan: () => $ZodCheckGreaterThan,
21546
+ $ZodCheckIncludes: () => $ZodCheckIncludes,
21547
+ $ZodCheckLengthEquals: () => $ZodCheckLengthEquals,
21548
+ $ZodCheckLessThan: () => $ZodCheckLessThan,
21549
+ $ZodCheckLowerCase: () => $ZodCheckLowerCase,
21550
+ $ZodCheckMaxLength: () => $ZodCheckMaxLength,
21551
+ $ZodCheckMaxSize: () => $ZodCheckMaxSize,
21552
+ $ZodCheckMimeType: () => $ZodCheckMimeType,
21553
+ $ZodCheckMinLength: () => $ZodCheckMinLength,
21554
+ $ZodCheckMinSize: () => $ZodCheckMinSize,
21555
+ $ZodCheckMultipleOf: () => $ZodCheckMultipleOf,
21556
+ $ZodCheckNumberFormat: () => $ZodCheckNumberFormat,
21557
+ $ZodCheckOverwrite: () => $ZodCheckOverwrite,
21558
+ $ZodCheckProperty: () => $ZodCheckProperty,
21559
+ $ZodCheckRegex: () => $ZodCheckRegex,
21560
+ $ZodCheckSizeEquals: () => $ZodCheckSizeEquals,
21561
+ $ZodCheckStartsWith: () => $ZodCheckStartsWith,
21562
+ $ZodCheckStringFormat: () => $ZodCheckStringFormat,
21563
+ $ZodCheckUpperCase: () => $ZodCheckUpperCase,
21564
+ $ZodCodec: () => $ZodCodec,
21565
+ $ZodCustom: () => $ZodCustom,
21566
+ $ZodCustomStringFormat: () => $ZodCustomStringFormat,
21567
+ $ZodDate: () => $ZodDate,
21568
+ $ZodDefault: () => $ZodDefault,
21569
+ $ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
21570
+ $ZodE164: () => $ZodE164,
21571
+ $ZodEmail: () => $ZodEmail,
21572
+ $ZodEmoji: () => $ZodEmoji,
21573
+ $ZodEncodeError: () => $ZodEncodeError,
21574
+ $ZodEnum: () => $ZodEnum,
21575
+ $ZodError: () => $ZodError,
21576
+ $ZodExactOptional: () => $ZodExactOptional,
21577
+ $ZodFile: () => $ZodFile,
21578
+ $ZodFunction: () => $ZodFunction,
21579
+ $ZodGUID: () => $ZodGUID,
21580
+ $ZodIPv4: () => $ZodIPv4,
21581
+ $ZodIPv6: () => $ZodIPv6,
21582
+ $ZodISODate: () => $ZodISODate,
21583
+ $ZodISODateTime: () => $ZodISODateTime,
21584
+ $ZodISODuration: () => $ZodISODuration,
21585
+ $ZodISOTime: () => $ZodISOTime,
21586
+ $ZodIntersection: () => $ZodIntersection,
21587
+ $ZodJWT: () => $ZodJWT,
21588
+ $ZodKSUID: () => $ZodKSUID,
21589
+ $ZodLazy: () => $ZodLazy,
21590
+ $ZodLiteral: () => $ZodLiteral,
21591
+ $ZodMAC: () => $ZodMAC,
21592
+ $ZodMap: () => $ZodMap,
21593
+ $ZodNaN: () => $ZodNaN,
21594
+ $ZodNanoID: () => $ZodNanoID,
21595
+ $ZodNever: () => $ZodNever,
21596
+ $ZodNonOptional: () => $ZodNonOptional,
21597
+ $ZodNull: () => $ZodNull,
21598
+ $ZodNullable: () => $ZodNullable,
21599
+ $ZodNumber: () => $ZodNumber,
21600
+ $ZodNumberFormat: () => $ZodNumberFormat,
21601
+ $ZodObject: () => $ZodObject,
21602
+ $ZodObjectJIT: () => $ZodObjectJIT,
21603
+ $ZodOptional: () => $ZodOptional,
21604
+ $ZodPipe: () => $ZodPipe,
21605
+ $ZodPrefault: () => $ZodPrefault,
21606
+ $ZodPreprocess: () => $ZodPreprocess,
21607
+ $ZodPromise: () => $ZodPromise,
21608
+ $ZodReadonly: () => $ZodReadonly,
21609
+ $ZodRealError: () => $ZodRealError,
21610
+ $ZodRecord: () => $ZodRecord,
21611
+ $ZodRegistry: () => $ZodRegistry,
21612
+ $ZodSet: () => $ZodSet,
21613
+ $ZodString: () => $ZodString,
21614
+ $ZodStringFormat: () => $ZodStringFormat,
21615
+ $ZodSuccess: () => $ZodSuccess,
21616
+ $ZodSymbol: () => $ZodSymbol,
21617
+ $ZodTemplateLiteral: () => $ZodTemplateLiteral,
21618
+ $ZodTransform: () => $ZodTransform,
21619
+ $ZodTuple: () => $ZodTuple,
21620
+ $ZodType: () => $ZodType,
21621
+ $ZodULID: () => $ZodULID,
21622
+ $ZodURL: () => $ZodURL,
21623
+ $ZodUUID: () => $ZodUUID,
21624
+ $ZodUndefined: () => $ZodUndefined,
21625
+ $ZodUnion: () => $ZodUnion,
21626
+ $ZodUnknown: () => $ZodUnknown,
21627
+ $ZodVoid: () => $ZodVoid,
21628
+ $ZodXID: () => $ZodXID,
21629
+ $ZodXor: () => $ZodXor,
21630
+ $brand: () => $brand,
21631
+ $constructor: () => $constructor,
21632
+ $input: () => $input,
21633
+ $output: () => $output,
21634
+ Doc: () => Doc,
21635
+ JSONSchema: () => exports_json_schema,
21636
+ JSONSchemaGenerator: () => JSONSchemaGenerator,
21637
+ NEVER: () => NEVER,
21638
+ TimePrecision: () => TimePrecision,
21639
+ _any: () => _any,
21640
+ _array: () => _array,
21641
+ _base64: () => _base64,
21642
+ _base64url: () => _base64url,
21643
+ _bigint: () => _bigint,
21644
+ _boolean: () => _boolean,
21645
+ _catch: () => _catch,
21646
+ _check: () => _check,
21647
+ _cidrv4: () => _cidrv4,
21648
+ _cidrv6: () => _cidrv6,
21649
+ _coercedBigint: () => _coercedBigint,
21650
+ _coercedBoolean: () => _coercedBoolean,
21651
+ _coercedDate: () => _coercedDate,
21652
+ _coercedNumber: () => _coercedNumber,
21653
+ _coercedString: () => _coercedString,
21654
+ _cuid: () => _cuid,
21655
+ _cuid2: () => _cuid2,
21656
+ _custom: () => _custom,
21657
+ _date: () => _date,
21658
+ _decode: () => _decode,
21659
+ _decodeAsync: () => _decodeAsync,
21660
+ _default: () => _default,
21661
+ _discriminatedUnion: () => _discriminatedUnion,
21662
+ _e164: () => _e164,
21663
+ _email: () => _email,
21664
+ _emoji: () => _emoji2,
21665
+ _encode: () => _encode,
21666
+ _encodeAsync: () => _encodeAsync,
21667
+ _endsWith: () => _endsWith,
21668
+ _enum: () => _enum,
21669
+ _file: () => _file,
21670
+ _float32: () => _float32,
21671
+ _float64: () => _float64,
21672
+ _gt: () => _gt,
21673
+ _gte: () => _gte,
21674
+ _guid: () => _guid,
21675
+ _includes: () => _includes,
21676
+ _int: () => _int,
21677
+ _int32: () => _int32,
21678
+ _int64: () => _int64,
21679
+ _intersection: () => _intersection,
21680
+ _ipv4: () => _ipv4,
21681
+ _ipv6: () => _ipv6,
21682
+ _isoDate: () => _isoDate,
21683
+ _isoDateTime: () => _isoDateTime,
21684
+ _isoDuration: () => _isoDuration,
21685
+ _isoTime: () => _isoTime,
21686
+ _jwt: () => _jwt,
21687
+ _ksuid: () => _ksuid,
21688
+ _lazy: () => _lazy,
21689
+ _length: () => _length,
21690
+ _literal: () => _literal,
21691
+ _lowercase: () => _lowercase,
21692
+ _lt: () => _lt,
21693
+ _lte: () => _lte,
21694
+ _mac: () => _mac,
21695
+ _map: () => _map,
21696
+ _max: () => _lte,
21697
+ _maxLength: () => _maxLength,
21698
+ _maxSize: () => _maxSize,
21699
+ _mime: () => _mime,
21700
+ _min: () => _gte,
21701
+ _minLength: () => _minLength,
21702
+ _minSize: () => _minSize,
21703
+ _multipleOf: () => _multipleOf,
21704
+ _nan: () => _nan,
21705
+ _nanoid: () => _nanoid,
21706
+ _nativeEnum: () => _nativeEnum,
21707
+ _negative: () => _negative,
21708
+ _never: () => _never,
21709
+ _nonnegative: () => _nonnegative,
21710
+ _nonoptional: () => _nonoptional,
21711
+ _nonpositive: () => _nonpositive,
21712
+ _normalize: () => _normalize,
21713
+ _null: () => _null2,
21714
+ _nullable: () => _nullable,
21715
+ _number: () => _number,
21716
+ _optional: () => _optional,
21717
+ _overwrite: () => _overwrite,
21718
+ _parse: () => _parse,
21719
+ _parseAsync: () => _parseAsync,
21720
+ _pipe: () => _pipe,
21721
+ _positive: () => _positive,
21722
+ _promise: () => _promise,
21723
+ _property: () => _property,
21724
+ _readonly: () => _readonly,
21725
+ _record: () => _record,
21726
+ _refine: () => _refine,
21727
+ _regex: () => _regex,
21728
+ _safeDecode: () => _safeDecode,
21729
+ _safeDecodeAsync: () => _safeDecodeAsync,
21730
+ _safeEncode: () => _safeEncode,
21731
+ _safeEncodeAsync: () => _safeEncodeAsync,
21732
+ _safeParse: () => _safeParse,
21733
+ _safeParseAsync: () => _safeParseAsync,
21734
+ _set: () => _set,
21735
+ _size: () => _size,
21736
+ _slugify: () => _slugify,
21737
+ _startsWith: () => _startsWith,
21738
+ _string: () => _string,
21739
+ _stringFormat: () => _stringFormat,
21740
+ _stringbool: () => _stringbool,
21741
+ _success: () => _success,
21742
+ _superRefine: () => _superRefine,
21743
+ _symbol: () => _symbol,
21744
+ _templateLiteral: () => _templateLiteral,
21745
+ _toLowerCase: () => _toLowerCase,
21746
+ _toUpperCase: () => _toUpperCase,
21747
+ _transform: () => _transform,
21748
+ _trim: () => _trim,
21749
+ _tuple: () => _tuple,
21750
+ _uint32: () => _uint32,
21751
+ _uint64: () => _uint64,
21752
+ _ulid: () => _ulid,
21753
+ _undefined: () => _undefined2,
21754
+ _union: () => _union,
21755
+ _unknown: () => _unknown,
21756
+ _uppercase: () => _uppercase,
21757
+ _url: () => _url,
21758
+ _uuid: () => _uuid,
21759
+ _uuidv4: () => _uuidv4,
21760
+ _uuidv6: () => _uuidv6,
21761
+ _uuidv7: () => _uuidv7,
21762
+ _void: () => _void,
21763
+ _xid: () => _xid,
21764
+ _xor: () => _xor,
21765
+ clone: () => clone,
21766
+ config: () => config,
21767
+ createStandardJSONSchemaMethod: () => createStandardJSONSchemaMethod,
21768
+ createToJSONSchemaMethod: () => createToJSONSchemaMethod,
21769
+ decode: () => decode,
21770
+ decodeAsync: () => decodeAsync,
21771
+ describe: () => describe,
21772
+ encode: () => encode,
21773
+ encodeAsync: () => encodeAsync,
21774
+ extractDefs: () => extractDefs,
21775
+ finalize: () => finalize,
21776
+ flattenError: () => flattenError,
21777
+ formatError: () => formatError,
21778
+ globalConfig: () => globalConfig,
21779
+ globalRegistry: () => globalRegistry,
21780
+ initializeContext: () => initializeContext,
21781
+ isValidBase64: () => isValidBase64,
21782
+ isValidBase64URL: () => isValidBase64URL,
21783
+ isValidJWT: () => isValidJWT,
21784
+ locales: () => exports_locales,
21785
+ meta: () => meta,
21786
+ parse: () => parse,
21787
+ parseAsync: () => parseAsync,
21788
+ prettifyError: () => prettifyError,
21789
+ process: () => process2,
21790
+ regexes: () => exports_regexes,
21791
+ registry: () => registry,
21792
+ safeDecode: () => safeDecode,
21793
+ safeDecodeAsync: () => safeDecodeAsync,
21794
+ safeEncode: () => safeEncode,
21795
+ safeEncodeAsync: () => safeEncodeAsync,
21796
+ safeParse: () => safeParse,
21797
+ safeParseAsync: () => safeParseAsync,
21798
+ toDotPath: () => toDotPath,
21799
+ toJSONSchema: () => toJSONSchema,
21800
+ treeifyError: () => treeifyError,
21801
+ util: () => exports_util,
21802
+ version: () => version
21832
21803
  });
21833
21804
 
21834
21805
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/core.js
@@ -21912,69 +21883,69 @@ function config(newConfig) {
21912
21883
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/util.js
21913
21884
  var exports_util = {};
21914
21885
  __export(exports_util, {
21915
- unwrapMessage: () => unwrapMessage,
21916
- uint8ArrayToHex: () => uint8ArrayToHex,
21917
- uint8ArrayToBase64url: () => uint8ArrayToBase64url,
21918
- uint8ArrayToBase64: () => uint8ArrayToBase64,
21919
- stringifyPrimitive: () => stringifyPrimitive,
21920
- slugify: () => slugify,
21921
- shallowClone: () => shallowClone,
21922
- safeExtend: () => safeExtend,
21923
- required: () => required,
21924
- randomString: () => randomString,
21925
- propertyKeyTypes: () => propertyKeyTypes,
21926
- promiseAllObject: () => promiseAllObject,
21927
- primitiveTypes: () => primitiveTypes,
21928
- prefixIssues: () => prefixIssues,
21929
- pick: () => pick,
21930
- partial: () => partial,
21931
- parsedType: () => parsedType,
21932
- optionalKeys: () => optionalKeys,
21933
- omit: () => omit,
21934
- objectClone: () => objectClone,
21935
- numKeys: () => numKeys,
21936
- nullish: () => nullish,
21937
- normalizeParams: () => normalizeParams,
21938
- mergeDefs: () => mergeDefs,
21939
- merge: () => merge,
21940
- jsonStringifyReplacer: () => jsonStringifyReplacer,
21941
- joinValues: () => joinValues,
21942
- issue: () => issue,
21943
- isPlainObject: () => isPlainObject2,
21944
- isObject: () => isObject,
21945
- hexToUint8Array: () => hexToUint8Array,
21946
- getSizableOrigin: () => getSizableOrigin,
21947
- getParsedType: () => getParsedType,
21948
- getLengthableOrigin: () => getLengthableOrigin,
21949
- getEnumValues: () => getEnumValues,
21950
- getElementAtPath: () => getElementAtPath,
21951
- floatSafeRemainder: () => floatSafeRemainder,
21952
- finalizeIssue: () => finalizeIssue,
21953
- extend: () => extend,
21954
- explicitlyAborted: () => explicitlyAborted,
21955
- escapeRegex: () => escapeRegex,
21956
- esc: () => esc,
21957
- defineLazy: () => defineLazy,
21958
- createTransparentProxy: () => createTransparentProxy,
21959
- cloneDef: () => cloneDef,
21960
- clone: () => clone,
21961
- cleanRegex: () => cleanRegex,
21962
- cleanEnum: () => cleanEnum,
21963
- captureStackTrace: () => captureStackTrace,
21964
- cached: () => cached,
21965
- base64urlToUint8Array: () => base64urlToUint8Array,
21966
- base64ToUint8Array: () => base64ToUint8Array,
21967
- assignProp: () => assignProp,
21968
- assertNotEqual: () => assertNotEqual,
21969
- assertNever: () => assertNever,
21970
- assertIs: () => assertIs,
21971
- assertEqual: () => assertEqual,
21972
- assert: () => assert,
21973
- allowsEval: () => allowsEval,
21974
- aborted: () => aborted,
21975
- NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
21886
+ BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
21976
21887
  Class: () => Class,
21977
- BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES
21888
+ NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
21889
+ aborted: () => aborted,
21890
+ allowsEval: () => allowsEval,
21891
+ assert: () => assert,
21892
+ assertEqual: () => assertEqual,
21893
+ assertIs: () => assertIs,
21894
+ assertNever: () => assertNever,
21895
+ assertNotEqual: () => assertNotEqual,
21896
+ assignProp: () => assignProp,
21897
+ base64ToUint8Array: () => base64ToUint8Array,
21898
+ base64urlToUint8Array: () => base64urlToUint8Array,
21899
+ cached: () => cached,
21900
+ captureStackTrace: () => captureStackTrace,
21901
+ cleanEnum: () => cleanEnum,
21902
+ cleanRegex: () => cleanRegex,
21903
+ clone: () => clone,
21904
+ cloneDef: () => cloneDef,
21905
+ createTransparentProxy: () => createTransparentProxy,
21906
+ defineLazy: () => defineLazy,
21907
+ esc: () => esc,
21908
+ escapeRegex: () => escapeRegex,
21909
+ explicitlyAborted: () => explicitlyAborted,
21910
+ extend: () => extend,
21911
+ finalizeIssue: () => finalizeIssue,
21912
+ floatSafeRemainder: () => floatSafeRemainder,
21913
+ getElementAtPath: () => getElementAtPath,
21914
+ getEnumValues: () => getEnumValues,
21915
+ getLengthableOrigin: () => getLengthableOrigin,
21916
+ getParsedType: () => getParsedType,
21917
+ getSizableOrigin: () => getSizableOrigin,
21918
+ hexToUint8Array: () => hexToUint8Array,
21919
+ isObject: () => isObject,
21920
+ isPlainObject: () => isPlainObject2,
21921
+ issue: () => issue,
21922
+ joinValues: () => joinValues,
21923
+ jsonStringifyReplacer: () => jsonStringifyReplacer,
21924
+ merge: () => merge,
21925
+ mergeDefs: () => mergeDefs,
21926
+ normalizeParams: () => normalizeParams,
21927
+ nullish: () => nullish,
21928
+ numKeys: () => numKeys,
21929
+ objectClone: () => objectClone,
21930
+ omit: () => omit,
21931
+ optionalKeys: () => optionalKeys,
21932
+ parsedType: () => parsedType,
21933
+ partial: () => partial,
21934
+ pick: () => pick,
21935
+ prefixIssues: () => prefixIssues,
21936
+ primitiveTypes: () => primitiveTypes,
21937
+ promiseAllObject: () => promiseAllObject,
21938
+ propertyKeyTypes: () => propertyKeyTypes,
21939
+ randomString: () => randomString,
21940
+ required: () => required,
21941
+ safeExtend: () => safeExtend,
21942
+ shallowClone: () => shallowClone,
21943
+ slugify: () => slugify,
21944
+ stringifyPrimitive: () => stringifyPrimitive,
21945
+ uint8ArrayToBase64: () => uint8ArrayToBase64,
21946
+ uint8ArrayToBase64url: () => uint8ArrayToBase64url,
21947
+ uint8ArrayToHex: () => uint8ArrayToHex,
21948
+ unwrapMessage: () => unwrapMessage
21978
21949
  });
21979
21950
  function assertEqual(val) {
21980
21951
  return val;
@@ -22831,65 +22802,65 @@ var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
22831
22802
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/regexes.js
22832
22803
  var exports_regexes = {};
22833
22804
  __export(exports_regexes, {
22834
- xid: () => xid,
22835
- uuid7: () => uuid7,
22836
- uuid6: () => uuid6,
22837
- uuid4: () => uuid4,
22838
- uuid: () => uuid,
22839
- uppercase: () => uppercase,
22840
- unicodeEmail: () => unicodeEmail,
22841
- undefined: () => _undefined,
22842
- ulid: () => ulid,
22843
- time: () => time,
22844
- string: () => string,
22845
- sha512_hex: () => sha512_hex,
22846
- sha512_base64url: () => sha512_base64url,
22847
- sha512_base64: () => sha512_base64,
22848
- sha384_hex: () => sha384_hex,
22849
- sha384_base64url: () => sha384_base64url,
22850
- sha384_base64: () => sha384_base64,
22851
- sha256_hex: () => sha256_hex,
22852
- sha256_base64url: () => sha256_base64url,
22853
- sha256_base64: () => sha256_base64,
22854
- sha1_hex: () => sha1_hex,
22855
- sha1_base64url: () => sha1_base64url,
22856
- sha1_base64: () => sha1_base64,
22857
- rfc5322Email: () => rfc5322Email,
22858
- number: () => number,
22859
- null: () => _null,
22860
- nanoid: () => nanoid,
22861
- md5_hex: () => md5_hex,
22862
- md5_base64url: () => md5_base64url,
22863
- md5_base64: () => md5_base64,
22864
- mac: () => mac,
22865
- lowercase: () => lowercase,
22866
- ksuid: () => ksuid,
22867
- ipv6: () => ipv6,
22868
- ipv4: () => ipv4,
22869
- integer: () => integer,
22870
- idnEmail: () => idnEmail,
22871
- httpProtocol: () => httpProtocol,
22872
- html5Email: () => html5Email,
22873
- hostname: () => hostname,
22874
- hex: () => hex,
22875
- guid: () => guid,
22876
- extendedDuration: () => extendedDuration,
22877
- emoji: () => emoji,
22878
- email: () => email,
22879
- e164: () => e164,
22880
- duration: () => duration,
22881
- domain: () => domain,
22882
- datetime: () => datetime,
22883
- date: () => date,
22884
- cuid2: () => cuid2,
22885
- cuid: () => cuid,
22886
- cidrv6: () => cidrv6,
22887
- cidrv4: () => cidrv4,
22888
- browserEmail: () => browserEmail,
22889
- boolean: () => boolean,
22890
- bigint: () => bigint,
22805
+ base64: () => base64,
22891
22806
  base64url: () => base64url,
22892
- base64: () => base64
22807
+ bigint: () => bigint,
22808
+ boolean: () => boolean,
22809
+ browserEmail: () => browserEmail,
22810
+ cidrv4: () => cidrv4,
22811
+ cidrv6: () => cidrv6,
22812
+ cuid: () => cuid,
22813
+ cuid2: () => cuid2,
22814
+ date: () => date,
22815
+ datetime: () => datetime,
22816
+ domain: () => domain,
22817
+ duration: () => duration,
22818
+ e164: () => e164,
22819
+ email: () => email,
22820
+ emoji: () => emoji,
22821
+ extendedDuration: () => extendedDuration,
22822
+ guid: () => guid,
22823
+ hex: () => hex,
22824
+ hostname: () => hostname,
22825
+ html5Email: () => html5Email,
22826
+ httpProtocol: () => httpProtocol,
22827
+ idnEmail: () => idnEmail,
22828
+ integer: () => integer,
22829
+ ipv4: () => ipv4,
22830
+ ipv6: () => ipv6,
22831
+ ksuid: () => ksuid,
22832
+ lowercase: () => lowercase,
22833
+ mac: () => mac,
22834
+ md5_base64: () => md5_base64,
22835
+ md5_base64url: () => md5_base64url,
22836
+ md5_hex: () => md5_hex,
22837
+ nanoid: () => nanoid,
22838
+ null: () => _null,
22839
+ number: () => number,
22840
+ rfc5322Email: () => rfc5322Email,
22841
+ sha1_base64: () => sha1_base64,
22842
+ sha1_base64url: () => sha1_base64url,
22843
+ sha1_hex: () => sha1_hex,
22844
+ sha256_base64: () => sha256_base64,
22845
+ sha256_base64url: () => sha256_base64url,
22846
+ sha256_hex: () => sha256_hex,
22847
+ sha384_base64: () => sha384_base64,
22848
+ sha384_base64url: () => sha384_base64url,
22849
+ sha384_hex: () => sha384_hex,
22850
+ sha512_base64: () => sha512_base64,
22851
+ sha512_base64url: () => sha512_base64url,
22852
+ sha512_hex: () => sha512_hex,
22853
+ string: () => string,
22854
+ time: () => time,
22855
+ ulid: () => ulid,
22856
+ undefined: () => _undefined,
22857
+ unicodeEmail: () => unicodeEmail,
22858
+ uppercase: () => uppercase,
22859
+ uuid: () => uuid,
22860
+ uuid4: () => uuid4,
22861
+ uuid6: () => uuid6,
22862
+ uuid7: () => uuid7,
22863
+ xid: () => xid
22893
22864
  });
22894
22865
  var cuid = /^[cC][0-9a-z]{6,}$/;
22895
22866
  var cuid2 = /^[0-9a-z]+$/;
@@ -25666,58 +25637,58 @@ function handleRefineResult(result, payload, input, inst) {
25666
25637
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/locales/index.js
25667
25638
  var exports_locales = {};
25668
25639
  __export(exports_locales, {
25669
- zhTW: () => zh_TW_default,
25670
- zhCN: () => zh_CN_default,
25671
- yo: () => yo_default,
25672
- vi: () => vi_default,
25673
- uz: () => uz_default,
25674
- ur: () => ur_default,
25675
- uk: () => uk_default,
25676
- ua: () => ua_default,
25677
- tr: () => tr_default,
25678
- th: () => th_default,
25679
- ta: () => ta_default,
25680
- sv: () => sv_default,
25681
- sl: () => sl_default,
25682
- ru: () => ru_default,
25683
- ro: () => ro_default,
25684
- pt: () => pt_default,
25685
- ps: () => ps_default,
25686
- pl: () => pl_default,
25687
- ota: () => ota_default,
25688
- no: () => no_default,
25689
- nl: () => nl_default,
25690
- ms: () => ms_default,
25691
- mk: () => mk_default,
25692
- lt: () => lt_default,
25693
- ko: () => ko_default,
25694
- km: () => km_default,
25695
- kh: () => kh_default,
25696
- ka: () => ka_default,
25697
- ja: () => ja_default,
25698
- it: () => it_default,
25699
- is: () => is_default,
25700
- id: () => id_default,
25701
- hy: () => hy_default,
25702
- hu: () => hu_default,
25703
- hr: () => hr_default,
25704
- he: () => he_default,
25705
- frCA: () => fr_CA_default,
25706
- fr: () => fr_default,
25707
- fi: () => fi_default,
25708
- fa: () => fa_default,
25709
- es: () => es_default,
25710
- eo: () => eo_default,
25711
- en: () => en_default,
25712
- el: () => el_default,
25713
- de: () => de_default,
25714
- da: () => da_default,
25715
- cs: () => cs_default,
25716
- ca: () => ca_default,
25717
- bg: () => bg_default,
25718
- be: () => be_default,
25640
+ ar: () => ar_default,
25719
25641
  az: () => az_default,
25720
- ar: () => ar_default
25642
+ be: () => be_default,
25643
+ bg: () => bg_default,
25644
+ ca: () => ca_default,
25645
+ cs: () => cs_default,
25646
+ da: () => da_default,
25647
+ de: () => de_default,
25648
+ el: () => el_default,
25649
+ en: () => en_default,
25650
+ eo: () => eo_default,
25651
+ es: () => es_default,
25652
+ fa: () => fa_default,
25653
+ fi: () => fi_default,
25654
+ fr: () => fr_default,
25655
+ frCA: () => fr_CA_default,
25656
+ he: () => he_default,
25657
+ hr: () => hr_default,
25658
+ hu: () => hu_default,
25659
+ hy: () => hy_default,
25660
+ id: () => id_default,
25661
+ is: () => is_default,
25662
+ it: () => it_default,
25663
+ ja: () => ja_default,
25664
+ ka: () => ka_default,
25665
+ kh: () => kh_default,
25666
+ km: () => km_default,
25667
+ ko: () => ko_default,
25668
+ lt: () => lt_default,
25669
+ mk: () => mk_default,
25670
+ ms: () => ms_default,
25671
+ nl: () => nl_default,
25672
+ no: () => no_default,
25673
+ ota: () => ota_default,
25674
+ pl: () => pl_default,
25675
+ ps: () => ps_default,
25676
+ pt: () => pt_default,
25677
+ ro: () => ro_default,
25678
+ ru: () => ru_default,
25679
+ sl: () => sl_default,
25680
+ sv: () => sv_default,
25681
+ ta: () => ta_default,
25682
+ th: () => th_default,
25683
+ tr: () => tr_default,
25684
+ ua: () => ua_default,
25685
+ uk: () => uk_default,
25686
+ ur: () => ur_default,
25687
+ uz: () => uz_default,
25688
+ vi: () => vi_default,
25689
+ yo: () => yo_default,
25690
+ zhCN: () => zh_CN_default,
25691
+ zhTW: () => zh_TW_default
25721
25692
  });
25722
25693
 
25723
25694
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/locales/ar.js
@@ -33488,219 +33459,219 @@ var exports_json_schema = {};
33488
33459
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
33489
33460
  var exports_schemas2 = {};
33490
33461
  __export(exports_schemas2, {
33491
- xor: () => xor,
33492
- xid: () => xid2,
33493
- void: () => _void2,
33494
- uuidv7: () => uuidv7,
33495
- uuidv6: () => uuidv6,
33496
- uuidv4: () => uuidv4,
33497
- uuid: () => uuid2,
33498
- url: () => url,
33499
- unknown: () => unknown,
33500
- union: () => union,
33501
- undefined: () => _undefined3,
33502
- ulid: () => ulid2,
33503
- uint64: () => uint64,
33504
- uint32: () => uint32,
33505
- tuple: () => tuple,
33506
- transform: () => transform,
33507
- templateLiteral: () => templateLiteral,
33508
- symbol: () => symbol,
33509
- superRefine: () => superRefine,
33510
- success: () => success,
33511
- stringbool: () => stringbool,
33512
- stringFormat: () => stringFormat,
33513
- string: () => string2,
33514
- strictObject: () => strictObject,
33515
- set: () => set,
33516
- refine: () => refine,
33517
- record: () => record,
33518
- readonly: () => readonly,
33519
- promise: () => promise,
33520
- preprocess: () => preprocess,
33521
- prefault: () => prefault,
33522
- pipe: () => pipe,
33523
- partialRecord: () => partialRecord,
33524
- optional: () => optional,
33525
- object: () => object,
33526
- number: () => number2,
33527
- nullish: () => nullish2,
33528
- nullable: () => nullable,
33529
- null: () => _null3,
33530
- nonoptional: () => nonoptional,
33531
- never: () => never,
33532
- nativeEnum: () => nativeEnum,
33533
- nanoid: () => nanoid2,
33534
- nan: () => nan,
33535
- meta: () => meta2,
33536
- map: () => map,
33537
- mac: () => mac2,
33538
- looseRecord: () => looseRecord,
33539
- looseObject: () => looseObject,
33540
- literal: () => literal,
33541
- lazy: () => lazy,
33542
- ksuid: () => ksuid2,
33543
- keyof: () => keyof,
33544
- jwt: () => jwt,
33545
- json: () => json,
33546
- ipv6: () => ipv62,
33547
- ipv4: () => ipv42,
33548
- invertCodec: () => invertCodec,
33549
- intersection: () => intersection,
33550
- int64: () => int64,
33551
- int32: () => int32,
33552
- int: () => int,
33553
- instanceof: () => _instanceof,
33554
- httpUrl: () => httpUrl,
33555
- hostname: () => hostname2,
33556
- hex: () => hex2,
33557
- hash: () => hash,
33558
- guid: () => guid2,
33559
- function: () => _function,
33560
- float64: () => float64,
33561
- float32: () => float32,
33562
- file: () => file,
33563
- exactOptional: () => exactOptional,
33564
- enum: () => _enum2,
33565
- emoji: () => emoji2,
33566
- email: () => email2,
33567
- e164: () => e1642,
33568
- discriminatedUnion: () => discriminatedUnion,
33569
- describe: () => describe2,
33570
- date: () => date3,
33571
- custom: () => custom,
33572
- cuid2: () => cuid22,
33573
- cuid: () => cuid3,
33574
- codec: () => codec,
33575
- cidrv6: () => cidrv62,
33576
- cidrv4: () => cidrv42,
33577
- check: () => check,
33578
- catch: () => _catch2,
33579
- boolean: () => boolean2,
33580
- bigint: () => bigint2,
33581
- base64url: () => base64url2,
33582
- base64: () => base642,
33583
- array: () => array,
33584
- any: () => any,
33585
- _function: () => _function,
33586
- _default: () => _default2,
33587
- _ZodString: () => _ZodString,
33588
- ZodXor: () => ZodXor,
33589
- ZodXID: () => ZodXID,
33590
- ZodVoid: () => ZodVoid,
33591
- ZodUnknown: () => ZodUnknown,
33592
- ZodUnion: () => ZodUnion,
33593
- ZodUndefined: () => ZodUndefined,
33594
- ZodUUID: () => ZodUUID,
33595
- ZodURL: () => ZodURL,
33596
- ZodULID: () => ZodULID,
33597
- ZodType: () => ZodType,
33598
- ZodTuple: () => ZodTuple,
33599
- ZodTransform: () => ZodTransform,
33600
- ZodTemplateLiteral: () => ZodTemplateLiteral,
33601
- ZodSymbol: () => ZodSymbol,
33602
- ZodSuccess: () => ZodSuccess,
33603
- ZodStringFormat: () => ZodStringFormat,
33604
- ZodString: () => ZodString,
33605
- ZodSet: () => ZodSet,
33606
- ZodRecord: () => ZodRecord,
33607
- ZodReadonly: () => ZodReadonly,
33608
- ZodPromise: () => ZodPromise,
33609
- ZodPreprocess: () => ZodPreprocess,
33610
- ZodPrefault: () => ZodPrefault,
33611
- ZodPipe: () => ZodPipe,
33612
- ZodOptional: () => ZodOptional,
33613
- ZodObject: () => ZodObject,
33614
- ZodNumberFormat: () => ZodNumberFormat,
33615
- ZodNumber: () => ZodNumber,
33616
- ZodNullable: () => ZodNullable,
33617
- ZodNull: () => ZodNull,
33618
- ZodNonOptional: () => ZodNonOptional,
33619
- ZodNever: () => ZodNever,
33620
- ZodNanoID: () => ZodNanoID,
33621
- ZodNaN: () => ZodNaN,
33622
- ZodMap: () => ZodMap,
33623
- ZodMAC: () => ZodMAC,
33624
- ZodLiteral: () => ZodLiteral,
33625
- ZodLazy: () => ZodLazy,
33626
- ZodKSUID: () => ZodKSUID,
33627
- ZodJWT: () => ZodJWT,
33628
- ZodIntersection: () => ZodIntersection,
33629
- ZodIPv6: () => ZodIPv6,
33630
- ZodIPv4: () => ZodIPv4,
33631
- ZodGUID: () => ZodGUID,
33632
- ZodFunction: () => ZodFunction,
33633
- ZodFile: () => ZodFile,
33634
- ZodExactOptional: () => ZodExactOptional,
33635
- ZodEnum: () => ZodEnum,
33636
- ZodEmoji: () => ZodEmoji,
33637
- ZodEmail: () => ZodEmail,
33638
- ZodE164: () => ZodE164,
33639
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
33640
- ZodDefault: () => ZodDefault,
33641
- ZodDate: () => ZodDate,
33642
- ZodCustomStringFormat: () => ZodCustomStringFormat,
33643
- ZodCustom: () => ZodCustom,
33644
- ZodCodec: () => ZodCodec,
33645
- ZodCatch: () => ZodCatch,
33646
- ZodCUID2: () => ZodCUID2,
33647
- ZodCUID: () => ZodCUID,
33648
- ZodCIDRv6: () => ZodCIDRv6,
33649
- ZodCIDRv4: () => ZodCIDRv4,
33650
- ZodBoolean: () => ZodBoolean,
33651
- ZodBigIntFormat: () => ZodBigIntFormat,
33652
- ZodBigInt: () => ZodBigInt,
33653
- ZodBase64URL: () => ZodBase64URL,
33654
- ZodBase64: () => ZodBase64,
33462
+ ZodAny: () => ZodAny,
33655
33463
  ZodArray: () => ZodArray,
33656
- ZodAny: () => ZodAny
33464
+ ZodBase64: () => ZodBase64,
33465
+ ZodBase64URL: () => ZodBase64URL,
33466
+ ZodBigInt: () => ZodBigInt,
33467
+ ZodBigIntFormat: () => ZodBigIntFormat,
33468
+ ZodBoolean: () => ZodBoolean,
33469
+ ZodCIDRv4: () => ZodCIDRv4,
33470
+ ZodCIDRv6: () => ZodCIDRv6,
33471
+ ZodCUID: () => ZodCUID,
33472
+ ZodCUID2: () => ZodCUID2,
33473
+ ZodCatch: () => ZodCatch,
33474
+ ZodCodec: () => ZodCodec,
33475
+ ZodCustom: () => ZodCustom,
33476
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
33477
+ ZodDate: () => ZodDate,
33478
+ ZodDefault: () => ZodDefault,
33479
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
33480
+ ZodE164: () => ZodE164,
33481
+ ZodEmail: () => ZodEmail,
33482
+ ZodEmoji: () => ZodEmoji,
33483
+ ZodEnum: () => ZodEnum,
33484
+ ZodExactOptional: () => ZodExactOptional,
33485
+ ZodFile: () => ZodFile,
33486
+ ZodFunction: () => ZodFunction,
33487
+ ZodGUID: () => ZodGUID,
33488
+ ZodIPv4: () => ZodIPv4,
33489
+ ZodIPv6: () => ZodIPv6,
33490
+ ZodIntersection: () => ZodIntersection,
33491
+ ZodJWT: () => ZodJWT,
33492
+ ZodKSUID: () => ZodKSUID,
33493
+ ZodLazy: () => ZodLazy,
33494
+ ZodLiteral: () => ZodLiteral,
33495
+ ZodMAC: () => ZodMAC,
33496
+ ZodMap: () => ZodMap,
33497
+ ZodNaN: () => ZodNaN,
33498
+ ZodNanoID: () => ZodNanoID,
33499
+ ZodNever: () => ZodNever,
33500
+ ZodNonOptional: () => ZodNonOptional,
33501
+ ZodNull: () => ZodNull,
33502
+ ZodNullable: () => ZodNullable,
33503
+ ZodNumber: () => ZodNumber,
33504
+ ZodNumberFormat: () => ZodNumberFormat,
33505
+ ZodObject: () => ZodObject,
33506
+ ZodOptional: () => ZodOptional,
33507
+ ZodPipe: () => ZodPipe,
33508
+ ZodPrefault: () => ZodPrefault,
33509
+ ZodPreprocess: () => ZodPreprocess,
33510
+ ZodPromise: () => ZodPromise,
33511
+ ZodReadonly: () => ZodReadonly,
33512
+ ZodRecord: () => ZodRecord,
33513
+ ZodSet: () => ZodSet,
33514
+ ZodString: () => ZodString,
33515
+ ZodStringFormat: () => ZodStringFormat,
33516
+ ZodSuccess: () => ZodSuccess,
33517
+ ZodSymbol: () => ZodSymbol,
33518
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
33519
+ ZodTransform: () => ZodTransform,
33520
+ ZodTuple: () => ZodTuple,
33521
+ ZodType: () => ZodType,
33522
+ ZodULID: () => ZodULID,
33523
+ ZodURL: () => ZodURL,
33524
+ ZodUUID: () => ZodUUID,
33525
+ ZodUndefined: () => ZodUndefined,
33526
+ ZodUnion: () => ZodUnion,
33527
+ ZodUnknown: () => ZodUnknown,
33528
+ ZodVoid: () => ZodVoid,
33529
+ ZodXID: () => ZodXID,
33530
+ ZodXor: () => ZodXor,
33531
+ _ZodString: () => _ZodString,
33532
+ _default: () => _default2,
33533
+ _function: () => _function,
33534
+ any: () => any,
33535
+ array: () => array,
33536
+ base64: () => base642,
33537
+ base64url: () => base64url2,
33538
+ bigint: () => bigint2,
33539
+ boolean: () => boolean2,
33540
+ catch: () => _catch2,
33541
+ check: () => check,
33542
+ cidrv4: () => cidrv42,
33543
+ cidrv6: () => cidrv62,
33544
+ codec: () => codec,
33545
+ cuid: () => cuid3,
33546
+ cuid2: () => cuid22,
33547
+ custom: () => custom,
33548
+ date: () => date3,
33549
+ describe: () => describe2,
33550
+ discriminatedUnion: () => discriminatedUnion,
33551
+ e164: () => e1642,
33552
+ email: () => email2,
33553
+ emoji: () => emoji2,
33554
+ enum: () => _enum2,
33555
+ exactOptional: () => exactOptional,
33556
+ file: () => file,
33557
+ float32: () => float32,
33558
+ float64: () => float64,
33559
+ function: () => _function,
33560
+ guid: () => guid2,
33561
+ hash: () => hash,
33562
+ hex: () => hex2,
33563
+ hostname: () => hostname2,
33564
+ httpUrl: () => httpUrl,
33565
+ instanceof: () => _instanceof,
33566
+ int: () => int,
33567
+ int32: () => int32,
33568
+ int64: () => int64,
33569
+ intersection: () => intersection,
33570
+ invertCodec: () => invertCodec,
33571
+ ipv4: () => ipv42,
33572
+ ipv6: () => ipv62,
33573
+ json: () => json,
33574
+ jwt: () => jwt,
33575
+ keyof: () => keyof,
33576
+ ksuid: () => ksuid2,
33577
+ lazy: () => lazy,
33578
+ literal: () => literal,
33579
+ looseObject: () => looseObject,
33580
+ looseRecord: () => looseRecord,
33581
+ mac: () => mac2,
33582
+ map: () => map,
33583
+ meta: () => meta2,
33584
+ nan: () => nan,
33585
+ nanoid: () => nanoid2,
33586
+ nativeEnum: () => nativeEnum,
33587
+ never: () => never,
33588
+ nonoptional: () => nonoptional,
33589
+ null: () => _null3,
33590
+ nullable: () => nullable,
33591
+ nullish: () => nullish2,
33592
+ number: () => number2,
33593
+ object: () => object,
33594
+ optional: () => optional,
33595
+ partialRecord: () => partialRecord,
33596
+ pipe: () => pipe,
33597
+ prefault: () => prefault,
33598
+ preprocess: () => preprocess,
33599
+ promise: () => promise,
33600
+ readonly: () => readonly,
33601
+ record: () => record,
33602
+ refine: () => refine,
33603
+ set: () => set,
33604
+ strictObject: () => strictObject,
33605
+ string: () => string2,
33606
+ stringFormat: () => stringFormat,
33607
+ stringbool: () => stringbool,
33608
+ success: () => success,
33609
+ superRefine: () => superRefine,
33610
+ symbol: () => symbol,
33611
+ templateLiteral: () => templateLiteral,
33612
+ transform: () => transform,
33613
+ tuple: () => tuple,
33614
+ uint32: () => uint32,
33615
+ uint64: () => uint64,
33616
+ ulid: () => ulid2,
33617
+ undefined: () => _undefined3,
33618
+ union: () => union,
33619
+ unknown: () => unknown,
33620
+ url: () => url,
33621
+ uuid: () => uuid2,
33622
+ uuidv4: () => uuidv4,
33623
+ uuidv6: () => uuidv6,
33624
+ uuidv7: () => uuidv7,
33625
+ void: () => _void2,
33626
+ xid: () => xid2,
33627
+ xor: () => xor
33657
33628
  });
33658
33629
 
33659
33630
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/checks.js
33660
33631
  var exports_checks2 = {};
33661
33632
  __export(exports_checks2, {
33662
- uppercase: () => _uppercase,
33663
- trim: () => _trim,
33664
- toUpperCase: () => _toUpperCase,
33665
- toLowerCase: () => _toLowerCase,
33666
- startsWith: () => _startsWith,
33667
- slugify: () => _slugify,
33668
- size: () => _size,
33669
- regex: () => _regex,
33670
- property: () => _property,
33671
- positive: () => _positive,
33672
- overwrite: () => _overwrite,
33673
- normalize: () => _normalize,
33674
- nonpositive: () => _nonpositive,
33675
- nonnegative: () => _nonnegative,
33676
- negative: () => _negative,
33677
- multipleOf: () => _multipleOf,
33678
- minSize: () => _minSize,
33679
- minLength: () => _minLength,
33680
- mime: () => _mime,
33681
- maxSize: () => _maxSize,
33682
- maxLength: () => _maxLength,
33683
- lte: () => _lte,
33684
- lt: () => _lt,
33685
- lowercase: () => _lowercase,
33686
- length: () => _length,
33687
- includes: () => _includes,
33688
- gte: () => _gte,
33633
+ endsWith: () => _endsWith,
33689
33634
  gt: () => _gt,
33690
- endsWith: () => _endsWith
33635
+ gte: () => _gte,
33636
+ includes: () => _includes,
33637
+ length: () => _length,
33638
+ lowercase: () => _lowercase,
33639
+ lt: () => _lt,
33640
+ lte: () => _lte,
33641
+ maxLength: () => _maxLength,
33642
+ maxSize: () => _maxSize,
33643
+ mime: () => _mime,
33644
+ minLength: () => _minLength,
33645
+ minSize: () => _minSize,
33646
+ multipleOf: () => _multipleOf,
33647
+ negative: () => _negative,
33648
+ nonnegative: () => _nonnegative,
33649
+ nonpositive: () => _nonpositive,
33650
+ normalize: () => _normalize,
33651
+ overwrite: () => _overwrite,
33652
+ positive: () => _positive,
33653
+ property: () => _property,
33654
+ regex: () => _regex,
33655
+ size: () => _size,
33656
+ slugify: () => _slugify,
33657
+ startsWith: () => _startsWith,
33658
+ toLowerCase: () => _toLowerCase,
33659
+ toUpperCase: () => _toUpperCase,
33660
+ trim: () => _trim,
33661
+ uppercase: () => _uppercase
33691
33662
  });
33692
33663
 
33693
33664
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/iso.js
33694
33665
  var exports_iso = {};
33695
33666
  __export(exports_iso, {
33696
- time: () => time2,
33697
- duration: () => duration2,
33698
- datetime: () => datetime2,
33699
- date: () => date2,
33700
- ZodISOTime: () => ZodISOTime,
33701
- ZodISODuration: () => ZodISODuration,
33667
+ ZodISODate: () => ZodISODate,
33702
33668
  ZodISODateTime: () => ZodISODateTime,
33703
- ZodISODate: () => ZodISODate
33669
+ ZodISODuration: () => ZodISODuration,
33670
+ ZodISOTime: () => ZodISOTime,
33671
+ date: () => date2,
33672
+ datetime: () => datetime2,
33673
+ duration: () => duration2,
33674
+ time: () => time2
33704
33675
  });
33705
33676
  var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
33706
33677
  $ZodISODateTime.init(inst, def);
@@ -35561,11 +35532,11 @@ function fromJSONSchema(schema, params) {
35561
35532
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/coerce.js
35562
35533
  var exports_coerce = {};
35563
35534
  __export(exports_coerce, {
35564
- string: () => string3,
35565
- number: () => number3,
35566
- date: () => date4,
35535
+ bigint: () => bigint3,
35567
35536
  boolean: () => boolean3,
35568
- bigint: () => bigint3
35537
+ date: () => date4,
35538
+ number: () => number3,
35539
+ string: () => string3
35569
35540
  });
35570
35541
  function string3(params) {
35571
35542
  return _coercedString(ZodString, params);
@@ -35846,7 +35817,7 @@ var AgentOverrideConfigSchema = exports_external.object({
35846
35817
  // ../plugin/src/config/schema/magic-context.ts
35847
35818
  var DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE = 65;
35848
35819
  var EXECUTE_THRESHOLD_CAP_MESSAGE = "execute_threshold is capped at 90% for cache safety: output capacity is reserved from the usable context window, and the remaining 10% absorbs mid-turn growth before the absolute 95% emergency wall. Use a value between 20 and 90.";
35849
- var DEFAULT_HISTORIAN_TIMEOUT_MS = 300000;
35820
+ var DEFAULT_HISTORIAN_TIMEOUT_MS = 600000;
35850
35821
  var DEFAULT_HISTORY_BUDGET_PERCENTAGE = 0.15;
35851
35822
  var DEFAULT_LOCAL_EMBEDDING_MODEL = "Xenova/all-MiniLM-L6-v2";
35852
35823
  var PiThinkingLevelSchema = exports_external.enum(["off", "minimal", "low", "medium", "high", "xhigh", "max"]).optional();
@@ -36054,7 +36025,7 @@ var MagicContextConfigSchema = exports_external.object({
36054
36025
  smart_notes: exports_external.object({
36055
36026
  retina_handoff: exports_external.boolean().default(false).describe("When true, dreamer skips smart notes whose surface conditions compiled to retina provider configs at authoring time. Default false keeps both paths active until the retina consumer is deployed.")
36056
36027
  }).default({ retina_handoff: false }).describe("Smart-note ownership transition controls."),
36057
- cache_ttl: exports_external.union([exports_external.string(), exports_external.object({ default: exports_external.string() }).catchall(exports_external.string())]).default("5m").describe('Cache TTL: string (e.g. "5m", "1h", "30s") or per-model object ({ default: "5m", "model-id": "10m" }). Set to "never" for lanes kept warm by an external keepwarm proxy — disables the idle-TTL heuristic so MC never initiates a rebuild based on elapsed time.'),
36028
+ cache_ttl: exports_external.union([exports_external.string(), exports_external.object({ default: exports_external.string() }).catchall(exports_external.string())]).default("5m").describe(`How long Magic Context assumes the provider's cached prefix stays valid. This is MC's own deferral gate — it does not change the provider's actual cache lifetime. String (e.g. "5m", "1h", "30s") or per-model object ({ default: "5m", "model-id": "10m" }). Set to "never" to mean MC never assumes expiry (for lanes kept warm externally by a cache-keep tool) — disables the idle-TTL heuristic so MC never initiates a rebuild based on elapsed time. Provider-side extended TTL is a separate request-level concern (cache_control: { ttl } in the request body).`),
36058
36029
  prompt_surface: PromptSurfaceConfigSchema.default({ default: "full" }).describe("Prompt-surface presets: default is full; models use bare model IDs, provider/model, or provider/* routing keys. Guidance and tool-description overrides are user-level only. On OpenCode and Pi, per-model routing applies to the guidance block only: tool descriptions are registered once per process, so they follow the default preset (a v1 plugin-surface limitation; per-model tool descriptions are planned for the OpenCode v2 plugin API once the SDK stabilizes)."),
36059
36030
  output_reserve: exports_external.union([
36060
36031
  exports_external.number().min(0),
@@ -36074,7 +36045,7 @@ var MagicContextConfigSchema = exports_external.object({
36074
36045
  protected_tags: exports_external.number().min(1).max(100).optional().describe("Number of recent tags to protect from dropping (min: 1, max: 100, default: 20)"),
36075
36046
  clear_reasoning_age: exports_external.number().min(10).default(50).describe("Clear reasoning/thinking blocks older than N tags (default: 50)"),
36076
36047
  history_budget_percentage: exports_external.number().min(0.05).max(0.5).default(DEFAULT_HISTORY_BUDGET_PERCENTAGE).describe("Fraction of usable context (context_limit × execute_threshold) reserved for the session history block (default: 0.15)"),
36077
- historian_timeout_ms: exports_external.number().min(60000).default(DEFAULT_HISTORIAN_TIMEOUT_MS).describe("Timeout for each historian prompt call in milliseconds (default: 300000)"),
36048
+ historian_timeout_ms: exports_external.number().min(60000).default(DEFAULT_HISTORIAN_TIMEOUT_MS).describe("Timeout for each historian prompt call in milliseconds (default: 600000)"),
36078
36049
  commit_cluster_trigger: exports_external.object({
36079
36050
  enabled: exports_external.boolean().default(true).describe("Enable commit-cluster based historian triggering (default: true)"),
36080
36051
  min_clusters: exports_external.number().min(1).default(3).describe("Minimum commit clusters required to trigger historian (min: 1, default: 3)")
@@ -39576,791 +39547,6 @@ function causeMessage(cause) {
39576
39547
  function pendingKey(handle, corr) {
39577
39548
  return handle ? `${handle.channel}:${handle.epoch}:${corr}` : `0:0:${corr}`;
39578
39549
  }
39579
- // ../../node_modules/.bun/@cortexkit+subc-client@0.4.1/node_modules/@cortexkit/subc-client/dist/provider.js
39580
- import { Buffer as Buffer4 } from "node:buffer";
39581
- var DEFAULT_HANDSHAKE_TIMEOUT_MS2 = 1e4;
39582
- var BODY_READ_TIMEOUT_MS2 = 30000;
39583
- var WRITE_TIMEOUT_MS = 30000;
39584
- var DEFAULT_RESTORED_DEBOUNCE_MS = 250;
39585
- var DEFAULT_PROVIDER_HANDLER_CAPACITY = 64;
39586
- var HEALTH_CHECK_OP = "health.check";
39587
- var HELLO_CORR = 1n;
39588
-
39589
- class AsyncPermitPool {
39590
- available;
39591
- waiters = [];
39592
- constructor(capacity) {
39593
- if (!Number.isInteger(capacity) || capacity <= 0) {
39594
- throw new SubcProviderError("provider handler capacity must be a positive integer", "invalid_handler_capacity");
39595
- }
39596
- this.available = capacity;
39597
- }
39598
- async acquire() {
39599
- if (this.available > 0) {
39600
- this.available -= 1;
39601
- return this.releaseOnce();
39602
- }
39603
- await new Promise((resolve5) => {
39604
- this.waiters.push(resolve5);
39605
- });
39606
- return this.releaseOnce();
39607
- }
39608
- releaseOnce() {
39609
- let released = false;
39610
- return () => {
39611
- if (released)
39612
- return;
39613
- released = true;
39614
- const next = this.waiters.shift();
39615
- if (next) {
39616
- next();
39617
- } else {
39618
- this.available += 1;
39619
- }
39620
- };
39621
- }
39622
- }
39623
-
39624
- class SubcProviderError extends Error {
39625
- code;
39626
- constructor(message, code) {
39627
- super(message);
39628
- this.code = code;
39629
- }
39630
- }
39631
- class SubcProvider {
39632
- sock;
39633
- currentConn;
39634
- opts;
39635
- closed;
39636
- resolveClosed = () => {
39637
- return;
39638
- };
39639
- closeStarted = false;
39640
- closedErr = null;
39641
- inflight = new Map;
39642
- pending = new Map;
39643
- liveRoutes = new Map;
39644
- connectionToken = newConnectionToken();
39645
- nextCorr = 1n;
39646
- ingressEpochDropCount = 0;
39647
- requestGate = new AsyncPermitPool(DEFAULT_PROVIDER_HANDLER_CAPACITY);
39648
- reconnecting = null;
39649
- generation = 1;
39650
- connectionEpoch = 1;
39651
- stateQueue = [];
39652
- drainingStateQueue = false;
39653
- restoredDebounceToken = 0;
39654
- storage;
39655
- constructor(sock, currentConn, opts, storage) {
39656
- this.sock = sock;
39657
- this.currentConn = currentConn;
39658
- this.opts = opts;
39659
- this.storage = storage;
39660
- this.closed = new Promise((resolve5) => {
39661
- this.resolveClosed = resolve5;
39662
- });
39663
- this.readLoop(sock, this.generation);
39664
- this.enqueueConnectionState({ state: "connected", epoch: this.connectionEpoch });
39665
- }
39666
- get droppedIngressFrames() {
39667
- return this.ingressEpochDropCount;
39668
- }
39669
- get conn() {
39670
- return this.currentConn;
39671
- }
39672
- currentEpoch() {
39673
- return this.connectionEpoch;
39674
- }
39675
- async request(handle, body, opts = {}) {
39676
- this.assertLiveHandle(handle);
39677
- const corr = this.allocateCorr();
39678
- const key = routeKey(handle, corr);
39679
- const timeoutMs = opts.timeoutMs ?? WRITE_TIMEOUT_MS;
39680
- const frame = buildFrame(FrameType.Request, buildFlags(false, opts.priority ?? Priority.Interactive, false, opts.admissionClass ?? AdmissionClass.Normal), handle.channel, handle.epoch, corr, body);
39681
- return await new Promise((resolve5, reject) => {
39682
- const timer = setTimeout(() => {
39683
- if (this.pending.delete(key))
39684
- reject(new SubcProviderError("reverse request timed out", "request_timeout"));
39685
- }, timeoutMs);
39686
- this.pending.set(key, {
39687
- resolve: (response) => resolve5(response.body),
39688
- reject,
39689
- timer
39690
- });
39691
- this.sendOn(this.sock, this.generation, frame).catch((error51) => {
39692
- const pending = this.pending.get(key);
39693
- if (!pending)
39694
- return;
39695
- this.pending.delete(key);
39696
- clearTimeout(pending.timer);
39697
- reject(error51 instanceof Error ? error51 : new SubcProviderError(String(error51)));
39698
- });
39699
- });
39700
- }
39701
- async push(handle, body, opts = {}) {
39702
- this.assertLiveHandle(handle);
39703
- await this.sendOn(this.sock, this.generation, buildFrame(FrameType.Push, buildFlags(false, opts.priority ?? Priority.Interactive, false, opts.admissionClass ?? AdmissionClass.Normal), handle.channel, handle.epoch, 0n, body));
39704
- }
39705
- cancel(handle, corr) {
39706
- this.assertLiveHandle(handle);
39707
- this.sendOn(this.sock, this.generation, buildFrame(FrameType.Cancel, controlFlags(), handle.channel, handle.epoch, corr, new Uint8Array(0)));
39708
- }
39709
- closeRoute(handle) {
39710
- this.assertLiveHandle(handle);
39711
- this.liveRoutes.delete(handle.channel);
39712
- this.abortHandle(handle);
39713
- this.sendOn(this.sock, this.generation, buildFrame(FrameType.Goodbye, controlFlags(), handle.channel, handle.epoch, 0n, new Uint8Array(0)));
39714
- }
39715
- static async connect(opts) {
39716
- if (opts.manifest.protocol_ver !== PROTOCOL_VERSION) {
39717
- throw new SubcProviderError(`manifest protocol_ver ${opts.manifest.protocol_ver} does not match client protocol ${PROTOCOL_VERSION}`, "invalid_manifest");
39718
- }
39719
- const normalized = normalizeProviderConnectOptions(opts);
39720
- const opened = await SubcProvider.openConnection(normalized);
39721
- return new SubcProvider(opened.sock, opened.conn, normalized, opened.ack.storage);
39722
- }
39723
- async close() {
39724
- if (!this.closeStarted) {
39725
- this.closeStarted = true;
39726
- this.cancelRestoredDebounce();
39727
- const sock = this.sock;
39728
- try {
39729
- await sendFrame(sock, buildFrame(FrameType.Goodbye, controlFlags(), 0, 0, 0n, new Uint8Array(0)));
39730
- } catch {} finally {
39731
- sock.close();
39732
- this.finishClosed();
39733
- }
39734
- }
39735
- await this.closed;
39736
- }
39737
- static async openConnection(opts) {
39738
- const conn = await readConnectionFile(opts.connectionFile);
39739
- const deadline = Date.now() + (opts.handshakeTimeoutMs ?? DEFAULT_HANDSHAKE_TIMEOUT_MS2);
39740
- const endpoint = conn.endpoints[0];
39741
- const sock = await SubcSocket.connect(endpoint.host, endpoint.port, deadline);
39742
- try {
39743
- await authenticateClient(sock, conn, deadline);
39744
- await sendFrame(sock, buildHelloFrame(opts));
39745
- const ack = await expectHelloAck(sock, deadline);
39746
- return { sock, conn, ack };
39747
- } catch (err) {
39748
- sock.close();
39749
- throw err;
39750
- }
39751
- }
39752
- async readLoop(sock, generation) {
39753
- try {
39754
- for (;; ) {
39755
- const frame = await sock.readFrame(Number.POSITIVE_INFINITY, { afterHeaderMs: BODY_READ_TIMEOUT_MS2 });
39756
- const keepGoing = await this.dispatch(frame, sock, generation);
39757
- if (!keepGoing) {
39758
- if (this.sock === sock && this.generation === generation)
39759
- this.closeStarted = true;
39760
- break;
39761
- }
39762
- }
39763
- } catch (error51) {
39764
- if (this.sock === sock && this.generation === generation && !this.closeStarted) {
39765
- this.handleUnexpectedDrop(sock, generation, error51 instanceof Error ? error51 : new SubcProviderError(String(error51)));
39766
- return;
39767
- }
39768
- } finally {
39769
- if (this.sock === sock && this.generation === generation) {
39770
- sock.close();
39771
- if (this.closeStarted)
39772
- this.finishClosed();
39773
- }
39774
- }
39775
- }
39776
- async dispatch(frame, sock, generation) {
39777
- let handle = null;
39778
- if (frame.header.channel !== 0) {
39779
- handle = this.liveRoutes.get(frame.header.channel) ?? null;
39780
- if (!handle || handle.epoch !== frame.header.epoch) {
39781
- this.ingressEpochDropCount += 1;
39782
- return true;
39783
- }
39784
- }
39785
- if (handle) {
39786
- const pendingKey2 = routeKey(handle, frame.header.corr);
39787
- const pending = this.pending.get(pendingKey2);
39788
- if (pending) {
39789
- if (frame.header.ty === FrameType.Push || frame.header.ty === FrameType.StreamData)
39790
- return true;
39791
- if (frame.header.ty === FrameType.Response || frame.header.ty === FrameType.StreamEnd) {
39792
- this.pending.delete(pendingKey2);
39793
- clearTimeout(pending.timer);
39794
- pending.resolve(frame);
39795
- return true;
39796
- }
39797
- if (frame.header.ty === FrameType.Error) {
39798
- this.pending.delete(pendingKey2);
39799
- clearTimeout(pending.timer);
39800
- pending.reject(providerErrorFromFrame(frame));
39801
- return true;
39802
- }
39803
- }
39804
- }
39805
- switch (frame.header.ty) {
39806
- case FrameType.Ping:
39807
- if (frame.header.channel === 0) {
39808
- await this.sendOn(sock, generation, buildFrameWithVersion(frame.header.ver, FrameType.Pong, frame.header.flags, 0, 0, frame.header.corr, new Uint8Array(0)));
39809
- }
39810
- return true;
39811
- case FrameType.Goodbye:
39812
- if (!handle)
39813
- return false;
39814
- this.liveRoutes.delete(handle.channel);
39815
- this.abortHandle(handle);
39816
- await this.opts.onRouteGone?.(handle);
39817
- return true;
39818
- case FrameType.Cancel:
39819
- if (handle)
39820
- this.inflight.get(routeKey(handle, frame.header.corr))?.abort();
39821
- return true;
39822
- case FrameType.Request:
39823
- if (frame.header.channel === 0) {
39824
- await this.handleControlRequest(frame, sock, generation);
39825
- } else if (handle) {
39826
- this.handleDataRequest(frame, handle, sock, generation).catch((error51) => {
39827
- if (!this.closeStarted && this.sock === sock && this.generation === generation) {
39828
- console.warn("SubcProvider handler failed after its request was dispatched", error51);
39829
- }
39830
- });
39831
- }
39832
- return true;
39833
- default:
39834
- return true;
39835
- }
39836
- }
39837
- abortHandle(handle) {
39838
- const prefix = `${handle.channel}:${handle.epoch}:`;
39839
- for (const [key, controller] of this.inflight) {
39840
- if (key.startsWith(prefix))
39841
- controller.abort();
39842
- }
39843
- for (const [key, pending] of this.pending) {
39844
- if (!key.startsWith(prefix))
39845
- continue;
39846
- this.pending.delete(key);
39847
- clearTimeout(pending.timer);
39848
- pending.reject(new StaleRouteHandleError(handle));
39849
- }
39850
- }
39851
- abortGeneration(_generation) {
39852
- this.abortAllInflight();
39853
- for (const [key, pending] of this.pending) {
39854
- this.pending.delete(key);
39855
- clearTimeout(pending.timer);
39856
- pending.reject(new SubcProviderError("provider connection dropped", "connection_dropped"));
39857
- }
39858
- this.liveRoutes.clear();
39859
- }
39860
- abortAllInflight() {
39861
- for (const controller of this.inflight.values())
39862
- controller.abort();
39863
- }
39864
- async handleControlRequest(frame, sock, generation) {
39865
- const request = parseJson(frame.body);
39866
- if (request.op === HEALTH_CHECK_OP) {
39867
- this.handleHealthRequest(frame, sock, generation).catch((error51) => {
39868
- if (!this.closeStarted && this.sock === sock && this.generation === generation) {
39869
- console.warn("SubcProvider health handler failed after its request was dispatched", error51);
39870
- }
39871
- });
39872
- return;
39873
- }
39874
- if (request.op !== "route.bind") {
39875
- throw new SubcProviderError(`unsupported module control request ${request.op ?? "<missing op>"}`);
39876
- }
39877
- const tentative = createRouteHandle(numberField(request.route_channel, "route_channel"), numberField(request.epoch, "epoch"), this.connectionToken);
39878
- const bindRequest = {
39879
- handle: tentative,
39880
- target: request.target,
39881
- identity: request.identity,
39882
- principal: request.principal,
39883
- consumer_capabilities: request.consumer_capabilities
39884
- };
39885
- let decision;
39886
- try {
39887
- decision = await this.opts.onBind?.(bindRequest);
39888
- } catch (error51) {
39889
- try {
39890
- await this.sendError(frame, "route_rejected", error51 instanceof Error ? error51.message : String(error51), controlFlags(), sock, generation);
39891
- } finally {
39892
- await this.opts.onRouteGone?.(tentative);
39893
- }
39894
- return;
39895
- }
39896
- const rejection = bindRejection(decision);
39897
- if (rejection) {
39898
- try {
39899
- await this.sendError(frame, rejection.code, rejection.message, controlFlags(), sock, generation);
39900
- } finally {
39901
- await this.opts.onRouteGone?.(tentative);
39902
- }
39903
- return;
39904
- }
39905
- try {
39906
- await this.sendOn(sock, generation, buildFrameWithVersion(frame.header.ver, FrameType.Response, controlFlags(), 0, 0, frame.header.corr, encodeJson({ op: "route.bind" })));
39907
- } catch (error51) {
39908
- await this.opts.onRouteGone?.(tentative);
39909
- throw error51;
39910
- }
39911
- if (this.sock !== sock || this.generation !== generation || this.closeStarted || this.closedErr) {
39912
- await this.opts.onRouteGone?.(tentative);
39913
- return;
39914
- }
39915
- this.liveRoutes.set(tentative.channel, tentative);
39916
- await this.opts.onBound?.(tentative);
39917
- }
39918
- async handleDataRequest(frame, handle, sock, generation) {
39919
- const { corr, ver } = frame.header;
39920
- const key = routeKey(handle, corr);
39921
- const controller = new AbortController;
39922
- this.inflight.set(key, controller);
39923
- const context = {
39924
- handle,
39925
- signal: controller.signal,
39926
- currentEpoch: () => this.connectionEpoch,
39927
- emit: async (eventBody, options = {}) => {
39928
- this.assertLiveHandle(handle);
39929
- if (controller.signal.aborted)
39930
- return;
39931
- await this.sendOn(sock, generation, buildFrameWithVersion(ver, FrameType.StreamData, buildFlags(false, options.priority ?? Priority.Interactive, false, options.admissionClass ?? AdmissionClass.Normal), handle.channel, handle.epoch, corr, eventBody));
39932
- }
39933
- };
39934
- const releasePermit = await (this.requestGate ?? new AsyncPermitPool(DEFAULT_PROVIDER_HANDLER_CAPACITY)).acquire();
39935
- const dataFlags = buildFlags(false, Priority.Interactive, false);
39936
- try {
39937
- const body = await this.opts.handler(handle, frame.body, context);
39938
- if (controller.signal.aborted)
39939
- return;
39940
- this.assertLiveHandle(handle);
39941
- if (body === undefined) {
39942
- await this.sendOn(sock, generation, buildFrameWithVersion(ver, FrameType.StreamEnd, dataFlags, handle.channel, handle.epoch, corr, new Uint8Array(0)));
39943
- } else if (body instanceof Uint8Array) {
39944
- await this.sendOn(sock, generation, buildFrameWithVersion(ver, FrameType.Response, dataFlags, handle.channel, handle.epoch, corr, body));
39945
- } else {
39946
- throw new SubcProviderError("provider handler must return a Uint8Array or void", "invalid_handler_response");
39947
- }
39948
- } catch (error51) {
39949
- if (error51 instanceof StaleRouteHandleError || controller.signal.aborted)
39950
- return;
39951
- await this.sendError(frame, error51 instanceof SubcProviderError && error51.code ? error51.code : "handler_error", error51 instanceof Error ? error51.message : String(error51), dataFlags, sock, generation);
39952
- } finally {
39953
- releasePermit();
39954
- if (this.inflight.get(key) === controller)
39955
- this.inflight.delete(key);
39956
- }
39957
- }
39958
- async handleHealthRequest(frame, sock, generation) {
39959
- const { corr, ver } = frame.header;
39960
- const key = `control:${generation}:${corr}`;
39961
- const controller = new AbortController;
39962
- this.inflight.set(key, controller);
39963
- const releasePermit = await (this.requestGate ?? new AsyncPermitPool(DEFAULT_PROVIDER_HANDLER_CAPACITY)).acquire();
39964
- try {
39965
- if (controller.signal.aborted)
39966
- return;
39967
- const report = await this.opts.health();
39968
- await this.sendOn(sock, generation, buildFrameWithVersion(ver, FrameType.Response, controlFlags(), 0, 0, corr, encodeJson({
39969
- op: HEALTH_CHECK_OP,
39970
- status: report.status,
39971
- ...report.detail === undefined ? {} : { detail: report.detail },
39972
- ...report.metrics === undefined ? {} : { metrics: report.metrics }
39973
- })));
39974
- } catch (error51) {
39975
- await this.sendError(frame, error51 instanceof SubcProviderError && error51.code ? error51.code : "health_error", error51 instanceof Error ? error51.message : String(error51), controlFlags(), sock, generation);
39976
- } finally {
39977
- releasePermit();
39978
- if (this.inflight.get(key) === controller)
39979
- this.inflight.delete(key);
39980
- }
39981
- }
39982
- async sendError(frame, code, message, flags, sock, generation) {
39983
- await this.sendOn(sock, generation, buildFrameWithVersion(frame.header.ver, FrameType.Error, flags, frame.header.channel, frame.header.epoch, frame.header.corr, encodeJson({ code, message })));
39984
- }
39985
- async sendOn(sock, generation, frame) {
39986
- if (this.sock !== sock || this.generation !== generation || this.closeStarted || this.closedErr)
39987
- return;
39988
- await sendFrame(sock, frame);
39989
- }
39990
- handleUnexpectedDrop(sock, generation, cause) {
39991
- this.cancelRestoredDebounce();
39992
- this.abortGeneration(generation);
39993
- this.generation += 1;
39994
- sock.close();
39995
- this.enqueueConnectionState({ state: "down", cause });
39996
- this.scheduleReconnectAfterDrop(cause);
39997
- }
39998
- scheduleReconnectAfterDrop(trigger) {
39999
- if (this.closeStarted || this.reconnecting)
40000
- return;
40001
- const promise2 = this.reconnectWithRetry(trigger).catch((err) => {
40002
- if (!this.closeStarted)
40003
- this.failFatal(err instanceof Error ? err : new SubcProviderError(String(err)));
40004
- }).finally(() => {
40005
- if (this.reconnecting === promise2)
40006
- this.reconnecting = null;
40007
- });
40008
- this.reconnecting = promise2;
40009
- }
40010
- async reconnectWithRetry(_trigger) {
40011
- let attempt = 0;
40012
- let delay = this.opts.reconnectBackoff.baseMs;
40013
- for (;; ) {
40014
- if (this.closeStarted)
40015
- throw new SubcProviderError("provider closed");
40016
- attempt += 1;
40017
- this.enqueueConnectionState({ state: "reconnecting", attempt });
40018
- try {
40019
- const opened = await SubcProvider.openConnection(this.opts);
40020
- if (this.closeStarted) {
40021
- opened.sock.close();
40022
- throw new SubcProviderError("provider closed");
40023
- }
40024
- this.replaceConnection(opened);
40025
- return;
40026
- } catch (err) {
40027
- if (this.closeStarted)
40028
- throw err;
40029
- if (!isProviderReconnectTransient(err))
40030
- throw err;
40031
- await this.opts.sleep(delay);
40032
- delay = Math.min(delay * 2, this.opts.reconnectBackoff.capMs);
40033
- }
40034
- }
40035
- }
40036
- replaceConnection(opened) {
40037
- this.sock.close();
40038
- this.sock = opened.sock;
40039
- this.currentConn = opened.conn;
40040
- this.storage = opened.ack.storage;
40041
- this.closedErr = null;
40042
- this.connectionEpoch += 1;
40043
- this.connectionToken = newConnectionToken();
40044
- this.liveRoutes.clear();
40045
- this.nextCorr = 1n;
40046
- const generation = this.generation;
40047
- this.readLoop(opened.sock, generation);
40048
- this.scheduleRestored(generation, this.connectionEpoch);
40049
- }
40050
- scheduleRestored(generation, epoch) {
40051
- if (!this.opts.onConnectionState)
40052
- return;
40053
- const token = ++this.restoredDebounceToken;
40054
- this.opts.sleep(this.opts.restoredDebounceMs).then(() => {
40055
- if (token === this.restoredDebounceToken && !this.closeStarted && this.sock && this.generation === generation && this.connectionEpoch === epoch) {
40056
- this.enqueueConnectionState({ state: "restored", epoch });
40057
- }
40058
- }).catch((err) => {
40059
- if (token === this.restoredDebounceToken && !this.closeStarted) {
40060
- console.warn("SubcProvider restored debounce timer failed", err);
40061
- }
40062
- });
40063
- }
40064
- cancelRestoredDebounce() {
40065
- this.restoredDebounceToken += 1;
40066
- }
40067
- enqueueConnectionState(event) {
40068
- if (!this.opts.onConnectionState)
40069
- return;
40070
- this.stateQueue.push(event);
40071
- if (!this.drainingStateQueue)
40072
- this.drainConnectionStateQueue();
40073
- }
40074
- async drainConnectionStateQueue() {
40075
- if (this.drainingStateQueue)
40076
- return;
40077
- this.drainingStateQueue = true;
40078
- try {
40079
- while (this.stateQueue.length > 0) {
40080
- const event = this.stateQueue[0];
40081
- try {
40082
- await this.opts.onConnectionState?.(event);
40083
- this.stateQueue.shift();
40084
- } catch (err) {
40085
- if (event.state === "restored") {
40086
- console.warn("SubcProvider restored callback failed; retrying delivery", err);
40087
- await pauseBeforeStateRetry();
40088
- continue;
40089
- }
40090
- console.warn("SubcProvider connection-state callback failed", err);
40091
- this.stateQueue.shift();
40092
- }
40093
- }
40094
- } finally {
40095
- this.drainingStateQueue = false;
40096
- if (this.stateQueue.length > 0)
40097
- this.drainConnectionStateQueue();
40098
- }
40099
- }
40100
- isLiveHandle(handle) {
40101
- return belongsToConnection(handle, this.connectionToken) && this.liveRoutes.get(handle.channel) === handle;
40102
- }
40103
- assertLiveHandle(handle) {
40104
- if (!this.isLiveHandle(handle))
40105
- throw new StaleRouteHandleError(handle);
40106
- }
40107
- allocateCorr() {
40108
- const maximum = 0xffffffffffffffffn;
40109
- if (this.nextCorr > maximum) {
40110
- const error51 = new SubcProviderError("channel-0 correlation id allocator exhausted", "corr_exhausted");
40111
- this.handleUnexpectedDrop(this.sock, this.generation, error51);
40112
- throw error51;
40113
- }
40114
- const corr = this.nextCorr;
40115
- this.nextCorr += 1n;
40116
- return corr;
40117
- }
40118
- failFatal(err) {
40119
- if (!this.closedErr)
40120
- this.closedErr = err;
40121
- this.closeStarted = true;
40122
- this.cancelRestoredDebounce();
40123
- this.abortAllInflight();
40124
- this.sock.close();
40125
- this.finishClosed();
40126
- }
40127
- finishClosed() {
40128
- this.resolveClosed();
40129
- }
40130
- }
40131
- function routeKey(handle, corr) {
40132
- return `${handle.channel}:${handle.epoch}:${corr}`;
40133
- }
40134
- function providerErrorFromFrame(frame) {
40135
- try {
40136
- const body = parseJson(frame.body);
40137
- return new SubcProviderError(body.message ?? "subc error", body.code);
40138
- } catch {
40139
- return new SubcProviderError(Buffer4.from(frame.body).toString("utf8") || "subc error");
40140
- }
40141
- }
40142
- function launchNonce(opts) {
40143
- const nonce = opts.launchNonce ?? process.env[SUBC_LAUNCH_NONCE_ENV2];
40144
- return nonce && nonce.length > 0 ? nonce : undefined;
40145
- }
40146
- var SUBC_LAUNCH_NONCE_ENV2 = "SUBC_LAUNCH_NONCE";
40147
- function normalizeProviderConnectOptions(opts) {
40148
- return {
40149
- connectionFile: opts.connectionFile,
40150
- manifest: opts.manifest,
40151
- handler: opts.handler,
40152
- health: opts.health ?? (() => ({ status: "ok" })),
40153
- handshakeTimeoutMs: opts.handshakeTimeoutMs,
40154
- controlOps: opts.controlOps,
40155
- onBind: opts.onBind,
40156
- onBound: opts.onBound,
40157
- onRouteGone: opts.onRouteGone,
40158
- reconnectBackoff: opts.reconnectBackoff ?? DEFAULT_RECONNECT_BACKOFF,
40159
- sleep: opts.sleep ?? ((ms) => new Promise((resolve5) => setTimeout(resolve5, ms))),
40160
- restoredDebounceMs: opts.restoredDebounceMs ?? DEFAULT_RESTORED_DEBOUNCE_MS,
40161
- onConnectionState: opts.onConnectionState,
40162
- launchNonce: opts.launchNonce
40163
- };
40164
- }
40165
- function normalizedControlOps(controlOps) {
40166
- if (controlOps === null)
40167
- return null;
40168
- const merged = new Set(controlOps ?? []);
40169
- merged.add(HEALTH_CHECK_OP);
40170
- return [...merged];
40171
- }
40172
- function buildHelloFrame(opts) {
40173
- const nonce = launchNonce(opts);
40174
- return buildFrame(FrameType.Hello, controlFlags(), 0, 0, HELLO_CORR, encodeJson({
40175
- manifest: normalizeManifest(opts.manifest),
40176
- protocol_ver: PROTOCOL_VERSION,
40177
- control_ops: normalizedControlOps(opts.controlOps),
40178
- ...nonce ? { launch_nonce: nonce } : {}
40179
- }));
40180
- }
40181
- function isProviderReconnectTransient(err) {
40182
- if (err instanceof SubcProviderError)
40183
- return err.code === "duplicate_module_id";
40184
- if (err instanceof SocketClosedError || err instanceof SocketTimeoutError)
40185
- return true;
40186
- if (err instanceof SocketWriteNotQueuedError || err instanceof SocketWriteQueuedError)
40187
- return true;
40188
- if (err instanceof AuthError)
40189
- return true;
40190
- if (err instanceof ConnectionFileError)
40191
- return false;
40192
- const code = errorCode2(err);
40193
- return code === "ECONNREFUSED" || code === "ECONNRESET" || code === "EPIPE" || code === "ETIMEDOUT" || code === "ENOENT";
40194
- }
40195
- function errorCode2(err) {
40196
- if (typeof err === "object" && err !== null && "code" in err) {
40197
- const code = err.code;
40198
- if (typeof code === "string")
40199
- return code;
40200
- }
40201
- return;
40202
- }
40203
- async function pauseBeforeStateRetry() {
40204
- await new Promise((resolve5) => setTimeout(resolve5, 0));
40205
- }
40206
- function controlFlags() {
40207
- return buildFlags(false, Priority.Passive, false);
40208
- }
40209
- async function sendFrame(sock, frame) {
40210
- await sock.write(encodeFrame(frame), Date.now() + WRITE_TIMEOUT_MS);
40211
- }
40212
- async function expectHelloAck(sock, deadline) {
40213
- const frame = await sock.readFrame(deadline, deadline);
40214
- switch (frame.header.ty) {
40215
- case FrameType.HelloAck: {
40216
- const ack = parseJson(frame.body);
40217
- if (ack.negotiated_ver !== PROTOCOL_VERSION) {
40218
- throw new SubcProviderError(`subc negotiated protocol ${ack.negotiated_ver}; expected exactly ${PROTOCOL_VERSION}`, "unsupported_version");
40219
- }
40220
- return ack;
40221
- }
40222
- case FrameType.Error: {
40223
- const error51 = parseJson(frame.body);
40224
- throw new SubcProviderError(`subc rejected HELLO: ${error51.code ?? "unknown"} — ${error51.message ?? "subc error"}`, error51.code);
40225
- }
40226
- default:
40227
- throw new SubcProviderError(`unexpected frame ${FrameType[frame.header.ty]} awaiting HELLO_ACK`);
40228
- }
40229
- }
40230
- function encodeJson(value) {
40231
- return new Uint8Array(Buffer4.from(JSON.stringify(value), "utf8"));
40232
- }
40233
- function parseJson(bytes) {
40234
- return JSON.parse(Buffer4.from(bytes).toString("utf8"));
40235
- }
40236
- function numberField(value, field) {
40237
- if (typeof value !== "number" || !Number.isInteger(value)) {
40238
- throw new SubcProviderError(`route.bind ${field} must be an integer`);
40239
- }
40240
- return value;
40241
- }
40242
- function bindRejection(decision) {
40243
- if (decision === undefined || decision === true)
40244
- return null;
40245
- if (decision === false) {
40246
- return { code: "route_rejected", message: "route.bind rejected by provider" };
40247
- }
40248
- if (decision.accept)
40249
- return null;
40250
- return {
40251
- code: decision.code ?? "route_rejected",
40252
- message: decision.message ?? "route.bind rejected by provider"
40253
- };
40254
- }
40255
- function normalizeManifest(manifest) {
40256
- return {
40257
- module_id: manifest.module_id,
40258
- module_version: manifest.module_version,
40259
- protocol_ver: manifest.protocol_ver,
40260
- trust_tier: manifest.trust_tier,
40261
- provides: manifest.provides.map(normalizeProviderRole),
40262
- consumes: manifest.consumes.map(normalizeConsumerRole),
40263
- scheduled_tasks: manifest.scheduled_tasks.map(normalizeScheduledTask),
40264
- bindings: {
40265
- storage: {
40266
- kind: manifest.bindings.storage.kind,
40267
- scope: manifest.bindings.storage.scope,
40268
- owns_schema: manifest.bindings.storage.owns_schema
40269
- },
40270
- vault_grants: manifest.bindings.vault_grants.map((grant) => ({
40271
- secret: grant.secret,
40272
- reason: grant.reason
40273
- })),
40274
- identity: {
40275
- requires: [...manifest.bindings.identity.requires],
40276
- optional: [...manifest.bindings.identity.optional]
40277
- }
40278
- }
40279
- };
40280
- }
40281
- function normalizeProviderRole(role) {
40282
- switch (role.role) {
40283
- case "tool_provider":
40284
- return {
40285
- role: "tool_provider",
40286
- tools: role.tools.map((tool) => ({
40287
- name: tool.name,
40288
- ...tool.description === undefined ? {} : { description: tool.description },
40289
- execution_mode: tool.execution_mode,
40290
- schema: tool.schema
40291
- })),
40292
- identity_scope: [...role.identity_scope],
40293
- concurrency: role.concurrency,
40294
- emits_push: role.emits_push,
40295
- sub_supervises: role.sub_supervises
40296
- };
40297
- case "pipeline_stage":
40298
- return {
40299
- role: "pipeline_stage",
40300
- stage: role.stage,
40301
- applies_to: {
40302
- provider: role.applies_to.provider,
40303
- model: role.applies_to.model
40304
- },
40305
- interface: role.interface,
40306
- declares_frozen_floor: role.declares_frozen_floor,
40307
- needs_signals: [...role.needs_signals],
40308
- conformance_class: role.conformance_class
40309
- };
40310
- case "management_surface":
40311
- return {
40312
- role: "management_surface",
40313
- operations: role.operations.map((operation) => ({
40314
- name: operation.name,
40315
- kind: operation.kind
40316
- })),
40317
- config_schema: role.config_schema,
40318
- observability: role.observability.map((surface) => ({
40319
- name: surface.name,
40320
- kind: surface.kind
40321
- })),
40322
- identity_scope: [...role.identity_scope]
40323
- };
40324
- case "internal_service":
40325
- return {
40326
- role: "internal_service",
40327
- service_id: role.service_id,
40328
- transport: role.transport,
40329
- agent_facing: role.agent_facing,
40330
- operations: [...role.operations]
40331
- };
40332
- }
40333
- }
40334
- function normalizeConsumerRole(role) {
40335
- switch (role.role) {
40336
- case "tool_client":
40337
- return { role: "tool_client", of: [...role.of] };
40338
- case "llm_client":
40339
- return { role: "llm_client", via: role.via, auth: role.auth };
40340
- case "service_client":
40341
- return { role: "service_client", of: [...role.of] };
40342
- }
40343
- }
40344
- function normalizeScheduledTask(task) {
40345
- return {
40346
- task_id: task.task_id,
40347
- eligibility: {
40348
- cooldown: task.eligibility.cooldown,
40349
- window: task.eligibility.window
40350
- },
40351
- lease_scope: task.lease_scope,
40352
- renews_during_calls: task.renews_during_calls,
40353
- toolset: [...task.toolset],
40354
- model_policy: {
40355
- tier: task.model_policy.tier,
40356
- fallback_chain: [...task.model_policy.fallback_chain]
40357
- },
40358
- step_cap: task.step_cap,
40359
- circuit_breaker: {
40360
- identical_failures: task.circuit_breaker.identical_failures
40361
- }
40362
- };
40363
- }
40364
39550
  // ../plugin/src/features/magic-context/memory/embedding-synapse.ts
40365
39551
  var SYNAPSE_DEFAULT_MODEL = "gte-modernbert-base-f16";
40366
39552
  var SYNAPSE_MAX_INPUT_TOKENS = 8192;
@@ -44326,12 +43512,12 @@ function unwrapImitatedReducedArgs(args, primaryFields, schema) {
44326
43512
  // ../../node_modules/.bun/typebox@1.3.1/node_modules/typebox/build/system/memory/memory.mjs
44327
43513
  var exports_memory = {};
44328
43514
  __export(exports_memory, {
44329
- Update: () => Update,
44330
- Metrics: () => Metrics,
44331
- Discard: () => Discard,
44332
- Create: () => Create,
43515
+ Assign: () => Assign,
44333
43516
  Clone: () => Clone,
44334
- Assign: () => Assign
43517
+ Create: () => Create,
43518
+ Discard: () => Discard,
43519
+ Metrics: () => Metrics,
43520
+ Update: () => Update
44335
43521
  });
44336
43522
 
44337
43523
  // ../../node_modules/.bun/typebox@1.3.1/node_modules/typebox/build/system/memory/metrics.mjs
@@ -44351,41 +43537,41 @@ function Assign(left, right) {
44351
43537
  // ../../node_modules/.bun/typebox@1.3.1/node_modules/typebox/build/guard/guard.mjs
44352
43538
  var exports_guard = {};
44353
43539
  __export(exports_guard, {
44354
- Values: () => Values,
44355
- Symbols: () => Symbols,
44356
- ShiftLeft: () => ShiftLeft,
44357
- Keys: () => Keys,
44358
- IsValueLike: () => IsValueLike,
44359
- IsUnsafePropertyKey: () => IsUnsafePropertyKey,
44360
- IsUndefined: () => IsUndefined,
44361
- IsSymbol: () => IsSymbol,
44362
- IsString: () => IsString,
44363
- IsObjectNotArray: () => IsObjectNotArray,
44364
- IsObject: () => IsObject,
44365
- IsNumber: () => IsNumber,
44366
- IsNull: () => IsNull,
44367
- IsMultipleOf: () => IsMultipleOf,
44368
- IsMinLength: () => IsMinLength2,
44369
- IsMaxLength: () => IsMaxLength2,
44370
- IsLessThan: () => IsLessThan,
44371
- IsLessEqualThan: () => IsLessEqualThan,
44372
- IsInteger: () => IsInteger,
44373
- IsGreaterThan: () => IsGreaterThan,
44374
- IsGreaterEqualThan: () => IsGreaterEqualThan,
44375
- IsFunction: () => IsFunction,
44376
- IsEqual: () => IsEqual,
44377
- IsDeepEqual: () => IsDeepEqual,
44378
- IsConstructor: () => IsConstructor,
44379
- IsClassInstance: () => IsClassInstance,
44380
- IsBoolean: () => IsBoolean,
44381
- IsBigInt: () => IsBigInt,
44382
- IsArray: () => IsArray,
44383
- HasPropertyKey: () => HasPropertyKey,
44384
- GraphemeCount: () => GraphemeCount2,
44385
- EveryAll: () => EveryAll,
44386
- Every: () => Every,
43540
+ Entries: () => Entries,
44387
43541
  EntriesRegExp: () => EntriesRegExp,
44388
- Entries: () => Entries
43542
+ Every: () => Every,
43543
+ EveryAll: () => EveryAll,
43544
+ GraphemeCount: () => GraphemeCount2,
43545
+ HasPropertyKey: () => HasPropertyKey,
43546
+ IsArray: () => IsArray,
43547
+ IsBigInt: () => IsBigInt,
43548
+ IsBoolean: () => IsBoolean,
43549
+ IsClassInstance: () => IsClassInstance,
43550
+ IsConstructor: () => IsConstructor,
43551
+ IsDeepEqual: () => IsDeepEqual,
43552
+ IsEqual: () => IsEqual,
43553
+ IsFunction: () => IsFunction,
43554
+ IsGreaterEqualThan: () => IsGreaterEqualThan,
43555
+ IsGreaterThan: () => IsGreaterThan,
43556
+ IsInteger: () => IsInteger,
43557
+ IsLessEqualThan: () => IsLessEqualThan,
43558
+ IsLessThan: () => IsLessThan,
43559
+ IsMaxLength: () => IsMaxLength2,
43560
+ IsMinLength: () => IsMinLength2,
43561
+ IsMultipleOf: () => IsMultipleOf,
43562
+ IsNull: () => IsNull,
43563
+ IsNumber: () => IsNumber,
43564
+ IsObject: () => IsObject,
43565
+ IsObjectNotArray: () => IsObjectNotArray,
43566
+ IsString: () => IsString,
43567
+ IsSymbol: () => IsSymbol,
43568
+ IsUndefined: () => IsUndefined,
43569
+ IsUnsafePropertyKey: () => IsUnsafePropertyKey,
43570
+ IsValueLike: () => IsValueLike,
43571
+ Keys: () => Keys,
43572
+ ShiftLeft: () => ShiftLeft,
43573
+ Symbols: () => Symbols,
43574
+ Values: () => Values
44389
43575
  });
44390
43576
 
44391
43577
  // ../../node_modules/.bun/typebox@1.3.1/node_modules/typebox/build/guard/string.mjs
@@ -44640,25 +43826,25 @@ function IsDeepEqual(left, right) {
44640
43826
  // ../../node_modules/.bun/typebox@1.3.1/node_modules/typebox/build/guard/globals.mjs
44641
43827
  var exports_globals = {};
44642
43828
  __export(exports_globals, {
44643
- IsUint8ClampedArray: () => IsUint8ClampedArray,
44644
- IsUint8Array: () => IsUint8Array,
44645
- IsUint32Array: () => IsUint32Array,
44646
- IsUint16Array: () => IsUint16Array,
44647
- IsTypeArray: () => IsTypeArray,
44648
- IsString: () => IsString2,
44649
- IsSet: () => IsSet,
44650
- IsRegExp: () => IsRegExp,
44651
- IsNumber: () => IsNumber2,
44652
- IsMap: () => IsMap,
44653
- IsInt8Array: () => IsInt8Array,
44654
- IsInt32Array: () => IsInt32Array,
44655
- IsInt16Array: () => IsInt16Array,
44656
- IsFloat64Array: () => IsFloat64Array,
44657
- IsFloat32Array: () => IsFloat32Array,
44658
- IsDate: () => IsDate,
44659
- IsBoolean: () => IsBoolean2,
43829
+ IsBigInt64Array: () => IsBigInt64Array,
44660
43830
  IsBigUint64Array: () => IsBigUint64Array,
44661
- IsBigInt64Array: () => IsBigInt64Array
43831
+ IsBoolean: () => IsBoolean2,
43832
+ IsDate: () => IsDate,
43833
+ IsFloat32Array: () => IsFloat32Array,
43834
+ IsFloat64Array: () => IsFloat64Array,
43835
+ IsInt16Array: () => IsInt16Array,
43836
+ IsInt32Array: () => IsInt32Array,
43837
+ IsInt8Array: () => IsInt8Array,
43838
+ IsMap: () => IsMap,
43839
+ IsNumber: () => IsNumber2,
43840
+ IsRegExp: () => IsRegExp,
43841
+ IsSet: () => IsSet,
43842
+ IsString: () => IsString2,
43843
+ IsTypeArray: () => IsTypeArray,
43844
+ IsUint16Array: () => IsUint16Array,
43845
+ IsUint32Array: () => IsUint32Array,
43846
+ IsUint8Array: () => IsUint8Array,
43847
+ IsUint8ClampedArray: () => IsUint8ClampedArray
44662
43848
  });
44663
43849
  function IsBoolean2(value) {
44664
43850
  return value instanceof Boolean;
@@ -44777,9 +43963,9 @@ function Clone(value) {
44777
43963
  // ../../node_modules/.bun/typebox@1.3.1/node_modules/typebox/build/system/settings/settings.mjs
44778
43964
  var exports_settings = {};
44779
43965
  __export(exports_settings, {
44780
- Set: () => Set2,
43966
+ Get: () => Get,
44781
43967
  Reset: () => Reset,
44782
- Get: () => Get
43968
+ Set: () => Set2
44783
43969
  });
44784
43970
  var settings = {
44785
43971
  immutableTypes: false,
@@ -46638,14 +45824,14 @@ function IsTemplateLiteral(value) {
46638
45824
  // ../../node_modules/.bun/typebox@1.3.1/node_modules/typebox/build/type/extends/result.mjs
46639
45825
  var exports_result = {};
46640
45826
  __export(exports_result, {
46641
- Match: () => Match3,
46642
- IsExtendsUnion: () => IsExtendsUnion,
46643
- IsExtendsTrueLike: () => IsExtendsTrueLike,
46644
- IsExtendsTrue: () => IsExtendsTrue,
46645
- IsExtendsFalse: () => IsExtendsFalse,
46646
- ExtendsUnion: () => ExtendsUnion,
45827
+ ExtendsFalse: () => ExtendsFalse,
46647
45828
  ExtendsTrue: () => ExtendsTrue,
46648
- ExtendsFalse: () => ExtendsFalse
45829
+ ExtendsUnion: () => ExtendsUnion,
45830
+ IsExtendsFalse: () => IsExtendsFalse,
45831
+ IsExtendsTrue: () => IsExtendsTrue,
45832
+ IsExtendsTrueLike: () => IsExtendsTrueLike,
45833
+ IsExtendsUnion: () => IsExtendsUnion,
45834
+ Match: () => Match3
46649
45835
  });
46650
45836
  function ExtendsUnion(inferred) {
46651
45837
  return exports_memory.Create({ ["~kind"]: "ExtendsUnion" }, { inferred });
@@ -48424,121 +47610,121 @@ function Script2(...args) {
48424
47610
  // ../../node_modules/.bun/typebox@1.3.1/node_modules/typebox/build/typebox.mjs
48425
47611
  var exports_typebox = {};
48426
47612
  __export(exports_typebox, {
48427
- With: () => With2,
48428
- Void: () => Void,
48429
- Uppercase: () => Uppercase,
48430
- Unsafe: () => Unsafe,
48431
- Unknown: () => Unknown,
48432
- Union: () => Union,
48433
- Undefined: () => Undefined,
48434
- Uncapitalize: () => Uncapitalize,
48435
- Tuple: () => Tuple,
48436
- This: () => This,
48437
- TemplateLiteral: () => TemplateLiteral2,
48438
- Symbol: () => Symbol2,
48439
- String: () => String2,
48440
- Script: () => Script2,
48441
- ReturnType: () => ReturnType,
48442
- Rest: () => Rest,
48443
- Required: () => Required,
48444
- Refine: () => Refine,
48445
- Ref: () => Ref,
48446
- RecordValue: () => RecordValue,
48447
- RecordPattern: () => RecordPattern,
48448
- RecordKey: () => RecordKey,
48449
- Record: () => Record,
48450
- ReadonlyObject: () => ReadonlyObject,
48451
- Readonly: () => Readonly,
48452
- Pick: () => Pick,
48453
- Partial: () => Partial,
48454
- Parameters: () => Parameters,
48455
- Parameter: () => Parameter,
48456
- Optional: () => Optional,
48457
- Omit: () => Omit,
48458
- Object: () => _Object_,
48459
- Number: () => Number2,
48460
- Null: () => Null,
48461
- NonNullable: () => NonNullable,
48462
- Never: () => Never,
48463
- Module: () => Module2,
48464
- Mapped: () => Mapped,
48465
- Lowercase: () => Lowercase,
48466
- Literal: () => Literal,
48467
- KeyOf: () => KeyOf2,
48468
- IsVoid: () => IsVoid,
48469
- IsUnsafe: () => IsUnsafe,
48470
- IsUnknown: () => IsUnknown,
48471
- IsUnion: () => IsUnion,
48472
- IsUndefined: () => IsUndefined2,
48473
- IsTuple: () => IsTuple,
48474
- IsThis: () => IsThis,
48475
- IsTemplateLiteral: () => IsTemplateLiteral,
48476
- IsSymbol: () => IsSymbol2,
48477
- IsString: () => IsString3,
48478
- IsSchema: () => IsSchema,
48479
- IsRest: () => IsRest,
48480
- IsRefine: () => IsRefine,
48481
- IsRef: () => IsRef,
48482
- IsRecord: () => IsRecord,
48483
- IsReadonly: () => IsReadonly,
48484
- IsParameter: () => IsParameter,
48485
- IsOptional: () => IsOptional,
48486
- IsObject: () => IsObject2,
48487
- IsNumber: () => IsNumber3,
48488
- IsNull: () => IsNull2,
48489
- IsNever: () => IsNever,
48490
- IsLiteral: () => IsLiteral,
48491
- IsKind: () => IsKind,
48492
- IsIntersect: () => IsIntersect,
48493
- IsInteger: () => IsInteger2,
48494
- IsInfer: () => IsInfer,
48495
- IsImmutable: () => IsImmutable,
48496
- IsIdentifier: () => IsIdentifier,
48497
- IsGeneric: () => IsGeneric,
48498
- IsFunction: () => IsFunction2,
48499
- IsEnum: () => IsEnum,
48500
- IsDependent: () => IsDependent,
48501
- IsCyclic: () => IsCyclic,
48502
- IsConstructor: () => IsConstructor2,
48503
- IsCodec: () => IsCodec,
48504
- IsCall: () => IsCall,
48505
- IsBoolean: () => IsBoolean3,
48506
- IsBigInt: () => IsBigInt2,
48507
- IsArray: () => IsArray2,
48508
- IsAny: () => IsAny,
48509
- Intersect: () => Intersect,
48510
- Interface: () => Interface,
48511
- Integer: () => Integer,
48512
- Instantiate: () => Instantiate,
48513
- InstanceType: () => InstanceType,
48514
- Infer: () => Infer,
48515
- Index: () => Index,
48516
- Immutable: () => Immutable,
48517
- Identifier: () => Identifier,
48518
- Generic: () => Generic,
48519
- Function: () => _Function_,
48520
- Extract: () => Extract,
48521
- ExtendsResult: () => exports_result,
48522
- Extends: () => Extends,
48523
- Exclude: () => Exclude,
48524
- Evaluate: () => Evaluate,
48525
- Enum: () => Enum,
48526
- EncodeBuilder: () => EncodeBuilder,
48527
- Encode: () => Encode,
48528
- Dependent: () => Dependent,
48529
- DecodeBuilder: () => DecodeBuilder,
48530
- Decode: () => Decode,
48531
- Cyclic: () => Cyclic,
48532
- ConstructorParameters: () => ConstructorParameters,
48533
- Constructor: () => Constructor,
48534
- Conditional: () => Conditional,
48535
- Codec: () => Codec,
48536
- Capitalize: () => Capitalize,
48537
- Call: () => Call,
48538
- Boolean: () => Boolean2,
48539
- BigInt: () => BigInt2,
47613
+ Any: () => Any,
48540
47614
  Array: () => _Array_,
48541
- Any: () => Any
47615
+ BigInt: () => BigInt2,
47616
+ Boolean: () => Boolean2,
47617
+ Call: () => Call,
47618
+ Capitalize: () => Capitalize,
47619
+ Codec: () => Codec,
47620
+ Conditional: () => Conditional,
47621
+ Constructor: () => Constructor,
47622
+ ConstructorParameters: () => ConstructorParameters,
47623
+ Cyclic: () => Cyclic,
47624
+ Decode: () => Decode,
47625
+ DecodeBuilder: () => DecodeBuilder,
47626
+ Dependent: () => Dependent,
47627
+ Encode: () => Encode,
47628
+ EncodeBuilder: () => EncodeBuilder,
47629
+ Enum: () => Enum,
47630
+ Evaluate: () => Evaluate,
47631
+ Exclude: () => Exclude,
47632
+ Extends: () => Extends,
47633
+ ExtendsResult: () => exports_result,
47634
+ Extract: () => Extract,
47635
+ Function: () => _Function_,
47636
+ Generic: () => Generic,
47637
+ Identifier: () => Identifier,
47638
+ Immutable: () => Immutable,
47639
+ Index: () => Index,
47640
+ Infer: () => Infer,
47641
+ InstanceType: () => InstanceType,
47642
+ Instantiate: () => Instantiate,
47643
+ Integer: () => Integer,
47644
+ Interface: () => Interface,
47645
+ Intersect: () => Intersect,
47646
+ IsAny: () => IsAny,
47647
+ IsArray: () => IsArray2,
47648
+ IsBigInt: () => IsBigInt2,
47649
+ IsBoolean: () => IsBoolean3,
47650
+ IsCall: () => IsCall,
47651
+ IsCodec: () => IsCodec,
47652
+ IsConstructor: () => IsConstructor2,
47653
+ IsCyclic: () => IsCyclic,
47654
+ IsDependent: () => IsDependent,
47655
+ IsEnum: () => IsEnum,
47656
+ IsFunction: () => IsFunction2,
47657
+ IsGeneric: () => IsGeneric,
47658
+ IsIdentifier: () => IsIdentifier,
47659
+ IsImmutable: () => IsImmutable,
47660
+ IsInfer: () => IsInfer,
47661
+ IsInteger: () => IsInteger2,
47662
+ IsIntersect: () => IsIntersect,
47663
+ IsKind: () => IsKind,
47664
+ IsLiteral: () => IsLiteral,
47665
+ IsNever: () => IsNever,
47666
+ IsNull: () => IsNull2,
47667
+ IsNumber: () => IsNumber3,
47668
+ IsObject: () => IsObject2,
47669
+ IsOptional: () => IsOptional,
47670
+ IsParameter: () => IsParameter,
47671
+ IsReadonly: () => IsReadonly,
47672
+ IsRecord: () => IsRecord,
47673
+ IsRef: () => IsRef,
47674
+ IsRefine: () => IsRefine,
47675
+ IsRest: () => IsRest,
47676
+ IsSchema: () => IsSchema,
47677
+ IsString: () => IsString3,
47678
+ IsSymbol: () => IsSymbol2,
47679
+ IsTemplateLiteral: () => IsTemplateLiteral,
47680
+ IsThis: () => IsThis,
47681
+ IsTuple: () => IsTuple,
47682
+ IsUndefined: () => IsUndefined2,
47683
+ IsUnion: () => IsUnion,
47684
+ IsUnknown: () => IsUnknown,
47685
+ IsUnsafe: () => IsUnsafe,
47686
+ IsVoid: () => IsVoid,
47687
+ KeyOf: () => KeyOf2,
47688
+ Literal: () => Literal,
47689
+ Lowercase: () => Lowercase,
47690
+ Mapped: () => Mapped,
47691
+ Module: () => Module2,
47692
+ Never: () => Never,
47693
+ NonNullable: () => NonNullable,
47694
+ Null: () => Null,
47695
+ Number: () => Number2,
47696
+ Object: () => _Object_,
47697
+ Omit: () => Omit,
47698
+ Optional: () => Optional,
47699
+ Parameter: () => Parameter,
47700
+ Parameters: () => Parameters,
47701
+ Partial: () => Partial,
47702
+ Pick: () => Pick,
47703
+ Readonly: () => Readonly,
47704
+ ReadonlyObject: () => ReadonlyObject,
47705
+ Record: () => Record,
47706
+ RecordKey: () => RecordKey,
47707
+ RecordPattern: () => RecordPattern,
47708
+ RecordValue: () => RecordValue,
47709
+ Ref: () => Ref,
47710
+ Refine: () => Refine,
47711
+ Required: () => Required,
47712
+ Rest: () => Rest,
47713
+ ReturnType: () => ReturnType,
47714
+ Script: () => Script2,
47715
+ String: () => String2,
47716
+ Symbol: () => Symbol2,
47717
+ TemplateLiteral: () => TemplateLiteral2,
47718
+ This: () => This,
47719
+ Tuple: () => Tuple,
47720
+ Uncapitalize: () => Uncapitalize,
47721
+ Undefined: () => Undefined,
47722
+ Union: () => Union,
47723
+ Unknown: () => Unknown,
47724
+ Unsafe: () => Unsafe,
47725
+ Uppercase: () => Uppercase,
47726
+ Void: () => Void,
47727
+ With: () => With2
48542
47728
  });
48543
47729
  // src/tools/ctx-expand.ts
48544
47730
  var ParamsSchema = exports_typebox.Object({
@@ -49176,6 +48362,9 @@ function assertTsMemoryIdWriteAllowed(db, id) {
49176
48362
  return memory2;
49177
48363
  }
49178
48364
  function insertMemory(db, input) {
48365
+ if (input.sourceType === "user") {
48366
+ throw new Error(`sourceType "user" is reserved for future dashboard manual entry and cannot be written by agent paths`);
48367
+ }
49179
48368
  assertTsMemoryWriteAllowed(db, input.projectPath);
49180
48369
  const now = Date.now();
49181
48370
  const normalizedHash = computeNormalizedHash(input.content);