@dudousxd/nestjs-agent 1.16.0 → 1.17.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 +15 -0
- package/dist/durable/index.cjs +501 -420
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +3 -0
- package/dist/durable/index.d.ts +3 -0
- package/dist/durable/index.js +142 -61
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +442 -392
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +64 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/durable/index.cjs
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = __toCommonJS(durable_exports);
|
|
|
32
32
|
// src/durable/agent-run.workflow.ts
|
|
33
33
|
var import_nestjs_agent_core3 = require("@dudousxd/nestjs-agent-core");
|
|
34
34
|
var import_nestjs_durable2 = require("@dudousxd/nestjs-durable");
|
|
35
|
-
var
|
|
35
|
+
var import_nestjs_durable_core2 = require("@dudousxd/nestjs-durable-core");
|
|
36
36
|
var import_common3 = require("@nestjs/common");
|
|
37
37
|
|
|
38
38
|
// src/agent-deps.ts
|
|
@@ -482,6 +482,19 @@ __name(queueFrame, "queueFrame");
|
|
|
482
482
|
var import_nestjs_agent_core2 = require("@dudousxd/nestjs-agent-core");
|
|
483
483
|
var import_nestjs_durable = require("@dudousxd/nestjs-durable");
|
|
484
484
|
var import_common2 = require("@nestjs/common");
|
|
485
|
+
|
|
486
|
+
// src/durable/outside-workflow-ctx.ts
|
|
487
|
+
var import_nestjs_durable_core = require("@dudousxd/nestjs-durable-core");
|
|
488
|
+
function outsideWorkflowCtx(fn) {
|
|
489
|
+
return (0, import_nestjs_durable_core.runInWorkflowCtx)(void 0, fn);
|
|
490
|
+
}
|
|
491
|
+
__name(outsideWorkflowCtx, "outsideWorkflowCtx");
|
|
492
|
+
function stepOf(ctx) {
|
|
493
|
+
return (name, fn, ...rest) => ctx.localStep(name, (...args) => outsideWorkflowCtx(() => fn(...args)), ...rest);
|
|
494
|
+
}
|
|
495
|
+
__name(stepOf, "stepOf");
|
|
496
|
+
|
|
497
|
+
// src/durable/agent-run.steps.ts
|
|
485
498
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
486
499
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
487
500
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -522,7 +535,10 @@ var AgentRunSteps = class {
|
|
|
522
535
|
* double-writes. NEVER call `writer.end()`/`fail()` here: the workflow owns the stream's lifecycle,
|
|
523
536
|
* across however many turns/retries it takes.
|
|
524
537
|
*/
|
|
525
|
-
|
|
538
|
+
llm(input) {
|
|
539
|
+
return outsideWorkflowCtx(() => this.runLlm(input));
|
|
540
|
+
}
|
|
541
|
+
async runLlm(input) {
|
|
526
542
|
const deps = this.factory.forAgent(input.agentName);
|
|
527
543
|
const tools = (0, import_nestjs_agent_core2.withMemoryTool)({
|
|
528
544
|
tools: (0, import_nestjs_agent_core2.withSkillTool)({
|
|
@@ -575,7 +591,10 @@ var AgentRunSteps = class {
|
|
|
575
591
|
* bounds engine liveness (retryable) rather than the tool's own business outcome — and per
|
|
576
592
|
* ATTEMPT, so a retried invocation gets its own fresh timeout window.
|
|
577
593
|
*/
|
|
578
|
-
|
|
594
|
+
tool(input) {
|
|
595
|
+
return outsideWorkflowCtx(() => this.runTool(input));
|
|
596
|
+
}
|
|
597
|
+
async runTool(input) {
|
|
579
598
|
const deps = this.factory.forAgent(input.ctx.agentName);
|
|
580
599
|
if (deps.registry.spec(input.toolName)?.kind === "action" && input.toolType !== "action") {
|
|
581
600
|
throw new Error(`tool "${input.toolName}" is an action tool but was dispatched without approval: the dispatching process resolved its kind against a registry that does not have it`);
|
|
@@ -587,7 +606,7 @@ var AgentRunSteps = class {
|
|
|
587
606
|
await (await opened).write((0, import_nestjs_agent_core2.encodeStreamEvent)(event));
|
|
588
607
|
});
|
|
589
608
|
const ctx = {
|
|
590
|
-
...input.ctx,
|
|
609
|
+
...(0, import_nestjs_agent_core2.toolCallContext)(input.ctx, input.toolCallId),
|
|
591
610
|
emitUi: ui.emit
|
|
592
611
|
};
|
|
593
612
|
const localClassify = deps.toolTransientRetry !== false ? deps.toolTransientRetry?.classify : void 0;
|
|
@@ -627,7 +646,7 @@ _ts_decorate2([
|
|
|
627
646
|
_ts_metadata2("design:paramtypes", [
|
|
628
647
|
typeof DispatchedLlmInput === "undefined" ? Object : DispatchedLlmInput
|
|
629
648
|
]),
|
|
630
|
-
_ts_metadata2("design:returntype", Promise)
|
|
649
|
+
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
631
650
|
], AgentRunSteps.prototype, "llm", null);
|
|
632
651
|
_ts_decorate2([
|
|
633
652
|
(0, import_nestjs_durable.Step)(),
|
|
@@ -635,7 +654,7 @@ _ts_decorate2([
|
|
|
635
654
|
_ts_metadata2("design:paramtypes", [
|
|
636
655
|
typeof DispatchedToolInput === "undefined" ? Object : DispatchedToolInput
|
|
637
656
|
]),
|
|
638
|
-
_ts_metadata2("design:returntype", Promise)
|
|
657
|
+
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
639
658
|
], AgentRunSteps.prototype, "tool", null);
|
|
640
659
|
AgentRunSteps = _ts_decorate2([
|
|
641
660
|
(0, import_common2.Injectable)(),
|
|
@@ -681,6 +700,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
681
700
|
store;
|
|
682
701
|
runs;
|
|
683
702
|
queue;
|
|
703
|
+
logger = new import_common3.Logger(_AgentRunWorkflow.name);
|
|
684
704
|
constructor(factory, store, runs, queue) {
|
|
685
705
|
this.factory = factory;
|
|
686
706
|
this.store = store;
|
|
@@ -705,7 +725,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
705
725
|
if (!await ctx.patched("agent:chat-queue")) {
|
|
706
726
|
return void 0;
|
|
707
727
|
}
|
|
708
|
-
const plan = await ctx
|
|
728
|
+
const plan = await stepOf(ctx)(`queue:${outcome}`, async () => {
|
|
709
729
|
try {
|
|
710
730
|
const settled = outcome === "completed" && await this.isCancelled(ctx.runId) ? "cancelled" : outcome;
|
|
711
731
|
return await queue.plan({
|
|
@@ -728,11 +748,11 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
728
748
|
await ctx.startChild(_AgentRunWorkflow, next.input, next.runId);
|
|
729
749
|
return plan.frame;
|
|
730
750
|
} catch (failure) {
|
|
731
|
-
if ((0,
|
|
751
|
+
if ((0, import_nestjs_durable_core2.isWorkflowControlFlowSignal)(failure)) {
|
|
732
752
|
throw failure;
|
|
733
753
|
}
|
|
734
754
|
const reason = failure instanceof Error ? failure.message : String(failure);
|
|
735
|
-
return ctx
|
|
755
|
+
return stepOf(ctx)("queue:restore", async () => {
|
|
736
756
|
await queue.restore(input.threadId, next, "start_failed", reason);
|
|
737
757
|
return queue.pausedFrame(input.threadId);
|
|
738
758
|
});
|
|
@@ -774,7 +794,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
774
794
|
if (delivery === void 0) {
|
|
775
795
|
return;
|
|
776
796
|
}
|
|
777
|
-
await ctx
|
|
797
|
+
await stepOf(ctx)("deliver:detached:unsettled", () => (0, import_nestjs_agent_core3.settleUnsettledDelegation)({
|
|
778
798
|
store: this.store,
|
|
779
799
|
delivery,
|
|
780
800
|
agent: input.agentName ?? "default",
|
|
@@ -790,7 +810,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
790
810
|
const deps = this.factory.forAgent(input.agentName);
|
|
791
811
|
const dispatchSteps = await ctx.patched("agent:dispatched-steps");
|
|
792
812
|
if (input.sinkRunId !== void 0 || input.deliverTo !== void 0) {
|
|
793
|
-
await ctx
|
|
813
|
+
await stepOf(ctx)("activate", () => this.store.setActiveStream(input.threadId, ctx.runId));
|
|
794
814
|
}
|
|
795
815
|
const sinkRunId = input.sinkRunId ?? ctx.runId;
|
|
796
816
|
const chainBelow = [
|
|
@@ -840,7 +860,9 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
840
860
|
// question set and an approval reach a parked run through one path, and the HTTP surface that
|
|
841
861
|
// settles either one is the same `POST /agent/tool-call/*` family.
|
|
842
862
|
awaitAnswers: /* @__PURE__ */ __name((request) => ctx.waitForSignal(`tool:${ctx.runId}:${request.id}`), "awaitAnswers"),
|
|
843
|
-
|
|
863
|
+
// Bodies run outside the ambient workflow ctx, so nothing the application does in there can
|
|
864
|
+
// take a position in this run's journal (see `outsideWorkflowCtx`).
|
|
865
|
+
step: /* @__PURE__ */ __name((name, fn) => stepOf(ctx)(name, fn), "step"),
|
|
844
866
|
// Both durable step primitives take their checkpoint position on the CALL, before their first
|
|
845
867
|
// await, so launching a batch in one tick — what `settleAll` does — fixes the block of
|
|
846
868
|
// positions in call order however the tools then settle. `ctx.patched` keeps a run that
|
|
@@ -852,9 +874,9 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
852
874
|
// failure. Marker-based predicate, NOT instanceof: the signal's CLASS differs by runtime
|
|
853
875
|
// (engine in-process throws durable-core's WorkflowSuspended/ContinueAsNew; the BullMQ thin
|
|
854
876
|
// worker throws durable-worker's own Suspend), so only the Symbol.for marker is reliable.
|
|
855
|
-
isControlFlowError: /* @__PURE__ */ __name((error) => (0,
|
|
877
|
+
isControlFlowError: /* @__PURE__ */ __name((error) => (0, import_nestjs_durable_core2.isWorkflowControlFlowSignal)(error), "isControlFlowError"),
|
|
856
878
|
runAgent: /* @__PURE__ */ __name(async (agentName, task) => {
|
|
857
|
-
const subThreadId = await ctx
|
|
879
|
+
const subThreadId = await stepOf(ctx)(`subthread:${agentName}`, async () => {
|
|
858
880
|
const thread = await this.store.createThread({
|
|
859
881
|
actor: input.actor,
|
|
860
882
|
transient: true
|
|
@@ -885,7 +907,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
885
907
|
// - `deliverTo` instead. The parent's tool result is a receipt, so the answer needs an
|
|
886
908
|
// address of its own, and by the time it exists nobody is holding one.
|
|
887
909
|
startAgent: /* @__PURE__ */ __name(async ({ agentName, task, toolCallId: toolCallId2 }) => {
|
|
888
|
-
const subThreadId = await ctx
|
|
910
|
+
const subThreadId = await stepOf(ctx)(`subthread:${agentName}`, async () => {
|
|
889
911
|
const thread = await this.store.createThread({
|
|
890
912
|
actor: input.actor,
|
|
891
913
|
transient: true
|
|
@@ -943,46 +965,58 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
943
965
|
...deps,
|
|
944
966
|
day
|
|
945
967
|
}, input, hooks);
|
|
946
|
-
await ctx
|
|
968
|
+
await stepOf(ctx)("deactivate", () => (0, import_nestjs_agent_core3.releaseThreadRun)(this.store, input.threadId, ctx.runId));
|
|
947
969
|
return result;
|
|
948
970
|
} catch (error) {
|
|
949
|
-
if ((0,
|
|
971
|
+
if ((0, import_nestjs_durable_core2.isWorkflowControlFlowSignal)(error)) {
|
|
950
972
|
throw error;
|
|
951
973
|
}
|
|
952
974
|
if (error instanceof import_nestjs_agent_core3.RunCancelledError) {
|
|
953
|
-
await ctx
|
|
975
|
+
await stepOf(ctx)("deactivate", () => (0, import_nestjs_agent_core3.releaseThreadRun)(this.store, input.threadId, ctx.runId));
|
|
954
976
|
await this.settleDetachedParent(ctx, input, {
|
|
955
977
|
status: "cancelled"
|
|
956
978
|
});
|
|
957
979
|
throw error;
|
|
958
980
|
}
|
|
959
981
|
if ((0, import_nestjs_agent_core3.isReplayIntegrityError)(error)) {
|
|
960
|
-
const
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
};
|
|
982
|
+
const detail = error.message;
|
|
983
|
+
const code2 = (0, import_nestjs_agent_core3.agentFailureCode)(error);
|
|
984
|
+
this.logger.error(`agent run ${ctx.runId} failed (${code2}): ${detail}`);
|
|
964
985
|
(0, import_nestjs_agent_core3.publishAgentRunFailed)({
|
|
965
986
|
runId: ctx.runId,
|
|
966
|
-
|
|
987
|
+
code: code2,
|
|
988
|
+
message: detail
|
|
989
|
+
});
|
|
990
|
+
await (0, import_nestjs_agent_core3.settleDeadRun)(this.store, {
|
|
991
|
+
runId: ctx.runId,
|
|
992
|
+
threadId: input.threadId,
|
|
993
|
+
failure: {
|
|
994
|
+
code: code2,
|
|
995
|
+
message: detail
|
|
996
|
+
}
|
|
967
997
|
});
|
|
968
|
-
await (await hooks.openSink()).fail(
|
|
998
|
+
await (await hooks.openSink()).fail((0, import_nestjs_agent_core3.streamFailure)(error));
|
|
969
999
|
throw error;
|
|
970
1000
|
}
|
|
971
1001
|
const message = error instanceof Error ? error.message : String(error);
|
|
972
1002
|
const code = (0, import_nestjs_agent_core3.agentFailureCode)(error);
|
|
1003
|
+
this.logger.error(`agent run ${ctx.runId} failed (${code}): ${message}`);
|
|
973
1004
|
(0, import_nestjs_agent_core3.publishAgentRunFailed)({
|
|
974
1005
|
runId: ctx.runId,
|
|
975
1006
|
code,
|
|
976
1007
|
message
|
|
977
1008
|
});
|
|
978
|
-
await ctx
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1009
|
+
await stepOf(ctx)("persist:run:fail", async () => {
|
|
1010
|
+
await this.store.recordRunEnd?.({
|
|
1011
|
+
runId: ctx.runId,
|
|
1012
|
+
status: "failed",
|
|
1013
|
+
errorCode: code,
|
|
1014
|
+
errorMessage: message
|
|
1015
|
+
});
|
|
1016
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(ctx.runId, import_nestjs_agent_core3.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
1017
|
+
});
|
|
984
1018
|
const queueFrame2 = await this.advanceQueue(ctx, input, "failed", message);
|
|
985
|
-
await ctx
|
|
1019
|
+
await stepOf(ctx)("deactivate", () => (0, import_nestjs_agent_core3.releaseThreadRun)(this.store, input.threadId, ctx.runId));
|
|
986
1020
|
await this.settleDetachedParent(ctx, input, {
|
|
987
1021
|
status: "failed",
|
|
988
1022
|
error: message
|
|
@@ -991,10 +1025,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
991
1025
|
if (queueFrame2 !== void 0) {
|
|
992
1026
|
await writer.write((0, import_nestjs_agent_core3.encodeStreamEvent)(queueFrame2));
|
|
993
1027
|
}
|
|
994
|
-
await writer.fail(
|
|
995
|
-
code,
|
|
996
|
-
message
|
|
997
|
-
});
|
|
1028
|
+
await writer.fail((0, import_nestjs_agent_core3.streamFailure)(error));
|
|
998
1029
|
throw error;
|
|
999
1030
|
}
|
|
1000
1031
|
}
|
|
@@ -1027,7 +1058,7 @@ __name(isSignalTimeout, "isSignalTimeout");
|
|
|
1027
1058
|
var import_node_crypto = require("crypto");
|
|
1028
1059
|
var import_nestjs_agent_core5 = require("@dudousxd/nestjs-agent-core");
|
|
1029
1060
|
var import_nestjs_durable3 = require("@dudousxd/nestjs-durable");
|
|
1030
|
-
var
|
|
1061
|
+
var import_nestjs_durable_core3 = require("@dudousxd/nestjs-durable-core");
|
|
1031
1062
|
var import_common4 = require("@nestjs/common");
|
|
1032
1063
|
|
|
1033
1064
|
// src/in-process-sink.ts
|
|
@@ -1165,7 +1196,7 @@ var DurableAgentRunner = class _DurableAgentRunner {
|
|
|
1165
1196
|
try {
|
|
1166
1197
|
await this.workflows.start(AgentRunWorkflow, stamped, runId);
|
|
1167
1198
|
} catch (error) {
|
|
1168
|
-
if (!(0,
|
|
1199
|
+
if (!(0, import_nestjs_durable_core3.isWorkflowControlFlowSignal)(error)) {
|
|
1169
1200
|
throw error;
|
|
1170
1201
|
}
|
|
1171
1202
|
}
|
|
@@ -1370,8 +1401,8 @@ AgentDurableModule = _ts_decorate5([
|
|
|
1370
1401
|
], AgentDurableModule);
|
|
1371
1402
|
|
|
1372
1403
|
// src/agent.module.ts
|
|
1373
|
-
var
|
|
1374
|
-
var
|
|
1404
|
+
var import_nestjs_agent_core31 = require("@dudousxd/nestjs-agent-core");
|
|
1405
|
+
var import_common27 = require("@nestjs/common");
|
|
1375
1406
|
var import_core4 = require("@nestjs/core");
|
|
1376
1407
|
|
|
1377
1408
|
// src/agent-deps.factory.ts
|
|
@@ -1633,8 +1664,28 @@ AgentDepsFactory2 = _ts_decorate6([
|
|
|
1633
1664
|
], AgentDepsFactory2);
|
|
1634
1665
|
|
|
1635
1666
|
// src/agent.service.ts
|
|
1667
|
+
var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
|
|
1668
|
+
var import_common8 = require("@nestjs/common");
|
|
1669
|
+
|
|
1670
|
+
// src/run-not-active.exception.ts
|
|
1636
1671
|
var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
|
|
1637
1672
|
var import_common7 = require("@nestjs/common");
|
|
1673
|
+
var RunNotActiveException = class extends import_common7.ConflictException {
|
|
1674
|
+
static {
|
|
1675
|
+
__name(this, "RunNotActiveException");
|
|
1676
|
+
}
|
|
1677
|
+
runId;
|
|
1678
|
+
code = import_nestjs_agent_core9.RUN_NOT_ACTIVE_CODE;
|
|
1679
|
+
constructor(runId) {
|
|
1680
|
+
super({
|
|
1681
|
+
statusCode: 409,
|
|
1682
|
+
code: import_nestjs_agent_core9.RUN_NOT_ACTIVE_CODE,
|
|
1683
|
+
message: import_nestjs_agent_core9.RUN_NOT_ACTIVE_MESSAGE
|
|
1684
|
+
}), this.runId = runId;
|
|
1685
|
+
}
|
|
1686
|
+
};
|
|
1687
|
+
|
|
1688
|
+
// src/agent.service.ts
|
|
1638
1689
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
1639
1690
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1640
1691
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1691,7 +1742,7 @@ var AgentService = class {
|
|
|
1691
1742
|
requireQueue() {
|
|
1692
1743
|
const queue = this.queueing();
|
|
1693
1744
|
if (queue === void 0) {
|
|
1694
|
-
throw new
|
|
1745
|
+
throw new import_common8.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
|
|
1695
1746
|
}
|
|
1696
1747
|
return queue;
|
|
1697
1748
|
}
|
|
@@ -1728,12 +1779,12 @@ var AgentService = class {
|
|
|
1728
1779
|
actor
|
|
1729
1780
|
});
|
|
1730
1781
|
if (blocked !== void 0) {
|
|
1731
|
-
throw new
|
|
1732
|
-
statusCode:
|
|
1782
|
+
throw new import_common8.HttpException({
|
|
1783
|
+
statusCode: import_common8.HttpStatus.TOO_MANY_REQUESTS,
|
|
1733
1784
|
code: "quota_exceeded",
|
|
1734
1785
|
period: blocked.period,
|
|
1735
1786
|
message: blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`
|
|
1736
|
-
},
|
|
1787
|
+
}, import_common8.HttpStatus.TOO_MANY_REQUESTS);
|
|
1737
1788
|
}
|
|
1738
1789
|
}
|
|
1739
1790
|
/**
|
|
@@ -1761,17 +1812,17 @@ var AgentService = class {
|
|
|
1761
1812
|
*/
|
|
1762
1813
|
async assertModelAllowed(actor, agent, model) {
|
|
1763
1814
|
if (this.models === void 0) {
|
|
1764
|
-
throw new
|
|
1815
|
+
throw new import_common8.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
|
|
1765
1816
|
}
|
|
1766
|
-
const entry = (0,
|
|
1817
|
+
const entry = (0, import_nestjs_agent_core10.findCatalogModel)(await this.models.list({
|
|
1767
1818
|
actor,
|
|
1768
1819
|
agent
|
|
1769
1820
|
}), model);
|
|
1770
1821
|
if (entry === void 0) {
|
|
1771
|
-
throw new
|
|
1822
|
+
throw new import_common8.BadRequestException(`model "${model}" is not offered`);
|
|
1772
1823
|
}
|
|
1773
1824
|
if (!entry.available) {
|
|
1774
|
-
throw new
|
|
1825
|
+
throw new import_common8.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
|
|
1775
1826
|
}
|
|
1776
1827
|
return entry.id;
|
|
1777
1828
|
}
|
|
@@ -1787,7 +1838,7 @@ var AgentService = class {
|
|
|
1787
1838
|
})).locked : void 0;
|
|
1788
1839
|
if (locked !== void 0) {
|
|
1789
1840
|
if (requested !== void 0 && requested !== locked.model) {
|
|
1790
|
-
throw new
|
|
1841
|
+
throw new import_common8.BadRequestException(`model "${requested}" cannot be selected: ${locked.reason ?? `this agent always uses "${locked.model}"`}`);
|
|
1791
1842
|
}
|
|
1792
1843
|
return locked.model;
|
|
1793
1844
|
}
|
|
@@ -1831,7 +1882,7 @@ var AgentService = class {
|
|
|
1831
1882
|
};
|
|
1832
1883
|
}
|
|
1833
1884
|
await this.requireQueue().publish(result.threadId);
|
|
1834
|
-
throw new
|
|
1885
|
+
throw new import_common8.ConflictException({
|
|
1835
1886
|
statusCode: 409,
|
|
1836
1887
|
code: "run_active",
|
|
1837
1888
|
message: `thread ${result.threadId} already has a turn running`
|
|
@@ -1849,7 +1900,7 @@ var AgentService = class {
|
|
|
1849
1900
|
let threadId = params.threadId;
|
|
1850
1901
|
if (threadId === void 0) {
|
|
1851
1902
|
if (params.regenerate === true) {
|
|
1852
|
-
throw new
|
|
1903
|
+
throw new import_common8.BadRequestException("regenerate requires an existing threadId");
|
|
1853
1904
|
}
|
|
1854
1905
|
const created = await this.store.createThread({
|
|
1855
1906
|
actor: params.actor,
|
|
@@ -1891,6 +1942,11 @@ var AgentService = class {
|
|
|
1891
1942
|
}
|
|
1892
1943
|
const mode = params.mode ?? "auto";
|
|
1893
1944
|
const { live, stale } = await queue.holder(threadId, this.runner);
|
|
1945
|
+
if (stale !== null) {
|
|
1946
|
+
await (0, import_nestjs_agent_core10.settleDeadRun)(this.store, {
|
|
1947
|
+
runId: stale
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1894
1950
|
if (live === null && mode !== "queue") {
|
|
1895
1951
|
const runId = crypto.randomUUID();
|
|
1896
1952
|
if (await queue.queueStore().claimActiveStream(threadId, runId, stale !== null ? {
|
|
@@ -1903,7 +1959,7 @@ var AgentService = class {
|
|
|
1903
1959
|
}
|
|
1904
1960
|
}
|
|
1905
1961
|
if (params.regenerate === true) {
|
|
1906
|
-
throw new
|
|
1962
|
+
throw new import_common8.ConflictException({
|
|
1907
1963
|
statusCode: 409,
|
|
1908
1964
|
code: "run_active",
|
|
1909
1965
|
message: "cannot regenerate while a turn is running on this thread"
|
|
@@ -2000,7 +2056,7 @@ var AgentService = class {
|
|
|
2000
2056
|
const store = queue.queueStore();
|
|
2001
2057
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
2002
2058
|
if (patch.message !== void 0 && patch.message.trim().length === 0) {
|
|
2003
|
-
throw new
|
|
2059
|
+
throw new import_common8.BadRequestException("message must not be empty");
|
|
2004
2060
|
}
|
|
2005
2061
|
const attachments = patch.attachments === void 0 || patch.attachments === null ? patch.attachments : await this.resolveAttachments(actor, patch.attachments);
|
|
2006
2062
|
if (patch.message !== void 0 || attachments !== void 0) {
|
|
@@ -2013,15 +2069,15 @@ var AgentService = class {
|
|
|
2013
2069
|
} : {}
|
|
2014
2070
|
});
|
|
2015
2071
|
if (updated === null) {
|
|
2016
|
-
throw new
|
|
2072
|
+
throw new import_common8.GoneException(`queued message ${messageId} already started or was removed`);
|
|
2017
2073
|
}
|
|
2018
2074
|
}
|
|
2019
2075
|
if (patch.position !== void 0) {
|
|
2020
2076
|
if (!Number.isInteger(patch.position) || patch.position < 0) {
|
|
2021
|
-
throw new
|
|
2077
|
+
throw new import_common8.BadRequestException("position must be a non-negative integer");
|
|
2022
2078
|
}
|
|
2023
2079
|
if (!await store.moveQueuedMessage(messageId, patch.position)) {
|
|
2024
|
-
throw new
|
|
2080
|
+
throw new import_common8.GoneException(`queued message ${messageId} already started or was removed`);
|
|
2025
2081
|
}
|
|
2026
2082
|
}
|
|
2027
2083
|
return queue.publish(threadId);
|
|
@@ -2031,7 +2087,7 @@ var AgentService = class {
|
|
|
2031
2087
|
const queue = this.requireQueue();
|
|
2032
2088
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
2033
2089
|
if (!await queue.queueStore().removeQueuedMessage(messageId)) {
|
|
2034
|
-
throw new
|
|
2090
|
+
throw new import_common8.GoneException(`queued message ${messageId} already started or was removed`);
|
|
2035
2091
|
}
|
|
2036
2092
|
return queue.publish(threadId);
|
|
2037
2093
|
}
|
|
@@ -2050,7 +2106,7 @@ var AgentService = class {
|
|
|
2050
2106
|
const queue = this.requireQueue();
|
|
2051
2107
|
const store = queue.queueStore();
|
|
2052
2108
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
2053
|
-
const gone = /* @__PURE__ */ __name(() => new
|
|
2109
|
+
const gone = /* @__PURE__ */ __name(() => new import_common8.GoneException(`queued message ${messageId} already started or was removed`), "gone");
|
|
2054
2110
|
const marked = await store.updateQueuedMessage(messageId, {
|
|
2055
2111
|
interrupt: true
|
|
2056
2112
|
});
|
|
@@ -2058,7 +2114,7 @@ var AgentService = class {
|
|
|
2058
2114
|
throw gone();
|
|
2059
2115
|
}
|
|
2060
2116
|
if (marked.interrupt !== true) {
|
|
2061
|
-
throw new
|
|
2117
|
+
throw new import_common8.NotImplementedException("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
|
|
2062
2118
|
}
|
|
2063
2119
|
if (!await store.moveQueuedMessage(messageId, 0)) {
|
|
2064
2120
|
throw gone();
|
|
@@ -2117,7 +2173,7 @@ var AgentService = class {
|
|
|
2117
2173
|
async assertOwnsQueuedMessage(actor, messageId) {
|
|
2118
2174
|
const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
|
|
2119
2175
|
if (message === null) {
|
|
2120
|
-
throw new
|
|
2176
|
+
throw new import_common8.NotFoundException(`queued message ${messageId} not found`);
|
|
2121
2177
|
}
|
|
2122
2178
|
await this.assertOwnsThread(actor, message.threadId);
|
|
2123
2179
|
return message.threadId;
|
|
@@ -2138,7 +2194,7 @@ var AgentService = class {
|
|
|
2138
2194
|
}
|
|
2139
2195
|
const staging = this.staging;
|
|
2140
2196
|
if (staging === void 0 || typeof staging.resolve !== "function") {
|
|
2141
|
-
throw new
|
|
2197
|
+
throw new import_common8.NotImplementedException("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
|
|
2142
2198
|
}
|
|
2143
2199
|
const resolved = [];
|
|
2144
2200
|
for (const ref of refs) {
|
|
@@ -2147,7 +2203,7 @@ var AgentService = class {
|
|
|
2147
2203
|
actor
|
|
2148
2204
|
});
|
|
2149
2205
|
if (attachment === null) {
|
|
2150
|
-
throw new
|
|
2206
|
+
throw new import_common8.ForbiddenException(`attachment ${ref.mediaId} is not available to this actor`);
|
|
2151
2207
|
}
|
|
2152
2208
|
resolved.push(attachment);
|
|
2153
2209
|
}
|
|
@@ -2251,8 +2307,29 @@ var AgentService = class {
|
|
|
2251
2307
|
async signalToolCall(toolCallId2, reply) {
|
|
2252
2308
|
await this.assertNotExpired(toolCallId2);
|
|
2253
2309
|
const runId = await this.resolveRunForToolCall(toolCallId2);
|
|
2310
|
+
await this.assertRunWaiting(runId);
|
|
2254
2311
|
return this.runner.signal(runId, toolCallId2, reply);
|
|
2255
2312
|
}
|
|
2313
|
+
/**
|
|
2314
|
+
* Refuse a decision addressed at a run that is over (`409 run_not_active`). The runtime would take
|
|
2315
|
+
* the signal and buffer it for a run that never comes back — the person's "yes" is accepted, the
|
|
2316
|
+
* card says so, and nothing runs. Settles the calls the dead run left awaiting a decision on the
|
|
2317
|
+
* way out, so the card stops asking. A runner that cannot say whether a run is alive is taken at
|
|
2318
|
+
* its word that it is, and so is one that fails to answer.
|
|
2319
|
+
*/
|
|
2320
|
+
async assertRunWaiting(runId) {
|
|
2321
|
+
if (typeof this.runner.isRunActive !== "function") {
|
|
2322
|
+
return;
|
|
2323
|
+
}
|
|
2324
|
+
const active = await this.runner.isRunActive(runId).catch(() => true);
|
|
2325
|
+
if (active) {
|
|
2326
|
+
return;
|
|
2327
|
+
}
|
|
2328
|
+
await (0, import_nestjs_agent_core10.settleDeadRun)(this.store, {
|
|
2329
|
+
runId
|
|
2330
|
+
});
|
|
2331
|
+
throw new RunNotActiveException(runId);
|
|
2332
|
+
}
|
|
2256
2333
|
async cancel(actor, runId) {
|
|
2257
2334
|
await this.assertOwnsActiveStream(actor, runId);
|
|
2258
2335
|
return this.runner.cancel(runId);
|
|
@@ -2296,7 +2373,7 @@ var AgentService = class {
|
|
|
2296
2373
|
return;
|
|
2297
2374
|
}
|
|
2298
2375
|
if (this.store.updateThread === void 0) {
|
|
2299
|
-
throw new
|
|
2376
|
+
throw new import_common8.NotImplementedException("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
2300
2377
|
}
|
|
2301
2378
|
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);
|
|
2302
2379
|
await this.store.updateThread(threadId, {
|
|
@@ -2314,10 +2391,10 @@ var AgentService = class {
|
|
|
2314
2391
|
validateTitle(title) {
|
|
2315
2392
|
const trimmed = title.trim();
|
|
2316
2393
|
if (trimmed.length === 0) {
|
|
2317
|
-
throw new
|
|
2394
|
+
throw new import_common8.BadRequestException("title must not be empty");
|
|
2318
2395
|
}
|
|
2319
2396
|
if (trimmed.length > 200) {
|
|
2320
|
-
throw new
|
|
2397
|
+
throw new import_common8.BadRequestException("title must be at most 200 characters");
|
|
2321
2398
|
}
|
|
2322
2399
|
return trimmed;
|
|
2323
2400
|
}
|
|
@@ -2420,21 +2497,21 @@ var AgentService = class {
|
|
|
2420
2497
|
*/
|
|
2421
2498
|
async setMessageFeedback(actor, messageId, input) {
|
|
2422
2499
|
if (input.value !== null && input.value !== "up" && input.value !== "down") {
|
|
2423
|
-
throw new
|
|
2500
|
+
throw new import_common8.BadRequestException("value must be 'up', 'down' or null");
|
|
2424
2501
|
}
|
|
2425
2502
|
if (input.comment !== void 0 && typeof input.comment !== "string") {
|
|
2426
|
-
throw new
|
|
2503
|
+
throw new import_common8.BadRequestException("comment must be a string");
|
|
2427
2504
|
}
|
|
2428
2505
|
const comment = input.comment?.trim();
|
|
2429
2506
|
if (comment !== void 0 && comment.length > 2e3) {
|
|
2430
|
-
throw new
|
|
2507
|
+
throw new import_common8.BadRequestException("comment must be at most 2000 characters");
|
|
2431
2508
|
}
|
|
2432
2509
|
if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
|
|
2433
|
-
throw new
|
|
2510
|
+
throw new import_common8.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
|
|
2434
2511
|
}
|
|
2435
2512
|
const threadId = await this.store.threadOfMessage(messageId);
|
|
2436
2513
|
if (threadId === null) {
|
|
2437
|
-
throw new
|
|
2514
|
+
throw new import_common8.NotFoundException(`message ${messageId} not found`);
|
|
2438
2515
|
}
|
|
2439
2516
|
await this.assertOwnsThread(actor, threadId);
|
|
2440
2517
|
const feedback = input.value === null ? null : {
|
|
@@ -2482,7 +2559,7 @@ var AgentService = class {
|
|
|
2482
2559
|
const list = this.attachmentInventory();
|
|
2483
2560
|
const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
|
|
2484
2561
|
if (referencedMediaIds === void 0) {
|
|
2485
|
-
throw new
|
|
2562
|
+
throw new import_common8.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.");
|
|
2486
2563
|
}
|
|
2487
2564
|
const stagedBefore = options.olderThan.toISOString();
|
|
2488
2565
|
const inventory = await list({
|
|
@@ -2504,7 +2581,7 @@ var AgentService = class {
|
|
|
2504
2581
|
attachmentInventory() {
|
|
2505
2582
|
const list = this.staging?.list?.bind(this.staging);
|
|
2506
2583
|
if (list === void 0) {
|
|
2507
|
-
throw new
|
|
2584
|
+
throw new import_common8.NotImplementedException("Listing attachments requires an AGENT_ATTACHMENT_STAGING provider implementing list(); the host owns the staged bytes, so only it can enumerate them.");
|
|
2508
2585
|
}
|
|
2509
2586
|
return list;
|
|
2510
2587
|
}
|
|
@@ -2515,10 +2592,10 @@ var AgentService = class {
|
|
|
2515
2592
|
async assertOwnsThread(actor, threadId) {
|
|
2516
2593
|
const owner = await this.store.ownerOfThread(threadId);
|
|
2517
2594
|
if (owner === null) {
|
|
2518
|
-
throw new
|
|
2595
|
+
throw new import_common8.NotFoundException(`thread ${threadId} not found`);
|
|
2519
2596
|
}
|
|
2520
2597
|
if (owner !== actor.id) {
|
|
2521
|
-
throw new
|
|
2598
|
+
throw new import_common8.ForbiddenException("thread belongs to another actor");
|
|
2522
2599
|
}
|
|
2523
2600
|
}
|
|
2524
2601
|
/**
|
|
@@ -2529,10 +2606,10 @@ var AgentService = class {
|
|
|
2529
2606
|
async assertOwnsToolCall(actor, toolCallId2) {
|
|
2530
2607
|
const owner = await this.store.ownerOfToolCall(toolCallId2);
|
|
2531
2608
|
if (owner === null) {
|
|
2532
|
-
throw new
|
|
2609
|
+
throw new import_common8.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
2533
2610
|
}
|
|
2534
2611
|
if (owner !== actor.id) {
|
|
2535
|
-
throw new
|
|
2612
|
+
throw new import_common8.ForbiddenException("tool call belongs to another actor");
|
|
2536
2613
|
}
|
|
2537
2614
|
}
|
|
2538
2615
|
/**
|
|
@@ -2547,12 +2624,12 @@ var AgentService = class {
|
|
|
2547
2624
|
if (this.store.toolCallInput === void 0) {
|
|
2548
2625
|
return;
|
|
2549
2626
|
}
|
|
2550
|
-
const questions = (0,
|
|
2627
|
+
const questions = (0, import_nestjs_agent_core10.readElicitationQuestions)(await this.store.toolCallInput(toolCallId2));
|
|
2551
2628
|
for (const question of questions) {
|
|
2552
2629
|
const submitted = Object.hasOwn(answers2, question.id) ? answers2[question.id] : void 0;
|
|
2553
|
-
const problem = (0,
|
|
2630
|
+
const problem = (0, import_nestjs_agent_core10.validateElicitationAnswer)(question, submitted ?? question.defaults ?? []);
|
|
2554
2631
|
if (problem !== null) {
|
|
2555
|
-
throw new
|
|
2632
|
+
throw new import_common8.BadRequestException(`answers["${question.id}"] ${problem}`);
|
|
2556
2633
|
}
|
|
2557
2634
|
}
|
|
2558
2635
|
}
|
|
@@ -2564,21 +2641,21 @@ var AgentService = class {
|
|
|
2564
2641
|
*/
|
|
2565
2642
|
async assertMayDecide(actor, toolCallId2) {
|
|
2566
2643
|
const approval = await this.store.toolCallApproval?.(toolCallId2);
|
|
2567
|
-
const approver = approval?.approver ??
|
|
2568
|
-
if (approver ===
|
|
2644
|
+
const approver = approval?.approver ?? import_nestjs_agent_core10.REQUESTER_APPROVER;
|
|
2645
|
+
if (approver === import_nestjs_agent_core10.REQUESTER_APPROVER) {
|
|
2569
2646
|
return this.assertOwnsToolCall(actor, toolCallId2);
|
|
2570
2647
|
}
|
|
2571
2648
|
const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
|
|
2572
2649
|
if (requesterRef === null) {
|
|
2573
|
-
throw new
|
|
2650
|
+
throw new import_common8.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
2574
2651
|
}
|
|
2575
|
-
const allowed = await (0,
|
|
2652
|
+
const allowed = await (0, import_nestjs_agent_core10.mayDecideApproval)(this.deps.forAgent().approvalPolicy, actor, {
|
|
2576
2653
|
toolCallId: toolCallId2,
|
|
2577
2654
|
approver,
|
|
2578
2655
|
requesterRef
|
|
2579
2656
|
});
|
|
2580
2657
|
if (!allowed) {
|
|
2581
|
-
throw new
|
|
2658
|
+
throw new import_common8.ForbiddenException(`this approval is for ${approver}`);
|
|
2582
2659
|
}
|
|
2583
2660
|
}
|
|
2584
2661
|
/**
|
|
@@ -2594,7 +2671,7 @@ var AgentService = class {
|
|
|
2594
2671
|
}
|
|
2595
2672
|
const lapsed = approval.status === "expired" || approval.status === "pending_approval" && approval.expiresAt !== null && Date.parse(approval.expiresAt) <= Date.now();
|
|
2596
2673
|
if (lapsed) {
|
|
2597
|
-
throw new
|
|
2674
|
+
throw new import_common8.GoneException(`the approval request for tool call ${toolCallId2} has expired`);
|
|
2598
2675
|
}
|
|
2599
2676
|
}
|
|
2600
2677
|
/**
|
|
@@ -2607,7 +2684,7 @@ var AgentService = class {
|
|
|
2607
2684
|
async resolveRunForToolCall(toolCallId2) {
|
|
2608
2685
|
const runId = await this.store.runForToolCall(toolCallId2);
|
|
2609
2686
|
if (runId === null) {
|
|
2610
|
-
throw new
|
|
2687
|
+
throw new import_common8.NotFoundException(`tool call ${toolCallId2} has no active run to signal`);
|
|
2611
2688
|
}
|
|
2612
2689
|
return runId;
|
|
2613
2690
|
}
|
|
@@ -2615,27 +2692,27 @@ var AgentService = class {
|
|
|
2615
2692
|
async assertOwnsActiveStream(actor, runId) {
|
|
2616
2693
|
const owner = await this.store.ownerOfActiveStream(runId);
|
|
2617
2694
|
if (owner === null) {
|
|
2618
|
-
throw new
|
|
2695
|
+
throw new import_common8.NotFoundException(`no active run ${runId}`);
|
|
2619
2696
|
}
|
|
2620
2697
|
if (owner !== actor.id) {
|
|
2621
|
-
throw new
|
|
2698
|
+
throw new import_common8.ForbiddenException("run belongs to another actor");
|
|
2622
2699
|
}
|
|
2623
2700
|
}
|
|
2624
2701
|
};
|
|
2625
2702
|
AgentService = _ts_decorate7([
|
|
2626
|
-
(0,
|
|
2627
|
-
_ts_param6(0, (0,
|
|
2628
|
-
_ts_param6(1, (0,
|
|
2629
|
-
_ts_param6(2, (0,
|
|
2630
|
-
_ts_param6(3, (0,
|
|
2631
|
-
_ts_param6(3, (0,
|
|
2632
|
-
_ts_param6(4, (0,
|
|
2633
|
-
_ts_param6(4, (0,
|
|
2634
|
-
_ts_param6(5, (0,
|
|
2635
|
-
_ts_param6(5, (0,
|
|
2636
|
-
_ts_param6(6, (0,
|
|
2637
|
-
_ts_param6(6, (0,
|
|
2638
|
-
_ts_param6(7, (0,
|
|
2703
|
+
(0, import_common8.Injectable)(),
|
|
2704
|
+
_ts_param6(0, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_RUNNER)),
|
|
2705
|
+
_ts_param6(1, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_STORE)),
|
|
2706
|
+
_ts_param6(2, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_DEPS_FACTORY)),
|
|
2707
|
+
_ts_param6(3, (0, import_common8.Optional)()),
|
|
2708
|
+
_ts_param6(3, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_ATTACHMENT_STAGING)),
|
|
2709
|
+
_ts_param6(4, (0, import_common8.Optional)()),
|
|
2710
|
+
_ts_param6(4, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_MODEL_CATALOG)),
|
|
2711
|
+
_ts_param6(5, (0, import_common8.Optional)()),
|
|
2712
|
+
_ts_param6(5, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_QUOTA_PROVIDER)),
|
|
2713
|
+
_ts_param6(6, (0, import_common8.Optional)()),
|
|
2714
|
+
_ts_param6(6, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_OPTIONS)),
|
|
2715
|
+
_ts_param6(7, (0, import_common8.Optional)()),
|
|
2639
2716
|
_ts_metadata6("design:type", Function),
|
|
2640
2717
|
_ts_metadata6("design:paramtypes", [
|
|
2641
2718
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
@@ -2650,7 +2727,7 @@ AgentService = _ts_decorate7([
|
|
|
2650
2727
|
], AgentService);
|
|
2651
2728
|
|
|
2652
2729
|
// src/approval-port.adapter.ts
|
|
2653
|
-
var
|
|
2730
|
+
var import_common9 = require("@nestjs/common");
|
|
2654
2731
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
2655
2732
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2656
2733
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -2709,7 +2786,7 @@ var AgentApprovalPortAdapter = class {
|
|
|
2709
2786
|
}
|
|
2710
2787
|
};
|
|
2711
2788
|
AgentApprovalPortAdapter = _ts_decorate8([
|
|
2712
|
-
(0,
|
|
2789
|
+
(0, import_common9.Injectable)(),
|
|
2713
2790
|
_ts_metadata7("design:type", Function),
|
|
2714
2791
|
_ts_metadata7("design:paramtypes", [
|
|
2715
2792
|
typeof AgentService === "undefined" ? Object : AgentService
|
|
@@ -2717,8 +2794,8 @@ AgentApprovalPortAdapter = _ts_decorate8([
|
|
|
2717
2794
|
], AgentApprovalPortAdapter);
|
|
2718
2795
|
|
|
2719
2796
|
// src/controller/agents.controller.ts
|
|
2720
|
-
var
|
|
2721
|
-
var
|
|
2797
|
+
var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
|
|
2798
|
+
var import_common10 = require("@nestjs/common");
|
|
2722
2799
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
2723
2800
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2724
2801
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -2767,25 +2844,25 @@ var AgentsController = class {
|
|
|
2767
2844
|
}
|
|
2768
2845
|
};
|
|
2769
2846
|
_ts_decorate9([
|
|
2770
|
-
(0,
|
|
2847
|
+
(0, import_common10.Get)(),
|
|
2771
2848
|
_ts_metadata8("design:type", Function),
|
|
2772
2849
|
_ts_metadata8("design:paramtypes", []),
|
|
2773
2850
|
_ts_metadata8("design:returntype", Array)
|
|
2774
2851
|
], AgentsController.prototype, "list", null);
|
|
2775
2852
|
AgentsController = _ts_decorate9([
|
|
2776
|
-
(0,
|
|
2777
|
-
_ts_param7(0, (0,
|
|
2778
|
-
_ts_param7(1, (0,
|
|
2853
|
+
(0, import_common10.Controller)("agents"),
|
|
2854
|
+
_ts_param7(0, (0, import_common10.Inject)(import_nestjs_agent_core11.AGENT_REGISTRY)),
|
|
2855
|
+
_ts_param7(1, (0, import_common10.Inject)(import_nestjs_agent_core11.AGENT_DEPS_FACTORY)),
|
|
2779
2856
|
_ts_metadata8("design:type", Function),
|
|
2780
2857
|
_ts_metadata8("design:paramtypes", [
|
|
2781
|
-
typeof
|
|
2858
|
+
typeof import_nestjs_agent_core11.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core11.AgentRegistry,
|
|
2782
2859
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
2783
2860
|
])
|
|
2784
2861
|
], AgentsController);
|
|
2785
2862
|
|
|
2786
2863
|
// src/controller/attachments.controller.ts
|
|
2787
|
-
var
|
|
2788
|
-
var
|
|
2864
|
+
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
2865
|
+
var import_common11 = require("@nestjs/common");
|
|
2789
2866
|
var import_platform_express = require("@nestjs/platform-express");
|
|
2790
2867
|
|
|
2791
2868
|
// src/attachment-limits.ts
|
|
@@ -2873,17 +2950,17 @@ var AttachmentsController = class {
|
|
|
2873
2950
|
}
|
|
2874
2951
|
async upload(req, file) {
|
|
2875
2952
|
if (this.staging === void 0) {
|
|
2876
|
-
throw new
|
|
2953
|
+
throw new import_common11.NotImplementedException("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
|
|
2877
2954
|
}
|
|
2878
2955
|
if (file === void 0) {
|
|
2879
|
-
throw new
|
|
2956
|
+
throw new import_common11.BadRequestException('multipart field "file" is required');
|
|
2880
2957
|
}
|
|
2881
2958
|
const { allowedContentTypes, maxBytes } = attachmentLimits(this.options, this.staging);
|
|
2882
2959
|
if (!allowedContentTypes.includes(file.mimetype)) {
|
|
2883
|
-
throw new
|
|
2960
|
+
throw new import_common11.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
|
|
2884
2961
|
}
|
|
2885
2962
|
if (file.size > maxBytes) {
|
|
2886
|
-
throw new
|
|
2963
|
+
throw new import_common11.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
|
|
2887
2964
|
}
|
|
2888
2965
|
const actor = await this.actorResolver.resolve(req);
|
|
2889
2966
|
return this.staging.stage({
|
|
@@ -2896,8 +2973,8 @@ var AttachmentsController = class {
|
|
|
2896
2973
|
}
|
|
2897
2974
|
};
|
|
2898
2975
|
_ts_decorate10([
|
|
2899
|
-
(0,
|
|
2900
|
-
_ts_param8(0, (0,
|
|
2976
|
+
(0, import_common11.Get)(),
|
|
2977
|
+
_ts_param8(0, (0, import_common11.Req)()),
|
|
2901
2978
|
_ts_metadata9("design:type", Function),
|
|
2902
2979
|
_ts_metadata9("design:paramtypes", [
|
|
2903
2980
|
typeof Request === "undefined" ? Object : Request
|
|
@@ -2905,14 +2982,14 @@ _ts_decorate10([
|
|
|
2905
2982
|
_ts_metadata9("design:returntype", Promise)
|
|
2906
2983
|
], AttachmentsController.prototype, "list", null);
|
|
2907
2984
|
_ts_decorate10([
|
|
2908
|
-
(0,
|
|
2909
|
-
(0,
|
|
2985
|
+
(0, import_common11.Post)(),
|
|
2986
|
+
(0, import_common11.UseInterceptors)((0, import_platform_express.FileInterceptor)("file", {
|
|
2910
2987
|
limits: {
|
|
2911
2988
|
fileSize: HARD_MAX_ATTACHMENT_BYTES
|
|
2912
2989
|
}
|
|
2913
2990
|
})),
|
|
2914
|
-
_ts_param8(0, (0,
|
|
2915
|
-
_ts_param8(1, (0,
|
|
2991
|
+
_ts_param8(0, (0, import_common11.Req)()),
|
|
2992
|
+
_ts_param8(1, (0, import_common11.UploadedFile)()),
|
|
2916
2993
|
_ts_metadata9("design:type", Function),
|
|
2917
2994
|
_ts_metadata9("design:paramtypes", [
|
|
2918
2995
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2921,11 +2998,11 @@ _ts_decorate10([
|
|
|
2921
2998
|
_ts_metadata9("design:returntype", Promise)
|
|
2922
2999
|
], AttachmentsController.prototype, "upload", null);
|
|
2923
3000
|
AttachmentsController = _ts_decorate10([
|
|
2924
|
-
(0,
|
|
2925
|
-
_ts_param8(0, (0,
|
|
2926
|
-
_ts_param8(1, (0,
|
|
2927
|
-
_ts_param8(3, (0,
|
|
2928
|
-
_ts_param8(3, (0,
|
|
3001
|
+
(0, import_common11.Controller)("attachments"),
|
|
3002
|
+
_ts_param8(0, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_OPTIONS)),
|
|
3003
|
+
_ts_param8(1, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
|
|
3004
|
+
_ts_param8(3, (0, import_common11.Optional)()),
|
|
3005
|
+
_ts_param8(3, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_ATTACHMENT_STAGING)),
|
|
2929
3006
|
_ts_metadata9("design:type", Function),
|
|
2930
3007
|
_ts_metadata9("design:paramtypes", [
|
|
2931
3008
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -2936,8 +3013,8 @@ AttachmentsController = _ts_decorate10([
|
|
|
2936
3013
|
], AttachmentsController);
|
|
2937
3014
|
|
|
2938
3015
|
// src/controller/chat.controller.ts
|
|
2939
|
-
var
|
|
2940
|
-
var
|
|
3016
|
+
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
3017
|
+
var import_common12 = require("@nestjs/common");
|
|
2941
3018
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
2942
3019
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2943
3020
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -2974,7 +3051,7 @@ function sendMode(body) {
|
|
|
2974
3051
|
if (body.mode === "auto" || body.mode === "queue" || body.mode === "interrupt") {
|
|
2975
3052
|
return body.mode;
|
|
2976
3053
|
}
|
|
2977
|
-
throw new
|
|
3054
|
+
throw new import_common12.BadRequestException("mode must be 'auto', 'queue' or 'interrupt'");
|
|
2978
3055
|
}
|
|
2979
3056
|
__name(sendMode, "sendMode");
|
|
2980
3057
|
function attachmentRefs(claimed) {
|
|
@@ -2982,21 +3059,21 @@ function attachmentRefs(claimed) {
|
|
|
2982
3059
|
return [];
|
|
2983
3060
|
}
|
|
2984
3061
|
if (!Array.isArray(claimed)) {
|
|
2985
|
-
throw new
|
|
3062
|
+
throw new import_common12.BadRequestException("attachments must be an array of { mediaId }");
|
|
2986
3063
|
}
|
|
2987
3064
|
if (claimed.length > MAX_ATTACHMENTS_PER_MESSAGE) {
|
|
2988
|
-
throw new
|
|
3065
|
+
throw new import_common12.BadRequestException(`a message may carry at most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments`);
|
|
2989
3066
|
}
|
|
2990
3067
|
return claimed.map((entry) => {
|
|
2991
3068
|
if (typeof entry !== "object" || entry === null || !("mediaId" in entry)) {
|
|
2992
|
-
throw new
|
|
3069
|
+
throw new import_common12.BadRequestException("each attachment must be an object with a mediaId");
|
|
2993
3070
|
}
|
|
2994
3071
|
if (Object.keys(entry).some((key) => key !== "mediaId")) {
|
|
2995
|
-
throw new
|
|
3072
|
+
throw new import_common12.BadRequestException("attachments are { mediaId } refs \u2014 send nothing but the id");
|
|
2996
3073
|
}
|
|
2997
3074
|
const { mediaId } = entry;
|
|
2998
3075
|
if (typeof mediaId !== "string" || mediaId.length === 0) {
|
|
2999
|
-
throw new
|
|
3076
|
+
throw new import_common12.BadRequestException("each attachment must carry a non-empty string mediaId");
|
|
3000
3077
|
}
|
|
3001
3078
|
return {
|
|
3002
3079
|
mediaId
|
|
@@ -3129,13 +3206,10 @@ data: ${line}
|
|
|
3129
3206
|
}
|
|
3130
3207
|
res.write("event: done\ndata: {}\n\n");
|
|
3131
3208
|
} catch (error) {
|
|
3132
|
-
const payload = error instanceof
|
|
3209
|
+
const payload = error instanceof import_nestjs_agent_core13.AgentStreamError ? {
|
|
3133
3210
|
code: error.code,
|
|
3134
3211
|
message: error.message
|
|
3135
|
-
} :
|
|
3136
|
-
code: "run_failed",
|
|
3137
|
-
message: error instanceof Error ? error.message : "stream error"
|
|
3138
|
-
};
|
|
3212
|
+
} : (0, import_nestjs_agent_core13.streamFailure)(error);
|
|
3139
3213
|
res.write(`event: error
|
|
3140
3214
|
data: ${JSON.stringify(payload)}
|
|
3141
3215
|
|
|
@@ -3145,10 +3219,10 @@ data: ${JSON.stringify(payload)}
|
|
|
3145
3219
|
}
|
|
3146
3220
|
};
|
|
3147
3221
|
_ts_decorate11([
|
|
3148
|
-
(0,
|
|
3149
|
-
_ts_param9(0, (0,
|
|
3150
|
-
_ts_param9(1, (0,
|
|
3151
|
-
_ts_param9(2, (0,
|
|
3222
|
+
(0, import_common12.Post)("chat"),
|
|
3223
|
+
_ts_param9(0, (0, import_common12.Req)()),
|
|
3224
|
+
_ts_param9(1, (0, import_common12.Res)()),
|
|
3225
|
+
_ts_param9(2, (0, import_common12.Body)()),
|
|
3152
3226
|
_ts_metadata10("design:type", Function),
|
|
3153
3227
|
_ts_metadata10("design:paramtypes", [
|
|
3154
3228
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3158,11 +3232,11 @@ _ts_decorate11([
|
|
|
3158
3232
|
_ts_metadata10("design:returntype", Promise)
|
|
3159
3233
|
], ChatController.prototype, "chat", null);
|
|
3160
3234
|
_ts_decorate11([
|
|
3161
|
-
(0,
|
|
3162
|
-
_ts_param9(0, (0,
|
|
3163
|
-
_ts_param9(1, (0,
|
|
3164
|
-
_ts_param9(2, (0,
|
|
3165
|
-
_ts_param9(3, (0,
|
|
3235
|
+
(0, import_common12.Get)("chat/:runId/stream"),
|
|
3236
|
+
_ts_param9(0, (0, import_common12.Req)()),
|
|
3237
|
+
_ts_param9(1, (0, import_common12.Param)("runId")),
|
|
3238
|
+
_ts_param9(2, (0, import_common12.Res)()),
|
|
3239
|
+
_ts_param9(3, (0, import_common12.Query)("after")),
|
|
3166
3240
|
_ts_metadata10("design:type", Function),
|
|
3167
3241
|
_ts_metadata10("design:paramtypes", [
|
|
3168
3242
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3173,9 +3247,9 @@ _ts_decorate11([
|
|
|
3173
3247
|
_ts_metadata10("design:returntype", Promise)
|
|
3174
3248
|
], ChatController.prototype, "stream", null);
|
|
3175
3249
|
_ts_decorate11([
|
|
3176
|
-
(0,
|
|
3177
|
-
_ts_param9(0, (0,
|
|
3178
|
-
_ts_param9(1, (0,
|
|
3250
|
+
(0, import_common12.Post)("chat/:runId/cancel"),
|
|
3251
|
+
_ts_param9(0, (0, import_common12.Req)()),
|
|
3252
|
+
_ts_param9(1, (0, import_common12.Param)("runId")),
|
|
3179
3253
|
_ts_metadata10("design:type", Function),
|
|
3180
3254
|
_ts_metadata10("design:paramtypes", [
|
|
3181
3255
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3184,8 +3258,8 @@ _ts_decorate11([
|
|
|
3184
3258
|
_ts_metadata10("design:returntype", Promise)
|
|
3185
3259
|
], ChatController.prototype, "cancel", null);
|
|
3186
3260
|
ChatController = _ts_decorate11([
|
|
3187
|
-
(0,
|
|
3188
|
-
_ts_param9(1, (0,
|
|
3261
|
+
(0, import_common12.Controller)(),
|
|
3262
|
+
_ts_param9(1, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
|
|
3189
3263
|
_ts_metadata10("design:type", Function),
|
|
3190
3264
|
_ts_metadata10("design:paramtypes", [
|
|
3191
3265
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -3203,8 +3277,8 @@ function parseCursor(raw) {
|
|
|
3203
3277
|
__name(parseCursor, "parseCursor");
|
|
3204
3278
|
|
|
3205
3279
|
// src/controller/config.controller.ts
|
|
3206
|
-
var
|
|
3207
|
-
var
|
|
3280
|
+
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
3281
|
+
var import_common13 = require("@nestjs/common");
|
|
3208
3282
|
|
|
3209
3283
|
// src/resolver/anonymous-actor-resolver.ts
|
|
3210
3284
|
var import_node_crypto2 = require("crypto");
|
|
@@ -3351,8 +3425,8 @@ var ConfigController = class {
|
|
|
3351
3425
|
}
|
|
3352
3426
|
};
|
|
3353
3427
|
_ts_decorate12([
|
|
3354
|
-
(0,
|
|
3355
|
-
_ts_param10(0, (0,
|
|
3428
|
+
(0, import_common13.Get)(),
|
|
3429
|
+
_ts_param10(0, (0, import_common13.Req)()),
|
|
3356
3430
|
_ts_metadata11("design:type", Function),
|
|
3357
3431
|
_ts_metadata11("design:paramtypes", [
|
|
3358
3432
|
typeof Request === "undefined" ? Object : Request
|
|
@@ -3360,13 +3434,13 @@ _ts_decorate12([
|
|
|
3360
3434
|
_ts_metadata11("design:returntype", Promise)
|
|
3361
3435
|
], ConfigController.prototype, "config", null);
|
|
3362
3436
|
ConfigController = _ts_decorate12([
|
|
3363
|
-
(0,
|
|
3364
|
-
_ts_param10(0, (0,
|
|
3365
|
-
_ts_param10(1, (0,
|
|
3366
|
-
_ts_param10(2, (0,
|
|
3367
|
-
_ts_param10(2, (0,
|
|
3368
|
-
_ts_param10(3, (0,
|
|
3369
|
-
_ts_param10(3, (0,
|
|
3437
|
+
(0, import_common13.Controller)("config"),
|
|
3438
|
+
_ts_param10(0, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_OPTIONS)),
|
|
3439
|
+
_ts_param10(1, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
|
|
3440
|
+
_ts_param10(2, (0, import_common13.Optional)()),
|
|
3441
|
+
_ts_param10(2, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_ATTACHMENT_STAGING)),
|
|
3442
|
+
_ts_param10(3, (0, import_common13.Optional)()),
|
|
3443
|
+
_ts_param10(3, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_MODEL_CATALOG)),
|
|
3370
3444
|
_ts_metadata11("design:type", Function),
|
|
3371
3445
|
_ts_metadata11("design:paramtypes", [
|
|
3372
3446
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -3377,8 +3451,8 @@ ConfigController = _ts_decorate12([
|
|
|
3377
3451
|
], ConfigController);
|
|
3378
3452
|
|
|
3379
3453
|
// src/controller/memories.controller.ts
|
|
3380
|
-
var
|
|
3381
|
-
var
|
|
3454
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
3455
|
+
var import_common14 = require("@nestjs/common");
|
|
3382
3456
|
function _ts_decorate13(decorators, target, key, desc) {
|
|
3383
3457
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3384
3458
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -3438,20 +3512,20 @@ var MemoriesController = class {
|
|
|
3438
3512
|
*/
|
|
3439
3513
|
async forget(req, id) {
|
|
3440
3514
|
if (this.memory === void 0) {
|
|
3441
|
-
throw new
|
|
3515
|
+
throw new import_common14.NotFoundException("No memory is configured in this deployment.");
|
|
3442
3516
|
}
|
|
3443
3517
|
const actor = await this.actorResolver.resolve(req);
|
|
3444
3518
|
const digest = await this.unbounded("", actor);
|
|
3445
3519
|
const entry = digest.entries.find((candidate) => candidate.id === id);
|
|
3446
3520
|
if (entry === void 0) {
|
|
3447
|
-
throw new
|
|
3521
|
+
throw new import_common14.NotFoundException(`No memory with id "${id}".`);
|
|
3448
3522
|
}
|
|
3449
|
-
const verdict = (0,
|
|
3523
|
+
const verdict = (0, import_nestjs_agent_core15.memoryForgetVerdict)({
|
|
3450
3524
|
record: entry,
|
|
3451
3525
|
actor
|
|
3452
3526
|
});
|
|
3453
3527
|
if (!verdict.allowed) {
|
|
3454
|
-
throw new
|
|
3528
|
+
throw new import_common14.ForbiddenException(verdict.reason);
|
|
3455
3529
|
}
|
|
3456
3530
|
return {
|
|
3457
3531
|
forgotten: await this.memory.provider.forget({
|
|
@@ -3465,7 +3539,7 @@ var MemoriesController = class {
|
|
|
3465
3539
|
}
|
|
3466
3540
|
async unbounded(threadId, actor) {
|
|
3467
3541
|
const config = this.memory;
|
|
3468
|
-
return await (0,
|
|
3542
|
+
return await (0, import_nestjs_agent_core15.offerMemories)({
|
|
3469
3543
|
config: {
|
|
3470
3544
|
...config,
|
|
3471
3545
|
maxMemories: Number.POSITIVE_INFINITY
|
|
@@ -3478,9 +3552,9 @@ var MemoriesController = class {
|
|
|
3478
3552
|
}
|
|
3479
3553
|
};
|
|
3480
3554
|
_ts_decorate13([
|
|
3481
|
-
(0,
|
|
3482
|
-
_ts_param11(0, (0,
|
|
3483
|
-
_ts_param11(1, (0,
|
|
3555
|
+
(0, import_common14.Get)(),
|
|
3556
|
+
_ts_param11(0, (0, import_common14.Req)()),
|
|
3557
|
+
_ts_param11(1, (0, import_common14.Query)("threadId")),
|
|
3484
3558
|
_ts_metadata12("design:type", Function),
|
|
3485
3559
|
_ts_metadata12("design:paramtypes", [
|
|
3486
3560
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3489,9 +3563,9 @@ _ts_decorate13([
|
|
|
3489
3563
|
_ts_metadata12("design:returntype", Promise)
|
|
3490
3564
|
], MemoriesController.prototype, "list", null);
|
|
3491
3565
|
_ts_decorate13([
|
|
3492
|
-
(0,
|
|
3493
|
-
_ts_param11(0, (0,
|
|
3494
|
-
_ts_param11(1, (0,
|
|
3566
|
+
(0, import_common14.Delete)(":id"),
|
|
3567
|
+
_ts_param11(0, (0, import_common14.Req)()),
|
|
3568
|
+
_ts_param11(1, (0, import_common14.Param)("id")),
|
|
3495
3569
|
_ts_metadata12("design:type", Function),
|
|
3496
3570
|
_ts_metadata12("design:paramtypes", [
|
|
3497
3571
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3500,10 +3574,10 @@ _ts_decorate13([
|
|
|
3500
3574
|
_ts_metadata12("design:returntype", Promise)
|
|
3501
3575
|
], MemoriesController.prototype, "forget", null);
|
|
3502
3576
|
MemoriesController = _ts_decorate13([
|
|
3503
|
-
(0,
|
|
3504
|
-
_ts_param11(0, (0,
|
|
3505
|
-
_ts_param11(1, (0,
|
|
3506
|
-
_ts_param11(1, (0,
|
|
3577
|
+
(0, import_common14.Controller)("memories"),
|
|
3578
|
+
_ts_param11(0, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
|
|
3579
|
+
_ts_param11(1, (0, import_common14.Optional)()),
|
|
3580
|
+
_ts_param11(1, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_MEMORY)),
|
|
3507
3581
|
_ts_metadata12("design:type", Function),
|
|
3508
3582
|
_ts_metadata12("design:paramtypes", [
|
|
3509
3583
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
@@ -3512,8 +3586,8 @@ MemoriesController = _ts_decorate13([
|
|
|
3512
3586
|
], MemoriesController);
|
|
3513
3587
|
|
|
3514
3588
|
// src/controller/messages.controller.ts
|
|
3515
|
-
var
|
|
3516
|
-
var
|
|
3589
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
3590
|
+
var import_common15 = require("@nestjs/common");
|
|
3517
3591
|
function _ts_decorate14(decorators, target, key, desc) {
|
|
3518
3592
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3519
3593
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -3568,11 +3642,11 @@ var MessagesController = class {
|
|
|
3568
3642
|
}
|
|
3569
3643
|
};
|
|
3570
3644
|
_ts_decorate14([
|
|
3571
|
-
(0,
|
|
3572
|
-
(0,
|
|
3573
|
-
_ts_param12(0, (0,
|
|
3574
|
-
_ts_param12(1, (0,
|
|
3575
|
-
_ts_param12(2, (0,
|
|
3645
|
+
(0, import_common15.Post)(":id/feedback"),
|
|
3646
|
+
(0, import_common15.HttpCode)(200),
|
|
3647
|
+
_ts_param12(0, (0, import_common15.Req)()),
|
|
3648
|
+
_ts_param12(1, (0, import_common15.Param)("id")),
|
|
3649
|
+
_ts_param12(2, (0, import_common15.Body)()),
|
|
3576
3650
|
_ts_metadata13("design:type", Function),
|
|
3577
3651
|
_ts_metadata13("design:paramtypes", [
|
|
3578
3652
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3582,8 +3656,8 @@ _ts_decorate14([
|
|
|
3582
3656
|
_ts_metadata13("design:returntype", Promise)
|
|
3583
3657
|
], MessagesController.prototype, "feedback", null);
|
|
3584
3658
|
MessagesController = _ts_decorate14([
|
|
3585
|
-
(0,
|
|
3586
|
-
_ts_param12(1, (0,
|
|
3659
|
+
(0, import_common15.Controller)("messages"),
|
|
3660
|
+
_ts_param12(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
|
|
3587
3661
|
_ts_metadata13("design:type", Function),
|
|
3588
3662
|
_ts_metadata13("design:paramtypes", [
|
|
3589
3663
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -3592,8 +3666,8 @@ MessagesController = _ts_decorate14([
|
|
|
3592
3666
|
], MessagesController);
|
|
3593
3667
|
|
|
3594
3668
|
// src/controller/models.controller.ts
|
|
3595
|
-
var
|
|
3596
|
-
var
|
|
3669
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
3670
|
+
var import_common16 = require("@nestjs/common");
|
|
3597
3671
|
function _ts_decorate15(decorators, target, key, desc) {
|
|
3598
3672
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3599
3673
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -3640,9 +3714,9 @@ var ModelsController = class {
|
|
|
3640
3714
|
}
|
|
3641
3715
|
};
|
|
3642
3716
|
_ts_decorate15([
|
|
3643
|
-
(0,
|
|
3644
|
-
_ts_param13(0, (0,
|
|
3645
|
-
_ts_param13(1, (0,
|
|
3717
|
+
(0, import_common16.Get)(),
|
|
3718
|
+
_ts_param13(0, (0, import_common16.Req)()),
|
|
3719
|
+
_ts_param13(1, (0, import_common16.Query)("agent")),
|
|
3646
3720
|
_ts_metadata14("design:type", Function),
|
|
3647
3721
|
_ts_metadata14("design:paramtypes", [
|
|
3648
3722
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3651,8 +3725,8 @@ _ts_decorate15([
|
|
|
3651
3725
|
_ts_metadata14("design:returntype", Promise)
|
|
3652
3726
|
], ModelsController.prototype, "list", null);
|
|
3653
3727
|
ModelsController = _ts_decorate15([
|
|
3654
|
-
(0,
|
|
3655
|
-
_ts_param13(1, (0,
|
|
3728
|
+
(0, import_common16.Controller)("models"),
|
|
3729
|
+
_ts_param13(1, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
|
|
3656
3730
|
_ts_metadata14("design:type", Function),
|
|
3657
3731
|
_ts_metadata14("design:paramtypes", [
|
|
3658
3732
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -3661,8 +3735,8 @@ ModelsController = _ts_decorate15([
|
|
|
3661
3735
|
], ModelsController);
|
|
3662
3736
|
|
|
3663
3737
|
// src/controller/queue.controller.ts
|
|
3664
|
-
var
|
|
3665
|
-
var
|
|
3738
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
3739
|
+
var import_common17 = require("@nestjs/common");
|
|
3666
3740
|
function _ts_decorate16(decorators, target, key, desc) {
|
|
3667
3741
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3668
3742
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -3712,10 +3786,10 @@ var QueueController = class {
|
|
|
3712
3786
|
async update(req, messageId, body) {
|
|
3713
3787
|
const actor = await this.actorResolver.resolve(req);
|
|
3714
3788
|
if (body.message !== void 0 && typeof body.message !== "string") {
|
|
3715
|
-
throw new
|
|
3789
|
+
throw new import_common17.BadRequestException("message must be a string");
|
|
3716
3790
|
}
|
|
3717
3791
|
if (body.position !== void 0 && typeof body.position !== "number") {
|
|
3718
|
-
throw new
|
|
3792
|
+
throw new import_common17.BadRequestException("position must be a number");
|
|
3719
3793
|
}
|
|
3720
3794
|
const attachments = body.attachments === void 0 ? void 0 : body.attachments === null ? null : attachmentRefs(body.attachments);
|
|
3721
3795
|
return this.agent.updateQueuedMessage(actor, messageId, {
|
|
@@ -3743,9 +3817,9 @@ var QueueController = class {
|
|
|
3743
3817
|
}
|
|
3744
3818
|
};
|
|
3745
3819
|
_ts_decorate16([
|
|
3746
|
-
(0,
|
|
3747
|
-
_ts_param14(0, (0,
|
|
3748
|
-
_ts_param14(1, (0,
|
|
3820
|
+
(0, import_common17.Get)("threads/:id/queue"),
|
|
3821
|
+
_ts_param14(0, (0, import_common17.Req)()),
|
|
3822
|
+
_ts_param14(1, (0, import_common17.Param)("id")),
|
|
3749
3823
|
_ts_metadata15("design:type", Function),
|
|
3750
3824
|
_ts_metadata15("design:paramtypes", [
|
|
3751
3825
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3754,9 +3828,9 @@ _ts_decorate16([
|
|
|
3754
3828
|
_ts_metadata15("design:returntype", Promise)
|
|
3755
3829
|
], QueueController.prototype, "list", null);
|
|
3756
3830
|
_ts_decorate16([
|
|
3757
|
-
(0,
|
|
3758
|
-
_ts_param14(0, (0,
|
|
3759
|
-
_ts_param14(1, (0,
|
|
3831
|
+
(0, import_common17.Delete)("threads/:id/queue"),
|
|
3832
|
+
_ts_param14(0, (0, import_common17.Req)()),
|
|
3833
|
+
_ts_param14(1, (0, import_common17.Param)("id")),
|
|
3760
3834
|
_ts_metadata15("design:type", Function),
|
|
3761
3835
|
_ts_metadata15("design:paramtypes", [
|
|
3762
3836
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3765,9 +3839,9 @@ _ts_decorate16([
|
|
|
3765
3839
|
_ts_metadata15("design:returntype", Promise)
|
|
3766
3840
|
], QueueController.prototype, "clear", null);
|
|
3767
3841
|
_ts_decorate16([
|
|
3768
|
-
(0,
|
|
3769
|
-
_ts_param14(0, (0,
|
|
3770
|
-
_ts_param14(1, (0,
|
|
3842
|
+
(0, import_common17.Post)("threads/:id/queue/resume"),
|
|
3843
|
+
_ts_param14(0, (0, import_common17.Req)()),
|
|
3844
|
+
_ts_param14(1, (0, import_common17.Param)("id")),
|
|
3771
3845
|
_ts_metadata15("design:type", Function),
|
|
3772
3846
|
_ts_metadata15("design:paramtypes", [
|
|
3773
3847
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3776,10 +3850,10 @@ _ts_decorate16([
|
|
|
3776
3850
|
_ts_metadata15("design:returntype", Promise)
|
|
3777
3851
|
], QueueController.prototype, "resume", null);
|
|
3778
3852
|
_ts_decorate16([
|
|
3779
|
-
(0,
|
|
3780
|
-
_ts_param14(0, (0,
|
|
3781
|
-
_ts_param14(1, (0,
|
|
3782
|
-
_ts_param14(2, (0,
|
|
3853
|
+
(0, import_common17.Patch)("queue/:messageId"),
|
|
3854
|
+
_ts_param14(0, (0, import_common17.Req)()),
|
|
3855
|
+
_ts_param14(1, (0, import_common17.Param)("messageId")),
|
|
3856
|
+
_ts_param14(2, (0, import_common17.Body)()),
|
|
3783
3857
|
_ts_metadata15("design:type", Function),
|
|
3784
3858
|
_ts_metadata15("design:paramtypes", [
|
|
3785
3859
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3789,9 +3863,9 @@ _ts_decorate16([
|
|
|
3789
3863
|
_ts_metadata15("design:returntype", Promise)
|
|
3790
3864
|
], QueueController.prototype, "update", null);
|
|
3791
3865
|
_ts_decorate16([
|
|
3792
|
-
(0,
|
|
3793
|
-
_ts_param14(0, (0,
|
|
3794
|
-
_ts_param14(1, (0,
|
|
3866
|
+
(0, import_common17.Post)("queue/:messageId/interrupt"),
|
|
3867
|
+
_ts_param14(0, (0, import_common17.Req)()),
|
|
3868
|
+
_ts_param14(1, (0, import_common17.Param)("messageId")),
|
|
3795
3869
|
_ts_metadata15("design:type", Function),
|
|
3796
3870
|
_ts_metadata15("design:paramtypes", [
|
|
3797
3871
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3800,9 +3874,9 @@ _ts_decorate16([
|
|
|
3800
3874
|
_ts_metadata15("design:returntype", Promise)
|
|
3801
3875
|
], QueueController.prototype, "interrupt", null);
|
|
3802
3876
|
_ts_decorate16([
|
|
3803
|
-
(0,
|
|
3804
|
-
_ts_param14(0, (0,
|
|
3805
|
-
_ts_param14(1, (0,
|
|
3877
|
+
(0, import_common17.Delete)("queue/:messageId"),
|
|
3878
|
+
_ts_param14(0, (0, import_common17.Req)()),
|
|
3879
|
+
_ts_param14(1, (0, import_common17.Param)("messageId")),
|
|
3806
3880
|
_ts_metadata15("design:type", Function),
|
|
3807
3881
|
_ts_metadata15("design:paramtypes", [
|
|
3808
3882
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3811,8 +3885,8 @@ _ts_decorate16([
|
|
|
3811
3885
|
_ts_metadata15("design:returntype", Promise)
|
|
3812
3886
|
], QueueController.prototype, "remove", null);
|
|
3813
3887
|
QueueController = _ts_decorate16([
|
|
3814
|
-
(0,
|
|
3815
|
-
_ts_param14(1, (0,
|
|
3888
|
+
(0, import_common17.Controller)(),
|
|
3889
|
+
_ts_param14(1, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
|
|
3816
3890
|
_ts_metadata15("design:type", Function),
|
|
3817
3891
|
_ts_metadata15("design:paramtypes", [
|
|
3818
3892
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -3821,8 +3895,8 @@ QueueController = _ts_decorate16([
|
|
|
3821
3895
|
], QueueController);
|
|
3822
3896
|
|
|
3823
3897
|
// src/controller/quota.controller.ts
|
|
3824
|
-
var
|
|
3825
|
-
var
|
|
3898
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
3899
|
+
var import_common18 = require("@nestjs/common");
|
|
3826
3900
|
function _ts_decorate17(decorators, target, key, desc) {
|
|
3827
3901
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3828
3902
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -3869,8 +3943,8 @@ var QuotaController = class {
|
|
|
3869
3943
|
}
|
|
3870
3944
|
};
|
|
3871
3945
|
_ts_decorate17([
|
|
3872
|
-
(0,
|
|
3873
|
-
_ts_param15(0, (0,
|
|
3946
|
+
(0, import_common18.Get)(),
|
|
3947
|
+
_ts_param15(0, (0, import_common18.Req)()),
|
|
3874
3948
|
_ts_metadata16("design:type", Function),
|
|
3875
3949
|
_ts_metadata16("design:paramtypes", [
|
|
3876
3950
|
typeof Request === "undefined" ? Object : Request
|
|
@@ -3878,8 +3952,8 @@ _ts_decorate17([
|
|
|
3878
3952
|
_ts_metadata16("design:returntype", Promise)
|
|
3879
3953
|
], QuotaController.prototype, "report", null);
|
|
3880
3954
|
QuotaController = _ts_decorate17([
|
|
3881
|
-
(0,
|
|
3882
|
-
_ts_param15(1, (0,
|
|
3955
|
+
(0, import_common18.Controller)("quota"),
|
|
3956
|
+
_ts_param15(1, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_ACTOR_RESOLVER)),
|
|
3883
3957
|
_ts_metadata16("design:type", Function),
|
|
3884
3958
|
_ts_metadata16("design:paramtypes", [
|
|
3885
3959
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -3888,8 +3962,8 @@ QuotaController = _ts_decorate17([
|
|
|
3888
3962
|
], QuotaController);
|
|
3889
3963
|
|
|
3890
3964
|
// src/controller/skills.controller.ts
|
|
3891
|
-
var
|
|
3892
|
-
var
|
|
3965
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
3966
|
+
var import_common19 = require("@nestjs/common");
|
|
3893
3967
|
function _ts_decorate18(decorators, target, key, desc) {
|
|
3894
3968
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3895
3969
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -3931,7 +4005,7 @@ var SkillsController = class {
|
|
|
3931
4005
|
return [];
|
|
3932
4006
|
}
|
|
3933
4007
|
const actor = await this.actorResolver.resolve(req);
|
|
3934
|
-
const offer = await (0,
|
|
4008
|
+
const offer = await (0, import_nestjs_agent_core20.offerSkills)(this.skills, {
|
|
3935
4009
|
actor,
|
|
3936
4010
|
threadId: threadId ?? ""
|
|
3937
4011
|
});
|
|
@@ -3939,9 +4013,9 @@ var SkillsController = class {
|
|
|
3939
4013
|
}
|
|
3940
4014
|
};
|
|
3941
4015
|
_ts_decorate18([
|
|
3942
|
-
(0,
|
|
3943
|
-
_ts_param16(0, (0,
|
|
3944
|
-
_ts_param16(1, (0,
|
|
4016
|
+
(0, import_common19.Get)(),
|
|
4017
|
+
_ts_param16(0, (0, import_common19.Req)()),
|
|
4018
|
+
_ts_param16(1, (0, import_common19.Query)("threadId")),
|
|
3945
4019
|
_ts_metadata17("design:type", Function),
|
|
3946
4020
|
_ts_metadata17("design:paramtypes", [
|
|
3947
4021
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3950,10 +4024,10 @@ _ts_decorate18([
|
|
|
3950
4024
|
_ts_metadata17("design:returntype", Promise)
|
|
3951
4025
|
], SkillsController.prototype, "list", null);
|
|
3952
4026
|
SkillsController = _ts_decorate18([
|
|
3953
|
-
(0,
|
|
3954
|
-
_ts_param16(0, (0,
|
|
3955
|
-
_ts_param16(1, (0,
|
|
3956
|
-
_ts_param16(1, (0,
|
|
4027
|
+
(0, import_common19.Controller)("skills"),
|
|
4028
|
+
_ts_param16(0, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER)),
|
|
4029
|
+
_ts_param16(1, (0, import_common19.Optional)()),
|
|
4030
|
+
_ts_param16(1, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_SKILLS)),
|
|
3957
4031
|
_ts_metadata17("design:type", Function),
|
|
3958
4032
|
_ts_metadata17("design:paramtypes", [
|
|
3959
4033
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
@@ -3962,8 +4036,8 @@ SkillsController = _ts_decorate18([
|
|
|
3962
4036
|
], SkillsController);
|
|
3963
4037
|
|
|
3964
4038
|
// src/controller/threads.controller.ts
|
|
3965
|
-
var
|
|
3966
|
-
var
|
|
4039
|
+
var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
|
|
4040
|
+
var import_common20 = require("@nestjs/common");
|
|
3967
4041
|
function _ts_decorate19(decorators, target, key, desc) {
|
|
3968
4042
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3969
4043
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -4057,8 +4131,8 @@ var ThreadsController = class {
|
|
|
4057
4131
|
}
|
|
4058
4132
|
};
|
|
4059
4133
|
_ts_decorate19([
|
|
4060
|
-
(0,
|
|
4061
|
-
_ts_param17(0, (0,
|
|
4134
|
+
(0, import_common20.Get)(),
|
|
4135
|
+
_ts_param17(0, (0, import_common20.Req)()),
|
|
4062
4136
|
_ts_metadata18("design:type", Function),
|
|
4063
4137
|
_ts_metadata18("design:paramtypes", [
|
|
4064
4138
|
typeof Request === "undefined" ? Object : Request
|
|
@@ -4066,9 +4140,9 @@ _ts_decorate19([
|
|
|
4066
4140
|
_ts_metadata18("design:returntype", Promise)
|
|
4067
4141
|
], ThreadsController.prototype, "list", null);
|
|
4068
4142
|
_ts_decorate19([
|
|
4069
|
-
(0,
|
|
4070
|
-
_ts_param17(0, (0,
|
|
4071
|
-
_ts_param17(1, (0,
|
|
4143
|
+
(0, import_common20.Get)(":id"),
|
|
4144
|
+
_ts_param17(0, (0, import_common20.Req)()),
|
|
4145
|
+
_ts_param17(1, (0, import_common20.Param)("id")),
|
|
4072
4146
|
_ts_metadata18("design:type", Function),
|
|
4073
4147
|
_ts_metadata18("design:paramtypes", [
|
|
4074
4148
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -4077,9 +4151,9 @@ _ts_decorate19([
|
|
|
4077
4151
|
_ts_metadata18("design:returntype", Promise)
|
|
4078
4152
|
], ThreadsController.prototype, "detail", null);
|
|
4079
4153
|
_ts_decorate19([
|
|
4080
|
-
(0,
|
|
4081
|
-
_ts_param17(0, (0,
|
|
4082
|
-
_ts_param17(1, (0,
|
|
4154
|
+
(0, import_common20.Delete)(":id"),
|
|
4155
|
+
_ts_param17(0, (0, import_common20.Req)()),
|
|
4156
|
+
_ts_param17(1, (0, import_common20.Param)("id")),
|
|
4083
4157
|
_ts_metadata18("design:type", Function),
|
|
4084
4158
|
_ts_metadata18("design:paramtypes", [
|
|
4085
4159
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -4088,10 +4162,10 @@ _ts_decorate19([
|
|
|
4088
4162
|
_ts_metadata18("design:returntype", Promise)
|
|
4089
4163
|
], ThreadsController.prototype, "remove", null);
|
|
4090
4164
|
_ts_decorate19([
|
|
4091
|
-
(0,
|
|
4092
|
-
_ts_param17(0, (0,
|
|
4093
|
-
_ts_param17(1, (0,
|
|
4094
|
-
_ts_param17(2, (0,
|
|
4165
|
+
(0, import_common20.Post)(":id/fork-from/:messageId"),
|
|
4166
|
+
_ts_param17(0, (0, import_common20.Req)()),
|
|
4167
|
+
_ts_param17(1, (0, import_common20.Param)("id")),
|
|
4168
|
+
_ts_param17(2, (0, import_common20.Param)("messageId")),
|
|
4095
4169
|
_ts_metadata18("design:type", Function),
|
|
4096
4170
|
_ts_metadata18("design:paramtypes", [
|
|
4097
4171
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -4101,10 +4175,10 @@ _ts_decorate19([
|
|
|
4101
4175
|
_ts_metadata18("design:returntype", Promise)
|
|
4102
4176
|
], ThreadsController.prototype, "fork", null);
|
|
4103
4177
|
_ts_decorate19([
|
|
4104
|
-
(0,
|
|
4105
|
-
_ts_param17(0, (0,
|
|
4106
|
-
_ts_param17(1, (0,
|
|
4107
|
-
_ts_param17(2, (0,
|
|
4178
|
+
(0, import_common20.Patch)(":id"),
|
|
4179
|
+
_ts_param17(0, (0, import_common20.Req)()),
|
|
4180
|
+
_ts_param17(1, (0, import_common20.Param)("id")),
|
|
4181
|
+
_ts_param17(2, (0, import_common20.Body)()),
|
|
4108
4182
|
_ts_metadata18("design:type", Function),
|
|
4109
4183
|
_ts_metadata18("design:paramtypes", [
|
|
4110
4184
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -4114,9 +4188,9 @@ _ts_decorate19([
|
|
|
4114
4188
|
_ts_metadata18("design:returntype", Promise)
|
|
4115
4189
|
], ThreadsController.prototype, "update", null);
|
|
4116
4190
|
_ts_decorate19([
|
|
4117
|
-
(0,
|
|
4118
|
-
_ts_param17(0, (0,
|
|
4119
|
-
_ts_param17(1, (0,
|
|
4191
|
+
(0, import_common20.Post)(":id/promote"),
|
|
4192
|
+
_ts_param17(0, (0, import_common20.Req)()),
|
|
4193
|
+
_ts_param17(1, (0, import_common20.Param)("id")),
|
|
4120
4194
|
_ts_metadata18("design:type", Function),
|
|
4121
4195
|
_ts_metadata18("design:paramtypes", [
|
|
4122
4196
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -4125,10 +4199,10 @@ _ts_decorate19([
|
|
|
4125
4199
|
_ts_metadata18("design:returntype", Promise)
|
|
4126
4200
|
], ThreadsController.prototype, "promote", null);
|
|
4127
4201
|
_ts_decorate19([
|
|
4128
|
-
(0,
|
|
4129
|
-
_ts_param17(0, (0,
|
|
4130
|
-
_ts_param17(1, (0,
|
|
4131
|
-
_ts_param17(2, (0,
|
|
4202
|
+
(0, import_common20.Delete)(":id/from/:messageId"),
|
|
4203
|
+
_ts_param17(0, (0, import_common20.Req)()),
|
|
4204
|
+
_ts_param17(1, (0, import_common20.Param)("id")),
|
|
4205
|
+
_ts_param17(2, (0, import_common20.Param)("messageId")),
|
|
4132
4206
|
_ts_metadata18("design:type", Function),
|
|
4133
4207
|
_ts_metadata18("design:paramtypes", [
|
|
4134
4208
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -4138,8 +4212,8 @@ _ts_decorate19([
|
|
|
4138
4212
|
_ts_metadata18("design:returntype", Promise)
|
|
4139
4213
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
4140
4214
|
ThreadsController = _ts_decorate19([
|
|
4141
|
-
(0,
|
|
4142
|
-
_ts_param17(1, (0,
|
|
4215
|
+
(0, import_common20.Controller)("threads"),
|
|
4216
|
+
_ts_param17(1, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_ACTOR_RESOLVER)),
|
|
4143
4217
|
_ts_metadata18("design:type", Function),
|
|
4144
4218
|
_ts_metadata18("design:paramtypes", [
|
|
4145
4219
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -4148,8 +4222,8 @@ ThreadsController = _ts_decorate19([
|
|
|
4148
4222
|
], ThreadsController);
|
|
4149
4223
|
|
|
4150
4224
|
// src/controller/tool-call.controller.ts
|
|
4151
|
-
var
|
|
4152
|
-
var
|
|
4225
|
+
var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
|
|
4226
|
+
var import_common21 = require("@nestjs/common");
|
|
4153
4227
|
function _ts_decorate20(decorators, target, key, desc) {
|
|
4154
4228
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4155
4229
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -4184,7 +4258,7 @@ var MAX_VIA_LENGTH = 64;
|
|
|
4184
4258
|
var DEFAULT_VIA = "web";
|
|
4185
4259
|
function toolCallId(claimed) {
|
|
4186
4260
|
if (typeof claimed !== "string" || claimed.length === 0) {
|
|
4187
|
-
throw new
|
|
4261
|
+
throw new import_common21.BadRequestException("toolCallId must be a non-empty string");
|
|
4188
4262
|
}
|
|
4189
4263
|
return claimed;
|
|
4190
4264
|
}
|
|
@@ -4194,10 +4268,10 @@ function rejectReason(claimed) {
|
|
|
4194
4268
|
return void 0;
|
|
4195
4269
|
}
|
|
4196
4270
|
if (typeof claimed !== "string") {
|
|
4197
|
-
throw new
|
|
4271
|
+
throw new import_common21.BadRequestException("reason must be a string");
|
|
4198
4272
|
}
|
|
4199
4273
|
if (claimed.length > MAX_REJECT_REASON_LENGTH) {
|
|
4200
|
-
throw new
|
|
4274
|
+
throw new import_common21.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
|
|
4201
4275
|
}
|
|
4202
4276
|
return claimed;
|
|
4203
4277
|
}
|
|
@@ -4207,7 +4281,7 @@ function remember(claimed) {
|
|
|
4207
4281
|
return false;
|
|
4208
4282
|
}
|
|
4209
4283
|
if (typeof claimed !== "boolean") {
|
|
4210
|
-
throw new
|
|
4284
|
+
throw new import_common21.BadRequestException("remember must be a boolean");
|
|
4211
4285
|
}
|
|
4212
4286
|
return claimed;
|
|
4213
4287
|
}
|
|
@@ -4217,7 +4291,7 @@ function via(claimed) {
|
|
|
4217
4291
|
return DEFAULT_VIA;
|
|
4218
4292
|
}
|
|
4219
4293
|
if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
|
|
4220
|
-
throw new
|
|
4294
|
+
throw new import_common21.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
|
|
4221
4295
|
}
|
|
4222
4296
|
return claimed;
|
|
4223
4297
|
}
|
|
@@ -4227,26 +4301,26 @@ function answers(claimed) {
|
|
|
4227
4301
|
return void 0;
|
|
4228
4302
|
}
|
|
4229
4303
|
if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
|
|
4230
|
-
throw new
|
|
4304
|
+
throw new import_common21.BadRequestException("answers must be an object of questionId \u2192 chosen values");
|
|
4231
4305
|
}
|
|
4232
4306
|
const entries = Object.entries(claimed);
|
|
4233
4307
|
if (entries.length > MAX_ANSWERED_QUESTIONS) {
|
|
4234
|
-
throw new
|
|
4308
|
+
throw new import_common21.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
|
|
4235
4309
|
}
|
|
4236
4310
|
const validated = /* @__PURE__ */ Object.create(null);
|
|
4237
4311
|
for (const [questionId, values] of entries) {
|
|
4238
4312
|
if (!Array.isArray(values)) {
|
|
4239
|
-
throw new
|
|
4313
|
+
throw new import_common21.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
|
|
4240
4314
|
}
|
|
4241
4315
|
if (values.length > MAX_VALUES_PER_QUESTION) {
|
|
4242
|
-
throw new
|
|
4316
|
+
throw new import_common21.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
|
|
4243
4317
|
}
|
|
4244
4318
|
for (const value of values) {
|
|
4245
4319
|
if (typeof value !== "string") {
|
|
4246
|
-
throw new
|
|
4320
|
+
throw new import_common21.BadRequestException(`answers["${questionId}"] must contain only strings`);
|
|
4247
4321
|
}
|
|
4248
4322
|
if (value.length > MAX_ANSWER_VALUE_LENGTH) {
|
|
4249
|
-
throw new
|
|
4323
|
+
throw new import_common21.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
|
|
4250
4324
|
}
|
|
4251
4325
|
}
|
|
4252
4326
|
validated[questionId] = values;
|
|
@@ -4309,9 +4383,9 @@ var ToolCallController = class {
|
|
|
4309
4383
|
}
|
|
4310
4384
|
};
|
|
4311
4385
|
_ts_decorate20([
|
|
4312
|
-
(0,
|
|
4313
|
-
_ts_param18(0, (0,
|
|
4314
|
-
_ts_param18(1, (0,
|
|
4386
|
+
(0, import_common21.Post)("approve"),
|
|
4387
|
+
_ts_param18(0, (0, import_common21.Req)()),
|
|
4388
|
+
_ts_param18(1, (0, import_common21.Body)()),
|
|
4315
4389
|
_ts_metadata19("design:type", Function),
|
|
4316
4390
|
_ts_metadata19("design:paramtypes", [
|
|
4317
4391
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -4320,9 +4394,9 @@ _ts_decorate20([
|
|
|
4320
4394
|
_ts_metadata19("design:returntype", Promise)
|
|
4321
4395
|
], ToolCallController.prototype, "approve", null);
|
|
4322
4396
|
_ts_decorate20([
|
|
4323
|
-
(0,
|
|
4324
|
-
_ts_param18(0, (0,
|
|
4325
|
-
_ts_param18(1, (0,
|
|
4397
|
+
(0, import_common21.Post)("reject"),
|
|
4398
|
+
_ts_param18(0, (0, import_common21.Req)()),
|
|
4399
|
+
_ts_param18(1, (0, import_common21.Body)()),
|
|
4326
4400
|
_ts_metadata19("design:type", Function),
|
|
4327
4401
|
_ts_metadata19("design:paramtypes", [
|
|
4328
4402
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -4331,9 +4405,9 @@ _ts_decorate20([
|
|
|
4331
4405
|
_ts_metadata19("design:returntype", Promise)
|
|
4332
4406
|
], ToolCallController.prototype, "reject", null);
|
|
4333
4407
|
_ts_decorate20([
|
|
4334
|
-
(0,
|
|
4335
|
-
_ts_param18(0, (0,
|
|
4336
|
-
_ts_param18(1, (0,
|
|
4408
|
+
(0, import_common21.Post)("answer"),
|
|
4409
|
+
_ts_param18(0, (0, import_common21.Req)()),
|
|
4410
|
+
_ts_param18(1, (0, import_common21.Body)()),
|
|
4337
4411
|
_ts_metadata19("design:type", Function),
|
|
4338
4412
|
_ts_metadata19("design:paramtypes", [
|
|
4339
4413
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -4342,9 +4416,9 @@ _ts_decorate20([
|
|
|
4342
4416
|
_ts_metadata19("design:returntype", Promise)
|
|
4343
4417
|
], ToolCallController.prototype, "answer", null);
|
|
4344
4418
|
_ts_decorate20([
|
|
4345
|
-
(0,
|
|
4346
|
-
_ts_param18(0, (0,
|
|
4347
|
-
_ts_param18(1, (0,
|
|
4419
|
+
(0, import_common21.Post)("skip"),
|
|
4420
|
+
_ts_param18(0, (0, import_common21.Req)()),
|
|
4421
|
+
_ts_param18(1, (0, import_common21.Body)()),
|
|
4348
4422
|
_ts_metadata19("design:type", Function),
|
|
4349
4423
|
_ts_metadata19("design:paramtypes", [
|
|
4350
4424
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -4353,8 +4427,8 @@ _ts_decorate20([
|
|
|
4353
4427
|
_ts_metadata19("design:returntype", Promise)
|
|
4354
4428
|
], ToolCallController.prototype, "skip", null);
|
|
4355
4429
|
ToolCallController = _ts_decorate20([
|
|
4356
|
-
(0,
|
|
4357
|
-
_ts_param18(1, (0,
|
|
4430
|
+
(0, import_common21.Controller)("tool-call"),
|
|
4431
|
+
_ts_param18(1, (0, import_common21.Inject)(import_nestjs_agent_core22.AGENT_ACTOR_RESOLVER)),
|
|
4358
4432
|
_ts_metadata19("design:type", Function),
|
|
4359
4433
|
_ts_metadata19("design:paramtypes", [
|
|
4360
4434
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -4363,8 +4437,8 @@ ToolCallController = _ts_decorate20([
|
|
|
4363
4437
|
], ToolCallController);
|
|
4364
4438
|
|
|
4365
4439
|
// src/controller/tools.controller.ts
|
|
4366
|
-
var
|
|
4367
|
-
var
|
|
4440
|
+
var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
|
|
4441
|
+
var import_common22 = require("@nestjs/common");
|
|
4368
4442
|
function _ts_decorate21(decorators, target, key, desc) {
|
|
4369
4443
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4370
4444
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -4404,11 +4478,11 @@ var ToolsController = class {
|
|
|
4404
4478
|
this.agents = agents;
|
|
4405
4479
|
}
|
|
4406
4480
|
async list(req, agent) {
|
|
4407
|
-
if (agent !== void 0 && agent !==
|
|
4408
|
-
throw new
|
|
4481
|
+
if (agent !== void 0 && agent !== import_nestjs_agent_core23.ALL_AGENTS && this.agents.get(agent) === void 0) {
|
|
4482
|
+
throw new import_common22.NotFoundException(`No agent named "${agent}"`);
|
|
4409
4483
|
}
|
|
4410
4484
|
const actor = await this.actorResolver.resolve(req);
|
|
4411
|
-
const names = agent ===
|
|
4485
|
+
const names = agent === import_nestjs_agent_core23.ALL_AGENTS ? [
|
|
4412
4486
|
void 0,
|
|
4413
4487
|
...this.agents.list().map((definition) => definition.name)
|
|
4414
4488
|
] : [
|
|
@@ -4435,9 +4509,9 @@ var ToolsController = class {
|
|
|
4435
4509
|
}
|
|
4436
4510
|
};
|
|
4437
4511
|
_ts_decorate21([
|
|
4438
|
-
(0,
|
|
4439
|
-
_ts_param19(0, (0,
|
|
4440
|
-
_ts_param19(1, (0,
|
|
4512
|
+
(0, import_common22.Get)(),
|
|
4513
|
+
_ts_param19(0, (0, import_common22.Req)()),
|
|
4514
|
+
_ts_param19(1, (0, import_common22.Query)("agent")),
|
|
4441
4515
|
_ts_metadata20("design:type", Function),
|
|
4442
4516
|
_ts_metadata20("design:paramtypes", [
|
|
4443
4517
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -4446,21 +4520,21 @@ _ts_decorate21([
|
|
|
4446
4520
|
_ts_metadata20("design:returntype", Promise)
|
|
4447
4521
|
], ToolsController.prototype, "list", null);
|
|
4448
4522
|
ToolsController = _ts_decorate21([
|
|
4449
|
-
(0,
|
|
4450
|
-
_ts_param19(0, (0,
|
|
4451
|
-
_ts_param19(1, (0,
|
|
4452
|
-
_ts_param19(2, (0,
|
|
4523
|
+
(0, import_common22.Controller)("tools"),
|
|
4524
|
+
_ts_param19(0, (0, import_common22.Inject)(import_nestjs_agent_core23.AGENT_ACTOR_RESOLVER)),
|
|
4525
|
+
_ts_param19(1, (0, import_common22.Inject)(import_nestjs_agent_core23.AGENT_DEPS_FACTORY)),
|
|
4526
|
+
_ts_param19(2, (0, import_common22.Inject)(import_nestjs_agent_core23.AGENT_REGISTRY)),
|
|
4453
4527
|
_ts_metadata20("design:type", Function),
|
|
4454
4528
|
_ts_metadata20("design:paramtypes", [
|
|
4455
4529
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
4456
4530
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
4457
|
-
typeof
|
|
4531
|
+
typeof import_nestjs_agent_core23.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core23.AgentRegistry
|
|
4458
4532
|
])
|
|
4459
4533
|
], ToolsController);
|
|
4460
4534
|
|
|
4461
4535
|
// src/discovery/agent-discovery.service.ts
|
|
4462
|
-
var
|
|
4463
|
-
var
|
|
4536
|
+
var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
|
|
4537
|
+
var import_common23 = require("@nestjs/common");
|
|
4464
4538
|
var import_core = require("@nestjs/core");
|
|
4465
4539
|
|
|
4466
4540
|
// src/decorator/agent.decorator.ts
|
|
@@ -4511,7 +4585,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
4511
4585
|
scanner;
|
|
4512
4586
|
registry;
|
|
4513
4587
|
contributors;
|
|
4514
|
-
logger = new
|
|
4588
|
+
logger = new import_common23.Logger(_AgentDiscoveryService.name);
|
|
4515
4589
|
constructor(discovery, scanner, registry, contributors) {
|
|
4516
4590
|
this.discovery = discovery;
|
|
4517
4591
|
this.scanner = scanner;
|
|
@@ -4630,21 +4704,21 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
4630
4704
|
}
|
|
4631
4705
|
};
|
|
4632
4706
|
AgentDiscoveryService = _ts_decorate22([
|
|
4633
|
-
(0,
|
|
4634
|
-
_ts_param20(2, (0,
|
|
4635
|
-
_ts_param20(3, (0,
|
|
4707
|
+
(0, import_common23.Injectable)(),
|
|
4708
|
+
_ts_param20(2, (0, import_common23.Inject)(import_nestjs_agent_core24.AGENT_REGISTRY)),
|
|
4709
|
+
_ts_param20(3, (0, import_common23.Inject)(import_nestjs_agent_core24.AGENT_PROMPT_CONTRIBUTORS)),
|
|
4636
4710
|
_ts_metadata21("design:type", Function),
|
|
4637
4711
|
_ts_metadata21("design:paramtypes", [
|
|
4638
4712
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
4639
4713
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
4640
|
-
typeof
|
|
4714
|
+
typeof import_nestjs_agent_core24.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core24.AgentRegistry,
|
|
4641
4715
|
Array
|
|
4642
4716
|
])
|
|
4643
4717
|
], AgentDiscoveryService);
|
|
4644
4718
|
|
|
4645
4719
|
// src/discovery/ai-tool-discovery.service.ts
|
|
4646
|
-
var
|
|
4647
|
-
var
|
|
4720
|
+
var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
|
|
4721
|
+
var import_common24 = require("@nestjs/common");
|
|
4648
4722
|
var import_core2 = require("@nestjs/core");
|
|
4649
4723
|
var import_zod = require("zod");
|
|
4650
4724
|
|
|
@@ -4698,7 +4772,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4698
4772
|
registry;
|
|
4699
4773
|
agents;
|
|
4700
4774
|
options;
|
|
4701
|
-
logger = new
|
|
4775
|
+
logger = new import_common24.Logger(_AiToolDiscoveryService.name);
|
|
4702
4776
|
constructor(discovery, registry, agents, options) {
|
|
4703
4777
|
this.discovery = discovery;
|
|
4704
4778
|
this.registry = registry;
|
|
@@ -4783,7 +4857,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4783
4857
|
let delegates = 0;
|
|
4784
4858
|
for (const definition of this.agents.list()) {
|
|
4785
4859
|
for (const edge of definition.delegatesTo ?? []) {
|
|
4786
|
-
const { agent: target, detached } = (0,
|
|
4860
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core25.normalizeDelegation)(edge);
|
|
4787
4861
|
const targetDefinition = this.agents.get(target);
|
|
4788
4862
|
if (targetDefinition === void 0) {
|
|
4789
4863
|
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.`);
|
|
@@ -4834,10 +4908,10 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4834
4908
|
}
|
|
4835
4909
|
};
|
|
4836
4910
|
AiToolDiscoveryService = _ts_decorate23([
|
|
4837
|
-
(0,
|
|
4838
|
-
_ts_param21(1, (0,
|
|
4839
|
-
_ts_param21(2, (0,
|
|
4840
|
-
_ts_param21(3, (0,
|
|
4911
|
+
(0, import_common24.Injectable)(),
|
|
4912
|
+
_ts_param21(1, (0, import_common24.Inject)(import_nestjs_agent_core25.AGENT_TOOL_REGISTRY)),
|
|
4913
|
+
_ts_param21(2, (0, import_common24.Inject)(import_nestjs_agent_core25.AGENT_REGISTRY)),
|
|
4914
|
+
_ts_param21(3, (0, import_common24.Inject)(import_nestjs_agent_core25.AGENT_OPTIONS)),
|
|
4841
4915
|
_ts_metadata22("design:type", Function),
|
|
4842
4916
|
_ts_metadata22("design:paramtypes", [
|
|
4843
4917
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
@@ -4848,20 +4922,20 @@ AiToolDiscoveryService = _ts_decorate23([
|
|
|
4848
4922
|
], AiToolDiscoveryService);
|
|
4849
4923
|
|
|
4850
4924
|
// src/discovery/skill-discovery.service.ts
|
|
4851
|
-
var
|
|
4852
|
-
var
|
|
4925
|
+
var import_nestjs_agent_core27 = require("@dudousxd/nestjs-agent-core");
|
|
4926
|
+
var import_common25 = require("@nestjs/common");
|
|
4853
4927
|
var import_core3 = require("@nestjs/core");
|
|
4854
4928
|
|
|
4855
4929
|
// src/decorator/skill.decorator.ts
|
|
4856
4930
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
4857
|
-
var
|
|
4931
|
+
var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
|
|
4858
4932
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
4859
4933
|
function readSkillMetadata(target) {
|
|
4860
4934
|
return Reflect.getMetadata(SKILL_METADATA, target);
|
|
4861
4935
|
}
|
|
4862
4936
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
4863
4937
|
function skillScope(options) {
|
|
4864
|
-
return options.scope ??
|
|
4938
|
+
return options.scope ?? import_nestjs_agent_core26.GLOBAL_SCOPE;
|
|
4865
4939
|
}
|
|
4866
4940
|
__name(skillScope, "skillScope");
|
|
4867
4941
|
|
|
@@ -4898,7 +4972,7 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
4898
4972
|
}
|
|
4899
4973
|
discovery;
|
|
4900
4974
|
declared;
|
|
4901
|
-
logger = new
|
|
4975
|
+
logger = new import_common25.Logger(_SkillDiscoveryService.name);
|
|
4902
4976
|
constructor(discovery, declared) {
|
|
4903
4977
|
this.discovery = discovery;
|
|
4904
4978
|
this.declared = declared;
|
|
@@ -4936,8 +5010,8 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
4936
5010
|
}
|
|
4937
5011
|
};
|
|
4938
5012
|
SkillDiscoveryService = _ts_decorate24([
|
|
4939
|
-
(0,
|
|
4940
|
-
_ts_param22(1, (0,
|
|
5013
|
+
(0, import_common25.Injectable)(),
|
|
5014
|
+
_ts_param22(1, (0, import_common25.Inject)(import_nestjs_agent_core27.AGENT_SKILL_SOURCES)),
|
|
4941
5015
|
_ts_metadata23("design:type", Function),
|
|
4942
5016
|
_ts_metadata23("design:paramtypes", [
|
|
4943
5017
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
@@ -4946,7 +5020,7 @@ SkillDiscoveryService = _ts_decorate24([
|
|
|
4946
5020
|
], SkillDiscoveryService);
|
|
4947
5021
|
|
|
4948
5022
|
// src/ledger-quota-provider.ts
|
|
4949
|
-
var
|
|
5023
|
+
var import_nestjs_agent_core28 = require("@dudousxd/nestjs-agent-core");
|
|
4950
5024
|
var LedgerQuotaProvider = class {
|
|
4951
5025
|
static {
|
|
4952
5026
|
__name(this, "LedgerQuotaProvider");
|
|
@@ -4966,12 +5040,12 @@ var LedgerQuotaProvider = class {
|
|
|
4966
5040
|
await this.dayWindow(actorRef, now)
|
|
4967
5041
|
];
|
|
4968
5042
|
if (this.store.usageBetween !== void 0) {
|
|
4969
|
-
const range = (0,
|
|
5043
|
+
const range = (0, import_nestjs_agent_core28.quotaPeriodRange)("month", now);
|
|
4970
5044
|
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
4971
5045
|
windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
|
|
4972
5046
|
}
|
|
4973
|
-
const blocked = (0,
|
|
4974
|
-
const warning = (0,
|
|
5047
|
+
const blocked = (0, import_nestjs_agent_core28.exhaustedWindow)(windows);
|
|
5048
|
+
const warning = (0, import_nestjs_agent_core28.quotaWarning)(windows);
|
|
4975
5049
|
return {
|
|
4976
5050
|
windows,
|
|
4977
5051
|
...blocked !== void 0 ? {
|
|
@@ -4983,7 +5057,7 @@ var LedgerQuotaProvider = class {
|
|
|
4983
5057
|
};
|
|
4984
5058
|
}
|
|
4985
5059
|
async dayWindow(actorRef, now) {
|
|
4986
|
-
const range = (0,
|
|
5060
|
+
const range = (0, import_nestjs_agent_core28.quotaPeriodRange)("day", now);
|
|
4987
5061
|
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
4988
5062
|
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
4989
5063
|
}
|
|
@@ -5008,8 +5082,8 @@ var LedgerQuotaProvider = class {
|
|
|
5008
5082
|
};
|
|
5009
5083
|
|
|
5010
5084
|
// src/runner/inline-agent-runner.ts
|
|
5011
|
-
var
|
|
5012
|
-
var
|
|
5085
|
+
var import_nestjs_agent_core29 = require("@dudousxd/nestjs-agent-core");
|
|
5086
|
+
var import_common26 = require("@nestjs/common");
|
|
5013
5087
|
function _ts_decorate25(decorators, target, key, desc) {
|
|
5014
5088
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5015
5089
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -5043,7 +5117,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5043
5117
|
factory;
|
|
5044
5118
|
store;
|
|
5045
5119
|
queue;
|
|
5046
|
-
logger = new
|
|
5120
|
+
logger = new import_common26.Logger(_InlineAgentRunner.name);
|
|
5047
5121
|
pending = /* @__PURE__ */ new Map();
|
|
5048
5122
|
/**
|
|
5049
5123
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -5063,7 +5137,15 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5063
5137
|
* that was running it is gone (a restart), and a thread it still holds is a stale claim.
|
|
5064
5138
|
*/
|
|
5065
5139
|
async isRunActive(runId) {
|
|
5066
|
-
|
|
5140
|
+
if (this.live.has(runId)) {
|
|
5141
|
+
return true;
|
|
5142
|
+
}
|
|
5143
|
+
for (const key of this.pending.keys()) {
|
|
5144
|
+
if (key.startsWith(`${runId}:`)) {
|
|
5145
|
+
return true;
|
|
5146
|
+
}
|
|
5147
|
+
}
|
|
5148
|
+
return false;
|
|
5067
5149
|
}
|
|
5068
5150
|
async start(input, options = {}) {
|
|
5069
5151
|
const runId = options.runId ?? crypto.randomUUID();
|
|
@@ -5084,18 +5166,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5084
5166
|
],
|
|
5085
5167
|
input
|
|
5086
5168
|
});
|
|
5087
|
-
void (0,
|
|
5169
|
+
void (0, import_nestjs_agent_core29.runAgentLoop)({
|
|
5088
5170
|
...deps,
|
|
5089
5171
|
day
|
|
5090
|
-
}, input, hooks).then(() => (0,
|
|
5091
|
-
if (error instanceof
|
|
5172
|
+
}, input, hooks).then(() => (0, import_nestjs_agent_core29.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
|
|
5173
|
+
if (error instanceof import_nestjs_agent_core29.RunCancelledError) {
|
|
5092
5174
|
await this.settleCancelled(runId, input, deps);
|
|
5093
5175
|
return;
|
|
5094
5176
|
}
|
|
5095
5177
|
const message = error instanceof Error ? error.message : String(error);
|
|
5096
|
-
const code = (0,
|
|
5178
|
+
const code = (0, import_nestjs_agent_core29.agentFailureCode)(error);
|
|
5097
5179
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
5098
|
-
(0,
|
|
5180
|
+
(0, import_nestjs_agent_core29.publishAgentRunFailed)({
|
|
5099
5181
|
runId,
|
|
5100
5182
|
code,
|
|
5101
5183
|
message
|
|
@@ -5106,13 +5188,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5106
5188
|
errorCode: code,
|
|
5107
5189
|
errorMessage: message
|
|
5108
5190
|
});
|
|
5191
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core29.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
5109
5192
|
const writer = await deps.sink.open(runId);
|
|
5110
5193
|
await this.settleQueue(writer, input, runId, "failed", message);
|
|
5111
|
-
await (0,
|
|
5112
|
-
await writer.fail(
|
|
5113
|
-
code,
|
|
5114
|
-
message
|
|
5115
|
-
});
|
|
5194
|
+
await (0, import_nestjs_agent_core29.releaseThreadRun)(this.store, input.threadId, runId);
|
|
5195
|
+
await writer.fail((0, import_nestjs_agent_core29.streamFailure)(error));
|
|
5116
5196
|
}).finally(() => {
|
|
5117
5197
|
this.cancelled.delete(runId);
|
|
5118
5198
|
this.live.delete(runId);
|
|
@@ -5148,7 +5228,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5148
5228
|
for (const [key, waiter] of this.pending) {
|
|
5149
5229
|
if (key.startsWith(`${runId}:`)) {
|
|
5150
5230
|
this.pending.delete(key);
|
|
5151
|
-
waiter.reject(new
|
|
5231
|
+
waiter.reject(new import_nestjs_agent_core29.RunCancelledError());
|
|
5152
5232
|
}
|
|
5153
5233
|
}
|
|
5154
5234
|
await Promise.resolve();
|
|
@@ -5163,8 +5243,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5163
5243
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
5164
5244
|
const writer = await deps.sink.open(runId);
|
|
5165
5245
|
await this.settleQueue(writer, input, runId, "cancelled");
|
|
5166
|
-
await (0,
|
|
5167
|
-
await writer.write((0,
|
|
5246
|
+
await (0, import_nestjs_agent_core29.releaseThreadRun)(this.store, input.threadId, runId);
|
|
5247
|
+
await writer.write((0, import_nestjs_agent_core29.encodeStreamEvent)({
|
|
5168
5248
|
kind: "cancelled"
|
|
5169
5249
|
}));
|
|
5170
5250
|
await writer.end();
|
|
@@ -5199,7 +5279,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5199
5279
|
runId: nextRunId
|
|
5200
5280
|
}));
|
|
5201
5281
|
if (frame !== void 0) {
|
|
5202
|
-
await writer.write((0,
|
|
5282
|
+
await writer.write((0, import_nestjs_agent_core29.encodeStreamEvent)(frame));
|
|
5203
5283
|
}
|
|
5204
5284
|
} catch (failure) {
|
|
5205
5285
|
this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
@@ -5270,7 +5350,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5270
5350
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
5271
5351
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
5272
5352
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
5273
|
-
parallel:
|
|
5353
|
+
parallel: import_nestjs_agent_core29.settleAll,
|
|
5274
5354
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
5275
5355
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
5276
5356
|
agentName,
|
|
@@ -5321,7 +5401,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5321
5401
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
5322
5402
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
5323
5403
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
5324
|
-
parallel:
|
|
5404
|
+
parallel: import_nestjs_agent_core29.settleAll,
|
|
5325
5405
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
5326
5406
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
5327
5407
|
agentName: childName,
|
|
@@ -5354,7 +5434,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5354
5434
|
}
|
|
5355
5435
|
}), "startAgent")
|
|
5356
5436
|
};
|
|
5357
|
-
void (0,
|
|
5437
|
+
void (0, import_nestjs_agent_core29.runAgentLoop)({
|
|
5358
5438
|
...deps,
|
|
5359
5439
|
day
|
|
5360
5440
|
}, {
|
|
@@ -5368,13 +5448,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5368
5448
|
parentRunId,
|
|
5369
5449
|
deliverTo
|
|
5370
5450
|
}, hooks).catch(async (error) => {
|
|
5371
|
-
const cancelled = error instanceof
|
|
5451
|
+
const cancelled = error instanceof import_nestjs_agent_core29.RunCancelledError;
|
|
5372
5452
|
const message = error instanceof Error ? error.message : String(error);
|
|
5373
5453
|
if (!cancelled) {
|
|
5374
5454
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
5375
|
-
(0,
|
|
5455
|
+
(0, import_nestjs_agent_core29.publishAgentRunFailed)({
|
|
5376
5456
|
runId,
|
|
5377
|
-
code: (0,
|
|
5457
|
+
code: (0, import_nestjs_agent_core29.agentFailureCode)(error),
|
|
5378
5458
|
message
|
|
5379
5459
|
});
|
|
5380
5460
|
}
|
|
@@ -5382,11 +5462,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5382
5462
|
runId,
|
|
5383
5463
|
status: cancelled ? "cancelled" : "failed",
|
|
5384
5464
|
...cancelled ? {} : {
|
|
5385
|
-
errorCode: (0,
|
|
5465
|
+
errorCode: (0, import_nestjs_agent_core29.agentFailureCode)(error),
|
|
5386
5466
|
errorMessage: message
|
|
5387
5467
|
}
|
|
5388
5468
|
});
|
|
5389
|
-
await (
|
|
5469
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core29.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
5470
|
+
await (0, import_nestjs_agent_core29.settleUnsettledDelegation)({
|
|
5390
5471
|
store: this.store,
|
|
5391
5472
|
delivery: deliverTo,
|
|
5392
5473
|
agent: agentName,
|
|
@@ -5425,7 +5506,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5425
5506
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
5426
5507
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
5427
5508
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
5428
|
-
parallel:
|
|
5509
|
+
parallel: import_nestjs_agent_core29.settleAll,
|
|
5429
5510
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
5430
5511
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
5431
5512
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -5460,7 +5541,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5460
5541
|
}), "startAgent")
|
|
5461
5542
|
};
|
|
5462
5543
|
try {
|
|
5463
|
-
return await (0,
|
|
5544
|
+
return await (0, import_nestjs_agent_core29.runAgentLoop)({
|
|
5464
5545
|
...deps,
|
|
5465
5546
|
day
|
|
5466
5547
|
}, {
|
|
@@ -5480,10 +5561,10 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5480
5561
|
}
|
|
5481
5562
|
};
|
|
5482
5563
|
InlineAgentRunner = _ts_decorate25([
|
|
5483
|
-
(0,
|
|
5484
|
-
_ts_param23(0, (0,
|
|
5485
|
-
_ts_param23(1, (0,
|
|
5486
|
-
_ts_param23(2, (0,
|
|
5564
|
+
(0, import_common26.Injectable)(),
|
|
5565
|
+
_ts_param23(0, (0, import_common26.Inject)(import_nestjs_agent_core29.AGENT_DEPS_FACTORY)),
|
|
5566
|
+
_ts_param23(1, (0, import_common26.Inject)(import_nestjs_agent_core29.AGENT_STORE)),
|
|
5567
|
+
_ts_param23(2, (0, import_common26.Optional)()),
|
|
5487
5568
|
_ts_metadata24("design:type", Function),
|
|
5488
5569
|
_ts_metadata24("design:paramtypes", [
|
|
5489
5570
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
@@ -5497,7 +5578,7 @@ function isThreadTurn2(input) {
|
|
|
5497
5578
|
__name(isThreadTurn2, "isThreadTurn");
|
|
5498
5579
|
|
|
5499
5580
|
// src/skills-config.ts
|
|
5500
|
-
var
|
|
5581
|
+
var import_nestjs_agent_core30 = require("@dudousxd/nestjs-agent-core");
|
|
5501
5582
|
function declaredSkillProvider(declared) {
|
|
5502
5583
|
return {
|
|
5503
5584
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -5523,7 +5604,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
5523
5604
|
declaredSkillProvider(declared)
|
|
5524
5605
|
];
|
|
5525
5606
|
return {
|
|
5526
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
5607
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core30.compositeSkillProvider)(providers),
|
|
5527
5608
|
...options.scopes !== void 0 ? {
|
|
5528
5609
|
scopes: options.scopes
|
|
5529
5610
|
} : {},
|
|
@@ -5550,11 +5631,11 @@ function _ts_decorate26(decorators, target, key, desc) {
|
|
|
5550
5631
|
}
|
|
5551
5632
|
__name(_ts_decorate26, "_ts_decorate");
|
|
5552
5633
|
var DEFAULT_PATH = "agent";
|
|
5553
|
-
var logger = new
|
|
5634
|
+
var logger = new import_common27.Logger("AgentModule");
|
|
5554
5635
|
function externalStoreWrapper(modules) {
|
|
5555
5636
|
for (const module2 of modules.values()) {
|
|
5556
5637
|
if (module2.metatype === AgentModule) continue;
|
|
5557
|
-
const wrapper = module2.providers.get(
|
|
5638
|
+
const wrapper = module2.providers.get(import_nestjs_agent_core31.AGENT_STORE);
|
|
5558
5639
|
if (wrapper !== void 0) return wrapper;
|
|
5559
5640
|
}
|
|
5560
5641
|
return void 0;
|
|
@@ -5585,7 +5666,7 @@ function resolveStore(options, modules) {
|
|
|
5585
5666
|
const external = externalStoreWrapper(modules);
|
|
5586
5667
|
if (external !== void 0) return forwardingStore(external);
|
|
5587
5668
|
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()).");
|
|
5588
|
-
return new
|
|
5669
|
+
return new import_nestjs_agent_core31.InMemoryAgentStore();
|
|
5589
5670
|
}
|
|
5590
5671
|
__name(resolveStore, "resolveStore");
|
|
5591
5672
|
function isQuotaProvider(quota) {
|
|
@@ -5601,99 +5682,99 @@ __name(resolveCatalog, "resolveCatalog");
|
|
|
5601
5682
|
function sharedProviders(durable) {
|
|
5602
5683
|
const providers = [
|
|
5603
5684
|
{
|
|
5604
|
-
provide:
|
|
5605
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
5685
|
+
provide: import_nestjs_agent_core31.AGENT_TOOL_REGISTRY,
|
|
5686
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core31.ToolRegistry(), "useFactory")
|
|
5606
5687
|
},
|
|
5607
5688
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
5608
5689
|
{
|
|
5609
|
-
provide:
|
|
5610
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
5690
|
+
provide: import_nestjs_agent_core31.AGENT_REGISTRY,
|
|
5691
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core31.AgentRegistry(), "useFactory")
|
|
5611
5692
|
},
|
|
5612
5693
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
5613
5694
|
{
|
|
5614
|
-
provide:
|
|
5695
|
+
provide: import_nestjs_agent_core31.AGENT_PROMPT_CONTRIBUTORS,
|
|
5615
5696
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
5616
5697
|
},
|
|
5617
5698
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
5618
5699
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
5619
5700
|
{
|
|
5620
|
-
provide:
|
|
5701
|
+
provide: import_nestjs_agent_core31.AGENT_SKILL_SOURCES,
|
|
5621
5702
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
5622
5703
|
},
|
|
5623
5704
|
{
|
|
5624
5705
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
5625
5706
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
5626
5707
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
5627
|
-
provide:
|
|
5708
|
+
provide: import_nestjs_agent_core31.AGENT_SKILLS,
|
|
5628
5709
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
5629
5710
|
inject: [
|
|
5630
|
-
|
|
5631
|
-
|
|
5711
|
+
import_nestjs_agent_core31.AGENT_OPTIONS,
|
|
5712
|
+
import_nestjs_agent_core31.AGENT_SKILL_SOURCES
|
|
5632
5713
|
]
|
|
5633
5714
|
},
|
|
5634
5715
|
{
|
|
5635
5716
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
5636
5717
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
5637
|
-
provide:
|
|
5718
|
+
provide: import_nestjs_agent_core31.AGENT_MEMORY,
|
|
5638
5719
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
5639
5720
|
inject: [
|
|
5640
|
-
|
|
5721
|
+
import_nestjs_agent_core31.AGENT_OPTIONS
|
|
5641
5722
|
]
|
|
5642
5723
|
},
|
|
5643
5724
|
{
|
|
5644
|
-
provide:
|
|
5725
|
+
provide: import_nestjs_agent_core31.AGENT_SINK,
|
|
5645
5726
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
5646
5727
|
inject: [
|
|
5647
|
-
|
|
5728
|
+
import_nestjs_agent_core31.AGENT_OPTIONS
|
|
5648
5729
|
]
|
|
5649
5730
|
},
|
|
5650
5731
|
{
|
|
5651
|
-
provide:
|
|
5652
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new
|
|
5732
|
+
provide: import_nestjs_agent_core31.AGENT_ROLES_POLICY,
|
|
5733
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core31.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
5653
5734
|
inject: [
|
|
5654
|
-
|
|
5735
|
+
import_nestjs_agent_core31.AGENT_OPTIONS
|
|
5655
5736
|
]
|
|
5656
5737
|
},
|
|
5657
5738
|
{
|
|
5658
|
-
provide:
|
|
5739
|
+
provide: import_nestjs_agent_core31.AGENT_ACTOR_RESOLVER,
|
|
5659
5740
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
5660
5741
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
5661
5742
|
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.");
|
|
5662
5743
|
return new AnonymousActorResolver();
|
|
5663
5744
|
}, "useFactory"),
|
|
5664
5745
|
inject: [
|
|
5665
|
-
|
|
5746
|
+
import_nestjs_agent_core31.AGENT_OPTIONS
|
|
5666
5747
|
]
|
|
5667
5748
|
},
|
|
5668
5749
|
{
|
|
5669
|
-
provide:
|
|
5750
|
+
provide: import_nestjs_agent_core31.AGENT_MODEL,
|
|
5670
5751
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
5671
5752
|
inject: [
|
|
5672
|
-
|
|
5753
|
+
import_nestjs_agent_core31.AGENT_OPTIONS
|
|
5673
5754
|
]
|
|
5674
5755
|
},
|
|
5675
5756
|
{
|
|
5676
5757
|
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
5677
5758
|
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
5678
|
-
provide:
|
|
5759
|
+
provide: import_nestjs_agent_core31.AGENT_QUOTA_PROVIDER,
|
|
5679
5760
|
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
|
|
5680
5761
|
warnAt: o.quota.warnAt
|
|
5681
5762
|
} : {}), "useFactory"),
|
|
5682
5763
|
inject: [
|
|
5683
|
-
|
|
5684
|
-
|
|
5764
|
+
import_nestjs_agent_core31.AGENT_OPTIONS,
|
|
5765
|
+
import_nestjs_agent_core31.AGENT_STORE
|
|
5685
5766
|
]
|
|
5686
5767
|
},
|
|
5687
5768
|
{
|
|
5688
|
-
provide:
|
|
5769
|
+
provide: import_nestjs_agent_core31.AGENT_MODEL_CATALOG,
|
|
5689
5770
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
5690
5771
|
inject: [
|
|
5691
|
-
|
|
5772
|
+
import_nestjs_agent_core31.AGENT_OPTIONS
|
|
5692
5773
|
]
|
|
5693
5774
|
},
|
|
5694
5775
|
AgentDepsFactory2,
|
|
5695
5776
|
{
|
|
5696
|
-
provide:
|
|
5777
|
+
provide: import_nestjs_agent_core31.AGENT_DEPS_FACTORY,
|
|
5697
5778
|
useExisting: AgentDepsFactory2
|
|
5698
5779
|
},
|
|
5699
5780
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -5710,21 +5791,21 @@ function sharedProviders(durable) {
|
|
|
5710
5791
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
5711
5792
|
AgentApprovalPortAdapter,
|
|
5712
5793
|
{
|
|
5713
|
-
provide:
|
|
5794
|
+
provide: import_nestjs_agent_core31.AGENT_APPROVAL_PORT,
|
|
5714
5795
|
useExisting: AgentApprovalPortAdapter
|
|
5715
5796
|
}
|
|
5716
5797
|
];
|
|
5717
5798
|
providers.push({
|
|
5718
|
-
provide:
|
|
5799
|
+
provide: import_nestjs_agent_core31.AGENT_STORE,
|
|
5719
5800
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
5720
5801
|
inject: [
|
|
5721
|
-
|
|
5802
|
+
import_nestjs_agent_core31.AGENT_OPTIONS,
|
|
5722
5803
|
import_core4.ModulesContainer
|
|
5723
5804
|
]
|
|
5724
5805
|
});
|
|
5725
5806
|
if (durable) {
|
|
5726
5807
|
providers.push({
|
|
5727
|
-
provide:
|
|
5808
|
+
provide: import_nestjs_agent_core31.AGENT_RUNNER,
|
|
5728
5809
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
5729
5810
|
if (durableRunner === void 0) {
|
|
5730
5811
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -5733,14 +5814,14 @@ function sharedProviders(durable) {
|
|
|
5733
5814
|
}, "useFactory"),
|
|
5734
5815
|
inject: [
|
|
5735
5816
|
{
|
|
5736
|
-
token:
|
|
5817
|
+
token: import_nestjs_agent_core31.AGENT_DURABLE_RUNNER,
|
|
5737
5818
|
optional: true
|
|
5738
5819
|
}
|
|
5739
5820
|
]
|
|
5740
5821
|
});
|
|
5741
5822
|
} else {
|
|
5742
5823
|
providers.push({
|
|
5743
|
-
provide:
|
|
5824
|
+
provide: import_nestjs_agent_core31.AGENT_RUNNER,
|
|
5744
5825
|
useExisting: InlineAgentRunner
|
|
5745
5826
|
});
|
|
5746
5827
|
}
|
|
@@ -5749,25 +5830,25 @@ function sharedProviders(durable) {
|
|
|
5749
5830
|
__name(sharedProviders, "sharedProviders");
|
|
5750
5831
|
function exportsFor() {
|
|
5751
5832
|
return [
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5833
|
+
import_nestjs_agent_core31.AGENT_OPTIONS,
|
|
5834
|
+
import_nestjs_agent_core31.AGENT_TOOL_REGISTRY,
|
|
5835
|
+
import_nestjs_agent_core31.AGENT_REGISTRY,
|
|
5836
|
+
import_nestjs_agent_core31.AGENT_SINK,
|
|
5837
|
+
import_nestjs_agent_core31.AGENT_ROLES_POLICY,
|
|
5838
|
+
import_nestjs_agent_core31.AGENT_ACTOR_RESOLVER,
|
|
5839
|
+
import_nestjs_agent_core31.AGENT_MODEL,
|
|
5840
|
+
import_nestjs_agent_core31.AGENT_STORE,
|
|
5841
|
+
import_nestjs_agent_core31.AGENT_MODEL_CATALOG,
|
|
5842
|
+
import_nestjs_agent_core31.AGENT_QUOTA_PROVIDER,
|
|
5843
|
+
import_nestjs_agent_core31.AGENT_PROMPT_CONTRIBUTORS,
|
|
5844
|
+
import_nestjs_agent_core31.AGENT_SKILLS,
|
|
5845
|
+
import_nestjs_agent_core31.AGENT_MEMORY,
|
|
5846
|
+
import_nestjs_agent_core31.AGENT_DEPS_FACTORY,
|
|
5766
5847
|
AgentDepsFactory2,
|
|
5767
5848
|
AgentService,
|
|
5768
5849
|
ChatQueueService,
|
|
5769
5850
|
InlineAgentRunner,
|
|
5770
|
-
|
|
5851
|
+
import_nestjs_agent_core31.AGENT_APPROVAL_PORT
|
|
5771
5852
|
];
|
|
5772
5853
|
}
|
|
5773
5854
|
__name(exportsFor, "exportsFor");
|
|
@@ -5831,7 +5912,7 @@ var AgentModule = class _AgentModule {
|
|
|
5831
5912
|
controllers: controllersForSurface(options.surface),
|
|
5832
5913
|
providers: [
|
|
5833
5914
|
{
|
|
5834
|
-
provide:
|
|
5915
|
+
provide: import_nestjs_agent_core31.AGENT_OPTIONS,
|
|
5835
5916
|
useValue: options
|
|
5836
5917
|
},
|
|
5837
5918
|
...sharedProviders(options.durable ?? false),
|
|
@@ -5854,7 +5935,7 @@ var AgentModule = class _AgentModule {
|
|
|
5854
5935
|
controllers: controllersForSurface(options.surface),
|
|
5855
5936
|
providers: [
|
|
5856
5937
|
{
|
|
5857
|
-
provide:
|
|
5938
|
+
provide: import_nestjs_agent_core31.AGENT_OPTIONS,
|
|
5858
5939
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
5859
5940
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
5860
5941
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -5876,8 +5957,8 @@ var AgentModule = class _AgentModule {
|
|
|
5876
5957
|
}
|
|
5877
5958
|
};
|
|
5878
5959
|
AgentModule = _ts_decorate26([
|
|
5879
|
-
(0,
|
|
5880
|
-
(0,
|
|
5960
|
+
(0, import_common27.Global)(),
|
|
5961
|
+
(0, import_common27.Module)({})
|
|
5881
5962
|
], AgentModule);
|
|
5882
5963
|
|
|
5883
5964
|
// src/durable/agent-durable.ts
|