chat-recall 0.7.21 → 0.7.24

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.
@@ -5409,19 +5409,19 @@ function mapJsonStrings(line, fn, escapedOnly) {
5409
5409
  const q = line.indexOf('"', i);
5410
5410
  if (q < 0)
5411
5411
  return out + line.slice(i);
5412
- let j = q + 1;
5413
- while (j < line.length) {
5414
- const c = line.charCodeAt(j);
5412
+ let j2 = q + 1;
5413
+ while (j2 < line.length) {
5414
+ const c = line.charCodeAt(j2);
5415
5415
  if (c === 92)
5416
- j += 2;
5416
+ j2 += 2;
5417
5417
  else if (c === 34)
5418
5418
  break;
5419
5419
  else
5420
- j++;
5420
+ j2++;
5421
5421
  }
5422
- const token = line.slice(q, j + 1);
5422
+ const token = line.slice(q, j2 + 1);
5423
5423
  out += line.slice(i, q);
5424
- i = j + 1;
5424
+ i = j2 + 1;
5425
5425
  const body = token.slice(1, -1);
5426
5426
  const escaped = body.includes("\\");
5427
5427
  if (escapedOnly && !escaped) {
@@ -6208,6 +6208,130 @@ var init_sqlite_reader = __esm({
6208
6208
  }
6209
6209
  });
6210
6210
 
6211
+ // ../engine/dist/core/backends/opencode-v2.js
6212
+ function hasTable(db, name) {
6213
+ return !!db.prepare("SELECT 1 FROM main.sqlite_master WHERE type = 'table' AND name = ?").get(name);
6214
+ }
6215
+ function columnsOf(db, table) {
6216
+ return new Set(db.prepare(`SELECT name FROM pragma_table_info('${table}', 'main')`).all().map((r) => r.name));
6217
+ }
6218
+ function installOpencodeV2Views(db) {
6219
+ if (!hasTable(db, "session_v2") || !hasTable(db, "session_message"))
6220
+ return false;
6221
+ const v2Cols = columnsOf(db, "session_v2");
6222
+ const sessionCols = SESSION_COLUMNS.map((c) => v2Cols.has(c) ? c : `NULL AS ${c}`).join(", ");
6223
+ const hasV1 = hasTable(db, "message") && hasTable(db, "part");
6224
+ const v1Messages = hasV1 ? `SELECT id, session_id, time_created, time_updated, data FROM main.message WHERE session_id NOT IN (${V2_SESSIONS}) UNION ALL ` : "";
6225
+ const v1Parts = hasV1 ? `SELECT id, message_id, session_id, time_created, time_updated, data FROM main.part WHERE session_id NOT IN (${V2_SESSIONS}) UNION ALL ` : "";
6226
+ db.exec(`
6227
+ CREATE TEMP VIEW IF NOT EXISTS session AS SELECT ${sessionCols} FROM main.session_v2;
6228
+
6229
+ CREATE TEMP VIEW IF NOT EXISTS message AS
6230
+ ${v1Messages}
6231
+ SELECT m.id, m.session_id, m.time_created, m.time_updated,
6232
+ CASE m.type
6233
+ WHEN 'user' THEN json_object('role', 'user', 'time', ${j("$.time")})
6234
+ ELSE json_object(
6235
+ 'role', 'assistant',
6236
+ 'agent', json_extract(m.data, '$.agent'),
6237
+ 'modelID', json_extract(m.data, '$.model.id'),
6238
+ 'providerID', json_extract(m.data, '$.model.providerID'),
6239
+ 'cost', coalesce(json_extract(m.data, '$.cost'), 0),
6240
+ 'tokens', ${j("$.tokens")},
6241
+ 'time', ${j("$.time")})
6242
+ END AS data
6243
+ FROM main.session_message m WHERE m.type IN ('user', 'assistant');
6244
+
6245
+ CREATE TEMP VIEW IF NOT EXISTS part AS
6246
+ ${v1Parts}
6247
+ SELECT m.id || ':text', m.id, m.session_id, m.time_created, m.time_updated,
6248
+ json_object('type', 'text', 'text', json_extract(m.data, '$.text'))
6249
+ FROM main.session_message m
6250
+ WHERE m.type = 'user' AND json_extract(m.data, '$.text') IS NOT NULL
6251
+ UNION ALL
6252
+ SELECT m.id || ':' || c.key, m.id, m.session_id, m.time_created + c.key, m.time_updated,
6253
+ CASE json_extract(c.value, '$.type')
6254
+ WHEN 'tool' THEN json_object(
6255
+ 'type', 'tool',
6256
+ 'tool', json_extract(c.value, '$.name'),
6257
+ 'callID', json_extract(c.value, '$.id'),
6258
+ 'state', json_object(
6259
+ 'status', json_extract(c.value, '$.state.status'),
6260
+ 'input', json(coalesce(json_extract(c.value, '$.state.input'), '{}')),
6261
+ 'output', (SELECT group_concat(json_extract(o.value, '$.text'), char(10))
6262
+ FROM json_each(c.value, '$.state.content') o
6263
+ WHERE json_extract(o.value, '$.type') = 'text')))
6264
+ ELSE json_object('type', json_extract(c.value, '$.type'), 'text', json_extract(c.value, '$.text'))
6265
+ END
6266
+ FROM main.session_message m, json_each(m.data, '$.content') c
6267
+ WHERE m.type = 'assistant'
6268
+ UNION ALL
6269
+ SELECT m.id || ':step', m.id, m.session_id,
6270
+ coalesce(json_extract(m.data, '$.time.completed'), m.time_created), m.time_updated,
6271
+ json_object('type', 'step-finish', 'cost', coalesce(json_extract(m.data, '$.cost'), 0), 'tokens', ${j("$.tokens")})
6272
+ FROM main.session_message m WHERE m.type = 'assistant';
6273
+ `);
6274
+ return true;
6275
+ }
6276
+ function openOpencodeDb(path) {
6277
+ const db = openSqliteReadonly(path);
6278
+ if (!db)
6279
+ return null;
6280
+ try {
6281
+ installOpencodeV2Views(db);
6282
+ } catch {
6283
+ }
6284
+ return db;
6285
+ }
6286
+ function openOpencodeDbOrThrow(path) {
6287
+ const db = openSqliteReadonlyOrThrow(path);
6288
+ try {
6289
+ installOpencodeV2Views(db);
6290
+ } catch {
6291
+ }
6292
+ return db;
6293
+ }
6294
+ var SESSION_COLUMNS, j, V2_SESSIONS;
6295
+ var init_opencode_v2 = __esm({
6296
+ "../engine/dist/core/backends/opencode-v2.js"() {
6297
+ "use strict";
6298
+ init_sqlite_reader();
6299
+ SESSION_COLUMNS = [
6300
+ "id",
6301
+ "project_id",
6302
+ "parent_id",
6303
+ "slug",
6304
+ "directory",
6305
+ "title",
6306
+ "version",
6307
+ "share_url",
6308
+ "summary_additions",
6309
+ "summary_deletions",
6310
+ "summary_files",
6311
+ "summary_diffs",
6312
+ "revert",
6313
+ "permission",
6314
+ "time_created",
6315
+ "time_updated",
6316
+ "time_compacting",
6317
+ "time_archived",
6318
+ "workspace_id",
6319
+ "path",
6320
+ "agent",
6321
+ "model",
6322
+ "cost",
6323
+ "tokens_input",
6324
+ "tokens_output",
6325
+ "tokens_reasoning",
6326
+ "tokens_cache_read",
6327
+ "tokens_cache_write",
6328
+ "metadata"
6329
+ ];
6330
+ j = (path, fallback = "'{}'") => `json(coalesce(json_extract(m.data, '${path}'), ${fallback}))`;
6331
+ V2_SESSIONS = "SELECT session_id FROM main.session_message";
6332
+ }
6333
+ });
6334
+
6211
6335
  // ../engine/dist/core/generic-engine.js
6212
6336
  import { basename as basename3 } from "path";
6213
6337
  import { createPatch } from "diff";
@@ -6500,13 +6624,13 @@ import { existsSync as existsSync5 } from "fs";
6500
6624
  import { homedir as homedir4 } from "os";
6501
6625
  import { dirname as dirname5, join as join5 } from "path";
6502
6626
  function openReadonly(path) {
6503
- return openSqliteReadonly(path);
6627
+ return openOpencodeDb(path);
6504
6628
  }
6505
6629
  var PREFIX, OpencodeBackend, opencodeBackend;
6506
6630
  var init_opencode = __esm({
6507
6631
  "../engine/dist/core/backends/opencode.js"() {
6508
6632
  "use strict";
6509
- init_sqlite_reader();
6633
+ init_opencode_v2();
6510
6634
  init_tool_paths();
6511
6635
  init_session_outcome();
6512
6636
  init_session_git();
@@ -6797,9 +6921,9 @@ var init_opencode = __esm({
6797
6921
  return [];
6798
6922
  const parts = db.prepare(`
6799
6923
  SELECT p.id, p.message_id, p.time_created, p.data, m.data AS msg_data
6800
- FROM part p JOIN message m ON m.id = p.message_id
6924
+ FROM part p JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON m.id = p.message_id
6801
6925
  WHERE p.session_id = ? ORDER BY p.time_created ASC
6802
- `).all(ocId);
6926
+ `).all(ocId, ocId);
6803
6927
  const events = [];
6804
6928
  let lineNum = 0;
6805
6929
  for (const p of parts) {
@@ -7015,17 +7139,17 @@ var init_opencode = __esm({
7015
7139
  if (!existsSync5(dbPath))
7016
7140
  return null;
7017
7141
  const realId = this.toRawId(id);
7018
- const db = openSqliteReadonlyOrThrow(dbPath);
7142
+ const db = openOpencodeDbOrThrow(dbPath);
7019
7143
  try {
7020
7144
  const session = db.prepare(`SELECT * FROM session WHERE id = ?`).get(realId);
7021
7145
  if (!session)
7022
7146
  return null;
7023
7147
  const rows = db.prepare(`
7024
7148
  SELECT m.id AS message_id, m.data AS message_data, p.id AS part_id, p.data AS part_data, p.time_created
7025
- FROM part p JOIN message m ON p.message_id = m.id
7149
+ FROM part p JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON p.message_id = m.id
7026
7150
  WHERE p.session_id = ?
7027
7151
  ORDER BY p.time_created ASC, p.id ASC
7028
- `).all(realId);
7152
+ `).all(realId, realId);
7029
7153
  const lines = [JSON.stringify({ kind: "session", row: session })];
7030
7154
  for (const r of rows)
7031
7155
  lines.push(JSON.stringify({ kind: "part", row: r }));
@@ -8137,6 +8261,10 @@ var init_agy = __esm({
8137
8261
  sharedSettingsFile() {
8138
8262
  return join7(this.sharedRootDir(), "settings.json");
8139
8263
  }
8264
+ /** The global hooks file the CLI reads. It does not read hooks from its own home directory. */
8265
+ sharedHooksFile() {
8266
+ return join7(this.sharedRootDir(), "config", "hooks.json");
8267
+ }
8140
8268
  sharedProjectsJson() {
8141
8269
  return join7(this.sharedRootDir(), "projects.json");
8142
8270
  }
package/dist/watch.js CHANGED
@@ -6794,19 +6794,19 @@ function mapJsonStrings(line, fn, escapedOnly) {
6794
6794
  const q = line.indexOf('"', i);
6795
6795
  if (q < 0)
6796
6796
  return out + line.slice(i);
6797
- let j = q + 1;
6798
- while (j < line.length) {
6799
- const c = line.charCodeAt(j);
6797
+ let j2 = q + 1;
6798
+ while (j2 < line.length) {
6799
+ const c = line.charCodeAt(j2);
6800
6800
  if (c === 92)
6801
- j += 2;
6801
+ j2 += 2;
6802
6802
  else if (c === 34)
6803
6803
  break;
6804
6804
  else
6805
- j++;
6805
+ j2++;
6806
6806
  }
6807
- const token = line.slice(q, j + 1);
6807
+ const token = line.slice(q, j2 + 1);
6808
6808
  out += line.slice(i, q);
6809
- i = j + 1;
6809
+ i = j2 + 1;
6810
6810
  const body = token.slice(1, -1);
6811
6811
  const escaped = body.includes("\\");
6812
6812
  if (escapedOnly && !escaped) {
@@ -9372,6 +9372,130 @@ var init_sqlite_reader = __esm({
9372
9372
  }
9373
9373
  });
9374
9374
 
9375
+ // ../engine/dist/core/backends/opencode-v2.js
9376
+ function hasTable(db, name) {
9377
+ return !!db.prepare("SELECT 1 FROM main.sqlite_master WHERE type = 'table' AND name = ?").get(name);
9378
+ }
9379
+ function columnsOf(db, table) {
9380
+ return new Set(db.prepare(`SELECT name FROM pragma_table_info('${table}', 'main')`).all().map((r) => r.name));
9381
+ }
9382
+ function installOpencodeV2Views(db) {
9383
+ if (!hasTable(db, "session_v2") || !hasTable(db, "session_message"))
9384
+ return false;
9385
+ const v2Cols = columnsOf(db, "session_v2");
9386
+ const sessionCols = SESSION_COLUMNS.map((c) => v2Cols.has(c) ? c : `NULL AS ${c}`).join(", ");
9387
+ const hasV1 = hasTable(db, "message") && hasTable(db, "part");
9388
+ const v1Messages = hasV1 ? `SELECT id, session_id, time_created, time_updated, data FROM main.message WHERE session_id NOT IN (${V2_SESSIONS}) UNION ALL ` : "";
9389
+ const v1Parts = hasV1 ? `SELECT id, message_id, session_id, time_created, time_updated, data FROM main.part WHERE session_id NOT IN (${V2_SESSIONS}) UNION ALL ` : "";
9390
+ db.exec(`
9391
+ CREATE TEMP VIEW IF NOT EXISTS session AS SELECT ${sessionCols} FROM main.session_v2;
9392
+
9393
+ CREATE TEMP VIEW IF NOT EXISTS message AS
9394
+ ${v1Messages}
9395
+ SELECT m.id, m.session_id, m.time_created, m.time_updated,
9396
+ CASE m.type
9397
+ WHEN 'user' THEN json_object('role', 'user', 'time', ${j("$.time")})
9398
+ ELSE json_object(
9399
+ 'role', 'assistant',
9400
+ 'agent', json_extract(m.data, '$.agent'),
9401
+ 'modelID', json_extract(m.data, '$.model.id'),
9402
+ 'providerID', json_extract(m.data, '$.model.providerID'),
9403
+ 'cost', coalesce(json_extract(m.data, '$.cost'), 0),
9404
+ 'tokens', ${j("$.tokens")},
9405
+ 'time', ${j("$.time")})
9406
+ END AS data
9407
+ FROM main.session_message m WHERE m.type IN ('user', 'assistant');
9408
+
9409
+ CREATE TEMP VIEW IF NOT EXISTS part AS
9410
+ ${v1Parts}
9411
+ SELECT m.id || ':text', m.id, m.session_id, m.time_created, m.time_updated,
9412
+ json_object('type', 'text', 'text', json_extract(m.data, '$.text'))
9413
+ FROM main.session_message m
9414
+ WHERE m.type = 'user' AND json_extract(m.data, '$.text') IS NOT NULL
9415
+ UNION ALL
9416
+ SELECT m.id || ':' || c.key, m.id, m.session_id, m.time_created + c.key, m.time_updated,
9417
+ CASE json_extract(c.value, '$.type')
9418
+ WHEN 'tool' THEN json_object(
9419
+ 'type', 'tool',
9420
+ 'tool', json_extract(c.value, '$.name'),
9421
+ 'callID', json_extract(c.value, '$.id'),
9422
+ 'state', json_object(
9423
+ 'status', json_extract(c.value, '$.state.status'),
9424
+ 'input', json(coalesce(json_extract(c.value, '$.state.input'), '{}')),
9425
+ 'output', (SELECT group_concat(json_extract(o.value, '$.text'), char(10))
9426
+ FROM json_each(c.value, '$.state.content') o
9427
+ WHERE json_extract(o.value, '$.type') = 'text')))
9428
+ ELSE json_object('type', json_extract(c.value, '$.type'), 'text', json_extract(c.value, '$.text'))
9429
+ END
9430
+ FROM main.session_message m, json_each(m.data, '$.content') c
9431
+ WHERE m.type = 'assistant'
9432
+ UNION ALL
9433
+ SELECT m.id || ':step', m.id, m.session_id,
9434
+ coalesce(json_extract(m.data, '$.time.completed'), m.time_created), m.time_updated,
9435
+ json_object('type', 'step-finish', 'cost', coalesce(json_extract(m.data, '$.cost'), 0), 'tokens', ${j("$.tokens")})
9436
+ FROM main.session_message m WHERE m.type = 'assistant';
9437
+ `);
9438
+ return true;
9439
+ }
9440
+ function openOpencodeDb(path) {
9441
+ const db = openSqliteReadonly(path);
9442
+ if (!db)
9443
+ return null;
9444
+ try {
9445
+ installOpencodeV2Views(db);
9446
+ } catch {
9447
+ }
9448
+ return db;
9449
+ }
9450
+ function openOpencodeDbOrThrow(path) {
9451
+ const db = openSqliteReadonlyOrThrow(path);
9452
+ try {
9453
+ installOpencodeV2Views(db);
9454
+ } catch {
9455
+ }
9456
+ return db;
9457
+ }
9458
+ var SESSION_COLUMNS, j, V2_SESSIONS;
9459
+ var init_opencode_v2 = __esm({
9460
+ "../engine/dist/core/backends/opencode-v2.js"() {
9461
+ "use strict";
9462
+ init_sqlite_reader();
9463
+ SESSION_COLUMNS = [
9464
+ "id",
9465
+ "project_id",
9466
+ "parent_id",
9467
+ "slug",
9468
+ "directory",
9469
+ "title",
9470
+ "version",
9471
+ "share_url",
9472
+ "summary_additions",
9473
+ "summary_deletions",
9474
+ "summary_files",
9475
+ "summary_diffs",
9476
+ "revert",
9477
+ "permission",
9478
+ "time_created",
9479
+ "time_updated",
9480
+ "time_compacting",
9481
+ "time_archived",
9482
+ "workspace_id",
9483
+ "path",
9484
+ "agent",
9485
+ "model",
9486
+ "cost",
9487
+ "tokens_input",
9488
+ "tokens_output",
9489
+ "tokens_reasoning",
9490
+ "tokens_cache_read",
9491
+ "tokens_cache_write",
9492
+ "metadata"
9493
+ ];
9494
+ j = (path, fallback = "'{}'") => `json(coalesce(json_extract(m.data, '${path}'), ${fallback}))`;
9495
+ V2_SESSIONS = "SELECT session_id FROM main.session_message";
9496
+ }
9497
+ });
9498
+
9375
9499
  // ../engine/dist/core/backends/opencode.js
9376
9500
  var opencode_exports = {};
9377
9501
  __export(opencode_exports, {
@@ -9382,13 +9506,13 @@ import { existsSync as existsSync11 } from "fs";
9382
9506
  import { homedir as homedir5 } from "os";
9383
9507
  import { dirname as dirname9, join as join12 } from "path";
9384
9508
  function openReadonly(path) {
9385
- return openSqliteReadonly(path);
9509
+ return openOpencodeDb(path);
9386
9510
  }
9387
9511
  var PREFIX, OpencodeBackend, opencodeBackend;
9388
9512
  var init_opencode = __esm({
9389
9513
  "../engine/dist/core/backends/opencode.js"() {
9390
9514
  "use strict";
9391
- init_sqlite_reader();
9515
+ init_opencode_v2();
9392
9516
  init_tool_paths();
9393
9517
  init_session_outcome();
9394
9518
  init_session_git();
@@ -9679,9 +9803,9 @@ var init_opencode = __esm({
9679
9803
  return [];
9680
9804
  const parts = db.prepare(`
9681
9805
  SELECT p.id, p.message_id, p.time_created, p.data, m.data AS msg_data
9682
- FROM part p JOIN message m ON m.id = p.message_id
9806
+ FROM part p JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON m.id = p.message_id
9683
9807
  WHERE p.session_id = ? ORDER BY p.time_created ASC
9684
- `).all(ocId);
9808
+ `).all(ocId, ocId);
9685
9809
  const events = [];
9686
9810
  let lineNum = 0;
9687
9811
  for (const p of parts) {
@@ -9897,17 +10021,17 @@ var init_opencode = __esm({
9897
10021
  if (!existsSync11(dbPath))
9898
10022
  return null;
9899
10023
  const realId = this.toRawId(id);
9900
- const db = openSqliteReadonlyOrThrow(dbPath);
10024
+ const db = openOpencodeDbOrThrow(dbPath);
9901
10025
  try {
9902
10026
  const session = db.prepare(`SELECT * FROM session WHERE id = ?`).get(realId);
9903
10027
  if (!session)
9904
10028
  return null;
9905
10029
  const rows = db.prepare(`
9906
10030
  SELECT m.id AS message_id, m.data AS message_data, p.id AS part_id, p.data AS part_data, p.time_created
9907
- FROM part p JOIN message m ON p.message_id = m.id
10031
+ FROM part p JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON p.message_id = m.id
9908
10032
  WHERE p.session_id = ?
9909
10033
  ORDER BY p.time_created ASC, p.id ASC
9910
- `).all(realId);
10034
+ `).all(realId, realId);
9911
10035
  const lines = [JSON.stringify({ kind: "session", row: session })];
9912
10036
  for (const r of rows)
9913
10037
  lines.push(JSON.stringify({ kind: "part", row: r }));
@@ -10823,6 +10947,10 @@ var init_agy = __esm({
10823
10947
  sharedSettingsFile() {
10824
10948
  return join14(this.sharedRootDir(), "settings.json");
10825
10949
  }
10950
+ /** The global hooks file the CLI reads. It does not read hooks from its own home directory. */
10951
+ sharedHooksFile() {
10952
+ return join14(this.sharedRootDir(), "config", "hooks.json");
10953
+ }
10826
10954
  sharedProjectsJson() {
10827
10955
  return join14(this.sharedRootDir(), "projects.json");
10828
10956
  }
@@ -14652,19 +14780,19 @@ function runTrufflehog(binary, filePath, opts = {}) {
14652
14780
  if (!line.trim())
14653
14781
  continue;
14654
14782
  try {
14655
- const j = JSON.parse(line);
14656
- const raw = j.Raw || "";
14783
+ const j2 = JSON.parse(line);
14784
+ const raw = j2.Raw || "";
14657
14785
  if (looksLikeUuid(raw))
14658
14786
  continue;
14659
14787
  out.push({
14660
- rule: j.DetectorName || "unknown",
14661
- line: j.SourceMetadata?.Data?.Filesystem?.line || 0,
14788
+ rule: j2.DetectorName || "unknown",
14789
+ line: j2.SourceMetadata?.Data?.Filesystem?.line || 0,
14662
14790
  preview: mask(raw),
14663
14791
  // trufflehog reports `Verified: true` only when --verification
14664
14792
  // ran AND the call succeeded. With --only-verified set, every
14665
14793
  // returned finding is verified live by definition, so we tag
14666
14794
  // them all true; with --no-verification, leave undefined.
14667
- verified: opts.verifyOnly ? true : j.Verified === true ? true : void 0
14795
+ verified: opts.verifyOnly ? true : j2.Verified === true ? true : void 0
14668
14796
  });
14669
14797
  } catch {
14670
14798
  }
@@ -14717,16 +14845,16 @@ function runTrufflehogDir(binary, dir, opts = {}) {
14717
14845
  if (!line.trim())
14718
14846
  continue;
14719
14847
  try {
14720
- const j = JSON.parse(line);
14721
- const raw = j.Raw || "";
14848
+ const j2 = JSON.parse(line);
14849
+ const raw = j2.Raw || "";
14722
14850
  if (looksLikeUuid(raw))
14723
14851
  continue;
14724
14852
  out.push({
14725
- rule: j.DetectorName || "unknown",
14726
- line: j.SourceMetadata?.Data?.Filesystem?.line || 0,
14853
+ rule: j2.DetectorName || "unknown",
14854
+ line: j2.SourceMetadata?.Data?.Filesystem?.line || 0,
14727
14855
  preview: mask(raw),
14728
- verified: opts.verifyOnly ? true : j.Verified === true ? true : void 0,
14729
- file: j.SourceMetadata?.Data?.Filesystem?.file || ""
14856
+ verified: opts.verifyOnly ? true : j2.Verified === true ? true : void 0,
14857
+ file: j2.SourceMetadata?.Data?.Filesystem?.file || ""
14730
14858
  });
14731
14859
  } catch {
14732
14860
  }
@@ -14894,7 +15022,7 @@ async function parseOpenCodeSubagents(parentSessionId) {
14894
15022
  if (!existsSync53(dbPath))
14895
15023
  return [];
14896
15024
  const realParent = parentSessionId.replace("opencode_", "");
14897
- const db = openSqliteReadonlyOrThrow(dbPath);
15025
+ const db = openOpencodeDbOrThrow(dbPath);
14898
15026
  try {
14899
15027
  const children = db.prepare(`
14900
15028
  SELECT id, title, time_created
@@ -14938,16 +15066,16 @@ async function parseOpenCodeTranscript(sessionId) {
14938
15066
  if (!existsSync53(dbPath))
14939
15067
  return [];
14940
15068
  const realId = sessionId.replace("opencode_", "");
14941
- const db = openSqliteReadonlyOrThrow(dbPath);
15069
+ const db = openOpencodeDbOrThrow(dbPath);
14942
15070
  const messages = [];
14943
15071
  try {
14944
15072
  const parts = db.prepare(`
14945
15073
  SELECT p.data, p.time_created, m.data as msg_data
14946
15074
  FROM part p
14947
- JOIN message m ON p.message_id = m.id
15075
+ JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON p.message_id = m.id
14948
15076
  WHERE p.session_id = ?
14949
15077
  ORDER BY p.time_created ASC
14950
- `).all(realId);
15078
+ `).all(realId, realId);
14951
15079
  let lineNum = 0;
14952
15080
  for (const part of parts) {
14953
15081
  try {
@@ -14978,7 +15106,7 @@ var log5;
14978
15106
  var init_opencode2 = __esm({
14979
15107
  "../engine/dist/transcript/opencode.js"() {
14980
15108
  "use strict";
14981
- init_sqlite_reader();
15109
+ init_opencode_v2();
14982
15110
  init_logger();
14983
15111
  log5 = createLogger("transcript-opencode");
14984
15112
  }
@@ -17647,7 +17775,7 @@ var MAX_CHUNK_CHARS8, OpenCodeSource;
17647
17775
  var init_opencode_source = __esm({
17648
17776
  "../engine/dist/parsers/opencode-source.js"() {
17649
17777
  "use strict";
17650
- init_sqlite_reader();
17778
+ init_opencode_v2();
17651
17779
  init_opencode();
17652
17780
  init_settings();
17653
17781
  MAX_CHUNK_CHARS8 = 2e3;
@@ -17664,7 +17792,7 @@ var init_opencode_source = __esm({
17664
17792
  return;
17665
17793
  let db;
17666
17794
  try {
17667
- db = openSqliteReadonlyOrThrow(this.dbPath);
17795
+ db = openOpencodeDbOrThrow(this.dbPath);
17668
17796
  } catch {
17669
17797
  return;
17670
17798
  }
@@ -17761,17 +17889,17 @@ var init_opencode_source = __esm({
17761
17889
  if (!existsSync30(this.dbPath))
17762
17890
  return [];
17763
17891
  const sessionId = item.id.replace("opencode_", "");
17764
- const db = openSqliteReadonlyOrThrow(this.dbPath);
17892
+ const db = openOpencodeDbOrThrow(this.dbPath);
17765
17893
  const chunks = [];
17766
17894
  try {
17767
17895
  const parts = db.prepare(`
17768
17896
  SELECT p.data, m.data as msg_data
17769
17897
  FROM part p
17770
- JOIN message m ON p.message_id = m.id
17898
+ JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON p.message_id = m.id
17771
17899
  WHERE p.session_id = ?
17772
17900
  AND (p.data LIKE '%"type":"text"%' OR p.data LIKE '%"type":"reasoning"%')
17773
17901
  ORDER BY p.time_created ASC
17774
- `).all(sessionId);
17902
+ `).all(sessionId, sessionId);
17775
17903
  const userTexts = [];
17776
17904
  const assistantTexts = [];
17777
17905
  for (const part of parts) {
@@ -17835,7 +17963,7 @@ var OpenCodeTodoSource;
17835
17963
  var init_opencode_todo_source = __esm({
17836
17964
  "../engine/dist/parsers/opencode-todo-source.js"() {
17837
17965
  "use strict";
17838
- init_sqlite_reader();
17966
+ init_opencode_v2();
17839
17967
  init_opencode();
17840
17968
  init_settings();
17841
17969
  OpenCodeTodoSource = class {
@@ -17851,7 +17979,7 @@ var init_opencode_todo_source = __esm({
17851
17979
  return;
17852
17980
  let db;
17853
17981
  try {
17854
- db = openSqliteReadonlyOrThrow(this.dbPath);
17982
+ db = openOpencodeDbOrThrow(this.dbPath);
17855
17983
  } catch {
17856
17984
  return;
17857
17985
  }
@@ -17899,7 +18027,7 @@ var init_opencode_todo_source = __esm({
17899
18027
  if (!existsSync31(this.dbPath))
17900
18028
  return [];
17901
18029
  const sessionId = item.extra?.sessionId || item.id.replace(`${opencodeBackend.idPrefix}todo_`, "");
17902
- const db = openSqliteReadonlyOrThrow(this.dbPath);
18030
+ const db = openOpencodeDbOrThrow(this.dbPath);
17903
18031
  const chunks = [];
17904
18032
  try {
17905
18033
  const todos = db.prepare(`
@@ -19583,12 +19711,12 @@ var require_foldFlowLines = __commonJS({
19583
19711
  ch = text[i += 1];
19584
19712
  overflow = true;
19585
19713
  }
19586
- const j = i > escEnd + 1 ? i - 2 : escStart - 1;
19587
- if (escapedFolds[j])
19714
+ const j2 = i > escEnd + 1 ? i - 2 : escStart - 1;
19715
+ if (escapedFolds[j2])
19588
19716
  return text;
19589
- folds.push(j);
19590
- escapedFolds[j] = true;
19591
- end = j + endStep;
19717
+ folds.push(j2);
19718
+ escapedFolds[j2] = true;
19719
+ end = j2 + endStep;
19592
19720
  split = void 0;
19593
19721
  } else {
19594
19722
  overflow = true;
@@ -27526,7 +27654,7 @@ var init_http = __esm({
27526
27654
  CLI_VERSION = JSON.parse(readFileSync35(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION;
27527
27655
  } catch {
27528
27656
  try {
27529
- if (true) CLI_VERSION = "0.7.21";
27657
+ if (true) CLI_VERSION = "0.7.24";
27530
27658
  } catch {
27531
27659
  }
27532
27660
  }
@@ -28020,7 +28148,7 @@ var init_telemetry = __esm({
28020
28148
  init_sync_client();
28021
28149
  cliVersion = () => {
28022
28150
  try {
28023
- return true ? "0.7.21" : "dev";
28151
+ return true ? "0.7.24" : "dev";
28024
28152
  } catch {
28025
28153
  return "dev";
28026
28154
  }
@@ -30385,7 +30513,7 @@ var init_sync_client = __esm({
30385
30513
  ownVersion = JSON.parse(readFileSync39(join46(dir, "../package.json"), "utf-8")).version || ownVersion;
30386
30514
  } catch {
30387
30515
  try {
30388
- if (true) ownVersion = "0.7.21";
30516
+ if (true) ownVersion = "0.7.24";
30389
30517
  } catch {
30390
30518
  }
30391
30519
  }
@@ -32816,16 +32944,16 @@ async function collectCode(opts) {
32816
32944
  ...blastTargets.map((f, i) => call(2e3 + i, "plan_change", { file: f, format: "json" }))
32817
32945
  ]);
32818
32946
  blastTargets.forEach((f, i) => {
32819
- const j = parseJson(pc, 2e3 + i, null);
32820
- if (j && typeof j === "object" && typeof j.fan_in === "number") {
32947
+ const j2 = parseJson(pc, 2e3 + i, null);
32948
+ if (j2 && typeof j2 === "object" && typeof j2.fan_in === "number") {
32821
32949
  blast[f] = {
32822
- fileRole: j.file_role ?? "regular",
32823
- fanIn: j.fan_in ?? 0,
32824
- fanOut: j.fan_out ?? 0,
32825
- direct: j.direct ?? 0,
32826
- transitive: j.transitive ?? 0,
32827
- maxDepth: j.max_depth ?? 0,
32828
- directFiles: Array.isArray(j.direct_files) ? j.direct_files.map(rel).slice(0, 20) : void 0
32950
+ fileRole: j2.file_role ?? "regular",
32951
+ fanIn: j2.fan_in ?? 0,
32952
+ fanOut: j2.fan_out ?? 0,
32953
+ direct: j2.direct ?? 0,
32954
+ transitive: j2.transitive ?? 0,
32955
+ maxDepth: j2.max_depth ?? 0,
32956
+ directFiles: Array.isArray(j2.direct_files) ? j2.direct_files.map(rel).slice(0, 20) : void 0
32829
32957
  };
32830
32958
  }
32831
32959
  });
@@ -33749,7 +33877,7 @@ try {
33749
33877
  ownVersion2 = JSON.parse(readFileSync43(join52(dir, "../package.json"), "utf-8")).version || ownVersion2;
33750
33878
  } catch {
33751
33879
  try {
33752
- if (true) ownVersion2 = "0.7.21";
33880
+ if (true) ownVersion2 = "0.7.24";
33753
33881
  } catch {
33754
33882
  }
33755
33883
  }
@@ -34134,7 +34262,7 @@ async function runCollectorMigration(opts) {
34134
34262
  init_sync_ledger();
34135
34263
  init_collector_health();
34136
34264
  import { existsSync as existsSync52, readFileSync as readFileSync49, statSync as statSync49 } from "fs";
34137
- var CLI_VERSION3 = true ? "0.7.21" : "0.0.0";
34265
+ var CLI_VERSION3 = true ? "0.7.24" : "0.0.0";
34138
34266
  var DEBOUNCE_MS = 5e3;
34139
34267
  var PLANS_DIR = claudeBackend.plansDir();
34140
34268
  var TASKS_DIR = claudeBackend.tasksDir();