@dudousxd/nestjs-agent 0.7.0 → 0.8.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.
@@ -92,12 +92,12 @@ var AgentRunSteps = class {
92
92
  const tools = await deps.registry.definitionsFor(input.actor, deps.rolesPolicy, deps.toolAllowList);
93
93
  const opened = await deps.sink.open(input.sinkRunId);
94
94
  const writer = input.childSink ? childSinkWriter(opened) : opened;
95
- return deps.model.runTurn({
95
+ return (0, import_nestjs_agent_core.traceLlmTurn)(input.runId, input.step, () => deps.model.runTurn({
96
96
  system: input.system,
97
97
  messages: input.messages,
98
98
  tools,
99
99
  sink: writer
100
- });
100
+ }));
101
101
  }
102
102
  /**
103
103
  * No retries — a tool may not be idempotent (a bare `@Step()` carries none, unlike `llm` above).
@@ -109,8 +109,14 @@ var AgentRunSteps = class {
109
109
  const ctx = {
110
110
  ...input.ctx
111
111
  };
112
- const invocation = deps.registry.invoke(input.toolName, input.input, ctx, deps.rolesPolicy);
113
- return input.timeoutMs !== void 0 ? (0, import_nestjs_agent_core.withToolTimeout)(invocation, input.timeoutMs, input.toolName) : invocation;
112
+ return (0, import_nestjs_agent_core.traceToolExecution)(input.ctx.runId, {
113
+ toolCallId: input.toolCallId,
114
+ toolName: input.toolName,
115
+ toolType: input.toolType
116
+ }, () => {
117
+ const invocation = deps.registry.invoke(input.toolName, input.input, ctx, deps.rolesPolicy);
118
+ return input.timeoutMs !== void 0 ? (0, import_nestjs_agent_core.withToolTimeout)(invocation, input.timeoutMs, input.toolName) : invocation;
119
+ });
114
120
  }
115
121
  };
116
122
  _ts_decorate([
@@ -127,7 +133,7 @@ _ts_decorate([
127
133
  (0, import_nestjs_durable.Step)(),
128
134
  _ts_metadata("design:type", Function),
129
135
  _ts_metadata("design:paramtypes", [
130
- typeof ToolStepEnvelope === "undefined" ? Object : ToolStepEnvelope
136
+ typeof DispatchedToolInput === "undefined" ? Object : DispatchedToolInput
131
137
  ]),
132
138
  _ts_metadata("design:returntype", Promise)
133
139
  ], AgentRunSteps.prototype, "tool", null);
@@ -216,13 +222,23 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
216
222
  // execution. `sinkRunId`/`childSink` are sink routing this workflow already resolved above —
217
223
  // core's dispatchLlm signature stays sink-topology-agnostic, so we add them here, not in core.
218
224
  ...this.dispatchedSteps ? {
219
- dispatchLlm: /* @__PURE__ */ __name((_index, envelope) => ctx.step(this.steps.llm, {
225
+ dispatchLlm: /* @__PURE__ */ __name((index, envelope) => ctx.step(this.steps.llm, {
220
226
  ...envelope,
221
227
  runId: ctx.runId,
228
+ step: index,
222
229
  sinkRunId,
223
230
  childSink: input.sinkRunId !== void 0
224
231
  }), "dispatchLlm"),
225
- dispatchTool: /* @__PURE__ */ __name((_call, envelope) => ctx.step(this.steps.tool, envelope), "dispatchTool")
232
+ // Fold the call identity (`toolCallId`/`toolType`) into the wire payload — the handler
233
+ // emits the `tool.execution` span with it. Only read/action calls reach dispatchTool
234
+ // ('agent'-kind delegations branch to runAgent earlier in the loop), so anything that
235
+ // isn't 'action' is defensively 'read' — the same posture core takes for an
236
+ // unresolvable `kind`.
237
+ dispatchTool: /* @__PURE__ */ __name((call, envelope) => ctx.step(this.steps.tool, {
238
+ ...envelope,
239
+ toolCallId: call.id,
240
+ toolType: call.kind === "action" ? "action" : "read"
241
+ }), "dispatchTool")
226
242
  } : {}
227
243
  };
228
244
  try {