@dudousxd/nestjs-agent-core 0.10.0 → 0.11.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
@@ -49,6 +49,7 @@ __export(index_exports, {
49
49
  DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS: () => DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS,
50
50
  DefaultRolesPolicy: () => DefaultRolesPolicy,
51
51
  QuotaExceededError: () => QuotaExceededError,
52
+ THREAD_DETAIL_CONTENT_CHARS: () => THREAD_DETAIL_CONTENT_CHARS,
52
53
  ToolForbiddenError: () => ToolForbiddenError,
53
54
  ToolInputInvalidError: () => ToolInputInvalidError,
54
55
  ToolNotFoundError: () => ToolNotFoundError,
@@ -75,10 +76,12 @@ __export(index_exports, {
75
76
  publishAgentToolCall: () => publishAgentToolCall,
76
77
  publishAgentToolRetry: () => publishAgentToolRetry,
77
78
  resolveToolTransientRetryNumbers: () => resolveToolTransientRetryNumbers,
79
+ rollupThreadUsage: () => rollupThreadUsage,
78
80
  runAgentLoop: () => runAgentLoop,
79
81
  seedModelPrices: () => seedModelPrices,
80
82
  traceLlmTurn: () => traceLlmTurn,
81
83
  traceToolExecution: () => traceToolExecution,
84
+ truncateDetailContent: () => truncateDetailContent,
82
85
  withToolTimeout: () => withToolTimeout
83
86
  });
84
87
  module.exports = __toCommonJS(index_exports);
@@ -134,6 +137,22 @@ async function seedModelPrices(store, prices) {
134
137
  }
135
138
  __name(seedModelPrices, "seedModelPrices");
136
139
 
140
+ // src/spi/governance-queries.ts
141
+ var THREAD_DETAIL_CONTENT_CHARS = 2e3;
142
+ function truncateDetailContent(content) {
143
+ if (content.length <= THREAD_DETAIL_CONTENT_CHARS) {
144
+ return {
145
+ content,
146
+ truncated: false
147
+ };
148
+ }
149
+ return {
150
+ content: content.slice(0, THREAD_DETAIL_CONTENT_CHARS),
151
+ truncated: true
152
+ };
153
+ }
154
+ __name(truncateDetailContent, "truncateDetailContent");
155
+
137
156
  // src/governance/compute.ts
138
157
  function estimateCost(usage, price) {
139
158
  if (price === void 0) {
@@ -239,6 +258,24 @@ function bucketByThread(rows, prices, threads, options) {
239
258
  return result.slice(0, options.limit);
240
259
  }
241
260
  __name(bucketByThread, "bucketByThread");
261
+ function rollupThreadUsage(rows, prices) {
262
+ const rollup = {
263
+ requests: 0,
264
+ inputTokens: 0,
265
+ outputTokens: 0,
266
+ totalTokens: 0,
267
+ costUsd: 0
268
+ };
269
+ for (const row of rows) {
270
+ rollup.requests += 1;
271
+ rollup.inputTokens += row.inputTokens;
272
+ rollup.outputTokens += row.outputTokens;
273
+ rollup.totalTokens += row.inputTokens + row.outputTokens;
274
+ rollup.costUsd += rowCost(row, prices);
275
+ }
276
+ return rollup;
277
+ }
278
+ __name(rollupThreadUsage, "rollupThreadUsage");
242
279
  function bucketUsageTrend(rows, prices) {
243
280
  const byDay = /* @__PURE__ */ new Map();
244
281
  for (const row of rows) {
@@ -1261,6 +1298,7 @@ __name(runAgentLoop, "runAgentLoop");
1261
1298
  DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS,
1262
1299
  DefaultRolesPolicy,
1263
1300
  QuotaExceededError,
1301
+ THREAD_DETAIL_CONTENT_CHARS,
1264
1302
  ToolForbiddenError,
1265
1303
  ToolInputInvalidError,
1266
1304
  ToolNotFoundError,
@@ -1287,10 +1325,12 @@ __name(runAgentLoop, "runAgentLoop");
1287
1325
  publishAgentToolCall,
1288
1326
  publishAgentToolRetry,
1289
1327
  resolveToolTransientRetryNumbers,
1328
+ rollupThreadUsage,
1290
1329
  runAgentLoop,
1291
1330
  seedModelPrices,
1292
1331
  traceLlmTurn,
1293
1332
  traceToolExecution,
1333
+ truncateDetailContent,
1294
1334
  withToolTimeout
1295
1335
  });
1296
1336
  //# sourceMappingURL=index.cjs.map