@dudousxd/nestjs-agent-store-drizzle 0.31.0 → 0.32.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/index.cjs +43 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +210 -8
- package/dist/index.d.ts +210 -8
- package/dist/index.js +43 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -311,6 +311,12 @@ var agentRun = (0, import_sqlite_core.sqliteTable)("agent_run", {
|
|
|
311
311
|
agentName: (0, import_sqlite_core.text)("agent_name"),
|
|
312
312
|
status: (0, import_sqlite_core.text)("status").$type().notNull(),
|
|
313
313
|
durationMs: (0, import_sqlite_core.integer)("duration_ms"),
|
|
314
|
+
/** Turn start to the first `text` frame; null for a run that streamed none or did not complete. */
|
|
315
|
+
ttftMs: (0, import_sqlite_core.integer)("ttft_ms"),
|
|
316
|
+
/** The run's known spend (the sum of its model calls with a known cost); null when none had one. */
|
|
317
|
+
costUsd: (0, import_sqlite_core.real)("cost_usd"),
|
|
318
|
+
/** The model the run's last model call resolved to. */
|
|
319
|
+
modelId: (0, import_sqlite_core.text)("model_id"),
|
|
314
320
|
errorCode: (0, import_sqlite_core.text)("error_code"),
|
|
315
321
|
errorMessage: (0, import_sqlite_core.text)("error_message"),
|
|
316
322
|
retries: (0, import_sqlite_core.integer)("retries").notNull().default(0),
|
|
@@ -743,6 +749,12 @@ var agentRun2 = (0, import_mysql_core.mysqlTable)("agent_run", {
|
|
|
743
749
|
agentName: key("agent_name"),
|
|
744
750
|
status: key("status").$type().notNull(),
|
|
745
751
|
durationMs: (0, import_mysql_core.int)("duration_ms"),
|
|
752
|
+
/** Turn start to the first `text` frame; null for a run that streamed none or did not complete. */
|
|
753
|
+
ttftMs: (0, import_mysql_core.int)("ttft_ms"),
|
|
754
|
+
/** The run's known spend (the sum of its model calls with a known cost); null when none had one. */
|
|
755
|
+
costUsd: (0, import_mysql_core.double)("cost_usd"),
|
|
756
|
+
/** The model the run's last model call resolved to. */
|
|
757
|
+
modelId: key("model_id"),
|
|
746
758
|
errorCode: key("error_code"),
|
|
747
759
|
errorMessage: (0, import_mysql_core.longtext)("error_message"),
|
|
748
760
|
retries: (0, import_mysql_core.int)("retries").notNull().default(0),
|
|
@@ -1189,6 +1201,12 @@ var agentRun3 = (0, import_pg_core.pgTable)("agent_run", {
|
|
|
1189
1201
|
agentName: (0, import_pg_core.text)("agent_name"),
|
|
1190
1202
|
status: (0, import_pg_core.text)("status").$type().notNull(),
|
|
1191
1203
|
durationMs: (0, import_pg_core.integer)("duration_ms"),
|
|
1204
|
+
/** Turn start to the first `text` frame; null for a run that streamed none or did not complete. */
|
|
1205
|
+
ttftMs: (0, import_pg_core.integer)("ttft_ms"),
|
|
1206
|
+
/** The run's known spend (the sum of its model calls with a known cost); null when none had one. */
|
|
1207
|
+
costUsd: (0, import_pg_core.doublePrecision)("cost_usd"),
|
|
1208
|
+
/** The model the run's last model call resolved to. */
|
|
1209
|
+
modelId: (0, import_pg_core.text)("model_id"),
|
|
1192
1210
|
errorCode: (0, import_pg_core.text)("error_code"),
|
|
1193
1211
|
errorMessage: (0, import_pg_core.text)("error_message"),
|
|
1194
1212
|
retries: (0, import_pg_core.integer)("retries").notNull().default(0),
|
|
@@ -2804,6 +2822,9 @@ var DrizzleAgentStore = class {
|
|
|
2804
2822
|
agentName: run.agentName ?? null,
|
|
2805
2823
|
status: "running",
|
|
2806
2824
|
durationMs: null,
|
|
2825
|
+
ttftMs: null,
|
|
2826
|
+
costUsd: null,
|
|
2827
|
+
modelId: null,
|
|
2807
2828
|
errorCode: null,
|
|
2808
2829
|
errorMessage: null,
|
|
2809
2830
|
retries: 0,
|
|
@@ -2823,6 +2844,15 @@ var DrizzleAgentStore = class {
|
|
|
2823
2844
|
if (end.durationMs !== void 0) {
|
|
2824
2845
|
updates.durationMs = end.durationMs;
|
|
2825
2846
|
}
|
|
2847
|
+
if (end.ttftMs !== void 0) {
|
|
2848
|
+
updates.ttftMs = end.ttftMs;
|
|
2849
|
+
}
|
|
2850
|
+
if (end.costUsd !== void 0) {
|
|
2851
|
+
updates.costUsd = end.costUsd;
|
|
2852
|
+
}
|
|
2853
|
+
if (end.modelId !== void 0) {
|
|
2854
|
+
updates.modelId = end.modelId;
|
|
2855
|
+
}
|
|
2826
2856
|
if (end.errorCode !== void 0) {
|
|
2827
2857
|
updates.errorCode = end.errorCode;
|
|
2828
2858
|
}
|
|
@@ -3308,6 +3338,11 @@ function toRecentRunRow(run) {
|
|
|
3308
3338
|
agentName: run.agentName ?? null,
|
|
3309
3339
|
status: run.status,
|
|
3310
3340
|
durationMs: run.durationMs ?? null,
|
|
3341
|
+
ttftMs: run.ttftMs ?? null,
|
|
3342
|
+
// MySQL's DOUBLE and Postgres' double precision come back as numbers; a driver that hands a
|
|
3343
|
+
// decimal back as a string is normalized here so the SPI row is always a number.
|
|
3344
|
+
costUsd: run.costUsd == null ? null : Number(run.costUsd),
|
|
3345
|
+
modelId: run.modelId ?? null,
|
|
3311
3346
|
errorCode: run.errorCode ?? null,
|
|
3312
3347
|
errorMessage: run.errorMessage ?? null,
|
|
3313
3348
|
retries: run.retries,
|
|
@@ -3511,6 +3546,7 @@ var DrizzleGovernanceQueries = class {
|
|
|
3511
3546
|
let failed = 0;
|
|
3512
3547
|
let retries = 0;
|
|
3513
3548
|
const settledDurationsMs = [];
|
|
3549
|
+
const ttftsMs = [];
|
|
3514
3550
|
for (const run of runs) {
|
|
3515
3551
|
if (run.status === "completed") {
|
|
3516
3552
|
completed += 1;
|
|
@@ -3521,8 +3557,12 @@ var DrizzleGovernanceQueries = class {
|
|
|
3521
3557
|
if ((run.status === "completed" || run.status === "failed") && run.durationMs != null) {
|
|
3522
3558
|
settledDurationsMs.push(run.durationMs);
|
|
3523
3559
|
}
|
|
3560
|
+
if (run.status === "completed" && run.parentRunId == null && run.ttftMs != null) {
|
|
3561
|
+
ttftsMs.push(run.ttftMs);
|
|
3562
|
+
}
|
|
3524
3563
|
}
|
|
3525
3564
|
settledDurationsMs.sort((left, right) => left - right);
|
|
3565
|
+
ttftsMs.sort((left, right) => left - right);
|
|
3526
3566
|
return {
|
|
3527
3567
|
runs: runs.length,
|
|
3528
3568
|
completed,
|
|
@@ -3530,7 +3570,9 @@ var DrizzleGovernanceQueries = class {
|
|
|
3530
3570
|
successRate: runs.length === 0 ? 0 : completed / runs.length,
|
|
3531
3571
|
retries,
|
|
3532
3572
|
durationP50Ms: percentileMs(settledDurationsMs, 0.5),
|
|
3533
|
-
durationP95Ms: percentileMs(settledDurationsMs, 0.95)
|
|
3573
|
+
durationP95Ms: percentileMs(settledDurationsMs, 0.95),
|
|
3574
|
+
ttftP50Ms: percentileMs(ttftsMs, 0.5),
|
|
3575
|
+
ttftP95Ms: percentileMs(ttftsMs, 0.95)
|
|
3534
3576
|
};
|
|
3535
3577
|
}
|
|
3536
3578
|
async runsByAgent(range) {
|