@dudousxd/nestjs-agent 0.4.1 → 0.6.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-BlC9tumI.d.cts} +24 -0
- package/dist/{agent-deps.factory-BM_RB6br.d.ts → agent-deps.factory-BlC9tumI.d.ts} +24 -0
- package/dist/durable/index.cjs +701 -459
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +76 -12
- package/dist/durable/index.d.ts +76 -12
- package/dist/durable/index.js +614 -374
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +327 -226
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -9
- package/dist/index.d.ts +48 -9
- package/dist/index.js +244 -144
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/durable/index.js
CHANGED
|
@@ -2,10 +2,10 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/durable/agent-run.workflow.ts
|
|
5
|
-
import { AGENT_DEPS_FACTORY, AGENT_STORE, QuotaExceededError, publishAgentRunFailed, runAgentLoop } from "@dudousxd/nestjs-agent-core";
|
|
5
|
+
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_STORE, QuotaExceededError, publishAgentRunFailed, runAgentLoop } from "@dudousxd/nestjs-agent-core";
|
|
6
6
|
import { Workflow } from "@dudousxd/nestjs-durable";
|
|
7
7
|
import { ContinueAsNew, WorkflowSuspended } from "@dudousxd/nestjs-durable-core";
|
|
8
|
-
import { Inject, Injectable } from "@nestjs/common";
|
|
8
|
+
import { Inject as Inject2, Injectable as Injectable2 } from "@nestjs/common";
|
|
9
9
|
|
|
10
10
|
// src/agent-deps.ts
|
|
11
11
|
function utcDay(date = /* @__PURE__ */ new Date()) {
|
|
@@ -23,7 +23,10 @@ function childSinkWriter(writer) {
|
|
|
23
23
|
}
|
|
24
24
|
__name(childSinkWriter, "childSinkWriter");
|
|
25
25
|
|
|
26
|
-
// src/durable/agent-run.
|
|
26
|
+
// src/durable/agent-run.steps.ts
|
|
27
|
+
import { AGENT_DEPS_FACTORY, withToolTimeout } from "@dudousxd/nestjs-agent-core";
|
|
28
|
+
import { Step } from "@dudousxd/nestjs-durable";
|
|
29
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
27
30
|
function _ts_decorate(decorators, target, key, desc) {
|
|
28
31
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
29
32
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -41,15 +44,107 @@ function _ts_param(paramIndex, decorator) {
|
|
|
41
44
|
};
|
|
42
45
|
}
|
|
43
46
|
__name(_ts_param, "_ts_param");
|
|
47
|
+
var AgentRunSteps = class {
|
|
48
|
+
static {
|
|
49
|
+
__name(this, "AgentRunSteps");
|
|
50
|
+
}
|
|
51
|
+
factory;
|
|
52
|
+
constructor(factory) {
|
|
53
|
+
this.factory = factory;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Retryable: every side effect (persist/quota/stream markers) happens loop-side under
|
|
57
|
+
* `hooks.step`, so a durable retry only re-runs the model call and re-streams its tokens — never
|
|
58
|
+
* double-writes. NEVER call `writer.end()`/`fail()` here: the workflow owns the stream's lifecycle,
|
|
59
|
+
* across however many turns/retries it takes.
|
|
60
|
+
*/
|
|
61
|
+
async llm(input) {
|
|
62
|
+
const deps = this.factory.forAgent(input.agentName);
|
|
63
|
+
const tools = await deps.registry.definitionsFor(input.actor, deps.rolesPolicy, deps.toolAllowList);
|
|
64
|
+
const opened = await deps.sink.open(input.sinkRunId);
|
|
65
|
+
const writer = input.childSink ? childSinkWriter(opened) : opened;
|
|
66
|
+
return deps.model.runTurn({
|
|
67
|
+
system: input.system,
|
|
68
|
+
messages: input.messages,
|
|
69
|
+
tools,
|
|
70
|
+
sink: writer
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* No retries — a tool may not be idempotent (a bare `@Step()` carries none, unlike `llm` above).
|
|
75
|
+
* The timeout is applied HERE, handler-side, via `withToolTimeout` — never as a durable dispatch
|
|
76
|
+
* `timeoutMs`, which bounds engine liveness (retryable) rather than the tool's own business outcome.
|
|
77
|
+
*/
|
|
78
|
+
async tool(input) {
|
|
79
|
+
const deps = this.factory.forAgent(input.ctx.agentName);
|
|
80
|
+
const ctx = {
|
|
81
|
+
...input.ctx
|
|
82
|
+
};
|
|
83
|
+
const invocation = deps.registry.invoke(input.toolName, input.input, ctx, deps.rolesPolicy);
|
|
84
|
+
return input.timeoutMs !== void 0 ? withToolTimeout(invocation, input.timeoutMs, input.toolName) : invocation;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
_ts_decorate([
|
|
88
|
+
Step({
|
|
89
|
+
retries: 3
|
|
90
|
+
}),
|
|
91
|
+
_ts_metadata("design:type", Function),
|
|
92
|
+
_ts_metadata("design:paramtypes", [
|
|
93
|
+
typeof DispatchedLlmInput === "undefined" ? Object : DispatchedLlmInput
|
|
94
|
+
]),
|
|
95
|
+
_ts_metadata("design:returntype", Promise)
|
|
96
|
+
], AgentRunSteps.prototype, "llm", null);
|
|
97
|
+
_ts_decorate([
|
|
98
|
+
Step(),
|
|
99
|
+
_ts_metadata("design:type", Function),
|
|
100
|
+
_ts_metadata("design:paramtypes", [
|
|
101
|
+
typeof ToolStepEnvelope === "undefined" ? Object : ToolStepEnvelope
|
|
102
|
+
]),
|
|
103
|
+
_ts_metadata("design:returntype", Promise)
|
|
104
|
+
], AgentRunSteps.prototype, "tool", null);
|
|
105
|
+
AgentRunSteps = _ts_decorate([
|
|
106
|
+
Injectable(),
|
|
107
|
+
_ts_param(0, Inject(AGENT_DEPS_FACTORY)),
|
|
108
|
+
_ts_metadata("design:type", Function),
|
|
109
|
+
_ts_metadata("design:paramtypes", [
|
|
110
|
+
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
111
|
+
])
|
|
112
|
+
], AgentRunSteps);
|
|
113
|
+
|
|
114
|
+
// src/durable/dispatched-steps.token.ts
|
|
115
|
+
var AGENT_DISPATCHED_STEPS = Symbol.for("@dudousxd/nestjs-agent:dispatched-steps");
|
|
116
|
+
|
|
117
|
+
// src/durable/agent-run.workflow.ts
|
|
118
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
119
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
120
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
121
|
+
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;
|
|
122
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
123
|
+
}
|
|
124
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
125
|
+
function _ts_metadata2(k, v) {
|
|
126
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
127
|
+
}
|
|
128
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
129
|
+
function _ts_param2(paramIndex, decorator) {
|
|
130
|
+
return function(target, key) {
|
|
131
|
+
decorator(target, key, paramIndex);
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
__name(_ts_param2, "_ts_param");
|
|
44
135
|
var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
45
136
|
static {
|
|
46
137
|
__name(this, "AgentRunWorkflow");
|
|
47
138
|
}
|
|
48
139
|
factory;
|
|
49
140
|
store;
|
|
50
|
-
|
|
141
|
+
steps;
|
|
142
|
+
dispatchedSteps;
|
|
143
|
+
constructor(factory, store, steps, dispatchedSteps) {
|
|
51
144
|
this.factory = factory;
|
|
52
145
|
this.store = store;
|
|
146
|
+
this.steps = steps;
|
|
147
|
+
this.dispatchedSteps = dispatchedSteps;
|
|
53
148
|
}
|
|
54
149
|
async run(ctx, input) {
|
|
55
150
|
const day = input.day ?? utcDay();
|
|
@@ -64,6 +159,8 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
64
159
|
openSink: /* @__PURE__ */ __name(async () => input.sinkRunId !== void 0 ? childSinkWriter(await deps.sink.open(sinkRunId)) : deps.sink.open(ctx.runId), "openSink"),
|
|
65
160
|
awaitApproval: /* @__PURE__ */ __name((call) => ctx.waitForSignal(`tool:${ctx.runId}:${call.id}`), "awaitApproval"),
|
|
66
161
|
step: /* @__PURE__ */ __name((name, fn) => ctx.localStep(name, fn), "step"),
|
|
162
|
+
// Dispatched-step suspends must escape the loop's tool catch — control flow, not a tool failure.
|
|
163
|
+
isControlFlowError: /* @__PURE__ */ __name((error) => error instanceof WorkflowSuspended || error instanceof ContinueAsNew, "isControlFlowError"),
|
|
67
164
|
runAgent: /* @__PURE__ */ __name(async (agentName, task) => {
|
|
68
165
|
const subThreadId = await ctx.localStep(`subthread:${agentName}`, async () => {
|
|
69
166
|
const thread = await this.store.createThread({
|
|
@@ -81,7 +178,20 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
81
178
|
delegationDepth: (input.delegationDepth ?? 0) + 1,
|
|
82
179
|
sinkRunId
|
|
83
180
|
});
|
|
84
|
-
}, "runAgent")
|
|
181
|
+
}, "runAgent"),
|
|
182
|
+
// Routes the two long steps through AgentRunSteps as engine-dispatched `ctx.step`s instead of
|
|
183
|
+
// `ctx.localStep`s, so a turn isn't pinned to this workflow worker for the model call or a tool
|
|
184
|
+
// execution. `sinkRunId`/`childSink` are sink routing this workflow already resolved above —
|
|
185
|
+
// core's dispatchLlm signature stays sink-topology-agnostic, so we add them here, not in core.
|
|
186
|
+
...this.dispatchedSteps ? {
|
|
187
|
+
dispatchLlm: /* @__PURE__ */ __name((_index, envelope) => ctx.step(this.steps.llm, {
|
|
188
|
+
...envelope,
|
|
189
|
+
runId: ctx.runId,
|
|
190
|
+
sinkRunId,
|
|
191
|
+
childSink: input.sinkRunId !== void 0
|
|
192
|
+
}), "dispatchLlm"),
|
|
193
|
+
dispatchTool: /* @__PURE__ */ __name((_call, envelope) => ctx.step(this.steps.tool, envelope), "dispatchTool")
|
|
194
|
+
} : {}
|
|
85
195
|
};
|
|
86
196
|
try {
|
|
87
197
|
const result = await runAgentLoop({
|
|
@@ -101,6 +211,12 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
101
211
|
code,
|
|
102
212
|
message
|
|
103
213
|
});
|
|
214
|
+
await ctx.localStep("persist:run:fail", () => this.store.recordRunEnd?.({
|
|
215
|
+
runId: ctx.runId,
|
|
216
|
+
status: "failed",
|
|
217
|
+
errorCode: code,
|
|
218
|
+
errorMessage: message
|
|
219
|
+
}) ?? Promise.resolve());
|
|
104
220
|
await ctx.localStep("deactivate", () => this.store.setActiveStream(input.threadId, null));
|
|
105
221
|
const writer = await hooks.openSink();
|
|
106
222
|
await writer.fail({
|
|
@@ -111,18 +227,21 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
111
227
|
}
|
|
112
228
|
}
|
|
113
229
|
};
|
|
114
|
-
AgentRunWorkflow =
|
|
115
|
-
|
|
230
|
+
AgentRunWorkflow = _ts_decorate2([
|
|
231
|
+
Injectable2(),
|
|
116
232
|
Workflow({
|
|
117
233
|
name: "agent.run",
|
|
118
234
|
version: "1"
|
|
119
235
|
}),
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
236
|
+
_ts_param2(0, Inject2(AGENT_DEPS_FACTORY2)),
|
|
237
|
+
_ts_param2(1, Inject2(AGENT_STORE)),
|
|
238
|
+
_ts_param2(3, Inject2(AGENT_DISPATCHED_STEPS)),
|
|
239
|
+
_ts_metadata2("design:type", Function),
|
|
240
|
+
_ts_metadata2("design:paramtypes", [
|
|
124
241
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
125
|
-
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
242
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
243
|
+
typeof AgentRunSteps === "undefined" ? Object : AgentRunSteps,
|
|
244
|
+
Boolean
|
|
126
245
|
])
|
|
127
246
|
], AgentRunWorkflow);
|
|
128
247
|
|
|
@@ -130,18 +249,18 @@ AgentRunWorkflow = _ts_decorate([
|
|
|
130
249
|
import { randomUUID } from "node:crypto";
|
|
131
250
|
import { WorkflowService } from "@dudousxd/nestjs-durable";
|
|
132
251
|
import { WorkflowSuspended as WorkflowSuspended2 } from "@dudousxd/nestjs-durable-core";
|
|
133
|
-
import { Injectable as
|
|
134
|
-
function
|
|
252
|
+
import { Injectable as Injectable3 } from "@nestjs/common";
|
|
253
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
135
254
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
136
255
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
137
256
|
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;
|
|
138
257
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
139
258
|
}
|
|
140
|
-
__name(
|
|
141
|
-
function
|
|
259
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
260
|
+
function _ts_metadata3(k, v) {
|
|
142
261
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
143
262
|
}
|
|
144
|
-
__name(
|
|
263
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
145
264
|
var DurableAgentRunner = class {
|
|
146
265
|
static {
|
|
147
266
|
__name(this, "DurableAgentRunner");
|
|
@@ -174,24 +293,95 @@ var DurableAgentRunner = class {
|
|
|
174
293
|
await Promise.resolve();
|
|
175
294
|
}
|
|
176
295
|
};
|
|
177
|
-
DurableAgentRunner =
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
296
|
+
DurableAgentRunner = _ts_decorate3([
|
|
297
|
+
Injectable3(),
|
|
298
|
+
_ts_metadata3("design:type", Function),
|
|
299
|
+
_ts_metadata3("design:paramtypes", [
|
|
181
300
|
typeof WorkflowService === "undefined" ? Object : WorkflowService
|
|
182
301
|
])
|
|
183
302
|
], DurableAgentRunner);
|
|
184
303
|
|
|
185
304
|
// src/durable/agent-durable.module.ts
|
|
186
|
-
import { AGENT_DURABLE_RUNNER } from "@dudousxd/nestjs-agent-core";
|
|
187
|
-
import { Global, Module } from "@nestjs/common";
|
|
188
|
-
|
|
305
|
+
import { AGENT_DURABLE_RUNNER, AGENT_OPTIONS, AGENT_SINK } from "@dudousxd/nestjs-agent-core";
|
|
306
|
+
import { Global, Logger, Module } from "@nestjs/common";
|
|
307
|
+
|
|
308
|
+
// src/in-process-sink.ts
|
|
309
|
+
import { AgentStreamError } from "@dudousxd/nestjs-agent-core";
|
|
310
|
+
var InProcessTokenStreamSink = class {
|
|
311
|
+
static {
|
|
312
|
+
__name(this, "InProcessTokenStreamSink");
|
|
313
|
+
}
|
|
314
|
+
runs = /* @__PURE__ */ new Map();
|
|
315
|
+
buffer(runId) {
|
|
316
|
+
let buf = this.runs.get(runId);
|
|
317
|
+
if (buf === void 0) {
|
|
318
|
+
buf = {
|
|
319
|
+
chunks: [],
|
|
320
|
+
ended: false,
|
|
321
|
+
notify: /* @__PURE__ */ new Set()
|
|
322
|
+
};
|
|
323
|
+
this.runs.set(runId, buf);
|
|
324
|
+
}
|
|
325
|
+
return buf;
|
|
326
|
+
}
|
|
327
|
+
wake(buf) {
|
|
328
|
+
for (const resolve of buf.notify) {
|
|
329
|
+
resolve();
|
|
330
|
+
}
|
|
331
|
+
buf.notify.clear();
|
|
332
|
+
}
|
|
333
|
+
open(runId) {
|
|
334
|
+
const buf = this.buffer(runId);
|
|
335
|
+
return {
|
|
336
|
+
write: /* @__PURE__ */ __name((chunk) => {
|
|
337
|
+
buf.chunks.push(chunk);
|
|
338
|
+
this.wake(buf);
|
|
339
|
+
}, "write"),
|
|
340
|
+
end: /* @__PURE__ */ __name(() => {
|
|
341
|
+
buf.ended = true;
|
|
342
|
+
this.wake(buf);
|
|
343
|
+
}, "end"),
|
|
344
|
+
fail: /* @__PURE__ */ __name((error) => {
|
|
345
|
+
buf.failure = error;
|
|
346
|
+
buf.ended = true;
|
|
347
|
+
this.wake(buf);
|
|
348
|
+
}, "fail")
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
async *subscribe(runId) {
|
|
352
|
+
const buf = this.buffer(runId);
|
|
353
|
+
let index = 0;
|
|
354
|
+
while (true) {
|
|
355
|
+
while (index < buf.chunks.length) {
|
|
356
|
+
const chunk = buf.chunks[index];
|
|
357
|
+
index += 1;
|
|
358
|
+
if (chunk !== void 0) {
|
|
359
|
+
yield chunk;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (buf.ended) {
|
|
363
|
+
if (buf.failure !== void 0) {
|
|
364
|
+
throw new AgentStreamError(buf.failure);
|
|
365
|
+
}
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
await new Promise((resolve) => buf.notify.add(resolve));
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
close(runId) {
|
|
372
|
+
this.runs.delete(runId);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
// src/durable/agent-durable.module.ts
|
|
377
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
189
378
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
190
379
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
191
380
|
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;
|
|
192
381
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
193
382
|
}
|
|
194
|
-
__name(
|
|
383
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
384
|
+
var logger = new Logger("AgentDurableModule");
|
|
195
385
|
var AgentDurableModule = class _AgentDurableModule {
|
|
196
386
|
static {
|
|
197
387
|
__name(this, "AgentDurableModule");
|
|
@@ -208,50 +398,67 @@ var AgentDurableModule = class _AgentDurableModule {
|
|
|
208
398
|
};
|
|
209
399
|
}
|
|
210
400
|
};
|
|
211
|
-
AgentDurableModule =
|
|
401
|
+
AgentDurableModule = _ts_decorate4([
|
|
212
402
|
Global(),
|
|
213
403
|
Module({
|
|
214
404
|
providers: [
|
|
215
405
|
AgentRunWorkflow,
|
|
406
|
+
AgentRunSteps,
|
|
216
407
|
DurableAgentRunner,
|
|
217
408
|
{
|
|
218
409
|
provide: AGENT_DURABLE_RUNNER,
|
|
219
410
|
useExisting: DurableAgentRunner
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
provide: AGENT_DISPATCHED_STEPS,
|
|
414
|
+
useFactory: /* @__PURE__ */ __name((options, sink) => {
|
|
415
|
+
const enabled = options.durable === true && options.dispatchedSteps !== false;
|
|
416
|
+
if (enabled && sink instanceof InProcessTokenStreamSink) {
|
|
417
|
+
logger.warn("Dispatched steps are active (the default under durable: true) 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, or set dispatchedSteps: false to keep the turn in-process localSteps.");
|
|
418
|
+
}
|
|
419
|
+
return enabled;
|
|
420
|
+
}, "useFactory"),
|
|
421
|
+
inject: [
|
|
422
|
+
AGENT_OPTIONS,
|
|
423
|
+
AGENT_SINK
|
|
424
|
+
]
|
|
220
425
|
}
|
|
221
426
|
],
|
|
222
427
|
exports: [
|
|
223
428
|
AGENT_DURABLE_RUNNER,
|
|
224
|
-
AgentRunWorkflow
|
|
429
|
+
AgentRunWorkflow,
|
|
430
|
+
AgentRunSteps,
|
|
431
|
+
AGENT_DISPATCHED_STEPS
|
|
225
432
|
]
|
|
226
433
|
})
|
|
227
434
|
], AgentDurableModule);
|
|
228
435
|
|
|
229
436
|
// src/agent.module.ts
|
|
230
|
-
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6, AGENT_DEPS_FACTORY as
|
|
437
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, AGENT_MODEL as AGENT_MODEL2, AGENT_OPTIONS as AGENT_OPTIONS5, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE3, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK3, AGENT_STORE as AGENT_STORE5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry5, DefaultRolesPolicy, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
231
438
|
import { Global as Global2, Module as Module2 } from "@nestjs/common";
|
|
232
439
|
import { DiscoveryModule, RouterModule } from "@nestjs/core";
|
|
233
440
|
|
|
234
441
|
// src/agent-deps.factory.ts
|
|
235
|
-
import { AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK, AGENT_STORE as AGENT_STORE2, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2 } from "@dudousxd/nestjs-agent-core";
|
|
236
|
-
import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
|
|
237
|
-
import { Inject as
|
|
238
|
-
function
|
|
442
|
+
import { AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK as AGENT_SINK2, AGENT_STORE as AGENT_STORE2, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2 } from "@dudousxd/nestjs-agent-core";
|
|
443
|
+
import { AGENT_OPTIONS as AGENT_OPTIONS2 } from "@dudousxd/nestjs-agent-core";
|
|
444
|
+
import { Inject as Inject3, Injectable as Injectable4, Optional } from "@nestjs/common";
|
|
445
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
239
446
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
240
447
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
241
448
|
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;
|
|
242
449
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
243
450
|
}
|
|
244
|
-
__name(
|
|
245
|
-
function
|
|
451
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
452
|
+
function _ts_metadata4(k, v) {
|
|
246
453
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
247
454
|
}
|
|
248
|
-
__name(
|
|
249
|
-
function
|
|
455
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
456
|
+
function _ts_param3(paramIndex, decorator) {
|
|
250
457
|
return function(target, key) {
|
|
251
458
|
decorator(target, key, paramIndex);
|
|
252
459
|
};
|
|
253
460
|
}
|
|
254
|
-
__name(
|
|
461
|
+
__name(_ts_param3, "_ts_param");
|
|
255
462
|
function delegateToolName(target) {
|
|
256
463
|
return `ask_${target.replace(/[^a-zA-Z0-9]+/g, "_")}`;
|
|
257
464
|
}
|
|
@@ -359,21 +566,21 @@ var AgentDepsFactory2 = class {
|
|
|
359
566
|
return void 0;
|
|
360
567
|
}
|
|
361
568
|
};
|
|
362
|
-
AgentDepsFactory2 =
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
569
|
+
AgentDepsFactory2 = _ts_decorate5([
|
|
570
|
+
Injectable4(),
|
|
571
|
+
_ts_param3(0, Inject3(AGENT_OPTIONS2)),
|
|
572
|
+
_ts_param3(1, Inject3(AGENT_MODEL)),
|
|
573
|
+
_ts_param3(2, Inject3(AGENT_STORE2)),
|
|
574
|
+
_ts_param3(3, Inject3(AGENT_SINK2)),
|
|
575
|
+
_ts_param3(4, Inject3(AGENT_ROLES_POLICY)),
|
|
576
|
+
_ts_param3(5, Inject3(AGENT_TOOL_REGISTRY)),
|
|
577
|
+
_ts_param3(6, Inject3(AGENT_REGISTRY)),
|
|
578
|
+
_ts_param3(7, Inject3(AGENT_PROMPT_CONTRIBUTORS)),
|
|
579
|
+
_ts_param3(8, Inject3(AGENT_QUOTA_STORE)),
|
|
580
|
+
_ts_param3(9, Optional()),
|
|
581
|
+
_ts_param3(9, Inject3(AGENT_PRICING_STORE)),
|
|
582
|
+
_ts_metadata4("design:type", Function),
|
|
583
|
+
_ts_metadata4("design:paramtypes", [
|
|
377
584
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
378
585
|
typeof ModelProvider === "undefined" ? Object : ModelProvider,
|
|
379
586
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
@@ -388,25 +595,25 @@ AgentDepsFactory2 = _ts_decorate4([
|
|
|
388
595
|
], AgentDepsFactory2);
|
|
389
596
|
|
|
390
597
|
// src/agent.service.ts
|
|
391
|
-
import { AGENT_DEPS_FACTORY as
|
|
392
|
-
import { BadRequestException, ForbiddenException, Inject as
|
|
393
|
-
function
|
|
598
|
+
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE3 } from "@dudousxd/nestjs-agent-core";
|
|
599
|
+
import { BadRequestException, ForbiddenException, Inject as Inject4, Injectable as Injectable5, NotFoundException, NotImplementedException } from "@nestjs/common";
|
|
600
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
394
601
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
395
602
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
396
603
|
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;
|
|
397
604
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
398
605
|
}
|
|
399
|
-
__name(
|
|
400
|
-
function
|
|
606
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
607
|
+
function _ts_metadata5(k, v) {
|
|
401
608
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
402
609
|
}
|
|
403
|
-
__name(
|
|
404
|
-
function
|
|
610
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
611
|
+
function _ts_param4(paramIndex, decorator) {
|
|
405
612
|
return function(target, key) {
|
|
406
613
|
decorator(target, key, paramIndex);
|
|
407
614
|
};
|
|
408
615
|
}
|
|
409
|
-
__name(
|
|
616
|
+
__name(_ts_param4, "_ts_param");
|
|
410
617
|
var AgentService = class {
|
|
411
618
|
static {
|
|
412
619
|
__name(this, "AgentService");
|
|
@@ -465,20 +672,32 @@ var AgentService = class {
|
|
|
465
672
|
return this.deps.forAgent().sink.subscribe(runId);
|
|
466
673
|
}
|
|
467
674
|
async approve(actor, toolCallId) {
|
|
468
|
-
|
|
469
|
-
return this.
|
|
675
|
+
await this.assertOwnsToolCall(actor, toolCallId);
|
|
676
|
+
return this.signalToolCall(toolCallId, {
|
|
470
677
|
approved: true
|
|
471
678
|
});
|
|
472
679
|
}
|
|
473
680
|
async reject(actor, toolCallId, reason) {
|
|
474
|
-
|
|
475
|
-
return this.
|
|
681
|
+
await this.assertOwnsToolCall(actor, toolCallId);
|
|
682
|
+
return this.signalToolCall(toolCallId, {
|
|
476
683
|
approved: false,
|
|
477
684
|
...reason !== void 0 ? {
|
|
478
685
|
reason
|
|
479
686
|
} : {}
|
|
480
687
|
});
|
|
481
688
|
}
|
|
689
|
+
/**
|
|
690
|
+
* The decision core behind approve/reject, WITHOUT an ownership check: resolves the run
|
|
691
|
+
* currently awaiting `toolCallId` and signals it. `approve`/`reject` above call this after their
|
|
692
|
+
* own `assertOwnsToolCall` gate; the console `AgentApprovalPort` adapter (bound by `AgentModule`)
|
|
693
|
+
* calls it directly — a console caller is already authorized by the dashboard's own guards, and
|
|
694
|
+
* re-deriving thread ownership here would reject a legitimate operator decision (an operator is
|
|
695
|
+
* not the thread's own actor).
|
|
696
|
+
*/
|
|
697
|
+
async signalToolCall(toolCallId, decision) {
|
|
698
|
+
const runId = await this.resolveRunForToolCall(toolCallId);
|
|
699
|
+
return this.runner.signal(runId, toolCallId, decision);
|
|
700
|
+
}
|
|
482
701
|
async cancel(actor, runId) {
|
|
483
702
|
await this.assertOwnsActiveStream(actor, runId);
|
|
484
703
|
return this.runner.cancel(runId);
|
|
@@ -626,12 +845,11 @@ var AgentService = class {
|
|
|
626
845
|
}
|
|
627
846
|
}
|
|
628
847
|
/**
|
|
629
|
-
* Authorization
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
* never knows or supplies a runId; it is derived here from the tool call alone.
|
|
848
|
+
* Authorization seam for HITL approve/reject: the caller must own the tool call's thread. Split
|
|
849
|
+
* out from run resolution (see {@link resolveRunForToolCall}) so the console `AgentApprovalPort`
|
|
850
|
+
* adapter can resolve+signal a decision WITHOUT this check — it is authorized upstream instead.
|
|
633
851
|
*/
|
|
634
|
-
async
|
|
852
|
+
async assertOwnsToolCall(actor, toolCallId) {
|
|
635
853
|
const owner = await this.store.ownerOfToolCall(toolCallId);
|
|
636
854
|
if (owner === null) {
|
|
637
855
|
throw new NotFoundException(`tool call ${toolCallId} not found`);
|
|
@@ -639,6 +857,13 @@ var AgentService = class {
|
|
|
639
857
|
if (owner !== actor.id) {
|
|
640
858
|
throw new ForbiddenException("tool call belongs to another actor");
|
|
641
859
|
}
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Resolve the run currently awaiting `toolCallId` (its thread's active stream). That run is the
|
|
863
|
+
* sub-agent's own child run when the pending call belongs to a delegated agent — the client never
|
|
864
|
+
* knows or supplies a runId; it is derived here from the tool call alone.
|
|
865
|
+
*/
|
|
866
|
+
async resolveRunForToolCall(toolCallId) {
|
|
642
867
|
const runId = await this.store.runForToolCall(toolCallId);
|
|
643
868
|
if (runId === null) {
|
|
644
869
|
throw new NotFoundException(`tool call ${toolCallId} has no active run to signal`);
|
|
@@ -656,14 +881,14 @@ var AgentService = class {
|
|
|
656
881
|
}
|
|
657
882
|
}
|
|
658
883
|
};
|
|
659
|
-
AgentService =
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
884
|
+
AgentService = _ts_decorate6([
|
|
885
|
+
Injectable5(),
|
|
886
|
+
_ts_param4(0, Inject4(AGENT_RUNNER)),
|
|
887
|
+
_ts_param4(1, Inject4(AGENT_STORE3)),
|
|
888
|
+
_ts_param4(2, Inject4(AGENT_DEPS_FACTORY3)),
|
|
889
|
+
_ts_param4(3, Inject4(AGENT_QUOTA_STORE2)),
|
|
890
|
+
_ts_metadata5("design:type", Function),
|
|
891
|
+
_ts_metadata5("design:paramtypes", [
|
|
667
892
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
668
893
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
669
894
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
@@ -671,26 +896,75 @@ AgentService = _ts_decorate5([
|
|
|
671
896
|
])
|
|
672
897
|
], AgentService);
|
|
673
898
|
|
|
899
|
+
// src/approval-port.adapter.ts
|
|
900
|
+
import { Injectable as Injectable6 } from "@nestjs/common";
|
|
901
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
902
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
903
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
904
|
+
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;
|
|
905
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
906
|
+
}
|
|
907
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
908
|
+
function _ts_metadata6(k, v) {
|
|
909
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
910
|
+
}
|
|
911
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
912
|
+
var AgentApprovalPortAdapter = class {
|
|
913
|
+
static {
|
|
914
|
+
__name(this, "AgentApprovalPortAdapter");
|
|
915
|
+
}
|
|
916
|
+
agent;
|
|
917
|
+
constructor(agent) {
|
|
918
|
+
this.agent = agent;
|
|
919
|
+
}
|
|
920
|
+
async approve(toolCallId, opts) {
|
|
921
|
+
await this.agent.signalToolCall(toolCallId, {
|
|
922
|
+
approved: true,
|
|
923
|
+
...opts?.executedByRef !== void 0 ? {
|
|
924
|
+
executedByRef: opts.executedByRef
|
|
925
|
+
} : {}
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
async reject(toolCallId, opts) {
|
|
929
|
+
await this.agent.signalToolCall(toolCallId, {
|
|
930
|
+
approved: false,
|
|
931
|
+
...opts?.executedByRef !== void 0 ? {
|
|
932
|
+
executedByRef: opts.executedByRef
|
|
933
|
+
} : {},
|
|
934
|
+
...opts?.reason !== void 0 ? {
|
|
935
|
+
reason: opts.reason
|
|
936
|
+
} : {}
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
AgentApprovalPortAdapter = _ts_decorate7([
|
|
941
|
+
Injectable6(),
|
|
942
|
+
_ts_metadata6("design:type", Function),
|
|
943
|
+
_ts_metadata6("design:paramtypes", [
|
|
944
|
+
typeof AgentService === "undefined" ? Object : AgentService
|
|
945
|
+
])
|
|
946
|
+
], AgentApprovalPortAdapter);
|
|
947
|
+
|
|
674
948
|
// src/controller/agents.controller.ts
|
|
675
|
-
import { AGENT_DEPS_FACTORY as
|
|
676
|
-
import { Controller, Get, Inject as
|
|
677
|
-
function
|
|
949
|
+
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_REGISTRY as AGENT_REGISTRY2, AgentRegistry as AgentRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
950
|
+
import { Controller, Get, Inject as Inject5 } from "@nestjs/common";
|
|
951
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
678
952
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
679
953
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
680
954
|
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;
|
|
681
955
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
682
956
|
}
|
|
683
|
-
__name(
|
|
684
|
-
function
|
|
957
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
958
|
+
function _ts_metadata7(k, v) {
|
|
685
959
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
686
960
|
}
|
|
687
|
-
__name(
|
|
688
|
-
function
|
|
961
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
962
|
+
function _ts_param5(paramIndex, decorator) {
|
|
689
963
|
return function(target, key) {
|
|
690
964
|
decorator(target, key, paramIndex);
|
|
691
965
|
};
|
|
692
966
|
}
|
|
693
|
-
__name(
|
|
967
|
+
__name(_ts_param5, "_ts_param");
|
|
694
968
|
var AgentsController = class {
|
|
695
969
|
static {
|
|
696
970
|
__name(this, "AgentsController");
|
|
@@ -712,44 +986,44 @@ var AgentsController = class {
|
|
|
712
986
|
}));
|
|
713
987
|
}
|
|
714
988
|
};
|
|
715
|
-
|
|
989
|
+
_ts_decorate8([
|
|
716
990
|
Get(),
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
991
|
+
_ts_metadata7("design:type", Function),
|
|
992
|
+
_ts_metadata7("design:paramtypes", []),
|
|
993
|
+
_ts_metadata7("design:returntype", Array)
|
|
720
994
|
], AgentsController.prototype, "list", null);
|
|
721
|
-
AgentsController =
|
|
995
|
+
AgentsController = _ts_decorate8([
|
|
722
996
|
Controller("agents"),
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
997
|
+
_ts_param5(0, Inject5(AGENT_REGISTRY2)),
|
|
998
|
+
_ts_param5(1, Inject5(AGENT_DEPS_FACTORY4)),
|
|
999
|
+
_ts_metadata7("design:type", Function),
|
|
1000
|
+
_ts_metadata7("design:paramtypes", [
|
|
727
1001
|
typeof AgentRegistry3 === "undefined" ? Object : AgentRegistry3,
|
|
728
1002
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
729
1003
|
])
|
|
730
1004
|
], AgentsController);
|
|
731
1005
|
|
|
732
1006
|
// src/controller/attachments.controller.ts
|
|
733
|
-
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING, AGENT_OPTIONS as
|
|
734
|
-
import { BadRequestException as BadRequestException2, Controller as Controller2, Inject as
|
|
1007
|
+
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING, AGENT_OPTIONS as AGENT_OPTIONS3 } from "@dudousxd/nestjs-agent-core";
|
|
1008
|
+
import { BadRequestException as BadRequestException2, Controller as Controller2, Inject as Inject6, NotImplementedException as NotImplementedException2, Optional as Optional2, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
|
|
735
1009
|
import { FileInterceptor } from "@nestjs/platform-express";
|
|
736
|
-
function
|
|
1010
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
737
1011
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
738
1012
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
739
1013
|
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;
|
|
740
1014
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
741
1015
|
}
|
|
742
|
-
__name(
|
|
743
|
-
function
|
|
1016
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1017
|
+
function _ts_metadata8(k, v) {
|
|
744
1018
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
745
1019
|
}
|
|
746
|
-
__name(
|
|
747
|
-
function
|
|
1020
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
1021
|
+
function _ts_param6(paramIndex, decorator) {
|
|
748
1022
|
return function(target, key) {
|
|
749
1023
|
decorator(target, key, paramIndex);
|
|
750
1024
|
};
|
|
751
1025
|
}
|
|
752
|
-
__name(
|
|
1026
|
+
__name(_ts_param6, "_ts_param");
|
|
753
1027
|
var DEFAULT_MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
|
|
754
1028
|
var DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES = [
|
|
755
1029
|
"image/png",
|
|
@@ -808,26 +1082,26 @@ var AttachmentsController = class {
|
|
|
808
1082
|
});
|
|
809
1083
|
}
|
|
810
1084
|
};
|
|
811
|
-
|
|
1085
|
+
_ts_decorate9([
|
|
812
1086
|
Post(),
|
|
813
1087
|
UseInterceptors(FileInterceptor("file")),
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
1088
|
+
_ts_param6(0, Req()),
|
|
1089
|
+
_ts_param6(1, UploadedFile()),
|
|
1090
|
+
_ts_metadata8("design:type", Function),
|
|
1091
|
+
_ts_metadata8("design:paramtypes", [
|
|
818
1092
|
typeof Request === "undefined" ? Object : Request,
|
|
819
1093
|
Object
|
|
820
1094
|
]),
|
|
821
|
-
|
|
1095
|
+
_ts_metadata8("design:returntype", Promise)
|
|
822
1096
|
], AttachmentsController.prototype, "upload", null);
|
|
823
|
-
AttachmentsController =
|
|
1097
|
+
AttachmentsController = _ts_decorate9([
|
|
824
1098
|
Controller2("attachments"),
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
1099
|
+
_ts_param6(0, Inject6(AGENT_OPTIONS3)),
|
|
1100
|
+
_ts_param6(1, Inject6(AGENT_ACTOR_RESOLVER)),
|
|
1101
|
+
_ts_param6(2, Optional2()),
|
|
1102
|
+
_ts_param6(2, Inject6(AGENT_ATTACHMENT_STAGING)),
|
|
1103
|
+
_ts_metadata8("design:type", Function),
|
|
1104
|
+
_ts_metadata8("design:paramtypes", [
|
|
831
1105
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
832
1106
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
833
1107
|
Object
|
|
@@ -835,25 +1109,25 @@ AttachmentsController = _ts_decorate7([
|
|
|
835
1109
|
], AttachmentsController);
|
|
836
1110
|
|
|
837
1111
|
// src/controller/chat.controller.ts
|
|
838
|
-
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError } from "@dudousxd/nestjs-agent-core";
|
|
839
|
-
import { Body, Controller as Controller3, Get as Get2, Inject as
|
|
840
|
-
function
|
|
1112
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError as AgentStreamError2 } from "@dudousxd/nestjs-agent-core";
|
|
1113
|
+
import { Body, Controller as Controller3, Get as Get2, Inject as Inject7, Param, Post as Post2, Req as Req2, Res } from "@nestjs/common";
|
|
1114
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
841
1115
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
842
1116
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
843
1117
|
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;
|
|
844
1118
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
845
1119
|
}
|
|
846
|
-
__name(
|
|
847
|
-
function
|
|
1120
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1121
|
+
function _ts_metadata9(k, v) {
|
|
848
1122
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
849
|
-
}
|
|
850
|
-
__name(
|
|
851
|
-
function
|
|
1123
|
+
}
|
|
1124
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
1125
|
+
function _ts_param7(paramIndex, decorator) {
|
|
852
1126
|
return function(target, key) {
|
|
853
1127
|
decorator(target, key, paramIndex);
|
|
854
1128
|
};
|
|
855
1129
|
}
|
|
856
|
-
__name(
|
|
1130
|
+
__name(_ts_param7, "_ts_param");
|
|
857
1131
|
var ChatController = class {
|
|
858
1132
|
static {
|
|
859
1133
|
__name(this, "ChatController");
|
|
@@ -941,7 +1215,7 @@ data: ${JSON.stringify({
|
|
|
941
1215
|
}
|
|
942
1216
|
res.write("event: done\ndata: {}\n\n");
|
|
943
1217
|
} catch (error) {
|
|
944
|
-
const payload = error instanceof
|
|
1218
|
+
const payload = error instanceof AgentStreamError2 ? {
|
|
945
1219
|
code: error.code,
|
|
946
1220
|
message: error.message
|
|
947
1221
|
} : {
|
|
@@ -956,46 +1230,46 @@ data: ${JSON.stringify(payload)}
|
|
|
956
1230
|
res.end();
|
|
957
1231
|
}
|
|
958
1232
|
};
|
|
959
|
-
|
|
1233
|
+
_ts_decorate10([
|
|
960
1234
|
Post2("chat"),
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
1235
|
+
_ts_param7(0, Req2()),
|
|
1236
|
+
_ts_param7(1, Res()),
|
|
1237
|
+
_ts_param7(2, Body()),
|
|
1238
|
+
_ts_metadata9("design:type", Function),
|
|
1239
|
+
_ts_metadata9("design:paramtypes", [
|
|
966
1240
|
typeof Request === "undefined" ? Object : Request,
|
|
967
1241
|
typeof Response === "undefined" ? Object : Response,
|
|
968
1242
|
typeof ChatBody === "undefined" ? Object : ChatBody
|
|
969
1243
|
]),
|
|
970
|
-
|
|
1244
|
+
_ts_metadata9("design:returntype", Promise)
|
|
971
1245
|
], ChatController.prototype, "chat", null);
|
|
972
|
-
|
|
1246
|
+
_ts_decorate10([
|
|
973
1247
|
Get2("chat/:runId/stream"),
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1248
|
+
_ts_param7(0, Param("runId")),
|
|
1249
|
+
_ts_param7(1, Res()),
|
|
1250
|
+
_ts_metadata9("design:type", Function),
|
|
1251
|
+
_ts_metadata9("design:paramtypes", [
|
|
978
1252
|
String,
|
|
979
1253
|
typeof Response === "undefined" ? Object : Response
|
|
980
1254
|
]),
|
|
981
|
-
|
|
1255
|
+
_ts_metadata9("design:returntype", Promise)
|
|
982
1256
|
], ChatController.prototype, "stream", null);
|
|
983
|
-
|
|
1257
|
+
_ts_decorate10([
|
|
984
1258
|
Post2("chat/:runId/cancel"),
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1259
|
+
_ts_param7(0, Req2()),
|
|
1260
|
+
_ts_param7(1, Param("runId")),
|
|
1261
|
+
_ts_metadata9("design:type", Function),
|
|
1262
|
+
_ts_metadata9("design:paramtypes", [
|
|
989
1263
|
typeof Request === "undefined" ? Object : Request,
|
|
990
1264
|
String
|
|
991
1265
|
]),
|
|
992
|
-
|
|
1266
|
+
_ts_metadata9("design:returntype", Promise)
|
|
993
1267
|
], ChatController.prototype, "cancel", null);
|
|
994
|
-
ChatController =
|
|
1268
|
+
ChatController = _ts_decorate10([
|
|
995
1269
|
Controller3(),
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1270
|
+
_ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER2)),
|
|
1271
|
+
_ts_metadata9("design:type", Function),
|
|
1272
|
+
_ts_metadata9("design:paramtypes", [
|
|
999
1273
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1000
1274
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1001
1275
|
])
|
|
@@ -1003,24 +1277,24 @@ ChatController = _ts_decorate8([
|
|
|
1003
1277
|
|
|
1004
1278
|
// src/controller/quota.controller.ts
|
|
1005
1279
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3 } from "@dudousxd/nestjs-agent-core";
|
|
1006
|
-
import { Controller as Controller4, Get as Get3, Inject as
|
|
1007
|
-
function
|
|
1280
|
+
import { Controller as Controller4, Get as Get3, Inject as Inject8, Req as Req3 } from "@nestjs/common";
|
|
1281
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1008
1282
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1009
1283
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1010
1284
|
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;
|
|
1011
1285
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1012
1286
|
}
|
|
1013
|
-
__name(
|
|
1014
|
-
function
|
|
1287
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1288
|
+
function _ts_metadata10(k, v) {
|
|
1015
1289
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1016
1290
|
}
|
|
1017
|
-
__name(
|
|
1018
|
-
function
|
|
1291
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
1292
|
+
function _ts_param8(paramIndex, decorator) {
|
|
1019
1293
|
return function(target, key) {
|
|
1020
1294
|
decorator(target, key, paramIndex);
|
|
1021
1295
|
};
|
|
1022
1296
|
}
|
|
1023
|
-
__name(
|
|
1297
|
+
__name(_ts_param8, "_ts_param");
|
|
1024
1298
|
var QuotaController = class {
|
|
1025
1299
|
static {
|
|
1026
1300
|
__name(this, "QuotaController");
|
|
@@ -1036,20 +1310,20 @@ var QuotaController = class {
|
|
|
1036
1310
|
return this.agent.quotaToday(actor.id);
|
|
1037
1311
|
}
|
|
1038
1312
|
};
|
|
1039
|
-
|
|
1313
|
+
_ts_decorate11([
|
|
1040
1314
|
Get3("today"),
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1315
|
+
_ts_param8(0, Req3()),
|
|
1316
|
+
_ts_metadata10("design:type", Function),
|
|
1317
|
+
_ts_metadata10("design:paramtypes", [
|
|
1044
1318
|
typeof Request === "undefined" ? Object : Request
|
|
1045
1319
|
]),
|
|
1046
|
-
|
|
1320
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1047
1321
|
], QuotaController.prototype, "today", null);
|
|
1048
|
-
QuotaController =
|
|
1322
|
+
QuotaController = _ts_decorate11([
|
|
1049
1323
|
Controller4("quota"),
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1324
|
+
_ts_param8(1, Inject8(AGENT_ACTOR_RESOLVER3)),
|
|
1325
|
+
_ts_metadata10("design:type", Function),
|
|
1326
|
+
_ts_metadata10("design:paramtypes", [
|
|
1053
1327
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1054
1328
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1055
1329
|
])
|
|
@@ -1057,24 +1331,24 @@ QuotaController = _ts_decorate9([
|
|
|
1057
1331
|
|
|
1058
1332
|
// src/controller/threads.controller.ts
|
|
1059
1333
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER4 } from "@dudousxd/nestjs-agent-core";
|
|
1060
|
-
import { Body as Body2, Controller as Controller5, Delete, Get as Get4, Inject as
|
|
1061
|
-
function
|
|
1334
|
+
import { Body as Body2, Controller as Controller5, Delete, Get as Get4, Inject as Inject9, Param as Param2, Patch, Post as Post3, Req as Req4 } from "@nestjs/common";
|
|
1335
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
1062
1336
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1063
1337
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1064
1338
|
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;
|
|
1065
1339
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1066
1340
|
}
|
|
1067
|
-
__name(
|
|
1068
|
-
function
|
|
1341
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
1342
|
+
function _ts_metadata11(k, v) {
|
|
1069
1343
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1070
1344
|
}
|
|
1071
|
-
__name(
|
|
1072
|
-
function
|
|
1345
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
1346
|
+
function _ts_param9(paramIndex, decorator) {
|
|
1073
1347
|
return function(target, key) {
|
|
1074
1348
|
decorator(target, key, paramIndex);
|
|
1075
1349
|
};
|
|
1076
1350
|
}
|
|
1077
|
-
__name(
|
|
1351
|
+
__name(_ts_param9, "_ts_param");
|
|
1078
1352
|
var ThreadsController = class {
|
|
1079
1353
|
static {
|
|
1080
1354
|
__name(this, "ThreadsController");
|
|
@@ -1138,92 +1412,92 @@ var ThreadsController = class {
|
|
|
1138
1412
|
};
|
|
1139
1413
|
}
|
|
1140
1414
|
};
|
|
1141
|
-
|
|
1415
|
+
_ts_decorate12([
|
|
1142
1416
|
Get4(),
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1417
|
+
_ts_param9(0, Req4()),
|
|
1418
|
+
_ts_metadata11("design:type", Function),
|
|
1419
|
+
_ts_metadata11("design:paramtypes", [
|
|
1146
1420
|
typeof Request === "undefined" ? Object : Request
|
|
1147
1421
|
]),
|
|
1148
|
-
|
|
1422
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1149
1423
|
], ThreadsController.prototype, "list", null);
|
|
1150
|
-
|
|
1424
|
+
_ts_decorate12([
|
|
1151
1425
|
Get4(":id"),
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1426
|
+
_ts_param9(0, Req4()),
|
|
1427
|
+
_ts_param9(1, Param2("id")),
|
|
1428
|
+
_ts_metadata11("design:type", Function),
|
|
1429
|
+
_ts_metadata11("design:paramtypes", [
|
|
1156
1430
|
typeof Request === "undefined" ? Object : Request,
|
|
1157
1431
|
String
|
|
1158
1432
|
]),
|
|
1159
|
-
|
|
1433
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1160
1434
|
], ThreadsController.prototype, "detail", null);
|
|
1161
|
-
|
|
1435
|
+
_ts_decorate12([
|
|
1162
1436
|
Delete(":id"),
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1437
|
+
_ts_param9(0, Req4()),
|
|
1438
|
+
_ts_param9(1, Param2("id")),
|
|
1439
|
+
_ts_metadata11("design:type", Function),
|
|
1440
|
+
_ts_metadata11("design:paramtypes", [
|
|
1167
1441
|
typeof Request === "undefined" ? Object : Request,
|
|
1168
1442
|
String
|
|
1169
1443
|
]),
|
|
1170
|
-
|
|
1444
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1171
1445
|
], ThreadsController.prototype, "remove", null);
|
|
1172
|
-
|
|
1446
|
+
_ts_decorate12([
|
|
1173
1447
|
Post3(":id/fork-from/:messageId"),
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1448
|
+
_ts_param9(0, Req4()),
|
|
1449
|
+
_ts_param9(1, Param2("id")),
|
|
1450
|
+
_ts_param9(2, Param2("messageId")),
|
|
1451
|
+
_ts_metadata11("design:type", Function),
|
|
1452
|
+
_ts_metadata11("design:paramtypes", [
|
|
1179
1453
|
typeof Request === "undefined" ? Object : Request,
|
|
1180
1454
|
String,
|
|
1181
1455
|
String
|
|
1182
1456
|
]),
|
|
1183
|
-
|
|
1457
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1184
1458
|
], ThreadsController.prototype, "fork", null);
|
|
1185
|
-
|
|
1459
|
+
_ts_decorate12([
|
|
1186
1460
|
Patch(":id"),
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1461
|
+
_ts_param9(0, Req4()),
|
|
1462
|
+
_ts_param9(1, Param2("id")),
|
|
1463
|
+
_ts_param9(2, Body2()),
|
|
1464
|
+
_ts_metadata11("design:type", Function),
|
|
1465
|
+
_ts_metadata11("design:paramtypes", [
|
|
1192
1466
|
typeof Request === "undefined" ? Object : Request,
|
|
1193
1467
|
String,
|
|
1194
1468
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
1195
1469
|
]),
|
|
1196
|
-
|
|
1470
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1197
1471
|
], ThreadsController.prototype, "update", null);
|
|
1198
|
-
|
|
1472
|
+
_ts_decorate12([
|
|
1199
1473
|
Post3(":id/promote"),
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1474
|
+
_ts_param9(0, Req4()),
|
|
1475
|
+
_ts_param9(1, Param2("id")),
|
|
1476
|
+
_ts_metadata11("design:type", Function),
|
|
1477
|
+
_ts_metadata11("design:paramtypes", [
|
|
1204
1478
|
typeof Request === "undefined" ? Object : Request,
|
|
1205
1479
|
String
|
|
1206
1480
|
]),
|
|
1207
|
-
|
|
1481
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1208
1482
|
], ThreadsController.prototype, "promote", null);
|
|
1209
|
-
|
|
1483
|
+
_ts_decorate12([
|
|
1210
1484
|
Delete(":id/from/:messageId"),
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1485
|
+
_ts_param9(0, Req4()),
|
|
1486
|
+
_ts_param9(1, Param2("id")),
|
|
1487
|
+
_ts_param9(2, Param2("messageId")),
|
|
1488
|
+
_ts_metadata11("design:type", Function),
|
|
1489
|
+
_ts_metadata11("design:paramtypes", [
|
|
1216
1490
|
typeof Request === "undefined" ? Object : Request,
|
|
1217
1491
|
String,
|
|
1218
1492
|
String
|
|
1219
1493
|
]),
|
|
1220
|
-
|
|
1494
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1221
1495
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
1222
|
-
ThreadsController =
|
|
1496
|
+
ThreadsController = _ts_decorate12([
|
|
1223
1497
|
Controller5("threads"),
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1498
|
+
_ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER4)),
|
|
1499
|
+
_ts_metadata11("design:type", Function),
|
|
1500
|
+
_ts_metadata11("design:paramtypes", [
|
|
1227
1501
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1228
1502
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1229
1503
|
])
|
|
@@ -1231,24 +1505,24 @@ ThreadsController = _ts_decorate10([
|
|
|
1231
1505
|
|
|
1232
1506
|
// src/controller/tool-call.controller.ts
|
|
1233
1507
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
|
|
1234
|
-
import { Body as Body3, Controller as Controller6, Inject as
|
|
1235
|
-
function
|
|
1508
|
+
import { Body as Body3, Controller as Controller6, Inject as Inject10, Post as Post4, Req as Req5 } from "@nestjs/common";
|
|
1509
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
1236
1510
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1237
1511
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1238
1512
|
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;
|
|
1239
1513
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1240
1514
|
}
|
|
1241
|
-
__name(
|
|
1242
|
-
function
|
|
1515
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
1516
|
+
function _ts_metadata12(k, v) {
|
|
1243
1517
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1244
1518
|
}
|
|
1245
|
-
__name(
|
|
1246
|
-
function
|
|
1519
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
1520
|
+
function _ts_param10(paramIndex, decorator) {
|
|
1247
1521
|
return function(target, key) {
|
|
1248
1522
|
decorator(target, key, paramIndex);
|
|
1249
1523
|
};
|
|
1250
1524
|
}
|
|
1251
|
-
__name(
|
|
1525
|
+
__name(_ts_param10, "_ts_param");
|
|
1252
1526
|
var ToolCallController = class {
|
|
1253
1527
|
static {
|
|
1254
1528
|
__name(this, "ToolCallController");
|
|
@@ -1274,33 +1548,33 @@ var ToolCallController = class {
|
|
|
1274
1548
|
};
|
|
1275
1549
|
}
|
|
1276
1550
|
};
|
|
1277
|
-
|
|
1551
|
+
_ts_decorate13([
|
|
1278
1552
|
Post4("approve"),
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1553
|
+
_ts_param10(0, Req5()),
|
|
1554
|
+
_ts_param10(1, Body3()),
|
|
1555
|
+
_ts_metadata12("design:type", Function),
|
|
1556
|
+
_ts_metadata12("design:paramtypes", [
|
|
1283
1557
|
typeof Request === "undefined" ? Object : Request,
|
|
1284
1558
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
1285
1559
|
]),
|
|
1286
|
-
|
|
1560
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1287
1561
|
], ToolCallController.prototype, "approve", null);
|
|
1288
|
-
|
|
1562
|
+
_ts_decorate13([
|
|
1289
1563
|
Post4("reject"),
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1564
|
+
_ts_param10(0, Req5()),
|
|
1565
|
+
_ts_param10(1, Body3()),
|
|
1566
|
+
_ts_metadata12("design:type", Function),
|
|
1567
|
+
_ts_metadata12("design:paramtypes", [
|
|
1294
1568
|
typeof Request === "undefined" ? Object : Request,
|
|
1295
1569
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
1296
1570
|
]),
|
|
1297
|
-
|
|
1571
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1298
1572
|
], ToolCallController.prototype, "reject", null);
|
|
1299
|
-
ToolCallController =
|
|
1573
|
+
ToolCallController = _ts_decorate13([
|
|
1300
1574
|
Controller6("tool-call"),
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1575
|
+
_ts_param10(1, Inject10(AGENT_ACTOR_RESOLVER5)),
|
|
1576
|
+
_ts_metadata12("design:type", Function),
|
|
1577
|
+
_ts_metadata12("design:paramtypes", [
|
|
1304
1578
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1305
1579
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1306
1580
|
])
|
|
@@ -1308,7 +1582,7 @@ ToolCallController = _ts_decorate11([
|
|
|
1308
1582
|
|
|
1309
1583
|
// src/discovery/agent-discovery.service.ts
|
|
1310
1584
|
import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY3, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
|
|
1311
|
-
import { Inject as
|
|
1585
|
+
import { Inject as Inject11, Injectable as Injectable7, Logger as Logger2 } from "@nestjs/common";
|
|
1312
1586
|
import { DiscoveryService, MetadataScanner } from "@nestjs/core";
|
|
1313
1587
|
|
|
1314
1588
|
// src/decorator/agent.decorator.ts
|
|
@@ -1325,23 +1599,23 @@ var SYSTEM_PROMPT_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt");
|
|
|
1325
1599
|
var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
|
|
1326
1600
|
|
|
1327
1601
|
// src/discovery/agent-discovery.service.ts
|
|
1328
|
-
function
|
|
1602
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
1329
1603
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1330
1604
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1331
1605
|
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;
|
|
1332
1606
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1333
1607
|
}
|
|
1334
|
-
__name(
|
|
1335
|
-
function
|
|
1608
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
1609
|
+
function _ts_metadata13(k, v) {
|
|
1336
1610
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1337
1611
|
}
|
|
1338
|
-
__name(
|
|
1339
|
-
function
|
|
1612
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
1613
|
+
function _ts_param11(paramIndex, decorator) {
|
|
1340
1614
|
return function(target, key) {
|
|
1341
1615
|
decorator(target, key, paramIndex);
|
|
1342
1616
|
};
|
|
1343
1617
|
}
|
|
1344
|
-
__name(
|
|
1618
|
+
__name(_ts_param11, "_ts_param");
|
|
1345
1619
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
1346
1620
|
static {
|
|
1347
1621
|
__name(this, "AgentDiscoveryService");
|
|
@@ -1350,7 +1624,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
1350
1624
|
scanner;
|
|
1351
1625
|
registry;
|
|
1352
1626
|
contributors;
|
|
1353
|
-
logger = new
|
|
1627
|
+
logger = new Logger2(_AgentDiscoveryService.name);
|
|
1354
1628
|
constructor(discovery, scanner, registry, contributors) {
|
|
1355
1629
|
this.discovery = discovery;
|
|
1356
1630
|
this.scanner = scanner;
|
|
@@ -1438,12 +1712,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
1438
1712
|
return (ctx) => candidate.call(instance, ctx);
|
|
1439
1713
|
}
|
|
1440
1714
|
};
|
|
1441
|
-
AgentDiscoveryService =
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1715
|
+
AgentDiscoveryService = _ts_decorate14([
|
|
1716
|
+
Injectable7(),
|
|
1717
|
+
_ts_param11(2, Inject11(AGENT_REGISTRY3)),
|
|
1718
|
+
_ts_param11(3, Inject11(AGENT_PROMPT_CONTRIBUTORS2)),
|
|
1719
|
+
_ts_metadata13("design:type", Function),
|
|
1720
|
+
_ts_metadata13("design:paramtypes", [
|
|
1447
1721
|
typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
|
|
1448
1722
|
typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
|
|
1449
1723
|
typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4,
|
|
@@ -1452,8 +1726,8 @@ AgentDiscoveryService = _ts_decorate12([
|
|
|
1452
1726
|
], AgentDiscoveryService);
|
|
1453
1727
|
|
|
1454
1728
|
// src/discovery/ai-tool-discovery.service.ts
|
|
1455
|
-
import { AGENT_OPTIONS as
|
|
1456
|
-
import { Inject as
|
|
1729
|
+
import { AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_REGISTRY as AGENT_REGISTRY4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2 } from "@dudousxd/nestjs-agent-core";
|
|
1730
|
+
import { Inject as Inject12, Injectable as Injectable8, Logger as Logger3 } from "@nestjs/common";
|
|
1457
1731
|
import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
|
|
1458
1732
|
import { z } from "zod";
|
|
1459
1733
|
|
|
@@ -1473,23 +1747,23 @@ function isBrandedFunctionalTool(value) {
|
|
|
1473
1747
|
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
1474
1748
|
|
|
1475
1749
|
// src/discovery/ai-tool-discovery.service.ts
|
|
1476
|
-
function
|
|
1750
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
1477
1751
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1478
1752
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1479
1753
|
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;
|
|
1480
1754
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1481
1755
|
}
|
|
1482
|
-
__name(
|
|
1483
|
-
function
|
|
1756
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
1757
|
+
function _ts_metadata14(k, v) {
|
|
1484
1758
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1485
1759
|
}
|
|
1486
|
-
__name(
|
|
1487
|
-
function
|
|
1760
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
1761
|
+
function _ts_param12(paramIndex, decorator) {
|
|
1488
1762
|
return function(target, key) {
|
|
1489
1763
|
decorator(target, key, paramIndex);
|
|
1490
1764
|
};
|
|
1491
1765
|
}
|
|
1492
|
-
__name(
|
|
1766
|
+
__name(_ts_param12, "_ts_param");
|
|
1493
1767
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
1494
1768
|
static {
|
|
1495
1769
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -1498,7 +1772,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
1498
1772
|
registry;
|
|
1499
1773
|
agents;
|
|
1500
1774
|
options;
|
|
1501
|
-
logger = new
|
|
1775
|
+
logger = new Logger3(_AiToolDiscoveryService.name);
|
|
1502
1776
|
constructor(discovery, registry, agents, options) {
|
|
1503
1777
|
this.discovery = discovery;
|
|
1504
1778
|
this.registry = registry;
|
|
@@ -1596,13 +1870,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
1596
1870
|
return true;
|
|
1597
1871
|
}
|
|
1598
1872
|
};
|
|
1599
|
-
AiToolDiscoveryService =
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1873
|
+
AiToolDiscoveryService = _ts_decorate15([
|
|
1874
|
+
Injectable8(),
|
|
1875
|
+
_ts_param12(1, Inject12(AGENT_TOOL_REGISTRY2)),
|
|
1876
|
+
_ts_param12(2, Inject12(AGENT_REGISTRY4)),
|
|
1877
|
+
_ts_param12(3, Inject12(AGENT_OPTIONS4)),
|
|
1878
|
+
_ts_metadata14("design:type", Function),
|
|
1879
|
+
_ts_metadata14("design:paramtypes", [
|
|
1606
1880
|
typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
|
|
1607
1881
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
1608
1882
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -1610,74 +1884,6 @@ AiToolDiscoveryService = _ts_decorate13([
|
|
|
1610
1884
|
])
|
|
1611
1885
|
], AiToolDiscoveryService);
|
|
1612
1886
|
|
|
1613
|
-
// src/in-process-sink.ts
|
|
1614
|
-
import { AgentStreamError as AgentStreamError2 } from "@dudousxd/nestjs-agent-core";
|
|
1615
|
-
var InProcessTokenStreamSink = class {
|
|
1616
|
-
static {
|
|
1617
|
-
__name(this, "InProcessTokenStreamSink");
|
|
1618
|
-
}
|
|
1619
|
-
runs = /* @__PURE__ */ new Map();
|
|
1620
|
-
buffer(runId) {
|
|
1621
|
-
let buf = this.runs.get(runId);
|
|
1622
|
-
if (buf === void 0) {
|
|
1623
|
-
buf = {
|
|
1624
|
-
chunks: [],
|
|
1625
|
-
ended: false,
|
|
1626
|
-
notify: /* @__PURE__ */ new Set()
|
|
1627
|
-
};
|
|
1628
|
-
this.runs.set(runId, buf);
|
|
1629
|
-
}
|
|
1630
|
-
return buf;
|
|
1631
|
-
}
|
|
1632
|
-
wake(buf) {
|
|
1633
|
-
for (const resolve of buf.notify) {
|
|
1634
|
-
resolve();
|
|
1635
|
-
}
|
|
1636
|
-
buf.notify.clear();
|
|
1637
|
-
}
|
|
1638
|
-
open(runId) {
|
|
1639
|
-
const buf = this.buffer(runId);
|
|
1640
|
-
return {
|
|
1641
|
-
write: /* @__PURE__ */ __name((chunk) => {
|
|
1642
|
-
buf.chunks.push(chunk);
|
|
1643
|
-
this.wake(buf);
|
|
1644
|
-
}, "write"),
|
|
1645
|
-
end: /* @__PURE__ */ __name(() => {
|
|
1646
|
-
buf.ended = true;
|
|
1647
|
-
this.wake(buf);
|
|
1648
|
-
}, "end"),
|
|
1649
|
-
fail: /* @__PURE__ */ __name((error) => {
|
|
1650
|
-
buf.failure = error;
|
|
1651
|
-
buf.ended = true;
|
|
1652
|
-
this.wake(buf);
|
|
1653
|
-
}, "fail")
|
|
1654
|
-
};
|
|
1655
|
-
}
|
|
1656
|
-
async *subscribe(runId) {
|
|
1657
|
-
const buf = this.buffer(runId);
|
|
1658
|
-
let index = 0;
|
|
1659
|
-
while (true) {
|
|
1660
|
-
while (index < buf.chunks.length) {
|
|
1661
|
-
const chunk = buf.chunks[index];
|
|
1662
|
-
index += 1;
|
|
1663
|
-
if (chunk !== void 0) {
|
|
1664
|
-
yield chunk;
|
|
1665
|
-
}
|
|
1666
|
-
}
|
|
1667
|
-
if (buf.ended) {
|
|
1668
|
-
if (buf.failure !== void 0) {
|
|
1669
|
-
throw new AgentStreamError2(buf.failure);
|
|
1670
|
-
}
|
|
1671
|
-
return;
|
|
1672
|
-
}
|
|
1673
|
-
await new Promise((resolve) => buf.notify.add(resolve));
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
close(runId) {
|
|
1677
|
-
this.runs.delete(runId);
|
|
1678
|
-
}
|
|
1679
|
-
};
|
|
1680
|
-
|
|
1681
1887
|
// src/ledger-quota-store.ts
|
|
1682
1888
|
var LedgerQuotaStore = class {
|
|
1683
1889
|
static {
|
|
@@ -1702,32 +1908,32 @@ var LedgerQuotaStore = class {
|
|
|
1702
1908
|
};
|
|
1703
1909
|
|
|
1704
1910
|
// src/runner/inline-agent-runner.ts
|
|
1705
|
-
import { AGENT_DEPS_FACTORY as
|
|
1706
|
-
import { Inject as
|
|
1707
|
-
function
|
|
1911
|
+
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_STORE as AGENT_STORE4, QuotaExceededError as QuotaExceededError2, publishAgentRunFailed as publishAgentRunFailed2, runAgentLoop as runAgentLoop2 } from "@dudousxd/nestjs-agent-core";
|
|
1912
|
+
import { Inject as Inject13, Injectable as Injectable9, Logger as Logger4 } from "@nestjs/common";
|
|
1913
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
1708
1914
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1709
1915
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1710
1916
|
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;
|
|
1711
1917
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1712
1918
|
}
|
|
1713
|
-
__name(
|
|
1714
|
-
function
|
|
1919
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
1920
|
+
function _ts_metadata15(k, v) {
|
|
1715
1921
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1716
1922
|
}
|
|
1717
|
-
__name(
|
|
1718
|
-
function
|
|
1923
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
1924
|
+
function _ts_param13(paramIndex, decorator) {
|
|
1719
1925
|
return function(target, key) {
|
|
1720
1926
|
decorator(target, key, paramIndex);
|
|
1721
1927
|
};
|
|
1722
1928
|
}
|
|
1723
|
-
__name(
|
|
1929
|
+
__name(_ts_param13, "_ts_param");
|
|
1724
1930
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
1725
1931
|
static {
|
|
1726
1932
|
__name(this, "InlineAgentRunner");
|
|
1727
1933
|
}
|
|
1728
1934
|
factory;
|
|
1729
1935
|
store;
|
|
1730
|
-
logger = new
|
|
1936
|
+
logger = new Logger4(_InlineAgentRunner.name);
|
|
1731
1937
|
pending = /* @__PURE__ */ new Map();
|
|
1732
1938
|
constructor(factory, store) {
|
|
1733
1939
|
this.factory = factory;
|
|
@@ -1750,6 +1956,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1750
1956
|
code,
|
|
1751
1957
|
message
|
|
1752
1958
|
});
|
|
1959
|
+
await this.store.recordRunEnd?.({
|
|
1960
|
+
runId,
|
|
1961
|
+
status: "failed",
|
|
1962
|
+
errorCode: code,
|
|
1963
|
+
errorMessage: message
|
|
1964
|
+
});
|
|
1753
1965
|
await this.store.setActiveStream(input.threadId, null);
|
|
1754
1966
|
const writer = await deps.sink.open(runId);
|
|
1755
1967
|
await writer.fail({
|
|
@@ -1826,25 +2038,25 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1826
2038
|
}
|
|
1827
2039
|
}
|
|
1828
2040
|
};
|
|
1829
|
-
InlineAgentRunner =
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
2041
|
+
InlineAgentRunner = _ts_decorate16([
|
|
2042
|
+
Injectable9(),
|
|
2043
|
+
_ts_param13(0, Inject13(AGENT_DEPS_FACTORY5)),
|
|
2044
|
+
_ts_param13(1, Inject13(AGENT_STORE4)),
|
|
2045
|
+
_ts_metadata15("design:type", Function),
|
|
2046
|
+
_ts_metadata15("design:paramtypes", [
|
|
1835
2047
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1836
2048
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
1837
2049
|
])
|
|
1838
2050
|
], InlineAgentRunner);
|
|
1839
2051
|
|
|
1840
2052
|
// src/agent.module.ts
|
|
1841
|
-
function
|
|
2053
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
1842
2054
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1843
2055
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1844
2056
|
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;
|
|
1845
2057
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1846
2058
|
}
|
|
1847
|
-
__name(
|
|
2059
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
1848
2060
|
var DEFAULT_PATH = "agent";
|
|
1849
2061
|
function sharedProviders(durable, includeStore) {
|
|
1850
2062
|
const providers = [
|
|
@@ -1863,31 +2075,31 @@ function sharedProviders(durable, includeStore) {
|
|
|
1863
2075
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
1864
2076
|
},
|
|
1865
2077
|
{
|
|
1866
|
-
provide:
|
|
2078
|
+
provide: AGENT_SINK3,
|
|
1867
2079
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
1868
2080
|
inject: [
|
|
1869
|
-
|
|
2081
|
+
AGENT_OPTIONS5
|
|
1870
2082
|
]
|
|
1871
2083
|
},
|
|
1872
2084
|
{
|
|
1873
2085
|
provide: AGENT_ROLES_POLICY2,
|
|
1874
2086
|
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
1875
2087
|
inject: [
|
|
1876
|
-
|
|
2088
|
+
AGENT_OPTIONS5
|
|
1877
2089
|
]
|
|
1878
2090
|
},
|
|
1879
2091
|
{
|
|
1880
2092
|
provide: AGENT_ACTOR_RESOLVER6,
|
|
1881
2093
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
1882
2094
|
inject: [
|
|
1883
|
-
|
|
2095
|
+
AGENT_OPTIONS5
|
|
1884
2096
|
]
|
|
1885
2097
|
},
|
|
1886
2098
|
{
|
|
1887
2099
|
provide: AGENT_MODEL2,
|
|
1888
2100
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
1889
2101
|
inject: [
|
|
1890
|
-
|
|
2102
|
+
AGENT_OPTIONS5
|
|
1891
2103
|
]
|
|
1892
2104
|
},
|
|
1893
2105
|
{
|
|
@@ -1897,13 +2109,13 @@ function sharedProviders(durable, includeStore) {
|
|
|
1897
2109
|
provide: AGENT_QUOTA_STORE3,
|
|
1898
2110
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
1899
2111
|
inject: [
|
|
1900
|
-
|
|
2112
|
+
AGENT_OPTIONS5,
|
|
1901
2113
|
AGENT_STORE5
|
|
1902
2114
|
]
|
|
1903
2115
|
},
|
|
1904
2116
|
AgentDepsFactory2,
|
|
1905
2117
|
{
|
|
1906
|
-
provide:
|
|
2118
|
+
provide: AGENT_DEPS_FACTORY6,
|
|
1907
2119
|
useExisting: AgentDepsFactory2
|
|
1908
2120
|
},
|
|
1909
2121
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -1911,14 +2123,21 @@ function sharedProviders(durable, includeStore) {
|
|
|
1911
2123
|
AgentDiscoveryService,
|
|
1912
2124
|
AiToolDiscoveryService,
|
|
1913
2125
|
InlineAgentRunner,
|
|
1914
|
-
AgentService
|
|
2126
|
+
AgentService,
|
|
2127
|
+
// Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
|
|
2128
|
+
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
2129
|
+
AgentApprovalPortAdapter,
|
|
2130
|
+
{
|
|
2131
|
+
provide: AGENT_APPROVAL_PORT,
|
|
2132
|
+
useExisting: AgentApprovalPortAdapter
|
|
2133
|
+
}
|
|
1915
2134
|
];
|
|
1916
2135
|
if (includeStore) {
|
|
1917
2136
|
providers.push({
|
|
1918
2137
|
provide: AGENT_STORE5,
|
|
1919
2138
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
1920
2139
|
inject: [
|
|
1921
|
-
|
|
2140
|
+
AGENT_OPTIONS5
|
|
1922
2141
|
]
|
|
1923
2142
|
});
|
|
1924
2143
|
}
|
|
@@ -1949,10 +2168,10 @@ function sharedProviders(durable, includeStore) {
|
|
|
1949
2168
|
__name(sharedProviders, "sharedProviders");
|
|
1950
2169
|
function exportsFor(includeStore) {
|
|
1951
2170
|
return [
|
|
1952
|
-
|
|
2171
|
+
AGENT_OPTIONS5,
|
|
1953
2172
|
AGENT_TOOL_REGISTRY3,
|
|
1954
2173
|
AGENT_REGISTRY5,
|
|
1955
|
-
|
|
2174
|
+
AGENT_SINK3,
|
|
1956
2175
|
AGENT_ROLES_POLICY2,
|
|
1957
2176
|
AGENT_ACTOR_RESOLVER6,
|
|
1958
2177
|
AGENT_MODEL2,
|
|
@@ -1961,10 +2180,11 @@ function exportsFor(includeStore) {
|
|
|
1961
2180
|
] : [],
|
|
1962
2181
|
AGENT_QUOTA_STORE3,
|
|
1963
2182
|
AGENT_PROMPT_CONTRIBUTORS3,
|
|
1964
|
-
|
|
2183
|
+
AGENT_DEPS_FACTORY6,
|
|
1965
2184
|
AgentDepsFactory2,
|
|
1966
2185
|
AgentService,
|
|
1967
|
-
InlineAgentRunner
|
|
2186
|
+
InlineAgentRunner,
|
|
2187
|
+
AGENT_APPROVAL_PORT
|
|
1968
2188
|
];
|
|
1969
2189
|
}
|
|
1970
2190
|
__name(exportsFor, "exportsFor");
|
|
@@ -2009,11 +2229,18 @@ function routerFor(path) {
|
|
|
2009
2229
|
]);
|
|
2010
2230
|
}
|
|
2011
2231
|
__name(routerFor, "routerFor");
|
|
2232
|
+
function assertDispatchedStepsRequiresDurable(dispatchedSteps, durable) {
|
|
2233
|
+
if (dispatchedSteps && !durable) {
|
|
2234
|
+
throw new Error("AgentModule dispatchedSteps: true requires durable: true \u2014 dispatched steps are routed durable steps (AgentRunSteps.llm/tool) with no in-process equivalent.");
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
__name(assertDispatchedStepsRequiresDurable, "assertDispatchedStepsRequiresDurable");
|
|
2012
2238
|
var AgentModule = class _AgentModule {
|
|
2013
2239
|
static {
|
|
2014
2240
|
__name(this, "AgentModule");
|
|
2015
2241
|
}
|
|
2016
2242
|
static forRoot(options) {
|
|
2243
|
+
assertDispatchedStepsRequiresDurable(options.dispatchedSteps ?? false, options.durable ?? false);
|
|
2017
2244
|
const path = options.path ?? DEFAULT_PATH;
|
|
2018
2245
|
const includeStore = options.store !== void 0;
|
|
2019
2246
|
applyGuards(options.guards);
|
|
@@ -2027,7 +2254,7 @@ var AgentModule = class _AgentModule {
|
|
|
2027
2254
|
controllers: controllersFor(options.attachments?.upload === true),
|
|
2028
2255
|
providers: [
|
|
2029
2256
|
{
|
|
2030
|
-
provide:
|
|
2257
|
+
provide: AGENT_OPTIONS5,
|
|
2031
2258
|
useValue: options
|
|
2032
2259
|
},
|
|
2033
2260
|
...sharedProviders(options.durable ?? false, includeStore),
|
|
@@ -2037,6 +2264,7 @@ var AgentModule = class _AgentModule {
|
|
|
2037
2264
|
};
|
|
2038
2265
|
}
|
|
2039
2266
|
static forRootAsync(options) {
|
|
2267
|
+
assertDispatchedStepsRequiresDurable(options.dispatchedSteps ?? false, options.durable ?? false);
|
|
2040
2268
|
const path = options.path ?? DEFAULT_PATH;
|
|
2041
2269
|
const includeStore = options.externalStore !== true;
|
|
2042
2270
|
applyGuards(options.guards);
|
|
@@ -2051,8 +2279,18 @@ var AgentModule = class _AgentModule {
|
|
|
2051
2279
|
controllers: controllersFor(options.attachmentsUpload === true),
|
|
2052
2280
|
providers: [
|
|
2053
2281
|
{
|
|
2054
|
-
provide:
|
|
2055
|
-
|
|
2282
|
+
provide: AGENT_OPTIONS5,
|
|
2283
|
+
// Stamp the STATIC wiring flags onto the factory result: `durable`/`dispatchedSteps` are
|
|
2284
|
+
// authoritative on the async config object (they decided the actual wiring above), and
|
|
2285
|
+
// `AgentDurableModule` derives the effective dispatched-steps value from AGENT_OPTIONS —
|
|
2286
|
+
// without this stamp, an async host would get in-process localSteps despite durable: true.
|
|
2287
|
+
useFactory: /* @__PURE__ */ __name(async (...args) => ({
|
|
2288
|
+
...await options.useFactory(...args),
|
|
2289
|
+
durable: options.durable ?? false,
|
|
2290
|
+
...options.dispatchedSteps !== void 0 ? {
|
|
2291
|
+
dispatchedSteps: options.dispatchedSteps
|
|
2292
|
+
} : {}
|
|
2293
|
+
}), "useFactory"),
|
|
2056
2294
|
inject: options.inject ?? []
|
|
2057
2295
|
},
|
|
2058
2296
|
...sharedProviders(options.durable ?? false, includeStore),
|
|
@@ -2062,7 +2300,7 @@ var AgentModule = class _AgentModule {
|
|
|
2062
2300
|
};
|
|
2063
2301
|
}
|
|
2064
2302
|
};
|
|
2065
|
-
AgentModule =
|
|
2303
|
+
AgentModule = _ts_decorate17([
|
|
2066
2304
|
Global2(),
|
|
2067
2305
|
Module2({})
|
|
2068
2306
|
], AgentModule);
|
|
@@ -2079,7 +2317,9 @@ function agentDurable(options) {
|
|
|
2079
2317
|
}
|
|
2080
2318
|
__name(agentDurable, "agentDurable");
|
|
2081
2319
|
export {
|
|
2320
|
+
AGENT_DISPATCHED_STEPS,
|
|
2082
2321
|
AgentDurableModule,
|
|
2322
|
+
AgentRunSteps,
|
|
2083
2323
|
AgentRunWorkflow,
|
|
2084
2324
|
DurableAgentRunner,
|
|
2085
2325
|
agentDurable
|