@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.d.cts
CHANGED
|
@@ -5,7 +5,10 @@ import { WorkflowService } from '@dudousxd/nestjs-durable';
|
|
|
5
5
|
import { DynamicModule } from '@nestjs/common';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* The agent turn AS a durable workflow. Each model/tool call is a checkpointed `ctx.
|
|
8
|
+
* The agent turn AS a durable workflow. Each model/tool call is a checkpointed `ctx.localStep` — the
|
|
9
|
+
* in-process primitive, NOT the always-dispatched `ctx.step`: the loop's deps (model provider, store,
|
|
10
|
+
* sink) live in THIS workflow worker's DI, and the step names are dynamic checkpoint identities
|
|
11
|
+
* (`llm:0`, `persist:toolcall:<id>`), not routable worker groups. HITL is
|
|
9
12
|
* `ctx.waitForSignal`, and sub-agent delegation is `ctx.child(AgentRunWorkflow)` — a replay-safe,
|
|
10
13
|
* observable child run (it shows up as a node in the durable dashboard). A child streams into its
|
|
11
14
|
* top-level ancestor's sink (`sinkRunId`) so the human watching the parent sees it and can approve
|
package/dist/durable/index.d.ts
CHANGED
|
@@ -5,7 +5,10 @@ import { WorkflowService } from '@dudousxd/nestjs-durable';
|
|
|
5
5
|
import { DynamicModule } from '@nestjs/common';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* The agent turn AS a durable workflow. Each model/tool call is a checkpointed `ctx.
|
|
8
|
+
* The agent turn AS a durable workflow. Each model/tool call is a checkpointed `ctx.localStep` — the
|
|
9
|
+
* in-process primitive, NOT the always-dispatched `ctx.step`: the loop's deps (model provider, store,
|
|
10
|
+
* sink) live in THIS workflow worker's DI, and the step names are dynamic checkpoint identities
|
|
11
|
+
* (`llm:0`, `persist:toolcall:<id>`), not routable worker groups. HITL is
|
|
9
12
|
* `ctx.waitForSignal`, and sub-agent delegation is `ctx.child(AgentRunWorkflow)` — a replay-safe,
|
|
10
13
|
* observable child run (it shows up as a node in the durable dashboard). A child streams into its
|
|
11
14
|
* top-level ancestor's sink (`sinkRunId`) so the human watching the parent sees it and can approve
|
package/dist/durable/index.js
CHANGED
|
@@ -55,7 +55,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
55
55
|
const day = input.day ?? utcDay();
|
|
56
56
|
const deps = this.factory.forAgent(input.agentName);
|
|
57
57
|
if (input.sinkRunId !== void 0) {
|
|
58
|
-
await ctx.
|
|
58
|
+
await ctx.localStep("activate", () => this.store.setActiveStream(input.threadId, ctx.runId));
|
|
59
59
|
}
|
|
60
60
|
const sinkRunId = input.sinkRunId ?? ctx.runId;
|
|
61
61
|
const hooks = {
|
|
@@ -63,9 +63,9 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
63
63
|
// A child forwards into the top-level sink but must not end/fail it (the top-level run owns it).
|
|
64
64
|
openSink: /* @__PURE__ */ __name(async () => input.sinkRunId !== void 0 ? childSinkWriter(await deps.sink.open(sinkRunId)) : deps.sink.open(ctx.runId), "openSink"),
|
|
65
65
|
awaitApproval: /* @__PURE__ */ __name((call) => ctx.waitForSignal(`tool:${ctx.runId}:${call.id}`), "awaitApproval"),
|
|
66
|
-
step: /* @__PURE__ */ __name((name, fn) => ctx.
|
|
66
|
+
step: /* @__PURE__ */ __name((name, fn) => ctx.localStep(name, fn), "step"),
|
|
67
67
|
runAgent: /* @__PURE__ */ __name(async (agentName, task) => {
|
|
68
|
-
const subThreadId = await ctx.
|
|
68
|
+
const subThreadId = await ctx.localStep(`subthread:${agentName}`, async () => {
|
|
69
69
|
const thread = await this.store.createThread({
|
|
70
70
|
actor: input.actor,
|
|
71
71
|
transient: true
|
|
@@ -88,7 +88,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
88
88
|
...deps,
|
|
89
89
|
day
|
|
90
90
|
}, input, hooks);
|
|
91
|
-
await ctx.
|
|
91
|
+
await ctx.localStep("deactivate", () => this.store.setActiveStream(input.threadId, null));
|
|
92
92
|
return result;
|
|
93
93
|
} catch (error) {
|
|
94
94
|
if (error instanceof WorkflowSuspended || error instanceof ContinueAsNew) {
|
|
@@ -101,7 +101,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
101
101
|
code,
|
|
102
102
|
message
|
|
103
103
|
});
|
|
104
|
-
await ctx.
|
|
104
|
+
await ctx.localStep("deactivate", () => this.store.setActiveStream(input.threadId, null));
|
|
105
105
|
const writer = await hooks.openSink();
|
|
106
106
|
await writer.fail({
|
|
107
107
|
code,
|