@dudousxd/nestjs-agent 1.20.0 → 1.21.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/README.md +51 -0
- package/dist/{chat-queue.service-C0hr7dqx.d.ts → chat-queue.service-CGsR40Ct.d.cts} +16 -2
- package/dist/{chat-queue.service-C0hr7dqx.d.cts → chat-queue.service-XG9RQCjU.d.ts} +16 -2
- package/dist/durable/index.cjs +1556 -830
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +3 -1
- package/dist/durable/index.d.ts +3 -1
- package/dist/durable/index.js +1290 -564
- package/dist/durable/index.js.map +1 -1
- package/dist/genui/index.d.cts +1 -1
- package/dist/genui/index.d.ts +1 -1
- package/dist/index.cjs +1487 -825
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +111 -9
- package/dist/index.d.ts +111 -9
- package/dist/index.js +1258 -599
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/durable/index.cjs
CHANGED
|
@@ -30,7 +30,7 @@ __export(durable_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(durable_exports);
|
|
31
31
|
|
|
32
32
|
// src/durable/agent-run.workflow.ts
|
|
33
|
-
var
|
|
33
|
+
var import_nestjs_agent_core4 = require("@dudousxd/nestjs-agent-core");
|
|
34
34
|
var import_nestjs_durable2 = require("@dudousxd/nestjs-durable");
|
|
35
35
|
var import_nestjs_durable_core2 = require("@dudousxd/nestjs-durable-core");
|
|
36
36
|
var import_common2 = require("@nestjs/common");
|
|
@@ -62,6 +62,8 @@ var AGENT_CHAT_QUEUE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:chat-q
|
|
|
62
62
|
|
|
63
63
|
// src/durable/agent-run.steps.ts
|
|
64
64
|
var import_nestjs_agent_core = require("@dudousxd/nestjs-agent-core");
|
|
65
|
+
var import_nestjs_agent_core2 = require("@dudousxd/nestjs-agent-core");
|
|
66
|
+
var import_nestjs_agent_core3 = require("@dudousxd/nestjs-agent-core");
|
|
65
67
|
var import_nestjs_durable = require("@dudousxd/nestjs-durable");
|
|
66
68
|
var import_common = require("@nestjs/common");
|
|
67
69
|
|
|
@@ -122,19 +124,22 @@ var AgentRunSteps = class {
|
|
|
122
124
|
}
|
|
123
125
|
async runLlm(input) {
|
|
124
126
|
const deps = this.factory.forAgent(input.agentName);
|
|
125
|
-
const tools = (0,
|
|
126
|
-
tools: (0,
|
|
127
|
-
tools: (0,
|
|
127
|
+
const tools = (0, import_nestjs_agent_core3.withMemoryTool)({
|
|
128
|
+
tools: (0, import_nestjs_agent_core3.withSkillTool)({
|
|
129
|
+
tools: (0, import_nestjs_agent_core3.withAskTool)({
|
|
128
130
|
tools: await deps.registry.definitionsFor(
|
|
129
131
|
input.actor,
|
|
130
132
|
deps.rolesPolicy,
|
|
131
133
|
// The persona narrowing the loop journaled in `persona:resolve` rides the envelope:
|
|
132
134
|
// this worker's own persona config may already say something else.
|
|
133
|
-
(0,
|
|
135
|
+
(0, import_nestjs_agent_core3.intersectAllowLists)(deps.toolAllowList, input.personaAllowedTools),
|
|
134
136
|
{
|
|
135
137
|
...input.threadId !== void 0 ? {
|
|
136
138
|
threadId: input.threadId
|
|
137
139
|
} : {},
|
|
140
|
+
...input.preflightContext?.uiCapabilities !== void 0 ? {
|
|
141
|
+
uiCapabilities: input.preflightContext.uiCapabilities
|
|
142
|
+
} : {},
|
|
138
143
|
...input.agentName !== void 0 ? {
|
|
139
144
|
agentName: input.agentName
|
|
140
145
|
} : {}
|
|
@@ -146,7 +151,7 @@ var AgentRunSteps = class {
|
|
|
146
151
|
}),
|
|
147
152
|
enabled: deps.memory?.provider.write !== void 0
|
|
148
153
|
});
|
|
149
|
-
const buffer = input.bufferOutput === true ? (0,
|
|
154
|
+
const buffer = input.bufferOutput === true ? (0, import_nestjs_agent_core3.createFrameBuffer)() : void 0;
|
|
150
155
|
let writer;
|
|
151
156
|
if (buffer !== void 0) {
|
|
152
157
|
writer = buffer.writer;
|
|
@@ -154,8 +159,8 @@ var AgentRunSteps = class {
|
|
|
154
159
|
const opened = await deps.sink.open(input.sinkRunId);
|
|
155
160
|
writer = input.childSink ? childSinkWriter(opened) : opened;
|
|
156
161
|
}
|
|
157
|
-
const frames = (0,
|
|
158
|
-
const turn = (0,
|
|
162
|
+
const frames = (0, import_nestjs_agent_core3.observeTurnFrames)(writer);
|
|
163
|
+
const turn = (0, import_nestjs_agent_core3.withTurnFrames)(await (0, import_nestjs_agent_core3.traceLlmTurn)(input.runId, input.step, () => deps.model.runTurn({
|
|
159
164
|
system: input.system,
|
|
160
165
|
messages: input.messages,
|
|
161
166
|
tools,
|
|
@@ -164,7 +169,68 @@ var AgentRunSteps = class {
|
|
|
164
169
|
model: input.model
|
|
165
170
|
} : {}
|
|
166
171
|
})), frames.summary());
|
|
167
|
-
const stamped = (0,
|
|
172
|
+
const stamped = (0, import_nestjs_agent_core3.stampToolKinds)(turn, deps);
|
|
173
|
+
const allowedTools = (0, import_nestjs_agent_core3.intersectAllowLists)(deps.toolAllowList, input.personaAllowedTools);
|
|
174
|
+
for (const call of stamped.toolCalls) {
|
|
175
|
+
if (call.kind !== "action") continue;
|
|
176
|
+
try {
|
|
177
|
+
const context = input.preflightContext ?? {
|
|
178
|
+
actor: input.actor,
|
|
179
|
+
threadId: input.threadId ?? "",
|
|
180
|
+
runId: input.runId,
|
|
181
|
+
requestId: input.runId,
|
|
182
|
+
...input.agentName !== void 0 ? {
|
|
183
|
+
agentName: input.agentName
|
|
184
|
+
} : {}
|
|
185
|
+
};
|
|
186
|
+
if (input.actionApprovalMode === "independent") {
|
|
187
|
+
const spec = deps.registry.spec(call.name);
|
|
188
|
+
call.actionApproval = await (0, import_nestjs_agent_core2.resolveActionProposalApproval)({
|
|
189
|
+
actor: input.actor,
|
|
190
|
+
store: deps.store,
|
|
191
|
+
tool: {
|
|
192
|
+
name: call.name,
|
|
193
|
+
kind: "action",
|
|
194
|
+
...spec !== void 0 ? {
|
|
195
|
+
spec
|
|
196
|
+
} : {}
|
|
197
|
+
},
|
|
198
|
+
thread: {
|
|
199
|
+
threadId: context.threadId,
|
|
200
|
+
runId: input.runId,
|
|
201
|
+
...input.agentName !== void 0 ? {
|
|
202
|
+
agentName: input.agentName
|
|
203
|
+
} : {}
|
|
204
|
+
},
|
|
205
|
+
...deps.approvalPolicy !== void 0 ? {
|
|
206
|
+
policy: deps.approvalPolicy
|
|
207
|
+
} : {}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
if (call.actionApproval?.mode === "ask") {
|
|
211
|
+
call.prepared = await (0, import_nestjs_agent_core2.prepareActionProposal)(deps.registry, call.name, call.input, {
|
|
212
|
+
...(0, import_nestjs_agent_core3.toolCallContext)(context, call.id),
|
|
213
|
+
emitUi: (0, import_nestjs_agent_core3.createNoopEmitUi)(call.id)
|
|
214
|
+
}, deps.rolesPolicy, allowedTools === void 0 ? {} : {
|
|
215
|
+
allowedTools
|
|
216
|
+
});
|
|
217
|
+
call.preflight = call.prepared.preflight;
|
|
218
|
+
} else {
|
|
219
|
+
call.preflight = await deps.registry.prepare(call.name, call.input, {
|
|
220
|
+
...(0, import_nestjs_agent_core3.toolCallContext)(context, call.id),
|
|
221
|
+
emitUi: (0, import_nestjs_agent_core3.createNoopEmitUi)(call.id)
|
|
222
|
+
}, deps.rolesPolicy, allowedTools === void 0 ? {} : {
|
|
223
|
+
allowedTools
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
} catch (error) {
|
|
227
|
+
if ((0, import_nestjs_agent_core3.isControlFlowSignal)(error) || (0, import_nestjs_agent_core3.isReplayIntegrityError)(error)) throw error;
|
|
228
|
+
call.preflight = {
|
|
229
|
+
status: "failed",
|
|
230
|
+
error: error instanceof Error ? error.message : String(error)
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
168
234
|
return buffer === void 0 ? stamped : {
|
|
169
235
|
...stamped,
|
|
170
236
|
bufferedFrames: buffer.frames()
|
|
@@ -190,12 +256,12 @@ var AgentRunSteps = class {
|
|
|
190
256
|
}
|
|
191
257
|
const sinkRunId = input.sinkRunId;
|
|
192
258
|
let opened;
|
|
193
|
-
const ui = (0, import_nestjs_agent_core.
|
|
259
|
+
const ui = (0, import_nestjs_agent_core.createNegotiatedUiCollector)(input.toolCallId, input.ctx, deps.resolveUiCatalog, sinkRunId === void 0 ? void 0 : async (event) => {
|
|
194
260
|
opened ??= Promise.resolve(deps.sink.open(sinkRunId)).then((writer) => input.childSink === true ? childSinkWriter(writer) : writer);
|
|
195
|
-
await (await opened).write((0,
|
|
261
|
+
await (await opened).write((0, import_nestjs_agent_core3.encodeStreamEvent)(event));
|
|
196
262
|
});
|
|
197
263
|
const ctx = {
|
|
198
|
-
...(0,
|
|
264
|
+
...(0, import_nestjs_agent_core3.toolCallContext)(input.ctx, input.toolCallId),
|
|
199
265
|
emitUi: ui.emit
|
|
200
266
|
};
|
|
201
267
|
const localClassify = deps.toolTransientRetry !== false ? deps.toolTransientRetry?.classify : void 0;
|
|
@@ -206,27 +272,38 @@ var AgentRunSteps = class {
|
|
|
206
272
|
classify: localClassify
|
|
207
273
|
} : {}
|
|
208
274
|
};
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
toolName: input.toolName,
|
|
223
|
-
toolCallId: input.toolCallId,
|
|
224
|
-
attempt,
|
|
225
|
-
message: error instanceof Error ? error.message : String(error)
|
|
275
|
+
const allowedTools = (0, import_nestjs_agent_core3.intersectAllowLists)(deps.toolAllowList, input.allowedTools === void 0 ? void 0 : [
|
|
276
|
+
...input.allowedTools
|
|
277
|
+
]);
|
|
278
|
+
let output;
|
|
279
|
+
try {
|
|
280
|
+
output = await (0, import_nestjs_agent_core3.traceToolExecution)(input.ctx.runId, {
|
|
281
|
+
toolCallId: input.toolCallId,
|
|
282
|
+
toolName: input.toolName,
|
|
283
|
+
toolType: input.toolType
|
|
284
|
+
}, () => (0, import_nestjs_agent_core3.invokeWithTransientRetry)(() => {
|
|
285
|
+
ui.restart();
|
|
286
|
+
const invocation = deps.registry.invoke(input.toolName, input.input, ctx, deps.rolesPolicy, allowedTools === void 0 ? {} : {
|
|
287
|
+
allowedTools
|
|
226
288
|
});
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
289
|
+
return input.timeoutMs !== void 0 ? (0, import_nestjs_agent_core3.withToolTimeout)(invocation, input.timeoutMs, input.toolName) : invocation;
|
|
290
|
+
}, transientRetry, {
|
|
291
|
+
onRetry: /* @__PURE__ */ __name((attempt, error) => {
|
|
292
|
+
(0, import_nestjs_agent_core3.publishAgentToolRetry)({
|
|
293
|
+
toolName: input.toolName,
|
|
294
|
+
toolCallId: input.toolCallId,
|
|
295
|
+
attempt,
|
|
296
|
+
message: error instanceof Error ? error.message : String(error)
|
|
297
|
+
});
|
|
298
|
+
}, "onRetry")
|
|
299
|
+
}));
|
|
300
|
+
} catch (error) {
|
|
301
|
+
if (error instanceof Error && error.name === "ToolPreflightDeniedError") {
|
|
302
|
+
return (0, import_nestjs_agent_core3.wrapToolPreflightDenied)(error.message);
|
|
303
|
+
}
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
306
|
+
return input.collectUi === true ? (0, import_nestjs_agent_core3.wrapToolStepOutput)(output, ui.components(), ui.text()) : output;
|
|
230
307
|
}
|
|
231
308
|
};
|
|
232
309
|
_ts_decorate([
|
|
@@ -249,7 +326,7 @@ _ts_decorate([
|
|
|
249
326
|
], AgentRunSteps.prototype, "tool", null);
|
|
250
327
|
AgentRunSteps = _ts_decorate([
|
|
251
328
|
(0, import_common.Injectable)(),
|
|
252
|
-
_ts_param(0, (0, import_common.Inject)(
|
|
329
|
+
_ts_param(0, (0, import_common.Inject)(import_nestjs_agent_core3.AGENT_DEPS_FACTORY)),
|
|
253
330
|
_ts_metadata("design:type", Function),
|
|
254
331
|
_ts_metadata("design:paramtypes", [
|
|
255
332
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
@@ -433,7 +510,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
433
510
|
if (delivery === void 0) {
|
|
434
511
|
return;
|
|
435
512
|
}
|
|
436
|
-
await stepOf(ctx)("deliver:detached:unsettled", () => (0,
|
|
513
|
+
await stepOf(ctx)("deliver:detached:unsettled", () => (0, import_nestjs_agent_core4.settleUnsettledDelegation)({
|
|
437
514
|
store: this.store,
|
|
438
515
|
delivery,
|
|
439
516
|
agent: input.agentName ?? "default",
|
|
@@ -474,7 +551,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
474
551
|
end: /* @__PURE__ */ __name(async () => {
|
|
475
552
|
const frame = await this.advanceQueue(ctx, input, "completed");
|
|
476
553
|
if (frame !== void 0) {
|
|
477
|
-
await writer.write((0,
|
|
554
|
+
await writer.write((0, import_nestjs_agent_core4.encodeStreamEvent)(frame));
|
|
478
555
|
}
|
|
479
556
|
await writer.end();
|
|
480
557
|
}, "end")
|
|
@@ -506,7 +583,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
506
583
|
// await, so launching a batch in one tick — what `settleAll` does — fixes the block of
|
|
507
584
|
// positions in call order however the tools then settle. `ctx.patched` keeps a run that
|
|
508
585
|
// recorded the one-call-at-a-time shape replaying against that shape.
|
|
509
|
-
parallel:
|
|
586
|
+
parallel: import_nestjs_agent_core4.settleAll,
|
|
510
587
|
cancelled: /* @__PURE__ */ __name(() => this.isCancelled(ctx.runId), "cancelled"),
|
|
511
588
|
patched: /* @__PURE__ */ __name((id) => ctx.patched(id), "patched"),
|
|
512
589
|
// Dispatched-step suspends must escape the loop's tool catch — control flow, not a tool
|
|
@@ -609,33 +686,33 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
609
686
|
} : {}
|
|
610
687
|
};
|
|
611
688
|
try {
|
|
612
|
-
const result = await (0,
|
|
689
|
+
const result = await (0, import_nestjs_agent_core4.runAgentLoop)({
|
|
613
690
|
...deps,
|
|
614
691
|
day
|
|
615
692
|
}, input, hooks);
|
|
616
|
-
await stepOf(ctx)("deactivate", () => (0,
|
|
693
|
+
await stepOf(ctx)("deactivate", () => (0, import_nestjs_agent_core4.releaseThreadRun)(this.store, input.threadId, ctx.runId));
|
|
617
694
|
return result;
|
|
618
695
|
} catch (error) {
|
|
619
696
|
if ((0, import_nestjs_durable_core2.isWorkflowControlFlowSignal)(error)) {
|
|
620
697
|
throw error;
|
|
621
698
|
}
|
|
622
|
-
if (error instanceof
|
|
623
|
-
await stepOf(ctx)("deactivate", () => (0,
|
|
699
|
+
if (error instanceof import_nestjs_agent_core4.RunCancelledError) {
|
|
700
|
+
await stepOf(ctx)("deactivate", () => (0, import_nestjs_agent_core4.releaseThreadRun)(this.store, input.threadId, ctx.runId));
|
|
624
701
|
await this.settleDetachedParent(ctx, input, {
|
|
625
702
|
status: "cancelled"
|
|
626
703
|
});
|
|
627
704
|
throw error;
|
|
628
705
|
}
|
|
629
|
-
if ((0,
|
|
706
|
+
if ((0, import_nestjs_agent_core4.isReplayIntegrityError)(error)) {
|
|
630
707
|
const detail = error.message;
|
|
631
|
-
const code2 = (0,
|
|
708
|
+
const code2 = (0, import_nestjs_agent_core4.agentFailureCode)(error);
|
|
632
709
|
this.logger.error(`agent run ${ctx.runId} failed (${code2}): ${detail}`);
|
|
633
|
-
(0,
|
|
710
|
+
(0, import_nestjs_agent_core4.publishAgentRunFailed)({
|
|
634
711
|
runId: ctx.runId,
|
|
635
712
|
code: code2,
|
|
636
713
|
message: detail
|
|
637
714
|
});
|
|
638
|
-
await (0,
|
|
715
|
+
await (0, import_nestjs_agent_core4.settleDeadRun)(this.store, {
|
|
639
716
|
runId: ctx.runId,
|
|
640
717
|
threadId: input.threadId,
|
|
641
718
|
failure: {
|
|
@@ -643,13 +720,13 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
643
720
|
message: detail
|
|
644
721
|
}
|
|
645
722
|
});
|
|
646
|
-
await (await hooks.openSink()).fail((0,
|
|
723
|
+
await (await hooks.openSink()).fail((0, import_nestjs_agent_core4.streamFailure)(error));
|
|
647
724
|
throw error;
|
|
648
725
|
}
|
|
649
726
|
const message = error instanceof Error ? error.message : String(error);
|
|
650
|
-
const code = (0,
|
|
727
|
+
const code = (0, import_nestjs_agent_core4.agentFailureCode)(error);
|
|
651
728
|
this.logger.error(`agent run ${ctx.runId} failed (${code}): ${message}`);
|
|
652
|
-
(0,
|
|
729
|
+
(0, import_nestjs_agent_core4.publishAgentRunFailed)({
|
|
653
730
|
runId: ctx.runId,
|
|
654
731
|
code,
|
|
655
732
|
message
|
|
@@ -661,19 +738,19 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
661
738
|
errorCode: code,
|
|
662
739
|
errorMessage: message
|
|
663
740
|
});
|
|
664
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(ctx.runId,
|
|
741
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(ctx.runId, import_nestjs_agent_core4.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
665
742
|
});
|
|
666
743
|
const queueFrame2 = await this.advanceQueue(ctx, input, "failed", message);
|
|
667
|
-
await stepOf(ctx)("deactivate", () => (0,
|
|
744
|
+
await stepOf(ctx)("deactivate", () => (0, import_nestjs_agent_core4.releaseThreadRun)(this.store, input.threadId, ctx.runId));
|
|
668
745
|
await this.settleDetachedParent(ctx, input, {
|
|
669
746
|
status: "failed",
|
|
670
747
|
error: message
|
|
671
748
|
});
|
|
672
749
|
const writer = await hooks.openSink();
|
|
673
750
|
if (queueFrame2 !== void 0) {
|
|
674
|
-
await writer.write((0,
|
|
751
|
+
await writer.write((0, import_nestjs_agent_core4.encodeStreamEvent)(queueFrame2));
|
|
675
752
|
}
|
|
676
|
-
await writer.fail((0,
|
|
753
|
+
await writer.fail((0, import_nestjs_agent_core4.streamFailure)(error));
|
|
677
754
|
throw error;
|
|
678
755
|
}
|
|
679
756
|
}
|
|
@@ -684,8 +761,8 @@ AgentRunWorkflow = _ts_decorate2([
|
|
|
684
761
|
name: "agent.run",
|
|
685
762
|
version: "1"
|
|
686
763
|
}),
|
|
687
|
-
_ts_param2(0, (0, import_common2.Inject)(
|
|
688
|
-
_ts_param2(1, (0, import_common2.Inject)(
|
|
764
|
+
_ts_param2(0, (0, import_common2.Inject)(import_nestjs_agent_core4.AGENT_DEPS_FACTORY)),
|
|
765
|
+
_ts_param2(1, (0, import_common2.Inject)(import_nestjs_agent_core4.AGENT_STORE)),
|
|
689
766
|
_ts_param2(2, (0, import_common2.Optional)()),
|
|
690
767
|
_ts_param2(2, (0, import_common2.Inject)(import_nestjs_durable2.RUN_GATEWAY)),
|
|
691
768
|
_ts_param2(3, (0, import_common2.Optional)()),
|
|
@@ -707,13 +784,13 @@ __name(isSignalTimeout, "isSignalTimeout");
|
|
|
707
784
|
|
|
708
785
|
// src/durable/durable-agent-runner.ts
|
|
709
786
|
var import_node_crypto = require("crypto");
|
|
710
|
-
var
|
|
787
|
+
var import_nestjs_agent_core6 = require("@dudousxd/nestjs-agent-core");
|
|
711
788
|
var import_nestjs_durable3 = require("@dudousxd/nestjs-durable");
|
|
712
789
|
var import_nestjs_durable_core3 = require("@dudousxd/nestjs-durable-core");
|
|
713
790
|
var import_common3 = require("@nestjs/common");
|
|
714
791
|
|
|
715
792
|
// src/in-process-sink.ts
|
|
716
|
-
var
|
|
793
|
+
var import_nestjs_agent_core5 = require("@dudousxd/nestjs-agent-core");
|
|
717
794
|
var InProcessTokenStreamSink = class {
|
|
718
795
|
static {
|
|
719
796
|
__name(this, "InProcessTokenStreamSink");
|
|
@@ -768,7 +845,7 @@ var InProcessTokenStreamSink = class {
|
|
|
768
845
|
}
|
|
769
846
|
if (buf.ended) {
|
|
770
847
|
if (buf.failure !== void 0) {
|
|
771
|
-
throw new
|
|
848
|
+
throw new import_nestjs_agent_core5.AgentStreamError(buf.failure);
|
|
772
849
|
}
|
|
773
850
|
return;
|
|
774
851
|
}
|
|
@@ -933,15 +1010,15 @@ var DurableAgentRunner = class _DurableAgentRunner {
|
|
|
933
1010
|
runId: nextRunId
|
|
934
1011
|
}));
|
|
935
1012
|
if (frame !== void 0) {
|
|
936
|
-
await writer.write((0,
|
|
1013
|
+
await writer.write((0, import_nestjs_agent_core6.encodeStreamEvent)(frame));
|
|
937
1014
|
}
|
|
938
1015
|
} catch (error) {
|
|
939
1016
|
this.logger.error(`could not advance the queue of thread ${threadId} after cancelling ${runId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
940
1017
|
}
|
|
941
1018
|
}
|
|
942
|
-
await (0,
|
|
1019
|
+
await (0, import_nestjs_agent_core6.releaseThreadRun)(this.store, threadId, runId);
|
|
943
1020
|
}
|
|
944
|
-
await writer.write((0,
|
|
1021
|
+
await writer.write((0, import_nestjs_agent_core6.encodeStreamEvent)({
|
|
945
1022
|
kind: "cancelled"
|
|
946
1023
|
}));
|
|
947
1024
|
await writer.end();
|
|
@@ -964,7 +1041,7 @@ var DurableAgentRunner = class _DurableAgentRunner {
|
|
|
964
1041
|
return;
|
|
965
1042
|
}
|
|
966
1043
|
try {
|
|
967
|
-
await (0,
|
|
1044
|
+
await (0, import_nestjs_agent_core6.settleUnsettledDelegation)({
|
|
968
1045
|
store: this.store,
|
|
969
1046
|
delivery: target.delivery,
|
|
970
1047
|
agent: target.agent,
|
|
@@ -987,11 +1064,11 @@ var DurableAgentRunner = class _DurableAgentRunner {
|
|
|
987
1064
|
}
|
|
988
1065
|
const subThreadId = threadOfRun(child.run.input);
|
|
989
1066
|
if (subThreadId !== void 0) {
|
|
990
|
-
await (0,
|
|
1067
|
+
await (0, import_nestjs_agent_core6.releaseThreadRun)(this.store, subThreadId, childId);
|
|
991
1068
|
}
|
|
992
1069
|
await this.settleCancelledDelegation(childId, child.run.input);
|
|
993
1070
|
const writer = await this.sink.open(childId);
|
|
994
|
-
await writer.write((0,
|
|
1071
|
+
await writer.write((0, import_nestjs_agent_core6.encodeStreamEvent)({
|
|
995
1072
|
kind: "cancelled"
|
|
996
1073
|
}));
|
|
997
1074
|
await writer.end();
|
|
@@ -1021,8 +1098,8 @@ var DurableAgentRunner = class _DurableAgentRunner {
|
|
|
1021
1098
|
DurableAgentRunner = _ts_decorate3([
|
|
1022
1099
|
(0, import_common3.Injectable)(),
|
|
1023
1100
|
_ts_param3(1, (0, import_common3.Inject)(import_nestjs_durable3.RUN_GATEWAY)),
|
|
1024
|
-
_ts_param3(2, (0, import_common3.Inject)(
|
|
1025
|
-
_ts_param3(3, (0, import_common3.Inject)(
|
|
1101
|
+
_ts_param3(2, (0, import_common3.Inject)(import_nestjs_agent_core6.AGENT_STORE)),
|
|
1102
|
+
_ts_param3(3, (0, import_common3.Inject)(import_nestjs_agent_core6.AGENT_SINK)),
|
|
1026
1103
|
_ts_param3(4, (0, import_common3.Optional)()),
|
|
1027
1104
|
_ts_param3(4, (0, import_common3.Inject)(AGENT_CHAT_QUEUE)),
|
|
1028
1105
|
_ts_metadata3("design:type", Function),
|
|
@@ -1036,7 +1113,7 @@ DurableAgentRunner = _ts_decorate3([
|
|
|
1036
1113
|
], DurableAgentRunner);
|
|
1037
1114
|
|
|
1038
1115
|
// src/durable/agent-durable.module.ts
|
|
1039
|
-
var
|
|
1116
|
+
var import_nestjs_agent_core7 = require("@dudousxd/nestjs-agent-core");
|
|
1040
1117
|
var import_common4 = require("@nestjs/common");
|
|
1041
1118
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
1042
1119
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1056,7 +1133,7 @@ function runnerProviders() {
|
|
|
1056
1133
|
return [
|
|
1057
1134
|
DurableAgentRunner,
|
|
1058
1135
|
{
|
|
1059
|
-
provide:
|
|
1136
|
+
provide: import_nestjs_agent_core7.AGENT_DURABLE_RUNNER,
|
|
1060
1137
|
useExisting: DurableAgentRunner
|
|
1061
1138
|
}
|
|
1062
1139
|
];
|
|
@@ -1075,7 +1152,7 @@ AgentDurableHttpModule = _ts_decorate4([
|
|
|
1075
1152
|
...runnerProviders()
|
|
1076
1153
|
],
|
|
1077
1154
|
exports: [
|
|
1078
|
-
|
|
1155
|
+
import_nestjs_agent_core7.AGENT_DURABLE_RUNNER,
|
|
1079
1156
|
AgentRunWorkflow
|
|
1080
1157
|
]
|
|
1081
1158
|
})
|
|
@@ -1114,7 +1191,7 @@ AgentDurableModule = _ts_decorate4([
|
|
|
1114
1191
|
...runnerProviders()
|
|
1115
1192
|
],
|
|
1116
1193
|
exports: [
|
|
1117
|
-
|
|
1194
|
+
import_nestjs_agent_core7.AGENT_DURABLE_RUNNER,
|
|
1118
1195
|
AgentRunWorkflow,
|
|
1119
1196
|
AgentRunSteps
|
|
1120
1197
|
]
|
|
@@ -1122,14 +1199,44 @@ AgentDurableModule = _ts_decorate4([
|
|
|
1122
1199
|
], AgentDurableModule);
|
|
1123
1200
|
|
|
1124
1201
|
// src/agent.module.ts
|
|
1125
|
-
var
|
|
1126
|
-
var
|
|
1202
|
+
var import_nestjs_agent_core37 = require("@dudousxd/nestjs-agent-core");
|
|
1203
|
+
var import_common31 = require("@nestjs/common");
|
|
1127
1204
|
var import_core4 = require("@nestjs/core");
|
|
1128
1205
|
|
|
1129
1206
|
// src/agent-deps.factory.ts
|
|
1130
|
-
var
|
|
1131
|
-
var
|
|
1207
|
+
var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
1208
|
+
var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
|
|
1209
|
+
var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
|
|
1210
|
+
var import_common6 = require("@nestjs/common");
|
|
1211
|
+
|
|
1212
|
+
// src/genui/agent-genui.module.ts
|
|
1213
|
+
var import_genui = require("@dudousxd/nestjs-agent-core/genui");
|
|
1132
1214
|
var import_common5 = require("@nestjs/common");
|
|
1215
|
+
|
|
1216
|
+
// src/functional-tool.ts
|
|
1217
|
+
var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
|
|
1218
|
+
function brand(tool) {
|
|
1219
|
+
return {
|
|
1220
|
+
[AGENT_TOOL_BRAND]: true,
|
|
1221
|
+
spec: tool.spec,
|
|
1222
|
+
handler: tool.handler
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
__name(brand, "brand");
|
|
1226
|
+
function isBrandedFunctionalTool(value) {
|
|
1227
|
+
return AGENT_TOOL_BRAND in value && "spec" in value && "handler" in value;
|
|
1228
|
+
}
|
|
1229
|
+
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
1230
|
+
function provideAgentTools(factory, inject) {
|
|
1231
|
+
return {
|
|
1232
|
+
provide: /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-list"),
|
|
1233
|
+
useFactory: /* @__PURE__ */ __name(async (...deps) => (await factory(...deps)).map(brand), "useFactory"),
|
|
1234
|
+
inject: inject ?? []
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
__name(provideAgentTools, "provideAgentTools");
|
|
1238
|
+
|
|
1239
|
+
// src/genui/agent-genui.module.ts
|
|
1133
1240
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
1134
1241
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1135
1242
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1144,6 +1251,124 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
1144
1251
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1145
1252
|
}
|
|
1146
1253
|
__name(_ts_decorate5, "_ts_decorate");
|
|
1254
|
+
var GENUI_CATALOG = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-catalog");
|
|
1255
|
+
var GENUI_OPTIONS = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-options");
|
|
1256
|
+
var GenuiCatalogResolver = class {
|
|
1257
|
+
static {
|
|
1258
|
+
__name(this, "GenuiCatalogResolver");
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
function resolverProviders(resolver) {
|
|
1262
|
+
if (resolver === void 0) return [];
|
|
1263
|
+
return [
|
|
1264
|
+
typeof resolver === "function" ? {
|
|
1265
|
+
provide: GenuiCatalogResolver,
|
|
1266
|
+
useClass: resolver
|
|
1267
|
+
} : {
|
|
1268
|
+
provide: GenuiCatalogResolver,
|
|
1269
|
+
useValue: resolver
|
|
1270
|
+
}
|
|
1271
|
+
];
|
|
1272
|
+
}
|
|
1273
|
+
__name(resolverProviders, "resolverProviders");
|
|
1274
|
+
function toolOptions(options, resolver) {
|
|
1275
|
+
const { catalog: _catalog, ...rest } = options;
|
|
1276
|
+
return {
|
|
1277
|
+
...rest,
|
|
1278
|
+
...resolver !== void 0 ? {
|
|
1279
|
+
resolveCatalog: /* @__PURE__ */ __name((scope) => resolver.resolve(scope), "resolveCatalog")
|
|
1280
|
+
} : {}
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
__name(toolOptions, "toolOptions");
|
|
1284
|
+
function coreProviders(resolver) {
|
|
1285
|
+
return [
|
|
1286
|
+
{
|
|
1287
|
+
provide: GENUI_CATALOG,
|
|
1288
|
+
useFactory: /* @__PURE__ */ __name((options) => options.catalog ?? (0, import_genui.defineCatalog)([]), "useFactory"),
|
|
1289
|
+
inject: [
|
|
1290
|
+
GENUI_OPTIONS
|
|
1291
|
+
]
|
|
1292
|
+
},
|
|
1293
|
+
...resolverProviders(resolver),
|
|
1294
|
+
// The generated tools, registered by the agent module's discovery like any `provideAgentTool`.
|
|
1295
|
+
// Built from the injected catalog, so `overrideProvider(GENUI_CATALOG)` changes them too.
|
|
1296
|
+
provideAgentTools((options, catalog, perRequest) => (0, import_genui.genuiTools)(catalog, toolOptions(options, perRequest)), [
|
|
1297
|
+
GENUI_OPTIONS,
|
|
1298
|
+
GENUI_CATALOG,
|
|
1299
|
+
{
|
|
1300
|
+
token: GenuiCatalogResolver,
|
|
1301
|
+
optional: true
|
|
1302
|
+
}
|
|
1303
|
+
])
|
|
1304
|
+
];
|
|
1305
|
+
}
|
|
1306
|
+
__name(coreProviders, "coreProviders");
|
|
1307
|
+
var EXPORTS = [
|
|
1308
|
+
GENUI_CATALOG,
|
|
1309
|
+
GENUI_OPTIONS
|
|
1310
|
+
];
|
|
1311
|
+
var AgentGenuiModule = class _AgentGenuiModule {
|
|
1312
|
+
static {
|
|
1313
|
+
__name(this, "AgentGenuiModule");
|
|
1314
|
+
}
|
|
1315
|
+
static forRoot(options = {}) {
|
|
1316
|
+
const { resolver, ...rest } = options;
|
|
1317
|
+
return {
|
|
1318
|
+
module: _AgentGenuiModule,
|
|
1319
|
+
global: true,
|
|
1320
|
+
providers: [
|
|
1321
|
+
{
|
|
1322
|
+
provide: GENUI_OPTIONS,
|
|
1323
|
+
useValue: rest
|
|
1324
|
+
},
|
|
1325
|
+
...coreProviders(resolver)
|
|
1326
|
+
],
|
|
1327
|
+
exports: resolver === void 0 ? EXPORTS : [
|
|
1328
|
+
...EXPORTS,
|
|
1329
|
+
GenuiCatalogResolver
|
|
1330
|
+
]
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
static forRootAsync(options) {
|
|
1334
|
+
return {
|
|
1335
|
+
module: _AgentGenuiModule,
|
|
1336
|
+
global: true,
|
|
1337
|
+
imports: options.imports ?? [],
|
|
1338
|
+
providers: [
|
|
1339
|
+
{
|
|
1340
|
+
provide: GENUI_OPTIONS,
|
|
1341
|
+
useFactory: options.useFactory,
|
|
1342
|
+
inject: options.inject ?? []
|
|
1343
|
+
},
|
|
1344
|
+
...coreProviders(options.resolver)
|
|
1345
|
+
],
|
|
1346
|
+
exports: options.resolver === void 0 ? EXPORTS : [
|
|
1347
|
+
...EXPORTS,
|
|
1348
|
+
GenuiCatalogResolver
|
|
1349
|
+
]
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
AgentGenuiModule = _ts_decorate5([
|
|
1354
|
+
(0, import_common5.Module)({})
|
|
1355
|
+
], AgentGenuiModule);
|
|
1356
|
+
|
|
1357
|
+
// src/agent-deps.factory.ts
|
|
1358
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1359
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1360
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1361
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1362
|
+
} else {
|
|
1363
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1364
|
+
if (d = decorators[i]) {
|
|
1365
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1370
|
+
}
|
|
1371
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
1147
1372
|
function _ts_metadata4(metadataKey, metadataValue) {
|
|
1148
1373
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1149
1374
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
@@ -1176,7 +1401,9 @@ var AgentDepsFactory2 = class {
|
|
|
1176
1401
|
pricingStore;
|
|
1177
1402
|
skills;
|
|
1178
1403
|
memory;
|
|
1179
|
-
|
|
1404
|
+
uiCatalog;
|
|
1405
|
+
uiCatalogResolver;
|
|
1406
|
+
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver) {
|
|
1180
1407
|
this.options = options;
|
|
1181
1408
|
this.model = model;
|
|
1182
1409
|
this.store = store;
|
|
@@ -1188,6 +1415,9 @@ var AgentDepsFactory2 = class {
|
|
|
1188
1415
|
this.pricingStore = pricingStore;
|
|
1189
1416
|
this.skills = skills;
|
|
1190
1417
|
this.memory = memory;
|
|
1418
|
+
this.uiCatalog = uiCatalog;
|
|
1419
|
+
this.uiCatalogResolver = uiCatalogResolver;
|
|
1420
|
+
if (options.actionApprovalMode === "independent") (0, import_nestjs_agent_core8.assertIndependentActionCapabilities)(store, options.backgroundActorResolver);
|
|
1191
1421
|
}
|
|
1192
1422
|
/** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
|
|
1193
1423
|
memoryConfig() {
|
|
@@ -1213,7 +1443,7 @@ var AgentDepsFactory2 = class {
|
|
|
1213
1443
|
return void 0;
|
|
1214
1444
|
}
|
|
1215
1445
|
const delegated = (definition.delegatesTo ?? []).map((edge) => {
|
|
1216
|
-
const { agent, detached } = (0,
|
|
1446
|
+
const { agent, detached } = (0, import_nestjs_agent_core9.normalizeDelegation)(edge);
|
|
1217
1447
|
return delegateToolName({
|
|
1218
1448
|
target: agent,
|
|
1219
1449
|
detached
|
|
@@ -1237,7 +1467,7 @@ var AgentDepsFactory2 = class {
|
|
|
1237
1467
|
agentName: name
|
|
1238
1468
|
};
|
|
1239
1469
|
}
|
|
1240
|
-
const alias = (0,
|
|
1470
|
+
const alias = (0, import_nestjs_agent_core9.resolvePersonaAlias)(this.agents.list(), name);
|
|
1241
1471
|
return alias === void 0 ? {
|
|
1242
1472
|
agentName: name
|
|
1243
1473
|
} : {
|
|
@@ -1247,7 +1477,7 @@ var AgentDepsFactory2 = class {
|
|
|
1247
1477
|
}
|
|
1248
1478
|
/** `agentName`'s personas as a picker reads them. Empty when it declares none. */
|
|
1249
1479
|
personaCatalog(agentName) {
|
|
1250
|
-
return (this.agents.get(agentName)?.personas ?? []).map(
|
|
1480
|
+
return (this.agents.get(agentName)?.personas ?? []).map(import_nestjs_agent_core9.personaCatalogEntry);
|
|
1251
1481
|
}
|
|
1252
1482
|
/** The persona `agentName` runs under when nothing names one. Undefined → none. */
|
|
1253
1483
|
defaultPersona(agentName) {
|
|
@@ -1261,8 +1491,8 @@ var AgentDepsFactory2 = class {
|
|
|
1261
1491
|
resolvePersona(args) {
|
|
1262
1492
|
const definition = this.agents.get(args.agentName);
|
|
1263
1493
|
if (args.requested !== void 0) {
|
|
1264
|
-
if ((0,
|
|
1265
|
-
throw new
|
|
1494
|
+
if ((0, import_nestjs_agent_core9.findPersona)(definition, args.requested) === void 0) {
|
|
1495
|
+
throw new import_common6.BadRequestException({
|
|
1266
1496
|
statusCode: 400,
|
|
1267
1497
|
code: "persona_not_found",
|
|
1268
1498
|
message: `agent "${args.agentName}" has no persona "${args.requested}"`
|
|
@@ -1271,16 +1501,28 @@ var AgentDepsFactory2 = class {
|
|
|
1271
1501
|
return args.requested;
|
|
1272
1502
|
}
|
|
1273
1503
|
const pinned = args.threadPersona ?? void 0;
|
|
1274
|
-
if (pinned !== void 0 && (0,
|
|
1504
|
+
if (pinned !== void 0 && (0, import_nestjs_agent_core9.findPersona)(definition, pinned) !== void 0) {
|
|
1275
1505
|
return pinned;
|
|
1276
1506
|
}
|
|
1277
1507
|
return definition?.defaultPersona;
|
|
1278
1508
|
}
|
|
1509
|
+
forProposal(proposal, _actor) {
|
|
1510
|
+
const name = proposal.executionContext?.agentName;
|
|
1511
|
+
if (name !== void 0 && !this.agents.has(name) && !(name === "default" && this.defaultAgentName() === "default" && this.agents.list().length === 0)) throw new Error(`Recorded agent ${name} no longer exists`);
|
|
1512
|
+
const deps = this.forAgent(name);
|
|
1513
|
+
const id = proposal.executionContext?.persona;
|
|
1514
|
+
if (id !== void 0) {
|
|
1515
|
+
const persona = deps.personas?.find((persona2) => persona2.id === id);
|
|
1516
|
+
if (!persona) throw new Error(`Recorded persona ${id} no longer exists`);
|
|
1517
|
+
return this.withPersona(deps, persona);
|
|
1518
|
+
}
|
|
1519
|
+
return deps;
|
|
1520
|
+
}
|
|
1279
1521
|
forAgent(agentName) {
|
|
1280
1522
|
const name = agentName ?? this.defaultAgentName();
|
|
1281
1523
|
if (agentName !== void 0 && !this.agents.has(agentName)) {
|
|
1282
|
-
const alias = (0,
|
|
1283
|
-
const persona = alias === void 0 ? void 0 : (0,
|
|
1524
|
+
const alias = (0, import_nestjs_agent_core9.resolvePersonaAlias)(this.agents.list(), agentName);
|
|
1525
|
+
const persona = alias === void 0 ? void 0 : (0, import_nestjs_agent_core9.findPersona)(this.agents.get(alias.agent), alias.persona);
|
|
1284
1526
|
if (alias !== void 0 && persona !== void 0) {
|
|
1285
1527
|
return this.withPersona(this.forAgent(alias.agent), persona);
|
|
1286
1528
|
}
|
|
@@ -1294,12 +1536,27 @@ var AgentDepsFactory2 = class {
|
|
|
1294
1536
|
return {
|
|
1295
1537
|
model: this.model,
|
|
1296
1538
|
store: this.store,
|
|
1539
|
+
...this.options.actionApprovalMode !== void 0 ? {
|
|
1540
|
+
actionApprovalMode: this.options.actionApprovalMode
|
|
1541
|
+
} : {},
|
|
1297
1542
|
sink: this.sink,
|
|
1298
1543
|
rolesPolicy: this.rolesPolicy,
|
|
1299
1544
|
...this.options.approvalPolicy !== void 0 ? {
|
|
1300
1545
|
approvalPolicy: this.options.approvalPolicy
|
|
1301
1546
|
} : {},
|
|
1302
1547
|
registry: this.registry,
|
|
1548
|
+
...this.uiCatalog !== void 0 || this.uiCatalogResolver !== void 0 ? {
|
|
1549
|
+
resolveUiCatalog: /* @__PURE__ */ __name((scope) => {
|
|
1550
|
+
const catalog = this.uiCatalogResolver?.resolve({
|
|
1551
|
+
...scope,
|
|
1552
|
+
...scope.actor.tenantRef !== void 0 ? {
|
|
1553
|
+
tenant: scope.actor.tenantRef
|
|
1554
|
+
} : {}
|
|
1555
|
+
}) ?? this.uiCatalog;
|
|
1556
|
+
if (!catalog) throw new Error("UI catalog unavailable");
|
|
1557
|
+
return catalog;
|
|
1558
|
+
}, "resolveUiCatalog")
|
|
1559
|
+
} : {},
|
|
1303
1560
|
promptContributors: this.promptContributors,
|
|
1304
1561
|
systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
|
|
1305
1562
|
maxSteps: definition?.maxSteps ?? 8,
|
|
@@ -1399,7 +1656,7 @@ var AgentDepsFactory2 = class {
|
|
|
1399
1656
|
} : {}
|
|
1400
1657
|
});
|
|
1401
1658
|
}, "systemPrompt");
|
|
1402
|
-
const toolAllowList = (0,
|
|
1659
|
+
const toolAllowList = (0, import_nestjs_agent_core9.intersectAllowLists)(deps.toolAllowList, persona.allowedTools);
|
|
1403
1660
|
return {
|
|
1404
1661
|
...deps,
|
|
1405
1662
|
systemPrompt,
|
|
@@ -1424,7 +1681,7 @@ var AgentDepsFactory2 = class {
|
|
|
1424
1681
|
}
|
|
1425
1682
|
/** Build the built-in window policy from the declarative `{ maxMessages, maxTokens, summarize }`. */
|
|
1426
1683
|
window(config) {
|
|
1427
|
-
return (0,
|
|
1684
|
+
return (0, import_nestjs_agent_core9.windowHistory)({
|
|
1428
1685
|
...config.maxMessages !== void 0 ? {
|
|
1429
1686
|
maxMessages: config.maxMessages
|
|
1430
1687
|
} : {},
|
|
@@ -1434,7 +1691,7 @@ var AgentDepsFactory2 = class {
|
|
|
1434
1691
|
// The shared module model, not a per-agent one: an agent's `modelId` is an accounting label,
|
|
1435
1692
|
// and only one provider is ever bound.
|
|
1436
1693
|
...config.summarize === true ? {
|
|
1437
|
-
summarize: (0,
|
|
1694
|
+
summarize: (0, import_nestjs_agent_core9.summarizeWithModel)(this.model)
|
|
1438
1695
|
} : {}
|
|
1439
1696
|
});
|
|
1440
1697
|
}
|
|
@@ -1450,22 +1707,25 @@ var AgentDepsFactory2 = class {
|
|
|
1450
1707
|
return void 0;
|
|
1451
1708
|
}
|
|
1452
1709
|
};
|
|
1453
|
-
AgentDepsFactory2 =
|
|
1454
|
-
(0,
|
|
1455
|
-
_ts_param4(0, (0,
|
|
1456
|
-
_ts_param4(1, (0,
|
|
1457
|
-
_ts_param4(2, (0,
|
|
1458
|
-
_ts_param4(3, (0,
|
|
1459
|
-
_ts_param4(4, (0,
|
|
1460
|
-
_ts_param4(5, (0,
|
|
1461
|
-
_ts_param4(6, (0,
|
|
1462
|
-
_ts_param4(7, (0,
|
|
1463
|
-
_ts_param4(8, (0,
|
|
1464
|
-
_ts_param4(8, (0,
|
|
1465
|
-
_ts_param4(9, (0,
|
|
1466
|
-
_ts_param4(9, (0,
|
|
1467
|
-
_ts_param4(10, (0,
|
|
1468
|
-
_ts_param4(10, (0,
|
|
1710
|
+
AgentDepsFactory2 = _ts_decorate6([
|
|
1711
|
+
(0, import_common6.Injectable)(),
|
|
1712
|
+
_ts_param4(0, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_OPTIONS)),
|
|
1713
|
+
_ts_param4(1, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_MODEL)),
|
|
1714
|
+
_ts_param4(2, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_STORE)),
|
|
1715
|
+
_ts_param4(3, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_SINK)),
|
|
1716
|
+
_ts_param4(4, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_ROLES_POLICY)),
|
|
1717
|
+
_ts_param4(5, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_TOOL_REGISTRY)),
|
|
1718
|
+
_ts_param4(6, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_REGISTRY)),
|
|
1719
|
+
_ts_param4(7, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_PROMPT_CONTRIBUTORS)),
|
|
1720
|
+
_ts_param4(8, (0, import_common6.Optional)()),
|
|
1721
|
+
_ts_param4(8, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_PRICING_STORE)),
|
|
1722
|
+
_ts_param4(9, (0, import_common6.Optional)()),
|
|
1723
|
+
_ts_param4(9, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_SKILLS)),
|
|
1724
|
+
_ts_param4(10, (0, import_common6.Optional)()),
|
|
1725
|
+
_ts_param4(10, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_MEMORY)),
|
|
1726
|
+
_ts_param4(11, (0, import_common6.Optional)()),
|
|
1727
|
+
_ts_param4(11, (0, import_common6.Inject)(GENUI_CATALOG)),
|
|
1728
|
+
_ts_param4(12, (0, import_common6.Optional)()),
|
|
1469
1729
|
_ts_metadata4("design:type", Function),
|
|
1470
1730
|
_ts_metadata4("design:paramtypes", [
|
|
1471
1731
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -1473,22 +1733,174 @@ AgentDepsFactory2 = _ts_decorate5([
|
|
|
1473
1733
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1474
1734
|
typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
|
|
1475
1735
|
typeof RolesPolicy === "undefined" ? Object : RolesPolicy,
|
|
1476
|
-
typeof
|
|
1477
|
-
typeof
|
|
1736
|
+
typeof import_nestjs_agent_core9.ToolRegistry === "undefined" ? Object : import_nestjs_agent_core9.ToolRegistry,
|
|
1737
|
+
typeof import_nestjs_agent_core9.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core9.AgentRegistry,
|
|
1478
1738
|
Array,
|
|
1479
1739
|
Object,
|
|
1480
1740
|
Object,
|
|
1481
|
-
Object
|
|
1741
|
+
Object,
|
|
1742
|
+
typeof Catalog === "undefined" ? Object : Catalog,
|
|
1743
|
+
typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
|
|
1482
1744
|
])
|
|
1483
1745
|
], AgentDepsFactory2);
|
|
1484
1746
|
|
|
1485
1747
|
// src/agent.service.ts
|
|
1486
|
-
var
|
|
1487
|
-
var
|
|
1748
|
+
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
1749
|
+
var import_common10 = require("@nestjs/common");
|
|
1750
|
+
|
|
1751
|
+
// src/proposals/action-proposal.service.ts
|
|
1752
|
+
var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
|
|
1753
|
+
var import_common7 = require("@nestjs/common");
|
|
1754
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1755
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1756
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1757
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1758
|
+
} else {
|
|
1759
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1760
|
+
if (d = decorators[i]) {
|
|
1761
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1766
|
+
}
|
|
1767
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
1768
|
+
function _ts_metadata5(metadataKey, metadataValue) {
|
|
1769
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1770
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
1774
|
+
function _ts_param5(paramIndex, decorator) {
|
|
1775
|
+
return function(target, key) {
|
|
1776
|
+
decorator(target, key, paramIndex);
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
__name(_ts_param5, "_ts_param");
|
|
1780
|
+
var ActionProposalService = class {
|
|
1781
|
+
static {
|
|
1782
|
+
__name(this, "ActionProposalService");
|
|
1783
|
+
}
|
|
1784
|
+
store;
|
|
1785
|
+
options;
|
|
1786
|
+
constructor(store, options) {
|
|
1787
|
+
this.store = store;
|
|
1788
|
+
this.options = options;
|
|
1789
|
+
}
|
|
1790
|
+
capability() {
|
|
1791
|
+
const store = this.store;
|
|
1792
|
+
if (typeof store.getThreadActionProposalScope !== "function" || typeof store.listActionProposals !== "function") throw new import_common7.NotImplementedException("Action proposals are unavailable");
|
|
1793
|
+
return store;
|
|
1794
|
+
}
|
|
1795
|
+
async scope(threadId, actor) {
|
|
1796
|
+
const scope = await this.capability().getThreadActionProposalScope(threadId);
|
|
1797
|
+
if (!scope) throw new import_common7.NotFoundException("Thread not found");
|
|
1798
|
+
if (scope.tenantRef !== (actor.tenantRef ?? null)) throw new import_common7.ForbiddenException("Wrong proposal tenant");
|
|
1799
|
+
return scope;
|
|
1800
|
+
}
|
|
1801
|
+
mayDecide(actor, proposal) {
|
|
1802
|
+
return (0, import_nestjs_agent_core11.mayDecideApproval)(this.options.approvalPolicy, actor, {
|
|
1803
|
+
toolCallId: proposal.originToolCallId,
|
|
1804
|
+
approver: proposal.approver,
|
|
1805
|
+
requesterRef: proposal.actorRef
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
async listPage(threadId, actor, query = {}) {
|
|
1809
|
+
const scope = await this.scope(threadId, actor);
|
|
1810
|
+
const rows = await this.capability().listActionProposals(scope, {
|
|
1811
|
+
limit: 1e3,
|
|
1812
|
+
...query
|
|
1813
|
+
});
|
|
1814
|
+
const visible = [];
|
|
1815
|
+
for (const row of rows) if (scope.actorRef === actor.id || await this.mayDecide(actor, row)) visible.push(row);
|
|
1816
|
+
const last = rows.at(-1);
|
|
1817
|
+
return {
|
|
1818
|
+
items: visible,
|
|
1819
|
+
...rows.length === 1e3 && last ? {
|
|
1820
|
+
next: {
|
|
1821
|
+
createdAt: last.createdAt,
|
|
1822
|
+
id: last.id
|
|
1823
|
+
}
|
|
1824
|
+
} : {}
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
async list(threadId, actor) {
|
|
1828
|
+
return (await this.listPage(threadId, actor)).items;
|
|
1829
|
+
}
|
|
1830
|
+
async decide(threadId, proposalId, actor, command) {
|
|
1831
|
+
const scope = await this.scope(threadId, actor);
|
|
1832
|
+
const proposal = await this.capability().getActionProposal(scope, proposalId);
|
|
1833
|
+
if (!proposal) throw new import_common7.NotFoundException("Proposal not found");
|
|
1834
|
+
if (!await this.mayDecide(actor, proposal)) throw new import_common7.ForbiddenException("May not decide this proposal");
|
|
1835
|
+
return this.capability().decideActionProposal(scope, proposalId, {
|
|
1836
|
+
decision: command.decision,
|
|
1837
|
+
actorRef: actor.id,
|
|
1838
|
+
via: command.via ?? "web",
|
|
1839
|
+
...command.remember !== void 0 ? {
|
|
1840
|
+
remember: command.remember
|
|
1841
|
+
} : {},
|
|
1842
|
+
...command.reason !== void 0 ? {
|
|
1843
|
+
reason: command.reason
|
|
1844
|
+
} : {}
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1847
|
+
async handleTextDecision(threadId, actor, text) {
|
|
1848
|
+
const command = (0, import_nestjs_agent_core11.parseTextActionProposalCommand)(text);
|
|
1849
|
+
if (command.status === "unmatched") return command;
|
|
1850
|
+
if (command.proposalId !== void 0) {
|
|
1851
|
+
const result2 = await this.decide(threadId, command.proposalId, actor, {
|
|
1852
|
+
decision: command.decision,
|
|
1853
|
+
remember: command.remember,
|
|
1854
|
+
via: "text"
|
|
1855
|
+
});
|
|
1856
|
+
return this.textReceipt(threadId, result2);
|
|
1857
|
+
}
|
|
1858
|
+
const candidates = [];
|
|
1859
|
+
const scope = await this.scope(threadId, actor);
|
|
1860
|
+
const pending = await this.capability().listActionProposals(scope, {
|
|
1861
|
+
decision: "pending",
|
|
1862
|
+
limit: 1e3
|
|
1863
|
+
});
|
|
1864
|
+
for (const proposal of pending) if (await this.mayDecide(actor, proposal)) candidates.push(proposal);
|
|
1865
|
+
const resolution = (0, import_nestjs_agent_core11.resolveTextActionProposalDecision)(text, candidates);
|
|
1866
|
+
if (resolution.status === "unmatched") return resolution;
|
|
1867
|
+
if (resolution.status === "ambiguous" || resolution.status === "decision" && pending.length === 1e3 && !text.includes("#")) return {
|
|
1868
|
+
threadId,
|
|
1869
|
+
proposalDecision: {
|
|
1870
|
+
status: "ambiguous",
|
|
1871
|
+
proposalIds: candidates.map(({ id }) => id)
|
|
1872
|
+
},
|
|
1873
|
+
text: `Choose the action to decide: ${candidates.map(({ id }) => id).map((id) => `#${id}`).join(", ")}`
|
|
1874
|
+
};
|
|
1875
|
+
const result = await this.decide(threadId, resolution.proposalId, actor, {
|
|
1876
|
+
decision: resolution.decision,
|
|
1877
|
+
remember: resolution.remember,
|
|
1878
|
+
via: "text"
|
|
1879
|
+
});
|
|
1880
|
+
return this.textReceipt(threadId, result);
|
|
1881
|
+
}
|
|
1882
|
+
textReceipt(threadId, result) {
|
|
1883
|
+
return {
|
|
1884
|
+
threadId,
|
|
1885
|
+
proposalDecision: result,
|
|
1886
|
+
text: result.proposal?.decision === "approved" ? "Action approved and queued for execution." : `Action ${result.proposal?.decision ?? result.status}; no execution was performed by this decision.`
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
};
|
|
1890
|
+
ActionProposalService = _ts_decorate7([
|
|
1891
|
+
(0, import_common7.Injectable)(),
|
|
1892
|
+
_ts_param5(0, (0, import_common7.Inject)(import_nestjs_agent_core11.AGENT_STORE)),
|
|
1893
|
+
_ts_param5(1, (0, import_common7.Inject)(import_nestjs_agent_core11.AGENT_OPTIONS)),
|
|
1894
|
+
_ts_metadata5("design:type", Function),
|
|
1895
|
+
_ts_metadata5("design:paramtypes", [
|
|
1896
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1897
|
+
typeof Pick === "undefined" ? Object : Pick
|
|
1898
|
+
])
|
|
1899
|
+
], ActionProposalService);
|
|
1488
1900
|
|
|
1489
1901
|
// src/queue/chat-queue.service.ts
|
|
1490
|
-
var
|
|
1491
|
-
var
|
|
1902
|
+
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
1903
|
+
var import_common8 = require("@nestjs/common");
|
|
1492
1904
|
|
|
1493
1905
|
// src/thread-persona.ts
|
|
1494
1906
|
async function threadPersona(store, threadId) {
|
|
@@ -1501,7 +1913,7 @@ async function threadPersona(store, threadId) {
|
|
|
1501
1913
|
__name(threadPersona, "threadPersona");
|
|
1502
1914
|
|
|
1503
1915
|
// src/queue/chat-queue.service.ts
|
|
1504
|
-
function
|
|
1916
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1505
1917
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1506
1918
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1507
1919
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1514,19 +1926,19 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1514
1926
|
}
|
|
1515
1927
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1516
1928
|
}
|
|
1517
|
-
__name(
|
|
1518
|
-
function
|
|
1929
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
1930
|
+
function _ts_metadata6(metadataKey, metadataValue) {
|
|
1519
1931
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1520
1932
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1521
1933
|
}
|
|
1522
1934
|
}
|
|
1523
|
-
__name(
|
|
1524
|
-
function
|
|
1935
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
1936
|
+
function _ts_param6(paramIndex, decorator) {
|
|
1525
1937
|
return function(target, key) {
|
|
1526
1938
|
decorator(target, key, paramIndex);
|
|
1527
1939
|
};
|
|
1528
1940
|
}
|
|
1529
|
-
__name(
|
|
1941
|
+
__name(_ts_param6, "_ts_param");
|
|
1530
1942
|
var MAX_DRAIN_ATTEMPTS = 8;
|
|
1531
1943
|
var ChatQueueService2 = class _ChatQueueService {
|
|
1532
1944
|
static {
|
|
@@ -1538,7 +1950,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1538
1950
|
options;
|
|
1539
1951
|
staging;
|
|
1540
1952
|
deps;
|
|
1541
|
-
logger = new
|
|
1953
|
+
logger = new import_common8.Logger(_ChatQueueService.name);
|
|
1542
1954
|
/**
|
|
1543
1955
|
* Runs this process claimed a thread for and has not handed to a runner yet. A holder in here is
|
|
1544
1956
|
* alive whatever the runner says — it simply has not registered the run yet.
|
|
@@ -1554,12 +1966,12 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1554
1966
|
}
|
|
1555
1967
|
/** Whether the bound store can hold a queue. Without one, a busy thread is not queued. */
|
|
1556
1968
|
get supported() {
|
|
1557
|
-
return (0,
|
|
1969
|
+
return (0, import_nestjs_agent_core12.isChatQueueStore)(this.store);
|
|
1558
1970
|
}
|
|
1559
1971
|
/** The bound store as a queue store, or a 501 naming what is missing. */
|
|
1560
1972
|
queueStore() {
|
|
1561
|
-
if (!(0,
|
|
1562
|
-
throw new
|
|
1973
|
+
if (!(0, import_nestjs_agent_core12.isChatQueueStore)(this.store)) {
|
|
1974
|
+
throw new import_common8.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore (enqueueMessage, listQueue, \u2026, claimActiveStream, releaseActiveStream); the bound store does not.");
|
|
1563
1975
|
}
|
|
1564
1976
|
return this.store;
|
|
1565
1977
|
}
|
|
@@ -1570,7 +1982,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1570
1982
|
store.queuePause(threadId)
|
|
1571
1983
|
]);
|
|
1572
1984
|
return {
|
|
1573
|
-
items: items.map(
|
|
1985
|
+
items: items.map(import_nestjs_agent_core12.queuedMessageView),
|
|
1574
1986
|
paused
|
|
1575
1987
|
};
|
|
1576
1988
|
}
|
|
@@ -1621,7 +2033,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1621
2033
|
* A no-op returning `{}` on a store without a queue.
|
|
1622
2034
|
*/
|
|
1623
2035
|
async plan(args) {
|
|
1624
|
-
if (!(0,
|
|
2036
|
+
if (!(0, import_nestjs_agent_core12.isChatQueueStore)(this.store)) {
|
|
1625
2037
|
return {};
|
|
1626
2038
|
}
|
|
1627
2039
|
const store = this.store;
|
|
@@ -1721,7 +2133,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1721
2133
|
* (its settle drains) or while the queue is paused. Answers the started run's id, if any.
|
|
1722
2134
|
*/
|
|
1723
2135
|
async kick(threadId, runner) {
|
|
1724
|
-
if (!(0,
|
|
2136
|
+
if (!(0, import_nestjs_agent_core12.isChatQueueStore)(this.store)) {
|
|
1725
2137
|
return void 0;
|
|
1726
2138
|
}
|
|
1727
2139
|
const { live, stale } = await this.holder(threadId, runner);
|
|
@@ -1786,6 +2198,9 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1786
2198
|
} : {},
|
|
1787
2199
|
...input.pageContext !== void 0 ? {
|
|
1788
2200
|
pageContext: input.pageContext
|
|
2201
|
+
} : {},
|
|
2202
|
+
...input.uiCapabilities !== void 0 ? {
|
|
2203
|
+
uiCapabilities: input.uiCapabilities
|
|
1789
2204
|
} : {}
|
|
1790
2205
|
});
|
|
1791
2206
|
await store.setQueuePause(threadId, {
|
|
@@ -1822,7 +2237,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1822
2237
|
}
|
|
1823
2238
|
async write(runId, frame) {
|
|
1824
2239
|
const writer = await this.sink.open(runId);
|
|
1825
|
-
await writer.write((0,
|
|
2240
|
+
await writer.write((0, import_nestjs_agent_core12.encodeStreamEvent)(frame));
|
|
1826
2241
|
}
|
|
1827
2242
|
/** Why `actor` may not start a turn now (the quota message), or `null`. */
|
|
1828
2243
|
async quotaBlock(actor) {
|
|
@@ -1866,6 +2281,9 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1866
2281
|
...message.pageContext !== void 0 ? {
|
|
1867
2282
|
pageContext: message.pageContext
|
|
1868
2283
|
} : {},
|
|
2284
|
+
...message.uiCapabilities !== void 0 ? {
|
|
2285
|
+
uiCapabilities: message.uiCapabilities
|
|
2286
|
+
} : {},
|
|
1869
2287
|
...message.model !== void 0 ? {
|
|
1870
2288
|
model: message.model
|
|
1871
2289
|
} : {}
|
|
@@ -1919,20 +2337,20 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1919
2337
|
}));
|
|
1920
2338
|
}
|
|
1921
2339
|
};
|
|
1922
|
-
ChatQueueService2 =
|
|
1923
|
-
(0,
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
2340
|
+
ChatQueueService2 = _ts_decorate8([
|
|
2341
|
+
(0, import_common8.Injectable)(),
|
|
2342
|
+
_ts_param6(0, (0, import_common8.Inject)(import_nestjs_agent_core12.AGENT_STORE)),
|
|
2343
|
+
_ts_param6(1, (0, import_common8.Inject)(import_nestjs_agent_core12.AGENT_SINK)),
|
|
2344
|
+
_ts_param6(2, (0, import_common8.Optional)()),
|
|
2345
|
+
_ts_param6(2, (0, import_common8.Inject)(import_nestjs_agent_core12.AGENT_QUOTA_PROVIDER)),
|
|
2346
|
+
_ts_param6(3, (0, import_common8.Optional)()),
|
|
2347
|
+
_ts_param6(3, (0, import_common8.Inject)(import_nestjs_agent_core12.AGENT_OPTIONS)),
|
|
2348
|
+
_ts_param6(4, (0, import_common8.Optional)()),
|
|
2349
|
+
_ts_param6(4, (0, import_common8.Inject)(import_nestjs_agent_core12.AGENT_ATTACHMENT_STAGING)),
|
|
2350
|
+
_ts_param6(5, (0, import_common8.Optional)()),
|
|
2351
|
+
_ts_param6(5, (0, import_common8.Inject)(import_nestjs_agent_core12.AGENT_DEPS_FACTORY)),
|
|
2352
|
+
_ts_metadata6("design:type", Function),
|
|
2353
|
+
_ts_metadata6("design:paramtypes", [
|
|
1936
2354
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1937
2355
|
typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
|
|
1938
2356
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
@@ -1955,7 +2373,7 @@ function queueFrame(items, paused, started) {
|
|
|
1955
2373
|
return {
|
|
1956
2374
|
kind: "queue",
|
|
1957
2375
|
queue: {
|
|
1958
|
-
items: items.map(
|
|
2376
|
+
items: items.map(import_nestjs_agent_core12.queuedMessageView),
|
|
1959
2377
|
paused
|
|
1960
2378
|
},
|
|
1961
2379
|
...started !== void 0 ? {
|
|
@@ -1966,25 +2384,25 @@ function queueFrame(items, paused, started) {
|
|
|
1966
2384
|
__name(queueFrame, "queueFrame");
|
|
1967
2385
|
|
|
1968
2386
|
// src/run-not-active.exception.ts
|
|
1969
|
-
var
|
|
1970
|
-
var
|
|
1971
|
-
var RunNotActiveException = class extends
|
|
2387
|
+
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
2388
|
+
var import_common9 = require("@nestjs/common");
|
|
2389
|
+
var RunNotActiveException = class extends import_common9.ConflictException {
|
|
1972
2390
|
static {
|
|
1973
2391
|
__name(this, "RunNotActiveException");
|
|
1974
2392
|
}
|
|
1975
2393
|
runId;
|
|
1976
|
-
code =
|
|
2394
|
+
code = import_nestjs_agent_core13.RUN_NOT_ACTIVE_CODE;
|
|
1977
2395
|
constructor(runId) {
|
|
1978
2396
|
super({
|
|
1979
2397
|
statusCode: 409,
|
|
1980
|
-
code:
|
|
1981
|
-
message:
|
|
2398
|
+
code: import_nestjs_agent_core13.RUN_NOT_ACTIVE_CODE,
|
|
2399
|
+
message: import_nestjs_agent_core13.RUN_NOT_ACTIVE_MESSAGE
|
|
1982
2400
|
}), this.runId = runId;
|
|
1983
2401
|
}
|
|
1984
2402
|
};
|
|
1985
2403
|
|
|
1986
2404
|
// src/agent.service.ts
|
|
1987
|
-
function
|
|
2405
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
1988
2406
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1989
2407
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1990
2408
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1997,19 +2415,19 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1997
2415
|
}
|
|
1998
2416
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1999
2417
|
}
|
|
2000
|
-
__name(
|
|
2001
|
-
function
|
|
2418
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
2419
|
+
function _ts_metadata7(metadataKey, metadataValue) {
|
|
2002
2420
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2003
2421
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2004
2422
|
}
|
|
2005
2423
|
}
|
|
2006
|
-
__name(
|
|
2007
|
-
function
|
|
2424
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
2425
|
+
function _ts_param7(paramIndex, decorator) {
|
|
2008
2426
|
return function(target, key) {
|
|
2009
2427
|
decorator(target, key, paramIndex);
|
|
2010
2428
|
};
|
|
2011
2429
|
}
|
|
2012
|
-
__name(
|
|
2430
|
+
__name(_ts_param7, "_ts_param");
|
|
2013
2431
|
var AgentService = class {
|
|
2014
2432
|
static {
|
|
2015
2433
|
__name(this, "AgentService");
|
|
@@ -2022,7 +2440,8 @@ var AgentService = class {
|
|
|
2022
2440
|
quotaProvider;
|
|
2023
2441
|
options;
|
|
2024
2442
|
queue;
|
|
2025
|
-
|
|
2443
|
+
proposals;
|
|
2444
|
+
constructor(runner, store, deps, staging, models, quotaProvider, options, queue, proposals) {
|
|
2026
2445
|
this.runner = runner;
|
|
2027
2446
|
this.store = store;
|
|
2028
2447
|
this.deps = deps;
|
|
@@ -2031,6 +2450,13 @@ var AgentService = class {
|
|
|
2031
2450
|
this.quotaProvider = quotaProvider;
|
|
2032
2451
|
this.options = options;
|
|
2033
2452
|
this.queue = queue;
|
|
2453
|
+
this.proposals = proposals;
|
|
2454
|
+
}
|
|
2455
|
+
async handleTextDecision(threadId, actor, text) {
|
|
2456
|
+
if (this.options?.actionApprovalMode !== "independent" || !this.proposals) return {
|
|
2457
|
+
status: "unmatched"
|
|
2458
|
+
};
|
|
2459
|
+
return this.proposals.handleTextDecision(threadId, actor, text);
|
|
2034
2460
|
}
|
|
2035
2461
|
/** The queue service when the bound store can hold a queue, else `undefined`. */
|
|
2036
2462
|
queueing() {
|
|
@@ -2040,7 +2466,7 @@ var AgentService = class {
|
|
|
2040
2466
|
requireQueue() {
|
|
2041
2467
|
const queue = this.queueing();
|
|
2042
2468
|
if (queue === void 0) {
|
|
2043
|
-
throw new
|
|
2469
|
+
throw new import_common10.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
|
|
2044
2470
|
}
|
|
2045
2471
|
return queue;
|
|
2046
2472
|
}
|
|
@@ -2077,12 +2503,12 @@ var AgentService = class {
|
|
|
2077
2503
|
actor
|
|
2078
2504
|
});
|
|
2079
2505
|
if (blocked !== void 0) {
|
|
2080
|
-
throw new
|
|
2081
|
-
statusCode:
|
|
2506
|
+
throw new import_common10.HttpException({
|
|
2507
|
+
statusCode: import_common10.HttpStatus.TOO_MANY_REQUESTS,
|
|
2082
2508
|
code: "quota_exceeded",
|
|
2083
2509
|
period: blocked.period,
|
|
2084
2510
|
message: blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`
|
|
2085
|
-
},
|
|
2511
|
+
}, import_common10.HttpStatus.TOO_MANY_REQUESTS);
|
|
2086
2512
|
}
|
|
2087
2513
|
}
|
|
2088
2514
|
/**
|
|
@@ -2110,17 +2536,17 @@ var AgentService = class {
|
|
|
2110
2536
|
*/
|
|
2111
2537
|
async assertModelAllowed(actor, agent, model) {
|
|
2112
2538
|
if (this.models === void 0) {
|
|
2113
|
-
throw new
|
|
2539
|
+
throw new import_common10.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
|
|
2114
2540
|
}
|
|
2115
|
-
const entry = (0,
|
|
2541
|
+
const entry = (0, import_nestjs_agent_core14.findCatalogModel)(await this.models.list({
|
|
2116
2542
|
actor,
|
|
2117
2543
|
agent
|
|
2118
2544
|
}), model);
|
|
2119
2545
|
if (entry === void 0) {
|
|
2120
|
-
throw new
|
|
2546
|
+
throw new import_common10.BadRequestException(`model "${model}" is not offered`);
|
|
2121
2547
|
}
|
|
2122
2548
|
if (!entry.available) {
|
|
2123
|
-
throw new
|
|
2549
|
+
throw new import_common10.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
|
|
2124
2550
|
}
|
|
2125
2551
|
return entry.id;
|
|
2126
2552
|
}
|
|
@@ -2136,7 +2562,7 @@ var AgentService = class {
|
|
|
2136
2562
|
})).locked : void 0;
|
|
2137
2563
|
if (locked !== void 0) {
|
|
2138
2564
|
if (requested !== void 0 && requested !== locked.model) {
|
|
2139
|
-
throw new
|
|
2565
|
+
throw new import_common10.BadRequestException(`model "${requested}" cannot be selected: ${locked.reason ?? `this agent always uses "${locked.model}"`}`);
|
|
2140
2566
|
}
|
|
2141
2567
|
return locked.model;
|
|
2142
2568
|
}
|
|
@@ -2162,7 +2588,10 @@ var AgentService = class {
|
|
|
2162
2588
|
const result = await this.send({
|
|
2163
2589
|
...params,
|
|
2164
2590
|
mode: "auto"
|
|
2591
|
+
}, {
|
|
2592
|
+
textDecisions: false
|
|
2165
2593
|
});
|
|
2594
|
+
if ("proposalDecision" in result) throw new Error("Unexpected text decision in run-only API");
|
|
2166
2595
|
if (result.queued !== true) {
|
|
2167
2596
|
return result;
|
|
2168
2597
|
}
|
|
@@ -2180,7 +2609,7 @@ var AgentService = class {
|
|
|
2180
2609
|
};
|
|
2181
2610
|
}
|
|
2182
2611
|
await this.requireQueue().publish(result.threadId);
|
|
2183
|
-
throw new
|
|
2612
|
+
throw new import_common10.ConflictException({
|
|
2184
2613
|
statusCode: 409,
|
|
2185
2614
|
code: "run_active",
|
|
2186
2615
|
message: `thread ${result.threadId} already has a turn running`
|
|
@@ -2190,7 +2619,11 @@ var AgentService = class {
|
|
|
2190
2619
|
* Send a message: start a turn, or — when its thread already has one running — queue the message
|
|
2191
2620
|
* to run after it (see {@link ChatSendMode}). What `POST <base>/chat` calls.
|
|
2192
2621
|
*/
|
|
2193
|
-
async send(params) {
|
|
2622
|
+
async send(params, sendOptions = {}) {
|
|
2623
|
+
if (sendOptions.textDecisions !== false && this.options?.actionApprovalMode === "independent" && params.threadId !== void 0 && params.regenerate !== true && this.proposals) {
|
|
2624
|
+
const decision = await this.proposals.handleTextDecision(params.threadId, params.actor, params.message);
|
|
2625
|
+
if ("proposalDecision" in decision) return decision;
|
|
2626
|
+
}
|
|
2194
2627
|
await this.assertWithinQuota(params.actor);
|
|
2195
2628
|
const target = this.deps.resolveAgent(await this.resolveAgentName(params.agentName, params.threadId));
|
|
2196
2629
|
const agentName = target.agentName;
|
|
@@ -2200,7 +2633,7 @@ var AgentService = class {
|
|
|
2200
2633
|
let threadId = params.threadId;
|
|
2201
2634
|
if (threadId === void 0) {
|
|
2202
2635
|
if (params.regenerate === true) {
|
|
2203
|
-
throw new
|
|
2636
|
+
throw new import_common10.BadRequestException("regenerate requires an existing threadId");
|
|
2204
2637
|
}
|
|
2205
2638
|
const created = await this.store.createThread({
|
|
2206
2639
|
actor: params.actor,
|
|
@@ -2239,12 +2672,16 @@ var AgentService = class {
|
|
|
2239
2672
|
...params.pageContext !== void 0 ? {
|
|
2240
2673
|
pageContext: params.pageContext
|
|
2241
2674
|
} : {},
|
|
2675
|
+
...params.uiCapabilities !== void 0 ? {
|
|
2676
|
+
uiCapabilities: params.uiCapabilities
|
|
2677
|
+
} : {},
|
|
2242
2678
|
...model !== void 0 ? {
|
|
2243
2679
|
model
|
|
2244
2680
|
} : {}
|
|
2245
2681
|
};
|
|
2246
2682
|
const queue = this.queueing();
|
|
2247
2683
|
if (queue === void 0) {
|
|
2684
|
+
if (this.options?.actionApprovalMode === "independent") throw new Error("Independent actions require queued thread admission");
|
|
2248
2685
|
const { runId } = await this.runner.start(input);
|
|
2249
2686
|
await this.store.setActiveStream(threadId, runId);
|
|
2250
2687
|
return {
|
|
@@ -2255,7 +2692,7 @@ var AgentService = class {
|
|
|
2255
2692
|
const mode = params.mode ?? "auto";
|
|
2256
2693
|
const { live, stale } = await queue.holder(threadId, this.runner);
|
|
2257
2694
|
if (stale !== null) {
|
|
2258
|
-
await (0,
|
|
2695
|
+
await (0, import_nestjs_agent_core14.settleDeadRun)(this.store, {
|
|
2259
2696
|
runId: stale
|
|
2260
2697
|
});
|
|
2261
2698
|
}
|
|
@@ -2271,7 +2708,7 @@ var AgentService = class {
|
|
|
2271
2708
|
}
|
|
2272
2709
|
}
|
|
2273
2710
|
if (params.regenerate === true) {
|
|
2274
|
-
throw new
|
|
2711
|
+
throw new import_common10.ConflictException({
|
|
2275
2712
|
statusCode: 409,
|
|
2276
2713
|
code: "run_active",
|
|
2277
2714
|
message: "cannot regenerate while a turn is running on this thread"
|
|
@@ -2325,6 +2762,9 @@ var AgentService = class {
|
|
|
2325
2762
|
...input.pageContext !== void 0 ? {
|
|
2326
2763
|
pageContext: input.pageContext
|
|
2327
2764
|
} : {},
|
|
2765
|
+
...input.uiCapabilities !== void 0 ? {
|
|
2766
|
+
uiCapabilities: input.uiCapabilities
|
|
2767
|
+
} : {},
|
|
2328
2768
|
...interrupting !== void 0 ? {
|
|
2329
2769
|
interrupt: true,
|
|
2330
2770
|
at: "head"
|
|
@@ -2371,7 +2811,7 @@ var AgentService = class {
|
|
|
2371
2811
|
const store = queue.queueStore();
|
|
2372
2812
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
2373
2813
|
if (patch.message !== void 0 && patch.message.trim().length === 0) {
|
|
2374
|
-
throw new
|
|
2814
|
+
throw new import_common10.BadRequestException("message must not be empty");
|
|
2375
2815
|
}
|
|
2376
2816
|
const attachments = patch.attachments === void 0 || patch.attachments === null ? patch.attachments : await this.resolveAttachments(actor, patch.attachments);
|
|
2377
2817
|
if (patch.message !== void 0 || attachments !== void 0) {
|
|
@@ -2384,15 +2824,15 @@ var AgentService = class {
|
|
|
2384
2824
|
} : {}
|
|
2385
2825
|
});
|
|
2386
2826
|
if (updated === null) {
|
|
2387
|
-
throw new
|
|
2827
|
+
throw new import_common10.GoneException(`queued message ${messageId} already started or was removed`);
|
|
2388
2828
|
}
|
|
2389
2829
|
}
|
|
2390
2830
|
if (patch.position !== void 0) {
|
|
2391
2831
|
if (!Number.isInteger(patch.position) || patch.position < 0) {
|
|
2392
|
-
throw new
|
|
2832
|
+
throw new import_common10.BadRequestException("position must be a non-negative integer");
|
|
2393
2833
|
}
|
|
2394
2834
|
if (!await store.moveQueuedMessage(messageId, patch.position)) {
|
|
2395
|
-
throw new
|
|
2835
|
+
throw new import_common10.GoneException(`queued message ${messageId} already started or was removed`);
|
|
2396
2836
|
}
|
|
2397
2837
|
}
|
|
2398
2838
|
return queue.publish(threadId);
|
|
@@ -2402,7 +2842,7 @@ var AgentService = class {
|
|
|
2402
2842
|
const queue = this.requireQueue();
|
|
2403
2843
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
2404
2844
|
if (!await queue.queueStore().removeQueuedMessage(messageId)) {
|
|
2405
|
-
throw new
|
|
2845
|
+
throw new import_common10.GoneException(`queued message ${messageId} already started or was removed`);
|
|
2406
2846
|
}
|
|
2407
2847
|
return queue.publish(threadId);
|
|
2408
2848
|
}
|
|
@@ -2421,7 +2861,7 @@ var AgentService = class {
|
|
|
2421
2861
|
const queue = this.requireQueue();
|
|
2422
2862
|
const store = queue.queueStore();
|
|
2423
2863
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
2424
|
-
const gone = /* @__PURE__ */ __name(() => new
|
|
2864
|
+
const gone = /* @__PURE__ */ __name(() => new import_common10.GoneException(`queued message ${messageId} already started or was removed`), "gone");
|
|
2425
2865
|
const marked = await store.updateQueuedMessage(messageId, {
|
|
2426
2866
|
interrupt: true
|
|
2427
2867
|
});
|
|
@@ -2429,7 +2869,7 @@ var AgentService = class {
|
|
|
2429
2869
|
throw gone();
|
|
2430
2870
|
}
|
|
2431
2871
|
if (marked.interrupt !== true) {
|
|
2432
|
-
throw new
|
|
2872
|
+
throw new import_common10.NotImplementedException("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
|
|
2433
2873
|
}
|
|
2434
2874
|
if (!await store.moveQueuedMessage(messageId, 0)) {
|
|
2435
2875
|
throw gone();
|
|
@@ -2488,7 +2928,7 @@ var AgentService = class {
|
|
|
2488
2928
|
async assertOwnsQueuedMessage(actor, messageId) {
|
|
2489
2929
|
const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
|
|
2490
2930
|
if (message === null) {
|
|
2491
|
-
throw new
|
|
2931
|
+
throw new import_common10.NotFoundException(`queued message ${messageId} not found`);
|
|
2492
2932
|
}
|
|
2493
2933
|
await this.assertOwnsThread(actor, message.threadId);
|
|
2494
2934
|
return message.threadId;
|
|
@@ -2509,7 +2949,7 @@ var AgentService = class {
|
|
|
2509
2949
|
}
|
|
2510
2950
|
const staging = this.staging;
|
|
2511
2951
|
if (staging === void 0 || typeof staging.resolve !== "function") {
|
|
2512
|
-
throw new
|
|
2952
|
+
throw new import_common10.NotImplementedException("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
|
|
2513
2953
|
}
|
|
2514
2954
|
const resolved = [];
|
|
2515
2955
|
for (const ref of refs) {
|
|
@@ -2518,7 +2958,7 @@ var AgentService = class {
|
|
|
2518
2958
|
actor
|
|
2519
2959
|
});
|
|
2520
2960
|
if (attachment === null) {
|
|
2521
|
-
throw new
|
|
2961
|
+
throw new import_common10.ForbiddenException(`attachment ${ref.mediaId} is not available to this actor`);
|
|
2522
2962
|
}
|
|
2523
2963
|
resolved.push(attachment);
|
|
2524
2964
|
}
|
|
@@ -2620,6 +3060,7 @@ var AgentService = class {
|
|
|
2620
3060
|
* not the thread's own actor).
|
|
2621
3061
|
*/
|
|
2622
3062
|
async signalToolCall(toolCallId2, reply) {
|
|
3063
|
+
if ((await this.store.toolCallApproval?.(toolCallId2))?.status === "proposed") throw new import_common10.ConflictException("Independent proposals require the scoped proposal decision route");
|
|
2623
3064
|
await this.assertNotExpired(toolCallId2);
|
|
2624
3065
|
const runId = await this.resolveRunForToolCall(toolCallId2);
|
|
2625
3066
|
await this.assertRunWaiting(runId);
|
|
@@ -2640,7 +3081,7 @@ var AgentService = class {
|
|
|
2640
3081
|
if (active) {
|
|
2641
3082
|
return;
|
|
2642
3083
|
}
|
|
2643
|
-
await (0,
|
|
3084
|
+
await (0, import_nestjs_agent_core14.settleDeadRun)(this.store, {
|
|
2644
3085
|
runId
|
|
2645
3086
|
});
|
|
2646
3087
|
throw new RunNotActiveException(runId);
|
|
@@ -2660,7 +3101,7 @@ var AgentService = class {
|
|
|
2660
3101
|
throw new RunNotActiveException(runId);
|
|
2661
3102
|
}
|
|
2662
3103
|
if (owner !== actor.id) {
|
|
2663
|
-
throw new
|
|
3104
|
+
throw new import_common10.ForbiddenException("run belongs to another actor");
|
|
2664
3105
|
}
|
|
2665
3106
|
}
|
|
2666
3107
|
/**
|
|
@@ -2720,7 +3161,7 @@ var AgentService = class {
|
|
|
2720
3161
|
return;
|
|
2721
3162
|
}
|
|
2722
3163
|
if (this.store.updateThread === void 0) {
|
|
2723
|
-
throw new
|
|
3164
|
+
throw new import_common10.NotImplementedException("Setting a thread's defaultAgent, model or persona requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
2724
3165
|
}
|
|
2725
3166
|
const model = patch.model === void 0 || patch.model === null ? patch.model : await this.assertModelAllowed(actor, patch.defaultAgent ?? await this.resolveAgentName(void 0, threadId), patch.model);
|
|
2726
3167
|
if (patch.persona !== void 0 && patch.persona !== null) {
|
|
@@ -2774,10 +3215,10 @@ var AgentService = class {
|
|
|
2774
3215
|
validateTitle(title) {
|
|
2775
3216
|
const trimmed = title.trim();
|
|
2776
3217
|
if (trimmed.length === 0) {
|
|
2777
|
-
throw new
|
|
3218
|
+
throw new import_common10.BadRequestException("title must not be empty");
|
|
2778
3219
|
}
|
|
2779
3220
|
if (trimmed.length > 200) {
|
|
2780
|
-
throw new
|
|
3221
|
+
throw new import_common10.BadRequestException("title must be at most 200 characters");
|
|
2781
3222
|
}
|
|
2782
3223
|
return trimmed;
|
|
2783
3224
|
}
|
|
@@ -2881,21 +3322,21 @@ var AgentService = class {
|
|
|
2881
3322
|
*/
|
|
2882
3323
|
async setMessageFeedback(actor, messageId, input) {
|
|
2883
3324
|
if (input.value !== null && input.value !== "up" && input.value !== "down") {
|
|
2884
|
-
throw new
|
|
3325
|
+
throw new import_common10.BadRequestException("value must be 'up', 'down' or null");
|
|
2885
3326
|
}
|
|
2886
3327
|
if (input.comment !== void 0 && typeof input.comment !== "string") {
|
|
2887
|
-
throw new
|
|
3328
|
+
throw new import_common10.BadRequestException("comment must be a string");
|
|
2888
3329
|
}
|
|
2889
3330
|
const comment = input.comment?.trim();
|
|
2890
3331
|
if (comment !== void 0 && comment.length > 2e3) {
|
|
2891
|
-
throw new
|
|
3332
|
+
throw new import_common10.BadRequestException("comment must be at most 2000 characters");
|
|
2892
3333
|
}
|
|
2893
3334
|
if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
|
|
2894
|
-
throw new
|
|
3335
|
+
throw new import_common10.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
|
|
2895
3336
|
}
|
|
2896
3337
|
const threadId = await this.store.threadOfMessage(messageId);
|
|
2897
3338
|
if (threadId === null) {
|
|
2898
|
-
throw new
|
|
3339
|
+
throw new import_common10.NotFoundException(`message ${messageId} not found`);
|
|
2899
3340
|
}
|
|
2900
3341
|
await this.assertOwnsThread(actor, threadId);
|
|
2901
3342
|
const feedback = input.value === null ? null : {
|
|
@@ -2943,7 +3384,7 @@ var AgentService = class {
|
|
|
2943
3384
|
const list = this.attachmentInventory();
|
|
2944
3385
|
const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
|
|
2945
3386
|
if (referencedMediaIds === void 0) {
|
|
2946
|
-
throw new
|
|
3387
|
+
throw new import_common10.NotImplementedException("Collecting attachments requires an AgentStore that implements referencedMediaIds(); the bound store cannot say which media a message still references, and guessing would delete files that are in use.");
|
|
2947
3388
|
}
|
|
2948
3389
|
const stagedBefore = options.olderThan.toISOString();
|
|
2949
3390
|
const inventory = await list({
|
|
@@ -2965,7 +3406,7 @@ var AgentService = class {
|
|
|
2965
3406
|
attachmentInventory() {
|
|
2966
3407
|
const list = this.staging?.list?.bind(this.staging);
|
|
2967
3408
|
if (list === void 0) {
|
|
2968
|
-
throw new
|
|
3409
|
+
throw new import_common10.NotImplementedException("Listing attachments requires an AGENT_ATTACHMENT_STAGING provider implementing list(); the host owns the staged bytes, so only it can enumerate them.");
|
|
2969
3410
|
}
|
|
2970
3411
|
return list;
|
|
2971
3412
|
}
|
|
@@ -2976,10 +3417,10 @@ var AgentService = class {
|
|
|
2976
3417
|
async assertOwnsThread(actor, threadId) {
|
|
2977
3418
|
const owner = await this.store.ownerOfThread(threadId);
|
|
2978
3419
|
if (owner === null) {
|
|
2979
|
-
throw new
|
|
3420
|
+
throw new import_common10.NotFoundException(`thread ${threadId} not found`);
|
|
2980
3421
|
}
|
|
2981
3422
|
if (owner !== actor.id) {
|
|
2982
|
-
throw new
|
|
3423
|
+
throw new import_common10.ForbiddenException("thread belongs to another actor");
|
|
2983
3424
|
}
|
|
2984
3425
|
}
|
|
2985
3426
|
/**
|
|
@@ -2990,10 +3431,10 @@ var AgentService = class {
|
|
|
2990
3431
|
async assertOwnsToolCall(actor, toolCallId2) {
|
|
2991
3432
|
const owner = await this.store.ownerOfToolCall(toolCallId2);
|
|
2992
3433
|
if (owner === null) {
|
|
2993
|
-
throw new
|
|
3434
|
+
throw new import_common10.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
2994
3435
|
}
|
|
2995
3436
|
if (owner !== actor.id) {
|
|
2996
|
-
throw new
|
|
3437
|
+
throw new import_common10.ForbiddenException("tool call belongs to another actor");
|
|
2997
3438
|
}
|
|
2998
3439
|
}
|
|
2999
3440
|
/**
|
|
@@ -3008,12 +3449,12 @@ var AgentService = class {
|
|
|
3008
3449
|
if (this.store.toolCallInput === void 0) {
|
|
3009
3450
|
return;
|
|
3010
3451
|
}
|
|
3011
|
-
const questions = (0,
|
|
3452
|
+
const questions = (0, import_nestjs_agent_core14.readElicitationQuestions)(await this.store.toolCallInput(toolCallId2));
|
|
3012
3453
|
for (const question of questions) {
|
|
3013
3454
|
const submitted = Object.hasOwn(answers2, question.id) ? answers2[question.id] : void 0;
|
|
3014
|
-
const problem = (0,
|
|
3455
|
+
const problem = (0, import_nestjs_agent_core14.validateElicitationAnswer)(question, submitted ?? question.defaults ?? []);
|
|
3015
3456
|
if (problem !== null) {
|
|
3016
|
-
throw new
|
|
3457
|
+
throw new import_common10.BadRequestException(`answers["${question.id}"] ${problem}`);
|
|
3017
3458
|
}
|
|
3018
3459
|
}
|
|
3019
3460
|
}
|
|
@@ -3025,21 +3466,21 @@ var AgentService = class {
|
|
|
3025
3466
|
*/
|
|
3026
3467
|
async assertMayDecide(actor, toolCallId2) {
|
|
3027
3468
|
const approval = await this.store.toolCallApproval?.(toolCallId2);
|
|
3028
|
-
const approver = approval?.approver ??
|
|
3029
|
-
if (approver ===
|
|
3469
|
+
const approver = approval?.approver ?? import_nestjs_agent_core14.REQUESTER_APPROVER;
|
|
3470
|
+
if (approver === import_nestjs_agent_core14.REQUESTER_APPROVER) {
|
|
3030
3471
|
return this.assertOwnsToolCall(actor, toolCallId2);
|
|
3031
3472
|
}
|
|
3032
3473
|
const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
|
|
3033
3474
|
if (requesterRef === null) {
|
|
3034
|
-
throw new
|
|
3475
|
+
throw new import_common10.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
3035
3476
|
}
|
|
3036
|
-
const allowed = await (0,
|
|
3477
|
+
const allowed = await (0, import_nestjs_agent_core14.mayDecideApproval)(this.deps.forAgent().approvalPolicy, actor, {
|
|
3037
3478
|
toolCallId: toolCallId2,
|
|
3038
3479
|
approver,
|
|
3039
3480
|
requesterRef
|
|
3040
3481
|
});
|
|
3041
3482
|
if (!allowed) {
|
|
3042
|
-
throw new
|
|
3483
|
+
throw new import_common10.ForbiddenException(`this approval is for ${approver}`);
|
|
3043
3484
|
}
|
|
3044
3485
|
}
|
|
3045
3486
|
/**
|
|
@@ -3055,7 +3496,7 @@ var AgentService = class {
|
|
|
3055
3496
|
}
|
|
3056
3497
|
const lapsed = approval.status === "expired" || approval.status === "pending_approval" && approval.expiresAt !== null && Date.parse(approval.expiresAt) <= Date.now();
|
|
3057
3498
|
if (lapsed) {
|
|
3058
|
-
throw new
|
|
3499
|
+
throw new import_common10.GoneException(`the approval request for tool call ${toolCallId2} has expired`);
|
|
3059
3500
|
}
|
|
3060
3501
|
}
|
|
3061
3502
|
/**
|
|
@@ -3068,7 +3509,7 @@ var AgentService = class {
|
|
|
3068
3509
|
async resolveRunForToolCall(toolCallId2) {
|
|
3069
3510
|
const runId = await this.store.runForToolCall(toolCallId2);
|
|
3070
3511
|
if (runId === null) {
|
|
3071
|
-
throw new
|
|
3512
|
+
throw new import_common10.NotFoundException(`tool call ${toolCallId2} has no active run to signal`);
|
|
3072
3513
|
}
|
|
3073
3514
|
return runId;
|
|
3074
3515
|
}
|
|
@@ -3076,43 +3517,45 @@ var AgentService = class {
|
|
|
3076
3517
|
async assertOwnsActiveStream(actor, runId) {
|
|
3077
3518
|
const owner = await this.store.ownerOfActiveStream(runId);
|
|
3078
3519
|
if (owner === null) {
|
|
3079
|
-
throw new
|
|
3520
|
+
throw new import_common10.NotFoundException(`no active run ${runId}`);
|
|
3080
3521
|
}
|
|
3081
3522
|
if (owner !== actor.id) {
|
|
3082
|
-
throw new
|
|
3523
|
+
throw new import_common10.ForbiddenException("run belongs to another actor");
|
|
3083
3524
|
}
|
|
3084
3525
|
}
|
|
3085
3526
|
};
|
|
3086
|
-
AgentService =
|
|
3087
|
-
(0,
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3527
|
+
AgentService = _ts_decorate9([
|
|
3528
|
+
(0, import_common10.Injectable)(),
|
|
3529
|
+
_ts_param7(0, (0, import_common10.Inject)(import_nestjs_agent_core14.AGENT_RUNNER)),
|
|
3530
|
+
_ts_param7(1, (0, import_common10.Inject)(import_nestjs_agent_core14.AGENT_STORE)),
|
|
3531
|
+
_ts_param7(2, (0, import_common10.Inject)(import_nestjs_agent_core14.AGENT_DEPS_FACTORY)),
|
|
3532
|
+
_ts_param7(3, (0, import_common10.Optional)()),
|
|
3533
|
+
_ts_param7(3, (0, import_common10.Inject)(import_nestjs_agent_core14.AGENT_ATTACHMENT_STAGING)),
|
|
3534
|
+
_ts_param7(4, (0, import_common10.Optional)()),
|
|
3535
|
+
_ts_param7(4, (0, import_common10.Inject)(import_nestjs_agent_core14.AGENT_MODEL_CATALOG)),
|
|
3536
|
+
_ts_param7(5, (0, import_common10.Optional)()),
|
|
3537
|
+
_ts_param7(5, (0, import_common10.Inject)(import_nestjs_agent_core14.AGENT_QUOTA_PROVIDER)),
|
|
3538
|
+
_ts_param7(6, (0, import_common10.Optional)()),
|
|
3539
|
+
_ts_param7(6, (0, import_common10.Inject)(import_nestjs_agent_core14.AGENT_OPTIONS)),
|
|
3540
|
+
_ts_param7(7, (0, import_common10.Optional)()),
|
|
3541
|
+
_ts_param7(8, (0, import_common10.Optional)()),
|
|
3542
|
+
_ts_metadata7("design:type", Function),
|
|
3543
|
+
_ts_metadata7("design:paramtypes", [
|
|
3544
|
+
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
3103
3545
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
3104
3546
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3105
3547
|
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
|
|
3106
3548
|
typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
|
|
3107
3549
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
3108
3550
|
typeof Pick === "undefined" ? Object : Pick,
|
|
3109
|
-
typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2
|
|
3551
|
+
typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2,
|
|
3552
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService
|
|
3110
3553
|
])
|
|
3111
3554
|
], AgentService);
|
|
3112
3555
|
|
|
3113
3556
|
// src/approval-port.adapter.ts
|
|
3114
|
-
var
|
|
3115
|
-
function
|
|
3557
|
+
var import_common11 = require("@nestjs/common");
|
|
3558
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
3116
3559
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3117
3560
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3118
3561
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3125,20 +3568,48 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
3125
3568
|
}
|
|
3126
3569
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3127
3570
|
}
|
|
3128
|
-
__name(
|
|
3129
|
-
function
|
|
3571
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
3572
|
+
function _ts_metadata8(metadataKey, metadataValue) {
|
|
3130
3573
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3131
3574
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3132
3575
|
}
|
|
3133
3576
|
}
|
|
3134
|
-
__name(
|
|
3577
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
3578
|
+
function _ts_param8(paramIndex, decorator) {
|
|
3579
|
+
return function(target, key) {
|
|
3580
|
+
decorator(target, key, paramIndex);
|
|
3581
|
+
};
|
|
3582
|
+
}
|
|
3583
|
+
__name(_ts_param8, "_ts_param");
|
|
3135
3584
|
var AgentApprovalPortAdapter = class {
|
|
3136
3585
|
static {
|
|
3137
3586
|
__name(this, "AgentApprovalPortAdapter");
|
|
3138
3587
|
}
|
|
3139
3588
|
agent;
|
|
3140
|
-
|
|
3589
|
+
proposals;
|
|
3590
|
+
constructor(agent, proposals) {
|
|
3141
3591
|
this.agent = agent;
|
|
3592
|
+
this.proposals = proposals;
|
|
3593
|
+
}
|
|
3594
|
+
async approveActionProposal(actor, target, opts) {
|
|
3595
|
+
if (!this.proposals) throw new import_common11.NotImplementedException("Action proposals unavailable");
|
|
3596
|
+
return this.proposals.decide(target.threadId, target.proposalId, actor, {
|
|
3597
|
+
decision: "approved",
|
|
3598
|
+
...opts?.remember !== void 0 ? {
|
|
3599
|
+
remember: opts.remember
|
|
3600
|
+
} : {},
|
|
3601
|
+
via: opts?.decidedVia ?? "console"
|
|
3602
|
+
});
|
|
3603
|
+
}
|
|
3604
|
+
async rejectActionProposal(actor, target, opts) {
|
|
3605
|
+
if (!this.proposals) throw new import_common11.NotImplementedException("Action proposals unavailable");
|
|
3606
|
+
return this.proposals.decide(target.threadId, target.proposalId, actor, {
|
|
3607
|
+
decision: "rejected",
|
|
3608
|
+
...opts?.reason !== void 0 ? {
|
|
3609
|
+
reason: opts.reason
|
|
3610
|
+
} : {},
|
|
3611
|
+
via: opts?.decidedVia ?? "console"
|
|
3612
|
+
});
|
|
3142
3613
|
}
|
|
3143
3614
|
async approve(toolCallId2, opts) {
|
|
3144
3615
|
await this.agent.signalToolCall(toolCallId2, {
|
|
@@ -3169,18 +3640,20 @@ var AgentApprovalPortAdapter = class {
|
|
|
3169
3640
|
});
|
|
3170
3641
|
}
|
|
3171
3642
|
};
|
|
3172
|
-
AgentApprovalPortAdapter =
|
|
3173
|
-
(0,
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3643
|
+
AgentApprovalPortAdapter = _ts_decorate10([
|
|
3644
|
+
(0, import_common11.Injectable)(),
|
|
3645
|
+
_ts_param8(1, (0, import_common11.Optional)()),
|
|
3646
|
+
_ts_metadata8("design:type", Function),
|
|
3647
|
+
_ts_metadata8("design:paramtypes", [
|
|
3648
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3649
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService
|
|
3177
3650
|
])
|
|
3178
3651
|
], AgentApprovalPortAdapter);
|
|
3179
3652
|
|
|
3180
3653
|
// src/controller/agents.controller.ts
|
|
3181
|
-
var
|
|
3182
|
-
var
|
|
3183
|
-
function
|
|
3654
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
3655
|
+
var import_common12 = require("@nestjs/common");
|
|
3656
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
3184
3657
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3185
3658
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3186
3659
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3193,19 +3666,19 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
3193
3666
|
}
|
|
3194
3667
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3195
3668
|
}
|
|
3196
|
-
__name(
|
|
3197
|
-
function
|
|
3669
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
3670
|
+
function _ts_metadata9(metadataKey, metadataValue) {
|
|
3198
3671
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3199
3672
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3200
3673
|
}
|
|
3201
3674
|
}
|
|
3202
|
-
__name(
|
|
3203
|
-
function
|
|
3675
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
3676
|
+
function _ts_param9(paramIndex, decorator) {
|
|
3204
3677
|
return function(target, key) {
|
|
3205
3678
|
decorator(target, key, paramIndex);
|
|
3206
3679
|
};
|
|
3207
3680
|
}
|
|
3208
|
-
__name(
|
|
3681
|
+
__name(_ts_param9, "_ts_param");
|
|
3209
3682
|
var AgentsController = class {
|
|
3210
3683
|
static {
|
|
3211
3684
|
__name(this, "AgentsController");
|
|
@@ -3236,26 +3709,26 @@ var AgentsController = class {
|
|
|
3236
3709
|
});
|
|
3237
3710
|
}
|
|
3238
3711
|
};
|
|
3239
|
-
|
|
3240
|
-
(0,
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3712
|
+
_ts_decorate11([
|
|
3713
|
+
(0, import_common12.Get)(),
|
|
3714
|
+
_ts_metadata9("design:type", Function),
|
|
3715
|
+
_ts_metadata9("design:paramtypes", []),
|
|
3716
|
+
_ts_metadata9("design:returntype", Array)
|
|
3244
3717
|
], AgentsController.prototype, "list", null);
|
|
3245
|
-
AgentsController =
|
|
3246
|
-
(0,
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
typeof
|
|
3718
|
+
AgentsController = _ts_decorate11([
|
|
3719
|
+
(0, import_common12.Controller)("agents"),
|
|
3720
|
+
_ts_param9(0, (0, import_common12.Inject)(import_nestjs_agent_core15.AGENT_REGISTRY)),
|
|
3721
|
+
_ts_param9(1, (0, import_common12.Inject)(import_nestjs_agent_core15.AGENT_DEPS_FACTORY)),
|
|
3722
|
+
_ts_metadata9("design:type", Function),
|
|
3723
|
+
_ts_metadata9("design:paramtypes", [
|
|
3724
|
+
typeof import_nestjs_agent_core15.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core15.AgentRegistry,
|
|
3252
3725
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
3253
3726
|
])
|
|
3254
3727
|
], AgentsController);
|
|
3255
3728
|
|
|
3256
3729
|
// src/controller/attachments.controller.ts
|
|
3257
|
-
var
|
|
3258
|
-
var
|
|
3730
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
3731
|
+
var import_common13 = require("@nestjs/common");
|
|
3259
3732
|
var import_platform_express = require("@nestjs/platform-express");
|
|
3260
3733
|
|
|
3261
3734
|
// src/attachment-limits.ts
|
|
@@ -3284,7 +3757,7 @@ function attachmentLimits(options, staging) {
|
|
|
3284
3757
|
__name(attachmentLimits, "attachmentLimits");
|
|
3285
3758
|
|
|
3286
3759
|
// src/controller/attachments.controller.ts
|
|
3287
|
-
function
|
|
3760
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
3288
3761
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3289
3762
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3290
3763
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3297,19 +3770,19 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
3297
3770
|
}
|
|
3298
3771
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3299
3772
|
}
|
|
3300
|
-
__name(
|
|
3301
|
-
function
|
|
3773
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
3774
|
+
function _ts_metadata10(metadataKey, metadataValue) {
|
|
3302
3775
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3303
3776
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3304
3777
|
}
|
|
3305
3778
|
}
|
|
3306
|
-
__name(
|
|
3307
|
-
function
|
|
3779
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
3780
|
+
function _ts_param10(paramIndex, decorator) {
|
|
3308
3781
|
return function(target, key) {
|
|
3309
3782
|
decorator(target, key, paramIndex);
|
|
3310
3783
|
};
|
|
3311
3784
|
}
|
|
3312
|
-
__name(
|
|
3785
|
+
__name(_ts_param10, "_ts_param");
|
|
3313
3786
|
var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
3314
3787
|
var ATTACHMENT_PAGE_SIZE = 50;
|
|
3315
3788
|
var AttachmentsController = class {
|
|
@@ -3343,17 +3816,17 @@ var AttachmentsController = class {
|
|
|
3343
3816
|
}
|
|
3344
3817
|
async upload(req, file) {
|
|
3345
3818
|
if (this.staging === void 0) {
|
|
3346
|
-
throw new
|
|
3819
|
+
throw new import_common13.NotImplementedException("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
|
|
3347
3820
|
}
|
|
3348
3821
|
if (file === void 0) {
|
|
3349
|
-
throw new
|
|
3822
|
+
throw new import_common13.BadRequestException('multipart field "file" is required');
|
|
3350
3823
|
}
|
|
3351
3824
|
const { allowedContentTypes, maxBytes } = attachmentLimits(this.options, this.staging);
|
|
3352
3825
|
if (!allowedContentTypes.includes(file.mimetype)) {
|
|
3353
|
-
throw new
|
|
3826
|
+
throw new import_common13.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
|
|
3354
3827
|
}
|
|
3355
3828
|
if (file.size > maxBytes) {
|
|
3356
|
-
throw new
|
|
3829
|
+
throw new import_common13.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
|
|
3357
3830
|
}
|
|
3358
3831
|
const actor = await this.actorResolver.resolve(req);
|
|
3359
3832
|
return this.staging.stage({
|
|
@@ -3365,39 +3838,39 @@ var AttachmentsController = class {
|
|
|
3365
3838
|
});
|
|
3366
3839
|
}
|
|
3367
3840
|
};
|
|
3368
|
-
|
|
3369
|
-
(0,
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3841
|
+
_ts_decorate12([
|
|
3842
|
+
(0, import_common13.Get)(),
|
|
3843
|
+
_ts_param10(0, (0, import_common13.Req)()),
|
|
3844
|
+
_ts_metadata10("design:type", Function),
|
|
3845
|
+
_ts_metadata10("design:paramtypes", [
|
|
3373
3846
|
typeof Request === "undefined" ? Object : Request
|
|
3374
3847
|
]),
|
|
3375
|
-
|
|
3848
|
+
_ts_metadata10("design:returntype", Promise)
|
|
3376
3849
|
], AttachmentsController.prototype, "list", null);
|
|
3377
|
-
|
|
3378
|
-
(0,
|
|
3379
|
-
(0,
|
|
3850
|
+
_ts_decorate12([
|
|
3851
|
+
(0, import_common13.Post)(),
|
|
3852
|
+
(0, import_common13.UseInterceptors)((0, import_platform_express.FileInterceptor)("file", {
|
|
3380
3853
|
limits: {
|
|
3381
3854
|
fileSize: HARD_MAX_ATTACHMENT_BYTES
|
|
3382
3855
|
}
|
|
3383
3856
|
})),
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3857
|
+
_ts_param10(0, (0, import_common13.Req)()),
|
|
3858
|
+
_ts_param10(1, (0, import_common13.UploadedFile)()),
|
|
3859
|
+
_ts_metadata10("design:type", Function),
|
|
3860
|
+
_ts_metadata10("design:paramtypes", [
|
|
3388
3861
|
typeof Request === "undefined" ? Object : Request,
|
|
3389
3862
|
Object
|
|
3390
3863
|
]),
|
|
3391
|
-
|
|
3864
|
+
_ts_metadata10("design:returntype", Promise)
|
|
3392
3865
|
], AttachmentsController.prototype, "upload", null);
|
|
3393
|
-
AttachmentsController =
|
|
3394
|
-
(0,
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3866
|
+
AttachmentsController = _ts_decorate12([
|
|
3867
|
+
(0, import_common13.Controller)("attachments"),
|
|
3868
|
+
_ts_param10(0, (0, import_common13.Inject)(import_nestjs_agent_core16.AGENT_OPTIONS)),
|
|
3869
|
+
_ts_param10(1, (0, import_common13.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
|
|
3870
|
+
_ts_param10(3, (0, import_common13.Optional)()),
|
|
3871
|
+
_ts_param10(3, (0, import_common13.Inject)(import_nestjs_agent_core16.AGENT_ATTACHMENT_STAGING)),
|
|
3872
|
+
_ts_metadata10("design:type", Function),
|
|
3873
|
+
_ts_metadata10("design:paramtypes", [
|
|
3401
3874
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
3402
3875
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3403
3876
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -3406,9 +3879,10 @@ AttachmentsController = _ts_decorate10([
|
|
|
3406
3879
|
], AttachmentsController);
|
|
3407
3880
|
|
|
3408
3881
|
// src/controller/chat.controller.ts
|
|
3409
|
-
var
|
|
3410
|
-
var
|
|
3411
|
-
|
|
3882
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
3883
|
+
var import_genui2 = require("@dudousxd/nestjs-agent-core/genui");
|
|
3884
|
+
var import_common14 = require("@nestjs/common");
|
|
3885
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
3412
3886
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3413
3887
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3414
3888
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3421,19 +3895,19 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
3421
3895
|
}
|
|
3422
3896
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3423
3897
|
}
|
|
3424
|
-
__name(
|
|
3425
|
-
function
|
|
3898
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
3899
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
3426
3900
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3427
3901
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3428
3902
|
}
|
|
3429
3903
|
}
|
|
3430
|
-
__name(
|
|
3431
|
-
function
|
|
3904
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
3905
|
+
function _ts_param11(paramIndex, decorator) {
|
|
3432
3906
|
return function(target, key) {
|
|
3433
3907
|
decorator(target, key, paramIndex);
|
|
3434
3908
|
};
|
|
3435
3909
|
}
|
|
3436
|
-
__name(
|
|
3910
|
+
__name(_ts_param11, "_ts_param");
|
|
3437
3911
|
function sendMode(body) {
|
|
3438
3912
|
if (body.interrupt === true) {
|
|
3439
3913
|
return "interrupt";
|
|
@@ -3444,7 +3918,7 @@ function sendMode(body) {
|
|
|
3444
3918
|
if (body.mode === "auto" || body.mode === "queue" || body.mode === "interrupt") {
|
|
3445
3919
|
return body.mode;
|
|
3446
3920
|
}
|
|
3447
|
-
throw new
|
|
3921
|
+
throw new import_common14.BadRequestException("mode must be 'auto', 'queue' or 'interrupt'");
|
|
3448
3922
|
}
|
|
3449
3923
|
__name(sendMode, "sendMode");
|
|
3450
3924
|
function attachmentRefs(claimed) {
|
|
@@ -3452,21 +3926,21 @@ function attachmentRefs(claimed) {
|
|
|
3452
3926
|
return [];
|
|
3453
3927
|
}
|
|
3454
3928
|
if (!Array.isArray(claimed)) {
|
|
3455
|
-
throw new
|
|
3929
|
+
throw new import_common14.BadRequestException("attachments must be an array of { mediaId }");
|
|
3456
3930
|
}
|
|
3457
3931
|
if (claimed.length > MAX_ATTACHMENTS_PER_MESSAGE) {
|
|
3458
|
-
throw new
|
|
3932
|
+
throw new import_common14.BadRequestException(`a message may carry at most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments`);
|
|
3459
3933
|
}
|
|
3460
3934
|
return claimed.map((entry) => {
|
|
3461
3935
|
if (typeof entry !== "object" || entry === null || !("mediaId" in entry)) {
|
|
3462
|
-
throw new
|
|
3936
|
+
throw new import_common14.BadRequestException("each attachment must be an object with a mediaId");
|
|
3463
3937
|
}
|
|
3464
3938
|
if (Object.keys(entry).some((key) => key !== "mediaId")) {
|
|
3465
|
-
throw new
|
|
3939
|
+
throw new import_common14.BadRequestException("attachments are { mediaId } refs \u2014 send nothing but the id");
|
|
3466
3940
|
}
|
|
3467
3941
|
const { mediaId } = entry;
|
|
3468
3942
|
if (typeof mediaId !== "string" || mediaId.length === 0) {
|
|
3469
|
-
throw new
|
|
3943
|
+
throw new import_common14.BadRequestException("each attachment must carry a non-empty string mediaId");
|
|
3470
3944
|
}
|
|
3471
3945
|
return {
|
|
3472
3946
|
mediaId
|
|
@@ -3494,9 +3968,18 @@ var ChatController = class {
|
|
|
3494
3968
|
const actor = await this.actorResolver.resolve(req);
|
|
3495
3969
|
const attachments = attachmentRefs(body.attachments);
|
|
3496
3970
|
const mode = sendMode(body);
|
|
3971
|
+
let uiCapabilities;
|
|
3972
|
+
try {
|
|
3973
|
+
uiCapabilities = body.uiCapabilities === void 0 ? void 0 : (0, import_genui2.validateUiCapabilities)(body.uiCapabilities);
|
|
3974
|
+
} catch {
|
|
3975
|
+
throw new import_common14.BadRequestException("Invalid UI capabilities");
|
|
3976
|
+
}
|
|
3497
3977
|
const result = await this.agent.send({
|
|
3498
3978
|
actor,
|
|
3499
3979
|
message: body.message,
|
|
3980
|
+
...uiCapabilities !== void 0 ? {
|
|
3981
|
+
uiCapabilities
|
|
3982
|
+
} : {},
|
|
3500
3983
|
...body.threadId !== void 0 ? {
|
|
3501
3984
|
threadId: body.threadId
|
|
3502
3985
|
} : {},
|
|
@@ -3523,6 +4006,10 @@ var ChatController = class {
|
|
|
3523
4006
|
} : {},
|
|
3524
4007
|
mode
|
|
3525
4008
|
});
|
|
4009
|
+
if ("proposalDecision" in result) {
|
|
4010
|
+
res.status(200).json(result);
|
|
4011
|
+
return;
|
|
4012
|
+
}
|
|
3526
4013
|
if (result.queued === true) {
|
|
3527
4014
|
res.status(202).json(result);
|
|
3528
4015
|
return;
|
|
@@ -3602,10 +4089,10 @@ data: ${line}
|
|
|
3602
4089
|
}
|
|
3603
4090
|
res.write("event: done\ndata: {}\n\n");
|
|
3604
4091
|
} catch (error) {
|
|
3605
|
-
const payload = error instanceof
|
|
4092
|
+
const payload = error instanceof import_nestjs_agent_core17.AgentStreamError ? {
|
|
3606
4093
|
code: error.code,
|
|
3607
4094
|
message: error.message
|
|
3608
|
-
} : (0,
|
|
4095
|
+
} : (0, import_nestjs_agent_core17.streamFailure)(error);
|
|
3609
4096
|
res.write(`event: error
|
|
3610
4097
|
data: ${JSON.stringify(payload)}
|
|
3611
4098
|
|
|
@@ -3614,50 +4101,50 @@ data: ${JSON.stringify(payload)}
|
|
|
3614
4101
|
res.end();
|
|
3615
4102
|
}
|
|
3616
4103
|
};
|
|
3617
|
-
|
|
3618
|
-
(0,
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
4104
|
+
_ts_decorate13([
|
|
4105
|
+
(0, import_common14.Post)("chat"),
|
|
4106
|
+
_ts_param11(0, (0, import_common14.Req)()),
|
|
4107
|
+
_ts_param11(1, (0, import_common14.Res)()),
|
|
4108
|
+
_ts_param11(2, (0, import_common14.Body)()),
|
|
4109
|
+
_ts_metadata11("design:type", Function),
|
|
4110
|
+
_ts_metadata11("design:paramtypes", [
|
|
3624
4111
|
typeof Request === "undefined" ? Object : Request,
|
|
3625
4112
|
typeof Response === "undefined" ? Object : Response,
|
|
3626
4113
|
typeof ChatBody === "undefined" ? Object : ChatBody
|
|
3627
4114
|
]),
|
|
3628
|
-
|
|
4115
|
+
_ts_metadata11("design:returntype", Promise)
|
|
3629
4116
|
], ChatController.prototype, "chat", null);
|
|
3630
|
-
|
|
3631
|
-
(0,
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
4117
|
+
_ts_decorate13([
|
|
4118
|
+
(0, import_common14.Get)("chat/:runId/stream"),
|
|
4119
|
+
_ts_param11(0, (0, import_common14.Req)()),
|
|
4120
|
+
_ts_param11(1, (0, import_common14.Param)("runId")),
|
|
4121
|
+
_ts_param11(2, (0, import_common14.Res)()),
|
|
4122
|
+
_ts_param11(3, (0, import_common14.Query)("after")),
|
|
4123
|
+
_ts_metadata11("design:type", Function),
|
|
4124
|
+
_ts_metadata11("design:paramtypes", [
|
|
3638
4125
|
typeof Request === "undefined" ? Object : Request,
|
|
3639
4126
|
String,
|
|
3640
4127
|
typeof Response === "undefined" ? Object : Response,
|
|
3641
4128
|
String
|
|
3642
4129
|
]),
|
|
3643
|
-
|
|
4130
|
+
_ts_metadata11("design:returntype", Promise)
|
|
3644
4131
|
], ChatController.prototype, "stream", null);
|
|
3645
|
-
|
|
3646
|
-
(0,
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
4132
|
+
_ts_decorate13([
|
|
4133
|
+
(0, import_common14.Post)("chat/:runId/cancel"),
|
|
4134
|
+
_ts_param11(0, (0, import_common14.Req)()),
|
|
4135
|
+
_ts_param11(1, (0, import_common14.Param)("runId")),
|
|
4136
|
+
_ts_metadata11("design:type", Function),
|
|
4137
|
+
_ts_metadata11("design:paramtypes", [
|
|
3651
4138
|
typeof Request === "undefined" ? Object : Request,
|
|
3652
4139
|
String
|
|
3653
4140
|
]),
|
|
3654
|
-
|
|
4141
|
+
_ts_metadata11("design:returntype", Promise)
|
|
3655
4142
|
], ChatController.prototype, "cancel", null);
|
|
3656
|
-
ChatController =
|
|
3657
|
-
(0,
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
4143
|
+
ChatController = _ts_decorate13([
|
|
4144
|
+
(0, import_common14.Controller)(),
|
|
4145
|
+
_ts_param11(1, (0, import_common14.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
|
|
4146
|
+
_ts_metadata11("design:type", Function),
|
|
4147
|
+
_ts_metadata11("design:paramtypes", [
|
|
3661
4148
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3662
4149
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3663
4150
|
])
|
|
@@ -3673,8 +4160,8 @@ function parseCursor(raw) {
|
|
|
3673
4160
|
__name(parseCursor, "parseCursor");
|
|
3674
4161
|
|
|
3675
4162
|
// src/controller/config.controller.ts
|
|
3676
|
-
var
|
|
3677
|
-
var
|
|
4163
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
4164
|
+
var import_common15 = require("@nestjs/common");
|
|
3678
4165
|
|
|
3679
4166
|
// src/resolver/anonymous-actor-resolver.ts
|
|
3680
4167
|
var import_node_crypto2 = require("crypto");
|
|
@@ -3764,7 +4251,7 @@ var AnonymousActorResolver = class {
|
|
|
3764
4251
|
};
|
|
3765
4252
|
|
|
3766
4253
|
// src/controller/config.controller.ts
|
|
3767
|
-
function
|
|
4254
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
3768
4255
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3769
4256
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3770
4257
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3777,19 +4264,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
3777
4264
|
}
|
|
3778
4265
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3779
4266
|
}
|
|
3780
|
-
__name(
|
|
3781
|
-
function
|
|
4267
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
4268
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
3782
4269
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3783
4270
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3784
4271
|
}
|
|
3785
4272
|
}
|
|
3786
|
-
__name(
|
|
3787
|
-
function
|
|
4273
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
4274
|
+
function _ts_param12(paramIndex, decorator) {
|
|
3788
4275
|
return function(target, key) {
|
|
3789
4276
|
decorator(target, key, paramIndex);
|
|
3790
4277
|
};
|
|
3791
4278
|
}
|
|
3792
|
-
__name(
|
|
4279
|
+
__name(_ts_param12, "_ts_param");
|
|
3793
4280
|
var ConfigController = class {
|
|
3794
4281
|
static {
|
|
3795
4282
|
__name(this, "ConfigController");
|
|
@@ -3820,25 +4307,25 @@ var ConfigController = class {
|
|
|
3820
4307
|
};
|
|
3821
4308
|
}
|
|
3822
4309
|
};
|
|
3823
|
-
|
|
3824
|
-
(0,
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
4310
|
+
_ts_decorate14([
|
|
4311
|
+
(0, import_common15.Get)(),
|
|
4312
|
+
_ts_param12(0, (0, import_common15.Req)()),
|
|
4313
|
+
_ts_metadata12("design:type", Function),
|
|
4314
|
+
_ts_metadata12("design:paramtypes", [
|
|
3828
4315
|
typeof Request === "undefined" ? Object : Request
|
|
3829
4316
|
]),
|
|
3830
|
-
|
|
4317
|
+
_ts_metadata12("design:returntype", Promise)
|
|
3831
4318
|
], ConfigController.prototype, "config", null);
|
|
3832
|
-
ConfigController =
|
|
3833
|
-
(0,
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
4319
|
+
ConfigController = _ts_decorate14([
|
|
4320
|
+
(0, import_common15.Controller)("config"),
|
|
4321
|
+
_ts_param12(0, (0, import_common15.Inject)(import_nestjs_agent_core18.AGENT_OPTIONS)),
|
|
4322
|
+
_ts_param12(1, (0, import_common15.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
|
|
4323
|
+
_ts_param12(2, (0, import_common15.Optional)()),
|
|
4324
|
+
_ts_param12(2, (0, import_common15.Inject)(import_nestjs_agent_core18.AGENT_ATTACHMENT_STAGING)),
|
|
4325
|
+
_ts_param12(3, (0, import_common15.Optional)()),
|
|
4326
|
+
_ts_param12(3, (0, import_common15.Inject)(import_nestjs_agent_core18.AGENT_MODEL_CATALOG)),
|
|
4327
|
+
_ts_metadata12("design:type", Function),
|
|
4328
|
+
_ts_metadata12("design:paramtypes", [
|
|
3842
4329
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
3843
4330
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3844
4331
|
Object,
|
|
@@ -3847,9 +4334,9 @@ ConfigController = _ts_decorate12([
|
|
|
3847
4334
|
], ConfigController);
|
|
3848
4335
|
|
|
3849
4336
|
// src/controller/memories.controller.ts
|
|
3850
|
-
var
|
|
3851
|
-
var
|
|
3852
|
-
function
|
|
4337
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
4338
|
+
var import_common16 = require("@nestjs/common");
|
|
4339
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
3853
4340
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3854
4341
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3855
4342
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3862,19 +4349,19 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
3862
4349
|
}
|
|
3863
4350
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3864
4351
|
}
|
|
3865
|
-
__name(
|
|
3866
|
-
function
|
|
4352
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
4353
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
3867
4354
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3868
4355
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3869
4356
|
}
|
|
3870
4357
|
}
|
|
3871
|
-
__name(
|
|
3872
|
-
function
|
|
4358
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
4359
|
+
function _ts_param13(paramIndex, decorator) {
|
|
3873
4360
|
return function(target, key) {
|
|
3874
4361
|
decorator(target, key, paramIndex);
|
|
3875
4362
|
};
|
|
3876
4363
|
}
|
|
3877
|
-
__name(
|
|
4364
|
+
__name(_ts_param13, "_ts_param");
|
|
3878
4365
|
var MemoriesController = class {
|
|
3879
4366
|
static {
|
|
3880
4367
|
__name(this, "MemoriesController");
|
|
@@ -3908,20 +4395,20 @@ var MemoriesController = class {
|
|
|
3908
4395
|
*/
|
|
3909
4396
|
async forget(req, id) {
|
|
3910
4397
|
if (this.memory === void 0) {
|
|
3911
|
-
throw new
|
|
4398
|
+
throw new import_common16.NotFoundException("No memory is configured in this deployment.");
|
|
3912
4399
|
}
|
|
3913
4400
|
const actor = await this.actorResolver.resolve(req);
|
|
3914
4401
|
const digest = await this.unbounded("", actor);
|
|
3915
4402
|
const entry = digest.entries.find((candidate) => candidate.id === id);
|
|
3916
4403
|
if (entry === void 0) {
|
|
3917
|
-
throw new
|
|
4404
|
+
throw new import_common16.NotFoundException(`No memory with id "${id}".`);
|
|
3918
4405
|
}
|
|
3919
|
-
const verdict = (0,
|
|
4406
|
+
const verdict = (0, import_nestjs_agent_core19.memoryForgetVerdict)({
|
|
3920
4407
|
record: entry,
|
|
3921
4408
|
actor
|
|
3922
4409
|
});
|
|
3923
4410
|
if (!verdict.allowed) {
|
|
3924
|
-
throw new
|
|
4411
|
+
throw new import_common16.ForbiddenException(verdict.reason);
|
|
3925
4412
|
}
|
|
3926
4413
|
return {
|
|
3927
4414
|
forgotten: await this.memory.provider.forget({
|
|
@@ -3935,7 +4422,7 @@ var MemoriesController = class {
|
|
|
3935
4422
|
}
|
|
3936
4423
|
async unbounded(threadId, actor) {
|
|
3937
4424
|
const config = this.memory;
|
|
3938
|
-
return await (0,
|
|
4425
|
+
return await (0, import_nestjs_agent_core19.offerMemories)({
|
|
3939
4426
|
config: {
|
|
3940
4427
|
...config,
|
|
3941
4428
|
maxMemories: Number.POSITIVE_INFINITY
|
|
@@ -3947,44 +4434,44 @@ var MemoriesController = class {
|
|
|
3947
4434
|
});
|
|
3948
4435
|
}
|
|
3949
4436
|
};
|
|
3950
|
-
|
|
3951
|
-
(0,
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
4437
|
+
_ts_decorate15([
|
|
4438
|
+
(0, import_common16.Get)(),
|
|
4439
|
+
_ts_param13(0, (0, import_common16.Req)()),
|
|
4440
|
+
_ts_param13(1, (0, import_common16.Query)("threadId")),
|
|
4441
|
+
_ts_metadata13("design:type", Function),
|
|
4442
|
+
_ts_metadata13("design:paramtypes", [
|
|
3956
4443
|
typeof Request === "undefined" ? Object : Request,
|
|
3957
4444
|
String
|
|
3958
4445
|
]),
|
|
3959
|
-
|
|
4446
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3960
4447
|
], MemoriesController.prototype, "list", null);
|
|
3961
|
-
|
|
3962
|
-
(0,
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
4448
|
+
_ts_decorate15([
|
|
4449
|
+
(0, import_common16.Delete)(":id"),
|
|
4450
|
+
_ts_param13(0, (0, import_common16.Req)()),
|
|
4451
|
+
_ts_param13(1, (0, import_common16.Param)("id")),
|
|
4452
|
+
_ts_metadata13("design:type", Function),
|
|
4453
|
+
_ts_metadata13("design:paramtypes", [
|
|
3967
4454
|
typeof Request === "undefined" ? Object : Request,
|
|
3968
4455
|
String
|
|
3969
4456
|
]),
|
|
3970
|
-
|
|
4457
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3971
4458
|
], MemoriesController.prototype, "forget", null);
|
|
3972
|
-
MemoriesController =
|
|
3973
|
-
(0,
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
4459
|
+
MemoriesController = _ts_decorate15([
|
|
4460
|
+
(0, import_common16.Controller)("memories"),
|
|
4461
|
+
_ts_param13(0, (0, import_common16.Inject)(import_nestjs_agent_core19.AGENT_ACTOR_RESOLVER)),
|
|
4462
|
+
_ts_param13(1, (0, import_common16.Optional)()),
|
|
4463
|
+
_ts_param13(1, (0, import_common16.Inject)(import_nestjs_agent_core19.AGENT_MEMORY)),
|
|
4464
|
+
_ts_metadata13("design:type", Function),
|
|
4465
|
+
_ts_metadata13("design:paramtypes", [
|
|
3979
4466
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3980
4467
|
Object
|
|
3981
4468
|
])
|
|
3982
4469
|
], MemoriesController);
|
|
3983
4470
|
|
|
3984
4471
|
// src/controller/messages.controller.ts
|
|
3985
|
-
var
|
|
3986
|
-
var
|
|
3987
|
-
function
|
|
4472
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
4473
|
+
var import_common17 = require("@nestjs/common");
|
|
4474
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
3988
4475
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3989
4476
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3990
4477
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3997,19 +4484,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
3997
4484
|
}
|
|
3998
4485
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3999
4486
|
}
|
|
4000
|
-
__name(
|
|
4001
|
-
function
|
|
4487
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
4488
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
4002
4489
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4003
4490
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4004
4491
|
}
|
|
4005
4492
|
}
|
|
4006
|
-
__name(
|
|
4007
|
-
function
|
|
4493
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
4494
|
+
function _ts_param14(paramIndex, decorator) {
|
|
4008
4495
|
return function(target, key) {
|
|
4009
4496
|
decorator(target, key, paramIndex);
|
|
4010
4497
|
};
|
|
4011
4498
|
}
|
|
4012
|
-
__name(
|
|
4499
|
+
__name(_ts_param14, "_ts_param");
|
|
4013
4500
|
var MessagesController = class {
|
|
4014
4501
|
static {
|
|
4015
4502
|
__name(this, "MessagesController");
|
|
@@ -4037,34 +4524,34 @@ var MessagesController = class {
|
|
|
4037
4524
|
};
|
|
4038
4525
|
}
|
|
4039
4526
|
};
|
|
4040
|
-
|
|
4041
|
-
(0,
|
|
4042
|
-
(0,
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4527
|
+
_ts_decorate16([
|
|
4528
|
+
(0, import_common17.Post)(":id/feedback"),
|
|
4529
|
+
(0, import_common17.HttpCode)(200),
|
|
4530
|
+
_ts_param14(0, (0, import_common17.Req)()),
|
|
4531
|
+
_ts_param14(1, (0, import_common17.Param)("id")),
|
|
4532
|
+
_ts_param14(2, (0, import_common17.Body)()),
|
|
4533
|
+
_ts_metadata14("design:type", Function),
|
|
4534
|
+
_ts_metadata14("design:paramtypes", [
|
|
4048
4535
|
typeof Request === "undefined" ? Object : Request,
|
|
4049
4536
|
String,
|
|
4050
4537
|
typeof FeedbackBody === "undefined" ? Object : FeedbackBody
|
|
4051
4538
|
]),
|
|
4052
|
-
|
|
4539
|
+
_ts_metadata14("design:returntype", Promise)
|
|
4053
4540
|
], MessagesController.prototype, "feedback", null);
|
|
4054
|
-
MessagesController =
|
|
4055
|
-
(0,
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4541
|
+
MessagesController = _ts_decorate16([
|
|
4542
|
+
(0, import_common17.Controller)("messages"),
|
|
4543
|
+
_ts_param14(1, (0, import_common17.Inject)(import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER)),
|
|
4544
|
+
_ts_metadata14("design:type", Function),
|
|
4545
|
+
_ts_metadata14("design:paramtypes", [
|
|
4059
4546
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
4060
4547
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
4061
4548
|
])
|
|
4062
4549
|
], MessagesController);
|
|
4063
4550
|
|
|
4064
4551
|
// src/controller/models.controller.ts
|
|
4065
|
-
var
|
|
4066
|
-
var
|
|
4067
|
-
function
|
|
4552
|
+
var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
|
|
4553
|
+
var import_common18 = require("@nestjs/common");
|
|
4554
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
4068
4555
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4069
4556
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4070
4557
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4077,19 +4564,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
4077
4564
|
}
|
|
4078
4565
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4079
4566
|
}
|
|
4080
|
-
__name(
|
|
4081
|
-
function
|
|
4567
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
4568
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
4082
4569
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4083
4570
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4084
4571
|
}
|
|
4085
4572
|
}
|
|
4086
|
-
__name(
|
|
4087
|
-
function
|
|
4573
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
4574
|
+
function _ts_param15(paramIndex, decorator) {
|
|
4088
4575
|
return function(target, key) {
|
|
4089
4576
|
decorator(target, key, paramIndex);
|
|
4090
4577
|
};
|
|
4091
4578
|
}
|
|
4092
|
-
__name(
|
|
4579
|
+
__name(_ts_param15, "_ts_param");
|
|
4093
4580
|
var ModelsController = class {
|
|
4094
4581
|
static {
|
|
4095
4582
|
__name(this, "ModelsController");
|
|
@@ -4109,31 +4596,31 @@ var ModelsController = class {
|
|
|
4109
4596
|
return this.agent.listModels(actor, agent);
|
|
4110
4597
|
}
|
|
4111
4598
|
};
|
|
4112
|
-
|
|
4113
|
-
(0,
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4599
|
+
_ts_decorate17([
|
|
4600
|
+
(0, import_common18.Get)(),
|
|
4601
|
+
_ts_param15(0, (0, import_common18.Req)()),
|
|
4602
|
+
_ts_param15(1, (0, import_common18.Query)("agent")),
|
|
4603
|
+
_ts_metadata15("design:type", Function),
|
|
4604
|
+
_ts_metadata15("design:paramtypes", [
|
|
4118
4605
|
typeof Request === "undefined" ? Object : Request,
|
|
4119
4606
|
String
|
|
4120
4607
|
]),
|
|
4121
|
-
|
|
4608
|
+
_ts_metadata15("design:returntype", Promise)
|
|
4122
4609
|
], ModelsController.prototype, "list", null);
|
|
4123
|
-
ModelsController =
|
|
4124
|
-
(0,
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4610
|
+
ModelsController = _ts_decorate17([
|
|
4611
|
+
(0, import_common18.Controller)("models"),
|
|
4612
|
+
_ts_param15(1, (0, import_common18.Inject)(import_nestjs_agent_core21.AGENT_ACTOR_RESOLVER)),
|
|
4613
|
+
_ts_metadata15("design:type", Function),
|
|
4614
|
+
_ts_metadata15("design:paramtypes", [
|
|
4128
4615
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
4129
4616
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
4130
4617
|
])
|
|
4131
4618
|
], ModelsController);
|
|
4132
4619
|
|
|
4133
4620
|
// src/controller/queue.controller.ts
|
|
4134
|
-
var
|
|
4135
|
-
var
|
|
4136
|
-
function
|
|
4621
|
+
var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
|
|
4622
|
+
var import_common19 = require("@nestjs/common");
|
|
4623
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
4137
4624
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4138
4625
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4139
4626
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4146,19 +4633,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
4146
4633
|
}
|
|
4147
4634
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4148
4635
|
}
|
|
4149
|
-
__name(
|
|
4150
|
-
function
|
|
4636
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
4637
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
4151
4638
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4152
4639
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4153
4640
|
}
|
|
4154
4641
|
}
|
|
4155
|
-
__name(
|
|
4156
|
-
function
|
|
4642
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
4643
|
+
function _ts_param16(paramIndex, decorator) {
|
|
4157
4644
|
return function(target, key) {
|
|
4158
4645
|
decorator(target, key, paramIndex);
|
|
4159
4646
|
};
|
|
4160
4647
|
}
|
|
4161
|
-
__name(
|
|
4648
|
+
__name(_ts_param16, "_ts_param");
|
|
4162
4649
|
var QueueController = class {
|
|
4163
4650
|
static {
|
|
4164
4651
|
__name(this, "QueueController");
|
|
@@ -4182,10 +4669,10 @@ var QueueController = class {
|
|
|
4182
4669
|
async update(req, messageId, body) {
|
|
4183
4670
|
const actor = await this.actorResolver.resolve(req);
|
|
4184
4671
|
if (body.message !== void 0 && typeof body.message !== "string") {
|
|
4185
|
-
throw new
|
|
4672
|
+
throw new import_common19.BadRequestException("message must be a string");
|
|
4186
4673
|
}
|
|
4187
4674
|
if (body.position !== void 0 && typeof body.position !== "number") {
|
|
4188
|
-
throw new
|
|
4675
|
+
throw new import_common19.BadRequestException("position must be a number");
|
|
4189
4676
|
}
|
|
4190
4677
|
const attachments = body.attachments === void 0 ? void 0 : body.attachments === null ? null : attachmentRefs(body.attachments);
|
|
4191
4678
|
return this.agent.updateQueuedMessage(actor, messageId, {
|
|
@@ -4212,88 +4699,88 @@ var QueueController = class {
|
|
|
4212
4699
|
return this.agent.removeQueuedMessage(await this.actorResolver.resolve(req), messageId);
|
|
4213
4700
|
}
|
|
4214
4701
|
};
|
|
4215
|
-
|
|
4216
|
-
(0,
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4702
|
+
_ts_decorate18([
|
|
4703
|
+
(0, import_common19.Get)("threads/:id/queue"),
|
|
4704
|
+
_ts_param16(0, (0, import_common19.Req)()),
|
|
4705
|
+
_ts_param16(1, (0, import_common19.Param)("id")),
|
|
4706
|
+
_ts_metadata16("design:type", Function),
|
|
4707
|
+
_ts_metadata16("design:paramtypes", [
|
|
4221
4708
|
typeof Request === "undefined" ? Object : Request,
|
|
4222
4709
|
String
|
|
4223
4710
|
]),
|
|
4224
|
-
|
|
4711
|
+
_ts_metadata16("design:returntype", Promise)
|
|
4225
4712
|
], QueueController.prototype, "list", null);
|
|
4226
|
-
|
|
4227
|
-
(0,
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4713
|
+
_ts_decorate18([
|
|
4714
|
+
(0, import_common19.Delete)("threads/:id/queue"),
|
|
4715
|
+
_ts_param16(0, (0, import_common19.Req)()),
|
|
4716
|
+
_ts_param16(1, (0, import_common19.Param)("id")),
|
|
4717
|
+
_ts_metadata16("design:type", Function),
|
|
4718
|
+
_ts_metadata16("design:paramtypes", [
|
|
4232
4719
|
typeof Request === "undefined" ? Object : Request,
|
|
4233
4720
|
String
|
|
4234
4721
|
]),
|
|
4235
|
-
|
|
4722
|
+
_ts_metadata16("design:returntype", Promise)
|
|
4236
4723
|
], QueueController.prototype, "clear", null);
|
|
4237
|
-
|
|
4238
|
-
(0,
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4724
|
+
_ts_decorate18([
|
|
4725
|
+
(0, import_common19.Post)("threads/:id/queue/resume"),
|
|
4726
|
+
_ts_param16(0, (0, import_common19.Req)()),
|
|
4727
|
+
_ts_param16(1, (0, import_common19.Param)("id")),
|
|
4728
|
+
_ts_metadata16("design:type", Function),
|
|
4729
|
+
_ts_metadata16("design:paramtypes", [
|
|
4243
4730
|
typeof Request === "undefined" ? Object : Request,
|
|
4244
4731
|
String
|
|
4245
4732
|
]),
|
|
4246
|
-
|
|
4733
|
+
_ts_metadata16("design:returntype", Promise)
|
|
4247
4734
|
], QueueController.prototype, "resume", null);
|
|
4248
|
-
|
|
4249
|
-
(0,
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4735
|
+
_ts_decorate18([
|
|
4736
|
+
(0, import_common19.Patch)("queue/:messageId"),
|
|
4737
|
+
_ts_param16(0, (0, import_common19.Req)()),
|
|
4738
|
+
_ts_param16(1, (0, import_common19.Param)("messageId")),
|
|
4739
|
+
_ts_param16(2, (0, import_common19.Body)()),
|
|
4740
|
+
_ts_metadata16("design:type", Function),
|
|
4741
|
+
_ts_metadata16("design:paramtypes", [
|
|
4255
4742
|
typeof Request === "undefined" ? Object : Request,
|
|
4256
4743
|
String,
|
|
4257
4744
|
typeof UpdateQueuedMessageBody === "undefined" ? Object : UpdateQueuedMessageBody
|
|
4258
4745
|
]),
|
|
4259
|
-
|
|
4746
|
+
_ts_metadata16("design:returntype", Promise)
|
|
4260
4747
|
], QueueController.prototype, "update", null);
|
|
4261
|
-
|
|
4262
|
-
(0,
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4748
|
+
_ts_decorate18([
|
|
4749
|
+
(0, import_common19.Post)("queue/:messageId/interrupt"),
|
|
4750
|
+
_ts_param16(0, (0, import_common19.Req)()),
|
|
4751
|
+
_ts_param16(1, (0, import_common19.Param)("messageId")),
|
|
4752
|
+
_ts_metadata16("design:type", Function),
|
|
4753
|
+
_ts_metadata16("design:paramtypes", [
|
|
4267
4754
|
typeof Request === "undefined" ? Object : Request,
|
|
4268
4755
|
String
|
|
4269
4756
|
]),
|
|
4270
|
-
|
|
4757
|
+
_ts_metadata16("design:returntype", Promise)
|
|
4271
4758
|
], QueueController.prototype, "interrupt", null);
|
|
4272
|
-
|
|
4273
|
-
(0,
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4759
|
+
_ts_decorate18([
|
|
4760
|
+
(0, import_common19.Delete)("queue/:messageId"),
|
|
4761
|
+
_ts_param16(0, (0, import_common19.Req)()),
|
|
4762
|
+
_ts_param16(1, (0, import_common19.Param)("messageId")),
|
|
4763
|
+
_ts_metadata16("design:type", Function),
|
|
4764
|
+
_ts_metadata16("design:paramtypes", [
|
|
4278
4765
|
typeof Request === "undefined" ? Object : Request,
|
|
4279
4766
|
String
|
|
4280
4767
|
]),
|
|
4281
|
-
|
|
4768
|
+
_ts_metadata16("design:returntype", Promise)
|
|
4282
4769
|
], QueueController.prototype, "remove", null);
|
|
4283
|
-
QueueController =
|
|
4284
|
-
(0,
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4770
|
+
QueueController = _ts_decorate18([
|
|
4771
|
+
(0, import_common19.Controller)(),
|
|
4772
|
+
_ts_param16(1, (0, import_common19.Inject)(import_nestjs_agent_core22.AGENT_ACTOR_RESOLVER)),
|
|
4773
|
+
_ts_metadata16("design:type", Function),
|
|
4774
|
+
_ts_metadata16("design:paramtypes", [
|
|
4288
4775
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
4289
4776
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
4290
4777
|
])
|
|
4291
4778
|
], QueueController);
|
|
4292
4779
|
|
|
4293
4780
|
// src/controller/quota.controller.ts
|
|
4294
|
-
var
|
|
4295
|
-
var
|
|
4296
|
-
function
|
|
4781
|
+
var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
|
|
4782
|
+
var import_common20 = require("@nestjs/common");
|
|
4783
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
4297
4784
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4298
4785
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4299
4786
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4306,19 +4793,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
4306
4793
|
}
|
|
4307
4794
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4308
4795
|
}
|
|
4309
|
-
__name(
|
|
4310
|
-
function
|
|
4796
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
4797
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
4311
4798
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4312
4799
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4313
4800
|
}
|
|
4314
4801
|
}
|
|
4315
|
-
__name(
|
|
4316
|
-
function
|
|
4802
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
4803
|
+
function _ts_param17(paramIndex, decorator) {
|
|
4317
4804
|
return function(target, key) {
|
|
4318
4805
|
decorator(target, key, paramIndex);
|
|
4319
4806
|
};
|
|
4320
4807
|
}
|
|
4321
|
-
__name(
|
|
4808
|
+
__name(_ts_param17, "_ts_param");
|
|
4322
4809
|
var QuotaController = class {
|
|
4323
4810
|
static {
|
|
4324
4811
|
__name(this, "QuotaController");
|
|
@@ -4338,29 +4825,29 @@ var QuotaController = class {
|
|
|
4338
4825
|
return this.agent.quotaReport(actor);
|
|
4339
4826
|
}
|
|
4340
4827
|
};
|
|
4341
|
-
|
|
4342
|
-
(0,
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4828
|
+
_ts_decorate19([
|
|
4829
|
+
(0, import_common20.Get)(),
|
|
4830
|
+
_ts_param17(0, (0, import_common20.Req)()),
|
|
4831
|
+
_ts_metadata17("design:type", Function),
|
|
4832
|
+
_ts_metadata17("design:paramtypes", [
|
|
4346
4833
|
typeof Request === "undefined" ? Object : Request
|
|
4347
4834
|
]),
|
|
4348
|
-
|
|
4835
|
+
_ts_metadata17("design:returntype", Promise)
|
|
4349
4836
|
], QuotaController.prototype, "report", null);
|
|
4350
|
-
QuotaController =
|
|
4351
|
-
(0,
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4837
|
+
QuotaController = _ts_decorate19([
|
|
4838
|
+
(0, import_common20.Controller)("quota"),
|
|
4839
|
+
_ts_param17(1, (0, import_common20.Inject)(import_nestjs_agent_core23.AGENT_ACTOR_RESOLVER)),
|
|
4840
|
+
_ts_metadata17("design:type", Function),
|
|
4841
|
+
_ts_metadata17("design:paramtypes", [
|
|
4355
4842
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
4356
4843
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
4357
4844
|
])
|
|
4358
4845
|
], QuotaController);
|
|
4359
4846
|
|
|
4360
4847
|
// src/controller/skills.controller.ts
|
|
4361
|
-
var
|
|
4362
|
-
var
|
|
4363
|
-
function
|
|
4848
|
+
var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
|
|
4849
|
+
var import_common21 = require("@nestjs/common");
|
|
4850
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
4364
4851
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4365
4852
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4366
4853
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4373,19 +4860,19 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
4373
4860
|
}
|
|
4374
4861
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4375
4862
|
}
|
|
4376
|
-
__name(
|
|
4377
|
-
function
|
|
4863
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
4864
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
4378
4865
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4379
4866
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4380
4867
|
}
|
|
4381
4868
|
}
|
|
4382
|
-
__name(
|
|
4383
|
-
function
|
|
4869
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
4870
|
+
function _ts_param18(paramIndex, decorator) {
|
|
4384
4871
|
return function(target, key) {
|
|
4385
4872
|
decorator(target, key, paramIndex);
|
|
4386
4873
|
};
|
|
4387
4874
|
}
|
|
4388
|
-
__name(
|
|
4875
|
+
__name(_ts_param18, "_ts_param");
|
|
4389
4876
|
var SkillsController = class {
|
|
4390
4877
|
static {
|
|
4391
4878
|
__name(this, "SkillsController");
|
|
@@ -4401,40 +4888,40 @@ var SkillsController = class {
|
|
|
4401
4888
|
return [];
|
|
4402
4889
|
}
|
|
4403
4890
|
const actor = await this.actorResolver.resolve(req);
|
|
4404
|
-
const offer = await (0,
|
|
4891
|
+
const offer = await (0, import_nestjs_agent_core24.offerSkills)(this.skills, {
|
|
4405
4892
|
actor,
|
|
4406
4893
|
threadId: threadId ?? ""
|
|
4407
4894
|
});
|
|
4408
4895
|
return offer.entries;
|
|
4409
4896
|
}
|
|
4410
4897
|
};
|
|
4411
|
-
|
|
4412
|
-
(0,
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4898
|
+
_ts_decorate20([
|
|
4899
|
+
(0, import_common21.Get)(),
|
|
4900
|
+
_ts_param18(0, (0, import_common21.Req)()),
|
|
4901
|
+
_ts_param18(1, (0, import_common21.Query)("threadId")),
|
|
4902
|
+
_ts_metadata18("design:type", Function),
|
|
4903
|
+
_ts_metadata18("design:paramtypes", [
|
|
4417
4904
|
typeof Request === "undefined" ? Object : Request,
|
|
4418
4905
|
String
|
|
4419
4906
|
]),
|
|
4420
|
-
|
|
4907
|
+
_ts_metadata18("design:returntype", Promise)
|
|
4421
4908
|
], SkillsController.prototype, "list", null);
|
|
4422
|
-
SkillsController =
|
|
4423
|
-
(0,
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4909
|
+
SkillsController = _ts_decorate20([
|
|
4910
|
+
(0, import_common21.Controller)("skills"),
|
|
4911
|
+
_ts_param18(0, (0, import_common21.Inject)(import_nestjs_agent_core24.AGENT_ACTOR_RESOLVER)),
|
|
4912
|
+
_ts_param18(1, (0, import_common21.Optional)()),
|
|
4913
|
+
_ts_param18(1, (0, import_common21.Inject)(import_nestjs_agent_core24.AGENT_SKILLS)),
|
|
4914
|
+
_ts_metadata18("design:type", Function),
|
|
4915
|
+
_ts_metadata18("design:paramtypes", [
|
|
4429
4916
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
4430
4917
|
Object
|
|
4431
4918
|
])
|
|
4432
4919
|
], SkillsController);
|
|
4433
4920
|
|
|
4434
4921
|
// src/controller/threads.controller.ts
|
|
4435
|
-
var
|
|
4436
|
-
var
|
|
4437
|
-
function
|
|
4922
|
+
var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
|
|
4923
|
+
var import_common22 = require("@nestjs/common");
|
|
4924
|
+
function _ts_decorate21(decorators, target, key, desc) {
|
|
4438
4925
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4439
4926
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4440
4927
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4447,19 +4934,19 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
4447
4934
|
}
|
|
4448
4935
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4449
4936
|
}
|
|
4450
|
-
__name(
|
|
4451
|
-
function
|
|
4937
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
4938
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
4452
4939
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4453
4940
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4454
4941
|
}
|
|
4455
4942
|
}
|
|
4456
|
-
__name(
|
|
4457
|
-
function
|
|
4943
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
4944
|
+
function _ts_param19(paramIndex, decorator) {
|
|
4458
4945
|
return function(target, key) {
|
|
4459
4946
|
decorator(target, key, paramIndex);
|
|
4460
4947
|
};
|
|
4461
4948
|
}
|
|
4462
|
-
__name(
|
|
4949
|
+
__name(_ts_param19, "_ts_param");
|
|
4463
4950
|
var ThreadsController = class {
|
|
4464
4951
|
static {
|
|
4465
4952
|
__name(this, "ThreadsController");
|
|
@@ -4529,101 +5016,101 @@ var ThreadsController = class {
|
|
|
4529
5016
|
};
|
|
4530
5017
|
}
|
|
4531
5018
|
};
|
|
4532
|
-
|
|
4533
|
-
(0,
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
5019
|
+
_ts_decorate21([
|
|
5020
|
+
(0, import_common22.Get)(),
|
|
5021
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5022
|
+
_ts_metadata19("design:type", Function),
|
|
5023
|
+
_ts_metadata19("design:paramtypes", [
|
|
4537
5024
|
typeof Request === "undefined" ? Object : Request
|
|
4538
5025
|
]),
|
|
4539
|
-
|
|
5026
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4540
5027
|
], ThreadsController.prototype, "list", null);
|
|
4541
|
-
|
|
4542
|
-
(0,
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
5028
|
+
_ts_decorate21([
|
|
5029
|
+
(0, import_common22.Get)(":id"),
|
|
5030
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5031
|
+
_ts_param19(1, (0, import_common22.Param)("id")),
|
|
5032
|
+
_ts_metadata19("design:type", Function),
|
|
5033
|
+
_ts_metadata19("design:paramtypes", [
|
|
4547
5034
|
typeof Request === "undefined" ? Object : Request,
|
|
4548
5035
|
String
|
|
4549
5036
|
]),
|
|
4550
|
-
|
|
5037
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4551
5038
|
], ThreadsController.prototype, "detail", null);
|
|
4552
|
-
|
|
4553
|
-
(0,
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
5039
|
+
_ts_decorate21([
|
|
5040
|
+
(0, import_common22.Delete)(":id"),
|
|
5041
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5042
|
+
_ts_param19(1, (0, import_common22.Param)("id")),
|
|
5043
|
+
_ts_metadata19("design:type", Function),
|
|
5044
|
+
_ts_metadata19("design:paramtypes", [
|
|
4558
5045
|
typeof Request === "undefined" ? Object : Request,
|
|
4559
5046
|
String
|
|
4560
5047
|
]),
|
|
4561
|
-
|
|
5048
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4562
5049
|
], ThreadsController.prototype, "remove", null);
|
|
4563
|
-
|
|
4564
|
-
(0,
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
5050
|
+
_ts_decorate21([
|
|
5051
|
+
(0, import_common22.Post)(":id/fork-from/:messageId"),
|
|
5052
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5053
|
+
_ts_param19(1, (0, import_common22.Param)("id")),
|
|
5054
|
+
_ts_param19(2, (0, import_common22.Param)("messageId")),
|
|
5055
|
+
_ts_metadata19("design:type", Function),
|
|
5056
|
+
_ts_metadata19("design:paramtypes", [
|
|
4570
5057
|
typeof Request === "undefined" ? Object : Request,
|
|
4571
5058
|
String,
|
|
4572
5059
|
String
|
|
4573
5060
|
]),
|
|
4574
|
-
|
|
5061
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4575
5062
|
], ThreadsController.prototype, "fork", null);
|
|
4576
|
-
|
|
4577
|
-
(0,
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
5063
|
+
_ts_decorate21([
|
|
5064
|
+
(0, import_common22.Patch)(":id"),
|
|
5065
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5066
|
+
_ts_param19(1, (0, import_common22.Param)("id")),
|
|
5067
|
+
_ts_param19(2, (0, import_common22.Body)()),
|
|
5068
|
+
_ts_metadata19("design:type", Function),
|
|
5069
|
+
_ts_metadata19("design:paramtypes", [
|
|
4583
5070
|
typeof Request === "undefined" ? Object : Request,
|
|
4584
5071
|
String,
|
|
4585
5072
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
4586
5073
|
]),
|
|
4587
|
-
|
|
5074
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4588
5075
|
], ThreadsController.prototype, "update", null);
|
|
4589
|
-
|
|
4590
|
-
(0,
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
5076
|
+
_ts_decorate21([
|
|
5077
|
+
(0, import_common22.Post)(":id/promote"),
|
|
5078
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5079
|
+
_ts_param19(1, (0, import_common22.Param)("id")),
|
|
5080
|
+
_ts_metadata19("design:type", Function),
|
|
5081
|
+
_ts_metadata19("design:paramtypes", [
|
|
4595
5082
|
typeof Request === "undefined" ? Object : Request,
|
|
4596
5083
|
String
|
|
4597
5084
|
]),
|
|
4598
|
-
|
|
5085
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4599
5086
|
], ThreadsController.prototype, "promote", null);
|
|
4600
|
-
|
|
4601
|
-
(0,
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
5087
|
+
_ts_decorate21([
|
|
5088
|
+
(0, import_common22.Delete)(":id/from/:messageId"),
|
|
5089
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5090
|
+
_ts_param19(1, (0, import_common22.Param)("id")),
|
|
5091
|
+
_ts_param19(2, (0, import_common22.Param)("messageId")),
|
|
5092
|
+
_ts_metadata19("design:type", Function),
|
|
5093
|
+
_ts_metadata19("design:paramtypes", [
|
|
4607
5094
|
typeof Request === "undefined" ? Object : Request,
|
|
4608
5095
|
String,
|
|
4609
5096
|
String
|
|
4610
5097
|
]),
|
|
4611
|
-
|
|
5098
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4612
5099
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
4613
|
-
ThreadsController =
|
|
4614
|
-
(0,
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
5100
|
+
ThreadsController = _ts_decorate21([
|
|
5101
|
+
(0, import_common22.Controller)("threads"),
|
|
5102
|
+
_ts_param19(1, (0, import_common22.Inject)(import_nestjs_agent_core25.AGENT_ACTOR_RESOLVER)),
|
|
5103
|
+
_ts_metadata19("design:type", Function),
|
|
5104
|
+
_ts_metadata19("design:paramtypes", [
|
|
4618
5105
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
4619
5106
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
4620
5107
|
])
|
|
4621
5108
|
], ThreadsController);
|
|
4622
5109
|
|
|
4623
5110
|
// src/controller/tool-call.controller.ts
|
|
4624
|
-
var
|
|
4625
|
-
var
|
|
4626
|
-
function
|
|
5111
|
+
var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
|
|
5112
|
+
var import_common23 = require("@nestjs/common");
|
|
5113
|
+
function _ts_decorate22(decorators, target, key, desc) {
|
|
4627
5114
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4628
5115
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4629
5116
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4636,19 +5123,19 @@ function _ts_decorate20(decorators, target, key, desc) {
|
|
|
4636
5123
|
}
|
|
4637
5124
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4638
5125
|
}
|
|
4639
|
-
__name(
|
|
4640
|
-
function
|
|
5126
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
5127
|
+
function _ts_metadata20(metadataKey, metadataValue) {
|
|
4641
5128
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4642
5129
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4643
5130
|
}
|
|
4644
5131
|
}
|
|
4645
|
-
__name(
|
|
4646
|
-
function
|
|
5132
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
5133
|
+
function _ts_param20(paramIndex, decorator) {
|
|
4647
5134
|
return function(target, key) {
|
|
4648
5135
|
decorator(target, key, paramIndex);
|
|
4649
5136
|
};
|
|
4650
5137
|
}
|
|
4651
|
-
__name(
|
|
5138
|
+
__name(_ts_param20, "_ts_param");
|
|
4652
5139
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
4653
5140
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
4654
5141
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -4657,7 +5144,7 @@ var MAX_VIA_LENGTH = 64;
|
|
|
4657
5144
|
var DEFAULT_VIA = "web";
|
|
4658
5145
|
function toolCallId(claimed) {
|
|
4659
5146
|
if (typeof claimed !== "string" || claimed.length === 0) {
|
|
4660
|
-
throw new
|
|
5147
|
+
throw new import_common23.BadRequestException("toolCallId must be a non-empty string");
|
|
4661
5148
|
}
|
|
4662
5149
|
return claimed;
|
|
4663
5150
|
}
|
|
@@ -4667,10 +5154,10 @@ function rejectReason(claimed) {
|
|
|
4667
5154
|
return void 0;
|
|
4668
5155
|
}
|
|
4669
5156
|
if (typeof claimed !== "string") {
|
|
4670
|
-
throw new
|
|
5157
|
+
throw new import_common23.BadRequestException("reason must be a string");
|
|
4671
5158
|
}
|
|
4672
5159
|
if (claimed.length > MAX_REJECT_REASON_LENGTH) {
|
|
4673
|
-
throw new
|
|
5160
|
+
throw new import_common23.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
|
|
4674
5161
|
}
|
|
4675
5162
|
return claimed;
|
|
4676
5163
|
}
|
|
@@ -4680,7 +5167,7 @@ function remember(claimed) {
|
|
|
4680
5167
|
return false;
|
|
4681
5168
|
}
|
|
4682
5169
|
if (typeof claimed !== "boolean") {
|
|
4683
|
-
throw new
|
|
5170
|
+
throw new import_common23.BadRequestException("remember must be a boolean");
|
|
4684
5171
|
}
|
|
4685
5172
|
return claimed;
|
|
4686
5173
|
}
|
|
@@ -4690,7 +5177,7 @@ function via(claimed) {
|
|
|
4690
5177
|
return DEFAULT_VIA;
|
|
4691
5178
|
}
|
|
4692
5179
|
if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
|
|
4693
|
-
throw new
|
|
5180
|
+
throw new import_common23.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
|
|
4694
5181
|
}
|
|
4695
5182
|
return claimed;
|
|
4696
5183
|
}
|
|
@@ -4700,26 +5187,26 @@ function answers(claimed) {
|
|
|
4700
5187
|
return void 0;
|
|
4701
5188
|
}
|
|
4702
5189
|
if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
|
|
4703
|
-
throw new
|
|
5190
|
+
throw new import_common23.BadRequestException("answers must be an object of questionId \u2192 chosen values");
|
|
4704
5191
|
}
|
|
4705
5192
|
const entries = Object.entries(claimed);
|
|
4706
5193
|
if (entries.length > MAX_ANSWERED_QUESTIONS) {
|
|
4707
|
-
throw new
|
|
5194
|
+
throw new import_common23.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
|
|
4708
5195
|
}
|
|
4709
5196
|
const validated = /* @__PURE__ */ Object.create(null);
|
|
4710
5197
|
for (const [questionId, values] of entries) {
|
|
4711
5198
|
if (!Array.isArray(values)) {
|
|
4712
|
-
throw new
|
|
5199
|
+
throw new import_common23.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
|
|
4713
5200
|
}
|
|
4714
5201
|
if (values.length > MAX_VALUES_PER_QUESTION) {
|
|
4715
|
-
throw new
|
|
5202
|
+
throw new import_common23.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
|
|
4716
5203
|
}
|
|
4717
5204
|
for (const value of values) {
|
|
4718
5205
|
if (typeof value !== "string") {
|
|
4719
|
-
throw new
|
|
5206
|
+
throw new import_common23.BadRequestException(`answers["${questionId}"] must contain only strings`);
|
|
4720
5207
|
}
|
|
4721
5208
|
if (value.length > MAX_ANSWER_VALUE_LENGTH) {
|
|
4722
|
-
throw new
|
|
5209
|
+
throw new import_common23.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
|
|
4723
5210
|
}
|
|
4724
5211
|
}
|
|
4725
5212
|
validated[questionId] = values;
|
|
@@ -4781,64 +5268,64 @@ var ToolCallController = class {
|
|
|
4781
5268
|
};
|
|
4782
5269
|
}
|
|
4783
5270
|
};
|
|
4784
|
-
|
|
4785
|
-
(0,
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
5271
|
+
_ts_decorate22([
|
|
5272
|
+
(0, import_common23.Post)("approve"),
|
|
5273
|
+
_ts_param20(0, (0, import_common23.Req)()),
|
|
5274
|
+
_ts_param20(1, (0, import_common23.Body)()),
|
|
5275
|
+
_ts_metadata20("design:type", Function),
|
|
5276
|
+
_ts_metadata20("design:paramtypes", [
|
|
4790
5277
|
typeof Request === "undefined" ? Object : Request,
|
|
4791
5278
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
4792
5279
|
]),
|
|
4793
|
-
|
|
5280
|
+
_ts_metadata20("design:returntype", Promise)
|
|
4794
5281
|
], ToolCallController.prototype, "approve", null);
|
|
4795
|
-
|
|
4796
|
-
(0,
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
5282
|
+
_ts_decorate22([
|
|
5283
|
+
(0, import_common23.Post)("reject"),
|
|
5284
|
+
_ts_param20(0, (0, import_common23.Req)()),
|
|
5285
|
+
_ts_param20(1, (0, import_common23.Body)()),
|
|
5286
|
+
_ts_metadata20("design:type", Function),
|
|
5287
|
+
_ts_metadata20("design:paramtypes", [
|
|
4801
5288
|
typeof Request === "undefined" ? Object : Request,
|
|
4802
5289
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
4803
5290
|
]),
|
|
4804
|
-
|
|
5291
|
+
_ts_metadata20("design:returntype", Promise)
|
|
4805
5292
|
], ToolCallController.prototype, "reject", null);
|
|
4806
|
-
|
|
4807
|
-
(0,
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
5293
|
+
_ts_decorate22([
|
|
5294
|
+
(0, import_common23.Post)("answer"),
|
|
5295
|
+
_ts_param20(0, (0, import_common23.Req)()),
|
|
5296
|
+
_ts_param20(1, (0, import_common23.Body)()),
|
|
5297
|
+
_ts_metadata20("design:type", Function),
|
|
5298
|
+
_ts_metadata20("design:paramtypes", [
|
|
4812
5299
|
typeof Request === "undefined" ? Object : Request,
|
|
4813
5300
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
4814
5301
|
]),
|
|
4815
|
-
|
|
5302
|
+
_ts_metadata20("design:returntype", Promise)
|
|
4816
5303
|
], ToolCallController.prototype, "answer", null);
|
|
4817
|
-
|
|
4818
|
-
(0,
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
5304
|
+
_ts_decorate22([
|
|
5305
|
+
(0, import_common23.Post)("skip"),
|
|
5306
|
+
_ts_param20(0, (0, import_common23.Req)()),
|
|
5307
|
+
_ts_param20(1, (0, import_common23.Body)()),
|
|
5308
|
+
_ts_metadata20("design:type", Function),
|
|
5309
|
+
_ts_metadata20("design:paramtypes", [
|
|
4823
5310
|
typeof Request === "undefined" ? Object : Request,
|
|
4824
5311
|
Object
|
|
4825
5312
|
]),
|
|
4826
|
-
|
|
5313
|
+
_ts_metadata20("design:returntype", Promise)
|
|
4827
5314
|
], ToolCallController.prototype, "skip", null);
|
|
4828
|
-
ToolCallController =
|
|
4829
|
-
(0,
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
5315
|
+
ToolCallController = _ts_decorate22([
|
|
5316
|
+
(0, import_common23.Controller)("tool-call"),
|
|
5317
|
+
_ts_param20(1, (0, import_common23.Inject)(import_nestjs_agent_core26.AGENT_ACTOR_RESOLVER)),
|
|
5318
|
+
_ts_metadata20("design:type", Function),
|
|
5319
|
+
_ts_metadata20("design:paramtypes", [
|
|
4833
5320
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
4834
5321
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
4835
5322
|
])
|
|
4836
5323
|
], ToolCallController);
|
|
4837
5324
|
|
|
4838
5325
|
// src/controller/tools.controller.ts
|
|
4839
|
-
var
|
|
4840
|
-
var
|
|
4841
|
-
function
|
|
5326
|
+
var import_nestjs_agent_core27 = require("@dudousxd/nestjs-agent-core");
|
|
5327
|
+
var import_common24 = require("@nestjs/common");
|
|
5328
|
+
function _ts_decorate23(decorators, target, key, desc) {
|
|
4842
5329
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4843
5330
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4844
5331
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4851,19 +5338,19 @@ function _ts_decorate21(decorators, target, key, desc) {
|
|
|
4851
5338
|
}
|
|
4852
5339
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4853
5340
|
}
|
|
4854
|
-
__name(
|
|
4855
|
-
function
|
|
5341
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
5342
|
+
function _ts_metadata21(metadataKey, metadataValue) {
|
|
4856
5343
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4857
5344
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4858
5345
|
}
|
|
4859
5346
|
}
|
|
4860
|
-
__name(
|
|
4861
|
-
function
|
|
5347
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
5348
|
+
function _ts_param21(paramIndex, decorator) {
|
|
4862
5349
|
return function(target, key) {
|
|
4863
5350
|
decorator(target, key, paramIndex);
|
|
4864
5351
|
};
|
|
4865
5352
|
}
|
|
4866
|
-
__name(
|
|
5353
|
+
__name(_ts_param21, "_ts_param");
|
|
4867
5354
|
var ToolsController = class {
|
|
4868
5355
|
static {
|
|
4869
5356
|
__name(this, "ToolsController");
|
|
@@ -4877,11 +5364,11 @@ var ToolsController = class {
|
|
|
4877
5364
|
this.agents = agents;
|
|
4878
5365
|
}
|
|
4879
5366
|
async list(req, agent) {
|
|
4880
|
-
if (agent !== void 0 && agent !==
|
|
4881
|
-
throw new
|
|
5367
|
+
if (agent !== void 0 && agent !== import_nestjs_agent_core27.ALL_AGENTS && this.agents.get(agent) === void 0) {
|
|
5368
|
+
throw new import_common24.NotFoundException(`No agent named "${agent}"`);
|
|
4882
5369
|
}
|
|
4883
5370
|
const actor = await this.actorResolver.resolve(req);
|
|
4884
|
-
const names = agent ===
|
|
5371
|
+
const names = agent === import_nestjs_agent_core27.ALL_AGENTS ? [
|
|
4885
5372
|
void 0,
|
|
4886
5373
|
...this.agents.list().map((definition) => definition.name)
|
|
4887
5374
|
] : [
|
|
@@ -4907,33 +5394,33 @@ var ToolsController = class {
|
|
|
4907
5394
|
];
|
|
4908
5395
|
}
|
|
4909
5396
|
};
|
|
4910
|
-
|
|
4911
|
-
(0,
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
5397
|
+
_ts_decorate23([
|
|
5398
|
+
(0, import_common24.Get)(),
|
|
5399
|
+
_ts_param21(0, (0, import_common24.Req)()),
|
|
5400
|
+
_ts_param21(1, (0, import_common24.Query)("agent")),
|
|
5401
|
+
_ts_metadata21("design:type", Function),
|
|
5402
|
+
_ts_metadata21("design:paramtypes", [
|
|
4916
5403
|
typeof Request === "undefined" ? Object : Request,
|
|
4917
5404
|
String
|
|
4918
5405
|
]),
|
|
4919
|
-
|
|
5406
|
+
_ts_metadata21("design:returntype", Promise)
|
|
4920
5407
|
], ToolsController.prototype, "list", null);
|
|
4921
|
-
ToolsController =
|
|
4922
|
-
(0,
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
5408
|
+
ToolsController = _ts_decorate23([
|
|
5409
|
+
(0, import_common24.Controller)("tools"),
|
|
5410
|
+
_ts_param21(0, (0, import_common24.Inject)(import_nestjs_agent_core27.AGENT_ACTOR_RESOLVER)),
|
|
5411
|
+
_ts_param21(1, (0, import_common24.Inject)(import_nestjs_agent_core27.AGENT_DEPS_FACTORY)),
|
|
5412
|
+
_ts_param21(2, (0, import_common24.Inject)(import_nestjs_agent_core27.AGENT_REGISTRY)),
|
|
5413
|
+
_ts_metadata21("design:type", Function),
|
|
5414
|
+
_ts_metadata21("design:paramtypes", [
|
|
4928
5415
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
4929
5416
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
4930
|
-
typeof
|
|
5417
|
+
typeof import_nestjs_agent_core27.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core27.AgentRegistry
|
|
4931
5418
|
])
|
|
4932
5419
|
], ToolsController);
|
|
4933
5420
|
|
|
4934
5421
|
// src/discovery/agent-discovery.service.ts
|
|
4935
|
-
var
|
|
4936
|
-
var
|
|
5422
|
+
var import_nestjs_agent_core28 = require("@dudousxd/nestjs-agent-core");
|
|
5423
|
+
var import_common25 = require("@nestjs/common");
|
|
4937
5424
|
var import_core = require("@nestjs/core");
|
|
4938
5425
|
|
|
4939
5426
|
// src/decorator/agent.decorator.ts
|
|
@@ -4950,7 +5437,7 @@ var SYSTEM_PROMPT_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:
|
|
|
4950
5437
|
var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
|
|
4951
5438
|
|
|
4952
5439
|
// src/discovery/agent-discovery.service.ts
|
|
4953
|
-
function
|
|
5440
|
+
function _ts_decorate24(decorators, target, key, desc) {
|
|
4954
5441
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4955
5442
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4956
5443
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4963,19 +5450,19 @@ function _ts_decorate22(decorators, target, key, desc) {
|
|
|
4963
5450
|
}
|
|
4964
5451
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4965
5452
|
}
|
|
4966
|
-
__name(
|
|
4967
|
-
function
|
|
5453
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
5454
|
+
function _ts_metadata22(metadataKey, metadataValue) {
|
|
4968
5455
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4969
5456
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4970
5457
|
}
|
|
4971
5458
|
}
|
|
4972
|
-
__name(
|
|
4973
|
-
function
|
|
5459
|
+
__name(_ts_metadata22, "_ts_metadata");
|
|
5460
|
+
function _ts_param22(paramIndex, decorator) {
|
|
4974
5461
|
return function(target, key) {
|
|
4975
5462
|
decorator(target, key, paramIndex);
|
|
4976
5463
|
};
|
|
4977
5464
|
}
|
|
4978
|
-
__name(
|
|
5465
|
+
__name(_ts_param22, "_ts_param");
|
|
4979
5466
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
4980
5467
|
static {
|
|
4981
5468
|
__name(this, "AgentDiscoveryService");
|
|
@@ -4984,7 +5471,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
4984
5471
|
scanner;
|
|
4985
5472
|
registry;
|
|
4986
5473
|
contributors;
|
|
4987
|
-
logger = new
|
|
5474
|
+
logger = new import_common25.Logger(_AgentDiscoveryService.name);
|
|
4988
5475
|
constructor(discovery, scanner, registry, contributors) {
|
|
4989
5476
|
this.discovery = discovery;
|
|
4990
5477
|
this.scanner = scanner;
|
|
@@ -5141,22 +5628,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
5141
5628
|
return (ctx) => candidate.call(instance, ctx);
|
|
5142
5629
|
}
|
|
5143
5630
|
};
|
|
5144
|
-
AgentDiscoveryService =
|
|
5145
|
-
(0,
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5631
|
+
AgentDiscoveryService = _ts_decorate24([
|
|
5632
|
+
(0, import_common25.Injectable)(),
|
|
5633
|
+
_ts_param22(2, (0, import_common25.Inject)(import_nestjs_agent_core28.AGENT_REGISTRY)),
|
|
5634
|
+
_ts_param22(3, (0, import_common25.Inject)(import_nestjs_agent_core28.AGENT_PROMPT_CONTRIBUTORS)),
|
|
5635
|
+
_ts_metadata22("design:type", Function),
|
|
5636
|
+
_ts_metadata22("design:paramtypes", [
|
|
5150
5637
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
5151
5638
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
5152
|
-
typeof
|
|
5639
|
+
typeof import_nestjs_agent_core28.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core28.AgentRegistry,
|
|
5153
5640
|
Array
|
|
5154
5641
|
])
|
|
5155
5642
|
], AgentDiscoveryService);
|
|
5156
5643
|
|
|
5157
5644
|
// src/discovery/ai-tool-discovery.service.ts
|
|
5158
|
-
var
|
|
5159
|
-
var
|
|
5645
|
+
var import_nestjs_agent_core29 = require("@dudousxd/nestjs-agent-core");
|
|
5646
|
+
var import_common26 = require("@nestjs/common");
|
|
5160
5647
|
var import_core2 = require("@nestjs/core");
|
|
5161
5648
|
var import_zod = require("zod");
|
|
5162
5649
|
|
|
@@ -5168,15 +5655,8 @@ function readAiToolMetadata(target) {
|
|
|
5168
5655
|
}
|
|
5169
5656
|
__name(readAiToolMetadata, "readAiToolMetadata");
|
|
5170
5657
|
|
|
5171
|
-
// src/functional-tool.ts
|
|
5172
|
-
var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
|
|
5173
|
-
function isBrandedFunctionalTool(value) {
|
|
5174
|
-
return AGENT_TOOL_BRAND in value && "spec" in value && "handler" in value;
|
|
5175
|
-
}
|
|
5176
|
-
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
5177
|
-
|
|
5178
5658
|
// src/discovery/ai-tool-discovery.service.ts
|
|
5179
|
-
function
|
|
5659
|
+
function _ts_decorate25(decorators, target, key, desc) {
|
|
5180
5660
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5181
5661
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5182
5662
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5189,19 +5669,19 @@ function _ts_decorate23(decorators, target, key, desc) {
|
|
|
5189
5669
|
}
|
|
5190
5670
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5191
5671
|
}
|
|
5192
|
-
__name(
|
|
5193
|
-
function
|
|
5672
|
+
__name(_ts_decorate25, "_ts_decorate");
|
|
5673
|
+
function _ts_metadata23(metadataKey, metadataValue) {
|
|
5194
5674
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5195
5675
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
5196
5676
|
}
|
|
5197
5677
|
}
|
|
5198
|
-
__name(
|
|
5199
|
-
function
|
|
5678
|
+
__name(_ts_metadata23, "_ts_metadata");
|
|
5679
|
+
function _ts_param23(paramIndex, decorator) {
|
|
5200
5680
|
return function(target, key) {
|
|
5201
5681
|
decorator(target, key, paramIndex);
|
|
5202
5682
|
};
|
|
5203
5683
|
}
|
|
5204
|
-
__name(
|
|
5684
|
+
__name(_ts_param23, "_ts_param");
|
|
5205
5685
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
5206
5686
|
static {
|
|
5207
5687
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -5210,7 +5690,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5210
5690
|
registry;
|
|
5211
5691
|
agents;
|
|
5212
5692
|
options;
|
|
5213
|
-
logger = new
|
|
5693
|
+
logger = new import_common26.Logger(_AiToolDiscoveryService.name);
|
|
5214
5694
|
constructor(discovery, registry, agents, options) {
|
|
5215
5695
|
this.discovery = discovery;
|
|
5216
5696
|
this.registry = registry;
|
|
@@ -5269,9 +5749,15 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5269
5749
|
} : {},
|
|
5270
5750
|
...meta.terminal === true ? {
|
|
5271
5751
|
terminal: true
|
|
5752
|
+
} : {},
|
|
5753
|
+
...meta.replacementKey !== void 0 ? {
|
|
5754
|
+
replacementKey: meta.replacementKey
|
|
5272
5755
|
} : {}
|
|
5273
5756
|
}, {
|
|
5274
5757
|
execute: /* @__PURE__ */ __name((input, ctx) => instance.execute(input, ctx), "execute"),
|
|
5758
|
+
...typeof handler.preflight === "function" ? {
|
|
5759
|
+
preflight: /* @__PURE__ */ __name((input, ctx, options) => instance.preflight(input, ctx, options), "preflight")
|
|
5760
|
+
} : {},
|
|
5275
5761
|
// Forwarded, not copied: the registry holds this wrapper rather than the provider, so an
|
|
5276
5762
|
// `isEnabled()`/`canUse()` left behind here would be a gate that silently never applies.
|
|
5277
5763
|
// Called through `instance` so each keeps its `this` (and its injected deps).
|
|
@@ -5295,7 +5781,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5295
5781
|
let delegates = 0;
|
|
5296
5782
|
for (const definition of this.agents.list()) {
|
|
5297
5783
|
for (const edge of definition.delegatesTo ?? []) {
|
|
5298
|
-
const { agent: target, detached } = (0,
|
|
5784
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core29.normalizeDelegation)(edge);
|
|
5299
5785
|
const targetDefinition = this.agents.get(target);
|
|
5300
5786
|
if (targetDefinition === void 0) {
|
|
5301
5787
|
throw new Error(`Agent "${definition.name}" hands off to "${target}", which is not a registered @Agent. Declare it as an @Agent provider or fix the reference.`);
|
|
@@ -5345,13 +5831,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5345
5831
|
return true;
|
|
5346
5832
|
}
|
|
5347
5833
|
};
|
|
5348
|
-
AiToolDiscoveryService =
|
|
5349
|
-
(0,
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5834
|
+
AiToolDiscoveryService = _ts_decorate25([
|
|
5835
|
+
(0, import_common26.Injectable)(),
|
|
5836
|
+
_ts_param23(1, (0, import_common26.Inject)(import_nestjs_agent_core29.AGENT_TOOL_REGISTRY)),
|
|
5837
|
+
_ts_param23(2, (0, import_common26.Inject)(import_nestjs_agent_core29.AGENT_REGISTRY)),
|
|
5838
|
+
_ts_param23(3, (0, import_common26.Inject)(import_nestjs_agent_core29.AGENT_OPTIONS)),
|
|
5839
|
+
_ts_metadata23("design:type", Function),
|
|
5840
|
+
_ts_metadata23("design:paramtypes", [
|
|
5355
5841
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
5356
5842
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
5357
5843
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -5360,25 +5846,25 @@ AiToolDiscoveryService = _ts_decorate23([
|
|
|
5360
5846
|
], AiToolDiscoveryService);
|
|
5361
5847
|
|
|
5362
5848
|
// src/discovery/skill-discovery.service.ts
|
|
5363
|
-
var
|
|
5364
|
-
var
|
|
5849
|
+
var import_nestjs_agent_core31 = require("@dudousxd/nestjs-agent-core");
|
|
5850
|
+
var import_common27 = require("@nestjs/common");
|
|
5365
5851
|
var import_core3 = require("@nestjs/core");
|
|
5366
5852
|
|
|
5367
5853
|
// src/decorator/skill.decorator.ts
|
|
5368
5854
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
5369
|
-
var
|
|
5855
|
+
var import_nestjs_agent_core30 = require("@dudousxd/nestjs-agent-core");
|
|
5370
5856
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
5371
5857
|
function readSkillMetadata(target) {
|
|
5372
5858
|
return Reflect.getMetadata(SKILL_METADATA, target);
|
|
5373
5859
|
}
|
|
5374
5860
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
5375
5861
|
function skillScope(options) {
|
|
5376
|
-
return options.scope ??
|
|
5862
|
+
return options.scope ?? import_nestjs_agent_core30.GLOBAL_SCOPE;
|
|
5377
5863
|
}
|
|
5378
5864
|
__name(skillScope, "skillScope");
|
|
5379
5865
|
|
|
5380
5866
|
// src/discovery/skill-discovery.service.ts
|
|
5381
|
-
function
|
|
5867
|
+
function _ts_decorate26(decorators, target, key, desc) {
|
|
5382
5868
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5383
5869
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5384
5870
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5391,26 +5877,26 @@ function _ts_decorate24(decorators, target, key, desc) {
|
|
|
5391
5877
|
}
|
|
5392
5878
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5393
5879
|
}
|
|
5394
|
-
__name(
|
|
5395
|
-
function
|
|
5880
|
+
__name(_ts_decorate26, "_ts_decorate");
|
|
5881
|
+
function _ts_metadata24(metadataKey, metadataValue) {
|
|
5396
5882
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5397
5883
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
5398
5884
|
}
|
|
5399
5885
|
}
|
|
5400
|
-
__name(
|
|
5401
|
-
function
|
|
5886
|
+
__name(_ts_metadata24, "_ts_metadata");
|
|
5887
|
+
function _ts_param24(paramIndex, decorator) {
|
|
5402
5888
|
return function(target, key) {
|
|
5403
5889
|
decorator(target, key, paramIndex);
|
|
5404
5890
|
};
|
|
5405
5891
|
}
|
|
5406
|
-
__name(
|
|
5892
|
+
__name(_ts_param24, "_ts_param");
|
|
5407
5893
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
5408
5894
|
static {
|
|
5409
5895
|
__name(this, "SkillDiscoveryService");
|
|
5410
5896
|
}
|
|
5411
5897
|
discovery;
|
|
5412
5898
|
declared;
|
|
5413
|
-
logger = new
|
|
5899
|
+
logger = new import_common27.Logger(_SkillDiscoveryService.name);
|
|
5414
5900
|
constructor(discovery, declared) {
|
|
5415
5901
|
this.discovery = discovery;
|
|
5416
5902
|
this.declared = declared;
|
|
@@ -5447,18 +5933,18 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
5447
5933
|
return flat === void 0 ? void 0 : () => flat;
|
|
5448
5934
|
}
|
|
5449
5935
|
};
|
|
5450
|
-
SkillDiscoveryService =
|
|
5451
|
-
(0,
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5936
|
+
SkillDiscoveryService = _ts_decorate26([
|
|
5937
|
+
(0, import_common27.Injectable)(),
|
|
5938
|
+
_ts_param24(1, (0, import_common27.Inject)(import_nestjs_agent_core31.AGENT_SKILL_SOURCES)),
|
|
5939
|
+
_ts_metadata24("design:type", Function),
|
|
5940
|
+
_ts_metadata24("design:paramtypes", [
|
|
5455
5941
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
5456
5942
|
Array
|
|
5457
5943
|
])
|
|
5458
5944
|
], SkillDiscoveryService);
|
|
5459
5945
|
|
|
5460
5946
|
// src/ledger-quota-provider.ts
|
|
5461
|
-
var
|
|
5947
|
+
var import_nestjs_agent_core32 = require("@dudousxd/nestjs-agent-core");
|
|
5462
5948
|
var LedgerQuotaProvider = class {
|
|
5463
5949
|
static {
|
|
5464
5950
|
__name(this, "LedgerQuotaProvider");
|
|
@@ -5478,12 +5964,12 @@ var LedgerQuotaProvider = class {
|
|
|
5478
5964
|
await this.dayWindow(actorRef, now)
|
|
5479
5965
|
];
|
|
5480
5966
|
if (this.store.usageBetween !== void 0) {
|
|
5481
|
-
const range = (0,
|
|
5967
|
+
const range = (0, import_nestjs_agent_core32.quotaPeriodRange)("month", now);
|
|
5482
5968
|
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
5483
5969
|
windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
|
|
5484
5970
|
}
|
|
5485
|
-
const blocked = (0,
|
|
5486
|
-
const warning = (0,
|
|
5971
|
+
const blocked = (0, import_nestjs_agent_core32.exhaustedWindow)(windows);
|
|
5972
|
+
const warning = (0, import_nestjs_agent_core32.quotaWarning)(windows);
|
|
5487
5973
|
return {
|
|
5488
5974
|
windows,
|
|
5489
5975
|
...blocked !== void 0 ? {
|
|
@@ -5495,7 +5981,7 @@ var LedgerQuotaProvider = class {
|
|
|
5495
5981
|
};
|
|
5496
5982
|
}
|
|
5497
5983
|
async dayWindow(actorRef, now) {
|
|
5498
|
-
const range = (0,
|
|
5984
|
+
const range = (0, import_nestjs_agent_core32.quotaPeriodRange)("day", now);
|
|
5499
5985
|
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
5500
5986
|
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
5501
5987
|
}
|
|
@@ -5519,10 +6005,245 @@ var LedgerQuotaProvider = class {
|
|
|
5519
6005
|
}
|
|
5520
6006
|
};
|
|
5521
6007
|
|
|
6008
|
+
// src/proposals/action-proposal-worker.service.ts
|
|
6009
|
+
var import_node_crypto3 = require("crypto");
|
|
6010
|
+
var import_nestjs_agent_core33 = require("@dudousxd/nestjs-agent-core");
|
|
6011
|
+
var import_common28 = require("@nestjs/common");
|
|
6012
|
+
function _ts_decorate27(decorators, target, key, desc) {
|
|
6013
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6014
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
6015
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
6016
|
+
} else {
|
|
6017
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
6018
|
+
if (d = decorators[i]) {
|
|
6019
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6020
|
+
}
|
|
6021
|
+
}
|
|
6022
|
+
}
|
|
6023
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6024
|
+
}
|
|
6025
|
+
__name(_ts_decorate27, "_ts_decorate");
|
|
6026
|
+
function _ts_metadata25(metadataKey, metadataValue) {
|
|
6027
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
6028
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
6029
|
+
}
|
|
6030
|
+
}
|
|
6031
|
+
__name(_ts_metadata25, "_ts_metadata");
|
|
6032
|
+
function _ts_param25(paramIndex, decorator) {
|
|
6033
|
+
return function(target, key) {
|
|
6034
|
+
decorator(target, key, paramIndex);
|
|
6035
|
+
};
|
|
6036
|
+
}
|
|
6037
|
+
__name(_ts_param25, "_ts_param");
|
|
6038
|
+
var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
6039
|
+
static {
|
|
6040
|
+
__name(this, "ActionProposalWorkerService");
|
|
6041
|
+
}
|
|
6042
|
+
store;
|
|
6043
|
+
options;
|
|
6044
|
+
deps;
|
|
6045
|
+
worker;
|
|
6046
|
+
logger = new import_common28.Logger(_ActionProposalWorkerService.name);
|
|
6047
|
+
constructor(store, options, deps) {
|
|
6048
|
+
this.store = store;
|
|
6049
|
+
this.options = options;
|
|
6050
|
+
this.deps = deps;
|
|
6051
|
+
}
|
|
6052
|
+
onModuleInit() {
|
|
6053
|
+
if (this.options.actionApprovalMode !== "independent") return;
|
|
6054
|
+
(0, import_nestjs_agent_core33.assertIndependentActionCapabilities)(this.store, this.options.backgroundActorResolver);
|
|
6055
|
+
if (this.options.surface === "http") return;
|
|
6056
|
+
const resolver = this.options.backgroundActorResolver;
|
|
6057
|
+
if (!resolver) throw new Error("BackgroundActorResolver is required");
|
|
6058
|
+
this.worker = new import_nestjs_agent_core33.ActionProposalWorker({
|
|
6059
|
+
store: this.store,
|
|
6060
|
+
workerId: (0, import_node_crypto3.randomUUID)(),
|
|
6061
|
+
...this.options.actionProposalWorker,
|
|
6062
|
+
executor: new import_nestjs_agent_core33.ActionProposalExecutor({
|
|
6063
|
+
resolver,
|
|
6064
|
+
resolveExecution: /* @__PURE__ */ __name(async (proposal, actor) => {
|
|
6065
|
+
const deps = this.deps.forProposal(proposal, actor);
|
|
6066
|
+
return {
|
|
6067
|
+
registry: deps.registry,
|
|
6068
|
+
rolesPolicy: deps.rolesPolicy,
|
|
6069
|
+
...deps.resolveUiCatalog !== void 0 ? {
|
|
6070
|
+
resolveUiCatalog: deps.resolveUiCatalog
|
|
6071
|
+
} : {},
|
|
6072
|
+
...deps.toolAllowList !== void 0 ? {
|
|
6073
|
+
allowedTools: deps.toolAllowList
|
|
6074
|
+
} : {}
|
|
6075
|
+
};
|
|
6076
|
+
}, "resolveExecution")
|
|
6077
|
+
}),
|
|
6078
|
+
onError: /* @__PURE__ */ __name((error) => this.logger.error(error), "onError")
|
|
6079
|
+
});
|
|
6080
|
+
this.worker.start();
|
|
6081
|
+
}
|
|
6082
|
+
async onModuleDestroy() {
|
|
6083
|
+
await this.worker?.stop();
|
|
6084
|
+
}
|
|
6085
|
+
};
|
|
6086
|
+
ActionProposalWorkerService = _ts_decorate27([
|
|
6087
|
+
(0, import_common28.Injectable)(),
|
|
6088
|
+
_ts_param25(0, (0, import_common28.Inject)(import_nestjs_agent_core33.AGENT_STORE)),
|
|
6089
|
+
_ts_param25(1, (0, import_common28.Inject)(import_nestjs_agent_core33.AGENT_OPTIONS)),
|
|
6090
|
+
_ts_param25(2, (0, import_common28.Inject)(import_nestjs_agent_core33.AGENT_DEPS_FACTORY)),
|
|
6091
|
+
_ts_metadata25("design:type", Function),
|
|
6092
|
+
_ts_metadata25("design:paramtypes", [
|
|
6093
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
6094
|
+
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
6095
|
+
typeof AgentDepsFactory2 === "undefined" ? Object : AgentDepsFactory2
|
|
6096
|
+
])
|
|
6097
|
+
], ActionProposalWorkerService);
|
|
6098
|
+
|
|
6099
|
+
// src/proposals/action-proposal.controller.ts
|
|
6100
|
+
var import_nestjs_agent_core34 = require("@dudousxd/nestjs-agent-core");
|
|
6101
|
+
var import_common29 = require("@nestjs/common");
|
|
6102
|
+
function _ts_decorate28(decorators, target, key, desc) {
|
|
6103
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6104
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
6105
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
6106
|
+
} else {
|
|
6107
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
6108
|
+
if (d = decorators[i]) {
|
|
6109
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6110
|
+
}
|
|
6111
|
+
}
|
|
6112
|
+
}
|
|
6113
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6114
|
+
}
|
|
6115
|
+
__name(_ts_decorate28, "_ts_decorate");
|
|
6116
|
+
function _ts_metadata26(metadataKey, metadataValue) {
|
|
6117
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
6118
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
6119
|
+
}
|
|
6120
|
+
}
|
|
6121
|
+
__name(_ts_metadata26, "_ts_metadata");
|
|
6122
|
+
function _ts_param26(paramIndex, decorator) {
|
|
6123
|
+
return function(target, key) {
|
|
6124
|
+
decorator(target, key, paramIndex);
|
|
6125
|
+
};
|
|
6126
|
+
}
|
|
6127
|
+
__name(_ts_param26, "_ts_param");
|
|
6128
|
+
function bodyFields(body, field) {
|
|
6129
|
+
if (body === void 0) return {};
|
|
6130
|
+
if (typeof body !== "object" || body === null || Array.isArray(body) || Object.keys(body).some((key) => key !== field)) throw new import_common29.BadRequestException(`Only ${field} is accepted`);
|
|
6131
|
+
const value = body;
|
|
6132
|
+
if (value[field] !== void 0 && (field === "remember" && typeof value[field] !== "boolean" || field === "reason" && typeof value[field] !== "string")) throw new import_common29.BadRequestException(`Invalid ${field}`);
|
|
6133
|
+
return value;
|
|
6134
|
+
}
|
|
6135
|
+
__name(bodyFields, "bodyFields");
|
|
6136
|
+
var ActionProposalController = class {
|
|
6137
|
+
static {
|
|
6138
|
+
__name(this, "ActionProposalController");
|
|
6139
|
+
}
|
|
6140
|
+
proposals;
|
|
6141
|
+
actors;
|
|
6142
|
+
constructor(proposals, actors) {
|
|
6143
|
+
this.proposals = proposals;
|
|
6144
|
+
this.actors = actors;
|
|
6145
|
+
}
|
|
6146
|
+
async list(threadId, request, cursor, response) {
|
|
6147
|
+
let query = {};
|
|
6148
|
+
if (cursor !== void 0) {
|
|
6149
|
+
try {
|
|
6150
|
+
if (typeof cursor !== "string") throw new Error("Invalid cursor");
|
|
6151
|
+
query = {
|
|
6152
|
+
after: JSON.parse(cursor)
|
|
6153
|
+
};
|
|
6154
|
+
(0, import_nestjs_agent_core34.validateActionProposalListQuery)(query);
|
|
6155
|
+
} catch {
|
|
6156
|
+
throw new import_common29.BadRequestException("Invalid action proposal cursor");
|
|
6157
|
+
}
|
|
6158
|
+
}
|
|
6159
|
+
const page = await this.proposals.listPage(threadId, await this.actors.resolve(request), query);
|
|
6160
|
+
if (page.next) {
|
|
6161
|
+
response.setHeader("X-Action-Proposals-Next", encodeURIComponent(JSON.stringify(page.next)));
|
|
6162
|
+
const exposed = response.getHeader("Access-Control-Expose-Headers");
|
|
6163
|
+
response.setHeader("Access-Control-Expose-Headers", `${exposed === void 0 ? "" : `${String(exposed)}, `}X-Action-Proposals-Next`);
|
|
6164
|
+
}
|
|
6165
|
+
return page.items;
|
|
6166
|
+
}
|
|
6167
|
+
async approve(threadId, proposalId, request, body) {
|
|
6168
|
+
const value = bodyFields(body, "remember");
|
|
6169
|
+
return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
|
|
6170
|
+
decision: "approved",
|
|
6171
|
+
...typeof value.remember === "boolean" ? {
|
|
6172
|
+
remember: value.remember
|
|
6173
|
+
} : {}
|
|
6174
|
+
});
|
|
6175
|
+
}
|
|
6176
|
+
async reject(threadId, proposalId, request, body) {
|
|
6177
|
+
const value = bodyFields(body, "reason");
|
|
6178
|
+
return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
|
|
6179
|
+
decision: "rejected",
|
|
6180
|
+
...typeof value.reason === "string" ? {
|
|
6181
|
+
reason: value.reason
|
|
6182
|
+
} : {}
|
|
6183
|
+
});
|
|
6184
|
+
}
|
|
6185
|
+
};
|
|
6186
|
+
_ts_decorate28([
|
|
6187
|
+
(0, import_common29.Get)(),
|
|
6188
|
+
_ts_param26(0, (0, import_common29.Param)("threadId")),
|
|
6189
|
+
_ts_param26(1, (0, import_common29.Req)()),
|
|
6190
|
+
_ts_param26(2, (0, import_common29.Query)("after")),
|
|
6191
|
+
_ts_param26(3, (0, import_common29.Res)({
|
|
6192
|
+
passthrough: true
|
|
6193
|
+
})),
|
|
6194
|
+
_ts_metadata26("design:type", Function),
|
|
6195
|
+
_ts_metadata26("design:paramtypes", [
|
|
6196
|
+
String,
|
|
6197
|
+
typeof Request === "undefined" ? Object : Request,
|
|
6198
|
+
Object,
|
|
6199
|
+
typeof Response === "undefined" ? Object : Response
|
|
6200
|
+
]),
|
|
6201
|
+
_ts_metadata26("design:returntype", Promise)
|
|
6202
|
+
], ActionProposalController.prototype, "list", null);
|
|
6203
|
+
_ts_decorate28([
|
|
6204
|
+
(0, import_common29.Post)(":proposalId/approve"),
|
|
6205
|
+
_ts_param26(0, (0, import_common29.Param)("threadId")),
|
|
6206
|
+
_ts_param26(1, (0, import_common29.Param)("proposalId")),
|
|
6207
|
+
_ts_param26(2, (0, import_common29.Req)()),
|
|
6208
|
+
_ts_param26(3, (0, import_common29.Body)()),
|
|
6209
|
+
_ts_metadata26("design:type", Function),
|
|
6210
|
+
_ts_metadata26("design:paramtypes", [
|
|
6211
|
+
String,
|
|
6212
|
+
String,
|
|
6213
|
+
typeof Request === "undefined" ? Object : Request,
|
|
6214
|
+
Object
|
|
6215
|
+
]),
|
|
6216
|
+
_ts_metadata26("design:returntype", Promise)
|
|
6217
|
+
], ActionProposalController.prototype, "approve", null);
|
|
6218
|
+
_ts_decorate28([
|
|
6219
|
+
(0, import_common29.Post)(":proposalId/reject"),
|
|
6220
|
+
_ts_param26(0, (0, import_common29.Param)("threadId")),
|
|
6221
|
+
_ts_param26(1, (0, import_common29.Param)("proposalId")),
|
|
6222
|
+
_ts_param26(2, (0, import_common29.Req)()),
|
|
6223
|
+
_ts_param26(3, (0, import_common29.Body)()),
|
|
6224
|
+
_ts_metadata26("design:type", Function),
|
|
6225
|
+
_ts_metadata26("design:paramtypes", [
|
|
6226
|
+
String,
|
|
6227
|
+
String,
|
|
6228
|
+
typeof Request === "undefined" ? Object : Request,
|
|
6229
|
+
Object
|
|
6230
|
+
]),
|
|
6231
|
+
_ts_metadata26("design:returntype", Promise)
|
|
6232
|
+
], ActionProposalController.prototype, "reject", null);
|
|
6233
|
+
ActionProposalController = _ts_decorate28([
|
|
6234
|
+
(0, import_common29.Controller)("threads/:threadId/action-proposals"),
|
|
6235
|
+
_ts_param26(1, (0, import_common29.Inject)(import_nestjs_agent_core34.AGENT_ACTOR_RESOLVER)),
|
|
6236
|
+
_ts_metadata26("design:type", Function),
|
|
6237
|
+
_ts_metadata26("design:paramtypes", [
|
|
6238
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService,
|
|
6239
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
6240
|
+
])
|
|
6241
|
+
], ActionProposalController);
|
|
6242
|
+
|
|
5522
6243
|
// src/runner/inline-agent-runner.ts
|
|
5523
|
-
var
|
|
5524
|
-
var
|
|
5525
|
-
function
|
|
6244
|
+
var import_nestjs_agent_core35 = require("@dudousxd/nestjs-agent-core");
|
|
6245
|
+
var import_common30 = require("@nestjs/common");
|
|
6246
|
+
function _ts_decorate29(decorators, target, key, desc) {
|
|
5526
6247
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5527
6248
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5528
6249
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5535,19 +6256,19 @@ function _ts_decorate25(decorators, target, key, desc) {
|
|
|
5535
6256
|
}
|
|
5536
6257
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5537
6258
|
}
|
|
5538
|
-
__name(
|
|
5539
|
-
function
|
|
6259
|
+
__name(_ts_decorate29, "_ts_decorate");
|
|
6260
|
+
function _ts_metadata27(metadataKey, metadataValue) {
|
|
5540
6261
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5541
6262
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
5542
6263
|
}
|
|
5543
6264
|
}
|
|
5544
|
-
__name(
|
|
5545
|
-
function
|
|
6265
|
+
__name(_ts_metadata27, "_ts_metadata");
|
|
6266
|
+
function _ts_param27(paramIndex, decorator) {
|
|
5546
6267
|
return function(target, key) {
|
|
5547
6268
|
decorator(target, key, paramIndex);
|
|
5548
6269
|
};
|
|
5549
6270
|
}
|
|
5550
|
-
__name(
|
|
6271
|
+
__name(_ts_param27, "_ts_param");
|
|
5551
6272
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
5552
6273
|
static {
|
|
5553
6274
|
__name(this, "InlineAgentRunner");
|
|
@@ -5555,7 +6276,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5555
6276
|
factory;
|
|
5556
6277
|
store;
|
|
5557
6278
|
queue;
|
|
5558
|
-
logger = new
|
|
6279
|
+
logger = new import_common30.Logger(_InlineAgentRunner.name);
|
|
5559
6280
|
pending = /* @__PURE__ */ new Map();
|
|
5560
6281
|
/**
|
|
5561
6282
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -5604,18 +6325,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5604
6325
|
],
|
|
5605
6326
|
input
|
|
5606
6327
|
});
|
|
5607
|
-
void (0,
|
|
6328
|
+
void (0, import_nestjs_agent_core35.runAgentLoop)({
|
|
5608
6329
|
...deps,
|
|
5609
6330
|
day
|
|
5610
|
-
}, input, hooks).then(() => (0,
|
|
5611
|
-
if (error instanceof
|
|
6331
|
+
}, input, hooks).then(() => (0, import_nestjs_agent_core35.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
|
|
6332
|
+
if (error instanceof import_nestjs_agent_core35.RunCancelledError) {
|
|
5612
6333
|
await this.settleCancelled(runId, input, deps);
|
|
5613
6334
|
return;
|
|
5614
6335
|
}
|
|
5615
6336
|
const message = error instanceof Error ? error.message : String(error);
|
|
5616
|
-
const code = (0,
|
|
6337
|
+
const code = (0, import_nestjs_agent_core35.agentFailureCode)(error);
|
|
5617
6338
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
5618
|
-
(0,
|
|
6339
|
+
(0, import_nestjs_agent_core35.publishAgentRunFailed)({
|
|
5619
6340
|
runId,
|
|
5620
6341
|
code,
|
|
5621
6342
|
message
|
|
@@ -5626,11 +6347,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5626
6347
|
errorCode: code,
|
|
5627
6348
|
errorMessage: message
|
|
5628
6349
|
});
|
|
5629
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
6350
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core35.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
5630
6351
|
const writer = await deps.sink.open(runId);
|
|
5631
6352
|
await this.settleQueue(writer, input, runId, "failed", message);
|
|
5632
|
-
await (0,
|
|
5633
|
-
await writer.fail((0,
|
|
6353
|
+
await (0, import_nestjs_agent_core35.releaseThreadRun)(this.store, input.threadId, runId);
|
|
6354
|
+
await writer.fail((0, import_nestjs_agent_core35.streamFailure)(error));
|
|
5634
6355
|
}).finally(() => {
|
|
5635
6356
|
this.cancelled.delete(runId);
|
|
5636
6357
|
this.live.delete(runId);
|
|
@@ -5666,7 +6387,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5666
6387
|
for (const [key, waiter] of this.pending) {
|
|
5667
6388
|
if (key.startsWith(`${runId}:`)) {
|
|
5668
6389
|
this.pending.delete(key);
|
|
5669
|
-
waiter.reject(new
|
|
6390
|
+
waiter.reject(new import_nestjs_agent_core35.RunCancelledError());
|
|
5670
6391
|
}
|
|
5671
6392
|
}
|
|
5672
6393
|
await Promise.resolve();
|
|
@@ -5681,8 +6402,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5681
6402
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
5682
6403
|
const writer = await deps.sink.open(runId);
|
|
5683
6404
|
await this.settleQueue(writer, input, runId, "cancelled");
|
|
5684
|
-
await (0,
|
|
5685
|
-
await writer.write((0,
|
|
6405
|
+
await (0, import_nestjs_agent_core35.releaseThreadRun)(this.store, input.threadId, runId);
|
|
6406
|
+
await writer.write((0, import_nestjs_agent_core35.encodeStreamEvent)({
|
|
5686
6407
|
kind: "cancelled"
|
|
5687
6408
|
}));
|
|
5688
6409
|
await writer.end();
|
|
@@ -5717,7 +6438,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5717
6438
|
runId: nextRunId
|
|
5718
6439
|
}));
|
|
5719
6440
|
if (frame !== void 0) {
|
|
5720
|
-
await writer.write((0,
|
|
6441
|
+
await writer.write((0, import_nestjs_agent_core35.encodeStreamEvent)(frame));
|
|
5721
6442
|
}
|
|
5722
6443
|
} catch (failure) {
|
|
5723
6444
|
this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
@@ -5788,7 +6509,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5788
6509
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
5789
6510
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
5790
6511
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
5791
|
-
parallel:
|
|
6512
|
+
parallel: import_nestjs_agent_core35.settleAll,
|
|
5792
6513
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
5793
6514
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
5794
6515
|
agentName,
|
|
@@ -5839,7 +6560,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5839
6560
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
5840
6561
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
5841
6562
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
5842
|
-
parallel:
|
|
6563
|
+
parallel: import_nestjs_agent_core35.settleAll,
|
|
5843
6564
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
5844
6565
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
5845
6566
|
agentName: childName,
|
|
@@ -5872,7 +6593,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5872
6593
|
}
|
|
5873
6594
|
}), "startAgent")
|
|
5874
6595
|
};
|
|
5875
|
-
void (0,
|
|
6596
|
+
void (0, import_nestjs_agent_core35.runAgentLoop)({
|
|
5876
6597
|
...deps,
|
|
5877
6598
|
day
|
|
5878
6599
|
}, {
|
|
@@ -5886,13 +6607,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5886
6607
|
parentRunId,
|
|
5887
6608
|
deliverTo
|
|
5888
6609
|
}, hooks).catch(async (error) => {
|
|
5889
|
-
const cancelled = error instanceof
|
|
6610
|
+
const cancelled = error instanceof import_nestjs_agent_core35.RunCancelledError;
|
|
5890
6611
|
const message = error instanceof Error ? error.message : String(error);
|
|
5891
6612
|
if (!cancelled) {
|
|
5892
6613
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
5893
|
-
(0,
|
|
6614
|
+
(0, import_nestjs_agent_core35.publishAgentRunFailed)({
|
|
5894
6615
|
runId,
|
|
5895
|
-
code: (0,
|
|
6616
|
+
code: (0, import_nestjs_agent_core35.agentFailureCode)(error),
|
|
5896
6617
|
message
|
|
5897
6618
|
});
|
|
5898
6619
|
}
|
|
@@ -5900,12 +6621,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5900
6621
|
runId,
|
|
5901
6622
|
status: cancelled ? "cancelled" : "failed",
|
|
5902
6623
|
...cancelled ? {} : {
|
|
5903
|
-
errorCode: (0,
|
|
6624
|
+
errorCode: (0, import_nestjs_agent_core35.agentFailureCode)(error),
|
|
5904
6625
|
errorMessage: message
|
|
5905
6626
|
}
|
|
5906
6627
|
});
|
|
5907
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
5908
|
-
await (0,
|
|
6628
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core35.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
6629
|
+
await (0, import_nestjs_agent_core35.settleUnsettledDelegation)({
|
|
5909
6630
|
store: this.store,
|
|
5910
6631
|
delivery: deliverTo,
|
|
5911
6632
|
agent: agentName,
|
|
@@ -5944,7 +6665,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5944
6665
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
5945
6666
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
5946
6667
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
5947
|
-
parallel:
|
|
6668
|
+
parallel: import_nestjs_agent_core35.settleAll,
|
|
5948
6669
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
5949
6670
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
5950
6671
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -5979,7 +6700,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5979
6700
|
}), "startAgent")
|
|
5980
6701
|
};
|
|
5981
6702
|
try {
|
|
5982
|
-
return await (0,
|
|
6703
|
+
return await (0, import_nestjs_agent_core35.runAgentLoop)({
|
|
5983
6704
|
...deps,
|
|
5984
6705
|
day
|
|
5985
6706
|
}, {
|
|
@@ -5998,13 +6719,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5998
6719
|
}
|
|
5999
6720
|
}
|
|
6000
6721
|
};
|
|
6001
|
-
InlineAgentRunner =
|
|
6002
|
-
(0,
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6722
|
+
InlineAgentRunner = _ts_decorate29([
|
|
6723
|
+
(0, import_common30.Injectable)(),
|
|
6724
|
+
_ts_param27(0, (0, import_common30.Inject)(import_nestjs_agent_core35.AGENT_DEPS_FACTORY)),
|
|
6725
|
+
_ts_param27(1, (0, import_common30.Inject)(import_nestjs_agent_core35.AGENT_STORE)),
|
|
6726
|
+
_ts_param27(2, (0, import_common30.Optional)()),
|
|
6727
|
+
_ts_metadata27("design:type", Function),
|
|
6728
|
+
_ts_metadata27("design:paramtypes", [
|
|
6008
6729
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
6009
6730
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
6010
6731
|
typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2
|
|
@@ -6016,7 +6737,7 @@ function isThreadTurn2(input) {
|
|
|
6016
6737
|
__name(isThreadTurn2, "isThreadTurn");
|
|
6017
6738
|
|
|
6018
6739
|
// src/skills-config.ts
|
|
6019
|
-
var
|
|
6740
|
+
var import_nestjs_agent_core36 = require("@dudousxd/nestjs-agent-core");
|
|
6020
6741
|
function declaredSkillProvider(declared) {
|
|
6021
6742
|
return {
|
|
6022
6743
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -6042,7 +6763,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
6042
6763
|
declaredSkillProvider(declared)
|
|
6043
6764
|
];
|
|
6044
6765
|
return {
|
|
6045
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
6766
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core36.compositeSkillProvider)(providers),
|
|
6046
6767
|
...options.scopes !== void 0 ? {
|
|
6047
6768
|
scopes: options.scopes
|
|
6048
6769
|
} : {},
|
|
@@ -6054,7 +6775,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
6054
6775
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
6055
6776
|
|
|
6056
6777
|
// src/agent.module.ts
|
|
6057
|
-
function
|
|
6778
|
+
function _ts_decorate30(decorators, target, key, desc) {
|
|
6058
6779
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6059
6780
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
6060
6781
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -6067,13 +6788,13 @@ function _ts_decorate26(decorators, target, key, desc) {
|
|
|
6067
6788
|
}
|
|
6068
6789
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6069
6790
|
}
|
|
6070
|
-
__name(
|
|
6791
|
+
__name(_ts_decorate30, "_ts_decorate");
|
|
6071
6792
|
var DEFAULT_PATH = "agent";
|
|
6072
|
-
var logger = new
|
|
6793
|
+
var logger = new import_common31.Logger("AgentModule");
|
|
6073
6794
|
function externalStoreWrapper(modules) {
|
|
6074
6795
|
for (const module2 of modules.values()) {
|
|
6075
6796
|
if (module2.metatype === AgentModule) continue;
|
|
6076
|
-
const wrapper = module2.providers.get(
|
|
6797
|
+
const wrapper = module2.providers.get(import_nestjs_agent_core37.AGENT_STORE);
|
|
6077
6798
|
if (wrapper !== void 0) return wrapper;
|
|
6078
6799
|
}
|
|
6079
6800
|
return void 0;
|
|
@@ -6104,7 +6825,7 @@ function resolveStore(options, modules) {
|
|
|
6104
6825
|
const external = externalStoreWrapper(modules);
|
|
6105
6826
|
if (external !== void 0) return forwardingStore(external);
|
|
6106
6827
|
logger.warn("No `store` configured and no store module imported \u2014 using the in-memory store. Threads are lost on restart and not shared between processes: not for production. Pass `store`, or import a store module (e.g. MikroOrmAgentStoreModule.forFeature()).");
|
|
6107
|
-
return new
|
|
6828
|
+
return new import_nestjs_agent_core37.InMemoryAgentStore();
|
|
6108
6829
|
}
|
|
6109
6830
|
__name(resolveStore, "resolveStore");
|
|
6110
6831
|
function isQuotaProvider(quota) {
|
|
@@ -6120,99 +6841,99 @@ __name(resolveCatalog, "resolveCatalog");
|
|
|
6120
6841
|
function sharedProviders(durable) {
|
|
6121
6842
|
const providers = [
|
|
6122
6843
|
{
|
|
6123
|
-
provide:
|
|
6124
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
6844
|
+
provide: import_nestjs_agent_core37.AGENT_TOOL_REGISTRY,
|
|
6845
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core37.ToolRegistry(), "useFactory")
|
|
6125
6846
|
},
|
|
6126
6847
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
6127
6848
|
{
|
|
6128
|
-
provide:
|
|
6129
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
6849
|
+
provide: import_nestjs_agent_core37.AGENT_REGISTRY,
|
|
6850
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core37.AgentRegistry(), "useFactory")
|
|
6130
6851
|
},
|
|
6131
6852
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
6132
6853
|
{
|
|
6133
|
-
provide:
|
|
6854
|
+
provide: import_nestjs_agent_core37.AGENT_PROMPT_CONTRIBUTORS,
|
|
6134
6855
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
6135
6856
|
},
|
|
6136
6857
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
6137
6858
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
6138
6859
|
{
|
|
6139
|
-
provide:
|
|
6860
|
+
provide: import_nestjs_agent_core37.AGENT_SKILL_SOURCES,
|
|
6140
6861
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
6141
6862
|
},
|
|
6142
6863
|
{
|
|
6143
6864
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
6144
6865
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
6145
6866
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
6146
|
-
provide:
|
|
6867
|
+
provide: import_nestjs_agent_core37.AGENT_SKILLS,
|
|
6147
6868
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
6148
6869
|
inject: [
|
|
6149
|
-
|
|
6150
|
-
|
|
6870
|
+
import_nestjs_agent_core37.AGENT_OPTIONS,
|
|
6871
|
+
import_nestjs_agent_core37.AGENT_SKILL_SOURCES
|
|
6151
6872
|
]
|
|
6152
6873
|
},
|
|
6153
6874
|
{
|
|
6154
6875
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
6155
6876
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
6156
|
-
provide:
|
|
6877
|
+
provide: import_nestjs_agent_core37.AGENT_MEMORY,
|
|
6157
6878
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
6158
6879
|
inject: [
|
|
6159
|
-
|
|
6880
|
+
import_nestjs_agent_core37.AGENT_OPTIONS
|
|
6160
6881
|
]
|
|
6161
6882
|
},
|
|
6162
6883
|
{
|
|
6163
|
-
provide:
|
|
6884
|
+
provide: import_nestjs_agent_core37.AGENT_SINK,
|
|
6164
6885
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
6165
6886
|
inject: [
|
|
6166
|
-
|
|
6887
|
+
import_nestjs_agent_core37.AGENT_OPTIONS
|
|
6167
6888
|
]
|
|
6168
6889
|
},
|
|
6169
6890
|
{
|
|
6170
|
-
provide:
|
|
6171
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? (options.emptyRoles === "deny" ? new
|
|
6891
|
+
provide: import_nestjs_agent_core37.AGENT_ROLES_POLICY,
|
|
6892
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? (options.emptyRoles === "deny" ? new import_nestjs_agent_core37.ClosedRolesPolicy(options.defaultRoles) : new import_nestjs_agent_core37.DefaultRolesPolicy(options.defaultRoles)), "useFactory"),
|
|
6172
6893
|
inject: [
|
|
6173
|
-
|
|
6894
|
+
import_nestjs_agent_core37.AGENT_OPTIONS
|
|
6174
6895
|
]
|
|
6175
6896
|
},
|
|
6176
6897
|
{
|
|
6177
|
-
provide:
|
|
6898
|
+
provide: import_nestjs_agent_core37.AGENT_ACTOR_RESOLVER,
|
|
6178
6899
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
6179
6900
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
6180
6901
|
logger.warn("No `actorResolver` configured \u2014 the agent endpoints are PUBLIC: every browser gets its own anonymous identity (an HttpOnly cookie). Set `actorResolver: requestUserActorResolver()` (or your own) to require login.");
|
|
6181
6902
|
return new AnonymousActorResolver();
|
|
6182
6903
|
}, "useFactory"),
|
|
6183
6904
|
inject: [
|
|
6184
|
-
|
|
6905
|
+
import_nestjs_agent_core37.AGENT_OPTIONS
|
|
6185
6906
|
]
|
|
6186
6907
|
},
|
|
6187
6908
|
{
|
|
6188
|
-
provide:
|
|
6909
|
+
provide: import_nestjs_agent_core37.AGENT_MODEL,
|
|
6189
6910
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
6190
6911
|
inject: [
|
|
6191
|
-
|
|
6912
|
+
import_nestjs_agent_core37.AGENT_OPTIONS
|
|
6192
6913
|
]
|
|
6193
6914
|
},
|
|
6194
6915
|
{
|
|
6195
6916
|
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
6196
6917
|
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
6197
|
-
provide:
|
|
6918
|
+
provide: import_nestjs_agent_core37.AGENT_QUOTA_PROVIDER,
|
|
6198
6919
|
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
|
|
6199
6920
|
warnAt: o.quota.warnAt
|
|
6200
6921
|
} : {}), "useFactory"),
|
|
6201
6922
|
inject: [
|
|
6202
|
-
|
|
6203
|
-
|
|
6923
|
+
import_nestjs_agent_core37.AGENT_OPTIONS,
|
|
6924
|
+
import_nestjs_agent_core37.AGENT_STORE
|
|
6204
6925
|
]
|
|
6205
6926
|
},
|
|
6206
6927
|
{
|
|
6207
|
-
provide:
|
|
6928
|
+
provide: import_nestjs_agent_core37.AGENT_MODEL_CATALOG,
|
|
6208
6929
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
6209
6930
|
inject: [
|
|
6210
|
-
|
|
6931
|
+
import_nestjs_agent_core37.AGENT_OPTIONS
|
|
6211
6932
|
]
|
|
6212
6933
|
},
|
|
6213
6934
|
AgentDepsFactory2,
|
|
6214
6935
|
{
|
|
6215
|
-
provide:
|
|
6936
|
+
provide: import_nestjs_agent_core37.AGENT_DEPS_FACTORY,
|
|
6216
6937
|
useExisting: AgentDepsFactory2
|
|
6217
6938
|
},
|
|
6218
6939
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -6229,25 +6950,27 @@ function sharedProviders(durable) {
|
|
|
6229
6950
|
},
|
|
6230
6951
|
InlineAgentRunner,
|
|
6231
6952
|
AgentService,
|
|
6953
|
+
ActionProposalService,
|
|
6954
|
+
ActionProposalWorkerService,
|
|
6232
6955
|
// Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
|
|
6233
6956
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
6234
6957
|
AgentApprovalPortAdapter,
|
|
6235
6958
|
{
|
|
6236
|
-
provide:
|
|
6959
|
+
provide: import_nestjs_agent_core37.AGENT_APPROVAL_PORT,
|
|
6237
6960
|
useExisting: AgentApprovalPortAdapter
|
|
6238
6961
|
}
|
|
6239
6962
|
];
|
|
6240
6963
|
providers.push({
|
|
6241
|
-
provide:
|
|
6964
|
+
provide: import_nestjs_agent_core37.AGENT_STORE,
|
|
6242
6965
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
6243
6966
|
inject: [
|
|
6244
|
-
|
|
6967
|
+
import_nestjs_agent_core37.AGENT_OPTIONS,
|
|
6245
6968
|
import_core4.ModulesContainer
|
|
6246
6969
|
]
|
|
6247
6970
|
});
|
|
6248
6971
|
if (durable) {
|
|
6249
6972
|
providers.push({
|
|
6250
|
-
provide:
|
|
6973
|
+
provide: import_nestjs_agent_core37.AGENT_RUNNER,
|
|
6251
6974
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
6252
6975
|
if (durableRunner === void 0) {
|
|
6253
6976
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -6256,14 +6979,14 @@ function sharedProviders(durable) {
|
|
|
6256
6979
|
}, "useFactory"),
|
|
6257
6980
|
inject: [
|
|
6258
6981
|
{
|
|
6259
|
-
token:
|
|
6982
|
+
token: import_nestjs_agent_core37.AGENT_DURABLE_RUNNER,
|
|
6260
6983
|
optional: true
|
|
6261
6984
|
}
|
|
6262
6985
|
]
|
|
6263
6986
|
});
|
|
6264
6987
|
} else {
|
|
6265
6988
|
providers.push({
|
|
6266
|
-
provide:
|
|
6989
|
+
provide: import_nestjs_agent_core37.AGENT_RUNNER,
|
|
6267
6990
|
useExisting: InlineAgentRunner
|
|
6268
6991
|
});
|
|
6269
6992
|
}
|
|
@@ -6272,30 +6995,33 @@ function sharedProviders(durable) {
|
|
|
6272
6995
|
__name(sharedProviders, "sharedProviders");
|
|
6273
6996
|
function exportsFor() {
|
|
6274
6997
|
return [
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6998
|
+
import_nestjs_agent_core37.AGENT_OPTIONS,
|
|
6999
|
+
import_nestjs_agent_core37.AGENT_TOOL_REGISTRY,
|
|
7000
|
+
import_nestjs_agent_core37.AGENT_REGISTRY,
|
|
7001
|
+
import_nestjs_agent_core37.AGENT_SINK,
|
|
7002
|
+
import_nestjs_agent_core37.AGENT_ROLES_POLICY,
|
|
7003
|
+
import_nestjs_agent_core37.AGENT_ACTOR_RESOLVER,
|
|
7004
|
+
import_nestjs_agent_core37.AGENT_MODEL,
|
|
7005
|
+
import_nestjs_agent_core37.AGENT_STORE,
|
|
7006
|
+
import_nestjs_agent_core37.AGENT_MODEL_CATALOG,
|
|
7007
|
+
import_nestjs_agent_core37.AGENT_QUOTA_PROVIDER,
|
|
7008
|
+
import_nestjs_agent_core37.AGENT_PROMPT_CONTRIBUTORS,
|
|
7009
|
+
import_nestjs_agent_core37.AGENT_SKILLS,
|
|
7010
|
+
import_nestjs_agent_core37.AGENT_MEMORY,
|
|
7011
|
+
import_nestjs_agent_core37.AGENT_DEPS_FACTORY,
|
|
6289
7012
|
AgentDepsFactory2,
|
|
6290
7013
|
AgentService,
|
|
7014
|
+
ActionProposalService,
|
|
7015
|
+
ActionProposalWorkerService,
|
|
6291
7016
|
ChatQueueService2,
|
|
6292
7017
|
AGENT_CHAT_QUEUE,
|
|
6293
7018
|
InlineAgentRunner,
|
|
6294
|
-
|
|
7019
|
+
import_nestjs_agent_core37.AGENT_APPROVAL_PORT
|
|
6295
7020
|
];
|
|
6296
7021
|
}
|
|
6297
7022
|
__name(exportsFor, "exportsFor");
|
|
6298
7023
|
var BASE_CONTROLLERS = [
|
|
7024
|
+
ActionProposalController,
|
|
6299
7025
|
ChatController,
|
|
6300
7026
|
QueueController,
|
|
6301
7027
|
ThreadsController,
|
|
@@ -6368,7 +7094,7 @@ var AgentModule = class _AgentModule {
|
|
|
6368
7094
|
controllers: controllersForSurface(options.surface, options.adapters),
|
|
6369
7095
|
providers: [
|
|
6370
7096
|
{
|
|
6371
|
-
provide:
|
|
7097
|
+
provide: import_nestjs_agent_core37.AGENT_OPTIONS,
|
|
6372
7098
|
useValue: options
|
|
6373
7099
|
},
|
|
6374
7100
|
...sharedProviders(options.durable ?? false),
|
|
@@ -6392,7 +7118,7 @@ var AgentModule = class _AgentModule {
|
|
|
6392
7118
|
controllers: controllersForSurface(options.surface, options.adapters),
|
|
6393
7119
|
providers: [
|
|
6394
7120
|
{
|
|
6395
|
-
provide:
|
|
7121
|
+
provide: import_nestjs_agent_core37.AGENT_OPTIONS,
|
|
6396
7122
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
6397
7123
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
6398
7124
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -6414,9 +7140,9 @@ var AgentModule = class _AgentModule {
|
|
|
6414
7140
|
};
|
|
6415
7141
|
}
|
|
6416
7142
|
};
|
|
6417
|
-
AgentModule =
|
|
6418
|
-
(0,
|
|
6419
|
-
(0,
|
|
7143
|
+
AgentModule = _ts_decorate30([
|
|
7144
|
+
(0, import_common31.Global)(),
|
|
7145
|
+
(0, import_common31.Module)({})
|
|
6420
7146
|
], AgentModule);
|
|
6421
7147
|
|
|
6422
7148
|
// src/durable/agent-durable.ts
|