@dudousxd/nestjs-agent 1.35.1 → 1.36.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/durable/index.cjs +130 -20
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.js +134 -24
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +43 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -12
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -6000,8 +6000,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6000
6000
|
...deps,
|
|
6001
6001
|
day
|
|
6002
6002
|
}, input, hooks).then(() => (0, import_nestjs_agent_core32.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
|
|
6003
|
+
const durationMs = (0, import_nestjs_agent_core32.runDurationMs)(error);
|
|
6004
|
+
const timed = durationMs !== void 0 ? {
|
|
6005
|
+
durationMs
|
|
6006
|
+
} : {};
|
|
6003
6007
|
if (error instanceof import_nestjs_agent_core32.RunCancelledError) {
|
|
6004
|
-
await this.settleCancelled(runId, input, deps);
|
|
6008
|
+
await this.settleCancelled(runId, input, deps, durationMs);
|
|
6005
6009
|
return;
|
|
6006
6010
|
}
|
|
6007
6011
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -6009,12 +6013,16 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6009
6013
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
6010
6014
|
(0, import_nestjs_agent_core32.publishAgentRunFailed)({
|
|
6011
6015
|
runId,
|
|
6016
|
+
threadId: input.threadId,
|
|
6012
6017
|
code,
|
|
6013
|
-
message
|
|
6018
|
+
message,
|
|
6019
|
+
...timed,
|
|
6020
|
+
context: (0, import_nestjs_agent_core32.agentRunContext)(input)
|
|
6014
6021
|
});
|
|
6015
6022
|
await this.store.recordRunEnd?.({
|
|
6016
6023
|
runId,
|
|
6017
6024
|
status: "failed",
|
|
6025
|
+
...timed,
|
|
6018
6026
|
errorCode: code,
|
|
6019
6027
|
errorMessage: message
|
|
6020
6028
|
});
|
|
@@ -6086,8 +6094,17 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6086
6094
|
* the stream ENDED after a `cancelled` frame rather than failed, so a client that retries failed
|
|
6087
6095
|
* streams does not retry this one.
|
|
6088
6096
|
*/
|
|
6089
|
-
async settleCancelled(runId, input, deps) {
|
|
6097
|
+
async settleCancelled(runId, input, deps, durationMs) {
|
|
6090
6098
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
6099
|
+
const timed = durationMs !== void 0 ? {
|
|
6100
|
+
durationMs
|
|
6101
|
+
} : {};
|
|
6102
|
+
(0, import_nestjs_agent_core32.publishAgentRunCancelled)({
|
|
6103
|
+
runId,
|
|
6104
|
+
threadId: input.threadId,
|
|
6105
|
+
...timed,
|
|
6106
|
+
context: (0, import_nestjs_agent_core32.agentRunContext)(input)
|
|
6107
|
+
});
|
|
6091
6108
|
const writer = await deps.sink.open(runId);
|
|
6092
6109
|
await this.settleQueue(writer, input, runId, "cancelled");
|
|
6093
6110
|
await (0, import_nestjs_agent_core32.releaseThreadRun)(this.store, input.threadId, runId);
|
|
@@ -6097,7 +6114,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6097
6114
|
await writer.end();
|
|
6098
6115
|
await this.store.recordRunEnd?.({
|
|
6099
6116
|
runId,
|
|
6100
|
-
status: "cancelled"
|
|
6117
|
+
status: "cancelled",
|
|
6118
|
+
...timed
|
|
6101
6119
|
});
|
|
6102
6120
|
}
|
|
6103
6121
|
/**
|
|
@@ -6283,10 +6301,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6283
6301
|
}
|
|
6284
6302
|
}), "startAgent")
|
|
6285
6303
|
};
|
|
6286
|
-
|
|
6287
|
-
...deps,
|
|
6288
|
-
day
|
|
6289
|
-
}, {
|
|
6304
|
+
const childInput = {
|
|
6290
6305
|
threadId: subThread.id,
|
|
6291
6306
|
actor,
|
|
6292
6307
|
userText: task,
|
|
@@ -6296,13 +6311,29 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6296
6311
|
delegationPath: path,
|
|
6297
6312
|
parentRunId,
|
|
6298
6313
|
deliverTo
|
|
6299
|
-
}
|
|
6314
|
+
};
|
|
6315
|
+
void (0, import_nestjs_agent_core32.runAgentLoop)({
|
|
6316
|
+
...deps,
|
|
6317
|
+
day
|
|
6318
|
+
}, childInput, hooks).catch(async (error) => {
|
|
6300
6319
|
const cancelled = error instanceof import_nestjs_agent_core32.RunCancelledError;
|
|
6301
6320
|
const message = error instanceof Error ? error.message : String(error);
|
|
6302
|
-
|
|
6321
|
+
const durationMs = (0, import_nestjs_agent_core32.runDurationMs)(error);
|
|
6322
|
+
const timed = durationMs !== void 0 ? {
|
|
6323
|
+
durationMs
|
|
6324
|
+
} : {};
|
|
6325
|
+
const settled = {
|
|
6326
|
+
runId,
|
|
6327
|
+
threadId: subThread.id,
|
|
6328
|
+
...timed,
|
|
6329
|
+
context: (0, import_nestjs_agent_core32.agentRunContext)(childInput)
|
|
6330
|
+
};
|
|
6331
|
+
if (cancelled) {
|
|
6332
|
+
(0, import_nestjs_agent_core32.publishAgentRunCancelled)(settled);
|
|
6333
|
+
} else {
|
|
6303
6334
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
6304
6335
|
(0, import_nestjs_agent_core32.publishAgentRunFailed)({
|
|
6305
|
-
|
|
6336
|
+
...settled,
|
|
6306
6337
|
code: (0, import_nestjs_agent_core32.agentFailureCode)(error),
|
|
6307
6338
|
message
|
|
6308
6339
|
});
|
|
@@ -6310,6 +6341,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6310
6341
|
await this.store.recordRunEnd?.({
|
|
6311
6342
|
runId,
|
|
6312
6343
|
status: cancelled ? "cancelled" : "failed",
|
|
6344
|
+
...timed,
|
|
6313
6345
|
...cancelled ? {} : {
|
|
6314
6346
|
errorCode: (0, import_nestjs_agent_core32.agentFailureCode)(error),
|
|
6315
6347
|
errorMessage: message
|