@dudousxd/nestjs-agent 1.20.0 → 1.22.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 +58 -0
- package/dist/{chat-queue.service-C0hr7dqx.d.cts → chat-queue.service-CTyX_yNr.d.ts} +48 -3
- package/dist/{chat-queue.service-C0hr7dqx.d.ts → chat-queue.service-Dx9OsjcF.d.cts} +48 -3
- package/dist/durable/index.cjs +1662 -839
- 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 +1395 -572
- package/dist/durable/index.js.map +1 -1
- package/dist/genui/index.cjs +1 -0
- package/dist/genui/index.cjs.map +1 -1
- package/dist/genui/index.d.cts +1 -1
- package/dist/genui/index.d.ts +1 -1
- package/dist/genui/index.js +1 -0
- package/dist/genui/index.js.map +1 -1
- package/dist/index.cjs +1647 -831
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +140 -9
- package/dist/index.d.ts +140 -9
- package/dist/index.js +1417 -605
- package/dist/index.js.map +1 -1
- package/dist/sink-redis/index.cjs +7 -2
- package/dist/sink-redis/index.cjs.map +1 -1
- package/dist/sink-redis/index.d.cts +6 -3
- package/dist/sink-redis/index.d.ts +6 -3
- package/dist/sink-redis/index.js +7 -2
- package/dist/sink-redis/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,45 @@ AgentDurableModule = _ts_decorate4([
|
|
|
1122
1199
|
], AgentDurableModule);
|
|
1123
1200
|
|
|
1124
1201
|
// src/agent.module.ts
|
|
1125
|
-
var
|
|
1126
|
-
var
|
|
1202
|
+
var import_nestjs_agent_core39 = 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_core9 = require("@dudousxd/nestjs-agent-core");
|
|
1208
|
+
var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
|
|
1209
|
+
var import_nestjs_agent_core11 = 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 import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
1218
|
+
var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
|
|
1219
|
+
function brand(tool) {
|
|
1220
|
+
return {
|
|
1221
|
+
[AGENT_TOOL_BRAND]: true,
|
|
1222
|
+
spec: tool.spec,
|
|
1223
|
+
handler: tool.handler
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
__name(brand, "brand");
|
|
1227
|
+
function isBrandedFunctionalTool(value) {
|
|
1228
|
+
return AGENT_TOOL_BRAND in value && "spec" in value && "handler" in value;
|
|
1229
|
+
}
|
|
1230
|
+
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
1231
|
+
function provideAgentTools(factory, inject) {
|
|
1232
|
+
return {
|
|
1233
|
+
provide: /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-list"),
|
|
1234
|
+
useFactory: /* @__PURE__ */ __name(async (...deps) => (await factory(...deps)).map(brand), "useFactory"),
|
|
1235
|
+
inject: inject ?? []
|
|
1236
|
+
};
|
|
1237
|
+
}
|
|
1238
|
+
__name(provideAgentTools, "provideAgentTools");
|
|
1239
|
+
|
|
1240
|
+
// src/genui/agent-genui.module.ts
|
|
1133
1241
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
1134
1242
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1135
1243
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1144,6 +1252,124 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
1144
1252
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1145
1253
|
}
|
|
1146
1254
|
__name(_ts_decorate5, "_ts_decorate");
|
|
1255
|
+
var GENUI_CATALOG = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-catalog");
|
|
1256
|
+
var GENUI_OPTIONS = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-options");
|
|
1257
|
+
var GenuiCatalogResolver = class {
|
|
1258
|
+
static {
|
|
1259
|
+
__name(this, "GenuiCatalogResolver");
|
|
1260
|
+
}
|
|
1261
|
+
};
|
|
1262
|
+
function resolverProviders(resolver) {
|
|
1263
|
+
if (resolver === void 0) return [];
|
|
1264
|
+
return [
|
|
1265
|
+
typeof resolver === "function" ? {
|
|
1266
|
+
provide: GenuiCatalogResolver,
|
|
1267
|
+
useClass: resolver
|
|
1268
|
+
} : {
|
|
1269
|
+
provide: GenuiCatalogResolver,
|
|
1270
|
+
useValue: resolver
|
|
1271
|
+
}
|
|
1272
|
+
];
|
|
1273
|
+
}
|
|
1274
|
+
__name(resolverProviders, "resolverProviders");
|
|
1275
|
+
function toolOptions(options, resolver) {
|
|
1276
|
+
const { catalog: _catalog, ...rest } = options;
|
|
1277
|
+
return {
|
|
1278
|
+
...rest,
|
|
1279
|
+
...resolver !== void 0 ? {
|
|
1280
|
+
resolveCatalog: /* @__PURE__ */ __name((scope) => resolver.resolve(scope), "resolveCatalog")
|
|
1281
|
+
} : {}
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
__name(toolOptions, "toolOptions");
|
|
1285
|
+
function coreProviders(resolver) {
|
|
1286
|
+
return [
|
|
1287
|
+
{
|
|
1288
|
+
provide: GENUI_CATALOG,
|
|
1289
|
+
useFactory: /* @__PURE__ */ __name((options) => options.catalog ?? (0, import_genui.defineCatalog)([]), "useFactory"),
|
|
1290
|
+
inject: [
|
|
1291
|
+
GENUI_OPTIONS
|
|
1292
|
+
]
|
|
1293
|
+
},
|
|
1294
|
+
...resolverProviders(resolver),
|
|
1295
|
+
// The generated tools, registered by the agent module's discovery like any `provideAgentTool`.
|
|
1296
|
+
// Built from the injected catalog, so `overrideProvider(GENUI_CATALOG)` changes them too.
|
|
1297
|
+
provideAgentTools((options, catalog, perRequest) => (0, import_genui.genuiTools)(catalog, toolOptions(options, perRequest)), [
|
|
1298
|
+
GENUI_OPTIONS,
|
|
1299
|
+
GENUI_CATALOG,
|
|
1300
|
+
{
|
|
1301
|
+
token: GenuiCatalogResolver,
|
|
1302
|
+
optional: true
|
|
1303
|
+
}
|
|
1304
|
+
])
|
|
1305
|
+
];
|
|
1306
|
+
}
|
|
1307
|
+
__name(coreProviders, "coreProviders");
|
|
1308
|
+
var EXPORTS = [
|
|
1309
|
+
GENUI_CATALOG,
|
|
1310
|
+
GENUI_OPTIONS
|
|
1311
|
+
];
|
|
1312
|
+
var AgentGenuiModule = class _AgentGenuiModule {
|
|
1313
|
+
static {
|
|
1314
|
+
__name(this, "AgentGenuiModule");
|
|
1315
|
+
}
|
|
1316
|
+
static forRoot(options = {}) {
|
|
1317
|
+
const { resolver, ...rest } = options;
|
|
1318
|
+
return {
|
|
1319
|
+
module: _AgentGenuiModule,
|
|
1320
|
+
global: true,
|
|
1321
|
+
providers: [
|
|
1322
|
+
{
|
|
1323
|
+
provide: GENUI_OPTIONS,
|
|
1324
|
+
useValue: rest
|
|
1325
|
+
},
|
|
1326
|
+
...coreProviders(resolver)
|
|
1327
|
+
],
|
|
1328
|
+
exports: resolver === void 0 ? EXPORTS : [
|
|
1329
|
+
...EXPORTS,
|
|
1330
|
+
GenuiCatalogResolver
|
|
1331
|
+
]
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
static forRootAsync(options) {
|
|
1335
|
+
return {
|
|
1336
|
+
module: _AgentGenuiModule,
|
|
1337
|
+
global: true,
|
|
1338
|
+
imports: options.imports ?? [],
|
|
1339
|
+
providers: [
|
|
1340
|
+
{
|
|
1341
|
+
provide: GENUI_OPTIONS,
|
|
1342
|
+
useFactory: options.useFactory,
|
|
1343
|
+
inject: options.inject ?? []
|
|
1344
|
+
},
|
|
1345
|
+
...coreProviders(options.resolver)
|
|
1346
|
+
],
|
|
1347
|
+
exports: options.resolver === void 0 ? EXPORTS : [
|
|
1348
|
+
...EXPORTS,
|
|
1349
|
+
GenuiCatalogResolver
|
|
1350
|
+
]
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
AgentGenuiModule = _ts_decorate5([
|
|
1355
|
+
(0, import_common5.Module)({})
|
|
1356
|
+
], AgentGenuiModule);
|
|
1357
|
+
|
|
1358
|
+
// src/agent-deps.factory.ts
|
|
1359
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1360
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1361
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1362
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1363
|
+
} else {
|
|
1364
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1365
|
+
if (d = decorators[i]) {
|
|
1366
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1371
|
+
}
|
|
1372
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
1147
1373
|
function _ts_metadata4(metadataKey, metadataValue) {
|
|
1148
1374
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1149
1375
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
@@ -1176,7 +1402,9 @@ var AgentDepsFactory2 = class {
|
|
|
1176
1402
|
pricingStore;
|
|
1177
1403
|
skills;
|
|
1178
1404
|
memory;
|
|
1179
|
-
|
|
1405
|
+
uiCatalog;
|
|
1406
|
+
uiCatalogResolver;
|
|
1407
|
+
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver) {
|
|
1180
1408
|
this.options = options;
|
|
1181
1409
|
this.model = model;
|
|
1182
1410
|
this.store = store;
|
|
@@ -1188,6 +1416,9 @@ var AgentDepsFactory2 = class {
|
|
|
1188
1416
|
this.pricingStore = pricingStore;
|
|
1189
1417
|
this.skills = skills;
|
|
1190
1418
|
this.memory = memory;
|
|
1419
|
+
this.uiCatalog = uiCatalog;
|
|
1420
|
+
this.uiCatalogResolver = uiCatalogResolver;
|
|
1421
|
+
if (options.actionApprovalMode === "independent") (0, import_nestjs_agent_core9.assertIndependentActionCapabilities)(store, options.backgroundActorResolver);
|
|
1191
1422
|
}
|
|
1192
1423
|
/** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
|
|
1193
1424
|
memoryConfig() {
|
|
@@ -1213,7 +1444,7 @@ var AgentDepsFactory2 = class {
|
|
|
1213
1444
|
return void 0;
|
|
1214
1445
|
}
|
|
1215
1446
|
const delegated = (definition.delegatesTo ?? []).map((edge) => {
|
|
1216
|
-
const { agent, detached } = (0,
|
|
1447
|
+
const { agent, detached } = (0, import_nestjs_agent_core10.normalizeDelegation)(edge);
|
|
1217
1448
|
return delegateToolName({
|
|
1218
1449
|
target: agent,
|
|
1219
1450
|
detached
|
|
@@ -1237,7 +1468,7 @@ var AgentDepsFactory2 = class {
|
|
|
1237
1468
|
agentName: name
|
|
1238
1469
|
};
|
|
1239
1470
|
}
|
|
1240
|
-
const alias = (0,
|
|
1471
|
+
const alias = (0, import_nestjs_agent_core10.resolvePersonaAlias)(this.agents.list(), name);
|
|
1241
1472
|
return alias === void 0 ? {
|
|
1242
1473
|
agentName: name
|
|
1243
1474
|
} : {
|
|
@@ -1247,7 +1478,7 @@ var AgentDepsFactory2 = class {
|
|
|
1247
1478
|
}
|
|
1248
1479
|
/** `agentName`'s personas as a picker reads them. Empty when it declares none. */
|
|
1249
1480
|
personaCatalog(agentName) {
|
|
1250
|
-
return (this.agents.get(agentName)?.personas ?? []).map(
|
|
1481
|
+
return (this.agents.get(agentName)?.personas ?? []).map(import_nestjs_agent_core10.personaCatalogEntry);
|
|
1251
1482
|
}
|
|
1252
1483
|
/** The persona `agentName` runs under when nothing names one. Undefined → none. */
|
|
1253
1484
|
defaultPersona(agentName) {
|
|
@@ -1261,8 +1492,8 @@ var AgentDepsFactory2 = class {
|
|
|
1261
1492
|
resolvePersona(args) {
|
|
1262
1493
|
const definition = this.agents.get(args.agentName);
|
|
1263
1494
|
if (args.requested !== void 0) {
|
|
1264
|
-
if ((0,
|
|
1265
|
-
throw new
|
|
1495
|
+
if ((0, import_nestjs_agent_core10.findPersona)(definition, args.requested) === void 0) {
|
|
1496
|
+
throw new import_common6.BadRequestException({
|
|
1266
1497
|
statusCode: 400,
|
|
1267
1498
|
code: "persona_not_found",
|
|
1268
1499
|
message: `agent "${args.agentName}" has no persona "${args.requested}"`
|
|
@@ -1271,16 +1502,28 @@ var AgentDepsFactory2 = class {
|
|
|
1271
1502
|
return args.requested;
|
|
1272
1503
|
}
|
|
1273
1504
|
const pinned = args.threadPersona ?? void 0;
|
|
1274
|
-
if (pinned !== void 0 && (0,
|
|
1505
|
+
if (pinned !== void 0 && (0, import_nestjs_agent_core10.findPersona)(definition, pinned) !== void 0) {
|
|
1275
1506
|
return pinned;
|
|
1276
1507
|
}
|
|
1277
1508
|
return definition?.defaultPersona;
|
|
1278
1509
|
}
|
|
1510
|
+
forProposal(proposal, _actor) {
|
|
1511
|
+
const name = proposal.executionContext?.agentName;
|
|
1512
|
+
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`);
|
|
1513
|
+
const deps = this.forAgent(name);
|
|
1514
|
+
const id = proposal.executionContext?.persona;
|
|
1515
|
+
if (id !== void 0) {
|
|
1516
|
+
const persona = deps.personas?.find((persona2) => persona2.id === id);
|
|
1517
|
+
if (!persona) throw new Error(`Recorded persona ${id} no longer exists`);
|
|
1518
|
+
return this.withPersona(deps, persona);
|
|
1519
|
+
}
|
|
1520
|
+
return deps;
|
|
1521
|
+
}
|
|
1279
1522
|
forAgent(agentName) {
|
|
1280
1523
|
const name = agentName ?? this.defaultAgentName();
|
|
1281
1524
|
if (agentName !== void 0 && !this.agents.has(agentName)) {
|
|
1282
|
-
const alias = (0,
|
|
1283
|
-
const persona = alias === void 0 ? void 0 : (0,
|
|
1525
|
+
const alias = (0, import_nestjs_agent_core10.resolvePersonaAlias)(this.agents.list(), agentName);
|
|
1526
|
+
const persona = alias === void 0 ? void 0 : (0, import_nestjs_agent_core10.findPersona)(this.agents.get(alias.agent), alias.persona);
|
|
1284
1527
|
if (alias !== void 0 && persona !== void 0) {
|
|
1285
1528
|
return this.withPersona(this.forAgent(alias.agent), persona);
|
|
1286
1529
|
}
|
|
@@ -1294,12 +1537,27 @@ var AgentDepsFactory2 = class {
|
|
|
1294
1537
|
return {
|
|
1295
1538
|
model: this.model,
|
|
1296
1539
|
store: this.store,
|
|
1540
|
+
...this.options.actionApprovalMode !== void 0 ? {
|
|
1541
|
+
actionApprovalMode: this.options.actionApprovalMode
|
|
1542
|
+
} : {},
|
|
1297
1543
|
sink: this.sink,
|
|
1298
1544
|
rolesPolicy: this.rolesPolicy,
|
|
1299
1545
|
...this.options.approvalPolicy !== void 0 ? {
|
|
1300
1546
|
approvalPolicy: this.options.approvalPolicy
|
|
1301
1547
|
} : {},
|
|
1302
1548
|
registry: this.registry,
|
|
1549
|
+
...this.uiCatalog !== void 0 || this.uiCatalogResolver !== void 0 ? {
|
|
1550
|
+
resolveUiCatalog: /* @__PURE__ */ __name((scope) => {
|
|
1551
|
+
const catalog = this.uiCatalogResolver?.resolve({
|
|
1552
|
+
...scope,
|
|
1553
|
+
...scope.actor.tenantRef !== void 0 ? {
|
|
1554
|
+
tenant: scope.actor.tenantRef
|
|
1555
|
+
} : {}
|
|
1556
|
+
}) ?? this.uiCatalog;
|
|
1557
|
+
if (!catalog) throw new Error("UI catalog unavailable");
|
|
1558
|
+
return catalog;
|
|
1559
|
+
}, "resolveUiCatalog")
|
|
1560
|
+
} : {},
|
|
1303
1561
|
promptContributors: this.promptContributors,
|
|
1304
1562
|
systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
|
|
1305
1563
|
maxSteps: definition?.maxSteps ?? 8,
|
|
@@ -1399,7 +1657,7 @@ var AgentDepsFactory2 = class {
|
|
|
1399
1657
|
} : {}
|
|
1400
1658
|
});
|
|
1401
1659
|
}, "systemPrompt");
|
|
1402
|
-
const toolAllowList = (0,
|
|
1660
|
+
const toolAllowList = (0, import_nestjs_agent_core10.intersectAllowLists)(deps.toolAllowList, persona.allowedTools);
|
|
1403
1661
|
return {
|
|
1404
1662
|
...deps,
|
|
1405
1663
|
systemPrompt,
|
|
@@ -1424,7 +1682,7 @@ var AgentDepsFactory2 = class {
|
|
|
1424
1682
|
}
|
|
1425
1683
|
/** Build the built-in window policy from the declarative `{ maxMessages, maxTokens, summarize }`. */
|
|
1426
1684
|
window(config) {
|
|
1427
|
-
return (0,
|
|
1685
|
+
return (0, import_nestjs_agent_core10.windowHistory)({
|
|
1428
1686
|
...config.maxMessages !== void 0 ? {
|
|
1429
1687
|
maxMessages: config.maxMessages
|
|
1430
1688
|
} : {},
|
|
@@ -1434,7 +1692,7 @@ var AgentDepsFactory2 = class {
|
|
|
1434
1692
|
// The shared module model, not a per-agent one: an agent's `modelId` is an accounting label,
|
|
1435
1693
|
// and only one provider is ever bound.
|
|
1436
1694
|
...config.summarize === true ? {
|
|
1437
|
-
summarize: (0,
|
|
1695
|
+
summarize: (0, import_nestjs_agent_core10.summarizeWithModel)(this.model)
|
|
1438
1696
|
} : {}
|
|
1439
1697
|
});
|
|
1440
1698
|
}
|
|
@@ -1450,22 +1708,25 @@ var AgentDepsFactory2 = class {
|
|
|
1450
1708
|
return void 0;
|
|
1451
1709
|
}
|
|
1452
1710
|
};
|
|
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,
|
|
1711
|
+
AgentDepsFactory2 = _ts_decorate6([
|
|
1712
|
+
(0, import_common6.Injectable)(),
|
|
1713
|
+
_ts_param4(0, (0, import_common6.Inject)(import_nestjs_agent_core11.AGENT_OPTIONS)),
|
|
1714
|
+
_ts_param4(1, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_MODEL)),
|
|
1715
|
+
_ts_param4(2, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_STORE)),
|
|
1716
|
+
_ts_param4(3, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_SINK)),
|
|
1717
|
+
_ts_param4(4, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_ROLES_POLICY)),
|
|
1718
|
+
_ts_param4(5, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_TOOL_REGISTRY)),
|
|
1719
|
+
_ts_param4(6, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_REGISTRY)),
|
|
1720
|
+
_ts_param4(7, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_PROMPT_CONTRIBUTORS)),
|
|
1721
|
+
_ts_param4(8, (0, import_common6.Optional)()),
|
|
1722
|
+
_ts_param4(8, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_PRICING_STORE)),
|
|
1723
|
+
_ts_param4(9, (0, import_common6.Optional)()),
|
|
1724
|
+
_ts_param4(9, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_SKILLS)),
|
|
1725
|
+
_ts_param4(10, (0, import_common6.Optional)()),
|
|
1726
|
+
_ts_param4(10, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_MEMORY)),
|
|
1727
|
+
_ts_param4(11, (0, import_common6.Optional)()),
|
|
1728
|
+
_ts_param4(11, (0, import_common6.Inject)(GENUI_CATALOG)),
|
|
1729
|
+
_ts_param4(12, (0, import_common6.Optional)()),
|
|
1469
1730
|
_ts_metadata4("design:type", Function),
|
|
1470
1731
|
_ts_metadata4("design:paramtypes", [
|
|
1471
1732
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -1473,22 +1734,223 @@ AgentDepsFactory2 = _ts_decorate5([
|
|
|
1473
1734
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1474
1735
|
typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
|
|
1475
1736
|
typeof RolesPolicy === "undefined" ? Object : RolesPolicy,
|
|
1476
|
-
typeof
|
|
1477
|
-
typeof
|
|
1737
|
+
typeof import_nestjs_agent_core10.ToolRegistry === "undefined" ? Object : import_nestjs_agent_core10.ToolRegistry,
|
|
1738
|
+
typeof import_nestjs_agent_core10.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core10.AgentRegistry,
|
|
1478
1739
|
Array,
|
|
1479
1740
|
Object,
|
|
1480
1741
|
Object,
|
|
1481
|
-
Object
|
|
1742
|
+
Object,
|
|
1743
|
+
typeof Catalog === "undefined" ? Object : Catalog,
|
|
1744
|
+
typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
|
|
1482
1745
|
])
|
|
1483
1746
|
], AgentDepsFactory2);
|
|
1484
1747
|
|
|
1485
1748
|
// src/agent.service.ts
|
|
1486
|
-
var
|
|
1487
|
-
var
|
|
1749
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
1750
|
+
var import_common10 = require("@nestjs/common");
|
|
1751
|
+
|
|
1752
|
+
// src/proposals/action-proposal.service.ts
|
|
1753
|
+
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
1754
|
+
var import_common7 = require("@nestjs/common");
|
|
1755
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1756
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1757
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1758
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1759
|
+
} else {
|
|
1760
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1761
|
+
if (d = decorators[i]) {
|
|
1762
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1767
|
+
}
|
|
1768
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
1769
|
+
function _ts_metadata5(metadataKey, metadataValue) {
|
|
1770
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1771
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
1775
|
+
function _ts_param5(paramIndex, decorator) {
|
|
1776
|
+
return function(target, key) {
|
|
1777
|
+
decorator(target, key, paramIndex);
|
|
1778
|
+
};
|
|
1779
|
+
}
|
|
1780
|
+
__name(_ts_param5, "_ts_param");
|
|
1781
|
+
var ActionProposalService = class {
|
|
1782
|
+
static {
|
|
1783
|
+
__name(this, "ActionProposalService");
|
|
1784
|
+
}
|
|
1785
|
+
store;
|
|
1786
|
+
options;
|
|
1787
|
+
constructor(store, options) {
|
|
1788
|
+
this.store = store;
|
|
1789
|
+
this.options = options;
|
|
1790
|
+
const text = options.actionProposalText;
|
|
1791
|
+
this.vocabulary = {
|
|
1792
|
+
...import_nestjs_agent_core12.DEFAULT_TEXT_ACTION_PROPOSAL_VOCABULARY,
|
|
1793
|
+
...text?.vocabulary
|
|
1794
|
+
};
|
|
1795
|
+
this.replies = {
|
|
1796
|
+
...import_nestjs_agent_core12.DEFAULT_TEXT_ACTION_PROPOSAL_REPLIES,
|
|
1797
|
+
...text?.replies
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1800
|
+
/** The words a text decision is made of, and what the agent answers — English unless configured. */
|
|
1801
|
+
vocabulary;
|
|
1802
|
+
replies;
|
|
1803
|
+
capability() {
|
|
1804
|
+
const store = this.store;
|
|
1805
|
+
if (typeof store.getThreadActionProposalScope !== "function" || typeof store.listActionProposals !== "function") throw new import_common7.NotImplementedException("Action proposals are unavailable");
|
|
1806
|
+
return store;
|
|
1807
|
+
}
|
|
1808
|
+
async scope(threadId, actor) {
|
|
1809
|
+
const scope = await this.capability().getThreadActionProposalScope(threadId);
|
|
1810
|
+
if (!scope) throw new import_common7.NotFoundException("Thread not found");
|
|
1811
|
+
if (scope.tenantRef !== (actor.tenantRef ?? null)) throw new import_common7.ForbiddenException("Wrong proposal tenant");
|
|
1812
|
+
return scope;
|
|
1813
|
+
}
|
|
1814
|
+
mayDecide(actor, proposal) {
|
|
1815
|
+
return (0, import_nestjs_agent_core12.mayDecideApproval)(this.options.approvalPolicy, actor, {
|
|
1816
|
+
toolCallId: proposal.originToolCallId,
|
|
1817
|
+
approver: proposal.approver,
|
|
1818
|
+
requesterRef: proposal.actorRef
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
async listPage(threadId, actor, query = {}) {
|
|
1822
|
+
const scope = await this.scope(threadId, actor);
|
|
1823
|
+
const rows = await this.capability().listActionProposals(scope, {
|
|
1824
|
+
limit: 1e3,
|
|
1825
|
+
...query
|
|
1826
|
+
});
|
|
1827
|
+
const visible = [];
|
|
1828
|
+
for (const row of rows) if (scope.actorRef === actor.id || await this.mayDecide(actor, row)) visible.push(row);
|
|
1829
|
+
const last = rows.at(-1);
|
|
1830
|
+
return {
|
|
1831
|
+
// The public view: a row carries the worker's lease token and the tool's idempotency key.
|
|
1832
|
+
items: visible.map(import_nestjs_agent_core12.toActionProposalView),
|
|
1833
|
+
...rows.length === 1e3 && last ? {
|
|
1834
|
+
next: {
|
|
1835
|
+
createdAt: last.createdAt,
|
|
1836
|
+
id: last.id
|
|
1837
|
+
}
|
|
1838
|
+
} : {}
|
|
1839
|
+
};
|
|
1840
|
+
}
|
|
1841
|
+
async list(threadId, actor) {
|
|
1842
|
+
return (await this.listPage(threadId, actor)).items;
|
|
1843
|
+
}
|
|
1844
|
+
async decide(threadId, proposalId, actor, command) {
|
|
1845
|
+
const scope = await this.scope(threadId, actor);
|
|
1846
|
+
const proposal = await this.capability().getActionProposal(scope, proposalId);
|
|
1847
|
+
if (!proposal) throw new import_common7.NotFoundException("Proposal not found");
|
|
1848
|
+
if (!await this.mayDecide(actor, proposal)) throw new import_common7.ForbiddenException("May not decide this proposal");
|
|
1849
|
+
const result = await this.capability().decideActionProposal(scope, proposalId, {
|
|
1850
|
+
decision: command.decision,
|
|
1851
|
+
actorRef: actor.id,
|
|
1852
|
+
via: command.via ?? "web",
|
|
1853
|
+
...command.remember !== void 0 ? {
|
|
1854
|
+
remember: command.remember
|
|
1855
|
+
} : {},
|
|
1856
|
+
...command.reason !== void 0 ? {
|
|
1857
|
+
reason: command.reason
|
|
1858
|
+
} : {}
|
|
1859
|
+
});
|
|
1860
|
+
return (0, import_nestjs_agent_core12.toActionProposalMutationView)(result);
|
|
1861
|
+
}
|
|
1862
|
+
async handleTextDecision(threadId, actor, text) {
|
|
1863
|
+
const command = (0, import_nestjs_agent_core12.parseTextActionProposalCommand)(text, this.vocabulary);
|
|
1864
|
+
if (command.status === "unmatched") return command;
|
|
1865
|
+
if (command.proposalId !== void 0) {
|
|
1866
|
+
const result2 = await this.decide(threadId, command.proposalId, actor, {
|
|
1867
|
+
decision: command.decision,
|
|
1868
|
+
remember: command.remember,
|
|
1869
|
+
via: "text"
|
|
1870
|
+
});
|
|
1871
|
+
return this.textReceipt(threadId, result2, command.decision);
|
|
1872
|
+
}
|
|
1873
|
+
const candidates = [];
|
|
1874
|
+
const scope = await this.scope(threadId, actor);
|
|
1875
|
+
const pending = await this.capability().listActionProposals(scope, {
|
|
1876
|
+
decision: "pending",
|
|
1877
|
+
limit: 1e3
|
|
1878
|
+
});
|
|
1879
|
+
for (const proposal of pending) if (await this.mayDecide(actor, proposal)) candidates.push(proposal);
|
|
1880
|
+
const resolution = (0, import_nestjs_agent_core12.resolveTextActionProposalDecision)(text, candidates, this.vocabulary);
|
|
1881
|
+
if (resolution.status === "unmatched") return resolution;
|
|
1882
|
+
const saturated = pending.length === 1e3 && !text.includes("#");
|
|
1883
|
+
if (resolution.status === "ambiguous" || saturated) {
|
|
1884
|
+
const proposalIds = candidates.map(({ id }) => id);
|
|
1885
|
+
return {
|
|
1886
|
+
threadId,
|
|
1887
|
+
proposalDecision: {
|
|
1888
|
+
status: "ambiguous",
|
|
1889
|
+
proposalIds
|
|
1890
|
+
},
|
|
1891
|
+
text: saturated ? this.replies.tooMany : this.replies.ambiguous(proposalIds)
|
|
1892
|
+
};
|
|
1893
|
+
}
|
|
1894
|
+
const result = await this.decide(threadId, resolution.proposalId, actor, {
|
|
1895
|
+
decision: resolution.decision,
|
|
1896
|
+
remember: resolution.remember,
|
|
1897
|
+
via: "text"
|
|
1898
|
+
});
|
|
1899
|
+
return this.textReceipt(threadId, result, resolution.decision);
|
|
1900
|
+
}
|
|
1901
|
+
textReceipt(threadId, result, decision) {
|
|
1902
|
+
return {
|
|
1903
|
+
threadId,
|
|
1904
|
+
proposalDecision: result,
|
|
1905
|
+
text: this.reply(result, decision)
|
|
1906
|
+
};
|
|
1907
|
+
}
|
|
1908
|
+
/** The configured reply to a decision the store answered with `result`. */
|
|
1909
|
+
reply(result, decision) {
|
|
1910
|
+
return (0, import_nestjs_agent_core12.textActionProposalReply)(result, decision, this.replies);
|
|
1911
|
+
}
|
|
1912
|
+
};
|
|
1913
|
+
ActionProposalService = _ts_decorate7([
|
|
1914
|
+
(0, import_common7.Injectable)(),
|
|
1915
|
+
_ts_param5(0, (0, import_common7.Inject)(import_nestjs_agent_core12.AGENT_STORE)),
|
|
1916
|
+
_ts_param5(1, (0, import_common7.Inject)(import_nestjs_agent_core12.AGENT_OPTIONS)),
|
|
1917
|
+
_ts_metadata5("design:type", Function),
|
|
1918
|
+
_ts_metadata5("design:paramtypes", [
|
|
1919
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1920
|
+
typeof Pick === "undefined" ? Object : Pick
|
|
1921
|
+
])
|
|
1922
|
+
], ActionProposalService);
|
|
1488
1923
|
|
|
1489
1924
|
// src/queue/chat-queue.service.ts
|
|
1490
|
-
var
|
|
1491
|
-
var
|
|
1925
|
+
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
1926
|
+
var import_common8 = require("@nestjs/common");
|
|
1927
|
+
|
|
1928
|
+
// src/quota-exceeded.ts
|
|
1929
|
+
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
1930
|
+
function publishQuotaBlocked(actor, report, blocked) {
|
|
1931
|
+
const window = report.windows.find((candidate) => candidate.period === blocked.period);
|
|
1932
|
+
const payload = {
|
|
1933
|
+
actorId: actor.id,
|
|
1934
|
+
period: blocked.period,
|
|
1935
|
+
...blocked.reason !== void 0 ? {
|
|
1936
|
+
reason: blocked.reason
|
|
1937
|
+
} : {},
|
|
1938
|
+
...window?.usedTokens !== void 0 ? {
|
|
1939
|
+
usedTokens: window.usedTokens
|
|
1940
|
+
} : {},
|
|
1941
|
+
...window?.limitTokens !== void 0 ? {
|
|
1942
|
+
limitTokens: window.limitTokens
|
|
1943
|
+
} : {},
|
|
1944
|
+
...window !== void 0 ? {
|
|
1945
|
+
usedUsd: window.usedUsd
|
|
1946
|
+
} : {},
|
|
1947
|
+
...window?.limitUsd !== void 0 ? {
|
|
1948
|
+
limitUsd: window.limitUsd
|
|
1949
|
+
} : {}
|
|
1950
|
+
};
|
|
1951
|
+
(0, import_nestjs_agent_core13.publishAgentQuotaExceeded)(payload);
|
|
1952
|
+
}
|
|
1953
|
+
__name(publishQuotaBlocked, "publishQuotaBlocked");
|
|
1492
1954
|
|
|
1493
1955
|
// src/thread-persona.ts
|
|
1494
1956
|
async function threadPersona(store, threadId) {
|
|
@@ -1501,7 +1963,7 @@ async function threadPersona(store, threadId) {
|
|
|
1501
1963
|
__name(threadPersona, "threadPersona");
|
|
1502
1964
|
|
|
1503
1965
|
// src/queue/chat-queue.service.ts
|
|
1504
|
-
function
|
|
1966
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1505
1967
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1506
1968
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1507
1969
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1514,19 +1976,19 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1514
1976
|
}
|
|
1515
1977
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1516
1978
|
}
|
|
1517
|
-
__name(
|
|
1518
|
-
function
|
|
1979
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
1980
|
+
function _ts_metadata6(metadataKey, metadataValue) {
|
|
1519
1981
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1520
1982
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1521
1983
|
}
|
|
1522
1984
|
}
|
|
1523
|
-
__name(
|
|
1524
|
-
function
|
|
1985
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
1986
|
+
function _ts_param6(paramIndex, decorator) {
|
|
1525
1987
|
return function(target, key) {
|
|
1526
1988
|
decorator(target, key, paramIndex);
|
|
1527
1989
|
};
|
|
1528
1990
|
}
|
|
1529
|
-
__name(
|
|
1991
|
+
__name(_ts_param6, "_ts_param");
|
|
1530
1992
|
var MAX_DRAIN_ATTEMPTS = 8;
|
|
1531
1993
|
var ChatQueueService2 = class _ChatQueueService {
|
|
1532
1994
|
static {
|
|
@@ -1538,7 +2000,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1538
2000
|
options;
|
|
1539
2001
|
staging;
|
|
1540
2002
|
deps;
|
|
1541
|
-
logger = new
|
|
2003
|
+
logger = new import_common8.Logger(_ChatQueueService.name);
|
|
1542
2004
|
/**
|
|
1543
2005
|
* Runs this process claimed a thread for and has not handed to a runner yet. A holder in here is
|
|
1544
2006
|
* alive whatever the runner says — it simply has not registered the run yet.
|
|
@@ -1554,12 +2016,12 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1554
2016
|
}
|
|
1555
2017
|
/** Whether the bound store can hold a queue. Without one, a busy thread is not queued. */
|
|
1556
2018
|
get supported() {
|
|
1557
|
-
return (0,
|
|
2019
|
+
return (0, import_nestjs_agent_core14.isChatQueueStore)(this.store);
|
|
1558
2020
|
}
|
|
1559
2021
|
/** The bound store as a queue store, or a 501 naming what is missing. */
|
|
1560
2022
|
queueStore() {
|
|
1561
|
-
if (!(0,
|
|
1562
|
-
throw new
|
|
2023
|
+
if (!(0, import_nestjs_agent_core14.isChatQueueStore)(this.store)) {
|
|
2024
|
+
throw new import_common8.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore (enqueueMessage, listQueue, \u2026, claimActiveStream, releaseActiveStream); the bound store does not.");
|
|
1563
2025
|
}
|
|
1564
2026
|
return this.store;
|
|
1565
2027
|
}
|
|
@@ -1570,7 +2032,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1570
2032
|
store.queuePause(threadId)
|
|
1571
2033
|
]);
|
|
1572
2034
|
return {
|
|
1573
|
-
items: items.map(
|
|
2035
|
+
items: items.map(import_nestjs_agent_core14.queuedMessageView),
|
|
1574
2036
|
paused
|
|
1575
2037
|
};
|
|
1576
2038
|
}
|
|
@@ -1621,7 +2083,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1621
2083
|
* A no-op returning `{}` on a store without a queue.
|
|
1622
2084
|
*/
|
|
1623
2085
|
async plan(args) {
|
|
1624
|
-
if (!(0,
|
|
2086
|
+
if (!(0, import_nestjs_agent_core14.isChatQueueStore)(this.store)) {
|
|
1625
2087
|
return {};
|
|
1626
2088
|
}
|
|
1627
2089
|
const store = this.store;
|
|
@@ -1721,7 +2183,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1721
2183
|
* (its settle drains) or while the queue is paused. Answers the started run's id, if any.
|
|
1722
2184
|
*/
|
|
1723
2185
|
async kick(threadId, runner) {
|
|
1724
|
-
if (!(0,
|
|
2186
|
+
if (!(0, import_nestjs_agent_core14.isChatQueueStore)(this.store)) {
|
|
1725
2187
|
return void 0;
|
|
1726
2188
|
}
|
|
1727
2189
|
const { live, stale } = await this.holder(threadId, runner);
|
|
@@ -1786,6 +2248,9 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1786
2248
|
} : {},
|
|
1787
2249
|
...input.pageContext !== void 0 ? {
|
|
1788
2250
|
pageContext: input.pageContext
|
|
2251
|
+
} : {},
|
|
2252
|
+
...input.uiCapabilities !== void 0 ? {
|
|
2253
|
+
uiCapabilities: input.uiCapabilities
|
|
1789
2254
|
} : {}
|
|
1790
2255
|
});
|
|
1791
2256
|
await store.setQueuePause(threadId, {
|
|
@@ -1822,7 +2287,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1822
2287
|
}
|
|
1823
2288
|
async write(runId, frame) {
|
|
1824
2289
|
const writer = await this.sink.open(runId);
|
|
1825
|
-
await writer.write((0,
|
|
2290
|
+
await writer.write((0, import_nestjs_agent_core14.encodeStreamEvent)(frame));
|
|
1826
2291
|
}
|
|
1827
2292
|
/** Why `actor` may not start a turn now (the quota message), or `null`. */
|
|
1828
2293
|
async quotaBlock(actor) {
|
|
@@ -1830,12 +2295,14 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1830
2295
|
return null;
|
|
1831
2296
|
}
|
|
1832
2297
|
try {
|
|
1833
|
-
const
|
|
2298
|
+
const report = await this.quotaProvider.report({
|
|
1834
2299
|
actor
|
|
1835
2300
|
});
|
|
2301
|
+
const { blocked } = report;
|
|
1836
2302
|
if (blocked === void 0) {
|
|
1837
2303
|
return null;
|
|
1838
2304
|
}
|
|
2305
|
+
publishQuotaBlocked(actor, report, blocked);
|
|
1839
2306
|
return blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`;
|
|
1840
2307
|
} catch {
|
|
1841
2308
|
return null;
|
|
@@ -1866,6 +2333,9 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1866
2333
|
...message.pageContext !== void 0 ? {
|
|
1867
2334
|
pageContext: message.pageContext
|
|
1868
2335
|
} : {},
|
|
2336
|
+
...message.uiCapabilities !== void 0 ? {
|
|
2337
|
+
uiCapabilities: message.uiCapabilities
|
|
2338
|
+
} : {},
|
|
1869
2339
|
...message.model !== void 0 ? {
|
|
1870
2340
|
model: message.model
|
|
1871
2341
|
} : {}
|
|
@@ -1919,20 +2389,20 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1919
2389
|
}));
|
|
1920
2390
|
}
|
|
1921
2391
|
};
|
|
1922
|
-
ChatQueueService2 =
|
|
1923
|
-
(0,
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
2392
|
+
ChatQueueService2 = _ts_decorate8([
|
|
2393
|
+
(0, import_common8.Injectable)(),
|
|
2394
|
+
_ts_param6(0, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_STORE)),
|
|
2395
|
+
_ts_param6(1, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_SINK)),
|
|
2396
|
+
_ts_param6(2, (0, import_common8.Optional)()),
|
|
2397
|
+
_ts_param6(2, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_QUOTA_PROVIDER)),
|
|
2398
|
+
_ts_param6(3, (0, import_common8.Optional)()),
|
|
2399
|
+
_ts_param6(3, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_OPTIONS)),
|
|
2400
|
+
_ts_param6(4, (0, import_common8.Optional)()),
|
|
2401
|
+
_ts_param6(4, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_ATTACHMENT_STAGING)),
|
|
2402
|
+
_ts_param6(5, (0, import_common8.Optional)()),
|
|
2403
|
+
_ts_param6(5, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_DEPS_FACTORY)),
|
|
2404
|
+
_ts_metadata6("design:type", Function),
|
|
2405
|
+
_ts_metadata6("design:paramtypes", [
|
|
1936
2406
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1937
2407
|
typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
|
|
1938
2408
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
@@ -1955,7 +2425,7 @@ function queueFrame(items, paused, started) {
|
|
|
1955
2425
|
return {
|
|
1956
2426
|
kind: "queue",
|
|
1957
2427
|
queue: {
|
|
1958
|
-
items: items.map(
|
|
2428
|
+
items: items.map(import_nestjs_agent_core14.queuedMessageView),
|
|
1959
2429
|
paused
|
|
1960
2430
|
},
|
|
1961
2431
|
...started !== void 0 ? {
|
|
@@ -1966,25 +2436,25 @@ function queueFrame(items, paused, started) {
|
|
|
1966
2436
|
__name(queueFrame, "queueFrame");
|
|
1967
2437
|
|
|
1968
2438
|
// src/run-not-active.exception.ts
|
|
1969
|
-
var
|
|
1970
|
-
var
|
|
1971
|
-
var RunNotActiveException = class extends
|
|
2439
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
2440
|
+
var import_common9 = require("@nestjs/common");
|
|
2441
|
+
var RunNotActiveException = class extends import_common9.ConflictException {
|
|
1972
2442
|
static {
|
|
1973
2443
|
__name(this, "RunNotActiveException");
|
|
1974
2444
|
}
|
|
1975
2445
|
runId;
|
|
1976
|
-
code =
|
|
2446
|
+
code = import_nestjs_agent_core15.RUN_NOT_ACTIVE_CODE;
|
|
1977
2447
|
constructor(runId) {
|
|
1978
2448
|
super({
|
|
1979
2449
|
statusCode: 409,
|
|
1980
|
-
code:
|
|
1981
|
-
message:
|
|
2450
|
+
code: import_nestjs_agent_core15.RUN_NOT_ACTIVE_CODE,
|
|
2451
|
+
message: import_nestjs_agent_core15.RUN_NOT_ACTIVE_MESSAGE
|
|
1982
2452
|
}), this.runId = runId;
|
|
1983
2453
|
}
|
|
1984
2454
|
};
|
|
1985
2455
|
|
|
1986
2456
|
// src/agent.service.ts
|
|
1987
|
-
function
|
|
2457
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
1988
2458
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1989
2459
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1990
2460
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1997,19 +2467,19 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1997
2467
|
}
|
|
1998
2468
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1999
2469
|
}
|
|
2000
|
-
__name(
|
|
2001
|
-
function
|
|
2470
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
2471
|
+
function _ts_metadata7(metadataKey, metadataValue) {
|
|
2002
2472
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2003
2473
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2004
2474
|
}
|
|
2005
2475
|
}
|
|
2006
|
-
__name(
|
|
2007
|
-
function
|
|
2476
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
2477
|
+
function _ts_param7(paramIndex, decorator) {
|
|
2008
2478
|
return function(target, key) {
|
|
2009
2479
|
decorator(target, key, paramIndex);
|
|
2010
2480
|
};
|
|
2011
2481
|
}
|
|
2012
|
-
__name(
|
|
2482
|
+
__name(_ts_param7, "_ts_param");
|
|
2013
2483
|
var AgentService = class {
|
|
2014
2484
|
static {
|
|
2015
2485
|
__name(this, "AgentService");
|
|
@@ -2022,7 +2492,8 @@ var AgentService = class {
|
|
|
2022
2492
|
quotaProvider;
|
|
2023
2493
|
options;
|
|
2024
2494
|
queue;
|
|
2025
|
-
|
|
2495
|
+
proposals;
|
|
2496
|
+
constructor(runner, store, deps, staging, models, quotaProvider, options, queue, proposals) {
|
|
2026
2497
|
this.runner = runner;
|
|
2027
2498
|
this.store = store;
|
|
2028
2499
|
this.deps = deps;
|
|
@@ -2031,6 +2502,28 @@ var AgentService = class {
|
|
|
2031
2502
|
this.quotaProvider = quotaProvider;
|
|
2032
2503
|
this.options = options;
|
|
2033
2504
|
this.queue = queue;
|
|
2505
|
+
this.proposals = proposals;
|
|
2506
|
+
}
|
|
2507
|
+
/**
|
|
2508
|
+
* Decide one independent proposal through the scoped proposal service — what the native
|
|
2509
|
+
* `action-proposals/:id/approve|reject` routes call — and the reply to show for it. `404` when
|
|
2510
|
+
* proposals are not on, `403`/`404` when this actor may not decide it.
|
|
2511
|
+
*/
|
|
2512
|
+
async decideActionProposal(actor, threadId, proposalId, command) {
|
|
2513
|
+
if (this.options?.actionApprovalMode !== "independent" || !this.proposals) {
|
|
2514
|
+
throw new import_common10.NotFoundException("Proposal not found");
|
|
2515
|
+
}
|
|
2516
|
+
const result = await this.proposals.decide(threadId, proposalId, actor, command);
|
|
2517
|
+
return {
|
|
2518
|
+
proposalDecision: result,
|
|
2519
|
+
text: this.proposals.reply(result, command.decision)
|
|
2520
|
+
};
|
|
2521
|
+
}
|
|
2522
|
+
async handleTextDecision(threadId, actor, text) {
|
|
2523
|
+
if (this.options?.actionApprovalMode !== "independent" || !this.proposals) return {
|
|
2524
|
+
status: "unmatched"
|
|
2525
|
+
};
|
|
2526
|
+
return this.proposals.handleTextDecision(threadId, actor, text);
|
|
2034
2527
|
}
|
|
2035
2528
|
/** The queue service when the bound store can hold a queue, else `undefined`. */
|
|
2036
2529
|
queueing() {
|
|
@@ -2040,7 +2533,7 @@ var AgentService = class {
|
|
|
2040
2533
|
requireQueue() {
|
|
2041
2534
|
const queue = this.queueing();
|
|
2042
2535
|
if (queue === void 0) {
|
|
2043
|
-
throw new
|
|
2536
|
+
throw new import_common10.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
|
|
2044
2537
|
}
|
|
2045
2538
|
return queue;
|
|
2046
2539
|
}
|
|
@@ -2073,16 +2566,18 @@ var AgentService = class {
|
|
|
2073
2566
|
if (this.options?.quota === void 0 || this.quotaProvider === void 0) {
|
|
2074
2567
|
return;
|
|
2075
2568
|
}
|
|
2076
|
-
const
|
|
2569
|
+
const report = await this.quotaProvider.report({
|
|
2077
2570
|
actor
|
|
2078
2571
|
});
|
|
2572
|
+
const { blocked } = report;
|
|
2079
2573
|
if (blocked !== void 0) {
|
|
2080
|
-
|
|
2081
|
-
|
|
2574
|
+
publishQuotaBlocked(actor, report, blocked);
|
|
2575
|
+
throw new import_common10.HttpException({
|
|
2576
|
+
statusCode: import_common10.HttpStatus.TOO_MANY_REQUESTS,
|
|
2082
2577
|
code: "quota_exceeded",
|
|
2083
2578
|
period: blocked.period,
|
|
2084
2579
|
message: blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`
|
|
2085
|
-
},
|
|
2580
|
+
}, import_common10.HttpStatus.TOO_MANY_REQUESTS);
|
|
2086
2581
|
}
|
|
2087
2582
|
}
|
|
2088
2583
|
/**
|
|
@@ -2110,17 +2605,17 @@ var AgentService = class {
|
|
|
2110
2605
|
*/
|
|
2111
2606
|
async assertModelAllowed(actor, agent, model) {
|
|
2112
2607
|
if (this.models === void 0) {
|
|
2113
|
-
throw new
|
|
2608
|
+
throw new import_common10.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
|
|
2114
2609
|
}
|
|
2115
|
-
const entry = (0,
|
|
2610
|
+
const entry = (0, import_nestjs_agent_core16.findCatalogModel)(await this.models.list({
|
|
2116
2611
|
actor,
|
|
2117
2612
|
agent
|
|
2118
2613
|
}), model);
|
|
2119
2614
|
if (entry === void 0) {
|
|
2120
|
-
throw new
|
|
2615
|
+
throw new import_common10.BadRequestException(`model "${model}" is not offered`);
|
|
2121
2616
|
}
|
|
2122
2617
|
if (!entry.available) {
|
|
2123
|
-
throw new
|
|
2618
|
+
throw new import_common10.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
|
|
2124
2619
|
}
|
|
2125
2620
|
return entry.id;
|
|
2126
2621
|
}
|
|
@@ -2136,7 +2631,7 @@ var AgentService = class {
|
|
|
2136
2631
|
})).locked : void 0;
|
|
2137
2632
|
if (locked !== void 0) {
|
|
2138
2633
|
if (requested !== void 0 && requested !== locked.model) {
|
|
2139
|
-
throw new
|
|
2634
|
+
throw new import_common10.BadRequestException(`model "${requested}" cannot be selected: ${locked.reason ?? `this agent always uses "${locked.model}"`}`);
|
|
2140
2635
|
}
|
|
2141
2636
|
return locked.model;
|
|
2142
2637
|
}
|
|
@@ -2162,7 +2657,10 @@ var AgentService = class {
|
|
|
2162
2657
|
const result = await this.send({
|
|
2163
2658
|
...params,
|
|
2164
2659
|
mode: "auto"
|
|
2660
|
+
}, {
|
|
2661
|
+
textDecisions: false
|
|
2165
2662
|
});
|
|
2663
|
+
if ("proposalDecision" in result) throw new Error("Unexpected text decision in run-only API");
|
|
2166
2664
|
if (result.queued !== true) {
|
|
2167
2665
|
return result;
|
|
2168
2666
|
}
|
|
@@ -2180,7 +2678,7 @@ var AgentService = class {
|
|
|
2180
2678
|
};
|
|
2181
2679
|
}
|
|
2182
2680
|
await this.requireQueue().publish(result.threadId);
|
|
2183
|
-
throw new
|
|
2681
|
+
throw new import_common10.ConflictException({
|
|
2184
2682
|
statusCode: 409,
|
|
2185
2683
|
code: "run_active",
|
|
2186
2684
|
message: `thread ${result.threadId} already has a turn running`
|
|
@@ -2190,7 +2688,11 @@ var AgentService = class {
|
|
|
2190
2688
|
* Send a message: start a turn, or — when its thread already has one running — queue the message
|
|
2191
2689
|
* to run after it (see {@link ChatSendMode}). What `POST <base>/chat` calls.
|
|
2192
2690
|
*/
|
|
2193
|
-
async send(params) {
|
|
2691
|
+
async send(params, sendOptions = {}) {
|
|
2692
|
+
if (sendOptions.textDecisions !== false && this.options?.actionApprovalMode === "independent" && params.threadId !== void 0 && params.regenerate !== true && this.proposals) {
|
|
2693
|
+
const decision = await this.proposals.handleTextDecision(params.threadId, params.actor, params.message);
|
|
2694
|
+
if ("proposalDecision" in decision) return decision;
|
|
2695
|
+
}
|
|
2194
2696
|
await this.assertWithinQuota(params.actor);
|
|
2195
2697
|
const target = this.deps.resolveAgent(await this.resolveAgentName(params.agentName, params.threadId));
|
|
2196
2698
|
const agentName = target.agentName;
|
|
@@ -2200,7 +2702,7 @@ var AgentService = class {
|
|
|
2200
2702
|
let threadId = params.threadId;
|
|
2201
2703
|
if (threadId === void 0) {
|
|
2202
2704
|
if (params.regenerate === true) {
|
|
2203
|
-
throw new
|
|
2705
|
+
throw new import_common10.BadRequestException("regenerate requires an existing threadId");
|
|
2204
2706
|
}
|
|
2205
2707
|
const created = await this.store.createThread({
|
|
2206
2708
|
actor: params.actor,
|
|
@@ -2239,12 +2741,16 @@ var AgentService = class {
|
|
|
2239
2741
|
...params.pageContext !== void 0 ? {
|
|
2240
2742
|
pageContext: params.pageContext
|
|
2241
2743
|
} : {},
|
|
2744
|
+
...params.uiCapabilities !== void 0 ? {
|
|
2745
|
+
uiCapabilities: params.uiCapabilities
|
|
2746
|
+
} : {},
|
|
2242
2747
|
...model !== void 0 ? {
|
|
2243
2748
|
model
|
|
2244
2749
|
} : {}
|
|
2245
2750
|
};
|
|
2246
2751
|
const queue = this.queueing();
|
|
2247
2752
|
if (queue === void 0) {
|
|
2753
|
+
if (this.options?.actionApprovalMode === "independent") throw new Error("Independent actions require queued thread admission");
|
|
2248
2754
|
const { runId } = await this.runner.start(input);
|
|
2249
2755
|
await this.store.setActiveStream(threadId, runId);
|
|
2250
2756
|
return {
|
|
@@ -2255,7 +2761,7 @@ var AgentService = class {
|
|
|
2255
2761
|
const mode = params.mode ?? "auto";
|
|
2256
2762
|
const { live, stale } = await queue.holder(threadId, this.runner);
|
|
2257
2763
|
if (stale !== null) {
|
|
2258
|
-
await (0,
|
|
2764
|
+
await (0, import_nestjs_agent_core16.settleDeadRun)(this.store, {
|
|
2259
2765
|
runId: stale
|
|
2260
2766
|
});
|
|
2261
2767
|
}
|
|
@@ -2271,7 +2777,7 @@ var AgentService = class {
|
|
|
2271
2777
|
}
|
|
2272
2778
|
}
|
|
2273
2779
|
if (params.regenerate === true) {
|
|
2274
|
-
throw new
|
|
2780
|
+
throw new import_common10.ConflictException({
|
|
2275
2781
|
statusCode: 409,
|
|
2276
2782
|
code: "run_active",
|
|
2277
2783
|
message: "cannot regenerate while a turn is running on this thread"
|
|
@@ -2325,6 +2831,9 @@ var AgentService = class {
|
|
|
2325
2831
|
...input.pageContext !== void 0 ? {
|
|
2326
2832
|
pageContext: input.pageContext
|
|
2327
2833
|
} : {},
|
|
2834
|
+
...input.uiCapabilities !== void 0 ? {
|
|
2835
|
+
uiCapabilities: input.uiCapabilities
|
|
2836
|
+
} : {},
|
|
2328
2837
|
...interrupting !== void 0 ? {
|
|
2329
2838
|
interrupt: true,
|
|
2330
2839
|
at: "head"
|
|
@@ -2371,7 +2880,7 @@ var AgentService = class {
|
|
|
2371
2880
|
const store = queue.queueStore();
|
|
2372
2881
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
2373
2882
|
if (patch.message !== void 0 && patch.message.trim().length === 0) {
|
|
2374
|
-
throw new
|
|
2883
|
+
throw new import_common10.BadRequestException("message must not be empty");
|
|
2375
2884
|
}
|
|
2376
2885
|
const attachments = patch.attachments === void 0 || patch.attachments === null ? patch.attachments : await this.resolveAttachments(actor, patch.attachments);
|
|
2377
2886
|
if (patch.message !== void 0 || attachments !== void 0) {
|
|
@@ -2384,15 +2893,15 @@ var AgentService = class {
|
|
|
2384
2893
|
} : {}
|
|
2385
2894
|
});
|
|
2386
2895
|
if (updated === null) {
|
|
2387
|
-
throw new
|
|
2896
|
+
throw new import_common10.GoneException(`queued message ${messageId} already started or was removed`);
|
|
2388
2897
|
}
|
|
2389
2898
|
}
|
|
2390
2899
|
if (patch.position !== void 0) {
|
|
2391
2900
|
if (!Number.isInteger(patch.position) || patch.position < 0) {
|
|
2392
|
-
throw new
|
|
2901
|
+
throw new import_common10.BadRequestException("position must be a non-negative integer");
|
|
2393
2902
|
}
|
|
2394
2903
|
if (!await store.moveQueuedMessage(messageId, patch.position)) {
|
|
2395
|
-
throw new
|
|
2904
|
+
throw new import_common10.GoneException(`queued message ${messageId} already started or was removed`);
|
|
2396
2905
|
}
|
|
2397
2906
|
}
|
|
2398
2907
|
return queue.publish(threadId);
|
|
@@ -2402,7 +2911,7 @@ var AgentService = class {
|
|
|
2402
2911
|
const queue = this.requireQueue();
|
|
2403
2912
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
2404
2913
|
if (!await queue.queueStore().removeQueuedMessage(messageId)) {
|
|
2405
|
-
throw new
|
|
2914
|
+
throw new import_common10.GoneException(`queued message ${messageId} already started or was removed`);
|
|
2406
2915
|
}
|
|
2407
2916
|
return queue.publish(threadId);
|
|
2408
2917
|
}
|
|
@@ -2421,7 +2930,7 @@ var AgentService = class {
|
|
|
2421
2930
|
const queue = this.requireQueue();
|
|
2422
2931
|
const store = queue.queueStore();
|
|
2423
2932
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
2424
|
-
const gone = /* @__PURE__ */ __name(() => new
|
|
2933
|
+
const gone = /* @__PURE__ */ __name(() => new import_common10.GoneException(`queued message ${messageId} already started or was removed`), "gone");
|
|
2425
2934
|
const marked = await store.updateQueuedMessage(messageId, {
|
|
2426
2935
|
interrupt: true
|
|
2427
2936
|
});
|
|
@@ -2429,7 +2938,7 @@ var AgentService = class {
|
|
|
2429
2938
|
throw gone();
|
|
2430
2939
|
}
|
|
2431
2940
|
if (marked.interrupt !== true) {
|
|
2432
|
-
throw new
|
|
2941
|
+
throw new import_common10.NotImplementedException("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
|
|
2433
2942
|
}
|
|
2434
2943
|
if (!await store.moveQueuedMessage(messageId, 0)) {
|
|
2435
2944
|
throw gone();
|
|
@@ -2488,7 +2997,7 @@ var AgentService = class {
|
|
|
2488
2997
|
async assertOwnsQueuedMessage(actor, messageId) {
|
|
2489
2998
|
const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
|
|
2490
2999
|
if (message === null) {
|
|
2491
|
-
throw new
|
|
3000
|
+
throw new import_common10.NotFoundException(`queued message ${messageId} not found`);
|
|
2492
3001
|
}
|
|
2493
3002
|
await this.assertOwnsThread(actor, message.threadId);
|
|
2494
3003
|
return message.threadId;
|
|
@@ -2509,7 +3018,7 @@ var AgentService = class {
|
|
|
2509
3018
|
}
|
|
2510
3019
|
const staging = this.staging;
|
|
2511
3020
|
if (staging === void 0 || typeof staging.resolve !== "function") {
|
|
2512
|
-
throw new
|
|
3021
|
+
throw new import_common10.NotImplementedException("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
|
|
2513
3022
|
}
|
|
2514
3023
|
const resolved = [];
|
|
2515
3024
|
for (const ref of refs) {
|
|
@@ -2518,7 +3027,7 @@ var AgentService = class {
|
|
|
2518
3027
|
actor
|
|
2519
3028
|
});
|
|
2520
3029
|
if (attachment === null) {
|
|
2521
|
-
throw new
|
|
3030
|
+
throw new import_common10.ForbiddenException(`attachment ${ref.mediaId} is not available to this actor`);
|
|
2522
3031
|
}
|
|
2523
3032
|
resolved.push(attachment);
|
|
2524
3033
|
}
|
|
@@ -2620,6 +3129,7 @@ var AgentService = class {
|
|
|
2620
3129
|
* not the thread's own actor).
|
|
2621
3130
|
*/
|
|
2622
3131
|
async signalToolCall(toolCallId2, reply) {
|
|
3132
|
+
if ((await this.store.toolCallApproval?.(toolCallId2))?.status === "proposed") throw new import_common10.ConflictException("Independent proposals require the scoped proposal decision route");
|
|
2623
3133
|
await this.assertNotExpired(toolCallId2);
|
|
2624
3134
|
const runId = await this.resolveRunForToolCall(toolCallId2);
|
|
2625
3135
|
await this.assertRunWaiting(runId);
|
|
@@ -2640,7 +3150,7 @@ var AgentService = class {
|
|
|
2640
3150
|
if (active) {
|
|
2641
3151
|
return;
|
|
2642
3152
|
}
|
|
2643
|
-
await (0,
|
|
3153
|
+
await (0, import_nestjs_agent_core16.settleDeadRun)(this.store, {
|
|
2644
3154
|
runId
|
|
2645
3155
|
});
|
|
2646
3156
|
throw new RunNotActiveException(runId);
|
|
@@ -2660,7 +3170,7 @@ var AgentService = class {
|
|
|
2660
3170
|
throw new RunNotActiveException(runId);
|
|
2661
3171
|
}
|
|
2662
3172
|
if (owner !== actor.id) {
|
|
2663
|
-
throw new
|
|
3173
|
+
throw new import_common10.ForbiddenException("run belongs to another actor");
|
|
2664
3174
|
}
|
|
2665
3175
|
}
|
|
2666
3176
|
/**
|
|
@@ -2720,7 +3230,7 @@ var AgentService = class {
|
|
|
2720
3230
|
return;
|
|
2721
3231
|
}
|
|
2722
3232
|
if (this.store.updateThread === void 0) {
|
|
2723
|
-
throw new
|
|
3233
|
+
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
3234
|
}
|
|
2725
3235
|
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
3236
|
if (patch.persona !== void 0 && patch.persona !== null) {
|
|
@@ -2774,10 +3284,10 @@ var AgentService = class {
|
|
|
2774
3284
|
validateTitle(title) {
|
|
2775
3285
|
const trimmed = title.trim();
|
|
2776
3286
|
if (trimmed.length === 0) {
|
|
2777
|
-
throw new
|
|
3287
|
+
throw new import_common10.BadRequestException("title must not be empty");
|
|
2778
3288
|
}
|
|
2779
3289
|
if (trimmed.length > 200) {
|
|
2780
|
-
throw new
|
|
3290
|
+
throw new import_common10.BadRequestException("title must be at most 200 characters");
|
|
2781
3291
|
}
|
|
2782
3292
|
return trimmed;
|
|
2783
3293
|
}
|
|
@@ -2881,21 +3391,21 @@ var AgentService = class {
|
|
|
2881
3391
|
*/
|
|
2882
3392
|
async setMessageFeedback(actor, messageId, input) {
|
|
2883
3393
|
if (input.value !== null && input.value !== "up" && input.value !== "down") {
|
|
2884
|
-
throw new
|
|
3394
|
+
throw new import_common10.BadRequestException("value must be 'up', 'down' or null");
|
|
2885
3395
|
}
|
|
2886
3396
|
if (input.comment !== void 0 && typeof input.comment !== "string") {
|
|
2887
|
-
throw new
|
|
3397
|
+
throw new import_common10.BadRequestException("comment must be a string");
|
|
2888
3398
|
}
|
|
2889
3399
|
const comment = input.comment?.trim();
|
|
2890
3400
|
if (comment !== void 0 && comment.length > 2e3) {
|
|
2891
|
-
throw new
|
|
3401
|
+
throw new import_common10.BadRequestException("comment must be at most 2000 characters");
|
|
2892
3402
|
}
|
|
2893
3403
|
if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
|
|
2894
|
-
throw new
|
|
3404
|
+
throw new import_common10.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
|
|
2895
3405
|
}
|
|
2896
3406
|
const threadId = await this.store.threadOfMessage(messageId);
|
|
2897
3407
|
if (threadId === null) {
|
|
2898
|
-
throw new
|
|
3408
|
+
throw new import_common10.NotFoundException(`message ${messageId} not found`);
|
|
2899
3409
|
}
|
|
2900
3410
|
await this.assertOwnsThread(actor, threadId);
|
|
2901
3411
|
const feedback = input.value === null ? null : {
|
|
@@ -2943,7 +3453,7 @@ var AgentService = class {
|
|
|
2943
3453
|
const list = this.attachmentInventory();
|
|
2944
3454
|
const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
|
|
2945
3455
|
if (referencedMediaIds === void 0) {
|
|
2946
|
-
throw new
|
|
3456
|
+
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
3457
|
}
|
|
2948
3458
|
const stagedBefore = options.olderThan.toISOString();
|
|
2949
3459
|
const inventory = await list({
|
|
@@ -2965,7 +3475,7 @@ var AgentService = class {
|
|
|
2965
3475
|
attachmentInventory() {
|
|
2966
3476
|
const list = this.staging?.list?.bind(this.staging);
|
|
2967
3477
|
if (list === void 0) {
|
|
2968
|
-
throw new
|
|
3478
|
+
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
3479
|
}
|
|
2970
3480
|
return list;
|
|
2971
3481
|
}
|
|
@@ -2976,10 +3486,10 @@ var AgentService = class {
|
|
|
2976
3486
|
async assertOwnsThread(actor, threadId) {
|
|
2977
3487
|
const owner = await this.store.ownerOfThread(threadId);
|
|
2978
3488
|
if (owner === null) {
|
|
2979
|
-
throw new
|
|
3489
|
+
throw new import_common10.NotFoundException(`thread ${threadId} not found`);
|
|
2980
3490
|
}
|
|
2981
3491
|
if (owner !== actor.id) {
|
|
2982
|
-
throw new
|
|
3492
|
+
throw new import_common10.ForbiddenException("thread belongs to another actor");
|
|
2983
3493
|
}
|
|
2984
3494
|
}
|
|
2985
3495
|
/**
|
|
@@ -2990,10 +3500,10 @@ var AgentService = class {
|
|
|
2990
3500
|
async assertOwnsToolCall(actor, toolCallId2) {
|
|
2991
3501
|
const owner = await this.store.ownerOfToolCall(toolCallId2);
|
|
2992
3502
|
if (owner === null) {
|
|
2993
|
-
throw new
|
|
3503
|
+
throw new import_common10.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
2994
3504
|
}
|
|
2995
3505
|
if (owner !== actor.id) {
|
|
2996
|
-
throw new
|
|
3506
|
+
throw new import_common10.ForbiddenException("tool call belongs to another actor");
|
|
2997
3507
|
}
|
|
2998
3508
|
}
|
|
2999
3509
|
/**
|
|
@@ -3008,12 +3518,12 @@ var AgentService = class {
|
|
|
3008
3518
|
if (this.store.toolCallInput === void 0) {
|
|
3009
3519
|
return;
|
|
3010
3520
|
}
|
|
3011
|
-
const questions = (0,
|
|
3521
|
+
const questions = (0, import_nestjs_agent_core16.readElicitationQuestions)(await this.store.toolCallInput(toolCallId2));
|
|
3012
3522
|
for (const question of questions) {
|
|
3013
3523
|
const submitted = Object.hasOwn(answers2, question.id) ? answers2[question.id] : void 0;
|
|
3014
|
-
const problem = (0,
|
|
3524
|
+
const problem = (0, import_nestjs_agent_core16.validateElicitationAnswer)(question, submitted ?? question.defaults ?? []);
|
|
3015
3525
|
if (problem !== null) {
|
|
3016
|
-
throw new
|
|
3526
|
+
throw new import_common10.BadRequestException(`answers["${question.id}"] ${problem}`);
|
|
3017
3527
|
}
|
|
3018
3528
|
}
|
|
3019
3529
|
}
|
|
@@ -3025,21 +3535,21 @@ var AgentService = class {
|
|
|
3025
3535
|
*/
|
|
3026
3536
|
async assertMayDecide(actor, toolCallId2) {
|
|
3027
3537
|
const approval = await this.store.toolCallApproval?.(toolCallId2);
|
|
3028
|
-
const approver = approval?.approver ??
|
|
3029
|
-
if (approver ===
|
|
3538
|
+
const approver = approval?.approver ?? import_nestjs_agent_core16.REQUESTER_APPROVER;
|
|
3539
|
+
if (approver === import_nestjs_agent_core16.REQUESTER_APPROVER) {
|
|
3030
3540
|
return this.assertOwnsToolCall(actor, toolCallId2);
|
|
3031
3541
|
}
|
|
3032
3542
|
const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
|
|
3033
3543
|
if (requesterRef === null) {
|
|
3034
|
-
throw new
|
|
3544
|
+
throw new import_common10.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
3035
3545
|
}
|
|
3036
|
-
const allowed = await (0,
|
|
3546
|
+
const allowed = await (0, import_nestjs_agent_core16.mayDecideApproval)(this.deps.forAgent().approvalPolicy, actor, {
|
|
3037
3547
|
toolCallId: toolCallId2,
|
|
3038
3548
|
approver,
|
|
3039
3549
|
requesterRef
|
|
3040
3550
|
});
|
|
3041
3551
|
if (!allowed) {
|
|
3042
|
-
throw new
|
|
3552
|
+
throw new import_common10.ForbiddenException(`this approval is for ${approver}`);
|
|
3043
3553
|
}
|
|
3044
3554
|
}
|
|
3045
3555
|
/**
|
|
@@ -3055,7 +3565,7 @@ var AgentService = class {
|
|
|
3055
3565
|
}
|
|
3056
3566
|
const lapsed = approval.status === "expired" || approval.status === "pending_approval" && approval.expiresAt !== null && Date.parse(approval.expiresAt) <= Date.now();
|
|
3057
3567
|
if (lapsed) {
|
|
3058
|
-
throw new
|
|
3568
|
+
throw new import_common10.GoneException(`the approval request for tool call ${toolCallId2} has expired`);
|
|
3059
3569
|
}
|
|
3060
3570
|
}
|
|
3061
3571
|
/**
|
|
@@ -3068,7 +3578,7 @@ var AgentService = class {
|
|
|
3068
3578
|
async resolveRunForToolCall(toolCallId2) {
|
|
3069
3579
|
const runId = await this.store.runForToolCall(toolCallId2);
|
|
3070
3580
|
if (runId === null) {
|
|
3071
|
-
throw new
|
|
3581
|
+
throw new import_common10.NotFoundException(`tool call ${toolCallId2} has no active run to signal`);
|
|
3072
3582
|
}
|
|
3073
3583
|
return runId;
|
|
3074
3584
|
}
|
|
@@ -3076,29 +3586,30 @@ var AgentService = class {
|
|
|
3076
3586
|
async assertOwnsActiveStream(actor, runId) {
|
|
3077
3587
|
const owner = await this.store.ownerOfActiveStream(runId);
|
|
3078
3588
|
if (owner === null) {
|
|
3079
|
-
throw new
|
|
3589
|
+
throw new import_common10.NotFoundException(`no active run ${runId}`);
|
|
3080
3590
|
}
|
|
3081
3591
|
if (owner !== actor.id) {
|
|
3082
|
-
throw new
|
|
3592
|
+
throw new import_common10.ForbiddenException("run belongs to another actor");
|
|
3083
3593
|
}
|
|
3084
3594
|
}
|
|
3085
3595
|
};
|
|
3086
|
-
AgentService =
|
|
3087
|
-
(0,
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3596
|
+
AgentService = _ts_decorate9([
|
|
3597
|
+
(0, import_common10.Injectable)(),
|
|
3598
|
+
_ts_param7(0, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_RUNNER)),
|
|
3599
|
+
_ts_param7(1, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_STORE)),
|
|
3600
|
+
_ts_param7(2, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_DEPS_FACTORY)),
|
|
3601
|
+
_ts_param7(3, (0, import_common10.Optional)()),
|
|
3602
|
+
_ts_param7(3, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_ATTACHMENT_STAGING)),
|
|
3603
|
+
_ts_param7(4, (0, import_common10.Optional)()),
|
|
3604
|
+
_ts_param7(4, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_MODEL_CATALOG)),
|
|
3605
|
+
_ts_param7(5, (0, import_common10.Optional)()),
|
|
3606
|
+
_ts_param7(5, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_QUOTA_PROVIDER)),
|
|
3607
|
+
_ts_param7(6, (0, import_common10.Optional)()),
|
|
3608
|
+
_ts_param7(6, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_OPTIONS)),
|
|
3609
|
+
_ts_param7(7, (0, import_common10.Optional)()),
|
|
3610
|
+
_ts_param7(8, (0, import_common10.Optional)()),
|
|
3611
|
+
_ts_metadata7("design:type", Function),
|
|
3612
|
+
_ts_metadata7("design:paramtypes", [
|
|
3102
3613
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
3103
3614
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
3104
3615
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
@@ -3106,13 +3617,14 @@ AgentService = _ts_decorate7([
|
|
|
3106
3617
|
typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
|
|
3107
3618
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
3108
3619
|
typeof Pick === "undefined" ? Object : Pick,
|
|
3109
|
-
typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2
|
|
3620
|
+
typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2,
|
|
3621
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService
|
|
3110
3622
|
])
|
|
3111
3623
|
], AgentService);
|
|
3112
3624
|
|
|
3113
3625
|
// src/approval-port.adapter.ts
|
|
3114
|
-
var
|
|
3115
|
-
function
|
|
3626
|
+
var import_common11 = require("@nestjs/common");
|
|
3627
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
3116
3628
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3117
3629
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3118
3630
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3125,20 +3637,48 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
3125
3637
|
}
|
|
3126
3638
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3127
3639
|
}
|
|
3128
|
-
__name(
|
|
3129
|
-
function
|
|
3640
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
3641
|
+
function _ts_metadata8(metadataKey, metadataValue) {
|
|
3130
3642
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3131
3643
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3132
3644
|
}
|
|
3133
3645
|
}
|
|
3134
|
-
__name(
|
|
3646
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
3647
|
+
function _ts_param8(paramIndex, decorator) {
|
|
3648
|
+
return function(target, key) {
|
|
3649
|
+
decorator(target, key, paramIndex);
|
|
3650
|
+
};
|
|
3651
|
+
}
|
|
3652
|
+
__name(_ts_param8, "_ts_param");
|
|
3135
3653
|
var AgentApprovalPortAdapter = class {
|
|
3136
3654
|
static {
|
|
3137
3655
|
__name(this, "AgentApprovalPortAdapter");
|
|
3138
3656
|
}
|
|
3139
3657
|
agent;
|
|
3140
|
-
|
|
3658
|
+
proposals;
|
|
3659
|
+
constructor(agent, proposals) {
|
|
3141
3660
|
this.agent = agent;
|
|
3661
|
+
this.proposals = proposals;
|
|
3662
|
+
}
|
|
3663
|
+
async approveActionProposal(actor, target, opts) {
|
|
3664
|
+
if (!this.proposals) throw new import_common11.NotImplementedException("Action proposals unavailable");
|
|
3665
|
+
return this.proposals.decide(target.threadId, target.proposalId, actor, {
|
|
3666
|
+
decision: "approved",
|
|
3667
|
+
...opts?.remember !== void 0 ? {
|
|
3668
|
+
remember: opts.remember
|
|
3669
|
+
} : {},
|
|
3670
|
+
via: opts?.decidedVia ?? "console"
|
|
3671
|
+
});
|
|
3672
|
+
}
|
|
3673
|
+
async rejectActionProposal(actor, target, opts) {
|
|
3674
|
+
if (!this.proposals) throw new import_common11.NotImplementedException("Action proposals unavailable");
|
|
3675
|
+
return this.proposals.decide(target.threadId, target.proposalId, actor, {
|
|
3676
|
+
decision: "rejected",
|
|
3677
|
+
...opts?.reason !== void 0 ? {
|
|
3678
|
+
reason: opts.reason
|
|
3679
|
+
} : {},
|
|
3680
|
+
via: opts?.decidedVia ?? "console"
|
|
3681
|
+
});
|
|
3142
3682
|
}
|
|
3143
3683
|
async approve(toolCallId2, opts) {
|
|
3144
3684
|
await this.agent.signalToolCall(toolCallId2, {
|
|
@@ -3169,18 +3709,20 @@ var AgentApprovalPortAdapter = class {
|
|
|
3169
3709
|
});
|
|
3170
3710
|
}
|
|
3171
3711
|
};
|
|
3172
|
-
AgentApprovalPortAdapter =
|
|
3173
|
-
(0,
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3712
|
+
AgentApprovalPortAdapter = _ts_decorate10([
|
|
3713
|
+
(0, import_common11.Injectable)(),
|
|
3714
|
+
_ts_param8(1, (0, import_common11.Optional)()),
|
|
3715
|
+
_ts_metadata8("design:type", Function),
|
|
3716
|
+
_ts_metadata8("design:paramtypes", [
|
|
3717
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3718
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService
|
|
3177
3719
|
])
|
|
3178
3720
|
], AgentApprovalPortAdapter);
|
|
3179
3721
|
|
|
3180
3722
|
// src/controller/agents.controller.ts
|
|
3181
|
-
var
|
|
3182
|
-
var
|
|
3183
|
-
function
|
|
3723
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
3724
|
+
var import_common12 = require("@nestjs/common");
|
|
3725
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
3184
3726
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3185
3727
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3186
3728
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3193,19 +3735,19 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
3193
3735
|
}
|
|
3194
3736
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3195
3737
|
}
|
|
3196
|
-
__name(
|
|
3197
|
-
function
|
|
3738
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
3739
|
+
function _ts_metadata9(metadataKey, metadataValue) {
|
|
3198
3740
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3199
3741
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3200
3742
|
}
|
|
3201
3743
|
}
|
|
3202
|
-
__name(
|
|
3203
|
-
function
|
|
3744
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
3745
|
+
function _ts_param9(paramIndex, decorator) {
|
|
3204
3746
|
return function(target, key) {
|
|
3205
3747
|
decorator(target, key, paramIndex);
|
|
3206
3748
|
};
|
|
3207
3749
|
}
|
|
3208
|
-
__name(
|
|
3750
|
+
__name(_ts_param9, "_ts_param");
|
|
3209
3751
|
var AgentsController = class {
|
|
3210
3752
|
static {
|
|
3211
3753
|
__name(this, "AgentsController");
|
|
@@ -3236,26 +3778,26 @@ var AgentsController = class {
|
|
|
3236
3778
|
});
|
|
3237
3779
|
}
|
|
3238
3780
|
};
|
|
3239
|
-
|
|
3240
|
-
(0,
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3781
|
+
_ts_decorate11([
|
|
3782
|
+
(0, import_common12.Get)(),
|
|
3783
|
+
_ts_metadata9("design:type", Function),
|
|
3784
|
+
_ts_metadata9("design:paramtypes", []),
|
|
3785
|
+
_ts_metadata9("design:returntype", Array)
|
|
3244
3786
|
], AgentsController.prototype, "list", null);
|
|
3245
|
-
AgentsController =
|
|
3246
|
-
(0,
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
typeof
|
|
3787
|
+
AgentsController = _ts_decorate11([
|
|
3788
|
+
(0, import_common12.Controller)("agents"),
|
|
3789
|
+
_ts_param9(0, (0, import_common12.Inject)(import_nestjs_agent_core17.AGENT_REGISTRY)),
|
|
3790
|
+
_ts_param9(1, (0, import_common12.Inject)(import_nestjs_agent_core17.AGENT_DEPS_FACTORY)),
|
|
3791
|
+
_ts_metadata9("design:type", Function),
|
|
3792
|
+
_ts_metadata9("design:paramtypes", [
|
|
3793
|
+
typeof import_nestjs_agent_core17.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core17.AgentRegistry,
|
|
3252
3794
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
3253
3795
|
])
|
|
3254
3796
|
], AgentsController);
|
|
3255
3797
|
|
|
3256
3798
|
// src/controller/attachments.controller.ts
|
|
3257
|
-
var
|
|
3258
|
-
var
|
|
3799
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
3800
|
+
var import_common13 = require("@nestjs/common");
|
|
3259
3801
|
var import_platform_express = require("@nestjs/platform-express");
|
|
3260
3802
|
|
|
3261
3803
|
// src/attachment-limits.ts
|
|
@@ -3284,7 +3826,7 @@ function attachmentLimits(options, staging) {
|
|
|
3284
3826
|
__name(attachmentLimits, "attachmentLimits");
|
|
3285
3827
|
|
|
3286
3828
|
// src/controller/attachments.controller.ts
|
|
3287
|
-
function
|
|
3829
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
3288
3830
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3289
3831
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3290
3832
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3297,19 +3839,19 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
3297
3839
|
}
|
|
3298
3840
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3299
3841
|
}
|
|
3300
|
-
__name(
|
|
3301
|
-
function
|
|
3842
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
3843
|
+
function _ts_metadata10(metadataKey, metadataValue) {
|
|
3302
3844
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3303
3845
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3304
3846
|
}
|
|
3305
3847
|
}
|
|
3306
|
-
__name(
|
|
3307
|
-
function
|
|
3848
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
3849
|
+
function _ts_param10(paramIndex, decorator) {
|
|
3308
3850
|
return function(target, key) {
|
|
3309
3851
|
decorator(target, key, paramIndex);
|
|
3310
3852
|
};
|
|
3311
3853
|
}
|
|
3312
|
-
__name(
|
|
3854
|
+
__name(_ts_param10, "_ts_param");
|
|
3313
3855
|
var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
3314
3856
|
var ATTACHMENT_PAGE_SIZE = 50;
|
|
3315
3857
|
var AttachmentsController = class {
|
|
@@ -3343,17 +3885,17 @@ var AttachmentsController = class {
|
|
|
3343
3885
|
}
|
|
3344
3886
|
async upload(req, file) {
|
|
3345
3887
|
if (this.staging === void 0) {
|
|
3346
|
-
throw new
|
|
3888
|
+
throw new import_common13.NotImplementedException("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
|
|
3347
3889
|
}
|
|
3348
3890
|
if (file === void 0) {
|
|
3349
|
-
throw new
|
|
3891
|
+
throw new import_common13.BadRequestException('multipart field "file" is required');
|
|
3350
3892
|
}
|
|
3351
3893
|
const { allowedContentTypes, maxBytes } = attachmentLimits(this.options, this.staging);
|
|
3352
3894
|
if (!allowedContentTypes.includes(file.mimetype)) {
|
|
3353
|
-
throw new
|
|
3895
|
+
throw new import_common13.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
|
|
3354
3896
|
}
|
|
3355
3897
|
if (file.size > maxBytes) {
|
|
3356
|
-
throw new
|
|
3898
|
+
throw new import_common13.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
|
|
3357
3899
|
}
|
|
3358
3900
|
const actor = await this.actorResolver.resolve(req);
|
|
3359
3901
|
return this.staging.stage({
|
|
@@ -3365,39 +3907,39 @@ var AttachmentsController = class {
|
|
|
3365
3907
|
});
|
|
3366
3908
|
}
|
|
3367
3909
|
};
|
|
3368
|
-
|
|
3369
|
-
(0,
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3910
|
+
_ts_decorate12([
|
|
3911
|
+
(0, import_common13.Get)(),
|
|
3912
|
+
_ts_param10(0, (0, import_common13.Req)()),
|
|
3913
|
+
_ts_metadata10("design:type", Function),
|
|
3914
|
+
_ts_metadata10("design:paramtypes", [
|
|
3373
3915
|
typeof Request === "undefined" ? Object : Request
|
|
3374
3916
|
]),
|
|
3375
|
-
|
|
3917
|
+
_ts_metadata10("design:returntype", Promise)
|
|
3376
3918
|
], AttachmentsController.prototype, "list", null);
|
|
3377
|
-
|
|
3378
|
-
(0,
|
|
3379
|
-
(0,
|
|
3919
|
+
_ts_decorate12([
|
|
3920
|
+
(0, import_common13.Post)(),
|
|
3921
|
+
(0, import_common13.UseInterceptors)((0, import_platform_express.FileInterceptor)("file", {
|
|
3380
3922
|
limits: {
|
|
3381
3923
|
fileSize: HARD_MAX_ATTACHMENT_BYTES
|
|
3382
3924
|
}
|
|
3383
3925
|
})),
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3926
|
+
_ts_param10(0, (0, import_common13.Req)()),
|
|
3927
|
+
_ts_param10(1, (0, import_common13.UploadedFile)()),
|
|
3928
|
+
_ts_metadata10("design:type", Function),
|
|
3929
|
+
_ts_metadata10("design:paramtypes", [
|
|
3388
3930
|
typeof Request === "undefined" ? Object : Request,
|
|
3389
3931
|
Object
|
|
3390
3932
|
]),
|
|
3391
|
-
|
|
3933
|
+
_ts_metadata10("design:returntype", Promise)
|
|
3392
3934
|
], AttachmentsController.prototype, "upload", null);
|
|
3393
|
-
AttachmentsController =
|
|
3394
|
-
(0,
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3935
|
+
AttachmentsController = _ts_decorate12([
|
|
3936
|
+
(0, import_common13.Controller)("attachments"),
|
|
3937
|
+
_ts_param10(0, (0, import_common13.Inject)(import_nestjs_agent_core18.AGENT_OPTIONS)),
|
|
3938
|
+
_ts_param10(1, (0, import_common13.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
|
|
3939
|
+
_ts_param10(3, (0, import_common13.Optional)()),
|
|
3940
|
+
_ts_param10(3, (0, import_common13.Inject)(import_nestjs_agent_core18.AGENT_ATTACHMENT_STAGING)),
|
|
3941
|
+
_ts_metadata10("design:type", Function),
|
|
3942
|
+
_ts_metadata10("design:paramtypes", [
|
|
3401
3943
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
3402
3944
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3403
3945
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -3406,9 +3948,10 @@ AttachmentsController = _ts_decorate10([
|
|
|
3406
3948
|
], AttachmentsController);
|
|
3407
3949
|
|
|
3408
3950
|
// src/controller/chat.controller.ts
|
|
3409
|
-
var
|
|
3410
|
-
var
|
|
3411
|
-
|
|
3951
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
3952
|
+
var import_genui2 = require("@dudousxd/nestjs-agent-core/genui");
|
|
3953
|
+
var import_common14 = require("@nestjs/common");
|
|
3954
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
3412
3955
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3413
3956
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3414
3957
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3421,19 +3964,19 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
3421
3964
|
}
|
|
3422
3965
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3423
3966
|
}
|
|
3424
|
-
__name(
|
|
3425
|
-
function
|
|
3967
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
3968
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
3426
3969
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3427
3970
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3428
3971
|
}
|
|
3429
3972
|
}
|
|
3430
|
-
__name(
|
|
3431
|
-
function
|
|
3973
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
3974
|
+
function _ts_param11(paramIndex, decorator) {
|
|
3432
3975
|
return function(target, key) {
|
|
3433
3976
|
decorator(target, key, paramIndex);
|
|
3434
3977
|
};
|
|
3435
3978
|
}
|
|
3436
|
-
__name(
|
|
3979
|
+
__name(_ts_param11, "_ts_param");
|
|
3437
3980
|
function sendMode(body) {
|
|
3438
3981
|
if (body.interrupt === true) {
|
|
3439
3982
|
return "interrupt";
|
|
@@ -3444,7 +3987,7 @@ function sendMode(body) {
|
|
|
3444
3987
|
if (body.mode === "auto" || body.mode === "queue" || body.mode === "interrupt") {
|
|
3445
3988
|
return body.mode;
|
|
3446
3989
|
}
|
|
3447
|
-
throw new
|
|
3990
|
+
throw new import_common14.BadRequestException("mode must be 'auto', 'queue' or 'interrupt'");
|
|
3448
3991
|
}
|
|
3449
3992
|
__name(sendMode, "sendMode");
|
|
3450
3993
|
function attachmentRefs(claimed) {
|
|
@@ -3452,21 +3995,21 @@ function attachmentRefs(claimed) {
|
|
|
3452
3995
|
return [];
|
|
3453
3996
|
}
|
|
3454
3997
|
if (!Array.isArray(claimed)) {
|
|
3455
|
-
throw new
|
|
3998
|
+
throw new import_common14.BadRequestException("attachments must be an array of { mediaId }");
|
|
3456
3999
|
}
|
|
3457
4000
|
if (claimed.length > MAX_ATTACHMENTS_PER_MESSAGE) {
|
|
3458
|
-
throw new
|
|
4001
|
+
throw new import_common14.BadRequestException(`a message may carry at most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments`);
|
|
3459
4002
|
}
|
|
3460
4003
|
return claimed.map((entry) => {
|
|
3461
4004
|
if (typeof entry !== "object" || entry === null || !("mediaId" in entry)) {
|
|
3462
|
-
throw new
|
|
4005
|
+
throw new import_common14.BadRequestException("each attachment must be an object with a mediaId");
|
|
3463
4006
|
}
|
|
3464
4007
|
if (Object.keys(entry).some((key) => key !== "mediaId")) {
|
|
3465
|
-
throw new
|
|
4008
|
+
throw new import_common14.BadRequestException("attachments are { mediaId } refs \u2014 send nothing but the id");
|
|
3466
4009
|
}
|
|
3467
4010
|
const { mediaId } = entry;
|
|
3468
4011
|
if (typeof mediaId !== "string" || mediaId.length === 0) {
|
|
3469
|
-
throw new
|
|
4012
|
+
throw new import_common14.BadRequestException("each attachment must carry a non-empty string mediaId");
|
|
3470
4013
|
}
|
|
3471
4014
|
return {
|
|
3472
4015
|
mediaId
|
|
@@ -3494,9 +4037,18 @@ var ChatController = class {
|
|
|
3494
4037
|
const actor = await this.actorResolver.resolve(req);
|
|
3495
4038
|
const attachments = attachmentRefs(body.attachments);
|
|
3496
4039
|
const mode = sendMode(body);
|
|
4040
|
+
let uiCapabilities;
|
|
4041
|
+
try {
|
|
4042
|
+
uiCapabilities = body.uiCapabilities === void 0 ? void 0 : (0, import_genui2.validateUiCapabilities)(body.uiCapabilities);
|
|
4043
|
+
} catch {
|
|
4044
|
+
throw new import_common14.BadRequestException("Invalid UI capabilities");
|
|
4045
|
+
}
|
|
3497
4046
|
const result = await this.agent.send({
|
|
3498
4047
|
actor,
|
|
3499
4048
|
message: body.message,
|
|
4049
|
+
...uiCapabilities !== void 0 ? {
|
|
4050
|
+
uiCapabilities
|
|
4051
|
+
} : {},
|
|
3500
4052
|
...body.threadId !== void 0 ? {
|
|
3501
4053
|
threadId: body.threadId
|
|
3502
4054
|
} : {},
|
|
@@ -3523,6 +4075,10 @@ var ChatController = class {
|
|
|
3523
4075
|
} : {},
|
|
3524
4076
|
mode
|
|
3525
4077
|
});
|
|
4078
|
+
if ("proposalDecision" in result) {
|
|
4079
|
+
res.status(200).json(result);
|
|
4080
|
+
return;
|
|
4081
|
+
}
|
|
3526
4082
|
if (result.queued === true) {
|
|
3527
4083
|
res.status(202).json(result);
|
|
3528
4084
|
return;
|
|
@@ -3602,10 +4158,10 @@ data: ${line}
|
|
|
3602
4158
|
}
|
|
3603
4159
|
res.write("event: done\ndata: {}\n\n");
|
|
3604
4160
|
} catch (error) {
|
|
3605
|
-
const payload = error instanceof
|
|
4161
|
+
const payload = error instanceof import_nestjs_agent_core19.AgentStreamError ? {
|
|
3606
4162
|
code: error.code,
|
|
3607
4163
|
message: error.message
|
|
3608
|
-
} : (0,
|
|
4164
|
+
} : (0, import_nestjs_agent_core19.streamFailure)(error);
|
|
3609
4165
|
res.write(`event: error
|
|
3610
4166
|
data: ${JSON.stringify(payload)}
|
|
3611
4167
|
|
|
@@ -3614,50 +4170,50 @@ data: ${JSON.stringify(payload)}
|
|
|
3614
4170
|
res.end();
|
|
3615
4171
|
}
|
|
3616
4172
|
};
|
|
3617
|
-
|
|
3618
|
-
(0,
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
4173
|
+
_ts_decorate13([
|
|
4174
|
+
(0, import_common14.Post)("chat"),
|
|
4175
|
+
_ts_param11(0, (0, import_common14.Req)()),
|
|
4176
|
+
_ts_param11(1, (0, import_common14.Res)()),
|
|
4177
|
+
_ts_param11(2, (0, import_common14.Body)()),
|
|
4178
|
+
_ts_metadata11("design:type", Function),
|
|
4179
|
+
_ts_metadata11("design:paramtypes", [
|
|
3624
4180
|
typeof Request === "undefined" ? Object : Request,
|
|
3625
4181
|
typeof Response === "undefined" ? Object : Response,
|
|
3626
4182
|
typeof ChatBody === "undefined" ? Object : ChatBody
|
|
3627
4183
|
]),
|
|
3628
|
-
|
|
4184
|
+
_ts_metadata11("design:returntype", Promise)
|
|
3629
4185
|
], ChatController.prototype, "chat", null);
|
|
3630
|
-
|
|
3631
|
-
(0,
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
4186
|
+
_ts_decorate13([
|
|
4187
|
+
(0, import_common14.Get)("chat/:runId/stream"),
|
|
4188
|
+
_ts_param11(0, (0, import_common14.Req)()),
|
|
4189
|
+
_ts_param11(1, (0, import_common14.Param)("runId")),
|
|
4190
|
+
_ts_param11(2, (0, import_common14.Res)()),
|
|
4191
|
+
_ts_param11(3, (0, import_common14.Query)("after")),
|
|
4192
|
+
_ts_metadata11("design:type", Function),
|
|
4193
|
+
_ts_metadata11("design:paramtypes", [
|
|
3638
4194
|
typeof Request === "undefined" ? Object : Request,
|
|
3639
4195
|
String,
|
|
3640
4196
|
typeof Response === "undefined" ? Object : Response,
|
|
3641
4197
|
String
|
|
3642
4198
|
]),
|
|
3643
|
-
|
|
4199
|
+
_ts_metadata11("design:returntype", Promise)
|
|
3644
4200
|
], ChatController.prototype, "stream", null);
|
|
3645
|
-
|
|
3646
|
-
(0,
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
4201
|
+
_ts_decorate13([
|
|
4202
|
+
(0, import_common14.Post)("chat/:runId/cancel"),
|
|
4203
|
+
_ts_param11(0, (0, import_common14.Req)()),
|
|
4204
|
+
_ts_param11(1, (0, import_common14.Param)("runId")),
|
|
4205
|
+
_ts_metadata11("design:type", Function),
|
|
4206
|
+
_ts_metadata11("design:paramtypes", [
|
|
3651
4207
|
typeof Request === "undefined" ? Object : Request,
|
|
3652
4208
|
String
|
|
3653
4209
|
]),
|
|
3654
|
-
|
|
4210
|
+
_ts_metadata11("design:returntype", Promise)
|
|
3655
4211
|
], ChatController.prototype, "cancel", null);
|
|
3656
|
-
ChatController =
|
|
3657
|
-
(0,
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
4212
|
+
ChatController = _ts_decorate13([
|
|
4213
|
+
(0, import_common14.Controller)(),
|
|
4214
|
+
_ts_param11(1, (0, import_common14.Inject)(import_nestjs_agent_core19.AGENT_ACTOR_RESOLVER)),
|
|
4215
|
+
_ts_metadata11("design:type", Function),
|
|
4216
|
+
_ts_metadata11("design:paramtypes", [
|
|
3661
4217
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3662
4218
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3663
4219
|
])
|
|
@@ -3673,8 +4229,8 @@ function parseCursor(raw) {
|
|
|
3673
4229
|
__name(parseCursor, "parseCursor");
|
|
3674
4230
|
|
|
3675
4231
|
// src/controller/config.controller.ts
|
|
3676
|
-
var
|
|
3677
|
-
var
|
|
4232
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
4233
|
+
var import_common15 = require("@nestjs/common");
|
|
3678
4234
|
|
|
3679
4235
|
// src/resolver/anonymous-actor-resolver.ts
|
|
3680
4236
|
var import_node_crypto2 = require("crypto");
|
|
@@ -3764,7 +4320,7 @@ var AnonymousActorResolver = class {
|
|
|
3764
4320
|
};
|
|
3765
4321
|
|
|
3766
4322
|
// src/controller/config.controller.ts
|
|
3767
|
-
function
|
|
4323
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
3768
4324
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3769
4325
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3770
4326
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3777,19 +4333,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
3777
4333
|
}
|
|
3778
4334
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3779
4335
|
}
|
|
3780
|
-
__name(
|
|
3781
|
-
function
|
|
4336
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
4337
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
3782
4338
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3783
4339
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3784
4340
|
}
|
|
3785
4341
|
}
|
|
3786
|
-
__name(
|
|
3787
|
-
function
|
|
4342
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
4343
|
+
function _ts_param12(paramIndex, decorator) {
|
|
3788
4344
|
return function(target, key) {
|
|
3789
4345
|
decorator(target, key, paramIndex);
|
|
3790
4346
|
};
|
|
3791
4347
|
}
|
|
3792
|
-
__name(
|
|
4348
|
+
__name(_ts_param12, "_ts_param");
|
|
3793
4349
|
var ConfigController = class {
|
|
3794
4350
|
static {
|
|
3795
4351
|
__name(this, "ConfigController");
|
|
@@ -3820,25 +4376,25 @@ var ConfigController = class {
|
|
|
3820
4376
|
};
|
|
3821
4377
|
}
|
|
3822
4378
|
};
|
|
3823
|
-
|
|
3824
|
-
(0,
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
4379
|
+
_ts_decorate14([
|
|
4380
|
+
(0, import_common15.Get)(),
|
|
4381
|
+
_ts_param12(0, (0, import_common15.Req)()),
|
|
4382
|
+
_ts_metadata12("design:type", Function),
|
|
4383
|
+
_ts_metadata12("design:paramtypes", [
|
|
3828
4384
|
typeof Request === "undefined" ? Object : Request
|
|
3829
4385
|
]),
|
|
3830
|
-
|
|
4386
|
+
_ts_metadata12("design:returntype", Promise)
|
|
3831
4387
|
], ConfigController.prototype, "config", null);
|
|
3832
|
-
ConfigController =
|
|
3833
|
-
(0,
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
4388
|
+
ConfigController = _ts_decorate14([
|
|
4389
|
+
(0, import_common15.Controller)("config"),
|
|
4390
|
+
_ts_param12(0, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_OPTIONS)),
|
|
4391
|
+
_ts_param12(1, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER)),
|
|
4392
|
+
_ts_param12(2, (0, import_common15.Optional)()),
|
|
4393
|
+
_ts_param12(2, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_ATTACHMENT_STAGING)),
|
|
4394
|
+
_ts_param12(3, (0, import_common15.Optional)()),
|
|
4395
|
+
_ts_param12(3, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_MODEL_CATALOG)),
|
|
4396
|
+
_ts_metadata12("design:type", Function),
|
|
4397
|
+
_ts_metadata12("design:paramtypes", [
|
|
3842
4398
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
3843
4399
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3844
4400
|
Object,
|
|
@@ -3847,9 +4403,9 @@ ConfigController = _ts_decorate12([
|
|
|
3847
4403
|
], ConfigController);
|
|
3848
4404
|
|
|
3849
4405
|
// src/controller/memories.controller.ts
|
|
3850
|
-
var
|
|
3851
|
-
var
|
|
3852
|
-
function
|
|
4406
|
+
var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
|
|
4407
|
+
var import_common16 = require("@nestjs/common");
|
|
4408
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
3853
4409
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3854
4410
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3855
4411
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3862,19 +4418,19 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
3862
4418
|
}
|
|
3863
4419
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3864
4420
|
}
|
|
3865
|
-
__name(
|
|
3866
|
-
function
|
|
4421
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
4422
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
3867
4423
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3868
4424
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3869
4425
|
}
|
|
3870
4426
|
}
|
|
3871
|
-
__name(
|
|
3872
|
-
function
|
|
4427
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
4428
|
+
function _ts_param13(paramIndex, decorator) {
|
|
3873
4429
|
return function(target, key) {
|
|
3874
4430
|
decorator(target, key, paramIndex);
|
|
3875
4431
|
};
|
|
3876
4432
|
}
|
|
3877
|
-
__name(
|
|
4433
|
+
__name(_ts_param13, "_ts_param");
|
|
3878
4434
|
var MemoriesController = class {
|
|
3879
4435
|
static {
|
|
3880
4436
|
__name(this, "MemoriesController");
|
|
@@ -3908,20 +4464,20 @@ var MemoriesController = class {
|
|
|
3908
4464
|
*/
|
|
3909
4465
|
async forget(req, id) {
|
|
3910
4466
|
if (this.memory === void 0) {
|
|
3911
|
-
throw new
|
|
4467
|
+
throw new import_common16.NotFoundException("No memory is configured in this deployment.");
|
|
3912
4468
|
}
|
|
3913
4469
|
const actor = await this.actorResolver.resolve(req);
|
|
3914
4470
|
const digest = await this.unbounded("", actor);
|
|
3915
4471
|
const entry = digest.entries.find((candidate) => candidate.id === id);
|
|
3916
4472
|
if (entry === void 0) {
|
|
3917
|
-
throw new
|
|
4473
|
+
throw new import_common16.NotFoundException(`No memory with id "${id}".`);
|
|
3918
4474
|
}
|
|
3919
|
-
const verdict = (0,
|
|
4475
|
+
const verdict = (0, import_nestjs_agent_core21.memoryForgetVerdict)({
|
|
3920
4476
|
record: entry,
|
|
3921
4477
|
actor
|
|
3922
4478
|
});
|
|
3923
4479
|
if (!verdict.allowed) {
|
|
3924
|
-
throw new
|
|
4480
|
+
throw new import_common16.ForbiddenException(verdict.reason);
|
|
3925
4481
|
}
|
|
3926
4482
|
return {
|
|
3927
4483
|
forgotten: await this.memory.provider.forget({
|
|
@@ -3935,7 +4491,7 @@ var MemoriesController = class {
|
|
|
3935
4491
|
}
|
|
3936
4492
|
async unbounded(threadId, actor) {
|
|
3937
4493
|
const config = this.memory;
|
|
3938
|
-
return await (0,
|
|
4494
|
+
return await (0, import_nestjs_agent_core21.offerMemories)({
|
|
3939
4495
|
config: {
|
|
3940
4496
|
...config,
|
|
3941
4497
|
maxMemories: Number.POSITIVE_INFINITY
|
|
@@ -3947,44 +4503,44 @@ var MemoriesController = class {
|
|
|
3947
4503
|
});
|
|
3948
4504
|
}
|
|
3949
4505
|
};
|
|
3950
|
-
|
|
3951
|
-
(0,
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
4506
|
+
_ts_decorate15([
|
|
4507
|
+
(0, import_common16.Get)(),
|
|
4508
|
+
_ts_param13(0, (0, import_common16.Req)()),
|
|
4509
|
+
_ts_param13(1, (0, import_common16.Query)("threadId")),
|
|
4510
|
+
_ts_metadata13("design:type", Function),
|
|
4511
|
+
_ts_metadata13("design:paramtypes", [
|
|
3956
4512
|
typeof Request === "undefined" ? Object : Request,
|
|
3957
4513
|
String
|
|
3958
4514
|
]),
|
|
3959
|
-
|
|
4515
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3960
4516
|
], MemoriesController.prototype, "list", null);
|
|
3961
|
-
|
|
3962
|
-
(0,
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
4517
|
+
_ts_decorate15([
|
|
4518
|
+
(0, import_common16.Delete)(":id"),
|
|
4519
|
+
_ts_param13(0, (0, import_common16.Req)()),
|
|
4520
|
+
_ts_param13(1, (0, import_common16.Param)("id")),
|
|
4521
|
+
_ts_metadata13("design:type", Function),
|
|
4522
|
+
_ts_metadata13("design:paramtypes", [
|
|
3967
4523
|
typeof Request === "undefined" ? Object : Request,
|
|
3968
4524
|
String
|
|
3969
4525
|
]),
|
|
3970
|
-
|
|
4526
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3971
4527
|
], MemoriesController.prototype, "forget", null);
|
|
3972
|
-
MemoriesController =
|
|
3973
|
-
(0,
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
4528
|
+
MemoriesController = _ts_decorate15([
|
|
4529
|
+
(0, import_common16.Controller)("memories"),
|
|
4530
|
+
_ts_param13(0, (0, import_common16.Inject)(import_nestjs_agent_core21.AGENT_ACTOR_RESOLVER)),
|
|
4531
|
+
_ts_param13(1, (0, import_common16.Optional)()),
|
|
4532
|
+
_ts_param13(1, (0, import_common16.Inject)(import_nestjs_agent_core21.AGENT_MEMORY)),
|
|
4533
|
+
_ts_metadata13("design:type", Function),
|
|
4534
|
+
_ts_metadata13("design:paramtypes", [
|
|
3979
4535
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3980
4536
|
Object
|
|
3981
4537
|
])
|
|
3982
4538
|
], MemoriesController);
|
|
3983
4539
|
|
|
3984
4540
|
// src/controller/messages.controller.ts
|
|
3985
|
-
var
|
|
3986
|
-
var
|
|
3987
|
-
function
|
|
4541
|
+
var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
|
|
4542
|
+
var import_common17 = require("@nestjs/common");
|
|
4543
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
3988
4544
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3989
4545
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3990
4546
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3997,19 +4553,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
3997
4553
|
}
|
|
3998
4554
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3999
4555
|
}
|
|
4000
|
-
__name(
|
|
4001
|
-
function
|
|
4556
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
4557
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
4002
4558
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4003
4559
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4004
4560
|
}
|
|
4005
4561
|
}
|
|
4006
|
-
__name(
|
|
4007
|
-
function
|
|
4562
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
4563
|
+
function _ts_param14(paramIndex, decorator) {
|
|
4008
4564
|
return function(target, key) {
|
|
4009
4565
|
decorator(target, key, paramIndex);
|
|
4010
4566
|
};
|
|
4011
4567
|
}
|
|
4012
|
-
__name(
|
|
4568
|
+
__name(_ts_param14, "_ts_param");
|
|
4013
4569
|
var MessagesController = class {
|
|
4014
4570
|
static {
|
|
4015
4571
|
__name(this, "MessagesController");
|
|
@@ -4037,34 +4593,34 @@ var MessagesController = class {
|
|
|
4037
4593
|
};
|
|
4038
4594
|
}
|
|
4039
4595
|
};
|
|
4040
|
-
|
|
4041
|
-
(0,
|
|
4042
|
-
(0,
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
typeof Request === "undefined" ? Object : Request,
|
|
4049
|
-
String,
|
|
4596
|
+
_ts_decorate16([
|
|
4597
|
+
(0, import_common17.Post)(":id/feedback"),
|
|
4598
|
+
(0, import_common17.HttpCode)(200),
|
|
4599
|
+
_ts_param14(0, (0, import_common17.Req)()),
|
|
4600
|
+
_ts_param14(1, (0, import_common17.Param)("id")),
|
|
4601
|
+
_ts_param14(2, (0, import_common17.Body)()),
|
|
4602
|
+
_ts_metadata14("design:type", Function),
|
|
4603
|
+
_ts_metadata14("design:paramtypes", [
|
|
4604
|
+
typeof Request === "undefined" ? Object : Request,
|
|
4605
|
+
String,
|
|
4050
4606
|
typeof FeedbackBody === "undefined" ? Object : FeedbackBody
|
|
4051
4607
|
]),
|
|
4052
|
-
|
|
4608
|
+
_ts_metadata14("design:returntype", Promise)
|
|
4053
4609
|
], MessagesController.prototype, "feedback", null);
|
|
4054
|
-
MessagesController =
|
|
4055
|
-
(0,
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4610
|
+
MessagesController = _ts_decorate16([
|
|
4611
|
+
(0, import_common17.Controller)("messages"),
|
|
4612
|
+
_ts_param14(1, (0, import_common17.Inject)(import_nestjs_agent_core22.AGENT_ACTOR_RESOLVER)),
|
|
4613
|
+
_ts_metadata14("design:type", Function),
|
|
4614
|
+
_ts_metadata14("design:paramtypes", [
|
|
4059
4615
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
4060
4616
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
4061
4617
|
])
|
|
4062
4618
|
], MessagesController);
|
|
4063
4619
|
|
|
4064
4620
|
// src/controller/models.controller.ts
|
|
4065
|
-
var
|
|
4066
|
-
var
|
|
4067
|
-
function
|
|
4621
|
+
var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
|
|
4622
|
+
var import_common18 = require("@nestjs/common");
|
|
4623
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
4068
4624
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4069
4625
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4070
4626
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4077,19 +4633,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
4077
4633
|
}
|
|
4078
4634
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4079
4635
|
}
|
|
4080
|
-
__name(
|
|
4081
|
-
function
|
|
4636
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
4637
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
4082
4638
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4083
4639
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4084
4640
|
}
|
|
4085
4641
|
}
|
|
4086
|
-
__name(
|
|
4087
|
-
function
|
|
4642
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
4643
|
+
function _ts_param15(paramIndex, decorator) {
|
|
4088
4644
|
return function(target, key) {
|
|
4089
4645
|
decorator(target, key, paramIndex);
|
|
4090
4646
|
};
|
|
4091
4647
|
}
|
|
4092
|
-
__name(
|
|
4648
|
+
__name(_ts_param15, "_ts_param");
|
|
4093
4649
|
var ModelsController = class {
|
|
4094
4650
|
static {
|
|
4095
4651
|
__name(this, "ModelsController");
|
|
@@ -4109,31 +4665,31 @@ var ModelsController = class {
|
|
|
4109
4665
|
return this.agent.listModels(actor, agent);
|
|
4110
4666
|
}
|
|
4111
4667
|
};
|
|
4112
|
-
|
|
4113
|
-
(0,
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4668
|
+
_ts_decorate17([
|
|
4669
|
+
(0, import_common18.Get)(),
|
|
4670
|
+
_ts_param15(0, (0, import_common18.Req)()),
|
|
4671
|
+
_ts_param15(1, (0, import_common18.Query)("agent")),
|
|
4672
|
+
_ts_metadata15("design:type", Function),
|
|
4673
|
+
_ts_metadata15("design:paramtypes", [
|
|
4118
4674
|
typeof Request === "undefined" ? Object : Request,
|
|
4119
4675
|
String
|
|
4120
4676
|
]),
|
|
4121
|
-
|
|
4677
|
+
_ts_metadata15("design:returntype", Promise)
|
|
4122
4678
|
], ModelsController.prototype, "list", null);
|
|
4123
|
-
ModelsController =
|
|
4124
|
-
(0,
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4679
|
+
ModelsController = _ts_decorate17([
|
|
4680
|
+
(0, import_common18.Controller)("models"),
|
|
4681
|
+
_ts_param15(1, (0, import_common18.Inject)(import_nestjs_agent_core23.AGENT_ACTOR_RESOLVER)),
|
|
4682
|
+
_ts_metadata15("design:type", Function),
|
|
4683
|
+
_ts_metadata15("design:paramtypes", [
|
|
4128
4684
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
4129
4685
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
4130
4686
|
])
|
|
4131
4687
|
], ModelsController);
|
|
4132
4688
|
|
|
4133
4689
|
// src/controller/queue.controller.ts
|
|
4134
|
-
var
|
|
4135
|
-
var
|
|
4136
|
-
function
|
|
4690
|
+
var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
|
|
4691
|
+
var import_common19 = require("@nestjs/common");
|
|
4692
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
4137
4693
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4138
4694
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4139
4695
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4146,19 +4702,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
4146
4702
|
}
|
|
4147
4703
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4148
4704
|
}
|
|
4149
|
-
__name(
|
|
4150
|
-
function
|
|
4705
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
4706
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
4151
4707
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4152
4708
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4153
4709
|
}
|
|
4154
4710
|
}
|
|
4155
|
-
__name(
|
|
4156
|
-
function
|
|
4711
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
4712
|
+
function _ts_param16(paramIndex, decorator) {
|
|
4157
4713
|
return function(target, key) {
|
|
4158
4714
|
decorator(target, key, paramIndex);
|
|
4159
4715
|
};
|
|
4160
4716
|
}
|
|
4161
|
-
__name(
|
|
4717
|
+
__name(_ts_param16, "_ts_param");
|
|
4162
4718
|
var QueueController = class {
|
|
4163
4719
|
static {
|
|
4164
4720
|
__name(this, "QueueController");
|
|
@@ -4182,10 +4738,10 @@ var QueueController = class {
|
|
|
4182
4738
|
async update(req, messageId, body) {
|
|
4183
4739
|
const actor = await this.actorResolver.resolve(req);
|
|
4184
4740
|
if (body.message !== void 0 && typeof body.message !== "string") {
|
|
4185
|
-
throw new
|
|
4741
|
+
throw new import_common19.BadRequestException("message must be a string");
|
|
4186
4742
|
}
|
|
4187
4743
|
if (body.position !== void 0 && typeof body.position !== "number") {
|
|
4188
|
-
throw new
|
|
4744
|
+
throw new import_common19.BadRequestException("position must be a number");
|
|
4189
4745
|
}
|
|
4190
4746
|
const attachments = body.attachments === void 0 ? void 0 : body.attachments === null ? null : attachmentRefs(body.attachments);
|
|
4191
4747
|
return this.agent.updateQueuedMessage(actor, messageId, {
|
|
@@ -4212,88 +4768,88 @@ var QueueController = class {
|
|
|
4212
4768
|
return this.agent.removeQueuedMessage(await this.actorResolver.resolve(req), messageId);
|
|
4213
4769
|
}
|
|
4214
4770
|
};
|
|
4215
|
-
|
|
4216
|
-
(0,
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4771
|
+
_ts_decorate18([
|
|
4772
|
+
(0, import_common19.Get)("threads/:id/queue"),
|
|
4773
|
+
_ts_param16(0, (0, import_common19.Req)()),
|
|
4774
|
+
_ts_param16(1, (0, import_common19.Param)("id")),
|
|
4775
|
+
_ts_metadata16("design:type", Function),
|
|
4776
|
+
_ts_metadata16("design:paramtypes", [
|
|
4221
4777
|
typeof Request === "undefined" ? Object : Request,
|
|
4222
4778
|
String
|
|
4223
4779
|
]),
|
|
4224
|
-
|
|
4780
|
+
_ts_metadata16("design:returntype", Promise)
|
|
4225
4781
|
], QueueController.prototype, "list", null);
|
|
4226
|
-
|
|
4227
|
-
(0,
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4782
|
+
_ts_decorate18([
|
|
4783
|
+
(0, import_common19.Delete)("threads/:id/queue"),
|
|
4784
|
+
_ts_param16(0, (0, import_common19.Req)()),
|
|
4785
|
+
_ts_param16(1, (0, import_common19.Param)("id")),
|
|
4786
|
+
_ts_metadata16("design:type", Function),
|
|
4787
|
+
_ts_metadata16("design:paramtypes", [
|
|
4232
4788
|
typeof Request === "undefined" ? Object : Request,
|
|
4233
4789
|
String
|
|
4234
4790
|
]),
|
|
4235
|
-
|
|
4791
|
+
_ts_metadata16("design:returntype", Promise)
|
|
4236
4792
|
], QueueController.prototype, "clear", null);
|
|
4237
|
-
|
|
4238
|
-
(0,
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4793
|
+
_ts_decorate18([
|
|
4794
|
+
(0, import_common19.Post)("threads/:id/queue/resume"),
|
|
4795
|
+
_ts_param16(0, (0, import_common19.Req)()),
|
|
4796
|
+
_ts_param16(1, (0, import_common19.Param)("id")),
|
|
4797
|
+
_ts_metadata16("design:type", Function),
|
|
4798
|
+
_ts_metadata16("design:paramtypes", [
|
|
4243
4799
|
typeof Request === "undefined" ? Object : Request,
|
|
4244
4800
|
String
|
|
4245
4801
|
]),
|
|
4246
|
-
|
|
4802
|
+
_ts_metadata16("design:returntype", Promise)
|
|
4247
4803
|
], QueueController.prototype, "resume", null);
|
|
4248
|
-
|
|
4249
|
-
(0,
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4804
|
+
_ts_decorate18([
|
|
4805
|
+
(0, import_common19.Patch)("queue/:messageId"),
|
|
4806
|
+
_ts_param16(0, (0, import_common19.Req)()),
|
|
4807
|
+
_ts_param16(1, (0, import_common19.Param)("messageId")),
|
|
4808
|
+
_ts_param16(2, (0, import_common19.Body)()),
|
|
4809
|
+
_ts_metadata16("design:type", Function),
|
|
4810
|
+
_ts_metadata16("design:paramtypes", [
|
|
4255
4811
|
typeof Request === "undefined" ? Object : Request,
|
|
4256
4812
|
String,
|
|
4257
4813
|
typeof UpdateQueuedMessageBody === "undefined" ? Object : UpdateQueuedMessageBody
|
|
4258
4814
|
]),
|
|
4259
|
-
|
|
4815
|
+
_ts_metadata16("design:returntype", Promise)
|
|
4260
4816
|
], QueueController.prototype, "update", null);
|
|
4261
|
-
|
|
4262
|
-
(0,
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4817
|
+
_ts_decorate18([
|
|
4818
|
+
(0, import_common19.Post)("queue/:messageId/interrupt"),
|
|
4819
|
+
_ts_param16(0, (0, import_common19.Req)()),
|
|
4820
|
+
_ts_param16(1, (0, import_common19.Param)("messageId")),
|
|
4821
|
+
_ts_metadata16("design:type", Function),
|
|
4822
|
+
_ts_metadata16("design:paramtypes", [
|
|
4267
4823
|
typeof Request === "undefined" ? Object : Request,
|
|
4268
4824
|
String
|
|
4269
4825
|
]),
|
|
4270
|
-
|
|
4826
|
+
_ts_metadata16("design:returntype", Promise)
|
|
4271
4827
|
], QueueController.prototype, "interrupt", null);
|
|
4272
|
-
|
|
4273
|
-
(0,
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4828
|
+
_ts_decorate18([
|
|
4829
|
+
(0, import_common19.Delete)("queue/:messageId"),
|
|
4830
|
+
_ts_param16(0, (0, import_common19.Req)()),
|
|
4831
|
+
_ts_param16(1, (0, import_common19.Param)("messageId")),
|
|
4832
|
+
_ts_metadata16("design:type", Function),
|
|
4833
|
+
_ts_metadata16("design:paramtypes", [
|
|
4278
4834
|
typeof Request === "undefined" ? Object : Request,
|
|
4279
4835
|
String
|
|
4280
4836
|
]),
|
|
4281
|
-
|
|
4837
|
+
_ts_metadata16("design:returntype", Promise)
|
|
4282
4838
|
], QueueController.prototype, "remove", null);
|
|
4283
|
-
QueueController =
|
|
4284
|
-
(0,
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4839
|
+
QueueController = _ts_decorate18([
|
|
4840
|
+
(0, import_common19.Controller)(),
|
|
4841
|
+
_ts_param16(1, (0, import_common19.Inject)(import_nestjs_agent_core24.AGENT_ACTOR_RESOLVER)),
|
|
4842
|
+
_ts_metadata16("design:type", Function),
|
|
4843
|
+
_ts_metadata16("design:paramtypes", [
|
|
4288
4844
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
4289
4845
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
4290
4846
|
])
|
|
4291
4847
|
], QueueController);
|
|
4292
4848
|
|
|
4293
4849
|
// src/controller/quota.controller.ts
|
|
4294
|
-
var
|
|
4295
|
-
var
|
|
4296
|
-
function
|
|
4850
|
+
var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
|
|
4851
|
+
var import_common20 = require("@nestjs/common");
|
|
4852
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
4297
4853
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4298
4854
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4299
4855
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4306,19 +4862,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
4306
4862
|
}
|
|
4307
4863
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4308
4864
|
}
|
|
4309
|
-
__name(
|
|
4310
|
-
function
|
|
4865
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
4866
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
4311
4867
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4312
4868
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4313
4869
|
}
|
|
4314
4870
|
}
|
|
4315
|
-
__name(
|
|
4316
|
-
function
|
|
4871
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
4872
|
+
function _ts_param17(paramIndex, decorator) {
|
|
4317
4873
|
return function(target, key) {
|
|
4318
4874
|
decorator(target, key, paramIndex);
|
|
4319
4875
|
};
|
|
4320
4876
|
}
|
|
4321
|
-
__name(
|
|
4877
|
+
__name(_ts_param17, "_ts_param");
|
|
4322
4878
|
var QuotaController = class {
|
|
4323
4879
|
static {
|
|
4324
4880
|
__name(this, "QuotaController");
|
|
@@ -4338,29 +4894,29 @@ var QuotaController = class {
|
|
|
4338
4894
|
return this.agent.quotaReport(actor);
|
|
4339
4895
|
}
|
|
4340
4896
|
};
|
|
4341
|
-
|
|
4342
|
-
(0,
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4897
|
+
_ts_decorate19([
|
|
4898
|
+
(0, import_common20.Get)(),
|
|
4899
|
+
_ts_param17(0, (0, import_common20.Req)()),
|
|
4900
|
+
_ts_metadata17("design:type", Function),
|
|
4901
|
+
_ts_metadata17("design:paramtypes", [
|
|
4346
4902
|
typeof Request === "undefined" ? Object : Request
|
|
4347
4903
|
]),
|
|
4348
|
-
|
|
4904
|
+
_ts_metadata17("design:returntype", Promise)
|
|
4349
4905
|
], QuotaController.prototype, "report", null);
|
|
4350
|
-
QuotaController =
|
|
4351
|
-
(0,
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4906
|
+
QuotaController = _ts_decorate19([
|
|
4907
|
+
(0, import_common20.Controller)("quota"),
|
|
4908
|
+
_ts_param17(1, (0, import_common20.Inject)(import_nestjs_agent_core25.AGENT_ACTOR_RESOLVER)),
|
|
4909
|
+
_ts_metadata17("design:type", Function),
|
|
4910
|
+
_ts_metadata17("design:paramtypes", [
|
|
4355
4911
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
4356
4912
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
4357
4913
|
])
|
|
4358
4914
|
], QuotaController);
|
|
4359
4915
|
|
|
4360
4916
|
// src/controller/skills.controller.ts
|
|
4361
|
-
var
|
|
4362
|
-
var
|
|
4363
|
-
function
|
|
4917
|
+
var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
|
|
4918
|
+
var import_common21 = require("@nestjs/common");
|
|
4919
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
4364
4920
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4365
4921
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4366
4922
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4373,19 +4929,19 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
4373
4929
|
}
|
|
4374
4930
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4375
4931
|
}
|
|
4376
|
-
__name(
|
|
4377
|
-
function
|
|
4932
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
4933
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
4378
4934
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4379
4935
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4380
4936
|
}
|
|
4381
4937
|
}
|
|
4382
|
-
__name(
|
|
4383
|
-
function
|
|
4938
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
4939
|
+
function _ts_param18(paramIndex, decorator) {
|
|
4384
4940
|
return function(target, key) {
|
|
4385
4941
|
decorator(target, key, paramIndex);
|
|
4386
4942
|
};
|
|
4387
4943
|
}
|
|
4388
|
-
__name(
|
|
4944
|
+
__name(_ts_param18, "_ts_param");
|
|
4389
4945
|
var SkillsController = class {
|
|
4390
4946
|
static {
|
|
4391
4947
|
__name(this, "SkillsController");
|
|
@@ -4401,40 +4957,40 @@ var SkillsController = class {
|
|
|
4401
4957
|
return [];
|
|
4402
4958
|
}
|
|
4403
4959
|
const actor = await this.actorResolver.resolve(req);
|
|
4404
|
-
const offer = await (0,
|
|
4960
|
+
const offer = await (0, import_nestjs_agent_core26.offerSkills)(this.skills, {
|
|
4405
4961
|
actor,
|
|
4406
4962
|
threadId: threadId ?? ""
|
|
4407
4963
|
});
|
|
4408
4964
|
return offer.entries;
|
|
4409
4965
|
}
|
|
4410
4966
|
};
|
|
4411
|
-
|
|
4412
|
-
(0,
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4967
|
+
_ts_decorate20([
|
|
4968
|
+
(0, import_common21.Get)(),
|
|
4969
|
+
_ts_param18(0, (0, import_common21.Req)()),
|
|
4970
|
+
_ts_param18(1, (0, import_common21.Query)("threadId")),
|
|
4971
|
+
_ts_metadata18("design:type", Function),
|
|
4972
|
+
_ts_metadata18("design:paramtypes", [
|
|
4417
4973
|
typeof Request === "undefined" ? Object : Request,
|
|
4418
4974
|
String
|
|
4419
4975
|
]),
|
|
4420
|
-
|
|
4976
|
+
_ts_metadata18("design:returntype", Promise)
|
|
4421
4977
|
], SkillsController.prototype, "list", null);
|
|
4422
|
-
SkillsController =
|
|
4423
|
-
(0,
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4978
|
+
SkillsController = _ts_decorate20([
|
|
4979
|
+
(0, import_common21.Controller)("skills"),
|
|
4980
|
+
_ts_param18(0, (0, import_common21.Inject)(import_nestjs_agent_core26.AGENT_ACTOR_RESOLVER)),
|
|
4981
|
+
_ts_param18(1, (0, import_common21.Optional)()),
|
|
4982
|
+
_ts_param18(1, (0, import_common21.Inject)(import_nestjs_agent_core26.AGENT_SKILLS)),
|
|
4983
|
+
_ts_metadata18("design:type", Function),
|
|
4984
|
+
_ts_metadata18("design:paramtypes", [
|
|
4429
4985
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
4430
4986
|
Object
|
|
4431
4987
|
])
|
|
4432
4988
|
], SkillsController);
|
|
4433
4989
|
|
|
4434
4990
|
// src/controller/threads.controller.ts
|
|
4435
|
-
var
|
|
4436
|
-
var
|
|
4437
|
-
function
|
|
4991
|
+
var import_nestjs_agent_core27 = require("@dudousxd/nestjs-agent-core");
|
|
4992
|
+
var import_common22 = require("@nestjs/common");
|
|
4993
|
+
function _ts_decorate21(decorators, target, key, desc) {
|
|
4438
4994
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4439
4995
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4440
4996
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4447,19 +5003,19 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
4447
5003
|
}
|
|
4448
5004
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4449
5005
|
}
|
|
4450
|
-
__name(
|
|
4451
|
-
function
|
|
5006
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
5007
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
4452
5008
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4453
5009
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4454
5010
|
}
|
|
4455
5011
|
}
|
|
4456
|
-
__name(
|
|
4457
|
-
function
|
|
5012
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
5013
|
+
function _ts_param19(paramIndex, decorator) {
|
|
4458
5014
|
return function(target, key) {
|
|
4459
5015
|
decorator(target, key, paramIndex);
|
|
4460
5016
|
};
|
|
4461
5017
|
}
|
|
4462
|
-
__name(
|
|
5018
|
+
__name(_ts_param19, "_ts_param");
|
|
4463
5019
|
var ThreadsController = class {
|
|
4464
5020
|
static {
|
|
4465
5021
|
__name(this, "ThreadsController");
|
|
@@ -4529,101 +5085,101 @@ var ThreadsController = class {
|
|
|
4529
5085
|
};
|
|
4530
5086
|
}
|
|
4531
5087
|
};
|
|
4532
|
-
|
|
4533
|
-
(0,
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
5088
|
+
_ts_decorate21([
|
|
5089
|
+
(0, import_common22.Get)(),
|
|
5090
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5091
|
+
_ts_metadata19("design:type", Function),
|
|
5092
|
+
_ts_metadata19("design:paramtypes", [
|
|
4537
5093
|
typeof Request === "undefined" ? Object : Request
|
|
4538
5094
|
]),
|
|
4539
|
-
|
|
5095
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4540
5096
|
], ThreadsController.prototype, "list", null);
|
|
4541
|
-
|
|
4542
|
-
(0,
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
5097
|
+
_ts_decorate21([
|
|
5098
|
+
(0, import_common22.Get)(":id"),
|
|
5099
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5100
|
+
_ts_param19(1, (0, import_common22.Param)("id")),
|
|
5101
|
+
_ts_metadata19("design:type", Function),
|
|
5102
|
+
_ts_metadata19("design:paramtypes", [
|
|
4547
5103
|
typeof Request === "undefined" ? Object : Request,
|
|
4548
5104
|
String
|
|
4549
5105
|
]),
|
|
4550
|
-
|
|
5106
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4551
5107
|
], ThreadsController.prototype, "detail", null);
|
|
4552
|
-
|
|
4553
|
-
(0,
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
5108
|
+
_ts_decorate21([
|
|
5109
|
+
(0, import_common22.Delete)(":id"),
|
|
5110
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5111
|
+
_ts_param19(1, (0, import_common22.Param)("id")),
|
|
5112
|
+
_ts_metadata19("design:type", Function),
|
|
5113
|
+
_ts_metadata19("design:paramtypes", [
|
|
4558
5114
|
typeof Request === "undefined" ? Object : Request,
|
|
4559
5115
|
String
|
|
4560
5116
|
]),
|
|
4561
|
-
|
|
5117
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4562
5118
|
], ThreadsController.prototype, "remove", null);
|
|
4563
|
-
|
|
4564
|
-
(0,
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
5119
|
+
_ts_decorate21([
|
|
5120
|
+
(0, import_common22.Post)(":id/fork-from/:messageId"),
|
|
5121
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5122
|
+
_ts_param19(1, (0, import_common22.Param)("id")),
|
|
5123
|
+
_ts_param19(2, (0, import_common22.Param)("messageId")),
|
|
5124
|
+
_ts_metadata19("design:type", Function),
|
|
5125
|
+
_ts_metadata19("design:paramtypes", [
|
|
4570
5126
|
typeof Request === "undefined" ? Object : Request,
|
|
4571
5127
|
String,
|
|
4572
5128
|
String
|
|
4573
5129
|
]),
|
|
4574
|
-
|
|
5130
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4575
5131
|
], ThreadsController.prototype, "fork", null);
|
|
4576
|
-
|
|
4577
|
-
(0,
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
5132
|
+
_ts_decorate21([
|
|
5133
|
+
(0, import_common22.Patch)(":id"),
|
|
5134
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5135
|
+
_ts_param19(1, (0, import_common22.Param)("id")),
|
|
5136
|
+
_ts_param19(2, (0, import_common22.Body)()),
|
|
5137
|
+
_ts_metadata19("design:type", Function),
|
|
5138
|
+
_ts_metadata19("design:paramtypes", [
|
|
4583
5139
|
typeof Request === "undefined" ? Object : Request,
|
|
4584
5140
|
String,
|
|
4585
5141
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
4586
5142
|
]),
|
|
4587
|
-
|
|
5143
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4588
5144
|
], ThreadsController.prototype, "update", null);
|
|
4589
|
-
|
|
4590
|
-
(0,
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
5145
|
+
_ts_decorate21([
|
|
5146
|
+
(0, import_common22.Post)(":id/promote"),
|
|
5147
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5148
|
+
_ts_param19(1, (0, import_common22.Param)("id")),
|
|
5149
|
+
_ts_metadata19("design:type", Function),
|
|
5150
|
+
_ts_metadata19("design:paramtypes", [
|
|
4595
5151
|
typeof Request === "undefined" ? Object : Request,
|
|
4596
5152
|
String
|
|
4597
5153
|
]),
|
|
4598
|
-
|
|
5154
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4599
5155
|
], ThreadsController.prototype, "promote", null);
|
|
4600
|
-
|
|
4601
|
-
(0,
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
5156
|
+
_ts_decorate21([
|
|
5157
|
+
(0, import_common22.Delete)(":id/from/:messageId"),
|
|
5158
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
5159
|
+
_ts_param19(1, (0, import_common22.Param)("id")),
|
|
5160
|
+
_ts_param19(2, (0, import_common22.Param)("messageId")),
|
|
5161
|
+
_ts_metadata19("design:type", Function),
|
|
5162
|
+
_ts_metadata19("design:paramtypes", [
|
|
4607
5163
|
typeof Request === "undefined" ? Object : Request,
|
|
4608
5164
|
String,
|
|
4609
5165
|
String
|
|
4610
5166
|
]),
|
|
4611
|
-
|
|
5167
|
+
_ts_metadata19("design:returntype", Promise)
|
|
4612
5168
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
4613
|
-
ThreadsController =
|
|
4614
|
-
(0,
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
5169
|
+
ThreadsController = _ts_decorate21([
|
|
5170
|
+
(0, import_common22.Controller)("threads"),
|
|
5171
|
+
_ts_param19(1, (0, import_common22.Inject)(import_nestjs_agent_core27.AGENT_ACTOR_RESOLVER)),
|
|
5172
|
+
_ts_metadata19("design:type", Function),
|
|
5173
|
+
_ts_metadata19("design:paramtypes", [
|
|
4618
5174
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
4619
5175
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
4620
5176
|
])
|
|
4621
5177
|
], ThreadsController);
|
|
4622
5178
|
|
|
4623
5179
|
// src/controller/tool-call.controller.ts
|
|
4624
|
-
var
|
|
4625
|
-
var
|
|
4626
|
-
function
|
|
5180
|
+
var import_nestjs_agent_core28 = require("@dudousxd/nestjs-agent-core");
|
|
5181
|
+
var import_common23 = require("@nestjs/common");
|
|
5182
|
+
function _ts_decorate22(decorators, target, key, desc) {
|
|
4627
5183
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4628
5184
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4629
5185
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4636,19 +5192,19 @@ function _ts_decorate20(decorators, target, key, desc) {
|
|
|
4636
5192
|
}
|
|
4637
5193
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4638
5194
|
}
|
|
4639
|
-
__name(
|
|
4640
|
-
function
|
|
5195
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
5196
|
+
function _ts_metadata20(metadataKey, metadataValue) {
|
|
4641
5197
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4642
5198
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4643
5199
|
}
|
|
4644
5200
|
}
|
|
4645
|
-
__name(
|
|
4646
|
-
function
|
|
5201
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
5202
|
+
function _ts_param20(paramIndex, decorator) {
|
|
4647
5203
|
return function(target, key) {
|
|
4648
5204
|
decorator(target, key, paramIndex);
|
|
4649
5205
|
};
|
|
4650
5206
|
}
|
|
4651
|
-
__name(
|
|
5207
|
+
__name(_ts_param20, "_ts_param");
|
|
4652
5208
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
4653
5209
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
4654
5210
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -4657,7 +5213,7 @@ var MAX_VIA_LENGTH = 64;
|
|
|
4657
5213
|
var DEFAULT_VIA = "web";
|
|
4658
5214
|
function toolCallId(claimed) {
|
|
4659
5215
|
if (typeof claimed !== "string" || claimed.length === 0) {
|
|
4660
|
-
throw new
|
|
5216
|
+
throw new import_common23.BadRequestException("toolCallId must be a non-empty string");
|
|
4661
5217
|
}
|
|
4662
5218
|
return claimed;
|
|
4663
5219
|
}
|
|
@@ -4667,10 +5223,10 @@ function rejectReason(claimed) {
|
|
|
4667
5223
|
return void 0;
|
|
4668
5224
|
}
|
|
4669
5225
|
if (typeof claimed !== "string") {
|
|
4670
|
-
throw new
|
|
5226
|
+
throw new import_common23.BadRequestException("reason must be a string");
|
|
4671
5227
|
}
|
|
4672
5228
|
if (claimed.length > MAX_REJECT_REASON_LENGTH) {
|
|
4673
|
-
throw new
|
|
5229
|
+
throw new import_common23.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
|
|
4674
5230
|
}
|
|
4675
5231
|
return claimed;
|
|
4676
5232
|
}
|
|
@@ -4680,7 +5236,7 @@ function remember(claimed) {
|
|
|
4680
5236
|
return false;
|
|
4681
5237
|
}
|
|
4682
5238
|
if (typeof claimed !== "boolean") {
|
|
4683
|
-
throw new
|
|
5239
|
+
throw new import_common23.BadRequestException("remember must be a boolean");
|
|
4684
5240
|
}
|
|
4685
5241
|
return claimed;
|
|
4686
5242
|
}
|
|
@@ -4690,7 +5246,7 @@ function via(claimed) {
|
|
|
4690
5246
|
return DEFAULT_VIA;
|
|
4691
5247
|
}
|
|
4692
5248
|
if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
|
|
4693
|
-
throw new
|
|
5249
|
+
throw new import_common23.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
|
|
4694
5250
|
}
|
|
4695
5251
|
return claimed;
|
|
4696
5252
|
}
|
|
@@ -4700,26 +5256,26 @@ function answers(claimed) {
|
|
|
4700
5256
|
return void 0;
|
|
4701
5257
|
}
|
|
4702
5258
|
if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
|
|
4703
|
-
throw new
|
|
5259
|
+
throw new import_common23.BadRequestException("answers must be an object of questionId \u2192 chosen values");
|
|
4704
5260
|
}
|
|
4705
5261
|
const entries = Object.entries(claimed);
|
|
4706
5262
|
if (entries.length > MAX_ANSWERED_QUESTIONS) {
|
|
4707
|
-
throw new
|
|
5263
|
+
throw new import_common23.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
|
|
4708
5264
|
}
|
|
4709
5265
|
const validated = /* @__PURE__ */ Object.create(null);
|
|
4710
5266
|
for (const [questionId, values] of entries) {
|
|
4711
5267
|
if (!Array.isArray(values)) {
|
|
4712
|
-
throw new
|
|
5268
|
+
throw new import_common23.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
|
|
4713
5269
|
}
|
|
4714
5270
|
if (values.length > MAX_VALUES_PER_QUESTION) {
|
|
4715
|
-
throw new
|
|
5271
|
+
throw new import_common23.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
|
|
4716
5272
|
}
|
|
4717
5273
|
for (const value of values) {
|
|
4718
5274
|
if (typeof value !== "string") {
|
|
4719
|
-
throw new
|
|
5275
|
+
throw new import_common23.BadRequestException(`answers["${questionId}"] must contain only strings`);
|
|
4720
5276
|
}
|
|
4721
5277
|
if (value.length > MAX_ANSWER_VALUE_LENGTH) {
|
|
4722
|
-
throw new
|
|
5278
|
+
throw new import_common23.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
|
|
4723
5279
|
}
|
|
4724
5280
|
}
|
|
4725
5281
|
validated[questionId] = values;
|
|
@@ -4778,67 +5334,67 @@ var ToolCallController = class {
|
|
|
4778
5334
|
});
|
|
4779
5335
|
return {
|
|
4780
5336
|
ok: true
|
|
4781
|
-
};
|
|
4782
|
-
}
|
|
4783
|
-
};
|
|
4784
|
-
|
|
4785
|
-
(0,
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
5337
|
+
};
|
|
5338
|
+
}
|
|
5339
|
+
};
|
|
5340
|
+
_ts_decorate22([
|
|
5341
|
+
(0, import_common23.Post)("approve"),
|
|
5342
|
+
_ts_param20(0, (0, import_common23.Req)()),
|
|
5343
|
+
_ts_param20(1, (0, import_common23.Body)()),
|
|
5344
|
+
_ts_metadata20("design:type", Function),
|
|
5345
|
+
_ts_metadata20("design:paramtypes", [
|
|
4790
5346
|
typeof Request === "undefined" ? Object : Request,
|
|
4791
5347
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
4792
5348
|
]),
|
|
4793
|
-
|
|
5349
|
+
_ts_metadata20("design:returntype", Promise)
|
|
4794
5350
|
], ToolCallController.prototype, "approve", null);
|
|
4795
|
-
|
|
4796
|
-
(0,
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
5351
|
+
_ts_decorate22([
|
|
5352
|
+
(0, import_common23.Post)("reject"),
|
|
5353
|
+
_ts_param20(0, (0, import_common23.Req)()),
|
|
5354
|
+
_ts_param20(1, (0, import_common23.Body)()),
|
|
5355
|
+
_ts_metadata20("design:type", Function),
|
|
5356
|
+
_ts_metadata20("design:paramtypes", [
|
|
4801
5357
|
typeof Request === "undefined" ? Object : Request,
|
|
4802
5358
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
4803
5359
|
]),
|
|
4804
|
-
|
|
5360
|
+
_ts_metadata20("design:returntype", Promise)
|
|
4805
5361
|
], ToolCallController.prototype, "reject", null);
|
|
4806
|
-
|
|
4807
|
-
(0,
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
5362
|
+
_ts_decorate22([
|
|
5363
|
+
(0, import_common23.Post)("answer"),
|
|
5364
|
+
_ts_param20(0, (0, import_common23.Req)()),
|
|
5365
|
+
_ts_param20(1, (0, import_common23.Body)()),
|
|
5366
|
+
_ts_metadata20("design:type", Function),
|
|
5367
|
+
_ts_metadata20("design:paramtypes", [
|
|
4812
5368
|
typeof Request === "undefined" ? Object : Request,
|
|
4813
5369
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
4814
5370
|
]),
|
|
4815
|
-
|
|
5371
|
+
_ts_metadata20("design:returntype", Promise)
|
|
4816
5372
|
], ToolCallController.prototype, "answer", null);
|
|
4817
|
-
|
|
4818
|
-
(0,
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
5373
|
+
_ts_decorate22([
|
|
5374
|
+
(0, import_common23.Post)("skip"),
|
|
5375
|
+
_ts_param20(0, (0, import_common23.Req)()),
|
|
5376
|
+
_ts_param20(1, (0, import_common23.Body)()),
|
|
5377
|
+
_ts_metadata20("design:type", Function),
|
|
5378
|
+
_ts_metadata20("design:paramtypes", [
|
|
4823
5379
|
typeof Request === "undefined" ? Object : Request,
|
|
4824
5380
|
Object
|
|
4825
5381
|
]),
|
|
4826
|
-
|
|
5382
|
+
_ts_metadata20("design:returntype", Promise)
|
|
4827
5383
|
], ToolCallController.prototype, "skip", null);
|
|
4828
|
-
ToolCallController =
|
|
4829
|
-
(0,
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
5384
|
+
ToolCallController = _ts_decorate22([
|
|
5385
|
+
(0, import_common23.Controller)("tool-call"),
|
|
5386
|
+
_ts_param20(1, (0, import_common23.Inject)(import_nestjs_agent_core28.AGENT_ACTOR_RESOLVER)),
|
|
5387
|
+
_ts_metadata20("design:type", Function),
|
|
5388
|
+
_ts_metadata20("design:paramtypes", [
|
|
4833
5389
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
4834
5390
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
4835
5391
|
])
|
|
4836
5392
|
], ToolCallController);
|
|
4837
5393
|
|
|
4838
5394
|
// src/controller/tools.controller.ts
|
|
4839
|
-
var
|
|
4840
|
-
var
|
|
4841
|
-
function
|
|
5395
|
+
var import_nestjs_agent_core29 = require("@dudousxd/nestjs-agent-core");
|
|
5396
|
+
var import_common24 = require("@nestjs/common");
|
|
5397
|
+
function _ts_decorate23(decorators, target, key, desc) {
|
|
4842
5398
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4843
5399
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4844
5400
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4851,19 +5407,19 @@ function _ts_decorate21(decorators, target, key, desc) {
|
|
|
4851
5407
|
}
|
|
4852
5408
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4853
5409
|
}
|
|
4854
|
-
__name(
|
|
4855
|
-
function
|
|
5410
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
5411
|
+
function _ts_metadata21(metadataKey, metadataValue) {
|
|
4856
5412
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4857
5413
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4858
5414
|
}
|
|
4859
5415
|
}
|
|
4860
|
-
__name(
|
|
4861
|
-
function
|
|
5416
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
5417
|
+
function _ts_param21(paramIndex, decorator) {
|
|
4862
5418
|
return function(target, key) {
|
|
4863
5419
|
decorator(target, key, paramIndex);
|
|
4864
5420
|
};
|
|
4865
5421
|
}
|
|
4866
|
-
__name(
|
|
5422
|
+
__name(_ts_param21, "_ts_param");
|
|
4867
5423
|
var ToolsController = class {
|
|
4868
5424
|
static {
|
|
4869
5425
|
__name(this, "ToolsController");
|
|
@@ -4877,11 +5433,11 @@ var ToolsController = class {
|
|
|
4877
5433
|
this.agents = agents;
|
|
4878
5434
|
}
|
|
4879
5435
|
async list(req, agent) {
|
|
4880
|
-
if (agent !== void 0 && agent !==
|
|
4881
|
-
throw new
|
|
5436
|
+
if (agent !== void 0 && agent !== import_nestjs_agent_core29.ALL_AGENTS && this.agents.get(agent) === void 0) {
|
|
5437
|
+
throw new import_common24.NotFoundException(`No agent named "${agent}"`);
|
|
4882
5438
|
}
|
|
4883
5439
|
const actor = await this.actorResolver.resolve(req);
|
|
4884
|
-
const names = agent ===
|
|
5440
|
+
const names = agent === import_nestjs_agent_core29.ALL_AGENTS ? [
|
|
4885
5441
|
void 0,
|
|
4886
5442
|
...this.agents.list().map((definition) => definition.name)
|
|
4887
5443
|
] : [
|
|
@@ -4907,33 +5463,33 @@ var ToolsController = class {
|
|
|
4907
5463
|
];
|
|
4908
5464
|
}
|
|
4909
5465
|
};
|
|
4910
|
-
|
|
4911
|
-
(0,
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
5466
|
+
_ts_decorate23([
|
|
5467
|
+
(0, import_common24.Get)(),
|
|
5468
|
+
_ts_param21(0, (0, import_common24.Req)()),
|
|
5469
|
+
_ts_param21(1, (0, import_common24.Query)("agent")),
|
|
5470
|
+
_ts_metadata21("design:type", Function),
|
|
5471
|
+
_ts_metadata21("design:paramtypes", [
|
|
4916
5472
|
typeof Request === "undefined" ? Object : Request,
|
|
4917
5473
|
String
|
|
4918
5474
|
]),
|
|
4919
|
-
|
|
5475
|
+
_ts_metadata21("design:returntype", Promise)
|
|
4920
5476
|
], ToolsController.prototype, "list", null);
|
|
4921
|
-
ToolsController =
|
|
4922
|
-
(0,
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
5477
|
+
ToolsController = _ts_decorate23([
|
|
5478
|
+
(0, import_common24.Controller)("tools"),
|
|
5479
|
+
_ts_param21(0, (0, import_common24.Inject)(import_nestjs_agent_core29.AGENT_ACTOR_RESOLVER)),
|
|
5480
|
+
_ts_param21(1, (0, import_common24.Inject)(import_nestjs_agent_core29.AGENT_DEPS_FACTORY)),
|
|
5481
|
+
_ts_param21(2, (0, import_common24.Inject)(import_nestjs_agent_core29.AGENT_REGISTRY)),
|
|
5482
|
+
_ts_metadata21("design:type", Function),
|
|
5483
|
+
_ts_metadata21("design:paramtypes", [
|
|
4928
5484
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
4929
5485
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
4930
|
-
typeof
|
|
5486
|
+
typeof import_nestjs_agent_core29.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core29.AgentRegistry
|
|
4931
5487
|
])
|
|
4932
5488
|
], ToolsController);
|
|
4933
5489
|
|
|
4934
5490
|
// src/discovery/agent-discovery.service.ts
|
|
4935
|
-
var
|
|
4936
|
-
var
|
|
5491
|
+
var import_nestjs_agent_core30 = require("@dudousxd/nestjs-agent-core");
|
|
5492
|
+
var import_common25 = require("@nestjs/common");
|
|
4937
5493
|
var import_core = require("@nestjs/core");
|
|
4938
5494
|
|
|
4939
5495
|
// src/decorator/agent.decorator.ts
|
|
@@ -4950,7 +5506,7 @@ var SYSTEM_PROMPT_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:
|
|
|
4950
5506
|
var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
|
|
4951
5507
|
|
|
4952
5508
|
// src/discovery/agent-discovery.service.ts
|
|
4953
|
-
function
|
|
5509
|
+
function _ts_decorate24(decorators, target, key, desc) {
|
|
4954
5510
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4955
5511
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4956
5512
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4963,19 +5519,19 @@ function _ts_decorate22(decorators, target, key, desc) {
|
|
|
4963
5519
|
}
|
|
4964
5520
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4965
5521
|
}
|
|
4966
|
-
__name(
|
|
4967
|
-
function
|
|
5522
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
5523
|
+
function _ts_metadata22(metadataKey, metadataValue) {
|
|
4968
5524
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4969
5525
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4970
5526
|
}
|
|
4971
5527
|
}
|
|
4972
|
-
__name(
|
|
4973
|
-
function
|
|
5528
|
+
__name(_ts_metadata22, "_ts_metadata");
|
|
5529
|
+
function _ts_param22(paramIndex, decorator) {
|
|
4974
5530
|
return function(target, key) {
|
|
4975
5531
|
decorator(target, key, paramIndex);
|
|
4976
5532
|
};
|
|
4977
5533
|
}
|
|
4978
|
-
__name(
|
|
5534
|
+
__name(_ts_param22, "_ts_param");
|
|
4979
5535
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
4980
5536
|
static {
|
|
4981
5537
|
__name(this, "AgentDiscoveryService");
|
|
@@ -4984,7 +5540,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
4984
5540
|
scanner;
|
|
4985
5541
|
registry;
|
|
4986
5542
|
contributors;
|
|
4987
|
-
logger = new
|
|
5543
|
+
logger = new import_common25.Logger(_AgentDiscoveryService.name);
|
|
4988
5544
|
constructor(discovery, scanner, registry, contributors) {
|
|
4989
5545
|
this.discovery = discovery;
|
|
4990
5546
|
this.scanner = scanner;
|
|
@@ -5141,22 +5697,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
5141
5697
|
return (ctx) => candidate.call(instance, ctx);
|
|
5142
5698
|
}
|
|
5143
5699
|
};
|
|
5144
|
-
AgentDiscoveryService =
|
|
5145
|
-
(0,
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5700
|
+
AgentDiscoveryService = _ts_decorate24([
|
|
5701
|
+
(0, import_common25.Injectable)(),
|
|
5702
|
+
_ts_param22(2, (0, import_common25.Inject)(import_nestjs_agent_core30.AGENT_REGISTRY)),
|
|
5703
|
+
_ts_param22(3, (0, import_common25.Inject)(import_nestjs_agent_core30.AGENT_PROMPT_CONTRIBUTORS)),
|
|
5704
|
+
_ts_metadata22("design:type", Function),
|
|
5705
|
+
_ts_metadata22("design:paramtypes", [
|
|
5150
5706
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
5151
5707
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
5152
|
-
typeof
|
|
5708
|
+
typeof import_nestjs_agent_core30.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core30.AgentRegistry,
|
|
5153
5709
|
Array
|
|
5154
5710
|
])
|
|
5155
5711
|
], AgentDiscoveryService);
|
|
5156
5712
|
|
|
5157
5713
|
// src/discovery/ai-tool-discovery.service.ts
|
|
5158
|
-
var
|
|
5159
|
-
var
|
|
5714
|
+
var import_nestjs_agent_core31 = require("@dudousxd/nestjs-agent-core");
|
|
5715
|
+
var import_common26 = require("@nestjs/common");
|
|
5160
5716
|
var import_core2 = require("@nestjs/core");
|
|
5161
5717
|
var import_zod = require("zod");
|
|
5162
5718
|
|
|
@@ -5168,15 +5724,8 @@ function readAiToolMetadata(target) {
|
|
|
5168
5724
|
}
|
|
5169
5725
|
__name(readAiToolMetadata, "readAiToolMetadata");
|
|
5170
5726
|
|
|
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
5727
|
// src/discovery/ai-tool-discovery.service.ts
|
|
5179
|
-
function
|
|
5728
|
+
function _ts_decorate25(decorators, target, key, desc) {
|
|
5180
5729
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5181
5730
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5182
5731
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5189,19 +5738,19 @@ function _ts_decorate23(decorators, target, key, desc) {
|
|
|
5189
5738
|
}
|
|
5190
5739
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5191
5740
|
}
|
|
5192
|
-
__name(
|
|
5193
|
-
function
|
|
5741
|
+
__name(_ts_decorate25, "_ts_decorate");
|
|
5742
|
+
function _ts_metadata23(metadataKey, metadataValue) {
|
|
5194
5743
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5195
5744
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
5196
5745
|
}
|
|
5197
5746
|
}
|
|
5198
|
-
__name(
|
|
5199
|
-
function
|
|
5747
|
+
__name(_ts_metadata23, "_ts_metadata");
|
|
5748
|
+
function _ts_param23(paramIndex, decorator) {
|
|
5200
5749
|
return function(target, key) {
|
|
5201
5750
|
decorator(target, key, paramIndex);
|
|
5202
5751
|
};
|
|
5203
5752
|
}
|
|
5204
|
-
__name(
|
|
5753
|
+
__name(_ts_param23, "_ts_param");
|
|
5205
5754
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
5206
5755
|
static {
|
|
5207
5756
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -5210,7 +5759,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5210
5759
|
registry;
|
|
5211
5760
|
agents;
|
|
5212
5761
|
options;
|
|
5213
|
-
logger = new
|
|
5762
|
+
logger = new import_common26.Logger(_AiToolDiscoveryService.name);
|
|
5214
5763
|
constructor(discovery, registry, agents, options) {
|
|
5215
5764
|
this.discovery = discovery;
|
|
5216
5765
|
this.registry = registry;
|
|
@@ -5269,9 +5818,18 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5269
5818
|
} : {},
|
|
5270
5819
|
...meta.terminal === true ? {
|
|
5271
5820
|
terminal: true
|
|
5821
|
+
} : {},
|
|
5822
|
+
...meta.replacementKey !== void 0 ? {
|
|
5823
|
+
replacementKey: meta.replacementKey
|
|
5272
5824
|
} : {}
|
|
5273
5825
|
}, {
|
|
5274
5826
|
execute: /* @__PURE__ */ __name((input, ctx) => instance.execute(input, ctx), "execute"),
|
|
5827
|
+
...typeof handler.present === "function" ? {
|
|
5828
|
+
present: /* @__PURE__ */ __name((output, ctx) => instance.present(output, ctx), "present")
|
|
5829
|
+
} : {},
|
|
5830
|
+
...typeof handler.preflight === "function" ? {
|
|
5831
|
+
preflight: /* @__PURE__ */ __name((input, ctx, options) => instance.preflight(input, ctx, options), "preflight")
|
|
5832
|
+
} : {},
|
|
5275
5833
|
// Forwarded, not copied: the registry holds this wrapper rather than the provider, so an
|
|
5276
5834
|
// `isEnabled()`/`canUse()` left behind here would be a gate that silently never applies.
|
|
5277
5835
|
// Called through `instance` so each keeps its `this` (and its injected deps).
|
|
@@ -5295,7 +5853,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5295
5853
|
let delegates = 0;
|
|
5296
5854
|
for (const definition of this.agents.list()) {
|
|
5297
5855
|
for (const edge of definition.delegatesTo ?? []) {
|
|
5298
|
-
const { agent: target, detached } = (0,
|
|
5856
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core31.normalizeDelegation)(edge);
|
|
5299
5857
|
const targetDefinition = this.agents.get(target);
|
|
5300
5858
|
if (targetDefinition === void 0) {
|
|
5301
5859
|
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 +5903,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5345
5903
|
return true;
|
|
5346
5904
|
}
|
|
5347
5905
|
};
|
|
5348
|
-
AiToolDiscoveryService =
|
|
5349
|
-
(0,
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5906
|
+
AiToolDiscoveryService = _ts_decorate25([
|
|
5907
|
+
(0, import_common26.Injectable)(),
|
|
5908
|
+
_ts_param23(1, (0, import_common26.Inject)(import_nestjs_agent_core31.AGENT_TOOL_REGISTRY)),
|
|
5909
|
+
_ts_param23(2, (0, import_common26.Inject)(import_nestjs_agent_core31.AGENT_REGISTRY)),
|
|
5910
|
+
_ts_param23(3, (0, import_common26.Inject)(import_nestjs_agent_core31.AGENT_OPTIONS)),
|
|
5911
|
+
_ts_metadata23("design:type", Function),
|
|
5912
|
+
_ts_metadata23("design:paramtypes", [
|
|
5355
5913
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
5356
5914
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
5357
5915
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -5360,25 +5918,25 @@ AiToolDiscoveryService = _ts_decorate23([
|
|
|
5360
5918
|
], AiToolDiscoveryService);
|
|
5361
5919
|
|
|
5362
5920
|
// src/discovery/skill-discovery.service.ts
|
|
5363
|
-
var
|
|
5364
|
-
var
|
|
5921
|
+
var import_nestjs_agent_core33 = require("@dudousxd/nestjs-agent-core");
|
|
5922
|
+
var import_common27 = require("@nestjs/common");
|
|
5365
5923
|
var import_core3 = require("@nestjs/core");
|
|
5366
5924
|
|
|
5367
5925
|
// src/decorator/skill.decorator.ts
|
|
5368
5926
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
5369
|
-
var
|
|
5927
|
+
var import_nestjs_agent_core32 = require("@dudousxd/nestjs-agent-core");
|
|
5370
5928
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
5371
5929
|
function readSkillMetadata(target) {
|
|
5372
5930
|
return Reflect.getMetadata(SKILL_METADATA, target);
|
|
5373
5931
|
}
|
|
5374
5932
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
5375
5933
|
function skillScope(options) {
|
|
5376
|
-
return options.scope ??
|
|
5934
|
+
return options.scope ?? import_nestjs_agent_core32.GLOBAL_SCOPE;
|
|
5377
5935
|
}
|
|
5378
5936
|
__name(skillScope, "skillScope");
|
|
5379
5937
|
|
|
5380
5938
|
// src/discovery/skill-discovery.service.ts
|
|
5381
|
-
function
|
|
5939
|
+
function _ts_decorate26(decorators, target, key, desc) {
|
|
5382
5940
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5383
5941
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5384
5942
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5391,26 +5949,26 @@ function _ts_decorate24(decorators, target, key, desc) {
|
|
|
5391
5949
|
}
|
|
5392
5950
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5393
5951
|
}
|
|
5394
|
-
__name(
|
|
5395
|
-
function
|
|
5952
|
+
__name(_ts_decorate26, "_ts_decorate");
|
|
5953
|
+
function _ts_metadata24(metadataKey, metadataValue) {
|
|
5396
5954
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5397
5955
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
5398
5956
|
}
|
|
5399
5957
|
}
|
|
5400
|
-
__name(
|
|
5401
|
-
function
|
|
5958
|
+
__name(_ts_metadata24, "_ts_metadata");
|
|
5959
|
+
function _ts_param24(paramIndex, decorator) {
|
|
5402
5960
|
return function(target, key) {
|
|
5403
5961
|
decorator(target, key, paramIndex);
|
|
5404
5962
|
};
|
|
5405
5963
|
}
|
|
5406
|
-
__name(
|
|
5964
|
+
__name(_ts_param24, "_ts_param");
|
|
5407
5965
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
5408
5966
|
static {
|
|
5409
5967
|
__name(this, "SkillDiscoveryService");
|
|
5410
5968
|
}
|
|
5411
5969
|
discovery;
|
|
5412
5970
|
declared;
|
|
5413
|
-
logger = new
|
|
5971
|
+
logger = new import_common27.Logger(_SkillDiscoveryService.name);
|
|
5414
5972
|
constructor(discovery, declared) {
|
|
5415
5973
|
this.discovery = discovery;
|
|
5416
5974
|
this.declared = declared;
|
|
@@ -5447,18 +6005,18 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
5447
6005
|
return flat === void 0 ? void 0 : () => flat;
|
|
5448
6006
|
}
|
|
5449
6007
|
};
|
|
5450
|
-
SkillDiscoveryService =
|
|
5451
|
-
(0,
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
6008
|
+
SkillDiscoveryService = _ts_decorate26([
|
|
6009
|
+
(0, import_common27.Injectable)(),
|
|
6010
|
+
_ts_param24(1, (0, import_common27.Inject)(import_nestjs_agent_core33.AGENT_SKILL_SOURCES)),
|
|
6011
|
+
_ts_metadata24("design:type", Function),
|
|
6012
|
+
_ts_metadata24("design:paramtypes", [
|
|
5455
6013
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
5456
6014
|
Array
|
|
5457
6015
|
])
|
|
5458
6016
|
], SkillDiscoveryService);
|
|
5459
6017
|
|
|
5460
6018
|
// src/ledger-quota-provider.ts
|
|
5461
|
-
var
|
|
6019
|
+
var import_nestjs_agent_core34 = require("@dudousxd/nestjs-agent-core");
|
|
5462
6020
|
var LedgerQuotaProvider = class {
|
|
5463
6021
|
static {
|
|
5464
6022
|
__name(this, "LedgerQuotaProvider");
|
|
@@ -5478,12 +6036,12 @@ var LedgerQuotaProvider = class {
|
|
|
5478
6036
|
await this.dayWindow(actorRef, now)
|
|
5479
6037
|
];
|
|
5480
6038
|
if (this.store.usageBetween !== void 0) {
|
|
5481
|
-
const range = (0,
|
|
6039
|
+
const range = (0, import_nestjs_agent_core34.quotaPeriodRange)("month", now);
|
|
5482
6040
|
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
5483
6041
|
windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
|
|
5484
6042
|
}
|
|
5485
|
-
const blocked = (0,
|
|
5486
|
-
const warning = (0,
|
|
6043
|
+
const blocked = (0, import_nestjs_agent_core34.exhaustedWindow)(windows);
|
|
6044
|
+
const warning = (0, import_nestjs_agent_core34.quotaWarning)(windows);
|
|
5487
6045
|
return {
|
|
5488
6046
|
windows,
|
|
5489
6047
|
...blocked !== void 0 ? {
|
|
@@ -5495,7 +6053,7 @@ var LedgerQuotaProvider = class {
|
|
|
5495
6053
|
};
|
|
5496
6054
|
}
|
|
5497
6055
|
async dayWindow(actorRef, now) {
|
|
5498
|
-
const range = (0,
|
|
6056
|
+
const range = (0, import_nestjs_agent_core34.quotaPeriodRange)("day", now);
|
|
5499
6057
|
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
5500
6058
|
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
5501
6059
|
}
|
|
@@ -5519,10 +6077,245 @@ var LedgerQuotaProvider = class {
|
|
|
5519
6077
|
}
|
|
5520
6078
|
};
|
|
5521
6079
|
|
|
6080
|
+
// src/proposals/action-proposal-worker.service.ts
|
|
6081
|
+
var import_node_crypto3 = require("crypto");
|
|
6082
|
+
var import_nestjs_agent_core35 = require("@dudousxd/nestjs-agent-core");
|
|
6083
|
+
var import_common28 = require("@nestjs/common");
|
|
6084
|
+
function _ts_decorate27(decorators, target, key, desc) {
|
|
6085
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6086
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
6087
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
6088
|
+
} else {
|
|
6089
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
6090
|
+
if (d = decorators[i]) {
|
|
6091
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6092
|
+
}
|
|
6093
|
+
}
|
|
6094
|
+
}
|
|
6095
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6096
|
+
}
|
|
6097
|
+
__name(_ts_decorate27, "_ts_decorate");
|
|
6098
|
+
function _ts_metadata25(metadataKey, metadataValue) {
|
|
6099
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
6100
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
6101
|
+
}
|
|
6102
|
+
}
|
|
6103
|
+
__name(_ts_metadata25, "_ts_metadata");
|
|
6104
|
+
function _ts_param25(paramIndex, decorator) {
|
|
6105
|
+
return function(target, key) {
|
|
6106
|
+
decorator(target, key, paramIndex);
|
|
6107
|
+
};
|
|
6108
|
+
}
|
|
6109
|
+
__name(_ts_param25, "_ts_param");
|
|
6110
|
+
var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
6111
|
+
static {
|
|
6112
|
+
__name(this, "ActionProposalWorkerService");
|
|
6113
|
+
}
|
|
6114
|
+
store;
|
|
6115
|
+
options;
|
|
6116
|
+
deps;
|
|
6117
|
+
worker;
|
|
6118
|
+
logger = new import_common28.Logger(_ActionProposalWorkerService.name);
|
|
6119
|
+
constructor(store, options, deps) {
|
|
6120
|
+
this.store = store;
|
|
6121
|
+
this.options = options;
|
|
6122
|
+
this.deps = deps;
|
|
6123
|
+
}
|
|
6124
|
+
onModuleInit() {
|
|
6125
|
+
if (this.options.actionApprovalMode !== "independent") return;
|
|
6126
|
+
(0, import_nestjs_agent_core35.assertIndependentActionCapabilities)(this.store, this.options.backgroundActorResolver);
|
|
6127
|
+
if (this.options.surface === "http") return;
|
|
6128
|
+
const resolver = this.options.backgroundActorResolver;
|
|
6129
|
+
if (!resolver) throw new Error("BackgroundActorResolver is required");
|
|
6130
|
+
this.worker = new import_nestjs_agent_core35.ActionProposalWorker({
|
|
6131
|
+
store: this.store,
|
|
6132
|
+
workerId: (0, import_node_crypto3.randomUUID)(),
|
|
6133
|
+
...this.options.actionProposalWorker,
|
|
6134
|
+
executor: new import_nestjs_agent_core35.ActionProposalExecutor({
|
|
6135
|
+
resolver,
|
|
6136
|
+
resolveExecution: /* @__PURE__ */ __name(async (proposal, actor) => {
|
|
6137
|
+
const deps = this.deps.forProposal(proposal, actor);
|
|
6138
|
+
return {
|
|
6139
|
+
registry: deps.registry,
|
|
6140
|
+
rolesPolicy: deps.rolesPolicy,
|
|
6141
|
+
...deps.resolveUiCatalog !== void 0 ? {
|
|
6142
|
+
resolveUiCatalog: deps.resolveUiCatalog
|
|
6143
|
+
} : {},
|
|
6144
|
+
...deps.toolAllowList !== void 0 ? {
|
|
6145
|
+
allowedTools: deps.toolAllowList
|
|
6146
|
+
} : {}
|
|
6147
|
+
};
|
|
6148
|
+
}, "resolveExecution")
|
|
6149
|
+
}),
|
|
6150
|
+
onError: /* @__PURE__ */ __name((error) => this.logger.error(error), "onError")
|
|
6151
|
+
});
|
|
6152
|
+
this.worker.start();
|
|
6153
|
+
}
|
|
6154
|
+
async onModuleDestroy() {
|
|
6155
|
+
await this.worker?.stop();
|
|
6156
|
+
}
|
|
6157
|
+
};
|
|
6158
|
+
ActionProposalWorkerService = _ts_decorate27([
|
|
6159
|
+
(0, import_common28.Injectable)(),
|
|
6160
|
+
_ts_param25(0, (0, import_common28.Inject)(import_nestjs_agent_core35.AGENT_STORE)),
|
|
6161
|
+
_ts_param25(1, (0, import_common28.Inject)(import_nestjs_agent_core35.AGENT_OPTIONS)),
|
|
6162
|
+
_ts_param25(2, (0, import_common28.Inject)(import_nestjs_agent_core35.AGENT_DEPS_FACTORY)),
|
|
6163
|
+
_ts_metadata25("design:type", Function),
|
|
6164
|
+
_ts_metadata25("design:paramtypes", [
|
|
6165
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
6166
|
+
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
6167
|
+
typeof AgentDepsFactory2 === "undefined" ? Object : AgentDepsFactory2
|
|
6168
|
+
])
|
|
6169
|
+
], ActionProposalWorkerService);
|
|
6170
|
+
|
|
6171
|
+
// src/proposals/action-proposal.controller.ts
|
|
6172
|
+
var import_nestjs_agent_core36 = require("@dudousxd/nestjs-agent-core");
|
|
6173
|
+
var import_common29 = require("@nestjs/common");
|
|
6174
|
+
function _ts_decorate28(decorators, target, key, desc) {
|
|
6175
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6176
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
6177
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
6178
|
+
} else {
|
|
6179
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
6180
|
+
if (d = decorators[i]) {
|
|
6181
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6182
|
+
}
|
|
6183
|
+
}
|
|
6184
|
+
}
|
|
6185
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6186
|
+
}
|
|
6187
|
+
__name(_ts_decorate28, "_ts_decorate");
|
|
6188
|
+
function _ts_metadata26(metadataKey, metadataValue) {
|
|
6189
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
6190
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
6191
|
+
}
|
|
6192
|
+
}
|
|
6193
|
+
__name(_ts_metadata26, "_ts_metadata");
|
|
6194
|
+
function _ts_param26(paramIndex, decorator) {
|
|
6195
|
+
return function(target, key) {
|
|
6196
|
+
decorator(target, key, paramIndex);
|
|
6197
|
+
};
|
|
6198
|
+
}
|
|
6199
|
+
__name(_ts_param26, "_ts_param");
|
|
6200
|
+
function bodyFields(body, field) {
|
|
6201
|
+
if (body === void 0) return {};
|
|
6202
|
+
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`);
|
|
6203
|
+
const value = body;
|
|
6204
|
+
if (value[field] !== void 0 && (field === "remember" && typeof value[field] !== "boolean" || field === "reason" && typeof value[field] !== "string")) throw new import_common29.BadRequestException(`Invalid ${field}`);
|
|
6205
|
+
return value;
|
|
6206
|
+
}
|
|
6207
|
+
__name(bodyFields, "bodyFields");
|
|
6208
|
+
var ActionProposalController = class {
|
|
6209
|
+
static {
|
|
6210
|
+
__name(this, "ActionProposalController");
|
|
6211
|
+
}
|
|
6212
|
+
proposals;
|
|
6213
|
+
actors;
|
|
6214
|
+
constructor(proposals, actors) {
|
|
6215
|
+
this.proposals = proposals;
|
|
6216
|
+
this.actors = actors;
|
|
6217
|
+
}
|
|
6218
|
+
async list(threadId, request, cursor, response) {
|
|
6219
|
+
let query = {};
|
|
6220
|
+
if (cursor !== void 0) {
|
|
6221
|
+
try {
|
|
6222
|
+
if (typeof cursor !== "string") throw new Error("Invalid cursor");
|
|
6223
|
+
query = {
|
|
6224
|
+
after: JSON.parse(cursor)
|
|
6225
|
+
};
|
|
6226
|
+
(0, import_nestjs_agent_core36.validateActionProposalListQuery)(query);
|
|
6227
|
+
} catch {
|
|
6228
|
+
throw new import_common29.BadRequestException("Invalid action proposal cursor");
|
|
6229
|
+
}
|
|
6230
|
+
}
|
|
6231
|
+
const page = await this.proposals.listPage(threadId, await this.actors.resolve(request), query);
|
|
6232
|
+
if (page.next) {
|
|
6233
|
+
response.setHeader("X-Action-Proposals-Next", encodeURIComponent(JSON.stringify(page.next)));
|
|
6234
|
+
const exposed = response.getHeader("Access-Control-Expose-Headers");
|
|
6235
|
+
response.setHeader("Access-Control-Expose-Headers", `${exposed === void 0 ? "" : `${String(exposed)}, `}X-Action-Proposals-Next`);
|
|
6236
|
+
}
|
|
6237
|
+
return page.items;
|
|
6238
|
+
}
|
|
6239
|
+
async approve(threadId, proposalId, request, body) {
|
|
6240
|
+
const value = bodyFields(body, "remember");
|
|
6241
|
+
return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
|
|
6242
|
+
decision: "approved",
|
|
6243
|
+
...typeof value.remember === "boolean" ? {
|
|
6244
|
+
remember: value.remember
|
|
6245
|
+
} : {}
|
|
6246
|
+
});
|
|
6247
|
+
}
|
|
6248
|
+
async reject(threadId, proposalId, request, body) {
|
|
6249
|
+
const value = bodyFields(body, "reason");
|
|
6250
|
+
return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
|
|
6251
|
+
decision: "rejected",
|
|
6252
|
+
...typeof value.reason === "string" ? {
|
|
6253
|
+
reason: value.reason
|
|
6254
|
+
} : {}
|
|
6255
|
+
});
|
|
6256
|
+
}
|
|
6257
|
+
};
|
|
6258
|
+
_ts_decorate28([
|
|
6259
|
+
(0, import_common29.Get)(),
|
|
6260
|
+
_ts_param26(0, (0, import_common29.Param)("threadId")),
|
|
6261
|
+
_ts_param26(1, (0, import_common29.Req)()),
|
|
6262
|
+
_ts_param26(2, (0, import_common29.Query)("after")),
|
|
6263
|
+
_ts_param26(3, (0, import_common29.Res)({
|
|
6264
|
+
passthrough: true
|
|
6265
|
+
})),
|
|
6266
|
+
_ts_metadata26("design:type", Function),
|
|
6267
|
+
_ts_metadata26("design:paramtypes", [
|
|
6268
|
+
String,
|
|
6269
|
+
typeof Request === "undefined" ? Object : Request,
|
|
6270
|
+
Object,
|
|
6271
|
+
typeof Response === "undefined" ? Object : Response
|
|
6272
|
+
]),
|
|
6273
|
+
_ts_metadata26("design:returntype", Promise)
|
|
6274
|
+
], ActionProposalController.prototype, "list", null);
|
|
6275
|
+
_ts_decorate28([
|
|
6276
|
+
(0, import_common29.Post)(":proposalId/approve"),
|
|
6277
|
+
_ts_param26(0, (0, import_common29.Param)("threadId")),
|
|
6278
|
+
_ts_param26(1, (0, import_common29.Param)("proposalId")),
|
|
6279
|
+
_ts_param26(2, (0, import_common29.Req)()),
|
|
6280
|
+
_ts_param26(3, (0, import_common29.Body)()),
|
|
6281
|
+
_ts_metadata26("design:type", Function),
|
|
6282
|
+
_ts_metadata26("design:paramtypes", [
|
|
6283
|
+
String,
|
|
6284
|
+
String,
|
|
6285
|
+
typeof Request === "undefined" ? Object : Request,
|
|
6286
|
+
Object
|
|
6287
|
+
]),
|
|
6288
|
+
_ts_metadata26("design:returntype", Promise)
|
|
6289
|
+
], ActionProposalController.prototype, "approve", null);
|
|
6290
|
+
_ts_decorate28([
|
|
6291
|
+
(0, import_common29.Post)(":proposalId/reject"),
|
|
6292
|
+
_ts_param26(0, (0, import_common29.Param)("threadId")),
|
|
6293
|
+
_ts_param26(1, (0, import_common29.Param)("proposalId")),
|
|
6294
|
+
_ts_param26(2, (0, import_common29.Req)()),
|
|
6295
|
+
_ts_param26(3, (0, import_common29.Body)()),
|
|
6296
|
+
_ts_metadata26("design:type", Function),
|
|
6297
|
+
_ts_metadata26("design:paramtypes", [
|
|
6298
|
+
String,
|
|
6299
|
+
String,
|
|
6300
|
+
typeof Request === "undefined" ? Object : Request,
|
|
6301
|
+
Object
|
|
6302
|
+
]),
|
|
6303
|
+
_ts_metadata26("design:returntype", Promise)
|
|
6304
|
+
], ActionProposalController.prototype, "reject", null);
|
|
6305
|
+
ActionProposalController = _ts_decorate28([
|
|
6306
|
+
(0, import_common29.Controller)("threads/:threadId/action-proposals"),
|
|
6307
|
+
_ts_param26(1, (0, import_common29.Inject)(import_nestjs_agent_core36.AGENT_ACTOR_RESOLVER)),
|
|
6308
|
+
_ts_metadata26("design:type", Function),
|
|
6309
|
+
_ts_metadata26("design:paramtypes", [
|
|
6310
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService,
|
|
6311
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
6312
|
+
])
|
|
6313
|
+
], ActionProposalController);
|
|
6314
|
+
|
|
5522
6315
|
// src/runner/inline-agent-runner.ts
|
|
5523
|
-
var
|
|
5524
|
-
var
|
|
5525
|
-
function
|
|
6316
|
+
var import_nestjs_agent_core37 = require("@dudousxd/nestjs-agent-core");
|
|
6317
|
+
var import_common30 = require("@nestjs/common");
|
|
6318
|
+
function _ts_decorate29(decorators, target, key, desc) {
|
|
5526
6319
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5527
6320
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5528
6321
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5535,19 +6328,19 @@ function _ts_decorate25(decorators, target, key, desc) {
|
|
|
5535
6328
|
}
|
|
5536
6329
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5537
6330
|
}
|
|
5538
|
-
__name(
|
|
5539
|
-
function
|
|
6331
|
+
__name(_ts_decorate29, "_ts_decorate");
|
|
6332
|
+
function _ts_metadata27(metadataKey, metadataValue) {
|
|
5540
6333
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5541
6334
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
5542
6335
|
}
|
|
5543
6336
|
}
|
|
5544
|
-
__name(
|
|
5545
|
-
function
|
|
6337
|
+
__name(_ts_metadata27, "_ts_metadata");
|
|
6338
|
+
function _ts_param27(paramIndex, decorator) {
|
|
5546
6339
|
return function(target, key) {
|
|
5547
6340
|
decorator(target, key, paramIndex);
|
|
5548
6341
|
};
|
|
5549
6342
|
}
|
|
5550
|
-
__name(
|
|
6343
|
+
__name(_ts_param27, "_ts_param");
|
|
5551
6344
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
5552
6345
|
static {
|
|
5553
6346
|
__name(this, "InlineAgentRunner");
|
|
@@ -5555,7 +6348,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5555
6348
|
factory;
|
|
5556
6349
|
store;
|
|
5557
6350
|
queue;
|
|
5558
|
-
logger = new
|
|
6351
|
+
logger = new import_common30.Logger(_InlineAgentRunner.name);
|
|
5559
6352
|
pending = /* @__PURE__ */ new Map();
|
|
5560
6353
|
/**
|
|
5561
6354
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -5604,18 +6397,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5604
6397
|
],
|
|
5605
6398
|
input
|
|
5606
6399
|
});
|
|
5607
|
-
void (0,
|
|
6400
|
+
void (0, import_nestjs_agent_core37.runAgentLoop)({
|
|
5608
6401
|
...deps,
|
|
5609
6402
|
day
|
|
5610
|
-
}, input, hooks).then(() => (0,
|
|
5611
|
-
if (error instanceof
|
|
6403
|
+
}, input, hooks).then(() => (0, import_nestjs_agent_core37.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
|
|
6404
|
+
if (error instanceof import_nestjs_agent_core37.RunCancelledError) {
|
|
5612
6405
|
await this.settleCancelled(runId, input, deps);
|
|
5613
6406
|
return;
|
|
5614
6407
|
}
|
|
5615
6408
|
const message = error instanceof Error ? error.message : String(error);
|
|
5616
|
-
const code = (0,
|
|
6409
|
+
const code = (0, import_nestjs_agent_core37.agentFailureCode)(error);
|
|
5617
6410
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
5618
|
-
(0,
|
|
6411
|
+
(0, import_nestjs_agent_core37.publishAgentRunFailed)({
|
|
5619
6412
|
runId,
|
|
5620
6413
|
code,
|
|
5621
6414
|
message
|
|
@@ -5626,11 +6419,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5626
6419
|
errorCode: code,
|
|
5627
6420
|
errorMessage: message
|
|
5628
6421
|
});
|
|
5629
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
6422
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core37.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
5630
6423
|
const writer = await deps.sink.open(runId);
|
|
5631
6424
|
await this.settleQueue(writer, input, runId, "failed", message);
|
|
5632
|
-
await (0,
|
|
5633
|
-
await writer.fail((0,
|
|
6425
|
+
await (0, import_nestjs_agent_core37.releaseThreadRun)(this.store, input.threadId, runId);
|
|
6426
|
+
await writer.fail((0, import_nestjs_agent_core37.streamFailure)(error));
|
|
5634
6427
|
}).finally(() => {
|
|
5635
6428
|
this.cancelled.delete(runId);
|
|
5636
6429
|
this.live.delete(runId);
|
|
@@ -5666,7 +6459,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5666
6459
|
for (const [key, waiter] of this.pending) {
|
|
5667
6460
|
if (key.startsWith(`${runId}:`)) {
|
|
5668
6461
|
this.pending.delete(key);
|
|
5669
|
-
waiter.reject(new
|
|
6462
|
+
waiter.reject(new import_nestjs_agent_core37.RunCancelledError());
|
|
5670
6463
|
}
|
|
5671
6464
|
}
|
|
5672
6465
|
await Promise.resolve();
|
|
@@ -5681,8 +6474,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5681
6474
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
5682
6475
|
const writer = await deps.sink.open(runId);
|
|
5683
6476
|
await this.settleQueue(writer, input, runId, "cancelled");
|
|
5684
|
-
await (0,
|
|
5685
|
-
await writer.write((0,
|
|
6477
|
+
await (0, import_nestjs_agent_core37.releaseThreadRun)(this.store, input.threadId, runId);
|
|
6478
|
+
await writer.write((0, import_nestjs_agent_core37.encodeStreamEvent)({
|
|
5686
6479
|
kind: "cancelled"
|
|
5687
6480
|
}));
|
|
5688
6481
|
await writer.end();
|
|
@@ -5717,7 +6510,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5717
6510
|
runId: nextRunId
|
|
5718
6511
|
}));
|
|
5719
6512
|
if (frame !== void 0) {
|
|
5720
|
-
await writer.write((0,
|
|
6513
|
+
await writer.write((0, import_nestjs_agent_core37.encodeStreamEvent)(frame));
|
|
5721
6514
|
}
|
|
5722
6515
|
} catch (failure) {
|
|
5723
6516
|
this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
@@ -5788,7 +6581,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5788
6581
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
5789
6582
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
5790
6583
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
5791
|
-
parallel:
|
|
6584
|
+
parallel: import_nestjs_agent_core37.settleAll,
|
|
5792
6585
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
5793
6586
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
5794
6587
|
agentName,
|
|
@@ -5839,7 +6632,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5839
6632
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
5840
6633
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
5841
6634
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
5842
|
-
parallel:
|
|
6635
|
+
parallel: import_nestjs_agent_core37.settleAll,
|
|
5843
6636
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
5844
6637
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
5845
6638
|
agentName: childName,
|
|
@@ -5872,7 +6665,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5872
6665
|
}
|
|
5873
6666
|
}), "startAgent")
|
|
5874
6667
|
};
|
|
5875
|
-
void (0,
|
|
6668
|
+
void (0, import_nestjs_agent_core37.runAgentLoop)({
|
|
5876
6669
|
...deps,
|
|
5877
6670
|
day
|
|
5878
6671
|
}, {
|
|
@@ -5886,13 +6679,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5886
6679
|
parentRunId,
|
|
5887
6680
|
deliverTo
|
|
5888
6681
|
}, hooks).catch(async (error) => {
|
|
5889
|
-
const cancelled = error instanceof
|
|
6682
|
+
const cancelled = error instanceof import_nestjs_agent_core37.RunCancelledError;
|
|
5890
6683
|
const message = error instanceof Error ? error.message : String(error);
|
|
5891
6684
|
if (!cancelled) {
|
|
5892
6685
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
5893
|
-
(0,
|
|
6686
|
+
(0, import_nestjs_agent_core37.publishAgentRunFailed)({
|
|
5894
6687
|
runId,
|
|
5895
|
-
code: (0,
|
|
6688
|
+
code: (0, import_nestjs_agent_core37.agentFailureCode)(error),
|
|
5896
6689
|
message
|
|
5897
6690
|
});
|
|
5898
6691
|
}
|
|
@@ -5900,12 +6693,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5900
6693
|
runId,
|
|
5901
6694
|
status: cancelled ? "cancelled" : "failed",
|
|
5902
6695
|
...cancelled ? {} : {
|
|
5903
|
-
errorCode: (0,
|
|
6696
|
+
errorCode: (0, import_nestjs_agent_core37.agentFailureCode)(error),
|
|
5904
6697
|
errorMessage: message
|
|
5905
6698
|
}
|
|
5906
6699
|
});
|
|
5907
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
5908
|
-
await (0,
|
|
6700
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core37.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
6701
|
+
await (0, import_nestjs_agent_core37.settleUnsettledDelegation)({
|
|
5909
6702
|
store: this.store,
|
|
5910
6703
|
delivery: deliverTo,
|
|
5911
6704
|
agent: agentName,
|
|
@@ -5944,7 +6737,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5944
6737
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
5945
6738
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
5946
6739
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
5947
|
-
parallel:
|
|
6740
|
+
parallel: import_nestjs_agent_core37.settleAll,
|
|
5948
6741
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
5949
6742
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
5950
6743
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -5979,7 +6772,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5979
6772
|
}), "startAgent")
|
|
5980
6773
|
};
|
|
5981
6774
|
try {
|
|
5982
|
-
return await (0,
|
|
6775
|
+
return await (0, import_nestjs_agent_core37.runAgentLoop)({
|
|
5983
6776
|
...deps,
|
|
5984
6777
|
day
|
|
5985
6778
|
}, {
|
|
@@ -5998,13 +6791,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5998
6791
|
}
|
|
5999
6792
|
}
|
|
6000
6793
|
};
|
|
6001
|
-
InlineAgentRunner =
|
|
6002
|
-
(0,
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6794
|
+
InlineAgentRunner = _ts_decorate29([
|
|
6795
|
+
(0, import_common30.Injectable)(),
|
|
6796
|
+
_ts_param27(0, (0, import_common30.Inject)(import_nestjs_agent_core37.AGENT_DEPS_FACTORY)),
|
|
6797
|
+
_ts_param27(1, (0, import_common30.Inject)(import_nestjs_agent_core37.AGENT_STORE)),
|
|
6798
|
+
_ts_param27(2, (0, import_common30.Optional)()),
|
|
6799
|
+
_ts_metadata27("design:type", Function),
|
|
6800
|
+
_ts_metadata27("design:paramtypes", [
|
|
6008
6801
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
6009
6802
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
6010
6803
|
typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2
|
|
@@ -6016,7 +6809,7 @@ function isThreadTurn2(input) {
|
|
|
6016
6809
|
__name(isThreadTurn2, "isThreadTurn");
|
|
6017
6810
|
|
|
6018
6811
|
// src/skills-config.ts
|
|
6019
|
-
var
|
|
6812
|
+
var import_nestjs_agent_core38 = require("@dudousxd/nestjs-agent-core");
|
|
6020
6813
|
function declaredSkillProvider(declared) {
|
|
6021
6814
|
return {
|
|
6022
6815
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -6042,7 +6835,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
6042
6835
|
declaredSkillProvider(declared)
|
|
6043
6836
|
];
|
|
6044
6837
|
return {
|
|
6045
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
6838
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core38.compositeSkillProvider)(providers),
|
|
6046
6839
|
...options.scopes !== void 0 ? {
|
|
6047
6840
|
scopes: options.scopes
|
|
6048
6841
|
} : {},
|
|
@@ -6054,7 +6847,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
6054
6847
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
6055
6848
|
|
|
6056
6849
|
// src/agent.module.ts
|
|
6057
|
-
function
|
|
6850
|
+
function _ts_decorate30(decorators, target, key, desc) {
|
|
6058
6851
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6059
6852
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
6060
6853
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -6067,18 +6860,18 @@ function _ts_decorate26(decorators, target, key, desc) {
|
|
|
6067
6860
|
}
|
|
6068
6861
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6069
6862
|
}
|
|
6070
|
-
__name(
|
|
6863
|
+
__name(_ts_decorate30, "_ts_decorate");
|
|
6071
6864
|
var DEFAULT_PATH = "agent";
|
|
6072
|
-
var logger = new
|
|
6073
|
-
function
|
|
6865
|
+
var logger = new import_common31.Logger("AgentModule");
|
|
6866
|
+
function externalWrapper(modules, token) {
|
|
6074
6867
|
for (const module2 of modules.values()) {
|
|
6075
6868
|
if (module2.metatype === AgentModule) continue;
|
|
6076
|
-
const wrapper = module2.providers.get(
|
|
6869
|
+
const wrapper = module2.providers.get(token);
|
|
6077
6870
|
if (wrapper !== void 0) return wrapper;
|
|
6078
6871
|
}
|
|
6079
6872
|
return void 0;
|
|
6080
6873
|
}
|
|
6081
|
-
__name(
|
|
6874
|
+
__name(externalWrapper, "externalWrapper");
|
|
6082
6875
|
function forwardingStore(wrapper) {
|
|
6083
6876
|
const target = /* @__PURE__ */ __name(() => {
|
|
6084
6877
|
const instance = wrapper.instance;
|
|
@@ -6101,12 +6894,36 @@ function forwardingStore(wrapper) {
|
|
|
6101
6894
|
__name(forwardingStore, "forwardingStore");
|
|
6102
6895
|
function resolveStore(options, modules) {
|
|
6103
6896
|
if (options.store !== void 0) return options.store;
|
|
6104
|
-
const external =
|
|
6897
|
+
const external = externalWrapper(modules, import_nestjs_agent_core39.AGENT_STORE);
|
|
6105
6898
|
if (external !== void 0) return forwardingStore(external);
|
|
6106
6899
|
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
|
|
6900
|
+
return new import_nestjs_agent_core39.InMemoryAgentStore();
|
|
6108
6901
|
}
|
|
6109
6902
|
__name(resolveStore, "resolveStore");
|
|
6903
|
+
function resolveRolesPolicy(options, modules) {
|
|
6904
|
+
const external = externalWrapper(modules, import_nestjs_agent_core39.AGENT_ROLES_POLICY);
|
|
6905
|
+
if (options.rolesPolicy !== void 0) {
|
|
6906
|
+
if (external !== void 0) {
|
|
6907
|
+
logger.warn("Both a `rolesPolicy` option and a module binding AGENT_ROLES_POLICY (e.g. AgentAuthzModule) are configured \u2014 the `rolesPolicy` option wins.");
|
|
6908
|
+
}
|
|
6909
|
+
return options.rolesPolicy;
|
|
6910
|
+
}
|
|
6911
|
+
if (external !== void 0) return forwardingPolicy(external);
|
|
6912
|
+
return options.emptyRoles === "deny" ? new import_nestjs_agent_core39.ClosedRolesPolicy(options.defaultRoles) : new import_nestjs_agent_core39.DefaultRolesPolicy(options.defaultRoles);
|
|
6913
|
+
}
|
|
6914
|
+
__name(resolveRolesPolicy, "resolveRolesPolicy");
|
|
6915
|
+
function forwardingPolicy(wrapper) {
|
|
6916
|
+
return {
|
|
6917
|
+
can(actor, tool) {
|
|
6918
|
+
const policy = wrapper.instance;
|
|
6919
|
+
if (policy === void 0 || policy === null) {
|
|
6920
|
+
throw new Error("AgentModule: the AGENT_ROLES_POLICY bound by another module is not ready yet");
|
|
6921
|
+
}
|
|
6922
|
+
return policy.can(actor, tool);
|
|
6923
|
+
}
|
|
6924
|
+
};
|
|
6925
|
+
}
|
|
6926
|
+
__name(forwardingPolicy, "forwardingPolicy");
|
|
6110
6927
|
function isQuotaProvider(quota) {
|
|
6111
6928
|
return quota !== void 0 && typeof quota.report === "function";
|
|
6112
6929
|
}
|
|
@@ -6120,99 +6937,100 @@ __name(resolveCatalog, "resolveCatalog");
|
|
|
6120
6937
|
function sharedProviders(durable) {
|
|
6121
6938
|
const providers = [
|
|
6122
6939
|
{
|
|
6123
|
-
provide:
|
|
6124
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
6940
|
+
provide: import_nestjs_agent_core39.AGENT_TOOL_REGISTRY,
|
|
6941
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core39.ToolRegistry(), "useFactory")
|
|
6125
6942
|
},
|
|
6126
6943
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
6127
6944
|
{
|
|
6128
|
-
provide:
|
|
6129
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
6945
|
+
provide: import_nestjs_agent_core39.AGENT_REGISTRY,
|
|
6946
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core39.AgentRegistry(), "useFactory")
|
|
6130
6947
|
},
|
|
6131
6948
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
6132
6949
|
{
|
|
6133
|
-
provide:
|
|
6950
|
+
provide: import_nestjs_agent_core39.AGENT_PROMPT_CONTRIBUTORS,
|
|
6134
6951
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
6135
6952
|
},
|
|
6136
6953
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
6137
6954
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
6138
6955
|
{
|
|
6139
|
-
provide:
|
|
6956
|
+
provide: import_nestjs_agent_core39.AGENT_SKILL_SOURCES,
|
|
6140
6957
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
6141
6958
|
},
|
|
6142
6959
|
{
|
|
6143
6960
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
6144
6961
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
6145
6962
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
6146
|
-
provide:
|
|
6963
|
+
provide: import_nestjs_agent_core39.AGENT_SKILLS,
|
|
6147
6964
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
6148
6965
|
inject: [
|
|
6149
|
-
|
|
6150
|
-
|
|
6966
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
6967
|
+
import_nestjs_agent_core39.AGENT_SKILL_SOURCES
|
|
6151
6968
|
]
|
|
6152
6969
|
},
|
|
6153
6970
|
{
|
|
6154
6971
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
6155
6972
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
6156
|
-
provide:
|
|
6973
|
+
provide: import_nestjs_agent_core39.AGENT_MEMORY,
|
|
6157
6974
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
6158
6975
|
inject: [
|
|
6159
|
-
|
|
6976
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6160
6977
|
]
|
|
6161
6978
|
},
|
|
6162
6979
|
{
|
|
6163
|
-
provide:
|
|
6980
|
+
provide: import_nestjs_agent_core39.AGENT_SINK,
|
|
6164
6981
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
6165
6982
|
inject: [
|
|
6166
|
-
|
|
6983
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6167
6984
|
]
|
|
6168
6985
|
},
|
|
6169
6986
|
{
|
|
6170
|
-
provide:
|
|
6171
|
-
useFactory: /* @__PURE__ */ __name((options) =>
|
|
6987
|
+
provide: import_nestjs_agent_core39.AGENT_ROLES_POLICY,
|
|
6988
|
+
useFactory: /* @__PURE__ */ __name((options, modules) => resolveRolesPolicy(options, modules), "useFactory"),
|
|
6172
6989
|
inject: [
|
|
6173
|
-
|
|
6990
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
6991
|
+
import_core4.ModulesContainer
|
|
6174
6992
|
]
|
|
6175
6993
|
},
|
|
6176
6994
|
{
|
|
6177
|
-
provide:
|
|
6995
|
+
provide: import_nestjs_agent_core39.AGENT_ACTOR_RESOLVER,
|
|
6178
6996
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
6179
6997
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
6180
6998
|
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
6999
|
return new AnonymousActorResolver();
|
|
6182
7000
|
}, "useFactory"),
|
|
6183
7001
|
inject: [
|
|
6184
|
-
|
|
7002
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6185
7003
|
]
|
|
6186
7004
|
},
|
|
6187
7005
|
{
|
|
6188
|
-
provide:
|
|
7006
|
+
provide: import_nestjs_agent_core39.AGENT_MODEL,
|
|
6189
7007
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
6190
7008
|
inject: [
|
|
6191
|
-
|
|
7009
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6192
7010
|
]
|
|
6193
7011
|
},
|
|
6194
7012
|
{
|
|
6195
7013
|
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
6196
7014
|
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
6197
|
-
provide:
|
|
7015
|
+
provide: import_nestjs_agent_core39.AGENT_QUOTA_PROVIDER,
|
|
6198
7016
|
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
|
|
6199
7017
|
warnAt: o.quota.warnAt
|
|
6200
7018
|
} : {}), "useFactory"),
|
|
6201
7019
|
inject: [
|
|
6202
|
-
|
|
6203
|
-
|
|
7020
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
7021
|
+
import_nestjs_agent_core39.AGENT_STORE
|
|
6204
7022
|
]
|
|
6205
7023
|
},
|
|
6206
7024
|
{
|
|
6207
|
-
provide:
|
|
7025
|
+
provide: import_nestjs_agent_core39.AGENT_MODEL_CATALOG,
|
|
6208
7026
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
6209
7027
|
inject: [
|
|
6210
|
-
|
|
7028
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6211
7029
|
]
|
|
6212
7030
|
},
|
|
6213
7031
|
AgentDepsFactory2,
|
|
6214
7032
|
{
|
|
6215
|
-
provide:
|
|
7033
|
+
provide: import_nestjs_agent_core39.AGENT_DEPS_FACTORY,
|
|
6216
7034
|
useExisting: AgentDepsFactory2
|
|
6217
7035
|
},
|
|
6218
7036
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -6229,25 +7047,27 @@ function sharedProviders(durable) {
|
|
|
6229
7047
|
},
|
|
6230
7048
|
InlineAgentRunner,
|
|
6231
7049
|
AgentService,
|
|
7050
|
+
ActionProposalService,
|
|
7051
|
+
ActionProposalWorkerService,
|
|
6232
7052
|
// Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
|
|
6233
7053
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
6234
7054
|
AgentApprovalPortAdapter,
|
|
6235
7055
|
{
|
|
6236
|
-
provide:
|
|
7056
|
+
provide: import_nestjs_agent_core39.AGENT_APPROVAL_PORT,
|
|
6237
7057
|
useExisting: AgentApprovalPortAdapter
|
|
6238
7058
|
}
|
|
6239
7059
|
];
|
|
6240
7060
|
providers.push({
|
|
6241
|
-
provide:
|
|
7061
|
+
provide: import_nestjs_agent_core39.AGENT_STORE,
|
|
6242
7062
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
6243
7063
|
inject: [
|
|
6244
|
-
|
|
7064
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
6245
7065
|
import_core4.ModulesContainer
|
|
6246
7066
|
]
|
|
6247
7067
|
});
|
|
6248
7068
|
if (durable) {
|
|
6249
7069
|
providers.push({
|
|
6250
|
-
provide:
|
|
7070
|
+
provide: import_nestjs_agent_core39.AGENT_RUNNER,
|
|
6251
7071
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
6252
7072
|
if (durableRunner === void 0) {
|
|
6253
7073
|
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 +7076,14 @@ function sharedProviders(durable) {
|
|
|
6256
7076
|
}, "useFactory"),
|
|
6257
7077
|
inject: [
|
|
6258
7078
|
{
|
|
6259
|
-
token:
|
|
7079
|
+
token: import_nestjs_agent_core39.AGENT_DURABLE_RUNNER,
|
|
6260
7080
|
optional: true
|
|
6261
7081
|
}
|
|
6262
7082
|
]
|
|
6263
7083
|
});
|
|
6264
7084
|
} else {
|
|
6265
7085
|
providers.push({
|
|
6266
|
-
provide:
|
|
7086
|
+
provide: import_nestjs_agent_core39.AGENT_RUNNER,
|
|
6267
7087
|
useExisting: InlineAgentRunner
|
|
6268
7088
|
});
|
|
6269
7089
|
}
|
|
@@ -6272,30 +7092,33 @@ function sharedProviders(durable) {
|
|
|
6272
7092
|
__name(sharedProviders, "sharedProviders");
|
|
6273
7093
|
function exportsFor() {
|
|
6274
7094
|
return [
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
7095
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
7096
|
+
import_nestjs_agent_core39.AGENT_TOOL_REGISTRY,
|
|
7097
|
+
import_nestjs_agent_core39.AGENT_REGISTRY,
|
|
7098
|
+
import_nestjs_agent_core39.AGENT_SINK,
|
|
7099
|
+
import_nestjs_agent_core39.AGENT_ROLES_POLICY,
|
|
7100
|
+
import_nestjs_agent_core39.AGENT_ACTOR_RESOLVER,
|
|
7101
|
+
import_nestjs_agent_core39.AGENT_MODEL,
|
|
7102
|
+
import_nestjs_agent_core39.AGENT_STORE,
|
|
7103
|
+
import_nestjs_agent_core39.AGENT_MODEL_CATALOG,
|
|
7104
|
+
import_nestjs_agent_core39.AGENT_QUOTA_PROVIDER,
|
|
7105
|
+
import_nestjs_agent_core39.AGENT_PROMPT_CONTRIBUTORS,
|
|
7106
|
+
import_nestjs_agent_core39.AGENT_SKILLS,
|
|
7107
|
+
import_nestjs_agent_core39.AGENT_MEMORY,
|
|
7108
|
+
import_nestjs_agent_core39.AGENT_DEPS_FACTORY,
|
|
6289
7109
|
AgentDepsFactory2,
|
|
6290
7110
|
AgentService,
|
|
7111
|
+
ActionProposalService,
|
|
7112
|
+
ActionProposalWorkerService,
|
|
6291
7113
|
ChatQueueService2,
|
|
6292
7114
|
AGENT_CHAT_QUEUE,
|
|
6293
7115
|
InlineAgentRunner,
|
|
6294
|
-
|
|
7116
|
+
import_nestjs_agent_core39.AGENT_APPROVAL_PORT
|
|
6295
7117
|
];
|
|
6296
7118
|
}
|
|
6297
7119
|
__name(exportsFor, "exportsFor");
|
|
6298
7120
|
var BASE_CONTROLLERS = [
|
|
7121
|
+
ActionProposalController,
|
|
6299
7122
|
ChatController,
|
|
6300
7123
|
QueueController,
|
|
6301
7124
|
ThreadsController,
|
|
@@ -6368,7 +7191,7 @@ var AgentModule = class _AgentModule {
|
|
|
6368
7191
|
controllers: controllersForSurface(options.surface, options.adapters),
|
|
6369
7192
|
providers: [
|
|
6370
7193
|
{
|
|
6371
|
-
provide:
|
|
7194
|
+
provide: import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
6372
7195
|
useValue: options
|
|
6373
7196
|
},
|
|
6374
7197
|
...sharedProviders(options.durable ?? false),
|
|
@@ -6392,7 +7215,7 @@ var AgentModule = class _AgentModule {
|
|
|
6392
7215
|
controllers: controllersForSurface(options.surface, options.adapters),
|
|
6393
7216
|
providers: [
|
|
6394
7217
|
{
|
|
6395
|
-
provide:
|
|
7218
|
+
provide: import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
6396
7219
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
6397
7220
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
6398
7221
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -6414,9 +7237,9 @@ var AgentModule = class _AgentModule {
|
|
|
6414
7237
|
};
|
|
6415
7238
|
}
|
|
6416
7239
|
};
|
|
6417
|
-
AgentModule =
|
|
6418
|
-
(0,
|
|
6419
|
-
(0,
|
|
7240
|
+
AgentModule = _ts_decorate30([
|
|
7241
|
+
(0, import_common31.Global)(),
|
|
7242
|
+
(0, import_common31.Module)({})
|
|
6420
7243
|
], AgentModule);
|
|
6421
7244
|
|
|
6422
7245
|
// src/durable/agent-durable.ts
|