@dudousxd/nestjs-agent 1.4.0 → 1.5.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 +18 -3
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +7 -0
- package/dist/durable/index.d.ts +7 -0
- package/dist/durable/index.js +23 -8
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/durable/index.cjs
CHANGED
|
@@ -143,8 +143,15 @@ var AgentRunSteps = class {
|
|
|
143
143
|
if (deps.registry.spec(input.toolName)?.kind === "action" && input.toolType !== "action") {
|
|
144
144
|
throw new Error(`tool "${input.toolName}" is an action tool but was dispatched without approval: the dispatching process resolved its kind against a registry that does not have it`);
|
|
145
145
|
}
|
|
146
|
+
const sinkRunId = input.sinkRunId;
|
|
147
|
+
let opened;
|
|
148
|
+
const ui = (0, import_nestjs_agent_core.createUiCollector)(input.toolCallId, sinkRunId === void 0 ? void 0 : async (event) => {
|
|
149
|
+
opened ??= Promise.resolve(deps.sink.open(sinkRunId)).then((writer) => input.childSink === true ? childSinkWriter(writer) : writer);
|
|
150
|
+
await (await opened).write((0, import_nestjs_agent_core.encodeStreamEvent)(event));
|
|
151
|
+
});
|
|
146
152
|
const ctx = {
|
|
147
|
-
...input.ctx
|
|
153
|
+
...input.ctx,
|
|
154
|
+
emitUi: ui.emit
|
|
148
155
|
};
|
|
149
156
|
const localClassify = deps.toolTransientRetry !== false ? deps.toolTransientRetry?.classify : void 0;
|
|
150
157
|
const transientRetry = input.transientRetry === false ? false : {
|
|
@@ -154,11 +161,12 @@ var AgentRunSteps = class {
|
|
|
154
161
|
classify: localClassify
|
|
155
162
|
} : {}
|
|
156
163
|
};
|
|
157
|
-
|
|
164
|
+
const output = await (0, import_nestjs_agent_core.traceToolExecution)(input.ctx.runId, {
|
|
158
165
|
toolCallId: input.toolCallId,
|
|
159
166
|
toolName: input.toolName,
|
|
160
167
|
toolType: input.toolType
|
|
161
168
|
}, () => (0, import_nestjs_agent_core.invokeWithTransientRetry)(() => {
|
|
169
|
+
ui.restart();
|
|
162
170
|
const invocation = deps.registry.invoke(input.toolName, input.input, ctx, deps.rolesPolicy);
|
|
163
171
|
return input.timeoutMs !== void 0 ? (0, import_nestjs_agent_core.withToolTimeout)(invocation, input.timeoutMs, input.toolName) : invocation;
|
|
164
172
|
}, transientRetry, {
|
|
@@ -171,6 +179,7 @@ var AgentRunSteps = class {
|
|
|
171
179
|
});
|
|
172
180
|
}, "onRetry")
|
|
173
181
|
}));
|
|
182
|
+
return input.collectUi === true ? (0, import_nestjs_agent_core.wrapToolStepOutput)(output, ui.components()) : output;
|
|
174
183
|
}
|
|
175
184
|
};
|
|
176
185
|
_ts_decorate([
|
|
@@ -414,7 +423,10 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
414
423
|
dispatchTool: /* @__PURE__ */ __name((call, envelope) => ctx.step(AgentRunSteps.prototype.tool, {
|
|
415
424
|
...envelope,
|
|
416
425
|
toolCallId: call.id,
|
|
417
|
-
toolType: call.kind === "action" ? "action" : "read"
|
|
426
|
+
toolType: call.kind === "action" ? "action" : "read",
|
|
427
|
+
// Where `ctx.emitUi` streams from the worker — the llm step's routing.
|
|
428
|
+
sinkRunId,
|
|
429
|
+
childSink: input.sinkRunId !== void 0
|
|
418
430
|
}), "dispatchTool")
|
|
419
431
|
} : {}
|
|
420
432
|
};
|
|
@@ -3146,6 +3158,9 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3146
3158
|
} : {},
|
|
3147
3159
|
...meta.presentation !== void 0 ? {
|
|
3148
3160
|
presentation: meta.presentation
|
|
3161
|
+
} : {},
|
|
3162
|
+
...meta.terminal === true ? {
|
|
3163
|
+
terminal: true
|
|
3149
3164
|
} : {}
|
|
3150
3165
|
}, {
|
|
3151
3166
|
execute: /* @__PURE__ */ __name((input, ctx) => instance.execute(input, ctx), "execute"),
|