@dudousxd/nestjs-agent-store-drizzle 0.3.4 → 0.5.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 +278 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +508 -4
- package/dist/index.d.ts +508 -4
- package/dist/index.js +278 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
|
|
2
2
|
import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
|
|
3
|
-
import { MessageRole, ToolCallRequest, ToolResult, MessageUsage, ToolKind, ToolCallStatus, UsagePurpose, AgentStore, CreateThreadInput, ThreadSummary, ThreadDetail, AppendMessageInput, StoredMessage, RecordToolCallInput, UpdateToolCallInput, RecordUsageInput, AgentGovernanceQueries, AgentPricingStore, GovernanceRange, ModelSpendRow, ActorSpendRow, ThreadSpendRow, UsageTrendPoint, ToolCallActivityRow, ThreadActivityRow, ModelPriceInput, CurrentModelPrice } from '@dudousxd/nestjs-agent-core';
|
|
3
|
+
import { MessageRole, ToolCallRequest, ToolResult, MessageUsage, ToolKind, ToolCallStatus, UsagePurpose, AgentStore, CreateThreadInput, ThreadSummary, ThreadDetail, AppendMessageInput, StoredMessage, RecordToolCallInput, UpdateToolCallInput, RecordUsageInput, AgentGovernanceQueries, AgentPricingStore, GovernanceRange, ModelSpendRow, ActorSpendRow, ThreadSpendRow, UsageTrendPoint, ToolCallActivityRow, ThreadActivityRow, RunMetrics, RunAgentBreakdownRow, RunErrorBreakdownRow, RunTrendPoint, RecentRunRow, PendingApprovalRow, ToolStatRow, ModelPriceInput, CurrentModelPrice } from '@dudousxd/nestjs-agent-core';
|
|
4
4
|
import { Type, DynamicModule } from '@nestjs/common';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Drizzle schema mirroring the MikroORM agent entities (same logical columns/relations):
|
|
8
|
-
* threads, messages, tool calls, token usage and
|
|
8
|
+
* threads, messages, tool calls, token usage, model pricing and run outcomes. Targets the SQLite core so the
|
|
9
9
|
* db-test runs on an in-memory better-sqlite3; timestamps are stored as integer epoch-ms columns
|
|
10
10
|
* (`{ mode: 'timestamp_ms' }`) which Drizzle round-trips to/from JS `Date`, and the model-facing
|
|
11
11
|
* message extras (tool calls/results, follow-ups, usage) live in JSON `text` columns.
|
|
@@ -987,7 +987,245 @@ declare const agentModelPricing: drizzle_orm_sqlite_core.SQLiteTableWithColumns<
|
|
|
987
987
|
};
|
|
988
988
|
dialect: "sqlite";
|
|
989
989
|
}>;
|
|
990
|
-
/**
|
|
990
|
+
/** A run's lifecycle status. Not part of the core SPI (that surfaces `string`) — internal only. */
|
|
991
|
+
type AgentRunStatus = 'running' | 'completed' | 'failed';
|
|
992
|
+
/**
|
|
993
|
+
* One recorded run (turn) outcome — the durable half of what `aviary:agent:*` diagnostics report
|
|
994
|
+
* ephemerally. Written by {@link import('./drizzle-agent-store.js').DrizzleAgentStore.recordRunStart}/
|
|
995
|
+
* `recordRunEnd`/`bumpRunRetries`, read by
|
|
996
|
+
* {@link import('./drizzle-governance-queries.js').DrizzleGovernanceQueries} for the reliability
|
|
997
|
+
* surfaces (success rate, error breakdown, duration percentiles, trend, recent runs). `threadId`
|
|
998
|
+
* cascades on delete, like `agent_message`/`agent_token_usage`.
|
|
999
|
+
*/
|
|
1000
|
+
declare const agentRun: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
1001
|
+
name: "agent_run";
|
|
1002
|
+
schema: undefined;
|
|
1003
|
+
columns: {
|
|
1004
|
+
id: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1005
|
+
name: "id";
|
|
1006
|
+
tableName: "agent_run";
|
|
1007
|
+
dataType: "string";
|
|
1008
|
+
columnType: "SQLiteText";
|
|
1009
|
+
data: string;
|
|
1010
|
+
driverParam: string;
|
|
1011
|
+
notNull: true;
|
|
1012
|
+
hasDefault: false;
|
|
1013
|
+
isPrimaryKey: true;
|
|
1014
|
+
isAutoincrement: false;
|
|
1015
|
+
hasRuntimeDefault: false;
|
|
1016
|
+
enumValues: [string, ...string[]];
|
|
1017
|
+
baseColumn: never;
|
|
1018
|
+
identity: undefined;
|
|
1019
|
+
generated: undefined;
|
|
1020
|
+
}, {}, {
|
|
1021
|
+
length: number | undefined;
|
|
1022
|
+
}>;
|
|
1023
|
+
threadId: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1024
|
+
name: "thread_id";
|
|
1025
|
+
tableName: "agent_run";
|
|
1026
|
+
dataType: "string";
|
|
1027
|
+
columnType: "SQLiteText";
|
|
1028
|
+
data: string;
|
|
1029
|
+
driverParam: string;
|
|
1030
|
+
notNull: true;
|
|
1031
|
+
hasDefault: false;
|
|
1032
|
+
isPrimaryKey: false;
|
|
1033
|
+
isAutoincrement: false;
|
|
1034
|
+
hasRuntimeDefault: false;
|
|
1035
|
+
enumValues: [string, ...string[]];
|
|
1036
|
+
baseColumn: never;
|
|
1037
|
+
identity: undefined;
|
|
1038
|
+
generated: undefined;
|
|
1039
|
+
}, {}, {
|
|
1040
|
+
length: number | undefined;
|
|
1041
|
+
}>;
|
|
1042
|
+
actorRef: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1043
|
+
name: "actor_ref";
|
|
1044
|
+
tableName: "agent_run";
|
|
1045
|
+
dataType: "string";
|
|
1046
|
+
columnType: "SQLiteText";
|
|
1047
|
+
data: string;
|
|
1048
|
+
driverParam: string;
|
|
1049
|
+
notNull: true;
|
|
1050
|
+
hasDefault: false;
|
|
1051
|
+
isPrimaryKey: false;
|
|
1052
|
+
isAutoincrement: false;
|
|
1053
|
+
hasRuntimeDefault: false;
|
|
1054
|
+
enumValues: [string, ...string[]];
|
|
1055
|
+
baseColumn: never;
|
|
1056
|
+
identity: undefined;
|
|
1057
|
+
generated: undefined;
|
|
1058
|
+
}, {}, {
|
|
1059
|
+
length: number | undefined;
|
|
1060
|
+
}>;
|
|
1061
|
+
agentName: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1062
|
+
name: "agent_name";
|
|
1063
|
+
tableName: "agent_run";
|
|
1064
|
+
dataType: "string";
|
|
1065
|
+
columnType: "SQLiteText";
|
|
1066
|
+
data: string;
|
|
1067
|
+
driverParam: string;
|
|
1068
|
+
notNull: false;
|
|
1069
|
+
hasDefault: false;
|
|
1070
|
+
isPrimaryKey: false;
|
|
1071
|
+
isAutoincrement: false;
|
|
1072
|
+
hasRuntimeDefault: false;
|
|
1073
|
+
enumValues: [string, ...string[]];
|
|
1074
|
+
baseColumn: never;
|
|
1075
|
+
identity: undefined;
|
|
1076
|
+
generated: undefined;
|
|
1077
|
+
}, {}, {
|
|
1078
|
+
length: number | undefined;
|
|
1079
|
+
}>;
|
|
1080
|
+
status: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1081
|
+
name: "status";
|
|
1082
|
+
tableName: "agent_run";
|
|
1083
|
+
dataType: "string";
|
|
1084
|
+
columnType: "SQLiteText";
|
|
1085
|
+
data: AgentRunStatus;
|
|
1086
|
+
driverParam: string;
|
|
1087
|
+
notNull: true;
|
|
1088
|
+
hasDefault: false;
|
|
1089
|
+
isPrimaryKey: false;
|
|
1090
|
+
isAutoincrement: false;
|
|
1091
|
+
hasRuntimeDefault: false;
|
|
1092
|
+
enumValues: [string, ...string[]];
|
|
1093
|
+
baseColumn: never;
|
|
1094
|
+
identity: undefined;
|
|
1095
|
+
generated: undefined;
|
|
1096
|
+
}, {}, {
|
|
1097
|
+
length: number | undefined;
|
|
1098
|
+
$type: AgentRunStatus;
|
|
1099
|
+
}>;
|
|
1100
|
+
durationMs: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1101
|
+
name: "duration_ms";
|
|
1102
|
+
tableName: "agent_run";
|
|
1103
|
+
dataType: "number";
|
|
1104
|
+
columnType: "SQLiteInteger";
|
|
1105
|
+
data: number;
|
|
1106
|
+
driverParam: number;
|
|
1107
|
+
notNull: false;
|
|
1108
|
+
hasDefault: false;
|
|
1109
|
+
isPrimaryKey: false;
|
|
1110
|
+
isAutoincrement: false;
|
|
1111
|
+
hasRuntimeDefault: false;
|
|
1112
|
+
enumValues: undefined;
|
|
1113
|
+
baseColumn: never;
|
|
1114
|
+
identity: undefined;
|
|
1115
|
+
generated: undefined;
|
|
1116
|
+
}, {}, {}>;
|
|
1117
|
+
errorCode: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1118
|
+
name: "error_code";
|
|
1119
|
+
tableName: "agent_run";
|
|
1120
|
+
dataType: "string";
|
|
1121
|
+
columnType: "SQLiteText";
|
|
1122
|
+
data: string;
|
|
1123
|
+
driverParam: string;
|
|
1124
|
+
notNull: false;
|
|
1125
|
+
hasDefault: false;
|
|
1126
|
+
isPrimaryKey: false;
|
|
1127
|
+
isAutoincrement: false;
|
|
1128
|
+
hasRuntimeDefault: false;
|
|
1129
|
+
enumValues: [string, ...string[]];
|
|
1130
|
+
baseColumn: never;
|
|
1131
|
+
identity: undefined;
|
|
1132
|
+
generated: undefined;
|
|
1133
|
+
}, {}, {
|
|
1134
|
+
length: number | undefined;
|
|
1135
|
+
}>;
|
|
1136
|
+
errorMessage: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1137
|
+
name: "error_message";
|
|
1138
|
+
tableName: "agent_run";
|
|
1139
|
+
dataType: "string";
|
|
1140
|
+
columnType: "SQLiteText";
|
|
1141
|
+
data: string;
|
|
1142
|
+
driverParam: string;
|
|
1143
|
+
notNull: false;
|
|
1144
|
+
hasDefault: false;
|
|
1145
|
+
isPrimaryKey: false;
|
|
1146
|
+
isAutoincrement: false;
|
|
1147
|
+
hasRuntimeDefault: false;
|
|
1148
|
+
enumValues: [string, ...string[]];
|
|
1149
|
+
baseColumn: never;
|
|
1150
|
+
identity: undefined;
|
|
1151
|
+
generated: undefined;
|
|
1152
|
+
}, {}, {
|
|
1153
|
+
length: number | undefined;
|
|
1154
|
+
}>;
|
|
1155
|
+
retries: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1156
|
+
name: "retries";
|
|
1157
|
+
tableName: "agent_run";
|
|
1158
|
+
dataType: "number";
|
|
1159
|
+
columnType: "SQLiteInteger";
|
|
1160
|
+
data: number;
|
|
1161
|
+
driverParam: number;
|
|
1162
|
+
notNull: true;
|
|
1163
|
+
hasDefault: true;
|
|
1164
|
+
isPrimaryKey: false;
|
|
1165
|
+
isAutoincrement: false;
|
|
1166
|
+
hasRuntimeDefault: false;
|
|
1167
|
+
enumValues: undefined;
|
|
1168
|
+
baseColumn: never;
|
|
1169
|
+
identity: undefined;
|
|
1170
|
+
generated: undefined;
|
|
1171
|
+
}, {}, {}>;
|
|
1172
|
+
startedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1173
|
+
name: "started_at";
|
|
1174
|
+
tableName: "agent_run";
|
|
1175
|
+
dataType: "date";
|
|
1176
|
+
columnType: "SQLiteTimestamp";
|
|
1177
|
+
data: Date;
|
|
1178
|
+
driverParam: number;
|
|
1179
|
+
notNull: true;
|
|
1180
|
+
hasDefault: false;
|
|
1181
|
+
isPrimaryKey: false;
|
|
1182
|
+
isAutoincrement: false;
|
|
1183
|
+
hasRuntimeDefault: false;
|
|
1184
|
+
enumValues: undefined;
|
|
1185
|
+
baseColumn: never;
|
|
1186
|
+
identity: undefined;
|
|
1187
|
+
generated: undefined;
|
|
1188
|
+
}, {}, {}>;
|
|
1189
|
+
settledAt: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1190
|
+
name: "settled_at";
|
|
1191
|
+
tableName: "agent_run";
|
|
1192
|
+
dataType: "date";
|
|
1193
|
+
columnType: "SQLiteTimestamp";
|
|
1194
|
+
data: Date;
|
|
1195
|
+
driverParam: number;
|
|
1196
|
+
notNull: false;
|
|
1197
|
+
hasDefault: false;
|
|
1198
|
+
isPrimaryKey: false;
|
|
1199
|
+
isAutoincrement: false;
|
|
1200
|
+
hasRuntimeDefault: false;
|
|
1201
|
+
enumValues: undefined;
|
|
1202
|
+
baseColumn: never;
|
|
1203
|
+
identity: undefined;
|
|
1204
|
+
generated: undefined;
|
|
1205
|
+
}, {}, {}>;
|
|
1206
|
+
promptHash: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1207
|
+
name: "prompt_hash";
|
|
1208
|
+
tableName: "agent_run";
|
|
1209
|
+
dataType: "string";
|
|
1210
|
+
columnType: "SQLiteText";
|
|
1211
|
+
data: string;
|
|
1212
|
+
driverParam: string;
|
|
1213
|
+
notNull: false;
|
|
1214
|
+
hasDefault: false;
|
|
1215
|
+
isPrimaryKey: false;
|
|
1216
|
+
isAutoincrement: false;
|
|
1217
|
+
hasRuntimeDefault: false;
|
|
1218
|
+
enumValues: [string, ...string[]];
|
|
1219
|
+
baseColumn: never;
|
|
1220
|
+
identity: undefined;
|
|
1221
|
+
generated: undefined;
|
|
1222
|
+
}, {}, {
|
|
1223
|
+
length: number | undefined;
|
|
1224
|
+
}>;
|
|
1225
|
+
};
|
|
1226
|
+
dialect: "sqlite";
|
|
1227
|
+
}>;
|
|
1228
|
+
/** The six agent tables as one schema object, ready for `drizzle(client, { schema })`. */
|
|
991
1229
|
declare const agentSchema: {
|
|
992
1230
|
agentThread: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
993
1231
|
name: "agent_thread";
|
|
@@ -1953,6 +2191,234 @@ declare const agentSchema: {
|
|
|
1953
2191
|
};
|
|
1954
2192
|
dialect: "sqlite";
|
|
1955
2193
|
}>;
|
|
2194
|
+
agentRun: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
2195
|
+
name: "agent_run";
|
|
2196
|
+
schema: undefined;
|
|
2197
|
+
columns: {
|
|
2198
|
+
id: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2199
|
+
name: "id";
|
|
2200
|
+
tableName: "agent_run";
|
|
2201
|
+
dataType: "string";
|
|
2202
|
+
columnType: "SQLiteText";
|
|
2203
|
+
data: string;
|
|
2204
|
+
driverParam: string;
|
|
2205
|
+
notNull: true;
|
|
2206
|
+
hasDefault: false;
|
|
2207
|
+
isPrimaryKey: true;
|
|
2208
|
+
isAutoincrement: false;
|
|
2209
|
+
hasRuntimeDefault: false;
|
|
2210
|
+
enumValues: [string, ...string[]];
|
|
2211
|
+
baseColumn: never;
|
|
2212
|
+
identity: undefined;
|
|
2213
|
+
generated: undefined;
|
|
2214
|
+
}, {}, {
|
|
2215
|
+
length: number | undefined;
|
|
2216
|
+
}>;
|
|
2217
|
+
threadId: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2218
|
+
name: "thread_id";
|
|
2219
|
+
tableName: "agent_run";
|
|
2220
|
+
dataType: "string";
|
|
2221
|
+
columnType: "SQLiteText";
|
|
2222
|
+
data: string;
|
|
2223
|
+
driverParam: string;
|
|
2224
|
+
notNull: true;
|
|
2225
|
+
hasDefault: false;
|
|
2226
|
+
isPrimaryKey: false;
|
|
2227
|
+
isAutoincrement: false;
|
|
2228
|
+
hasRuntimeDefault: false;
|
|
2229
|
+
enumValues: [string, ...string[]];
|
|
2230
|
+
baseColumn: never;
|
|
2231
|
+
identity: undefined;
|
|
2232
|
+
generated: undefined;
|
|
2233
|
+
}, {}, {
|
|
2234
|
+
length: number | undefined;
|
|
2235
|
+
}>;
|
|
2236
|
+
actorRef: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2237
|
+
name: "actor_ref";
|
|
2238
|
+
tableName: "agent_run";
|
|
2239
|
+
dataType: "string";
|
|
2240
|
+
columnType: "SQLiteText";
|
|
2241
|
+
data: string;
|
|
2242
|
+
driverParam: string;
|
|
2243
|
+
notNull: true;
|
|
2244
|
+
hasDefault: false;
|
|
2245
|
+
isPrimaryKey: false;
|
|
2246
|
+
isAutoincrement: false;
|
|
2247
|
+
hasRuntimeDefault: false;
|
|
2248
|
+
enumValues: [string, ...string[]];
|
|
2249
|
+
baseColumn: never;
|
|
2250
|
+
identity: undefined;
|
|
2251
|
+
generated: undefined;
|
|
2252
|
+
}, {}, {
|
|
2253
|
+
length: number | undefined;
|
|
2254
|
+
}>;
|
|
2255
|
+
agentName: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2256
|
+
name: "agent_name";
|
|
2257
|
+
tableName: "agent_run";
|
|
2258
|
+
dataType: "string";
|
|
2259
|
+
columnType: "SQLiteText";
|
|
2260
|
+
data: string;
|
|
2261
|
+
driverParam: string;
|
|
2262
|
+
notNull: false;
|
|
2263
|
+
hasDefault: false;
|
|
2264
|
+
isPrimaryKey: false;
|
|
2265
|
+
isAutoincrement: false;
|
|
2266
|
+
hasRuntimeDefault: false;
|
|
2267
|
+
enumValues: [string, ...string[]];
|
|
2268
|
+
baseColumn: never;
|
|
2269
|
+
identity: undefined;
|
|
2270
|
+
generated: undefined;
|
|
2271
|
+
}, {}, {
|
|
2272
|
+
length: number | undefined;
|
|
2273
|
+
}>;
|
|
2274
|
+
status: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2275
|
+
name: "status";
|
|
2276
|
+
tableName: "agent_run";
|
|
2277
|
+
dataType: "string";
|
|
2278
|
+
columnType: "SQLiteText";
|
|
2279
|
+
data: AgentRunStatus;
|
|
2280
|
+
driverParam: string;
|
|
2281
|
+
notNull: true;
|
|
2282
|
+
hasDefault: false;
|
|
2283
|
+
isPrimaryKey: false;
|
|
2284
|
+
isAutoincrement: false;
|
|
2285
|
+
hasRuntimeDefault: false;
|
|
2286
|
+
enumValues: [string, ...string[]];
|
|
2287
|
+
baseColumn: never;
|
|
2288
|
+
identity: undefined;
|
|
2289
|
+
generated: undefined;
|
|
2290
|
+
}, {}, {
|
|
2291
|
+
length: number | undefined;
|
|
2292
|
+
$type: AgentRunStatus;
|
|
2293
|
+
}>;
|
|
2294
|
+
durationMs: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2295
|
+
name: "duration_ms";
|
|
2296
|
+
tableName: "agent_run";
|
|
2297
|
+
dataType: "number";
|
|
2298
|
+
columnType: "SQLiteInteger";
|
|
2299
|
+
data: number;
|
|
2300
|
+
driverParam: number;
|
|
2301
|
+
notNull: false;
|
|
2302
|
+
hasDefault: false;
|
|
2303
|
+
isPrimaryKey: false;
|
|
2304
|
+
isAutoincrement: false;
|
|
2305
|
+
hasRuntimeDefault: false;
|
|
2306
|
+
enumValues: undefined;
|
|
2307
|
+
baseColumn: never;
|
|
2308
|
+
identity: undefined;
|
|
2309
|
+
generated: undefined;
|
|
2310
|
+
}, {}, {}>;
|
|
2311
|
+
errorCode: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2312
|
+
name: "error_code";
|
|
2313
|
+
tableName: "agent_run";
|
|
2314
|
+
dataType: "string";
|
|
2315
|
+
columnType: "SQLiteText";
|
|
2316
|
+
data: string;
|
|
2317
|
+
driverParam: string;
|
|
2318
|
+
notNull: false;
|
|
2319
|
+
hasDefault: false;
|
|
2320
|
+
isPrimaryKey: false;
|
|
2321
|
+
isAutoincrement: false;
|
|
2322
|
+
hasRuntimeDefault: false;
|
|
2323
|
+
enumValues: [string, ...string[]];
|
|
2324
|
+
baseColumn: never;
|
|
2325
|
+
identity: undefined;
|
|
2326
|
+
generated: undefined;
|
|
2327
|
+
}, {}, {
|
|
2328
|
+
length: number | undefined;
|
|
2329
|
+
}>;
|
|
2330
|
+
errorMessage: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2331
|
+
name: "error_message";
|
|
2332
|
+
tableName: "agent_run";
|
|
2333
|
+
dataType: "string";
|
|
2334
|
+
columnType: "SQLiteText";
|
|
2335
|
+
data: string;
|
|
2336
|
+
driverParam: string;
|
|
2337
|
+
notNull: false;
|
|
2338
|
+
hasDefault: false;
|
|
2339
|
+
isPrimaryKey: false;
|
|
2340
|
+
isAutoincrement: false;
|
|
2341
|
+
hasRuntimeDefault: false;
|
|
2342
|
+
enumValues: [string, ...string[]];
|
|
2343
|
+
baseColumn: never;
|
|
2344
|
+
identity: undefined;
|
|
2345
|
+
generated: undefined;
|
|
2346
|
+
}, {}, {
|
|
2347
|
+
length: number | undefined;
|
|
2348
|
+
}>;
|
|
2349
|
+
retries: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2350
|
+
name: "retries";
|
|
2351
|
+
tableName: "agent_run";
|
|
2352
|
+
dataType: "number";
|
|
2353
|
+
columnType: "SQLiteInteger";
|
|
2354
|
+
data: number;
|
|
2355
|
+
driverParam: number;
|
|
2356
|
+
notNull: true;
|
|
2357
|
+
hasDefault: true;
|
|
2358
|
+
isPrimaryKey: false;
|
|
2359
|
+
isAutoincrement: false;
|
|
2360
|
+
hasRuntimeDefault: false;
|
|
2361
|
+
enumValues: undefined;
|
|
2362
|
+
baseColumn: never;
|
|
2363
|
+
identity: undefined;
|
|
2364
|
+
generated: undefined;
|
|
2365
|
+
}, {}, {}>;
|
|
2366
|
+
startedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2367
|
+
name: "started_at";
|
|
2368
|
+
tableName: "agent_run";
|
|
2369
|
+
dataType: "date";
|
|
2370
|
+
columnType: "SQLiteTimestamp";
|
|
2371
|
+
data: Date;
|
|
2372
|
+
driverParam: number;
|
|
2373
|
+
notNull: true;
|
|
2374
|
+
hasDefault: false;
|
|
2375
|
+
isPrimaryKey: false;
|
|
2376
|
+
isAutoincrement: false;
|
|
2377
|
+
hasRuntimeDefault: false;
|
|
2378
|
+
enumValues: undefined;
|
|
2379
|
+
baseColumn: never;
|
|
2380
|
+
identity: undefined;
|
|
2381
|
+
generated: undefined;
|
|
2382
|
+
}, {}, {}>;
|
|
2383
|
+
settledAt: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2384
|
+
name: "settled_at";
|
|
2385
|
+
tableName: "agent_run";
|
|
2386
|
+
dataType: "date";
|
|
2387
|
+
columnType: "SQLiteTimestamp";
|
|
2388
|
+
data: Date;
|
|
2389
|
+
driverParam: number;
|
|
2390
|
+
notNull: false;
|
|
2391
|
+
hasDefault: false;
|
|
2392
|
+
isPrimaryKey: false;
|
|
2393
|
+
isAutoincrement: false;
|
|
2394
|
+
hasRuntimeDefault: false;
|
|
2395
|
+
enumValues: undefined;
|
|
2396
|
+
baseColumn: never;
|
|
2397
|
+
identity: undefined;
|
|
2398
|
+
generated: undefined;
|
|
2399
|
+
}, {}, {}>;
|
|
2400
|
+
promptHash: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2401
|
+
name: "prompt_hash";
|
|
2402
|
+
tableName: "agent_run";
|
|
2403
|
+
dataType: "string";
|
|
2404
|
+
columnType: "SQLiteText";
|
|
2405
|
+
data: string;
|
|
2406
|
+
driverParam: string;
|
|
2407
|
+
notNull: false;
|
|
2408
|
+
hasDefault: false;
|
|
2409
|
+
isPrimaryKey: false;
|
|
2410
|
+
isAutoincrement: false;
|
|
2411
|
+
hasRuntimeDefault: false;
|
|
2412
|
+
enumValues: [string, ...string[]];
|
|
2413
|
+
baseColumn: never;
|
|
2414
|
+
identity: undefined;
|
|
2415
|
+
generated: undefined;
|
|
2416
|
+
}, {}, {
|
|
2417
|
+
length: number | undefined;
|
|
2418
|
+
}>;
|
|
2419
|
+
};
|
|
2420
|
+
dialect: "sqlite";
|
|
2421
|
+
}>;
|
|
1956
2422
|
};
|
|
1957
2423
|
/**
|
|
1958
2424
|
* The dialect-portable Drizzle SQLite database handle the store operates on. Accepts any SQLite
|
|
@@ -1964,6 +2430,8 @@ type AgentDrizzleDb = BaseSQLiteDatabase<'sync' | 'async', unknown>;
|
|
|
1964
2430
|
type AgentThreadRow = typeof agentThread.$inferSelect;
|
|
1965
2431
|
/** A persisted message row as Drizzle selects it. */
|
|
1966
2432
|
type AgentMessageRow = typeof agentMessage.$inferSelect;
|
|
2433
|
+
/** A persisted run row as Drizzle selects it. */
|
|
2434
|
+
type AgentRunRow = typeof agentRun.$inferSelect;
|
|
1967
2435
|
|
|
1968
2436
|
/** Runs the `CREATE TABLE IF NOT EXISTS` DDL above against the supplied Drizzle SQLite db. */
|
|
1969
2437
|
declare function ensureAgentSchema(db: AgentDrizzleDb): Promise<void>;
|
|
@@ -1989,6 +2457,24 @@ declare class DrizzleAgentStore implements AgentStore {
|
|
|
1989
2457
|
setTitle(threadId: string, title: string): Promise<void>;
|
|
1990
2458
|
promoteThread(threadId: string): Promise<void>;
|
|
1991
2459
|
setActiveStream(threadId: string, runId: string | null): Promise<void>;
|
|
2460
|
+
/** Persist the start of a run (turn). Replay-safe: called under a durable localStep. */
|
|
2461
|
+
recordRunStart(run: {
|
|
2462
|
+
runId: string;
|
|
2463
|
+
threadId: string;
|
|
2464
|
+
actorRef: string;
|
|
2465
|
+
agentName?: string;
|
|
2466
|
+
promptHash?: string;
|
|
2467
|
+
}): Promise<void>;
|
|
2468
|
+
/** Settle a run's outcome. A no-op when the run is unknown (mirrors `setTitle`/`updateThread`). */
|
|
2469
|
+
recordRunEnd(end: {
|
|
2470
|
+
runId: string;
|
|
2471
|
+
status: 'completed' | 'failed';
|
|
2472
|
+
durationMs?: number;
|
|
2473
|
+
errorCode?: string;
|
|
2474
|
+
errorMessage?: string;
|
|
2475
|
+
}): Promise<void>;
|
|
2476
|
+
/** Bump the run's llm-step retry counter. Atomic `retries = retries + 1`, no read-modify-write. */
|
|
2477
|
+
bumpRunRetries(runId: string): Promise<void>;
|
|
1992
2478
|
appendMessage(input: AppendMessageInput): Promise<StoredMessage>;
|
|
1993
2479
|
truncateFrom(threadId: string, messageId: string): Promise<void>;
|
|
1994
2480
|
recordToolCall(input: RecordToolCallInput): Promise<void>;
|
|
@@ -2027,6 +2513,24 @@ declare class DrizzleGovernanceQueries implements AgentGovernanceQueries {
|
|
|
2027
2513
|
usageTrend(range: GovernanceRange): Promise<UsageTrendPoint[]>;
|
|
2028
2514
|
recentToolCalls(limit: number): Promise<ToolCallActivityRow[]>;
|
|
2029
2515
|
recentThreads(limit: number): Promise<ThreadActivityRow[]>;
|
|
2516
|
+
private runsInRange;
|
|
2517
|
+
runMetrics(range: GovernanceRange): Promise<RunMetrics>;
|
|
2518
|
+
runsByAgent(range: GovernanceRange): Promise<RunAgentBreakdownRow[]>;
|
|
2519
|
+
runErrors(range: GovernanceRange): Promise<RunErrorBreakdownRow[]>;
|
|
2520
|
+
runTrend(range: GovernanceRange): Promise<RunTrendPoint[]>;
|
|
2521
|
+
recentRuns(limit: number): Promise<RecentRunRow[]>;
|
|
2522
|
+
/**
|
|
2523
|
+
* Tool calls sitting `pending_approval`, oldest first (an inbox drains from the back), joined
|
|
2524
|
+
* through their message to the owning thread for title/actorRef and to the message itself for
|
|
2525
|
+
* `agentName` (null when the message carries none).
|
|
2526
|
+
*/
|
|
2527
|
+
pendingApprovals(limit: number): Promise<PendingApprovalRow[]>;
|
|
2528
|
+
/**
|
|
2529
|
+
* Per-tool call/failure/rejection/latency rollup over the range, highest call count first.
|
|
2530
|
+
* `p95ExecutionMs` is computed over calls that recorded a non-null `executionMs` (regardless of
|
|
2531
|
+
* their final status); `null` when none did.
|
|
2532
|
+
*/
|
|
2533
|
+
toolStats(range: GovernanceRange): Promise<ToolStatRow[]>;
|
|
2030
2534
|
}
|
|
2031
2535
|
|
|
2032
2536
|
/**
|
|
@@ -2074,4 +2578,4 @@ declare class DrizzleAgentStoreModule {
|
|
|
2074
2578
|
static forRoot(options: DrizzleAgentStoreModuleOptions): DynamicModule;
|
|
2075
2579
|
}
|
|
2076
2580
|
|
|
2077
|
-
export { type AgentDrizzleDb, type AgentMessageRow, type AgentThreadRow, DrizzleAgentStore, DrizzleAgentStoreModule, type DrizzleAgentStoreModuleOptions, DrizzleGovernanceQueries, DrizzlePricingStore, agentMessage, agentModelPricing, agentSchema, agentThread, agentTokenUsage, agentToolCall, ensureAgentSchema };
|
|
2581
|
+
export { type AgentDrizzleDb, type AgentMessageRow, type AgentRunRow, type AgentRunStatus, type AgentThreadRow, DrizzleAgentStore, DrizzleAgentStoreModule, type DrizzleAgentStoreModuleOptions, DrizzleGovernanceQueries, DrizzlePricingStore, agentMessage, agentModelPricing, agentRun, agentSchema, agentThread, agentTokenUsage, agentToolCall, ensureAgentSchema };
|