@dudousxd/nestjs-agent 0.4.0 → 0.4.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.
package/dist/durable/index.cjs
CHANGED
|
@@ -82,7 +82,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
82
82
|
const day = input.day ?? utcDay();
|
|
83
83
|
const deps = this.factory.forAgent(input.agentName);
|
|
84
84
|
if (input.sinkRunId !== void 0) {
|
|
85
|
-
await ctx.
|
|
85
|
+
await ctx.localStep("activate", () => this.store.setActiveStream(input.threadId, ctx.runId));
|
|
86
86
|
}
|
|
87
87
|
const sinkRunId = input.sinkRunId ?? ctx.runId;
|
|
88
88
|
const hooks = {
|
|
@@ -90,9 +90,9 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
90
90
|
// A child forwards into the top-level sink but must not end/fail it (the top-level run owns it).
|
|
91
91
|
openSink: /* @__PURE__ */ __name(async () => input.sinkRunId !== void 0 ? childSinkWriter(await deps.sink.open(sinkRunId)) : deps.sink.open(ctx.runId), "openSink"),
|
|
92
92
|
awaitApproval: /* @__PURE__ */ __name((call) => ctx.waitForSignal(`tool:${ctx.runId}:${call.id}`), "awaitApproval"),
|
|
93
|
-
step: /* @__PURE__ */ __name((name, fn) => ctx.
|
|
93
|
+
step: /* @__PURE__ */ __name((name, fn) => ctx.localStep(name, fn), "step"),
|
|
94
94
|
runAgent: /* @__PURE__ */ __name(async (agentName, task) => {
|
|
95
|
-
const subThreadId = await ctx.
|
|
95
|
+
const subThreadId = await ctx.localStep(`subthread:${agentName}`, async () => {
|
|
96
96
|
const thread = await this.store.createThread({
|
|
97
97
|
actor: input.actor,
|
|
98
98
|
transient: true
|
|
@@ -115,7 +115,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
115
115
|
...deps,
|
|
116
116
|
day
|
|
117
117
|
}, input, hooks);
|
|
118
|
-
await ctx.
|
|
118
|
+
await ctx.localStep("deactivate", () => this.store.setActiveStream(input.threadId, null));
|
|
119
119
|
return result;
|
|
120
120
|
} catch (error) {
|
|
121
121
|
if (error instanceof import_nestjs_durable_core.WorkflowSuspended || error instanceof import_nestjs_durable_core.ContinueAsNew) {
|
|
@@ -128,7 +128,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
128
128
|
code,
|
|
129
129
|
message
|
|
130
130
|
});
|
|
131
|
-
await ctx.
|
|
131
|
+
await ctx.localStep("deactivate", () => this.store.setActiveStream(input.threadId, null));
|
|
132
132
|
const writer = await hooks.openSink();
|
|
133
133
|
await writer.fail({
|
|
134
134
|
code,
|