@dudousxd/nestjs-agent-dashboard 0.13.1 → 0.14.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.
Files changed (44) hide show
  1. package/README.md +29 -4
  2. package/dist/client/agent-client.d.ts +111 -1
  3. package/dist/client/agent-client.d.ts.map +1 -1
  4. package/dist/client/agent-client.js +27 -1
  5. package/dist/client/agent-client.js.map +1 -1
  6. package/dist/client/describe-error.d.ts +30 -0
  7. package/dist/client/describe-error.d.ts.map +1 -0
  8. package/dist/client/describe-error.js +63 -0
  9. package/dist/client/describe-error.js.map +1 -0
  10. package/dist/client/format-day.d.ts +19 -0
  11. package/dist/client/format-day.d.ts.map +1 -0
  12. package/dist/client/format-day.js +38 -0
  13. package/dist/client/format-day.js.map +1 -0
  14. package/dist/client/trend-summary.d.ts +33 -0
  15. package/dist/client/trend-summary.d.ts.map +1 -0
  16. package/dist/client/trend-summary.js +33 -0
  17. package/dist/client/trend-summary.js.map +1 -0
  18. package/dist/server/index.cjs +170 -2
  19. package/dist/server/index.cjs.map +1 -1
  20. package/dist/server/index.d.cts +62 -4
  21. package/dist/server/index.d.ts +62 -4
  22. package/dist/server/index.js +181 -13
  23. package/dist/server/index.js.map +1 -1
  24. package/dist/spa/assets/base-ui-CKhU3I2F.js +55 -0
  25. package/dist/spa/assets/index-CO6XH1b7.css +1 -0
  26. package/dist/spa/assets/index-Cvgm9m_c.js +1 -0
  27. package/dist/spa/assets/index-Dr3vAOUw.js +25 -0
  28. package/dist/spa/assets/preview-BdD_YKne.js +1 -0
  29. package/dist/spa/assets/recharts-CPMXF7sD.js +69 -0
  30. package/dist/spa/index.html +5 -3
  31. package/dist/spa/preview.html +5 -3
  32. package/package.json +15 -9
  33. package/dist/client/run-trend-path.d.ts +0 -30
  34. package/dist/client/run-trend-path.d.ts.map +0 -1
  35. package/dist/client/run-trend-path.js +0 -36
  36. package/dist/client/run-trend-path.js.map +0 -1
  37. package/dist/client/trend-path.d.ts +0 -27
  38. package/dist/client/trend-path.d.ts.map +0 -1
  39. package/dist/client/trend-path.js +0 -25
  40. package/dist/client/trend-path.js.map +0 -1
  41. package/dist/spa/assets/index-C42SW8IV.js +0 -1
  42. package/dist/spa/assets/index-DMBWMAsE.css +0 -1
  43. package/dist/spa/assets/index-DZVPxvtJ.js +0 -49
  44. package/dist/spa/assets/preview-DhDnTjWH.js +0 -1
@@ -590,10 +590,56 @@ var DashboardService = class {
590
590
  runsPage(query) {
591
591
  return this.queries.runsPage(query);
592
592
  }
593
- /** Tool calls sitting `pending_approval`, oldest first, for the cross-thread approvals inbox. */
593
+ /**
594
+ * Tool calls sitting `pending_approval`, oldest first, for the cross-thread approvals inbox.
595
+ * Capped and totalless — kept because the SPA still calls `GET approvals`; new callers want
596
+ * {@link approvalsPage}, which reports how much of the backlog the cap hid.
597
+ */
594
598
  pendingApprovals(limit) {
595
599
  return this.queries.pendingApprovals(limit);
596
600
  }
601
+ /** Paged, filterable approvals inbox with a total — the backlog-safe read of the HITL queue. */
602
+ approvalsPage(query) {
603
+ return this.queries.approvalsPage(query);
604
+ }
605
+ /**
606
+ * One run with its thread and its tool calls. 404s on an unknown id rather than returning an empty
607
+ * detail: "this run does not exist" and "this run did nothing" are different answers, and a console
608
+ * that conflates them sends an operator looking for a bug that isn't there.
609
+ */
610
+ async runDetail(runId) {
611
+ const detail = await this.queries.runDetail(runId);
612
+ if (detail === null) {
613
+ throw new import_common4.NotFoundException(`No run "${runId}".`);
614
+ }
615
+ const [thread] = await this.withActorLabels([
616
+ detail.thread
617
+ ]);
618
+ return {
619
+ ...detail,
620
+ thread: thread ?? {
621
+ ...detail.thread,
622
+ actorLabel: null
623
+ }
624
+ };
625
+ }
626
+ /** One thread with its usage rollup, runs and messages. 404s on an unknown id, like {@link runDetail}. */
627
+ async threadDetail(query) {
628
+ const detail = await this.queries.threadDetail(query);
629
+ if (detail === null) {
630
+ throw new import_common4.NotFoundException(`No thread "${query.threadId}".`);
631
+ }
632
+ const [thread] = await this.withActorLabels([
633
+ detail.thread
634
+ ]);
635
+ return {
636
+ ...detail,
637
+ thread: thread ?? {
638
+ ...detail.thread,
639
+ actorLabel: null
640
+ }
641
+ };
642
+ }
597
643
  /** Per-tool call/failure/rejection/latency rollup for a day range, for the Tools section. */
598
644
  toolStats(range) {
599
645
  return this.queries.toolStats(range);
@@ -827,6 +873,7 @@ var RUN_WHERE_FIELDS = [
827
873
  "agentName",
828
874
  "status",
829
875
  "errorCode",
876
+ "threadId",
830
877
  "fromDay",
831
878
  "toDay"
832
879
  ];
@@ -844,6 +891,9 @@ function parseRunWhere(raw) {
844
891
  ...raw.errorCode !== void 0 ? {
845
892
  errorCode: raw.errorCode
846
893
  } : {},
894
+ ...raw.threadId !== void 0 ? {
895
+ threadId: raw.threadId
896
+ } : {},
847
897
  ...raw.fromDay !== void 0 ? {
848
898
  fromDay: raw.fromDay
849
899
  } : {},
@@ -853,6 +903,40 @@ function parseRunWhere(raw) {
853
903
  };
854
904
  }
855
905
  __name(parseRunWhere, "parseRunWhere");
906
+ var APPROVAL_WHERE_FIELDS = [
907
+ "toolName",
908
+ "threadId",
909
+ "actorRef",
910
+ "agentName",
911
+ "fromDay",
912
+ "toDay"
913
+ ];
914
+ function parseApprovalWhere(raw) {
915
+ if (raw === void 0 || Object.keys(raw).length === 0) return void 0;
916
+ assertKnownFields(raw, APPROVAL_WHERE_FIELDS);
917
+ assertDayFields(raw, DAY_FIELDS);
918
+ return {
919
+ ...raw.toolName !== void 0 ? {
920
+ toolName: raw.toolName
921
+ } : {},
922
+ ...raw.threadId !== void 0 ? {
923
+ threadId: raw.threadId
924
+ } : {},
925
+ ...raw.actorRef !== void 0 ? {
926
+ actorRef: raw.actorRef
927
+ } : {},
928
+ ...raw.agentName !== void 0 ? {
929
+ agentName: raw.agentName
930
+ } : {},
931
+ ...raw.fromDay !== void 0 ? {
932
+ fromDay: raw.fromDay
933
+ } : {},
934
+ ...raw.toDay !== void 0 ? {
935
+ toDay: raw.toDay
936
+ } : {}
937
+ };
938
+ }
939
+ __name(parseApprovalWhere, "parseApprovalWhere");
856
940
 
857
941
  // src/server/agent-api.controller.ts
858
942
  function _ts_decorate3(decorators, target, key, desc) {
@@ -938,6 +1022,16 @@ var AgentApiController = class {
938
1022
  } : {}
939
1023
  });
940
1024
  }
1025
+ /**
1026
+ * One run drill-down: the run, its owning thread's headline (actor-labeled) and its tool calls, in
1027
+ * ONE round trip. 404s on an unknown run id.
1028
+ *
1029
+ * Declared AFTER `runs-page` so the literal route wins over this parameterised one regardless of
1030
+ * how the router orders same-prefix paths.
1031
+ */
1032
+ runDetail(runId) {
1033
+ return this.dashboard.runDetail(runId);
1034
+ }
941
1035
  /** Most recent tool calls (default 50, max 200) for the activity feed. */
942
1036
  toolCalls(limit) {
943
1037
  return this.dashboard.recentToolCalls(parseLimit(limit, 50));
@@ -957,11 +1051,34 @@ var AgentApiController = class {
957
1051
  } : {}
958
1052
  });
959
1053
  }
960
- /** Tool calls sitting `pending_approval` (default 50, max 200), oldest first — the approvals inbox. */
1054
+ /**
1055
+ * Tool calls sitting `pending_approval` (default 50, max 200), oldest first — the approvals inbox.
1056
+ *
1057
+ * Capped with NO total, so a backlog past `limit` is invisible from the response alone. Kept
1058
+ * because the SPA still calls it; anything new should call `approvals-page` instead.
1059
+ */
961
1060
  approvals(limit) {
962
1061
  return this.dashboard.pendingApprovals(parseLimit(limit, 50));
963
1062
  }
964
1063
  /**
1064
+ * Paged, filterable approvals inbox, oldest first. `page` (default 1), `limit` (default 25, max
1065
+ * 200), and `where[toolName]`/`where[threadId]`/`where[actorRef]`/`where[agentName]`/
1066
+ * `where[fromDay]`/`where[toDay]` (`YYYY-MM-DD`) — an unknown `where` field 400s naming it.
1067
+ *
1068
+ * Unlike `GET approvals` this reports `total`, so the console can say "showing N of M" instead of
1069
+ * silently hiding pending decisions behind a row cap.
1070
+ */
1071
+ approvalsPage(page, limit, where) {
1072
+ const parsedWhere = parseApprovalWhere(where);
1073
+ return this.dashboard.approvalsPage({
1074
+ page: parsePageNumber(page),
1075
+ pageSize: parseLimit(limit, 25),
1076
+ ...parsedWhere !== void 0 ? {
1077
+ where: parsedWhere
1078
+ } : {}
1079
+ });
1080
+ }
1081
+ /**
965
1082
  * Decide a pending HITL tool call. Body `{ approved: boolean; reason?: string }`. 501s (via
966
1083
  * `DashboardService.decideApproval`) when no `AGENT_APPROVAL_PORT` is bound. `executedByRef`
967
1084
  * comes from {@link deciderRef} run against the live request.
@@ -1013,6 +1130,22 @@ var AgentApiController = class {
1013
1130
  });
1014
1131
  }
1015
1132
  /**
1133
+ * One thread drill-down: the thread (actor-labeled), its lifetime token/cost rollup, its newest
1134
+ * runs and its newest messages, in ONE round trip. `messages` (default 50, max 200) and `runs`
1135
+ * (default 25, max 200) cap the two lists; `runTotal` and `thread.messageCount` report the true
1136
+ * sizes so the console can say what the caps hid. 404s on an unknown thread id.
1137
+ *
1138
+ * A soft-deleted thread is still returned, flagged `deleted: true` — an audit needs the thread it
1139
+ * just lost, and the alternative is a drill-down that 404s on exactly the interesting case.
1140
+ */
1141
+ threadDetail(threadId, messages, runs) {
1142
+ return this.dashboard.threadDetail({
1143
+ threadId,
1144
+ messageLimit: parseLimit(messages, 50),
1145
+ runLimit: parseLimit(runs, 25)
1146
+ });
1147
+ }
1148
+ /**
1016
1149
  * Current price row per model, for the pricing tab. 501s (via `DashboardService.listPrices`) when
1017
1150
  * no `AGENT_PRICING_STORE` is bound.
1018
1151
  */
@@ -1089,6 +1222,15 @@ _ts_decorate3([
1089
1222
  ]),
1090
1223
  _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1091
1224
  ], AgentApiController.prototype, "runsPage", null);
1225
+ _ts_decorate3([
1226
+ (0, import_common6.Get)("runs/:runId"),
1227
+ _ts_param3(0, (0, import_common6.Param)("runId")),
1228
+ _ts_metadata3("design:type", Function),
1229
+ _ts_metadata3("design:paramtypes", [
1230
+ String
1231
+ ]),
1232
+ _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1233
+ ], AgentApiController.prototype, "runDetail", null);
1092
1234
  _ts_decorate3([
1093
1235
  (0, import_common6.Get)("tool-calls"),
1094
1236
  _ts_param3(0, (0, import_common6.Query)("limit")),
@@ -1120,6 +1262,19 @@ _ts_decorate3([
1120
1262
  ]),
1121
1263
  _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1122
1264
  ], AgentApiController.prototype, "approvals", null);
1265
+ _ts_decorate3([
1266
+ (0, import_common6.Get)("approvals-page"),
1267
+ _ts_param3(0, (0, import_common6.Query)("page")),
1268
+ _ts_param3(1, (0, import_common6.Query)("limit")),
1269
+ _ts_param3(2, (0, import_common6.Query)("where")),
1270
+ _ts_metadata3("design:type", Function),
1271
+ _ts_metadata3("design:paramtypes", [
1272
+ String,
1273
+ String,
1274
+ typeof Record === "undefined" ? Object : Record
1275
+ ]),
1276
+ _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1277
+ ], AgentApiController.prototype, "approvalsPage", null);
1123
1278
  _ts_decorate3([
1124
1279
  (0, import_common6.Post)("approvals/:toolCallId"),
1125
1280
  (0, import_common6.HttpCode)(204),
@@ -1167,6 +1322,19 @@ _ts_decorate3([
1167
1322
  ]),
1168
1323
  _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1169
1324
  ], AgentApiController.prototype, "threadsPage", null);
1325
+ _ts_decorate3([
1326
+ (0, import_common6.Get)("threads/:threadId"),
1327
+ _ts_param3(0, (0, import_common6.Param)("threadId")),
1328
+ _ts_param3(1, (0, import_common6.Query)("messages")),
1329
+ _ts_param3(2, (0, import_common6.Query)("runs")),
1330
+ _ts_metadata3("design:type", Function),
1331
+ _ts_metadata3("design:paramtypes", [
1332
+ String,
1333
+ String,
1334
+ String
1335
+ ]),
1336
+ _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1337
+ ], AgentApiController.prototype, "threadDetail", null);
1170
1338
  _ts_decorate3([
1171
1339
  (0, import_common6.Get)("pricing"),
1172
1340
  _ts_metadata3("design:type", Function),