@threadbase-sh/scanner 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +72 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +71 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +71 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -44,6 +44,8 @@ interface ConversationMeta {
|
|
|
44
44
|
model: string | null;
|
|
45
45
|
isSubagent: boolean;
|
|
46
46
|
parentSessionId: string | null;
|
|
47
|
+
subagentId?: string;
|
|
48
|
+
parentSessionUuid?: string;
|
|
47
49
|
isTeammate: boolean;
|
|
48
50
|
teamName: string | null;
|
|
49
51
|
toolNames: string[];
|
|
@@ -303,6 +305,8 @@ interface CodexAccumulator {
|
|
|
303
305
|
latestTimestamp: string;
|
|
304
306
|
messageCount: number;
|
|
305
307
|
lastMessageSender: MessageSender;
|
|
308
|
+
isSubagent: boolean;
|
|
309
|
+
parentSessionUuid: string | null;
|
|
306
310
|
firstUser: MessageSnapshot | null;
|
|
307
311
|
lastUser: MessageSnapshot | null;
|
|
308
312
|
lastAssistant: MessageSnapshot | null;
|
|
@@ -332,6 +336,8 @@ interface ReducerState {
|
|
|
332
336
|
messageCount: number;
|
|
333
337
|
pageMessageCount: number;
|
|
334
338
|
lastMessageSender: MessageSender;
|
|
339
|
+
agentId: string;
|
|
340
|
+
isSidechain: boolean;
|
|
335
341
|
isTeammate: boolean;
|
|
336
342
|
firstUserSeen: boolean;
|
|
337
343
|
firstMessage: MessageSnapshot | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ interface ConversationMeta {
|
|
|
44
44
|
model: string | null;
|
|
45
45
|
isSubagent: boolean;
|
|
46
46
|
parentSessionId: string | null;
|
|
47
|
+
subagentId?: string;
|
|
48
|
+
parentSessionUuid?: string;
|
|
47
49
|
isTeammate: boolean;
|
|
48
50
|
teamName: string | null;
|
|
49
51
|
toolNames: string[];
|
|
@@ -303,6 +305,8 @@ interface CodexAccumulator {
|
|
|
303
305
|
latestTimestamp: string;
|
|
304
306
|
messageCount: number;
|
|
305
307
|
lastMessageSender: MessageSender;
|
|
308
|
+
isSubagent: boolean;
|
|
309
|
+
parentSessionUuid: string | null;
|
|
306
310
|
firstUser: MessageSnapshot | null;
|
|
307
311
|
lastUser: MessageSnapshot | null;
|
|
308
312
|
lastAssistant: MessageSnapshot | null;
|
|
@@ -332,6 +336,8 @@ interface ReducerState {
|
|
|
332
336
|
messageCount: number;
|
|
333
337
|
pageMessageCount: number;
|
|
334
338
|
lastMessageSender: MessageSender;
|
|
339
|
+
agentId: string;
|
|
340
|
+
isSidechain: boolean;
|
|
335
341
|
isTeammate: boolean;
|
|
336
342
|
firstUserSeen: boolean;
|
|
337
343
|
firstMessage: MessageSnapshot | null;
|
package/dist/index.js
CHANGED
|
@@ -373,6 +373,8 @@ function initialReducerState() {
|
|
|
373
373
|
model: null,
|
|
374
374
|
messageCount: 0,
|
|
375
375
|
lastMessageSender: "user",
|
|
376
|
+
agentId: "",
|
|
377
|
+
isSidechain: false,
|
|
376
378
|
isTeammate: false,
|
|
377
379
|
firstUserSeen: false,
|
|
378
380
|
firstMessage: null,
|
|
@@ -392,6 +394,8 @@ function reduceLine(state, entry, tier) {
|
|
|
392
394
|
if (entry.sessionId && !state.sessionId) state.sessionId = entry.sessionId;
|
|
393
395
|
if (entry.slug && !state.sessionName) state.sessionName = entry.slug;
|
|
394
396
|
if (entry.teamName && !state.teamName) state.teamName = entry.teamName;
|
|
397
|
+
if (entry.agentId && !state.agentId) state.agentId = entry.agentId;
|
|
398
|
+
if (entry.isSidechain === true) state.isSidechain = true;
|
|
395
399
|
if (entry.timestamp) {
|
|
396
400
|
const ts = entry.timestamp;
|
|
397
401
|
if (!state.latestTimestamp || ts > state.latestTimestamp) state.latestTimestamp = ts;
|
|
@@ -443,9 +447,11 @@ function reduceLine(state, entry, tier) {
|
|
|
443
447
|
}
|
|
444
448
|
function finalizeMeta(state, filePath, account, tier) {
|
|
445
449
|
if (state.messageCount === 0) return null;
|
|
446
|
-
const
|
|
450
|
+
const isSidechain = state.isSidechain && !!state.agentId;
|
|
451
|
+
const isSubagentPath = SUBAGENT_PATH_RE.test(filePath);
|
|
452
|
+
const isSubagent = isSidechain || isSubagentPath;
|
|
447
453
|
let parentSessionId = null;
|
|
448
|
-
if (
|
|
454
|
+
if (isSubagentPath) {
|
|
449
455
|
const uuidDir = dirname2(dirname2(filePath));
|
|
450
456
|
parentSessionId = join2(dirname2(uuidDir), `${basename(uuidDir)}.jsonl`);
|
|
451
457
|
}
|
|
@@ -468,6 +474,10 @@ function finalizeMeta(state, filePath, account, tier) {
|
|
|
468
474
|
model: state.model,
|
|
469
475
|
isSubagent,
|
|
470
476
|
parentSessionId,
|
|
477
|
+
subagentId: isSidechain ? state.agentId : void 0,
|
|
478
|
+
// A sidechain line's `sessionId` IS the parent's id — that is exactly the
|
|
479
|
+
// conflation `subagentId` exists to undo, so it is the parent UUID here.
|
|
480
|
+
parentSessionUuid: isSidechain && state.sessionId ? state.sessionId : void 0,
|
|
471
481
|
isTeammate: state.isTeammate,
|
|
472
482
|
teamName: state.teamName || null,
|
|
473
483
|
toolNames: state.toolNames,
|
|
@@ -476,6 +486,7 @@ function finalizeMeta(state, filePath, account, tier) {
|
|
|
476
486
|
lastPrompt: state.lastPrompt || void 0
|
|
477
487
|
};
|
|
478
488
|
}
|
|
489
|
+
var SUBAGENT_PATH_RE = /[\\/]subagents[\\/]/;
|
|
479
490
|
function deriveSessionNameFromFirstMessage(firstMessage) {
|
|
480
491
|
const firstLine = firstMessage?.text.split("\n", 1)[0]?.trim() ?? "";
|
|
481
492
|
return firstLine.slice(0, 80);
|
|
@@ -961,6 +972,8 @@ var CodexCliProvider = class {
|
|
|
961
972
|
latestTimestamp: "",
|
|
962
973
|
messageCount: 0,
|
|
963
974
|
lastMessageSender: "user",
|
|
975
|
+
isSubagent: false,
|
|
976
|
+
parentSessionUuid: null,
|
|
964
977
|
firstUser: null,
|
|
965
978
|
lastUser: null,
|
|
966
979
|
lastAssistant: null,
|
|
@@ -1022,6 +1035,10 @@ function reduceCodexEntry(acc, entry, tier) {
|
|
|
1022
1035
|
if (!acc.cwd) acc.cwd = asString(payload.cwd);
|
|
1023
1036
|
const git = payload.git;
|
|
1024
1037
|
if (acc.gitBranch === null && git?.branch) acc.gitBranch = asString(git.branch) || null;
|
|
1038
|
+
if (!acc.isSubagent && isSubagentSource(payload.source)) {
|
|
1039
|
+
acc.isSubagent = true;
|
|
1040
|
+
acc.parentSessionUuid = parentThreadId(payload.source);
|
|
1041
|
+
}
|
|
1025
1042
|
return;
|
|
1026
1043
|
}
|
|
1027
1044
|
if (acc.model === null && payload.model) acc.model = asString(payload.model) || null;
|
|
@@ -1081,8 +1098,10 @@ function finalizeCodexMeta(acc, filePath, account, tier) {
|
|
|
1081
1098
|
contentSnippet: acc.snippetParts.join(" "),
|
|
1082
1099
|
gitBranch: acc.gitBranch,
|
|
1083
1100
|
model: acc.model,
|
|
1084
|
-
isSubagent:
|
|
1101
|
+
isSubagent: acc.isSubagent,
|
|
1102
|
+
// Codex exposes no path-shaped parent, and no per-child id of its own.
|
|
1085
1103
|
parentSessionId: null,
|
|
1104
|
+
parentSessionUuid: acc.parentSessionUuid ?? void 0,
|
|
1086
1105
|
isTeammate: false,
|
|
1087
1106
|
teamName: null,
|
|
1088
1107
|
toolNames: acc.toolNames,
|
|
@@ -1094,6 +1113,17 @@ function finalizeCodexMeta(acc, filePath, account, tier) {
|
|
|
1094
1113
|
function getShortProjectName3(fullPath) {
|
|
1095
1114
|
return fullPath.split("/").filter(Boolean).slice(-3).join("/");
|
|
1096
1115
|
}
|
|
1116
|
+
function isSubagentSource(source) {
|
|
1117
|
+
return typeof source === "object" && source !== null && "subagent" in source;
|
|
1118
|
+
}
|
|
1119
|
+
function parentThreadId(source) {
|
|
1120
|
+
if (!isSubagentSource(source)) return null;
|
|
1121
|
+
const subagent = source.subagent;
|
|
1122
|
+
if (typeof subagent !== "object" || subagent === null) return null;
|
|
1123
|
+
const spawn = subagent.thread_spawn;
|
|
1124
|
+
if (typeof spawn !== "object" || spawn === null) return null;
|
|
1125
|
+
return asString(spawn.parent_thread_id) || null;
|
|
1126
|
+
}
|
|
1097
1127
|
async function parseCodexConversation(filePath, account) {
|
|
1098
1128
|
const log = getLogger();
|
|
1099
1129
|
const messages = [];
|
|
@@ -1753,7 +1783,7 @@ import { mkdirSync } from "fs";
|
|
|
1753
1783
|
import { dirname as dirname3 } from "path";
|
|
1754
1784
|
|
|
1755
1785
|
// src/persistent/schema.ts
|
|
1756
|
-
var SCHEMA_VERSION =
|
|
1786
|
+
var SCHEMA_VERSION = 6;
|
|
1757
1787
|
var SCHEMA_SQL = `
|
|
1758
1788
|
CREATE TABLE IF NOT EXISTS conversation_files (
|
|
1759
1789
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -1828,7 +1858,11 @@ CREATE TABLE IF NOT EXISTS conversations (
|
|
|
1828
1858
|
|
|
1829
1859
|
model TEXT,
|
|
1830
1860
|
is_subagent INTEGER NOT NULL DEFAULT 0,
|
|
1861
|
+
-- The parent's JSONL PATH (matched against source_path), not an id.
|
|
1831
1862
|
parent_session_id TEXT,
|
|
1863
|
+
-- The subagent's own id (Claude agentId), and the parent's session UUID.
|
|
1864
|
+
subagent_id TEXT,
|
|
1865
|
+
parent_session_uuid TEXT,
|
|
1832
1866
|
is_teammate INTEGER NOT NULL DEFAULT 0,
|
|
1833
1867
|
team_name TEXT,
|
|
1834
1868
|
tool_names_json TEXT,
|
|
@@ -1961,6 +1995,29 @@ function runMigrations(db) {
|
|
|
1961
1995
|
}
|
|
1962
1996
|
}
|
|
1963
1997
|
}
|
|
1998
|
+
if (current >= 1 && current < 6 && tableExists(db, "conversations")) {
|
|
1999
|
+
for (const [col, ddl] of [
|
|
2000
|
+
["subagent_id", "ALTER TABLE conversations ADD COLUMN subagent_id TEXT"],
|
|
2001
|
+
["parent_session_uuid", "ALTER TABLE conversations ADD COLUMN parent_session_uuid TEXT"]
|
|
2002
|
+
]) {
|
|
2003
|
+
if (!hasColumn(db, "conversations", col)) db.exec(ddl);
|
|
2004
|
+
}
|
|
2005
|
+
if (tableExists(db, "conversation_files")) {
|
|
2006
|
+
const assignments = [];
|
|
2007
|
+
if (hasColumn(db, "conversation_files", "last_indexed_offset")) {
|
|
2008
|
+
assignments.push("last_indexed_offset = 0");
|
|
2009
|
+
}
|
|
2010
|
+
if (hasColumn(db, "conversation_files", "last_indexed_line")) {
|
|
2011
|
+
assignments.push("last_indexed_line = 0");
|
|
2012
|
+
}
|
|
2013
|
+
if (hasColumn(db, "conversation_files", "reducer_state")) {
|
|
2014
|
+
assignments.push("reducer_state = NULL");
|
|
2015
|
+
}
|
|
2016
|
+
if (assignments.length > 0) {
|
|
2017
|
+
db.exec(`UPDATE conversation_files SET ${assignments.join(", ")}`);
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
1964
2021
|
db.exec(SCHEMA_SQL);
|
|
1965
2022
|
db.pragma(`user_version = ${SCHEMA_VERSION}`);
|
|
1966
2023
|
}
|
|
@@ -2285,6 +2342,8 @@ function rowToMeta(row) {
|
|
|
2285
2342
|
model: row.model,
|
|
2286
2343
|
isSubagent: row.is_subagent === 1,
|
|
2287
2344
|
parentSessionId: row.parent_session_id,
|
|
2345
|
+
subagentId: row.subagent_id ?? void 0,
|
|
2346
|
+
parentSessionUuid: row.parent_session_uuid ?? void 0,
|
|
2288
2347
|
isTeammate: row.is_teammate === 1,
|
|
2289
2348
|
teamName: row.team_name,
|
|
2290
2349
|
toolNames: row.tool_names_json ? JSON.parse(row.tool_names_json) : [],
|
|
@@ -2308,7 +2367,8 @@ var ConversationsRepo = class {
|
|
|
2308
2367
|
account, branch, preview, content_snippet, message_count, page_message_count,
|
|
2309
2368
|
last_message_sender,
|
|
2310
2369
|
timestamp, index_seq, first_sent_at, first_sent_text, last_sent_at, last_sent_text,
|
|
2311
|
-
model, is_subagent, parent_session_id,
|
|
2370
|
+
model, is_subagent, parent_session_id, subagent_id, parent_session_uuid,
|
|
2371
|
+
is_teammate, team_name, tool_names_json,
|
|
2312
2372
|
last_prompt, status, updated_at
|
|
2313
2373
|
) VALUES (
|
|
2314
2374
|
@file_id, @source_path, @provider, @kind, @external_session_id,
|
|
@@ -2318,7 +2378,8 @@ var ConversationsRepo = class {
|
|
|
2318
2378
|
@timestamp,
|
|
2319
2379
|
(SELECT COALESCE(MAX(index_seq), 0) + 1 FROM conversations),
|
|
2320
2380
|
@first_sent_at, @first_sent_text, @last_sent_at, @last_sent_text,
|
|
2321
|
-
@model, @is_subagent, @parent_session_id, @
|
|
2381
|
+
@model, @is_subagent, @parent_session_id, @subagent_id, @parent_session_uuid,
|
|
2382
|
+
@is_teammate, @team_name, @tool_names_json,
|
|
2322
2383
|
@last_prompt, 'active', CURRENT_TIMESTAMP
|
|
2323
2384
|
)
|
|
2324
2385
|
ON CONFLICT(file_id) DO UPDATE SET
|
|
@@ -2345,6 +2406,8 @@ var ConversationsRepo = class {
|
|
|
2345
2406
|
model = excluded.model,
|
|
2346
2407
|
is_subagent = excluded.is_subagent,
|
|
2347
2408
|
parent_session_id = excluded.parent_session_id,
|
|
2409
|
+
subagent_id = excluded.subagent_id,
|
|
2410
|
+
parent_session_uuid = excluded.parent_session_uuid,
|
|
2348
2411
|
is_teammate = excluded.is_teammate,
|
|
2349
2412
|
team_name = excluded.team_name,
|
|
2350
2413
|
tool_names_json = excluded.tool_names_json,
|
|
@@ -2380,6 +2443,8 @@ var ConversationsRepo = class {
|
|
|
2380
2443
|
model: meta.model,
|
|
2381
2444
|
is_subagent: meta.isSubagent ? 1 : 0,
|
|
2382
2445
|
parent_session_id: meta.parentSessionId,
|
|
2446
|
+
subagent_id: meta.subagentId ?? null,
|
|
2447
|
+
parent_session_uuid: meta.parentSessionUuid ?? null,
|
|
2383
2448
|
is_teammate: meta.isTeammate ? 1 : 0,
|
|
2384
2449
|
team_name: meta.teamName,
|
|
2385
2450
|
tool_names_json: JSON.stringify(meta.toolNames),
|