@dudousxd/nestjs-agent 0.4.0 → 0.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/{agent-deps.factory-BM_RB6br.d.cts → agent-deps.factory-DGM0IVtA.d.cts} +17 -0
- package/dist/{agent-deps.factory-BM_RB6br.d.ts → agent-deps.factory-DGM0IVtA.d.ts} +17 -0
- package/dist/durable/index.cjs +609 -452
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +70 -5
- package/dist/durable/index.d.ts +70 -5
- package/dist/durable/index.js +521 -366
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +14 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
package/dist/durable/index.cjs
CHANGED
|
@@ -21,7 +21,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/durable/index.ts
|
|
22
22
|
var durable_exports = {};
|
|
23
23
|
__export(durable_exports, {
|
|
24
|
+
AGENT_DISPATCHED_STEPS: () => AGENT_DISPATCHED_STEPS,
|
|
24
25
|
AgentDurableModule: () => AgentDurableModule,
|
|
26
|
+
AgentRunSteps: () => AgentRunSteps,
|
|
25
27
|
AgentRunWorkflow: () => AgentRunWorkflow,
|
|
26
28
|
DurableAgentRunner: () => DurableAgentRunner,
|
|
27
29
|
agentDurable: () => agentDurable
|
|
@@ -29,10 +31,10 @@ __export(durable_exports, {
|
|
|
29
31
|
module.exports = __toCommonJS(durable_exports);
|
|
30
32
|
|
|
31
33
|
// src/durable/agent-run.workflow.ts
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
+
var import_nestjs_agent_core2 = require("@dudousxd/nestjs-agent-core");
|
|
35
|
+
var import_nestjs_durable2 = require("@dudousxd/nestjs-durable");
|
|
34
36
|
var import_nestjs_durable_core = require("@dudousxd/nestjs-durable-core");
|
|
35
|
-
var
|
|
37
|
+
var import_common2 = require("@nestjs/common");
|
|
36
38
|
|
|
37
39
|
// src/agent-deps.ts
|
|
38
40
|
function utcDay(date = /* @__PURE__ */ new Date()) {
|
|
@@ -50,7 +52,10 @@ function childSinkWriter(writer) {
|
|
|
50
52
|
}
|
|
51
53
|
__name(childSinkWriter, "childSinkWriter");
|
|
52
54
|
|
|
53
|
-
// src/durable/agent-run.
|
|
55
|
+
// src/durable/agent-run.steps.ts
|
|
56
|
+
var import_nestjs_agent_core = require("@dudousxd/nestjs-agent-core");
|
|
57
|
+
var import_nestjs_durable = require("@dudousxd/nestjs-durable");
|
|
58
|
+
var import_common = require("@nestjs/common");
|
|
54
59
|
function _ts_decorate(decorators, target, key, desc) {
|
|
55
60
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
56
61
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -68,21 +73,113 @@ function _ts_param(paramIndex, decorator) {
|
|
|
68
73
|
};
|
|
69
74
|
}
|
|
70
75
|
__name(_ts_param, "_ts_param");
|
|
76
|
+
var AgentRunSteps = class {
|
|
77
|
+
static {
|
|
78
|
+
__name(this, "AgentRunSteps");
|
|
79
|
+
}
|
|
80
|
+
factory;
|
|
81
|
+
constructor(factory) {
|
|
82
|
+
this.factory = factory;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Retryable: every side effect (persist/quota/stream markers) happens loop-side under
|
|
86
|
+
* `hooks.step`, so a durable retry only re-runs the model call and re-streams its tokens — never
|
|
87
|
+
* double-writes. NEVER call `writer.end()`/`fail()` here: the workflow owns the stream's lifecycle,
|
|
88
|
+
* across however many turns/retries it takes.
|
|
89
|
+
*/
|
|
90
|
+
async llm(input) {
|
|
91
|
+
const deps = this.factory.forAgent(input.agentName);
|
|
92
|
+
const tools = await deps.registry.definitionsFor(input.actor, deps.rolesPolicy, deps.toolAllowList);
|
|
93
|
+
const opened = await deps.sink.open(input.sinkRunId);
|
|
94
|
+
const writer = input.childSink ? childSinkWriter(opened) : opened;
|
|
95
|
+
return deps.model.runTurn({
|
|
96
|
+
system: input.system,
|
|
97
|
+
messages: input.messages,
|
|
98
|
+
tools,
|
|
99
|
+
sink: writer
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* No retries — a tool may not be idempotent (a bare `@Step()` carries none, unlike `llm` above).
|
|
104
|
+
* The timeout is applied HERE, handler-side, via `withToolTimeout` — never as a durable dispatch
|
|
105
|
+
* `timeoutMs`, which bounds engine liveness (retryable) rather than the tool's own business outcome.
|
|
106
|
+
*/
|
|
107
|
+
async tool(input) {
|
|
108
|
+
const deps = this.factory.forAgent(input.ctx.agentName);
|
|
109
|
+
const ctx = {
|
|
110
|
+
...input.ctx
|
|
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;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
_ts_decorate([
|
|
117
|
+
(0, import_nestjs_durable.Step)({
|
|
118
|
+
retries: 3
|
|
119
|
+
}),
|
|
120
|
+
_ts_metadata("design:type", Function),
|
|
121
|
+
_ts_metadata("design:paramtypes", [
|
|
122
|
+
typeof DispatchedLlmInput === "undefined" ? Object : DispatchedLlmInput
|
|
123
|
+
]),
|
|
124
|
+
_ts_metadata("design:returntype", Promise)
|
|
125
|
+
], AgentRunSteps.prototype, "llm", null);
|
|
126
|
+
_ts_decorate([
|
|
127
|
+
(0, import_nestjs_durable.Step)(),
|
|
128
|
+
_ts_metadata("design:type", Function),
|
|
129
|
+
_ts_metadata("design:paramtypes", [
|
|
130
|
+
typeof ToolStepEnvelope === "undefined" ? Object : ToolStepEnvelope
|
|
131
|
+
]),
|
|
132
|
+
_ts_metadata("design:returntype", Promise)
|
|
133
|
+
], AgentRunSteps.prototype, "tool", null);
|
|
134
|
+
AgentRunSteps = _ts_decorate([
|
|
135
|
+
(0, import_common.Injectable)(),
|
|
136
|
+
_ts_param(0, (0, import_common.Inject)(import_nestjs_agent_core.AGENT_DEPS_FACTORY)),
|
|
137
|
+
_ts_metadata("design:type", Function),
|
|
138
|
+
_ts_metadata("design:paramtypes", [
|
|
139
|
+
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
140
|
+
])
|
|
141
|
+
], AgentRunSteps);
|
|
142
|
+
|
|
143
|
+
// src/durable/dispatched-steps.token.ts
|
|
144
|
+
var AGENT_DISPATCHED_STEPS = Symbol.for("@dudousxd/nestjs-agent:dispatched-steps");
|
|
145
|
+
|
|
146
|
+
// src/durable/agent-run.workflow.ts
|
|
147
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
148
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
149
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
150
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
151
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
152
|
+
}
|
|
153
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
154
|
+
function _ts_metadata2(k, v) {
|
|
155
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
156
|
+
}
|
|
157
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
158
|
+
function _ts_param2(paramIndex, decorator) {
|
|
159
|
+
return function(target, key) {
|
|
160
|
+
decorator(target, key, paramIndex);
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
__name(_ts_param2, "_ts_param");
|
|
71
164
|
var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
72
165
|
static {
|
|
73
166
|
__name(this, "AgentRunWorkflow");
|
|
74
167
|
}
|
|
75
168
|
factory;
|
|
76
169
|
store;
|
|
77
|
-
|
|
170
|
+
steps;
|
|
171
|
+
dispatchedSteps;
|
|
172
|
+
constructor(factory, store, steps, dispatchedSteps) {
|
|
78
173
|
this.factory = factory;
|
|
79
174
|
this.store = store;
|
|
175
|
+
this.steps = steps;
|
|
176
|
+
this.dispatchedSteps = dispatchedSteps;
|
|
80
177
|
}
|
|
81
178
|
async run(ctx, input) {
|
|
82
179
|
const day = input.day ?? utcDay();
|
|
83
180
|
const deps = this.factory.forAgent(input.agentName);
|
|
84
181
|
if (input.sinkRunId !== void 0) {
|
|
85
|
-
await ctx.
|
|
182
|
+
await ctx.localStep("activate", () => this.store.setActiveStream(input.threadId, ctx.runId));
|
|
86
183
|
}
|
|
87
184
|
const sinkRunId = input.sinkRunId ?? ctx.runId;
|
|
88
185
|
const hooks = {
|
|
@@ -90,9 +187,11 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
90
187
|
// A child forwards into the top-level sink but must not end/fail it (the top-level run owns it).
|
|
91
188
|
openSink: /* @__PURE__ */ __name(async () => input.sinkRunId !== void 0 ? childSinkWriter(await deps.sink.open(sinkRunId)) : deps.sink.open(ctx.runId), "openSink"),
|
|
92
189
|
awaitApproval: /* @__PURE__ */ __name((call) => ctx.waitForSignal(`tool:${ctx.runId}:${call.id}`), "awaitApproval"),
|
|
93
|
-
step: /* @__PURE__ */ __name((name, fn) => ctx.
|
|
190
|
+
step: /* @__PURE__ */ __name((name, fn) => ctx.localStep(name, fn), "step"),
|
|
191
|
+
// Dispatched-step suspends must escape the loop's tool catch — control flow, not a tool failure.
|
|
192
|
+
isControlFlowError: /* @__PURE__ */ __name((error) => error instanceof import_nestjs_durable_core.WorkflowSuspended || error instanceof import_nestjs_durable_core.ContinueAsNew, "isControlFlowError"),
|
|
94
193
|
runAgent: /* @__PURE__ */ __name(async (agentName, task) => {
|
|
95
|
-
const subThreadId = await ctx.
|
|
194
|
+
const subThreadId = await ctx.localStep(`subthread:${agentName}`, async () => {
|
|
96
195
|
const thread = await this.store.createThread({
|
|
97
196
|
actor: input.actor,
|
|
98
197
|
transient: true
|
|
@@ -108,27 +207,46 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
108
207
|
delegationDepth: (input.delegationDepth ?? 0) + 1,
|
|
109
208
|
sinkRunId
|
|
110
209
|
});
|
|
111
|
-
}, "runAgent")
|
|
210
|
+
}, "runAgent"),
|
|
211
|
+
// Routes the two long steps through AgentRunSteps as engine-dispatched `ctx.step`s instead of
|
|
212
|
+
// `ctx.localStep`s, so a turn isn't pinned to this workflow worker for the model call or a tool
|
|
213
|
+
// execution. `sinkRunId`/`childSink` are sink routing this workflow already resolved above —
|
|
214
|
+
// core's dispatchLlm signature stays sink-topology-agnostic, so we add them here, not in core.
|
|
215
|
+
...this.dispatchedSteps ? {
|
|
216
|
+
dispatchLlm: /* @__PURE__ */ __name((_index, envelope) => ctx.step(this.steps.llm, {
|
|
217
|
+
...envelope,
|
|
218
|
+
runId: ctx.runId,
|
|
219
|
+
sinkRunId,
|
|
220
|
+
childSink: input.sinkRunId !== void 0
|
|
221
|
+
}), "dispatchLlm"),
|
|
222
|
+
dispatchTool: /* @__PURE__ */ __name((_call, envelope) => ctx.step(this.steps.tool, envelope), "dispatchTool")
|
|
223
|
+
} : {}
|
|
112
224
|
};
|
|
113
225
|
try {
|
|
114
|
-
const result = await (0,
|
|
226
|
+
const result = await (0, import_nestjs_agent_core2.runAgentLoop)({
|
|
115
227
|
...deps,
|
|
116
228
|
day
|
|
117
229
|
}, input, hooks);
|
|
118
|
-
await ctx.
|
|
230
|
+
await ctx.localStep("deactivate", () => this.store.setActiveStream(input.threadId, null));
|
|
119
231
|
return result;
|
|
120
232
|
} catch (error) {
|
|
121
233
|
if (error instanceof import_nestjs_durable_core.WorkflowSuspended || error instanceof import_nestjs_durable_core.ContinueAsNew) {
|
|
122
234
|
throw error;
|
|
123
235
|
}
|
|
124
236
|
const message = error instanceof Error ? error.message : String(error);
|
|
125
|
-
const code = error instanceof
|
|
126
|
-
(0,
|
|
237
|
+
const code = error instanceof import_nestjs_agent_core2.QuotaExceededError ? "quota_exceeded" : "run_failed";
|
|
238
|
+
(0, import_nestjs_agent_core2.publishAgentRunFailed)({
|
|
127
239
|
runId: ctx.runId,
|
|
128
240
|
code,
|
|
129
241
|
message
|
|
130
242
|
});
|
|
131
|
-
await ctx.
|
|
243
|
+
await ctx.localStep("persist:run:fail", () => this.store.recordRunEnd?.({
|
|
244
|
+
runId: ctx.runId,
|
|
245
|
+
status: "failed",
|
|
246
|
+
errorCode: code,
|
|
247
|
+
errorMessage: message
|
|
248
|
+
}) ?? Promise.resolve());
|
|
249
|
+
await ctx.localStep("deactivate", () => this.store.setActiveStream(input.threadId, null));
|
|
132
250
|
const writer = await hooks.openSink();
|
|
133
251
|
await writer.fail({
|
|
134
252
|
code,
|
|
@@ -138,37 +256,40 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
138
256
|
}
|
|
139
257
|
}
|
|
140
258
|
};
|
|
141
|
-
AgentRunWorkflow =
|
|
142
|
-
(0,
|
|
143
|
-
(0,
|
|
259
|
+
AgentRunWorkflow = _ts_decorate2([
|
|
260
|
+
(0, import_common2.Injectable)(),
|
|
261
|
+
(0, import_nestjs_durable2.Workflow)({
|
|
144
262
|
name: "agent.run",
|
|
145
263
|
version: "1"
|
|
146
264
|
}),
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
265
|
+
_ts_param2(0, (0, import_common2.Inject)(import_nestjs_agent_core2.AGENT_DEPS_FACTORY)),
|
|
266
|
+
_ts_param2(1, (0, import_common2.Inject)(import_nestjs_agent_core2.AGENT_STORE)),
|
|
267
|
+
_ts_param2(3, (0, import_common2.Inject)(AGENT_DISPATCHED_STEPS)),
|
|
268
|
+
_ts_metadata2("design:type", Function),
|
|
269
|
+
_ts_metadata2("design:paramtypes", [
|
|
151
270
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
152
|
-
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
271
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
272
|
+
typeof AgentRunSteps === "undefined" ? Object : AgentRunSteps,
|
|
273
|
+
Boolean
|
|
153
274
|
])
|
|
154
275
|
], AgentRunWorkflow);
|
|
155
276
|
|
|
156
277
|
// src/durable/durable-agent-runner.ts
|
|
157
278
|
var import_node_crypto = require("crypto");
|
|
158
|
-
var
|
|
279
|
+
var import_nestjs_durable3 = require("@dudousxd/nestjs-durable");
|
|
159
280
|
var import_nestjs_durable_core2 = require("@dudousxd/nestjs-durable-core");
|
|
160
|
-
var
|
|
161
|
-
function
|
|
281
|
+
var import_common3 = require("@nestjs/common");
|
|
282
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
162
283
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
163
284
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
164
285
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
165
286
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
166
287
|
}
|
|
167
|
-
__name(
|
|
168
|
-
function
|
|
288
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
289
|
+
function _ts_metadata3(k, v) {
|
|
169
290
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
170
291
|
}
|
|
171
|
-
__name(
|
|
292
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
172
293
|
var DurableAgentRunner = class {
|
|
173
294
|
static {
|
|
174
295
|
__name(this, "DurableAgentRunner");
|
|
@@ -201,24 +322,95 @@ var DurableAgentRunner = class {
|
|
|
201
322
|
await Promise.resolve();
|
|
202
323
|
}
|
|
203
324
|
};
|
|
204
|
-
DurableAgentRunner =
|
|
205
|
-
(0,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
typeof
|
|
325
|
+
DurableAgentRunner = _ts_decorate3([
|
|
326
|
+
(0, import_common3.Injectable)(),
|
|
327
|
+
_ts_metadata3("design:type", Function),
|
|
328
|
+
_ts_metadata3("design:paramtypes", [
|
|
329
|
+
typeof import_nestjs_durable3.WorkflowService === "undefined" ? Object : import_nestjs_durable3.WorkflowService
|
|
209
330
|
])
|
|
210
331
|
], DurableAgentRunner);
|
|
211
332
|
|
|
212
333
|
// src/durable/agent-durable.module.ts
|
|
213
|
-
var
|
|
214
|
-
var
|
|
215
|
-
|
|
334
|
+
var import_nestjs_agent_core4 = require("@dudousxd/nestjs-agent-core");
|
|
335
|
+
var import_common4 = require("@nestjs/common");
|
|
336
|
+
|
|
337
|
+
// src/in-process-sink.ts
|
|
338
|
+
var import_nestjs_agent_core3 = require("@dudousxd/nestjs-agent-core");
|
|
339
|
+
var InProcessTokenStreamSink = class {
|
|
340
|
+
static {
|
|
341
|
+
__name(this, "InProcessTokenStreamSink");
|
|
342
|
+
}
|
|
343
|
+
runs = /* @__PURE__ */ new Map();
|
|
344
|
+
buffer(runId) {
|
|
345
|
+
let buf = this.runs.get(runId);
|
|
346
|
+
if (buf === void 0) {
|
|
347
|
+
buf = {
|
|
348
|
+
chunks: [],
|
|
349
|
+
ended: false,
|
|
350
|
+
notify: /* @__PURE__ */ new Set()
|
|
351
|
+
};
|
|
352
|
+
this.runs.set(runId, buf);
|
|
353
|
+
}
|
|
354
|
+
return buf;
|
|
355
|
+
}
|
|
356
|
+
wake(buf) {
|
|
357
|
+
for (const resolve of buf.notify) {
|
|
358
|
+
resolve();
|
|
359
|
+
}
|
|
360
|
+
buf.notify.clear();
|
|
361
|
+
}
|
|
362
|
+
open(runId) {
|
|
363
|
+
const buf = this.buffer(runId);
|
|
364
|
+
return {
|
|
365
|
+
write: /* @__PURE__ */ __name((chunk) => {
|
|
366
|
+
buf.chunks.push(chunk);
|
|
367
|
+
this.wake(buf);
|
|
368
|
+
}, "write"),
|
|
369
|
+
end: /* @__PURE__ */ __name(() => {
|
|
370
|
+
buf.ended = true;
|
|
371
|
+
this.wake(buf);
|
|
372
|
+
}, "end"),
|
|
373
|
+
fail: /* @__PURE__ */ __name((error) => {
|
|
374
|
+
buf.failure = error;
|
|
375
|
+
buf.ended = true;
|
|
376
|
+
this.wake(buf);
|
|
377
|
+
}, "fail")
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
async *subscribe(runId) {
|
|
381
|
+
const buf = this.buffer(runId);
|
|
382
|
+
let index = 0;
|
|
383
|
+
while (true) {
|
|
384
|
+
while (index < buf.chunks.length) {
|
|
385
|
+
const chunk = buf.chunks[index];
|
|
386
|
+
index += 1;
|
|
387
|
+
if (chunk !== void 0) {
|
|
388
|
+
yield chunk;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (buf.ended) {
|
|
392
|
+
if (buf.failure !== void 0) {
|
|
393
|
+
throw new import_nestjs_agent_core3.AgentStreamError(buf.failure);
|
|
394
|
+
}
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
await new Promise((resolve) => buf.notify.add(resolve));
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
close(runId) {
|
|
401
|
+
this.runs.delete(runId);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
// src/durable/agent-durable.module.ts
|
|
406
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
216
407
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
217
408
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
218
409
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
219
410
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
220
411
|
}
|
|
221
|
-
__name(
|
|
412
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
413
|
+
var logger = new import_common4.Logger("AgentDurableModule");
|
|
222
414
|
var AgentDurableModule = class _AgentDurableModule {
|
|
223
415
|
static {
|
|
224
416
|
__name(this, "AgentDurableModule");
|
|
@@ -235,50 +427,67 @@ var AgentDurableModule = class _AgentDurableModule {
|
|
|
235
427
|
};
|
|
236
428
|
}
|
|
237
429
|
};
|
|
238
|
-
AgentDurableModule =
|
|
239
|
-
(0,
|
|
240
|
-
(0,
|
|
430
|
+
AgentDurableModule = _ts_decorate4([
|
|
431
|
+
(0, import_common4.Global)(),
|
|
432
|
+
(0, import_common4.Module)({
|
|
241
433
|
providers: [
|
|
242
434
|
AgentRunWorkflow,
|
|
435
|
+
AgentRunSteps,
|
|
243
436
|
DurableAgentRunner,
|
|
244
437
|
{
|
|
245
|
-
provide:
|
|
438
|
+
provide: import_nestjs_agent_core4.AGENT_DURABLE_RUNNER,
|
|
246
439
|
useExisting: DurableAgentRunner
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
provide: AGENT_DISPATCHED_STEPS,
|
|
443
|
+
useFactory: /* @__PURE__ */ __name((options, sink) => {
|
|
444
|
+
const enabled = options.dispatchedSteps ?? false;
|
|
445
|
+
if (enabled && sink instanceof InProcessTokenStreamSink) {
|
|
446
|
+
logger.warn("dispatchedSteps is enabled with the default InProcessTokenStreamSink, which only buffers tokens in-process. A dispatched `llm` step served by a different worker cannot stream into this buffer. Wire a cross-process TokenStreamSink (e.g. a Redis pub/sub sink) via AgentModule.forRoot({ sink }) before running multi-pod.");
|
|
447
|
+
}
|
|
448
|
+
return enabled;
|
|
449
|
+
}, "useFactory"),
|
|
450
|
+
inject: [
|
|
451
|
+
import_nestjs_agent_core4.AGENT_OPTIONS,
|
|
452
|
+
import_nestjs_agent_core4.AGENT_SINK
|
|
453
|
+
]
|
|
247
454
|
}
|
|
248
455
|
],
|
|
249
456
|
exports: [
|
|
250
|
-
|
|
251
|
-
AgentRunWorkflow
|
|
457
|
+
import_nestjs_agent_core4.AGENT_DURABLE_RUNNER,
|
|
458
|
+
AgentRunWorkflow,
|
|
459
|
+
AgentRunSteps,
|
|
460
|
+
AGENT_DISPATCHED_STEPS
|
|
252
461
|
]
|
|
253
462
|
})
|
|
254
463
|
], AgentDurableModule);
|
|
255
464
|
|
|
256
465
|
// src/agent.module.ts
|
|
257
|
-
var
|
|
258
|
-
var
|
|
466
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
467
|
+
var import_common16 = require("@nestjs/common");
|
|
259
468
|
var import_core3 = require("@nestjs/core");
|
|
260
469
|
|
|
261
470
|
// src/agent-deps.factory.ts
|
|
262
|
-
var
|
|
263
|
-
var
|
|
264
|
-
var
|
|
265
|
-
function
|
|
471
|
+
var import_nestjs_agent_core5 = require("@dudousxd/nestjs-agent-core");
|
|
472
|
+
var import_nestjs_agent_core6 = require("@dudousxd/nestjs-agent-core");
|
|
473
|
+
var import_common5 = require("@nestjs/common");
|
|
474
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
266
475
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
267
476
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
268
477
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
269
478
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
270
479
|
}
|
|
271
|
-
__name(
|
|
272
|
-
function
|
|
480
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
481
|
+
function _ts_metadata4(k, v) {
|
|
273
482
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
274
483
|
}
|
|
275
|
-
__name(
|
|
276
|
-
function
|
|
484
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
485
|
+
function _ts_param3(paramIndex, decorator) {
|
|
277
486
|
return function(target, key) {
|
|
278
487
|
decorator(target, key, paramIndex);
|
|
279
488
|
};
|
|
280
489
|
}
|
|
281
|
-
__name(
|
|
490
|
+
__name(_ts_param3, "_ts_param");
|
|
282
491
|
function delegateToolName(target) {
|
|
283
492
|
return `ask_${target.replace(/[^a-zA-Z0-9]+/g, "_")}`;
|
|
284
493
|
}
|
|
@@ -386,28 +595,28 @@ var AgentDepsFactory2 = class {
|
|
|
386
595
|
return void 0;
|
|
387
596
|
}
|
|
388
597
|
};
|
|
389
|
-
AgentDepsFactory2 =
|
|
390
|
-
(0,
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
598
|
+
AgentDepsFactory2 = _ts_decorate5([
|
|
599
|
+
(0, import_common5.Injectable)(),
|
|
600
|
+
_ts_param3(0, (0, import_common5.Inject)(import_nestjs_agent_core6.AGENT_OPTIONS)),
|
|
601
|
+
_ts_param3(1, (0, import_common5.Inject)(import_nestjs_agent_core5.AGENT_MODEL)),
|
|
602
|
+
_ts_param3(2, (0, import_common5.Inject)(import_nestjs_agent_core5.AGENT_STORE)),
|
|
603
|
+
_ts_param3(3, (0, import_common5.Inject)(import_nestjs_agent_core5.AGENT_SINK)),
|
|
604
|
+
_ts_param3(4, (0, import_common5.Inject)(import_nestjs_agent_core5.AGENT_ROLES_POLICY)),
|
|
605
|
+
_ts_param3(5, (0, import_common5.Inject)(import_nestjs_agent_core5.AGENT_TOOL_REGISTRY)),
|
|
606
|
+
_ts_param3(6, (0, import_common5.Inject)(import_nestjs_agent_core5.AGENT_REGISTRY)),
|
|
607
|
+
_ts_param3(7, (0, import_common5.Inject)(import_nestjs_agent_core5.AGENT_PROMPT_CONTRIBUTORS)),
|
|
608
|
+
_ts_param3(8, (0, import_common5.Inject)(import_nestjs_agent_core5.AGENT_QUOTA_STORE)),
|
|
609
|
+
_ts_param3(9, (0, import_common5.Optional)()),
|
|
610
|
+
_ts_param3(9, (0, import_common5.Inject)(import_nestjs_agent_core5.AGENT_PRICING_STORE)),
|
|
611
|
+
_ts_metadata4("design:type", Function),
|
|
612
|
+
_ts_metadata4("design:paramtypes", [
|
|
404
613
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
405
614
|
typeof ModelProvider === "undefined" ? Object : ModelProvider,
|
|
406
615
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
407
616
|
typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
|
|
408
617
|
typeof RolesPolicy === "undefined" ? Object : RolesPolicy,
|
|
409
|
-
typeof
|
|
410
|
-
typeof
|
|
618
|
+
typeof import_nestjs_agent_core5.ToolRegistry === "undefined" ? Object : import_nestjs_agent_core5.ToolRegistry,
|
|
619
|
+
typeof import_nestjs_agent_core5.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core5.AgentRegistry,
|
|
411
620
|
Array,
|
|
412
621
|
Object,
|
|
413
622
|
Object
|
|
@@ -415,25 +624,25 @@ AgentDepsFactory2 = _ts_decorate4([
|
|
|
415
624
|
], AgentDepsFactory2);
|
|
416
625
|
|
|
417
626
|
// src/agent.service.ts
|
|
418
|
-
var
|
|
419
|
-
var
|
|
420
|
-
function
|
|
627
|
+
var import_nestjs_agent_core7 = require("@dudousxd/nestjs-agent-core");
|
|
628
|
+
var import_common6 = require("@nestjs/common");
|
|
629
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
421
630
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
422
631
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
423
632
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
424
633
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
425
634
|
}
|
|
426
|
-
__name(
|
|
427
|
-
function
|
|
635
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
636
|
+
function _ts_metadata5(k, v) {
|
|
428
637
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
429
638
|
}
|
|
430
|
-
__name(
|
|
431
|
-
function
|
|
639
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
640
|
+
function _ts_param4(paramIndex, decorator) {
|
|
432
641
|
return function(target, key) {
|
|
433
642
|
decorator(target, key, paramIndex);
|
|
434
643
|
};
|
|
435
644
|
}
|
|
436
|
-
__name(
|
|
645
|
+
__name(_ts_param4, "_ts_param");
|
|
437
646
|
var AgentService = class {
|
|
438
647
|
static {
|
|
439
648
|
__name(this, "AgentService");
|
|
@@ -453,7 +662,7 @@ var AgentService = class {
|
|
|
453
662
|
let threadId = params.threadId;
|
|
454
663
|
if (threadId === void 0) {
|
|
455
664
|
if (params.regenerate === true) {
|
|
456
|
-
throw new
|
|
665
|
+
throw new import_common6.BadRequestException("regenerate requires an existing threadId");
|
|
457
666
|
}
|
|
458
667
|
const created = await this.store.createThread({
|
|
459
668
|
actor: params.actor,
|
|
@@ -549,7 +758,7 @@ var AgentService = class {
|
|
|
549
758
|
return;
|
|
550
759
|
}
|
|
551
760
|
if (this.store.updateThread === void 0) {
|
|
552
|
-
throw new
|
|
761
|
+
throw new import_common6.NotImplementedException("Setting a thread's defaultAgent requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
553
762
|
}
|
|
554
763
|
await this.store.updateThread(threadId, {
|
|
555
764
|
...title !== void 0 ? {
|
|
@@ -561,10 +770,10 @@ var AgentService = class {
|
|
|
561
770
|
validateTitle(title) {
|
|
562
771
|
const trimmed = title.trim();
|
|
563
772
|
if (trimmed.length === 0) {
|
|
564
|
-
throw new
|
|
773
|
+
throw new import_common6.BadRequestException("title must not be empty");
|
|
565
774
|
}
|
|
566
775
|
if (trimmed.length > 200) {
|
|
567
|
-
throw new
|
|
776
|
+
throw new import_common6.BadRequestException("title must be at most 200 characters");
|
|
568
777
|
}
|
|
569
778
|
return trimmed;
|
|
570
779
|
}
|
|
@@ -646,10 +855,10 @@ var AgentService = class {
|
|
|
646
855
|
async assertOwnsThread(actor, threadId) {
|
|
647
856
|
const owner = await this.store.ownerOfThread(threadId);
|
|
648
857
|
if (owner === null) {
|
|
649
|
-
throw new
|
|
858
|
+
throw new import_common6.NotFoundException(`thread ${threadId} not found`);
|
|
650
859
|
}
|
|
651
860
|
if (owner !== actor.id) {
|
|
652
|
-
throw new
|
|
861
|
+
throw new import_common6.ForbiddenException("thread belongs to another actor");
|
|
653
862
|
}
|
|
654
863
|
}
|
|
655
864
|
/**
|
|
@@ -661,14 +870,14 @@ var AgentService = class {
|
|
|
661
870
|
async runForOwnedToolCall(actor, toolCallId) {
|
|
662
871
|
const owner = await this.store.ownerOfToolCall(toolCallId);
|
|
663
872
|
if (owner === null) {
|
|
664
|
-
throw new
|
|
873
|
+
throw new import_common6.NotFoundException(`tool call ${toolCallId} not found`);
|
|
665
874
|
}
|
|
666
875
|
if (owner !== actor.id) {
|
|
667
|
-
throw new
|
|
876
|
+
throw new import_common6.ForbiddenException("tool call belongs to another actor");
|
|
668
877
|
}
|
|
669
878
|
const runId = await this.store.runForToolCall(toolCallId);
|
|
670
879
|
if (runId === null) {
|
|
671
|
-
throw new
|
|
880
|
+
throw new import_common6.NotFoundException(`tool call ${toolCallId} has no active run to signal`);
|
|
672
881
|
}
|
|
673
882
|
return runId;
|
|
674
883
|
}
|
|
@@ -676,21 +885,21 @@ var AgentService = class {
|
|
|
676
885
|
async assertOwnsActiveStream(actor, runId) {
|
|
677
886
|
const owner = await this.store.ownerOfActiveStream(runId);
|
|
678
887
|
if (owner === null) {
|
|
679
|
-
throw new
|
|
888
|
+
throw new import_common6.NotFoundException(`no active run ${runId}`);
|
|
680
889
|
}
|
|
681
890
|
if (owner !== actor.id) {
|
|
682
|
-
throw new
|
|
891
|
+
throw new import_common6.ForbiddenException("run belongs to another actor");
|
|
683
892
|
}
|
|
684
893
|
}
|
|
685
894
|
};
|
|
686
|
-
AgentService =
|
|
687
|
-
(0,
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
895
|
+
AgentService = _ts_decorate6([
|
|
896
|
+
(0, import_common6.Injectable)(),
|
|
897
|
+
_ts_param4(0, (0, import_common6.Inject)(import_nestjs_agent_core7.AGENT_RUNNER)),
|
|
898
|
+
_ts_param4(1, (0, import_common6.Inject)(import_nestjs_agent_core7.AGENT_STORE)),
|
|
899
|
+
_ts_param4(2, (0, import_common6.Inject)(import_nestjs_agent_core7.AGENT_DEPS_FACTORY)),
|
|
900
|
+
_ts_param4(3, (0, import_common6.Inject)(import_nestjs_agent_core7.AGENT_QUOTA_STORE)),
|
|
901
|
+
_ts_metadata5("design:type", Function),
|
|
902
|
+
_ts_metadata5("design:paramtypes", [
|
|
694
903
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
695
904
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
696
905
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
@@ -699,25 +908,25 @@ AgentService = _ts_decorate5([
|
|
|
699
908
|
], AgentService);
|
|
700
909
|
|
|
701
910
|
// src/controller/agents.controller.ts
|
|
702
|
-
var
|
|
703
|
-
var
|
|
704
|
-
function
|
|
911
|
+
var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
912
|
+
var import_common7 = require("@nestjs/common");
|
|
913
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
705
914
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
706
915
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
707
916
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
708
917
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
709
918
|
}
|
|
710
|
-
__name(
|
|
711
|
-
function
|
|
919
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
920
|
+
function _ts_metadata6(k, v) {
|
|
712
921
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
713
922
|
}
|
|
714
|
-
__name(
|
|
715
|
-
function
|
|
923
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
924
|
+
function _ts_param5(paramIndex, decorator) {
|
|
716
925
|
return function(target, key) {
|
|
717
926
|
decorator(target, key, paramIndex);
|
|
718
927
|
};
|
|
719
928
|
}
|
|
720
|
-
__name(
|
|
929
|
+
__name(_ts_param5, "_ts_param");
|
|
721
930
|
var AgentsController = class {
|
|
722
931
|
static {
|
|
723
932
|
__name(this, "AgentsController");
|
|
@@ -739,44 +948,44 @@ var AgentsController = class {
|
|
|
739
948
|
}));
|
|
740
949
|
}
|
|
741
950
|
};
|
|
742
|
-
|
|
743
|
-
(0,
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
951
|
+
_ts_decorate7([
|
|
952
|
+
(0, import_common7.Get)(),
|
|
953
|
+
_ts_metadata6("design:type", Function),
|
|
954
|
+
_ts_metadata6("design:paramtypes", []),
|
|
955
|
+
_ts_metadata6("design:returntype", Array)
|
|
747
956
|
], AgentsController.prototype, "list", null);
|
|
748
|
-
AgentsController =
|
|
749
|
-
(0,
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
typeof
|
|
957
|
+
AgentsController = _ts_decorate7([
|
|
958
|
+
(0, import_common7.Controller)("agents"),
|
|
959
|
+
_ts_param5(0, (0, import_common7.Inject)(import_nestjs_agent_core8.AGENT_REGISTRY)),
|
|
960
|
+
_ts_param5(1, (0, import_common7.Inject)(import_nestjs_agent_core8.AGENT_DEPS_FACTORY)),
|
|
961
|
+
_ts_metadata6("design:type", Function),
|
|
962
|
+
_ts_metadata6("design:paramtypes", [
|
|
963
|
+
typeof import_nestjs_agent_core8.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core8.AgentRegistry,
|
|
755
964
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
756
965
|
])
|
|
757
966
|
], AgentsController);
|
|
758
967
|
|
|
759
968
|
// src/controller/attachments.controller.ts
|
|
760
|
-
var
|
|
761
|
-
var
|
|
969
|
+
var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
|
|
970
|
+
var import_common8 = require("@nestjs/common");
|
|
762
971
|
var import_platform_express = require("@nestjs/platform-express");
|
|
763
|
-
function
|
|
972
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
764
973
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
765
974
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
766
975
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
767
976
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
768
977
|
}
|
|
769
|
-
__name(
|
|
770
|
-
function
|
|
978
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
979
|
+
function _ts_metadata7(k, v) {
|
|
771
980
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
772
981
|
}
|
|
773
|
-
__name(
|
|
774
|
-
function
|
|
982
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
983
|
+
function _ts_param6(paramIndex, decorator) {
|
|
775
984
|
return function(target, key) {
|
|
776
985
|
decorator(target, key, paramIndex);
|
|
777
986
|
};
|
|
778
987
|
}
|
|
779
|
-
__name(
|
|
988
|
+
__name(_ts_param6, "_ts_param");
|
|
780
989
|
var DEFAULT_MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
|
|
781
990
|
var DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES = [
|
|
782
991
|
"image/png",
|
|
@@ -812,18 +1021,18 @@ var AttachmentsController = class {
|
|
|
812
1021
|
}
|
|
813
1022
|
async upload(req, file) {
|
|
814
1023
|
if (this.staging === void 0) {
|
|
815
|
-
throw new
|
|
1024
|
+
throw new import_common8.NotImplementedException("Attachment upload is not configured on this server.");
|
|
816
1025
|
}
|
|
817
1026
|
if (file === void 0) {
|
|
818
|
-
throw new
|
|
1027
|
+
throw new import_common8.BadRequestException('multipart field "file" is required');
|
|
819
1028
|
}
|
|
820
1029
|
const allowedContentTypes = this.options.attachments?.allowedContentTypes ?? DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES;
|
|
821
1030
|
if (!allowedContentTypes.includes(file.mimetype)) {
|
|
822
|
-
throw new
|
|
1031
|
+
throw new import_common8.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
|
|
823
1032
|
}
|
|
824
1033
|
const maxBytes = this.options.attachments?.maxBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES;
|
|
825
1034
|
if (file.size > maxBytes) {
|
|
826
|
-
throw new
|
|
1035
|
+
throw new import_common8.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
|
|
827
1036
|
}
|
|
828
1037
|
const actor = await this.actorResolver.resolve(req);
|
|
829
1038
|
return this.staging.stage({
|
|
@@ -835,26 +1044,26 @@ var AttachmentsController = class {
|
|
|
835
1044
|
});
|
|
836
1045
|
}
|
|
837
1046
|
};
|
|
838
|
-
|
|
839
|
-
(0,
|
|
840
|
-
(0,
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
1047
|
+
_ts_decorate8([
|
|
1048
|
+
(0, import_common8.Post)(),
|
|
1049
|
+
(0, import_common8.UseInterceptors)((0, import_platform_express.FileInterceptor)("file")),
|
|
1050
|
+
_ts_param6(0, (0, import_common8.Req)()),
|
|
1051
|
+
_ts_param6(1, (0, import_common8.UploadedFile)()),
|
|
1052
|
+
_ts_metadata7("design:type", Function),
|
|
1053
|
+
_ts_metadata7("design:paramtypes", [
|
|
845
1054
|
typeof Request === "undefined" ? Object : Request,
|
|
846
1055
|
Object
|
|
847
1056
|
]),
|
|
848
|
-
|
|
1057
|
+
_ts_metadata7("design:returntype", Promise)
|
|
849
1058
|
], AttachmentsController.prototype, "upload", null);
|
|
850
|
-
AttachmentsController =
|
|
851
|
-
(0,
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
1059
|
+
AttachmentsController = _ts_decorate8([
|
|
1060
|
+
(0, import_common8.Controller)("attachments"),
|
|
1061
|
+
_ts_param6(0, (0, import_common8.Inject)(import_nestjs_agent_core9.AGENT_OPTIONS)),
|
|
1062
|
+
_ts_param6(1, (0, import_common8.Inject)(import_nestjs_agent_core9.AGENT_ACTOR_RESOLVER)),
|
|
1063
|
+
_ts_param6(2, (0, import_common8.Optional)()),
|
|
1064
|
+
_ts_param6(2, (0, import_common8.Inject)(import_nestjs_agent_core9.AGENT_ATTACHMENT_STAGING)),
|
|
1065
|
+
_ts_metadata7("design:type", Function),
|
|
1066
|
+
_ts_metadata7("design:paramtypes", [
|
|
858
1067
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
859
1068
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
860
1069
|
Object
|
|
@@ -862,25 +1071,25 @@ AttachmentsController = _ts_decorate7([
|
|
|
862
1071
|
], AttachmentsController);
|
|
863
1072
|
|
|
864
1073
|
// src/controller/chat.controller.ts
|
|
865
|
-
var
|
|
866
|
-
var
|
|
867
|
-
function
|
|
1074
|
+
var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
|
|
1075
|
+
var import_common9 = require("@nestjs/common");
|
|
1076
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
868
1077
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
869
1078
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
870
1079
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
871
1080
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
872
1081
|
}
|
|
873
|
-
__name(
|
|
874
|
-
function
|
|
1082
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1083
|
+
function _ts_metadata8(k, v) {
|
|
875
1084
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
876
1085
|
}
|
|
877
|
-
__name(
|
|
878
|
-
function
|
|
1086
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
1087
|
+
function _ts_param7(paramIndex, decorator) {
|
|
879
1088
|
return function(target, key) {
|
|
880
1089
|
decorator(target, key, paramIndex);
|
|
881
1090
|
};
|
|
882
1091
|
}
|
|
883
|
-
__name(
|
|
1092
|
+
__name(_ts_param7, "_ts_param");
|
|
884
1093
|
var ChatController = class {
|
|
885
1094
|
static {
|
|
886
1095
|
__name(this, "ChatController");
|
|
@@ -968,7 +1177,7 @@ data: ${JSON.stringify({
|
|
|
968
1177
|
}
|
|
969
1178
|
res.write("event: done\ndata: {}\n\n");
|
|
970
1179
|
} catch (error) {
|
|
971
|
-
const payload = error instanceof
|
|
1180
|
+
const payload = error instanceof import_nestjs_agent_core10.AgentStreamError ? {
|
|
972
1181
|
code: error.code,
|
|
973
1182
|
message: error.message
|
|
974
1183
|
} : {
|
|
@@ -983,71 +1192,71 @@ data: ${JSON.stringify(payload)}
|
|
|
983
1192
|
res.end();
|
|
984
1193
|
}
|
|
985
1194
|
};
|
|
986
|
-
|
|
987
|
-
(0,
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1195
|
+
_ts_decorate9([
|
|
1196
|
+
(0, import_common9.Post)("chat"),
|
|
1197
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
1198
|
+
_ts_param7(1, (0, import_common9.Res)()),
|
|
1199
|
+
_ts_param7(2, (0, import_common9.Body)()),
|
|
1200
|
+
_ts_metadata8("design:type", Function),
|
|
1201
|
+
_ts_metadata8("design:paramtypes", [
|
|
993
1202
|
typeof Request === "undefined" ? Object : Request,
|
|
994
1203
|
typeof Response === "undefined" ? Object : Response,
|
|
995
1204
|
typeof ChatBody === "undefined" ? Object : ChatBody
|
|
996
1205
|
]),
|
|
997
|
-
|
|
1206
|
+
_ts_metadata8("design:returntype", Promise)
|
|
998
1207
|
], ChatController.prototype, "chat", null);
|
|
999
|
-
|
|
1000
|
-
(0,
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1208
|
+
_ts_decorate9([
|
|
1209
|
+
(0, import_common9.Get)("chat/:runId/stream"),
|
|
1210
|
+
_ts_param7(0, (0, import_common9.Param)("runId")),
|
|
1211
|
+
_ts_param7(1, (0, import_common9.Res)()),
|
|
1212
|
+
_ts_metadata8("design:type", Function),
|
|
1213
|
+
_ts_metadata8("design:paramtypes", [
|
|
1005
1214
|
String,
|
|
1006
1215
|
typeof Response === "undefined" ? Object : Response
|
|
1007
1216
|
]),
|
|
1008
|
-
|
|
1217
|
+
_ts_metadata8("design:returntype", Promise)
|
|
1009
1218
|
], ChatController.prototype, "stream", null);
|
|
1010
|
-
|
|
1011
|
-
(0,
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1219
|
+
_ts_decorate9([
|
|
1220
|
+
(0, import_common9.Post)("chat/:runId/cancel"),
|
|
1221
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
1222
|
+
_ts_param7(1, (0, import_common9.Param)("runId")),
|
|
1223
|
+
_ts_metadata8("design:type", Function),
|
|
1224
|
+
_ts_metadata8("design:paramtypes", [
|
|
1016
1225
|
typeof Request === "undefined" ? Object : Request,
|
|
1017
1226
|
String
|
|
1018
1227
|
]),
|
|
1019
|
-
|
|
1228
|
+
_ts_metadata8("design:returntype", Promise)
|
|
1020
1229
|
], ChatController.prototype, "cancel", null);
|
|
1021
|
-
ChatController =
|
|
1022
|
-
(0,
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1230
|
+
ChatController = _ts_decorate9([
|
|
1231
|
+
(0, import_common9.Controller)(),
|
|
1232
|
+
_ts_param7(1, (0, import_common9.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
|
|
1233
|
+
_ts_metadata8("design:type", Function),
|
|
1234
|
+
_ts_metadata8("design:paramtypes", [
|
|
1026
1235
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1027
1236
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1028
1237
|
])
|
|
1029
1238
|
], ChatController);
|
|
1030
1239
|
|
|
1031
1240
|
// src/controller/quota.controller.ts
|
|
1032
|
-
var
|
|
1033
|
-
var
|
|
1034
|
-
function
|
|
1241
|
+
var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
|
|
1242
|
+
var import_common10 = require("@nestjs/common");
|
|
1243
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
1035
1244
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1036
1245
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1037
1246
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1038
1247
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1039
1248
|
}
|
|
1040
|
-
__name(
|
|
1041
|
-
function
|
|
1249
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1250
|
+
function _ts_metadata9(k, v) {
|
|
1042
1251
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1043
1252
|
}
|
|
1044
|
-
__name(
|
|
1045
|
-
function
|
|
1253
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
1254
|
+
function _ts_param8(paramIndex, decorator) {
|
|
1046
1255
|
return function(target, key) {
|
|
1047
1256
|
decorator(target, key, paramIndex);
|
|
1048
1257
|
};
|
|
1049
1258
|
}
|
|
1050
|
-
__name(
|
|
1259
|
+
__name(_ts_param8, "_ts_param");
|
|
1051
1260
|
var QuotaController = class {
|
|
1052
1261
|
static {
|
|
1053
1262
|
__name(this, "QuotaController");
|
|
@@ -1063,45 +1272,45 @@ var QuotaController = class {
|
|
|
1063
1272
|
return this.agent.quotaToday(actor.id);
|
|
1064
1273
|
}
|
|
1065
1274
|
};
|
|
1066
|
-
|
|
1067
|
-
(0,
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1275
|
+
_ts_decorate10([
|
|
1276
|
+
(0, import_common10.Get)("today"),
|
|
1277
|
+
_ts_param8(0, (0, import_common10.Req)()),
|
|
1278
|
+
_ts_metadata9("design:type", Function),
|
|
1279
|
+
_ts_metadata9("design:paramtypes", [
|
|
1071
1280
|
typeof Request === "undefined" ? Object : Request
|
|
1072
1281
|
]),
|
|
1073
|
-
|
|
1282
|
+
_ts_metadata9("design:returntype", Promise)
|
|
1074
1283
|
], QuotaController.prototype, "today", null);
|
|
1075
|
-
QuotaController =
|
|
1076
|
-
(0,
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1284
|
+
QuotaController = _ts_decorate10([
|
|
1285
|
+
(0, import_common10.Controller)("quota"),
|
|
1286
|
+
_ts_param8(1, (0, import_common10.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
|
|
1287
|
+
_ts_metadata9("design:type", Function),
|
|
1288
|
+
_ts_metadata9("design:paramtypes", [
|
|
1080
1289
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1081
1290
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1082
1291
|
])
|
|
1083
1292
|
], QuotaController);
|
|
1084
1293
|
|
|
1085
1294
|
// src/controller/threads.controller.ts
|
|
1086
|
-
var
|
|
1087
|
-
var
|
|
1088
|
-
function
|
|
1295
|
+
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
1296
|
+
var import_common11 = require("@nestjs/common");
|
|
1297
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1089
1298
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1090
1299
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1091
1300
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1092
1301
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1093
1302
|
}
|
|
1094
|
-
__name(
|
|
1095
|
-
function
|
|
1303
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1304
|
+
function _ts_metadata10(k, v) {
|
|
1096
1305
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1097
1306
|
}
|
|
1098
|
-
__name(
|
|
1099
|
-
function
|
|
1307
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
1308
|
+
function _ts_param9(paramIndex, decorator) {
|
|
1100
1309
|
return function(target, key) {
|
|
1101
1310
|
decorator(target, key, paramIndex);
|
|
1102
1311
|
};
|
|
1103
1312
|
}
|
|
1104
|
-
__name(
|
|
1313
|
+
__name(_ts_param9, "_ts_param");
|
|
1105
1314
|
var ThreadsController = class {
|
|
1106
1315
|
static {
|
|
1107
1316
|
__name(this, "ThreadsController");
|
|
@@ -1165,117 +1374,117 @@ var ThreadsController = class {
|
|
|
1165
1374
|
};
|
|
1166
1375
|
}
|
|
1167
1376
|
};
|
|
1168
|
-
|
|
1169
|
-
(0,
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1377
|
+
_ts_decorate11([
|
|
1378
|
+
(0, import_common11.Get)(),
|
|
1379
|
+
_ts_param9(0, (0, import_common11.Req)()),
|
|
1380
|
+
_ts_metadata10("design:type", Function),
|
|
1381
|
+
_ts_metadata10("design:paramtypes", [
|
|
1173
1382
|
typeof Request === "undefined" ? Object : Request
|
|
1174
1383
|
]),
|
|
1175
|
-
|
|
1384
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1176
1385
|
], ThreadsController.prototype, "list", null);
|
|
1177
|
-
|
|
1178
|
-
(0,
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1386
|
+
_ts_decorate11([
|
|
1387
|
+
(0, import_common11.Get)(":id"),
|
|
1388
|
+
_ts_param9(0, (0, import_common11.Req)()),
|
|
1389
|
+
_ts_param9(1, (0, import_common11.Param)("id")),
|
|
1390
|
+
_ts_metadata10("design:type", Function),
|
|
1391
|
+
_ts_metadata10("design:paramtypes", [
|
|
1183
1392
|
typeof Request === "undefined" ? Object : Request,
|
|
1184
1393
|
String
|
|
1185
1394
|
]),
|
|
1186
|
-
|
|
1395
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1187
1396
|
], ThreadsController.prototype, "detail", null);
|
|
1188
|
-
|
|
1189
|
-
(0,
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1397
|
+
_ts_decorate11([
|
|
1398
|
+
(0, import_common11.Delete)(":id"),
|
|
1399
|
+
_ts_param9(0, (0, import_common11.Req)()),
|
|
1400
|
+
_ts_param9(1, (0, import_common11.Param)("id")),
|
|
1401
|
+
_ts_metadata10("design:type", Function),
|
|
1402
|
+
_ts_metadata10("design:paramtypes", [
|
|
1194
1403
|
typeof Request === "undefined" ? Object : Request,
|
|
1195
1404
|
String
|
|
1196
1405
|
]),
|
|
1197
|
-
|
|
1406
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1198
1407
|
], ThreadsController.prototype, "remove", null);
|
|
1199
|
-
|
|
1200
|
-
(0,
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1408
|
+
_ts_decorate11([
|
|
1409
|
+
(0, import_common11.Post)(":id/fork-from/:messageId"),
|
|
1410
|
+
_ts_param9(0, (0, import_common11.Req)()),
|
|
1411
|
+
_ts_param9(1, (0, import_common11.Param)("id")),
|
|
1412
|
+
_ts_param9(2, (0, import_common11.Param)("messageId")),
|
|
1413
|
+
_ts_metadata10("design:type", Function),
|
|
1414
|
+
_ts_metadata10("design:paramtypes", [
|
|
1206
1415
|
typeof Request === "undefined" ? Object : Request,
|
|
1207
1416
|
String,
|
|
1208
1417
|
String
|
|
1209
1418
|
]),
|
|
1210
|
-
|
|
1419
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1211
1420
|
], ThreadsController.prototype, "fork", null);
|
|
1212
|
-
|
|
1213
|
-
(0,
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1421
|
+
_ts_decorate11([
|
|
1422
|
+
(0, import_common11.Patch)(":id"),
|
|
1423
|
+
_ts_param9(0, (0, import_common11.Req)()),
|
|
1424
|
+
_ts_param9(1, (0, import_common11.Param)("id")),
|
|
1425
|
+
_ts_param9(2, (0, import_common11.Body)()),
|
|
1426
|
+
_ts_metadata10("design:type", Function),
|
|
1427
|
+
_ts_metadata10("design:paramtypes", [
|
|
1219
1428
|
typeof Request === "undefined" ? Object : Request,
|
|
1220
1429
|
String,
|
|
1221
1430
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
1222
1431
|
]),
|
|
1223
|
-
|
|
1432
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1224
1433
|
], ThreadsController.prototype, "update", null);
|
|
1225
|
-
|
|
1226
|
-
(0,
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1434
|
+
_ts_decorate11([
|
|
1435
|
+
(0, import_common11.Post)(":id/promote"),
|
|
1436
|
+
_ts_param9(0, (0, import_common11.Req)()),
|
|
1437
|
+
_ts_param9(1, (0, import_common11.Param)("id")),
|
|
1438
|
+
_ts_metadata10("design:type", Function),
|
|
1439
|
+
_ts_metadata10("design:paramtypes", [
|
|
1231
1440
|
typeof Request === "undefined" ? Object : Request,
|
|
1232
1441
|
String
|
|
1233
1442
|
]),
|
|
1234
|
-
|
|
1443
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1235
1444
|
], ThreadsController.prototype, "promote", null);
|
|
1236
|
-
|
|
1237
|
-
(0,
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1445
|
+
_ts_decorate11([
|
|
1446
|
+
(0, import_common11.Delete)(":id/from/:messageId"),
|
|
1447
|
+
_ts_param9(0, (0, import_common11.Req)()),
|
|
1448
|
+
_ts_param9(1, (0, import_common11.Param)("id")),
|
|
1449
|
+
_ts_param9(2, (0, import_common11.Param)("messageId")),
|
|
1450
|
+
_ts_metadata10("design:type", Function),
|
|
1451
|
+
_ts_metadata10("design:paramtypes", [
|
|
1243
1452
|
typeof Request === "undefined" ? Object : Request,
|
|
1244
1453
|
String,
|
|
1245
1454
|
String
|
|
1246
1455
|
]),
|
|
1247
|
-
|
|
1456
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1248
1457
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
1249
|
-
ThreadsController =
|
|
1250
|
-
(0,
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1458
|
+
ThreadsController = _ts_decorate11([
|
|
1459
|
+
(0, import_common11.Controller)("threads"),
|
|
1460
|
+
_ts_param9(1, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
|
|
1461
|
+
_ts_metadata10("design:type", Function),
|
|
1462
|
+
_ts_metadata10("design:paramtypes", [
|
|
1254
1463
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1255
1464
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1256
1465
|
])
|
|
1257
1466
|
], ThreadsController);
|
|
1258
1467
|
|
|
1259
1468
|
// src/controller/tool-call.controller.ts
|
|
1260
|
-
var
|
|
1261
|
-
var
|
|
1262
|
-
function
|
|
1469
|
+
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
1470
|
+
var import_common12 = require("@nestjs/common");
|
|
1471
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
1263
1472
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1264
1473
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1265
1474
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1266
1475
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1267
1476
|
}
|
|
1268
|
-
__name(
|
|
1269
|
-
function
|
|
1477
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
1478
|
+
function _ts_metadata11(k, v) {
|
|
1270
1479
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1271
1480
|
}
|
|
1272
|
-
__name(
|
|
1273
|
-
function
|
|
1481
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
1482
|
+
function _ts_param10(paramIndex, decorator) {
|
|
1274
1483
|
return function(target, key) {
|
|
1275
1484
|
decorator(target, key, paramIndex);
|
|
1276
1485
|
};
|
|
1277
1486
|
}
|
|
1278
|
-
__name(
|
|
1487
|
+
__name(_ts_param10, "_ts_param");
|
|
1279
1488
|
var ToolCallController = class {
|
|
1280
1489
|
static {
|
|
1281
1490
|
__name(this, "ToolCallController");
|
|
@@ -1301,41 +1510,41 @@ var ToolCallController = class {
|
|
|
1301
1510
|
};
|
|
1302
1511
|
}
|
|
1303
1512
|
};
|
|
1304
|
-
|
|
1305
|
-
(0,
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1513
|
+
_ts_decorate12([
|
|
1514
|
+
(0, import_common12.Post)("approve"),
|
|
1515
|
+
_ts_param10(0, (0, import_common12.Req)()),
|
|
1516
|
+
_ts_param10(1, (0, import_common12.Body)()),
|
|
1517
|
+
_ts_metadata11("design:type", Function),
|
|
1518
|
+
_ts_metadata11("design:paramtypes", [
|
|
1310
1519
|
typeof Request === "undefined" ? Object : Request,
|
|
1311
1520
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
1312
1521
|
]),
|
|
1313
|
-
|
|
1522
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1314
1523
|
], ToolCallController.prototype, "approve", null);
|
|
1315
|
-
|
|
1316
|
-
(0,
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1524
|
+
_ts_decorate12([
|
|
1525
|
+
(0, import_common12.Post)("reject"),
|
|
1526
|
+
_ts_param10(0, (0, import_common12.Req)()),
|
|
1527
|
+
_ts_param10(1, (0, import_common12.Body)()),
|
|
1528
|
+
_ts_metadata11("design:type", Function),
|
|
1529
|
+
_ts_metadata11("design:paramtypes", [
|
|
1321
1530
|
typeof Request === "undefined" ? Object : Request,
|
|
1322
1531
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
1323
1532
|
]),
|
|
1324
|
-
|
|
1533
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1325
1534
|
], ToolCallController.prototype, "reject", null);
|
|
1326
|
-
ToolCallController =
|
|
1327
|
-
(0,
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1535
|
+
ToolCallController = _ts_decorate12([
|
|
1536
|
+
(0, import_common12.Controller)("tool-call"),
|
|
1537
|
+
_ts_param10(1, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
|
|
1538
|
+
_ts_metadata11("design:type", Function),
|
|
1539
|
+
_ts_metadata11("design:paramtypes", [
|
|
1331
1540
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1332
1541
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1333
1542
|
])
|
|
1334
1543
|
], ToolCallController);
|
|
1335
1544
|
|
|
1336
1545
|
// src/discovery/agent-discovery.service.ts
|
|
1337
|
-
var
|
|
1338
|
-
var
|
|
1546
|
+
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
1547
|
+
var import_common13 = require("@nestjs/common");
|
|
1339
1548
|
var import_core = require("@nestjs/core");
|
|
1340
1549
|
|
|
1341
1550
|
// src/decorator/agent.decorator.ts
|
|
@@ -1352,23 +1561,23 @@ var SYSTEM_PROMPT_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt");
|
|
|
1352
1561
|
var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
|
|
1353
1562
|
|
|
1354
1563
|
// src/discovery/agent-discovery.service.ts
|
|
1355
|
-
function
|
|
1564
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
1356
1565
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1357
1566
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1358
1567
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1359
1568
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1360
1569
|
}
|
|
1361
|
-
__name(
|
|
1362
|
-
function
|
|
1570
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
1571
|
+
function _ts_metadata12(k, v) {
|
|
1363
1572
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1364
1573
|
}
|
|
1365
|
-
__name(
|
|
1366
|
-
function
|
|
1574
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
1575
|
+
function _ts_param11(paramIndex, decorator) {
|
|
1367
1576
|
return function(target, key) {
|
|
1368
1577
|
decorator(target, key, paramIndex);
|
|
1369
1578
|
};
|
|
1370
1579
|
}
|
|
1371
|
-
__name(
|
|
1580
|
+
__name(_ts_param11, "_ts_param");
|
|
1372
1581
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
1373
1582
|
static {
|
|
1374
1583
|
__name(this, "AgentDiscoveryService");
|
|
@@ -1377,7 +1586,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
1377
1586
|
scanner;
|
|
1378
1587
|
registry;
|
|
1379
1588
|
contributors;
|
|
1380
|
-
logger = new
|
|
1589
|
+
logger = new import_common13.Logger(_AgentDiscoveryService.name);
|
|
1381
1590
|
constructor(discovery, scanner, registry, contributors) {
|
|
1382
1591
|
this.discovery = discovery;
|
|
1383
1592
|
this.scanner = scanner;
|
|
@@ -1465,22 +1674,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
1465
1674
|
return (ctx) => candidate.call(instance, ctx);
|
|
1466
1675
|
}
|
|
1467
1676
|
};
|
|
1468
|
-
AgentDiscoveryService =
|
|
1469
|
-
(0,
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1677
|
+
AgentDiscoveryService = _ts_decorate13([
|
|
1678
|
+
(0, import_common13.Injectable)(),
|
|
1679
|
+
_ts_param11(2, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_REGISTRY)),
|
|
1680
|
+
_ts_param11(3, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_PROMPT_CONTRIBUTORS)),
|
|
1681
|
+
_ts_metadata12("design:type", Function),
|
|
1682
|
+
_ts_metadata12("design:paramtypes", [
|
|
1474
1683
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
1475
1684
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
1476
|
-
typeof
|
|
1685
|
+
typeof import_nestjs_agent_core14.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core14.AgentRegistry,
|
|
1477
1686
|
Array
|
|
1478
1687
|
])
|
|
1479
1688
|
], AgentDiscoveryService);
|
|
1480
1689
|
|
|
1481
1690
|
// src/discovery/ai-tool-discovery.service.ts
|
|
1482
|
-
var
|
|
1483
|
-
var
|
|
1691
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
1692
|
+
var import_common14 = require("@nestjs/common");
|
|
1484
1693
|
var import_core2 = require("@nestjs/core");
|
|
1485
1694
|
var import_zod = require("zod");
|
|
1486
1695
|
|
|
@@ -1500,23 +1709,23 @@ function isBrandedFunctionalTool(value) {
|
|
|
1500
1709
|
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
1501
1710
|
|
|
1502
1711
|
// src/discovery/ai-tool-discovery.service.ts
|
|
1503
|
-
function
|
|
1712
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
1504
1713
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1505
1714
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1506
1715
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1507
1716
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1508
1717
|
}
|
|
1509
|
-
__name(
|
|
1510
|
-
function
|
|
1718
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
1719
|
+
function _ts_metadata13(k, v) {
|
|
1511
1720
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1512
1721
|
}
|
|
1513
|
-
__name(
|
|
1514
|
-
function
|
|
1722
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
1723
|
+
function _ts_param12(paramIndex, decorator) {
|
|
1515
1724
|
return function(target, key) {
|
|
1516
1725
|
decorator(target, key, paramIndex);
|
|
1517
1726
|
};
|
|
1518
1727
|
}
|
|
1519
|
-
__name(
|
|
1728
|
+
__name(_ts_param12, "_ts_param");
|
|
1520
1729
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
1521
1730
|
static {
|
|
1522
1731
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -1525,7 +1734,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
1525
1734
|
registry;
|
|
1526
1735
|
agents;
|
|
1527
1736
|
options;
|
|
1528
|
-
logger = new
|
|
1737
|
+
logger = new import_common14.Logger(_AiToolDiscoveryService.name);
|
|
1529
1738
|
constructor(discovery, registry, agents, options) {
|
|
1530
1739
|
this.discovery = discovery;
|
|
1531
1740
|
this.registry = registry;
|
|
@@ -1623,13 +1832,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
1623
1832
|
return true;
|
|
1624
1833
|
}
|
|
1625
1834
|
};
|
|
1626
|
-
AiToolDiscoveryService =
|
|
1627
|
-
(0,
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1835
|
+
AiToolDiscoveryService = _ts_decorate14([
|
|
1836
|
+
(0, import_common14.Injectable)(),
|
|
1837
|
+
_ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_TOOL_REGISTRY)),
|
|
1838
|
+
_ts_param12(2, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_REGISTRY)),
|
|
1839
|
+
_ts_param12(3, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_OPTIONS)),
|
|
1840
|
+
_ts_metadata13("design:type", Function),
|
|
1841
|
+
_ts_metadata13("design:paramtypes", [
|
|
1633
1842
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
1634
1843
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
1635
1844
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -1637,74 +1846,6 @@ AiToolDiscoveryService = _ts_decorate13([
|
|
|
1637
1846
|
])
|
|
1638
1847
|
], AiToolDiscoveryService);
|
|
1639
1848
|
|
|
1640
|
-
// src/in-process-sink.ts
|
|
1641
|
-
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
1642
|
-
var InProcessTokenStreamSink = class {
|
|
1643
|
-
static {
|
|
1644
|
-
__name(this, "InProcessTokenStreamSink");
|
|
1645
|
-
}
|
|
1646
|
-
runs = /* @__PURE__ */ new Map();
|
|
1647
|
-
buffer(runId) {
|
|
1648
|
-
let buf = this.runs.get(runId);
|
|
1649
|
-
if (buf === void 0) {
|
|
1650
|
-
buf = {
|
|
1651
|
-
chunks: [],
|
|
1652
|
-
ended: false,
|
|
1653
|
-
notify: /* @__PURE__ */ new Set()
|
|
1654
|
-
};
|
|
1655
|
-
this.runs.set(runId, buf);
|
|
1656
|
-
}
|
|
1657
|
-
return buf;
|
|
1658
|
-
}
|
|
1659
|
-
wake(buf) {
|
|
1660
|
-
for (const resolve of buf.notify) {
|
|
1661
|
-
resolve();
|
|
1662
|
-
}
|
|
1663
|
-
buf.notify.clear();
|
|
1664
|
-
}
|
|
1665
|
-
open(runId) {
|
|
1666
|
-
const buf = this.buffer(runId);
|
|
1667
|
-
return {
|
|
1668
|
-
write: /* @__PURE__ */ __name((chunk) => {
|
|
1669
|
-
buf.chunks.push(chunk);
|
|
1670
|
-
this.wake(buf);
|
|
1671
|
-
}, "write"),
|
|
1672
|
-
end: /* @__PURE__ */ __name(() => {
|
|
1673
|
-
buf.ended = true;
|
|
1674
|
-
this.wake(buf);
|
|
1675
|
-
}, "end"),
|
|
1676
|
-
fail: /* @__PURE__ */ __name((error) => {
|
|
1677
|
-
buf.failure = error;
|
|
1678
|
-
buf.ended = true;
|
|
1679
|
-
this.wake(buf);
|
|
1680
|
-
}, "fail")
|
|
1681
|
-
};
|
|
1682
|
-
}
|
|
1683
|
-
async *subscribe(runId) {
|
|
1684
|
-
const buf = this.buffer(runId);
|
|
1685
|
-
let index = 0;
|
|
1686
|
-
while (true) {
|
|
1687
|
-
while (index < buf.chunks.length) {
|
|
1688
|
-
const chunk = buf.chunks[index];
|
|
1689
|
-
index += 1;
|
|
1690
|
-
if (chunk !== void 0) {
|
|
1691
|
-
yield chunk;
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1694
|
-
if (buf.ended) {
|
|
1695
|
-
if (buf.failure !== void 0) {
|
|
1696
|
-
throw new import_nestjs_agent_core14.AgentStreamError(buf.failure);
|
|
1697
|
-
}
|
|
1698
|
-
return;
|
|
1699
|
-
}
|
|
1700
|
-
await new Promise((resolve) => buf.notify.add(resolve));
|
|
1701
|
-
}
|
|
1702
|
-
}
|
|
1703
|
-
close(runId) {
|
|
1704
|
-
this.runs.delete(runId);
|
|
1705
|
-
}
|
|
1706
|
-
};
|
|
1707
|
-
|
|
1708
1849
|
// src/ledger-quota-store.ts
|
|
1709
1850
|
var LedgerQuotaStore = class {
|
|
1710
1851
|
static {
|
|
@@ -1729,32 +1870,32 @@ var LedgerQuotaStore = class {
|
|
|
1729
1870
|
};
|
|
1730
1871
|
|
|
1731
1872
|
// src/runner/inline-agent-runner.ts
|
|
1732
|
-
var
|
|
1733
|
-
var
|
|
1734
|
-
function
|
|
1873
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
1874
|
+
var import_common15 = require("@nestjs/common");
|
|
1875
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
1735
1876
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1736
1877
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1737
1878
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1738
1879
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1739
1880
|
}
|
|
1740
|
-
__name(
|
|
1741
|
-
function
|
|
1881
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
1882
|
+
function _ts_metadata14(k, v) {
|
|
1742
1883
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1743
1884
|
}
|
|
1744
|
-
__name(
|
|
1745
|
-
function
|
|
1885
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
1886
|
+
function _ts_param13(paramIndex, decorator) {
|
|
1746
1887
|
return function(target, key) {
|
|
1747
1888
|
decorator(target, key, paramIndex);
|
|
1748
1889
|
};
|
|
1749
1890
|
}
|
|
1750
|
-
__name(
|
|
1891
|
+
__name(_ts_param13, "_ts_param");
|
|
1751
1892
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
1752
1893
|
static {
|
|
1753
1894
|
__name(this, "InlineAgentRunner");
|
|
1754
1895
|
}
|
|
1755
1896
|
factory;
|
|
1756
1897
|
store;
|
|
1757
|
-
logger = new
|
|
1898
|
+
logger = new import_common15.Logger(_InlineAgentRunner.name);
|
|
1758
1899
|
pending = /* @__PURE__ */ new Map();
|
|
1759
1900
|
constructor(factory, store) {
|
|
1760
1901
|
this.factory = factory;
|
|
@@ -1765,18 +1906,24 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1765
1906
|
const day = input.day ?? utcDay();
|
|
1766
1907
|
const deps = this.factory.forAgent(input.agentName);
|
|
1767
1908
|
const hooks = this.topLevelHooks(runId, deps, input.actor, day);
|
|
1768
|
-
void (0,
|
|
1909
|
+
void (0, import_nestjs_agent_core16.runAgentLoop)({
|
|
1769
1910
|
...deps,
|
|
1770
1911
|
day
|
|
1771
1912
|
}, input, hooks).then(() => this.store.setActiveStream(input.threadId, null)).catch(async (error) => {
|
|
1772
1913
|
const message = error instanceof Error ? error.message : String(error);
|
|
1773
|
-
const code = error instanceof
|
|
1914
|
+
const code = error instanceof import_nestjs_agent_core16.QuotaExceededError ? "quota_exceeded" : "run_failed";
|
|
1774
1915
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
1775
|
-
(0,
|
|
1916
|
+
(0, import_nestjs_agent_core16.publishAgentRunFailed)({
|
|
1776
1917
|
runId,
|
|
1777
1918
|
code,
|
|
1778
1919
|
message
|
|
1779
1920
|
});
|
|
1921
|
+
await this.store.recordRunEnd?.({
|
|
1922
|
+
runId,
|
|
1923
|
+
status: "failed",
|
|
1924
|
+
errorCode: code,
|
|
1925
|
+
errorMessage: message
|
|
1926
|
+
});
|
|
1780
1927
|
await this.store.setActiveStream(input.threadId, null);
|
|
1781
1928
|
const writer = await deps.sink.open(runId);
|
|
1782
1929
|
await writer.fail({
|
|
@@ -1836,7 +1983,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1836
1983
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested(childName, childTask, actor, day, depth + 1, sinkRunId), "runAgent")
|
|
1837
1984
|
};
|
|
1838
1985
|
try {
|
|
1839
|
-
return await (0,
|
|
1986
|
+
return await (0, import_nestjs_agent_core16.runAgentLoop)({
|
|
1840
1987
|
...deps,
|
|
1841
1988
|
day
|
|
1842
1989
|
}, {
|
|
@@ -1853,84 +2000,84 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1853
2000
|
}
|
|
1854
2001
|
}
|
|
1855
2002
|
};
|
|
1856
|
-
InlineAgentRunner =
|
|
1857
|
-
(0,
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
2003
|
+
InlineAgentRunner = _ts_decorate15([
|
|
2004
|
+
(0, import_common15.Injectable)(),
|
|
2005
|
+
_ts_param13(0, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_DEPS_FACTORY)),
|
|
2006
|
+
_ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_STORE)),
|
|
2007
|
+
_ts_metadata14("design:type", Function),
|
|
2008
|
+
_ts_metadata14("design:paramtypes", [
|
|
1862
2009
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1863
2010
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
1864
2011
|
])
|
|
1865
2012
|
], InlineAgentRunner);
|
|
1866
2013
|
|
|
1867
2014
|
// src/agent.module.ts
|
|
1868
|
-
function
|
|
2015
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
1869
2016
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1870
2017
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1871
2018
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1872
2019
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1873
2020
|
}
|
|
1874
|
-
__name(
|
|
2021
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
1875
2022
|
var DEFAULT_PATH = "agent";
|
|
1876
2023
|
function sharedProviders(durable, includeStore) {
|
|
1877
2024
|
const providers = [
|
|
1878
2025
|
{
|
|
1879
|
-
provide:
|
|
1880
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
2026
|
+
provide: import_nestjs_agent_core17.AGENT_TOOL_REGISTRY,
|
|
2027
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core17.ToolRegistry(), "useFactory")
|
|
1881
2028
|
},
|
|
1882
2029
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
1883
2030
|
{
|
|
1884
|
-
provide:
|
|
1885
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
2031
|
+
provide: import_nestjs_agent_core17.AGENT_REGISTRY,
|
|
2032
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core17.AgentRegistry(), "useFactory")
|
|
1886
2033
|
},
|
|
1887
2034
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
1888
2035
|
{
|
|
1889
|
-
provide:
|
|
2036
|
+
provide: import_nestjs_agent_core17.AGENT_PROMPT_CONTRIBUTORS,
|
|
1890
2037
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
1891
2038
|
},
|
|
1892
2039
|
{
|
|
1893
|
-
provide:
|
|
2040
|
+
provide: import_nestjs_agent_core17.AGENT_SINK,
|
|
1894
2041
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
1895
2042
|
inject: [
|
|
1896
|
-
|
|
2043
|
+
import_nestjs_agent_core17.AGENT_OPTIONS
|
|
1897
2044
|
]
|
|
1898
2045
|
},
|
|
1899
2046
|
{
|
|
1900
|
-
provide:
|
|
1901
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new
|
|
2047
|
+
provide: import_nestjs_agent_core17.AGENT_ROLES_POLICY,
|
|
2048
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core17.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
1902
2049
|
inject: [
|
|
1903
|
-
|
|
2050
|
+
import_nestjs_agent_core17.AGENT_OPTIONS
|
|
1904
2051
|
]
|
|
1905
2052
|
},
|
|
1906
2053
|
{
|
|
1907
|
-
provide:
|
|
2054
|
+
provide: import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER,
|
|
1908
2055
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
1909
2056
|
inject: [
|
|
1910
|
-
|
|
2057
|
+
import_nestjs_agent_core17.AGENT_OPTIONS
|
|
1911
2058
|
]
|
|
1912
2059
|
},
|
|
1913
2060
|
{
|
|
1914
|
-
provide:
|
|
2061
|
+
provide: import_nestjs_agent_core17.AGENT_MODEL,
|
|
1915
2062
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
1916
2063
|
inject: [
|
|
1917
|
-
|
|
2064
|
+
import_nestjs_agent_core17.AGENT_OPTIONS
|
|
1918
2065
|
]
|
|
1919
2066
|
},
|
|
1920
2067
|
{
|
|
1921
2068
|
// An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
|
|
1922
2069
|
// store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
|
|
1923
2070
|
// the loop already writes, so enforcement needs no extra shared state across replicas.
|
|
1924
|
-
provide:
|
|
2071
|
+
provide: import_nestjs_agent_core17.AGENT_QUOTA_STORE,
|
|
1925
2072
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
1926
2073
|
inject: [
|
|
1927
|
-
|
|
1928
|
-
|
|
2074
|
+
import_nestjs_agent_core17.AGENT_OPTIONS,
|
|
2075
|
+
import_nestjs_agent_core17.AGENT_STORE
|
|
1929
2076
|
]
|
|
1930
2077
|
},
|
|
1931
2078
|
AgentDepsFactory2,
|
|
1932
2079
|
{
|
|
1933
|
-
provide:
|
|
2080
|
+
provide: import_nestjs_agent_core17.AGENT_DEPS_FACTORY,
|
|
1934
2081
|
useExisting: AgentDepsFactory2
|
|
1935
2082
|
},
|
|
1936
2083
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -1942,16 +2089,16 @@ function sharedProviders(durable, includeStore) {
|
|
|
1942
2089
|
];
|
|
1943
2090
|
if (includeStore) {
|
|
1944
2091
|
providers.push({
|
|
1945
|
-
provide:
|
|
2092
|
+
provide: import_nestjs_agent_core17.AGENT_STORE,
|
|
1946
2093
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
1947
2094
|
inject: [
|
|
1948
|
-
|
|
2095
|
+
import_nestjs_agent_core17.AGENT_OPTIONS
|
|
1949
2096
|
]
|
|
1950
2097
|
});
|
|
1951
2098
|
}
|
|
1952
2099
|
if (durable) {
|
|
1953
2100
|
providers.push({
|
|
1954
|
-
provide:
|
|
2101
|
+
provide: import_nestjs_agent_core17.AGENT_RUNNER,
|
|
1955
2102
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
1956
2103
|
if (durableRunner === void 0) {
|
|
1957
2104
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -1960,14 +2107,14 @@ function sharedProviders(durable, includeStore) {
|
|
|
1960
2107
|
}, "useFactory"),
|
|
1961
2108
|
inject: [
|
|
1962
2109
|
{
|
|
1963
|
-
token:
|
|
2110
|
+
token: import_nestjs_agent_core17.AGENT_DURABLE_RUNNER,
|
|
1964
2111
|
optional: true
|
|
1965
2112
|
}
|
|
1966
2113
|
]
|
|
1967
2114
|
});
|
|
1968
2115
|
} else {
|
|
1969
2116
|
providers.push({
|
|
1970
|
-
provide:
|
|
2117
|
+
provide: import_nestjs_agent_core17.AGENT_RUNNER,
|
|
1971
2118
|
useExisting: InlineAgentRunner
|
|
1972
2119
|
});
|
|
1973
2120
|
}
|
|
@@ -1976,19 +2123,19 @@ function sharedProviders(durable, includeStore) {
|
|
|
1976
2123
|
__name(sharedProviders, "sharedProviders");
|
|
1977
2124
|
function exportsFor(includeStore) {
|
|
1978
2125
|
return [
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
2126
|
+
import_nestjs_agent_core17.AGENT_OPTIONS,
|
|
2127
|
+
import_nestjs_agent_core17.AGENT_TOOL_REGISTRY,
|
|
2128
|
+
import_nestjs_agent_core17.AGENT_REGISTRY,
|
|
2129
|
+
import_nestjs_agent_core17.AGENT_SINK,
|
|
2130
|
+
import_nestjs_agent_core17.AGENT_ROLES_POLICY,
|
|
2131
|
+
import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER,
|
|
2132
|
+
import_nestjs_agent_core17.AGENT_MODEL,
|
|
1986
2133
|
...includeStore ? [
|
|
1987
|
-
|
|
2134
|
+
import_nestjs_agent_core17.AGENT_STORE
|
|
1988
2135
|
] : [],
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
2136
|
+
import_nestjs_agent_core17.AGENT_QUOTA_STORE,
|
|
2137
|
+
import_nestjs_agent_core17.AGENT_PROMPT_CONTRIBUTORS,
|
|
2138
|
+
import_nestjs_agent_core17.AGENT_DEPS_FACTORY,
|
|
1992
2139
|
AgentDepsFactory2,
|
|
1993
2140
|
AgentService,
|
|
1994
2141
|
InlineAgentRunner
|
|
@@ -2036,11 +2183,18 @@ function routerFor(path) {
|
|
|
2036
2183
|
]);
|
|
2037
2184
|
}
|
|
2038
2185
|
__name(routerFor, "routerFor");
|
|
2186
|
+
function assertDispatchedStepsRequiresDurable(dispatchedSteps, durable) {
|
|
2187
|
+
if (dispatchedSteps && !durable) {
|
|
2188
|
+
throw new Error("AgentModule dispatchedSteps: true requires durable: true \u2014 dispatched steps are routed durable steps (AgentRunSteps.llm/tool) with no in-process equivalent.");
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
__name(assertDispatchedStepsRequiresDurable, "assertDispatchedStepsRequiresDurable");
|
|
2039
2192
|
var AgentModule = class _AgentModule {
|
|
2040
2193
|
static {
|
|
2041
2194
|
__name(this, "AgentModule");
|
|
2042
2195
|
}
|
|
2043
2196
|
static forRoot(options) {
|
|
2197
|
+
assertDispatchedStepsRequiresDurable(options.dispatchedSteps ?? false, options.durable ?? false);
|
|
2044
2198
|
const path = options.path ?? DEFAULT_PATH;
|
|
2045
2199
|
const includeStore = options.store !== void 0;
|
|
2046
2200
|
applyGuards(options.guards);
|
|
@@ -2054,7 +2208,7 @@ var AgentModule = class _AgentModule {
|
|
|
2054
2208
|
controllers: controllersFor(options.attachments?.upload === true),
|
|
2055
2209
|
providers: [
|
|
2056
2210
|
{
|
|
2057
|
-
provide:
|
|
2211
|
+
provide: import_nestjs_agent_core17.AGENT_OPTIONS,
|
|
2058
2212
|
useValue: options
|
|
2059
2213
|
},
|
|
2060
2214
|
...sharedProviders(options.durable ?? false, includeStore),
|
|
@@ -2064,6 +2218,7 @@ var AgentModule = class _AgentModule {
|
|
|
2064
2218
|
};
|
|
2065
2219
|
}
|
|
2066
2220
|
static forRootAsync(options) {
|
|
2221
|
+
assertDispatchedStepsRequiresDurable(options.dispatchedSteps ?? false, options.durable ?? false);
|
|
2067
2222
|
const path = options.path ?? DEFAULT_PATH;
|
|
2068
2223
|
const includeStore = options.externalStore !== true;
|
|
2069
2224
|
applyGuards(options.guards);
|
|
@@ -2078,7 +2233,7 @@ var AgentModule = class _AgentModule {
|
|
|
2078
2233
|
controllers: controllersFor(options.attachmentsUpload === true),
|
|
2079
2234
|
providers: [
|
|
2080
2235
|
{
|
|
2081
|
-
provide:
|
|
2236
|
+
provide: import_nestjs_agent_core17.AGENT_OPTIONS,
|
|
2082
2237
|
useFactory: options.useFactory,
|
|
2083
2238
|
inject: options.inject ?? []
|
|
2084
2239
|
},
|
|
@@ -2089,9 +2244,9 @@ var AgentModule = class _AgentModule {
|
|
|
2089
2244
|
};
|
|
2090
2245
|
}
|
|
2091
2246
|
};
|
|
2092
|
-
AgentModule =
|
|
2093
|
-
(0,
|
|
2094
|
-
(0,
|
|
2247
|
+
AgentModule = _ts_decorate16([
|
|
2248
|
+
(0, import_common16.Global)(),
|
|
2249
|
+
(0, import_common16.Module)({})
|
|
2095
2250
|
], AgentModule);
|
|
2096
2251
|
|
|
2097
2252
|
// src/durable/agent-durable.ts
|
|
@@ -2107,7 +2262,9 @@ function agentDurable(options) {
|
|
|
2107
2262
|
__name(agentDurable, "agentDurable");
|
|
2108
2263
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2109
2264
|
0 && (module.exports = {
|
|
2265
|
+
AGENT_DISPATCHED_STEPS,
|
|
2110
2266
|
AgentDurableModule,
|
|
2267
|
+
AgentRunSteps,
|
|
2111
2268
|
AgentRunWorkflow,
|
|
2112
2269
|
DurableAgentRunner,
|
|
2113
2270
|
agentDurable
|