@massu/core 2.5.4 → 2.5.6

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.
@@ -481,7 +481,8 @@ var init_config = __esm({
481
481
  input_per_million: z2.number(),
482
482
  output_per_million: z2.number(),
483
483
  cache_read_per_million: z2.number().optional(),
484
- cache_write_per_million: z2.number().optional()
484
+ cache_write_per_million: z2.number().optional(),
485
+ cache_write_1h_per_million: z2.number().optional()
485
486
  });
486
487
  AnalyticsConfigSchema = z2.object({
487
488
  quality: z2.object({
@@ -2137,6 +2138,7 @@ __export(memory_db_exports, {
2137
2138
  pruneToolCostEvents: () => pruneToolCostEvents,
2138
2139
  recordRecallHits: () => recordRecallHits,
2139
2140
  recordTelemetry: () => recordTelemetry,
2141
+ releaseMetaLease: () => releaseMetaLease,
2140
2142
  removePendingSync: () => removePendingSync,
2141
2143
  sanitizeFts5Query: () => sanitizeFts5Query,
2142
2144
  sanitizeFts5QueryOr: () => sanitizeFts5QueryOr,
@@ -2145,6 +2147,7 @@ __export(memory_db_exports, {
2145
2147
  searchObservations: () => searchObservations,
2146
2148
  setLastProcessedLine: () => setLastProcessedLine,
2147
2149
  setMemoryMeta: () => setMemoryMeta,
2150
+ tryAcquireMetaLease: () => tryAcquireMetaLease,
2148
2151
  upsertObservationEmbedding: () => upsertObservationEmbedding,
2149
2152
  usageWarmupElapsed: () => usageWarmupElapsed
2150
2153
  });
@@ -2650,6 +2653,15 @@ function initMemorySchema(db) {
2650
2653
  );
2651
2654
  CREATE INDEX IF NOT EXISTS idx_sc_session ON session_costs(session_id);
2652
2655
  `);
2656
+ const costCols = db.prepare(`PRAGMA table_info(session_costs)`).all();
2657
+ const addCostCol = (name, ddl) => {
2658
+ if (!costCols.some((c) => c.name === name)) db.exec(`ALTER TABLE session_costs ADD COLUMN ${ddl}`);
2659
+ };
2660
+ addCostCol("cost_status", `cost_status TEXT NOT NULL DEFAULT 'unknown'`);
2661
+ addCostCol("unpriced_models", `unpriced_models TEXT NOT NULL DEFAULT ''`);
2662
+ addCostCol("priced_responses", `priced_responses INTEGER NOT NULL DEFAULT 0`);
2663
+ addCostCol("unpriced_responses", `unpriced_responses INTEGER NOT NULL DEFAULT 0`);
2664
+ addCostCol("pricing_version", `pricing_version INTEGER NOT NULL DEFAULT 0`);
2653
2665
  db.exec(`
2654
2666
  CREATE TABLE IF NOT EXISTS feature_costs (
2655
2667
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -3079,6 +3091,18 @@ function getMemoryMeta(db, key) {
3079
3091
  function setMemoryMeta(db, key, value) {
3080
3092
  db.prepare("INSERT OR REPLACE INTO memory_meta (key, value) VALUES (?, ?)").run(key, value);
3081
3093
  }
3094
+ function tryAcquireMetaLease(db, key, ttlSec, nowSec = Math.floor(Date.now() / 1e3)) {
3095
+ const r = db.prepare(
3096
+ `INSERT INTO memory_meta (key, value) VALUES (?, ?)
3097
+ ON CONFLICT(key) DO UPDATE SET value = excluded.value
3098
+ WHERE memory_meta.value = ''
3099
+ OR CAST(substr(memory_meta.value, instr(memory_meta.value, ':') + 1) AS INTEGER) <= ?`
3100
+ ).run(key, `${process.pid}:${nowSec + ttlSec}`, nowSec);
3101
+ return Number(r.changes) === 1;
3102
+ }
3103
+ function releaseMetaLease(db, key) {
3104
+ db.prepare(`UPDATE memory_meta SET value = '' WHERE key = ? AND value LIKE ?`).run(key, `${process.pid}:%`);
3105
+ }
3082
3106
  function upsertObservationEmbedding(db, observationId, vec, modelId, dim) {
3083
3107
  db.prepare(
3084
3108
  `INSERT OR REPLACE INTO observation_embeddings (observation_id, model_id, dim, vec, created_at)
@@ -3947,7 +3971,7 @@ var init_memory_db = __esm({
3947
3971
  init_rule_candidate_store();
3948
3972
  init_hook_failure_signal();
3949
3973
  init_memory_embed_sweep();
3950
- MEMORY_SCHEMA_VERSION = 1;
3974
+ MEMORY_SCHEMA_VERSION = 2;
3951
3975
  TOOL_COST_EVENTS_RETENTION_DAYS = 90;
3952
3976
  MAX_DRAFT_TEXT_LEN = 16384;
3953
3977
  FUNNEL_EVENT_OUTBOX_CAP = 2e4;