@cookielab.io/oopst 0.3.0 → 0.3.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.
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4109,7 +4109,6 @@ import { basename, isAbsolute, join as join4 } from "path";
|
|
|
4109
4109
|
// ../../packages/parsers/src/opencode/bucketize.ts
|
|
4110
4110
|
init_esm_shims();
|
|
4111
4111
|
import { readFile } from "fs/promises";
|
|
4112
|
-
import { DatabaseSync } from "sqlite";
|
|
4113
4112
|
|
|
4114
4113
|
// ../../packages/parsers/src/opencode/events.ts
|
|
4115
4114
|
init_esm_shims();
|
|
@@ -4249,6 +4248,7 @@ function pickOpenCodeUsage(value, fallbackSessionId, fallbackTimestampMs) {
|
|
|
4249
4248
|
}
|
|
4250
4249
|
|
|
4251
4250
|
// ../../packages/parsers/src/opencode/bucketize.ts
|
|
4251
|
+
var NODE_SQLITE_SPECIFIER = ["node", "sqlite"].join(":");
|
|
4252
4252
|
var MISSING_SESSION_MESSAGE_TABLE_PATTERN = /no such table: session_message/u;
|
|
4253
4253
|
function key3(hourUtc, model, sessionId) {
|
|
4254
4254
|
return `${hourUtc.toISOString()}|${model}|${sessionId}`;
|
|
@@ -4331,6 +4331,10 @@ function parseJson(value) {
|
|
|
4331
4331
|
function isMissingTableError(err) {
|
|
4332
4332
|
return err instanceof Error && MISSING_SESSION_MESSAGE_TABLE_PATTERN.test(err.message);
|
|
4333
4333
|
}
|
|
4334
|
+
async function loadDatabaseSync() {
|
|
4335
|
+
const sqliteModule = await import(NODE_SQLITE_SPECIFIER);
|
|
4336
|
+
return sqliteModule.DatabaseSync;
|
|
4337
|
+
}
|
|
4334
4338
|
function* readSessionMessageRows(db, cutoff) {
|
|
4335
4339
|
const statement = db.prepare(`
|
|
4336
4340
|
select session_id as "sessionId", time_created as "timeCreated", data
|
|
@@ -4342,6 +4346,7 @@ function* readSessionMessageRows(db, cutoff) {
|
|
|
4342
4346
|
}
|
|
4343
4347
|
async function* bucketizeOpenCodeDatabase(path2, cutoff, logger) {
|
|
4344
4348
|
const accumulators = /* @__PURE__ */ new Map();
|
|
4349
|
+
const DatabaseSync = await loadDatabaseSync();
|
|
4345
4350
|
let db;
|
|
4346
4351
|
try {
|
|
4347
4352
|
db = new DatabaseSync(path2, { readOnly: true, timeout: 1e3 });
|