modelstat 0.0.19 → 0.0.20
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.mjs +55 -9
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -44049,7 +44049,15 @@ async function buildForOneSession(sessionId, events, adapters2) {
|
|
|
44049
44049
|
const turnSurfaces = sorted.map((e) => turnSurface(e));
|
|
44050
44050
|
const turnEmbeddings = [];
|
|
44051
44051
|
for (const s of turnSurfaces) {
|
|
44052
|
-
|
|
44052
|
+
if (s.length === 0) {
|
|
44053
|
+
turnEmbeddings.push([]);
|
|
44054
|
+
continue;
|
|
44055
|
+
}
|
|
44056
|
+
try {
|
|
44057
|
+
turnEmbeddings.push(await adapters2.embed(s));
|
|
44058
|
+
} catch {
|
|
44059
|
+
turnEmbeddings.push([]);
|
|
44060
|
+
}
|
|
44053
44061
|
}
|
|
44054
44062
|
const boundaries = [];
|
|
44055
44063
|
let runStart = 0;
|
|
@@ -44320,27 +44328,62 @@ var init_node2 = __esm({
|
|
|
44320
44328
|
});
|
|
44321
44329
|
|
|
44322
44330
|
// src/pipeline.ts
|
|
44323
|
-
function
|
|
44324
|
-
|
|
44325
|
-
const
|
|
44331
|
+
async function probeOllama(baseUrl) {
|
|
44332
|
+
try {
|
|
44333
|
+
const ctrl = new AbortController();
|
|
44334
|
+
const t = setTimeout(() => ctrl.abort(), 500);
|
|
44335
|
+
const res = await fetch(`${baseUrl.replace(/\/+$/, "")}/api/tags`, {
|
|
44336
|
+
method: "GET",
|
|
44337
|
+
signal: ctrl.signal
|
|
44338
|
+
});
|
|
44339
|
+
clearTimeout(t);
|
|
44340
|
+
return res.ok;
|
|
44341
|
+
} catch {
|
|
44342
|
+
return false;
|
|
44343
|
+
}
|
|
44344
|
+
}
|
|
44345
|
+
function fallbackAdapters() {
|
|
44346
|
+
return {
|
|
44347
|
+
embed: async () => [],
|
|
44348
|
+
// Throw → companion-core/summariseSlice's try/catch falls back to
|
|
44349
|
+
// the `promptFacts` string which is what we want here.
|
|
44350
|
+
summarize: async () => {
|
|
44351
|
+
throw new Error("ollama_unavailable");
|
|
44352
|
+
},
|
|
44353
|
+
tokenize: (text) => Math.max(1, Math.ceil(text.length / 4))
|
|
44354
|
+
};
|
|
44355
|
+
}
|
|
44356
|
+
async function getAdapters() {
|
|
44357
|
+
if (adapters && probed) return adapters;
|
|
44358
|
+
const cfg = defaultOllamaConfig();
|
|
44359
|
+
const up = await probeOllama(cfg.baseUrl);
|
|
44360
|
+
probed = true;
|
|
44361
|
+
if (up) {
|
|
44362
|
+
console.log(`[modelstat] ollama up at ${cfg.baseUrl} \u2014 using LLM pipeline`);
|
|
44326
44363
|
adapters = {
|
|
44327
44364
|
embed: ollamaEmbed(cfg),
|
|
44328
44365
|
summarize: ollamaSummarize(cfg),
|
|
44329
44366
|
tokenize: ollamaTokenize()
|
|
44330
44367
|
};
|
|
44368
|
+
} else {
|
|
44369
|
+
console.log(
|
|
44370
|
+
`[modelstat] ollama not reachable at ${cfg.baseUrl} \u2014 using fallback pipeline (server does classification)`
|
|
44371
|
+
);
|
|
44372
|
+
adapters = fallbackAdapters();
|
|
44331
44373
|
}
|
|
44332
44374
|
return adapters;
|
|
44333
44375
|
}
|
|
44334
44376
|
async function buildSegments(events) {
|
|
44335
|
-
return buildSegmentsForSession(events, getAdapters());
|
|
44377
|
+
return buildSegmentsForSession(events, await getAdapters());
|
|
44336
44378
|
}
|
|
44337
|
-
var adapters;
|
|
44379
|
+
var adapters, probed;
|
|
44338
44380
|
var init_pipeline2 = __esm({
|
|
44339
44381
|
"src/pipeline.ts"() {
|
|
44340
44382
|
"use strict";
|
|
44341
44383
|
init_pipeline();
|
|
44342
44384
|
init_node2();
|
|
44343
44385
|
adapters = null;
|
|
44386
|
+
probed = false;
|
|
44344
44387
|
}
|
|
44345
44388
|
});
|
|
44346
44389
|
|
|
@@ -44406,6 +44449,7 @@ async function scanAll(cb = {}) {
|
|
|
44406
44449
|
let batchesUploaded = 0;
|
|
44407
44450
|
let eventsUploaded = 0;
|
|
44408
44451
|
let buffer = [];
|
|
44452
|
+
let pendingCursors = [];
|
|
44409
44453
|
async function flushBatch() {
|
|
44410
44454
|
if (!buffer.length) return;
|
|
44411
44455
|
cb.onUpload?.(buffer.length);
|
|
@@ -44420,6 +44464,8 @@ async function scanAll(cb = {}) {
|
|
|
44420
44464
|
const res = await uploadBatch(batch);
|
|
44421
44465
|
batchesUploaded += 1;
|
|
44422
44466
|
eventsUploaded += res.accepted;
|
|
44467
|
+
for (const pc of pendingCursors) state.setCursor(pc.path, pc.cs);
|
|
44468
|
+
pendingCursors = [];
|
|
44423
44469
|
buffer = [];
|
|
44424
44470
|
}
|
|
44425
44471
|
for (let i = 0; i < jobs.length; i++) {
|
|
@@ -44440,7 +44486,7 @@ async function scanAll(cb = {}) {
|
|
|
44440
44486
|
if (buffer.length >= BATCH_MAX_EVENTS) await flushBatch();
|
|
44441
44487
|
}
|
|
44442
44488
|
}
|
|
44443
|
-
if (cs)
|
|
44489
|
+
if (cs) pendingCursors.push({ path: job.path, cs });
|
|
44444
44490
|
} catch (e) {
|
|
44445
44491
|
console.warn(` ! parse failed for ${job.path}:`, e.message);
|
|
44446
44492
|
}
|
|
@@ -44457,7 +44503,7 @@ var init_scan = __esm({
|
|
|
44457
44503
|
init_pipeline2();
|
|
44458
44504
|
init_config2();
|
|
44459
44505
|
init_api();
|
|
44460
|
-
AGENT_VERSION = "agent-dev-0.0.
|
|
44506
|
+
AGENT_VERSION = "agent-dev-0.0.20";
|
|
44461
44507
|
BATCH_MAX_EVENTS = 2e3;
|
|
44462
44508
|
}
|
|
44463
44509
|
});
|
|
@@ -46351,7 +46397,7 @@ var init_daemon = __esm({
|
|
|
46351
46397
|
init_api();
|
|
46352
46398
|
init_config2();
|
|
46353
46399
|
init_scan();
|
|
46354
|
-
AGENT_VERSION2 = "agent-dev-0.0.
|
|
46400
|
+
AGENT_VERSION2 = "agent-dev-0.0.20";
|
|
46355
46401
|
HEARTBEAT_INTERVAL_MS = 1e4;
|
|
46356
46402
|
SCAN_INTERVAL_MS = 5 * 60 * 1e3;
|
|
46357
46403
|
status = {
|