@dudousxd/nestjs-agent-store-drizzle 0.19.1 → 0.20.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 CHANGED
@@ -1151,6 +1151,43 @@ var DrizzleAgentStore = class {
1151
1151
  }
1152
1152
  await this.db.update(agentToolCall).set(updates).where((0, import_drizzle_orm2.eq)(agentToolCall.id, input.toolCallId));
1153
1153
  }
1154
+ async toolCallOutcomes(toolCallIds) {
1155
+ if (toolCallIds.length === 0) {
1156
+ return [];
1157
+ }
1158
+ const rows = await this.db.select({
1159
+ id: agentToolCall.id,
1160
+ status: agentToolCall.status,
1161
+ output: agentToolCall.output,
1162
+ error: agentToolCall.error
1163
+ }).from(agentToolCall).where((0, import_drizzle_orm2.inArray)(agentToolCall.id, [
1164
+ ...toolCallIds
1165
+ ]));
1166
+ return rows.map((row) => ({
1167
+ id: row.id,
1168
+ status: row.status,
1169
+ ...row.output !== void 0 && row.output !== null ? {
1170
+ output: row.output
1171
+ } : {},
1172
+ ...typeof row.error === "string" ? {
1173
+ error: row.error
1174
+ } : {}
1175
+ }));
1176
+ }
1177
+ async failUnsettledToolCalls(runId, error) {
1178
+ const pending = (0, import_drizzle_orm2.and)((0, import_drizzle_orm2.eq)(agentToolCall.runId, runId), (0, import_drizzle_orm2.eq)(agentToolCall.status, "pending_approval"));
1179
+ const rows = await this.db.select({
1180
+ id: agentToolCall.id
1181
+ }).from(agentToolCall).where(pending);
1182
+ if (rows.length === 0) {
1183
+ return 0;
1184
+ }
1185
+ await this.db.update(agentToolCall).set({
1186
+ status: "failed",
1187
+ error
1188
+ }).where(pending);
1189
+ return rows.length;
1190
+ }
1154
1191
  /**
1155
1192
  * Of `mediaIds`, the ones a surviving message in one of this actor's threads still carries.
1156
1193
  *