@dudousxd/nestjs-agent 1.21.0 → 1.23.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 +7 -0
- package/dist/{chat-queue.service-XG9RQCjU.d.ts → chat-queue.service-CwxJDrBM.d.ts} +76 -5
- package/dist/{chat-queue.service-CGsR40Ct.d.cts → chat-queue.service-D1z3WjFI.d.cts} +76 -5
- package/dist/durable/index.cjs +398 -256
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +1 -1
- package/dist/durable/index.d.ts +1 -1
- package/dist/durable/index.js +186 -44
- package/dist/durable/index.js.map +1 -1
- package/dist/genui/index.cjs +1 -0
- package/dist/genui/index.cjs.map +1 -1
- package/dist/genui/index.js +1 -0
- package/dist/genui/index.js.map +1 -1
- package/dist/index.cjs +468 -269
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -14
- package/dist/index.d.ts +51 -14
- package/dist/index.js +249 -51
- package/dist/index.js.map +1 -1
- package/dist/sink-redis/index.cjs +7 -2
- package/dist/sink-redis/index.cjs.map +1 -1
- package/dist/sink-redis/index.d.cts +6 -3
- package/dist/sink-redis/index.d.ts +6 -3
- package/dist/sink-redis/index.js +7 -2
- package/dist/sink-redis/index.js.map +1 -1
- package/package.json +4 -4
package/dist/durable/index.cjs
CHANGED
|
@@ -1199,14 +1199,14 @@ AgentDurableModule = _ts_decorate4([
|
|
|
1199
1199
|
], AgentDurableModule);
|
|
1200
1200
|
|
|
1201
1201
|
// src/agent.module.ts
|
|
1202
|
-
var
|
|
1202
|
+
var import_nestjs_agent_core39 = require("@dudousxd/nestjs-agent-core");
|
|
1203
1203
|
var import_common31 = require("@nestjs/common");
|
|
1204
1204
|
var import_core4 = require("@nestjs/core");
|
|
1205
1205
|
|
|
1206
1206
|
// src/agent-deps.factory.ts
|
|
1207
|
-
var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
1208
1207
|
var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
|
|
1209
1208
|
var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
|
|
1209
|
+
var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
|
|
1210
1210
|
var import_common6 = require("@nestjs/common");
|
|
1211
1211
|
|
|
1212
1212
|
// src/genui/agent-genui.module.ts
|
|
@@ -1214,6 +1214,7 @@ var import_genui = require("@dudousxd/nestjs-agent-core/genui");
|
|
|
1214
1214
|
var import_common5 = require("@nestjs/common");
|
|
1215
1215
|
|
|
1216
1216
|
// src/functional-tool.ts
|
|
1217
|
+
var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
1217
1218
|
var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
|
|
1218
1219
|
function brand(tool) {
|
|
1219
1220
|
return {
|
|
@@ -1417,7 +1418,7 @@ var AgentDepsFactory2 = class {
|
|
|
1417
1418
|
this.memory = memory;
|
|
1418
1419
|
this.uiCatalog = uiCatalog;
|
|
1419
1420
|
this.uiCatalogResolver = uiCatalogResolver;
|
|
1420
|
-
if (options.actionApprovalMode === "independent") (0,
|
|
1421
|
+
if (options.actionApprovalMode === "independent") (0, import_nestjs_agent_core9.assertIndependentActionCapabilities)(store, options.backgroundActorResolver);
|
|
1421
1422
|
}
|
|
1422
1423
|
/** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
|
|
1423
1424
|
memoryConfig() {
|
|
@@ -1443,7 +1444,7 @@ var AgentDepsFactory2 = class {
|
|
|
1443
1444
|
return void 0;
|
|
1444
1445
|
}
|
|
1445
1446
|
const delegated = (definition.delegatesTo ?? []).map((edge) => {
|
|
1446
|
-
const { agent, detached } = (0,
|
|
1447
|
+
const { agent, detached } = (0, import_nestjs_agent_core10.normalizeDelegation)(edge);
|
|
1447
1448
|
return delegateToolName({
|
|
1448
1449
|
target: agent,
|
|
1449
1450
|
detached
|
|
@@ -1467,7 +1468,7 @@ var AgentDepsFactory2 = class {
|
|
|
1467
1468
|
agentName: name
|
|
1468
1469
|
};
|
|
1469
1470
|
}
|
|
1470
|
-
const alias = (0,
|
|
1471
|
+
const alias = (0, import_nestjs_agent_core10.resolvePersonaAlias)(this.agents.list(), name);
|
|
1471
1472
|
return alias === void 0 ? {
|
|
1472
1473
|
agentName: name
|
|
1473
1474
|
} : {
|
|
@@ -1477,7 +1478,7 @@ var AgentDepsFactory2 = class {
|
|
|
1477
1478
|
}
|
|
1478
1479
|
/** `agentName`'s personas as a picker reads them. Empty when it declares none. */
|
|
1479
1480
|
personaCatalog(agentName) {
|
|
1480
|
-
return (this.agents.get(agentName)?.personas ?? []).map(
|
|
1481
|
+
return (this.agents.get(agentName)?.personas ?? []).map(import_nestjs_agent_core10.personaCatalogEntry);
|
|
1481
1482
|
}
|
|
1482
1483
|
/** The persona `agentName` runs under when nothing names one. Undefined → none. */
|
|
1483
1484
|
defaultPersona(agentName) {
|
|
@@ -1491,7 +1492,7 @@ var AgentDepsFactory2 = class {
|
|
|
1491
1492
|
resolvePersona(args) {
|
|
1492
1493
|
const definition = this.agents.get(args.agentName);
|
|
1493
1494
|
if (args.requested !== void 0) {
|
|
1494
|
-
if ((0,
|
|
1495
|
+
if ((0, import_nestjs_agent_core10.findPersona)(definition, args.requested) === void 0) {
|
|
1495
1496
|
throw new import_common6.BadRequestException({
|
|
1496
1497
|
statusCode: 400,
|
|
1497
1498
|
code: "persona_not_found",
|
|
@@ -1501,7 +1502,7 @@ var AgentDepsFactory2 = class {
|
|
|
1501
1502
|
return args.requested;
|
|
1502
1503
|
}
|
|
1503
1504
|
const pinned = args.threadPersona ?? void 0;
|
|
1504
|
-
if (pinned !== void 0 && (0,
|
|
1505
|
+
if (pinned !== void 0 && (0, import_nestjs_agent_core10.findPersona)(definition, pinned) !== void 0) {
|
|
1505
1506
|
return pinned;
|
|
1506
1507
|
}
|
|
1507
1508
|
return definition?.defaultPersona;
|
|
@@ -1521,8 +1522,8 @@ var AgentDepsFactory2 = class {
|
|
|
1521
1522
|
forAgent(agentName) {
|
|
1522
1523
|
const name = agentName ?? this.defaultAgentName();
|
|
1523
1524
|
if (agentName !== void 0 && !this.agents.has(agentName)) {
|
|
1524
|
-
const alias = (0,
|
|
1525
|
-
const persona = alias === void 0 ? void 0 : (0,
|
|
1525
|
+
const alias = (0, import_nestjs_agent_core10.resolvePersonaAlias)(this.agents.list(), agentName);
|
|
1526
|
+
const persona = alias === void 0 ? void 0 : (0, import_nestjs_agent_core10.findPersona)(this.agents.get(alias.agent), alias.persona);
|
|
1526
1527
|
if (alias !== void 0 && persona !== void 0) {
|
|
1527
1528
|
return this.withPersona(this.forAgent(alias.agent), persona);
|
|
1528
1529
|
}
|
|
@@ -1656,7 +1657,7 @@ var AgentDepsFactory2 = class {
|
|
|
1656
1657
|
} : {}
|
|
1657
1658
|
});
|
|
1658
1659
|
}, "systemPrompt");
|
|
1659
|
-
const toolAllowList = (0,
|
|
1660
|
+
const toolAllowList = (0, import_nestjs_agent_core10.intersectAllowLists)(deps.toolAllowList, persona.allowedTools);
|
|
1660
1661
|
return {
|
|
1661
1662
|
...deps,
|
|
1662
1663
|
systemPrompt,
|
|
@@ -1681,7 +1682,7 @@ var AgentDepsFactory2 = class {
|
|
|
1681
1682
|
}
|
|
1682
1683
|
/** Build the built-in window policy from the declarative `{ maxMessages, maxTokens, summarize }`. */
|
|
1683
1684
|
window(config) {
|
|
1684
|
-
return (0,
|
|
1685
|
+
return (0, import_nestjs_agent_core10.windowHistory)({
|
|
1685
1686
|
...config.maxMessages !== void 0 ? {
|
|
1686
1687
|
maxMessages: config.maxMessages
|
|
1687
1688
|
} : {},
|
|
@@ -1691,7 +1692,7 @@ var AgentDepsFactory2 = class {
|
|
|
1691
1692
|
// The shared module model, not a per-agent one: an agent's `modelId` is an accounting label,
|
|
1692
1693
|
// and only one provider is ever bound.
|
|
1693
1694
|
...config.summarize === true ? {
|
|
1694
|
-
summarize: (0,
|
|
1695
|
+
summarize: (0, import_nestjs_agent_core10.summarizeWithModel)(this.model)
|
|
1695
1696
|
} : {}
|
|
1696
1697
|
});
|
|
1697
1698
|
}
|
|
@@ -1709,20 +1710,20 @@ var AgentDepsFactory2 = class {
|
|
|
1709
1710
|
};
|
|
1710
1711
|
AgentDepsFactory2 = _ts_decorate6([
|
|
1711
1712
|
(0, import_common6.Injectable)(),
|
|
1712
|
-
_ts_param4(0, (0, import_common6.Inject)(
|
|
1713
|
-
_ts_param4(1, (0, import_common6.Inject)(
|
|
1714
|
-
_ts_param4(2, (0, import_common6.Inject)(
|
|
1715
|
-
_ts_param4(3, (0, import_common6.Inject)(
|
|
1716
|
-
_ts_param4(4, (0, import_common6.Inject)(
|
|
1717
|
-
_ts_param4(5, (0, import_common6.Inject)(
|
|
1718
|
-
_ts_param4(6, (0, import_common6.Inject)(
|
|
1719
|
-
_ts_param4(7, (0, import_common6.Inject)(
|
|
1713
|
+
_ts_param4(0, (0, import_common6.Inject)(import_nestjs_agent_core11.AGENT_OPTIONS)),
|
|
1714
|
+
_ts_param4(1, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_MODEL)),
|
|
1715
|
+
_ts_param4(2, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_STORE)),
|
|
1716
|
+
_ts_param4(3, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_SINK)),
|
|
1717
|
+
_ts_param4(4, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_ROLES_POLICY)),
|
|
1718
|
+
_ts_param4(5, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_TOOL_REGISTRY)),
|
|
1719
|
+
_ts_param4(6, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_REGISTRY)),
|
|
1720
|
+
_ts_param4(7, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_PROMPT_CONTRIBUTORS)),
|
|
1720
1721
|
_ts_param4(8, (0, import_common6.Optional)()),
|
|
1721
|
-
_ts_param4(8, (0, import_common6.Inject)(
|
|
1722
|
+
_ts_param4(8, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_PRICING_STORE)),
|
|
1722
1723
|
_ts_param4(9, (0, import_common6.Optional)()),
|
|
1723
|
-
_ts_param4(9, (0, import_common6.Inject)(
|
|
1724
|
+
_ts_param4(9, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_SKILLS)),
|
|
1724
1725
|
_ts_param4(10, (0, import_common6.Optional)()),
|
|
1725
|
-
_ts_param4(10, (0, import_common6.Inject)(
|
|
1726
|
+
_ts_param4(10, (0, import_common6.Inject)(import_nestjs_agent_core10.AGENT_MEMORY)),
|
|
1726
1727
|
_ts_param4(11, (0, import_common6.Optional)()),
|
|
1727
1728
|
_ts_param4(11, (0, import_common6.Inject)(GENUI_CATALOG)),
|
|
1728
1729
|
_ts_param4(12, (0, import_common6.Optional)()),
|
|
@@ -1733,8 +1734,8 @@ AgentDepsFactory2 = _ts_decorate6([
|
|
|
1733
1734
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1734
1735
|
typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
|
|
1735
1736
|
typeof RolesPolicy === "undefined" ? Object : RolesPolicy,
|
|
1736
|
-
typeof
|
|
1737
|
-
typeof
|
|
1737
|
+
typeof import_nestjs_agent_core10.ToolRegistry === "undefined" ? Object : import_nestjs_agent_core10.ToolRegistry,
|
|
1738
|
+
typeof import_nestjs_agent_core10.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core10.AgentRegistry,
|
|
1738
1739
|
Array,
|
|
1739
1740
|
Object,
|
|
1740
1741
|
Object,
|
|
@@ -1745,11 +1746,11 @@ AgentDepsFactory2 = _ts_decorate6([
|
|
|
1745
1746
|
], AgentDepsFactory2);
|
|
1746
1747
|
|
|
1747
1748
|
// src/agent.service.ts
|
|
1748
|
-
var
|
|
1749
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
1749
1750
|
var import_common10 = require("@nestjs/common");
|
|
1750
1751
|
|
|
1751
1752
|
// src/proposals/action-proposal.service.ts
|
|
1752
|
-
var
|
|
1753
|
+
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
1753
1754
|
var import_common7 = require("@nestjs/common");
|
|
1754
1755
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
1755
1756
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1786,7 +1787,19 @@ var ActionProposalService = class {
|
|
|
1786
1787
|
constructor(store, options) {
|
|
1787
1788
|
this.store = store;
|
|
1788
1789
|
this.options = options;
|
|
1790
|
+
const text = options.actionProposalText;
|
|
1791
|
+
this.vocabulary = {
|
|
1792
|
+
...import_nestjs_agent_core12.DEFAULT_TEXT_ACTION_PROPOSAL_VOCABULARY,
|
|
1793
|
+
...text?.vocabulary
|
|
1794
|
+
};
|
|
1795
|
+
this.replies = {
|
|
1796
|
+
...import_nestjs_agent_core12.DEFAULT_TEXT_ACTION_PROPOSAL_REPLIES,
|
|
1797
|
+
...text?.replies
|
|
1798
|
+
};
|
|
1789
1799
|
}
|
|
1800
|
+
/** The words a text decision is made of, and what the agent answers — English unless configured. */
|
|
1801
|
+
vocabulary;
|
|
1802
|
+
replies;
|
|
1790
1803
|
capability() {
|
|
1791
1804
|
const store = this.store;
|
|
1792
1805
|
if (typeof store.getThreadActionProposalScope !== "function" || typeof store.listActionProposals !== "function") throw new import_common7.NotImplementedException("Action proposals are unavailable");
|
|
@@ -1799,7 +1812,7 @@ var ActionProposalService = class {
|
|
|
1799
1812
|
return scope;
|
|
1800
1813
|
}
|
|
1801
1814
|
mayDecide(actor, proposal) {
|
|
1802
|
-
return (0,
|
|
1815
|
+
return (0, import_nestjs_agent_core12.mayDecideApproval)(this.options.approvalPolicy, actor, {
|
|
1803
1816
|
toolCallId: proposal.originToolCallId,
|
|
1804
1817
|
approver: proposal.approver,
|
|
1805
1818
|
requesterRef: proposal.actorRef
|
|
@@ -1815,7 +1828,8 @@ var ActionProposalService = class {
|
|
|
1815
1828
|
for (const row of rows) if (scope.actorRef === actor.id || await this.mayDecide(actor, row)) visible.push(row);
|
|
1816
1829
|
const last = rows.at(-1);
|
|
1817
1830
|
return {
|
|
1818
|
-
|
|
1831
|
+
// The public view: a row carries the worker's lease token and the tool's idempotency key.
|
|
1832
|
+
items: visible.map(import_nestjs_agent_core12.toActionProposalView),
|
|
1819
1833
|
...rows.length === 1e3 && last ? {
|
|
1820
1834
|
next: {
|
|
1821
1835
|
createdAt: last.createdAt,
|
|
@@ -1832,7 +1846,7 @@ var ActionProposalService = class {
|
|
|
1832
1846
|
const proposal = await this.capability().getActionProposal(scope, proposalId);
|
|
1833
1847
|
if (!proposal) throw new import_common7.NotFoundException("Proposal not found");
|
|
1834
1848
|
if (!await this.mayDecide(actor, proposal)) throw new import_common7.ForbiddenException("May not decide this proposal");
|
|
1835
|
-
|
|
1849
|
+
const result = await this.capability().decideActionProposal(scope, proposalId, {
|
|
1836
1850
|
decision: command.decision,
|
|
1837
1851
|
actorRef: actor.id,
|
|
1838
1852
|
via: command.via ?? "web",
|
|
@@ -1843,9 +1857,10 @@ var ActionProposalService = class {
|
|
|
1843
1857
|
reason: command.reason
|
|
1844
1858
|
} : {}
|
|
1845
1859
|
});
|
|
1860
|
+
return (0, import_nestjs_agent_core12.toActionProposalMutationView)(result);
|
|
1846
1861
|
}
|
|
1847
1862
|
async handleTextDecision(threadId, actor, text) {
|
|
1848
|
-
const command = (0,
|
|
1863
|
+
const command = (0, import_nestjs_agent_core12.parseTextActionProposalCommand)(text, this.vocabulary);
|
|
1849
1864
|
if (command.status === "unmatched") return command;
|
|
1850
1865
|
if (command.proposalId !== void 0) {
|
|
1851
1866
|
const result2 = await this.decide(threadId, command.proposalId, actor, {
|
|
@@ -1853,7 +1868,7 @@ var ActionProposalService = class {
|
|
|
1853
1868
|
remember: command.remember,
|
|
1854
1869
|
via: "text"
|
|
1855
1870
|
});
|
|
1856
|
-
return this.textReceipt(threadId, result2);
|
|
1871
|
+
return this.textReceipt(threadId, result2, command.decision);
|
|
1857
1872
|
}
|
|
1858
1873
|
const candidates = [];
|
|
1859
1874
|
const scope = await this.scope(threadId, actor);
|
|
@@ -1862,35 +1877,43 @@ var ActionProposalService = class {
|
|
|
1862
1877
|
limit: 1e3
|
|
1863
1878
|
});
|
|
1864
1879
|
for (const proposal of pending) if (await this.mayDecide(actor, proposal)) candidates.push(proposal);
|
|
1865
|
-
const resolution = (0,
|
|
1880
|
+
const resolution = (0, import_nestjs_agent_core12.resolveTextActionProposalDecision)(text, candidates, this.vocabulary);
|
|
1866
1881
|
if (resolution.status === "unmatched") return resolution;
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1882
|
+
const saturated = pending.length === 1e3 && !text.includes("#");
|
|
1883
|
+
if (resolution.status === "ambiguous" || saturated) {
|
|
1884
|
+
const proposalIds = candidates.map(({ id }) => id);
|
|
1885
|
+
return {
|
|
1886
|
+
threadId,
|
|
1887
|
+
proposalDecision: {
|
|
1888
|
+
status: "ambiguous",
|
|
1889
|
+
proposalIds
|
|
1890
|
+
},
|
|
1891
|
+
text: saturated ? this.replies.tooMany : this.replies.ambiguous(proposalIds)
|
|
1892
|
+
};
|
|
1893
|
+
}
|
|
1875
1894
|
const result = await this.decide(threadId, resolution.proposalId, actor, {
|
|
1876
1895
|
decision: resolution.decision,
|
|
1877
1896
|
remember: resolution.remember,
|
|
1878
1897
|
via: "text"
|
|
1879
1898
|
});
|
|
1880
|
-
return this.textReceipt(threadId, result);
|
|
1899
|
+
return this.textReceipt(threadId, result, resolution.decision);
|
|
1881
1900
|
}
|
|
1882
|
-
textReceipt(threadId, result) {
|
|
1901
|
+
textReceipt(threadId, result, decision) {
|
|
1883
1902
|
return {
|
|
1884
1903
|
threadId,
|
|
1885
1904
|
proposalDecision: result,
|
|
1886
|
-
text:
|
|
1905
|
+
text: this.reply(result, decision)
|
|
1887
1906
|
};
|
|
1888
1907
|
}
|
|
1908
|
+
/** The configured reply to a decision the store answered with `result`. */
|
|
1909
|
+
reply(result, decision) {
|
|
1910
|
+
return (0, import_nestjs_agent_core12.textActionProposalReply)(result, decision, this.replies);
|
|
1911
|
+
}
|
|
1889
1912
|
};
|
|
1890
1913
|
ActionProposalService = _ts_decorate7([
|
|
1891
1914
|
(0, import_common7.Injectable)(),
|
|
1892
|
-
_ts_param5(0, (0, import_common7.Inject)(
|
|
1893
|
-
_ts_param5(1, (0, import_common7.Inject)(
|
|
1915
|
+
_ts_param5(0, (0, import_common7.Inject)(import_nestjs_agent_core12.AGENT_STORE)),
|
|
1916
|
+
_ts_param5(1, (0, import_common7.Inject)(import_nestjs_agent_core12.AGENT_OPTIONS)),
|
|
1894
1917
|
_ts_metadata5("design:type", Function),
|
|
1895
1918
|
_ts_metadata5("design:paramtypes", [
|
|
1896
1919
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
@@ -1899,9 +1922,36 @@ ActionProposalService = _ts_decorate7([
|
|
|
1899
1922
|
], ActionProposalService);
|
|
1900
1923
|
|
|
1901
1924
|
// src/queue/chat-queue.service.ts
|
|
1902
|
-
var
|
|
1925
|
+
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
1903
1926
|
var import_common8 = require("@nestjs/common");
|
|
1904
1927
|
|
|
1928
|
+
// src/quota-exceeded.ts
|
|
1929
|
+
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
1930
|
+
function publishQuotaBlocked(actor, report, blocked) {
|
|
1931
|
+
const window = report.windows.find((candidate) => candidate.period === blocked.period);
|
|
1932
|
+
const payload = {
|
|
1933
|
+
actorId: actor.id,
|
|
1934
|
+
period: blocked.period,
|
|
1935
|
+
...blocked.reason !== void 0 ? {
|
|
1936
|
+
reason: blocked.reason
|
|
1937
|
+
} : {},
|
|
1938
|
+
...window?.usedTokens !== void 0 ? {
|
|
1939
|
+
usedTokens: window.usedTokens
|
|
1940
|
+
} : {},
|
|
1941
|
+
...window?.limitTokens !== void 0 ? {
|
|
1942
|
+
limitTokens: window.limitTokens
|
|
1943
|
+
} : {},
|
|
1944
|
+
...window !== void 0 ? {
|
|
1945
|
+
usedUsd: window.usedUsd
|
|
1946
|
+
} : {},
|
|
1947
|
+
...window?.limitUsd !== void 0 ? {
|
|
1948
|
+
limitUsd: window.limitUsd
|
|
1949
|
+
} : {}
|
|
1950
|
+
};
|
|
1951
|
+
(0, import_nestjs_agent_core13.publishAgentQuotaExceeded)(payload);
|
|
1952
|
+
}
|
|
1953
|
+
__name(publishQuotaBlocked, "publishQuotaBlocked");
|
|
1954
|
+
|
|
1905
1955
|
// src/thread-persona.ts
|
|
1906
1956
|
async function threadPersona(store, threadId) {
|
|
1907
1957
|
const projecting = store;
|
|
@@ -1966,11 +2016,11 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1966
2016
|
}
|
|
1967
2017
|
/** Whether the bound store can hold a queue. Without one, a busy thread is not queued. */
|
|
1968
2018
|
get supported() {
|
|
1969
|
-
return (0,
|
|
2019
|
+
return (0, import_nestjs_agent_core14.isChatQueueStore)(this.store);
|
|
1970
2020
|
}
|
|
1971
2021
|
/** The bound store as a queue store, or a 501 naming what is missing. */
|
|
1972
2022
|
queueStore() {
|
|
1973
|
-
if (!(0,
|
|
2023
|
+
if (!(0, import_nestjs_agent_core14.isChatQueueStore)(this.store)) {
|
|
1974
2024
|
throw new import_common8.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore (enqueueMessage, listQueue, \u2026, claimActiveStream, releaseActiveStream); the bound store does not.");
|
|
1975
2025
|
}
|
|
1976
2026
|
return this.store;
|
|
@@ -1982,7 +2032,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
1982
2032
|
store.queuePause(threadId)
|
|
1983
2033
|
]);
|
|
1984
2034
|
return {
|
|
1985
|
-
items: items.map(
|
|
2035
|
+
items: items.map(import_nestjs_agent_core14.queuedMessageView),
|
|
1986
2036
|
paused
|
|
1987
2037
|
};
|
|
1988
2038
|
}
|
|
@@ -2033,7 +2083,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
2033
2083
|
* A no-op returning `{}` on a store without a queue.
|
|
2034
2084
|
*/
|
|
2035
2085
|
async plan(args) {
|
|
2036
|
-
if (!(0,
|
|
2086
|
+
if (!(0, import_nestjs_agent_core14.isChatQueueStore)(this.store)) {
|
|
2037
2087
|
return {};
|
|
2038
2088
|
}
|
|
2039
2089
|
const store = this.store;
|
|
@@ -2133,7 +2183,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
2133
2183
|
* (its settle drains) or while the queue is paused. Answers the started run's id, if any.
|
|
2134
2184
|
*/
|
|
2135
2185
|
async kick(threadId, runner) {
|
|
2136
|
-
if (!(0,
|
|
2186
|
+
if (!(0, import_nestjs_agent_core14.isChatQueueStore)(this.store)) {
|
|
2137
2187
|
return void 0;
|
|
2138
2188
|
}
|
|
2139
2189
|
const { live, stale } = await this.holder(threadId, runner);
|
|
@@ -2201,6 +2251,9 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
2201
2251
|
} : {},
|
|
2202
2252
|
...input.uiCapabilities !== void 0 ? {
|
|
2203
2253
|
uiCapabilities: input.uiCapabilities
|
|
2254
|
+
} : {},
|
|
2255
|
+
...input.hostContext !== void 0 ? {
|
|
2256
|
+
hostContext: input.hostContext
|
|
2204
2257
|
} : {}
|
|
2205
2258
|
});
|
|
2206
2259
|
await store.setQueuePause(threadId, {
|
|
@@ -2237,7 +2290,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
2237
2290
|
}
|
|
2238
2291
|
async write(runId, frame) {
|
|
2239
2292
|
const writer = await this.sink.open(runId);
|
|
2240
|
-
await writer.write((0,
|
|
2293
|
+
await writer.write((0, import_nestjs_agent_core14.encodeStreamEvent)(frame));
|
|
2241
2294
|
}
|
|
2242
2295
|
/** Why `actor` may not start a turn now (the quota message), or `null`. */
|
|
2243
2296
|
async quotaBlock(actor) {
|
|
@@ -2245,12 +2298,14 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
2245
2298
|
return null;
|
|
2246
2299
|
}
|
|
2247
2300
|
try {
|
|
2248
|
-
const
|
|
2301
|
+
const report = await this.quotaProvider.report({
|
|
2249
2302
|
actor
|
|
2250
2303
|
});
|
|
2304
|
+
const { blocked } = report;
|
|
2251
2305
|
if (blocked === void 0) {
|
|
2252
2306
|
return null;
|
|
2253
2307
|
}
|
|
2308
|
+
publishQuotaBlocked(actor, report, blocked);
|
|
2254
2309
|
return blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`;
|
|
2255
2310
|
} catch {
|
|
2256
2311
|
return null;
|
|
@@ -2284,6 +2339,9 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
2284
2339
|
...message.uiCapabilities !== void 0 ? {
|
|
2285
2340
|
uiCapabilities: message.uiCapabilities
|
|
2286
2341
|
} : {},
|
|
2342
|
+
...message.hostContext !== void 0 ? {
|
|
2343
|
+
hostContext: message.hostContext
|
|
2344
|
+
} : {},
|
|
2287
2345
|
...message.model !== void 0 ? {
|
|
2288
2346
|
model: message.model
|
|
2289
2347
|
} : {}
|
|
@@ -2339,16 +2397,16 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
2339
2397
|
};
|
|
2340
2398
|
ChatQueueService2 = _ts_decorate8([
|
|
2341
2399
|
(0, import_common8.Injectable)(),
|
|
2342
|
-
_ts_param6(0, (0, import_common8.Inject)(
|
|
2343
|
-
_ts_param6(1, (0, import_common8.Inject)(
|
|
2400
|
+
_ts_param6(0, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_STORE)),
|
|
2401
|
+
_ts_param6(1, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_SINK)),
|
|
2344
2402
|
_ts_param6(2, (0, import_common8.Optional)()),
|
|
2345
|
-
_ts_param6(2, (0, import_common8.Inject)(
|
|
2403
|
+
_ts_param6(2, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_QUOTA_PROVIDER)),
|
|
2346
2404
|
_ts_param6(3, (0, import_common8.Optional)()),
|
|
2347
|
-
_ts_param6(3, (0, import_common8.Inject)(
|
|
2405
|
+
_ts_param6(3, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_OPTIONS)),
|
|
2348
2406
|
_ts_param6(4, (0, import_common8.Optional)()),
|
|
2349
|
-
_ts_param6(4, (0, import_common8.Inject)(
|
|
2407
|
+
_ts_param6(4, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_ATTACHMENT_STAGING)),
|
|
2350
2408
|
_ts_param6(5, (0, import_common8.Optional)()),
|
|
2351
|
-
_ts_param6(5, (0, import_common8.Inject)(
|
|
2409
|
+
_ts_param6(5, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_DEPS_FACTORY)),
|
|
2352
2410
|
_ts_metadata6("design:type", Function),
|
|
2353
2411
|
_ts_metadata6("design:paramtypes", [
|
|
2354
2412
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
@@ -2373,7 +2431,7 @@ function queueFrame(items, paused, started) {
|
|
|
2373
2431
|
return {
|
|
2374
2432
|
kind: "queue",
|
|
2375
2433
|
queue: {
|
|
2376
|
-
items: items.map(
|
|
2434
|
+
items: items.map(import_nestjs_agent_core14.queuedMessageView),
|
|
2377
2435
|
paused
|
|
2378
2436
|
},
|
|
2379
2437
|
...started !== void 0 ? {
|
|
@@ -2384,19 +2442,19 @@ function queueFrame(items, paused, started) {
|
|
|
2384
2442
|
__name(queueFrame, "queueFrame");
|
|
2385
2443
|
|
|
2386
2444
|
// src/run-not-active.exception.ts
|
|
2387
|
-
var
|
|
2445
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
2388
2446
|
var import_common9 = require("@nestjs/common");
|
|
2389
2447
|
var RunNotActiveException = class extends import_common9.ConflictException {
|
|
2390
2448
|
static {
|
|
2391
2449
|
__name(this, "RunNotActiveException");
|
|
2392
2450
|
}
|
|
2393
2451
|
runId;
|
|
2394
|
-
code =
|
|
2452
|
+
code = import_nestjs_agent_core15.RUN_NOT_ACTIVE_CODE;
|
|
2395
2453
|
constructor(runId) {
|
|
2396
2454
|
super({
|
|
2397
2455
|
statusCode: 409,
|
|
2398
|
-
code:
|
|
2399
|
-
message:
|
|
2456
|
+
code: import_nestjs_agent_core15.RUN_NOT_ACTIVE_CODE,
|
|
2457
|
+
message: import_nestjs_agent_core15.RUN_NOT_ACTIVE_MESSAGE
|
|
2400
2458
|
}), this.runId = runId;
|
|
2401
2459
|
}
|
|
2402
2460
|
};
|
|
@@ -2452,6 +2510,21 @@ var AgentService = class {
|
|
|
2452
2510
|
this.queue = queue;
|
|
2453
2511
|
this.proposals = proposals;
|
|
2454
2512
|
}
|
|
2513
|
+
/**
|
|
2514
|
+
* Decide one independent proposal through the scoped proposal service — what the native
|
|
2515
|
+
* `action-proposals/:id/approve|reject` routes call — and the reply to show for it. `404` when
|
|
2516
|
+
* proposals are not on, `403`/`404` when this actor may not decide it.
|
|
2517
|
+
*/
|
|
2518
|
+
async decideActionProposal(actor, threadId, proposalId, command) {
|
|
2519
|
+
if (this.options?.actionApprovalMode !== "independent" || !this.proposals) {
|
|
2520
|
+
throw new import_common10.NotFoundException("Proposal not found");
|
|
2521
|
+
}
|
|
2522
|
+
const result = await this.proposals.decide(threadId, proposalId, actor, command);
|
|
2523
|
+
return {
|
|
2524
|
+
proposalDecision: result,
|
|
2525
|
+
text: this.proposals.reply(result, command.decision)
|
|
2526
|
+
};
|
|
2527
|
+
}
|
|
2455
2528
|
async handleTextDecision(threadId, actor, text) {
|
|
2456
2529
|
if (this.options?.actionApprovalMode !== "independent" || !this.proposals) return {
|
|
2457
2530
|
status: "unmatched"
|
|
@@ -2499,10 +2572,12 @@ var AgentService = class {
|
|
|
2499
2572
|
if (this.options?.quota === void 0 || this.quotaProvider === void 0) {
|
|
2500
2573
|
return;
|
|
2501
2574
|
}
|
|
2502
|
-
const
|
|
2575
|
+
const report = await this.quotaProvider.report({
|
|
2503
2576
|
actor
|
|
2504
2577
|
});
|
|
2578
|
+
const { blocked } = report;
|
|
2505
2579
|
if (blocked !== void 0) {
|
|
2580
|
+
publishQuotaBlocked(actor, report, blocked);
|
|
2506
2581
|
throw new import_common10.HttpException({
|
|
2507
2582
|
statusCode: import_common10.HttpStatus.TOO_MANY_REQUESTS,
|
|
2508
2583
|
code: "quota_exceeded",
|
|
@@ -2538,7 +2613,7 @@ var AgentService = class {
|
|
|
2538
2613
|
if (this.models === void 0) {
|
|
2539
2614
|
throw new import_common10.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
|
|
2540
2615
|
}
|
|
2541
|
-
const entry = (0,
|
|
2616
|
+
const entry = (0, import_nestjs_agent_core16.findCatalogModel)(await this.models.list({
|
|
2542
2617
|
actor,
|
|
2543
2618
|
agent
|
|
2544
2619
|
}), model);
|
|
@@ -2637,6 +2712,9 @@ var AgentService = class {
|
|
|
2637
2712
|
}
|
|
2638
2713
|
const created = await this.store.createThread({
|
|
2639
2714
|
actor: params.actor,
|
|
2715
|
+
...agentName !== void 0 ? {
|
|
2716
|
+
agentName
|
|
2717
|
+
} : {},
|
|
2640
2718
|
...params.transient === true ? {
|
|
2641
2719
|
transient: true
|
|
2642
2720
|
} : {},
|
|
@@ -2649,7 +2727,7 @@ var AgentService = class {
|
|
|
2649
2727
|
});
|
|
2650
2728
|
threadId = created.id;
|
|
2651
2729
|
} else {
|
|
2652
|
-
await this.assertOwnsThread(params.actor, threadId);
|
|
2730
|
+
if (params.authorized !== true) await this.assertOwnsThread(params.actor, threadId);
|
|
2653
2731
|
if (params.personaId !== void 0) {
|
|
2654
2732
|
await this.pinThreadPersona(threadId, params.personaId);
|
|
2655
2733
|
}
|
|
@@ -2675,6 +2753,9 @@ var AgentService = class {
|
|
|
2675
2753
|
...params.uiCapabilities !== void 0 ? {
|
|
2676
2754
|
uiCapabilities: params.uiCapabilities
|
|
2677
2755
|
} : {},
|
|
2756
|
+
...params.hostContext !== void 0 ? {
|
|
2757
|
+
hostContext: params.hostContext
|
|
2758
|
+
} : {},
|
|
2678
2759
|
...model !== void 0 ? {
|
|
2679
2760
|
model
|
|
2680
2761
|
} : {}
|
|
@@ -2692,12 +2773,12 @@ var AgentService = class {
|
|
|
2692
2773
|
const mode = params.mode ?? "auto";
|
|
2693
2774
|
const { live, stale } = await queue.holder(threadId, this.runner);
|
|
2694
2775
|
if (stale !== null) {
|
|
2695
|
-
await (0,
|
|
2776
|
+
await (0, import_nestjs_agent_core16.settleDeadRun)(this.store, {
|
|
2696
2777
|
runId: stale
|
|
2697
2778
|
});
|
|
2698
2779
|
}
|
|
2699
2780
|
if (live === null && mode !== "queue") {
|
|
2700
|
-
const runId = crypto.randomUUID();
|
|
2781
|
+
const runId = this.runner.runIdFor?.(input) ?? crypto.randomUUID();
|
|
2701
2782
|
if (await queue.queueStore().claimActiveStream(threadId, runId, stale !== null ? {
|
|
2702
2783
|
replacing: stale
|
|
2703
2784
|
} : {})) {
|
|
@@ -2765,6 +2846,9 @@ var AgentService = class {
|
|
|
2765
2846
|
...input.uiCapabilities !== void 0 ? {
|
|
2766
2847
|
uiCapabilities: input.uiCapabilities
|
|
2767
2848
|
} : {},
|
|
2849
|
+
...input.hostContext !== void 0 ? {
|
|
2850
|
+
hostContext: input.hostContext
|
|
2851
|
+
} : {},
|
|
2768
2852
|
...interrupting !== void 0 ? {
|
|
2769
2853
|
interrupt: true,
|
|
2770
2854
|
at: "head"
|
|
@@ -3081,7 +3165,7 @@ var AgentService = class {
|
|
|
3081
3165
|
if (active) {
|
|
3082
3166
|
return;
|
|
3083
3167
|
}
|
|
3084
|
-
await (0,
|
|
3168
|
+
await (0, import_nestjs_agent_core16.settleDeadRun)(this.store, {
|
|
3085
3169
|
runId
|
|
3086
3170
|
});
|
|
3087
3171
|
throw new RunNotActiveException(runId);
|
|
@@ -3449,10 +3533,10 @@ var AgentService = class {
|
|
|
3449
3533
|
if (this.store.toolCallInput === void 0) {
|
|
3450
3534
|
return;
|
|
3451
3535
|
}
|
|
3452
|
-
const questions = (0,
|
|
3536
|
+
const questions = (0, import_nestjs_agent_core16.readElicitationQuestions)(await this.store.toolCallInput(toolCallId2));
|
|
3453
3537
|
for (const question of questions) {
|
|
3454
3538
|
const submitted = Object.hasOwn(answers2, question.id) ? answers2[question.id] : void 0;
|
|
3455
|
-
const problem = (0,
|
|
3539
|
+
const problem = (0, import_nestjs_agent_core16.validateElicitationAnswer)(question, submitted ?? question.defaults ?? []);
|
|
3456
3540
|
if (problem !== null) {
|
|
3457
3541
|
throw new import_common10.BadRequestException(`answers["${question.id}"] ${problem}`);
|
|
3458
3542
|
}
|
|
@@ -3466,15 +3550,15 @@ var AgentService = class {
|
|
|
3466
3550
|
*/
|
|
3467
3551
|
async assertMayDecide(actor, toolCallId2) {
|
|
3468
3552
|
const approval = await this.store.toolCallApproval?.(toolCallId2);
|
|
3469
|
-
const approver = approval?.approver ??
|
|
3470
|
-
if (approver ===
|
|
3553
|
+
const approver = approval?.approver ?? import_nestjs_agent_core16.REQUESTER_APPROVER;
|
|
3554
|
+
if (approver === import_nestjs_agent_core16.REQUESTER_APPROVER) {
|
|
3471
3555
|
return this.assertOwnsToolCall(actor, toolCallId2);
|
|
3472
3556
|
}
|
|
3473
3557
|
const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
|
|
3474
3558
|
if (requesterRef === null) {
|
|
3475
3559
|
throw new import_common10.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
3476
3560
|
}
|
|
3477
|
-
const allowed = await (0,
|
|
3561
|
+
const allowed = await (0, import_nestjs_agent_core16.mayDecideApproval)(this.deps.forAgent().approvalPolicy, actor, {
|
|
3478
3562
|
toolCallId: toolCallId2,
|
|
3479
3563
|
approver,
|
|
3480
3564
|
requesterRef
|
|
@@ -3526,17 +3610,17 @@ var AgentService = class {
|
|
|
3526
3610
|
};
|
|
3527
3611
|
AgentService = _ts_decorate9([
|
|
3528
3612
|
(0, import_common10.Injectable)(),
|
|
3529
|
-
_ts_param7(0, (0, import_common10.Inject)(
|
|
3530
|
-
_ts_param7(1, (0, import_common10.Inject)(
|
|
3531
|
-
_ts_param7(2, (0, import_common10.Inject)(
|
|
3613
|
+
_ts_param7(0, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_RUNNER)),
|
|
3614
|
+
_ts_param7(1, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_STORE)),
|
|
3615
|
+
_ts_param7(2, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_DEPS_FACTORY)),
|
|
3532
3616
|
_ts_param7(3, (0, import_common10.Optional)()),
|
|
3533
|
-
_ts_param7(3, (0, import_common10.Inject)(
|
|
3617
|
+
_ts_param7(3, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_ATTACHMENT_STAGING)),
|
|
3534
3618
|
_ts_param7(4, (0, import_common10.Optional)()),
|
|
3535
|
-
_ts_param7(4, (0, import_common10.Inject)(
|
|
3619
|
+
_ts_param7(4, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_MODEL_CATALOG)),
|
|
3536
3620
|
_ts_param7(5, (0, import_common10.Optional)()),
|
|
3537
|
-
_ts_param7(5, (0, import_common10.Inject)(
|
|
3621
|
+
_ts_param7(5, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_QUOTA_PROVIDER)),
|
|
3538
3622
|
_ts_param7(6, (0, import_common10.Optional)()),
|
|
3539
|
-
_ts_param7(6, (0, import_common10.Inject)(
|
|
3623
|
+
_ts_param7(6, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_OPTIONS)),
|
|
3540
3624
|
_ts_param7(7, (0, import_common10.Optional)()),
|
|
3541
3625
|
_ts_param7(8, (0, import_common10.Optional)()),
|
|
3542
3626
|
_ts_metadata7("design:type", Function),
|
|
@@ -3651,7 +3735,7 @@ AgentApprovalPortAdapter = _ts_decorate10([
|
|
|
3651
3735
|
], AgentApprovalPortAdapter);
|
|
3652
3736
|
|
|
3653
3737
|
// src/controller/agents.controller.ts
|
|
3654
|
-
var
|
|
3738
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
3655
3739
|
var import_common12 = require("@nestjs/common");
|
|
3656
3740
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
3657
3741
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3717,17 +3801,17 @@ _ts_decorate11([
|
|
|
3717
3801
|
], AgentsController.prototype, "list", null);
|
|
3718
3802
|
AgentsController = _ts_decorate11([
|
|
3719
3803
|
(0, import_common12.Controller)("agents"),
|
|
3720
|
-
_ts_param9(0, (0, import_common12.Inject)(
|
|
3721
|
-
_ts_param9(1, (0, import_common12.Inject)(
|
|
3804
|
+
_ts_param9(0, (0, import_common12.Inject)(import_nestjs_agent_core17.AGENT_REGISTRY)),
|
|
3805
|
+
_ts_param9(1, (0, import_common12.Inject)(import_nestjs_agent_core17.AGENT_DEPS_FACTORY)),
|
|
3722
3806
|
_ts_metadata9("design:type", Function),
|
|
3723
3807
|
_ts_metadata9("design:paramtypes", [
|
|
3724
|
-
typeof
|
|
3808
|
+
typeof import_nestjs_agent_core17.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core17.AgentRegistry,
|
|
3725
3809
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
3726
3810
|
])
|
|
3727
3811
|
], AgentsController);
|
|
3728
3812
|
|
|
3729
3813
|
// src/controller/attachments.controller.ts
|
|
3730
|
-
var
|
|
3814
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
3731
3815
|
var import_common13 = require("@nestjs/common");
|
|
3732
3816
|
var import_platform_express = require("@nestjs/platform-express");
|
|
3733
3817
|
|
|
@@ -3865,10 +3949,10 @@ _ts_decorate12([
|
|
|
3865
3949
|
], AttachmentsController.prototype, "upload", null);
|
|
3866
3950
|
AttachmentsController = _ts_decorate12([
|
|
3867
3951
|
(0, import_common13.Controller)("attachments"),
|
|
3868
|
-
_ts_param10(0, (0, import_common13.Inject)(
|
|
3869
|
-
_ts_param10(1, (0, import_common13.Inject)(
|
|
3952
|
+
_ts_param10(0, (0, import_common13.Inject)(import_nestjs_agent_core18.AGENT_OPTIONS)),
|
|
3953
|
+
_ts_param10(1, (0, import_common13.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
|
|
3870
3954
|
_ts_param10(3, (0, import_common13.Optional)()),
|
|
3871
|
-
_ts_param10(3, (0, import_common13.Inject)(
|
|
3955
|
+
_ts_param10(3, (0, import_common13.Inject)(import_nestjs_agent_core18.AGENT_ATTACHMENT_STAGING)),
|
|
3872
3956
|
_ts_metadata10("design:type", Function),
|
|
3873
3957
|
_ts_metadata10("design:paramtypes", [
|
|
3874
3958
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -3879,7 +3963,7 @@ AttachmentsController = _ts_decorate12([
|
|
|
3879
3963
|
], AttachmentsController);
|
|
3880
3964
|
|
|
3881
3965
|
// src/controller/chat.controller.ts
|
|
3882
|
-
var
|
|
3966
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
3883
3967
|
var import_genui2 = require("@dudousxd/nestjs-agent-core/genui");
|
|
3884
3968
|
var import_common14 = require("@nestjs/common");
|
|
3885
3969
|
function _ts_decorate13(decorators, target, key, desc) {
|
|
@@ -4089,10 +4173,10 @@ data: ${line}
|
|
|
4089
4173
|
}
|
|
4090
4174
|
res.write("event: done\ndata: {}\n\n");
|
|
4091
4175
|
} catch (error) {
|
|
4092
|
-
const payload = error instanceof
|
|
4176
|
+
const payload = error instanceof import_nestjs_agent_core19.AgentStreamError ? {
|
|
4093
4177
|
code: error.code,
|
|
4094
4178
|
message: error.message
|
|
4095
|
-
} : (0,
|
|
4179
|
+
} : (0, import_nestjs_agent_core19.streamFailure)(error);
|
|
4096
4180
|
res.write(`event: error
|
|
4097
4181
|
data: ${JSON.stringify(payload)}
|
|
4098
4182
|
|
|
@@ -4142,7 +4226,7 @@ _ts_decorate13([
|
|
|
4142
4226
|
], ChatController.prototype, "cancel", null);
|
|
4143
4227
|
ChatController = _ts_decorate13([
|
|
4144
4228
|
(0, import_common14.Controller)(),
|
|
4145
|
-
_ts_param11(1, (0, import_common14.Inject)(
|
|
4229
|
+
_ts_param11(1, (0, import_common14.Inject)(import_nestjs_agent_core19.AGENT_ACTOR_RESOLVER)),
|
|
4146
4230
|
_ts_metadata11("design:type", Function),
|
|
4147
4231
|
_ts_metadata11("design:paramtypes", [
|
|
4148
4232
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -4160,7 +4244,7 @@ function parseCursor(raw) {
|
|
|
4160
4244
|
__name(parseCursor, "parseCursor");
|
|
4161
4245
|
|
|
4162
4246
|
// src/controller/config.controller.ts
|
|
4163
|
-
var
|
|
4247
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
4164
4248
|
var import_common15 = require("@nestjs/common");
|
|
4165
4249
|
|
|
4166
4250
|
// src/resolver/anonymous-actor-resolver.ts
|
|
@@ -4318,12 +4402,12 @@ _ts_decorate14([
|
|
|
4318
4402
|
], ConfigController.prototype, "config", null);
|
|
4319
4403
|
ConfigController = _ts_decorate14([
|
|
4320
4404
|
(0, import_common15.Controller)("config"),
|
|
4321
|
-
_ts_param12(0, (0, import_common15.Inject)(
|
|
4322
|
-
_ts_param12(1, (0, import_common15.Inject)(
|
|
4405
|
+
_ts_param12(0, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_OPTIONS)),
|
|
4406
|
+
_ts_param12(1, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER)),
|
|
4323
4407
|
_ts_param12(2, (0, import_common15.Optional)()),
|
|
4324
|
-
_ts_param12(2, (0, import_common15.Inject)(
|
|
4408
|
+
_ts_param12(2, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_ATTACHMENT_STAGING)),
|
|
4325
4409
|
_ts_param12(3, (0, import_common15.Optional)()),
|
|
4326
|
-
_ts_param12(3, (0, import_common15.Inject)(
|
|
4410
|
+
_ts_param12(3, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_MODEL_CATALOG)),
|
|
4327
4411
|
_ts_metadata12("design:type", Function),
|
|
4328
4412
|
_ts_metadata12("design:paramtypes", [
|
|
4329
4413
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -4334,7 +4418,7 @@ ConfigController = _ts_decorate14([
|
|
|
4334
4418
|
], ConfigController);
|
|
4335
4419
|
|
|
4336
4420
|
// src/controller/memories.controller.ts
|
|
4337
|
-
var
|
|
4421
|
+
var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
|
|
4338
4422
|
var import_common16 = require("@nestjs/common");
|
|
4339
4423
|
function _ts_decorate15(decorators, target, key, desc) {
|
|
4340
4424
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -4403,7 +4487,7 @@ var MemoriesController = class {
|
|
|
4403
4487
|
if (entry === void 0) {
|
|
4404
4488
|
throw new import_common16.NotFoundException(`No memory with id "${id}".`);
|
|
4405
4489
|
}
|
|
4406
|
-
const verdict = (0,
|
|
4490
|
+
const verdict = (0, import_nestjs_agent_core21.memoryForgetVerdict)({
|
|
4407
4491
|
record: entry,
|
|
4408
4492
|
actor
|
|
4409
4493
|
});
|
|
@@ -4422,7 +4506,7 @@ var MemoriesController = class {
|
|
|
4422
4506
|
}
|
|
4423
4507
|
async unbounded(threadId, actor) {
|
|
4424
4508
|
const config = this.memory;
|
|
4425
|
-
return await (0,
|
|
4509
|
+
return await (0, import_nestjs_agent_core21.offerMemories)({
|
|
4426
4510
|
config: {
|
|
4427
4511
|
...config,
|
|
4428
4512
|
maxMemories: Number.POSITIVE_INFINITY
|
|
@@ -4458,9 +4542,9 @@ _ts_decorate15([
|
|
|
4458
4542
|
], MemoriesController.prototype, "forget", null);
|
|
4459
4543
|
MemoriesController = _ts_decorate15([
|
|
4460
4544
|
(0, import_common16.Controller)("memories"),
|
|
4461
|
-
_ts_param13(0, (0, import_common16.Inject)(
|
|
4545
|
+
_ts_param13(0, (0, import_common16.Inject)(import_nestjs_agent_core21.AGENT_ACTOR_RESOLVER)),
|
|
4462
4546
|
_ts_param13(1, (0, import_common16.Optional)()),
|
|
4463
|
-
_ts_param13(1, (0, import_common16.Inject)(
|
|
4547
|
+
_ts_param13(1, (0, import_common16.Inject)(import_nestjs_agent_core21.AGENT_MEMORY)),
|
|
4464
4548
|
_ts_metadata13("design:type", Function),
|
|
4465
4549
|
_ts_metadata13("design:paramtypes", [
|
|
4466
4550
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
@@ -4469,7 +4553,7 @@ MemoriesController = _ts_decorate15([
|
|
|
4469
4553
|
], MemoriesController);
|
|
4470
4554
|
|
|
4471
4555
|
// src/controller/messages.controller.ts
|
|
4472
|
-
var
|
|
4556
|
+
var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
|
|
4473
4557
|
var import_common17 = require("@nestjs/common");
|
|
4474
4558
|
function _ts_decorate16(decorators, target, key, desc) {
|
|
4475
4559
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -4540,7 +4624,7 @@ _ts_decorate16([
|
|
|
4540
4624
|
], MessagesController.prototype, "feedback", null);
|
|
4541
4625
|
MessagesController = _ts_decorate16([
|
|
4542
4626
|
(0, import_common17.Controller)("messages"),
|
|
4543
|
-
_ts_param14(1, (0, import_common17.Inject)(
|
|
4627
|
+
_ts_param14(1, (0, import_common17.Inject)(import_nestjs_agent_core22.AGENT_ACTOR_RESOLVER)),
|
|
4544
4628
|
_ts_metadata14("design:type", Function),
|
|
4545
4629
|
_ts_metadata14("design:paramtypes", [
|
|
4546
4630
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -4549,7 +4633,7 @@ MessagesController = _ts_decorate16([
|
|
|
4549
4633
|
], MessagesController);
|
|
4550
4634
|
|
|
4551
4635
|
// src/controller/models.controller.ts
|
|
4552
|
-
var
|
|
4636
|
+
var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
|
|
4553
4637
|
var import_common18 = require("@nestjs/common");
|
|
4554
4638
|
function _ts_decorate17(decorators, target, key, desc) {
|
|
4555
4639
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -4609,7 +4693,7 @@ _ts_decorate17([
|
|
|
4609
4693
|
], ModelsController.prototype, "list", null);
|
|
4610
4694
|
ModelsController = _ts_decorate17([
|
|
4611
4695
|
(0, import_common18.Controller)("models"),
|
|
4612
|
-
_ts_param15(1, (0, import_common18.Inject)(
|
|
4696
|
+
_ts_param15(1, (0, import_common18.Inject)(import_nestjs_agent_core23.AGENT_ACTOR_RESOLVER)),
|
|
4613
4697
|
_ts_metadata15("design:type", Function),
|
|
4614
4698
|
_ts_metadata15("design:paramtypes", [
|
|
4615
4699
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -4618,7 +4702,7 @@ ModelsController = _ts_decorate17([
|
|
|
4618
4702
|
], ModelsController);
|
|
4619
4703
|
|
|
4620
4704
|
// src/controller/queue.controller.ts
|
|
4621
|
-
var
|
|
4705
|
+
var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
|
|
4622
4706
|
var import_common19 = require("@nestjs/common");
|
|
4623
4707
|
function _ts_decorate18(decorators, target, key, desc) {
|
|
4624
4708
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -4769,7 +4853,7 @@ _ts_decorate18([
|
|
|
4769
4853
|
], QueueController.prototype, "remove", null);
|
|
4770
4854
|
QueueController = _ts_decorate18([
|
|
4771
4855
|
(0, import_common19.Controller)(),
|
|
4772
|
-
_ts_param16(1, (0, import_common19.Inject)(
|
|
4856
|
+
_ts_param16(1, (0, import_common19.Inject)(import_nestjs_agent_core24.AGENT_ACTOR_RESOLVER)),
|
|
4773
4857
|
_ts_metadata16("design:type", Function),
|
|
4774
4858
|
_ts_metadata16("design:paramtypes", [
|
|
4775
4859
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -4778,7 +4862,7 @@ QueueController = _ts_decorate18([
|
|
|
4778
4862
|
], QueueController);
|
|
4779
4863
|
|
|
4780
4864
|
// src/controller/quota.controller.ts
|
|
4781
|
-
var
|
|
4865
|
+
var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
|
|
4782
4866
|
var import_common20 = require("@nestjs/common");
|
|
4783
4867
|
function _ts_decorate19(decorators, target, key, desc) {
|
|
4784
4868
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -4836,7 +4920,7 @@ _ts_decorate19([
|
|
|
4836
4920
|
], QuotaController.prototype, "report", null);
|
|
4837
4921
|
QuotaController = _ts_decorate19([
|
|
4838
4922
|
(0, import_common20.Controller)("quota"),
|
|
4839
|
-
_ts_param17(1, (0, import_common20.Inject)(
|
|
4923
|
+
_ts_param17(1, (0, import_common20.Inject)(import_nestjs_agent_core25.AGENT_ACTOR_RESOLVER)),
|
|
4840
4924
|
_ts_metadata17("design:type", Function),
|
|
4841
4925
|
_ts_metadata17("design:paramtypes", [
|
|
4842
4926
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -4845,7 +4929,7 @@ QuotaController = _ts_decorate19([
|
|
|
4845
4929
|
], QuotaController);
|
|
4846
4930
|
|
|
4847
4931
|
// src/controller/skills.controller.ts
|
|
4848
|
-
var
|
|
4932
|
+
var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
|
|
4849
4933
|
var import_common21 = require("@nestjs/common");
|
|
4850
4934
|
function _ts_decorate20(decorators, target, key, desc) {
|
|
4851
4935
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -4888,7 +4972,7 @@ var SkillsController = class {
|
|
|
4888
4972
|
return [];
|
|
4889
4973
|
}
|
|
4890
4974
|
const actor = await this.actorResolver.resolve(req);
|
|
4891
|
-
const offer = await (0,
|
|
4975
|
+
const offer = await (0, import_nestjs_agent_core26.offerSkills)(this.skills, {
|
|
4892
4976
|
actor,
|
|
4893
4977
|
threadId: threadId ?? ""
|
|
4894
4978
|
});
|
|
@@ -4908,9 +4992,9 @@ _ts_decorate20([
|
|
|
4908
4992
|
], SkillsController.prototype, "list", null);
|
|
4909
4993
|
SkillsController = _ts_decorate20([
|
|
4910
4994
|
(0, import_common21.Controller)("skills"),
|
|
4911
|
-
_ts_param18(0, (0, import_common21.Inject)(
|
|
4995
|
+
_ts_param18(0, (0, import_common21.Inject)(import_nestjs_agent_core26.AGENT_ACTOR_RESOLVER)),
|
|
4912
4996
|
_ts_param18(1, (0, import_common21.Optional)()),
|
|
4913
|
-
_ts_param18(1, (0, import_common21.Inject)(
|
|
4997
|
+
_ts_param18(1, (0, import_common21.Inject)(import_nestjs_agent_core26.AGENT_SKILLS)),
|
|
4914
4998
|
_ts_metadata18("design:type", Function),
|
|
4915
4999
|
_ts_metadata18("design:paramtypes", [
|
|
4916
5000
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
@@ -4919,7 +5003,7 @@ SkillsController = _ts_decorate20([
|
|
|
4919
5003
|
], SkillsController);
|
|
4920
5004
|
|
|
4921
5005
|
// src/controller/threads.controller.ts
|
|
4922
|
-
var
|
|
5006
|
+
var import_nestjs_agent_core27 = require("@dudousxd/nestjs-agent-core");
|
|
4923
5007
|
var import_common22 = require("@nestjs/common");
|
|
4924
5008
|
function _ts_decorate21(decorators, target, key, desc) {
|
|
4925
5009
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -5099,7 +5183,7 @@ _ts_decorate21([
|
|
|
5099
5183
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
5100
5184
|
ThreadsController = _ts_decorate21([
|
|
5101
5185
|
(0, import_common22.Controller)("threads"),
|
|
5102
|
-
_ts_param19(1, (0, import_common22.Inject)(
|
|
5186
|
+
_ts_param19(1, (0, import_common22.Inject)(import_nestjs_agent_core27.AGENT_ACTOR_RESOLVER)),
|
|
5103
5187
|
_ts_metadata19("design:type", Function),
|
|
5104
5188
|
_ts_metadata19("design:paramtypes", [
|
|
5105
5189
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -5108,7 +5192,7 @@ ThreadsController = _ts_decorate21([
|
|
|
5108
5192
|
], ThreadsController);
|
|
5109
5193
|
|
|
5110
5194
|
// src/controller/tool-call.controller.ts
|
|
5111
|
-
var
|
|
5195
|
+
var import_nestjs_agent_core28 = require("@dudousxd/nestjs-agent-core");
|
|
5112
5196
|
var import_common23 = require("@nestjs/common");
|
|
5113
5197
|
function _ts_decorate22(decorators, target, key, desc) {
|
|
5114
5198
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -5314,7 +5398,7 @@ _ts_decorate22([
|
|
|
5314
5398
|
], ToolCallController.prototype, "skip", null);
|
|
5315
5399
|
ToolCallController = _ts_decorate22([
|
|
5316
5400
|
(0, import_common23.Controller)("tool-call"),
|
|
5317
|
-
_ts_param20(1, (0, import_common23.Inject)(
|
|
5401
|
+
_ts_param20(1, (0, import_common23.Inject)(import_nestjs_agent_core28.AGENT_ACTOR_RESOLVER)),
|
|
5318
5402
|
_ts_metadata20("design:type", Function),
|
|
5319
5403
|
_ts_metadata20("design:paramtypes", [
|
|
5320
5404
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -5323,7 +5407,7 @@ ToolCallController = _ts_decorate22([
|
|
|
5323
5407
|
], ToolCallController);
|
|
5324
5408
|
|
|
5325
5409
|
// src/controller/tools.controller.ts
|
|
5326
|
-
var
|
|
5410
|
+
var import_nestjs_agent_core29 = require("@dudousxd/nestjs-agent-core");
|
|
5327
5411
|
var import_common24 = require("@nestjs/common");
|
|
5328
5412
|
function _ts_decorate23(decorators, target, key, desc) {
|
|
5329
5413
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -5364,11 +5448,11 @@ var ToolsController = class {
|
|
|
5364
5448
|
this.agents = agents;
|
|
5365
5449
|
}
|
|
5366
5450
|
async list(req, agent) {
|
|
5367
|
-
if (agent !== void 0 && agent !==
|
|
5451
|
+
if (agent !== void 0 && agent !== import_nestjs_agent_core29.ALL_AGENTS && this.agents.get(agent) === void 0) {
|
|
5368
5452
|
throw new import_common24.NotFoundException(`No agent named "${agent}"`);
|
|
5369
5453
|
}
|
|
5370
5454
|
const actor = await this.actorResolver.resolve(req);
|
|
5371
|
-
const names = agent ===
|
|
5455
|
+
const names = agent === import_nestjs_agent_core29.ALL_AGENTS ? [
|
|
5372
5456
|
void 0,
|
|
5373
5457
|
...this.agents.list().map((definition) => definition.name)
|
|
5374
5458
|
] : [
|
|
@@ -5407,19 +5491,19 @@ _ts_decorate23([
|
|
|
5407
5491
|
], ToolsController.prototype, "list", null);
|
|
5408
5492
|
ToolsController = _ts_decorate23([
|
|
5409
5493
|
(0, import_common24.Controller)("tools"),
|
|
5410
|
-
_ts_param21(0, (0, import_common24.Inject)(
|
|
5411
|
-
_ts_param21(1, (0, import_common24.Inject)(
|
|
5412
|
-
_ts_param21(2, (0, import_common24.Inject)(
|
|
5494
|
+
_ts_param21(0, (0, import_common24.Inject)(import_nestjs_agent_core29.AGENT_ACTOR_RESOLVER)),
|
|
5495
|
+
_ts_param21(1, (0, import_common24.Inject)(import_nestjs_agent_core29.AGENT_DEPS_FACTORY)),
|
|
5496
|
+
_ts_param21(2, (0, import_common24.Inject)(import_nestjs_agent_core29.AGENT_REGISTRY)),
|
|
5413
5497
|
_ts_metadata21("design:type", Function),
|
|
5414
5498
|
_ts_metadata21("design:paramtypes", [
|
|
5415
5499
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
5416
5500
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
5417
|
-
typeof
|
|
5501
|
+
typeof import_nestjs_agent_core29.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core29.AgentRegistry
|
|
5418
5502
|
])
|
|
5419
5503
|
], ToolsController);
|
|
5420
5504
|
|
|
5421
5505
|
// src/discovery/agent-discovery.service.ts
|
|
5422
|
-
var
|
|
5506
|
+
var import_nestjs_agent_core30 = require("@dudousxd/nestjs-agent-core");
|
|
5423
5507
|
var import_common25 = require("@nestjs/common");
|
|
5424
5508
|
var import_core = require("@nestjs/core");
|
|
5425
5509
|
|
|
@@ -5630,19 +5714,19 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
5630
5714
|
};
|
|
5631
5715
|
AgentDiscoveryService = _ts_decorate24([
|
|
5632
5716
|
(0, import_common25.Injectable)(),
|
|
5633
|
-
_ts_param22(2, (0, import_common25.Inject)(
|
|
5634
|
-
_ts_param22(3, (0, import_common25.Inject)(
|
|
5717
|
+
_ts_param22(2, (0, import_common25.Inject)(import_nestjs_agent_core30.AGENT_REGISTRY)),
|
|
5718
|
+
_ts_param22(3, (0, import_common25.Inject)(import_nestjs_agent_core30.AGENT_PROMPT_CONTRIBUTORS)),
|
|
5635
5719
|
_ts_metadata22("design:type", Function),
|
|
5636
5720
|
_ts_metadata22("design:paramtypes", [
|
|
5637
5721
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
5638
5722
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
5639
|
-
typeof
|
|
5723
|
+
typeof import_nestjs_agent_core30.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core30.AgentRegistry,
|
|
5640
5724
|
Array
|
|
5641
5725
|
])
|
|
5642
5726
|
], AgentDiscoveryService);
|
|
5643
5727
|
|
|
5644
5728
|
// src/discovery/ai-tool-discovery.service.ts
|
|
5645
|
-
var
|
|
5729
|
+
var import_nestjs_agent_core31 = require("@dudousxd/nestjs-agent-core");
|
|
5646
5730
|
var import_common26 = require("@nestjs/common");
|
|
5647
5731
|
var import_core2 = require("@nestjs/core");
|
|
5648
5732
|
var import_zod = require("zod");
|
|
@@ -5755,6 +5839,9 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5755
5839
|
} : {}
|
|
5756
5840
|
}, {
|
|
5757
5841
|
execute: /* @__PURE__ */ __name((input, ctx) => instance.execute(input, ctx), "execute"),
|
|
5842
|
+
...typeof handler.present === "function" ? {
|
|
5843
|
+
present: /* @__PURE__ */ __name((output, ctx) => instance.present(output, ctx), "present")
|
|
5844
|
+
} : {},
|
|
5758
5845
|
...typeof handler.preflight === "function" ? {
|
|
5759
5846
|
preflight: /* @__PURE__ */ __name((input, ctx, options) => instance.preflight(input, ctx, options), "preflight")
|
|
5760
5847
|
} : {},
|
|
@@ -5781,7 +5868,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5781
5868
|
let delegates = 0;
|
|
5782
5869
|
for (const definition of this.agents.list()) {
|
|
5783
5870
|
for (const edge of definition.delegatesTo ?? []) {
|
|
5784
|
-
const { agent: target, detached } = (0,
|
|
5871
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core31.normalizeDelegation)(edge);
|
|
5785
5872
|
const targetDefinition = this.agents.get(target);
|
|
5786
5873
|
if (targetDefinition === void 0) {
|
|
5787
5874
|
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.`);
|
|
@@ -5833,9 +5920,9 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5833
5920
|
};
|
|
5834
5921
|
AiToolDiscoveryService = _ts_decorate25([
|
|
5835
5922
|
(0, import_common26.Injectable)(),
|
|
5836
|
-
_ts_param23(1, (0, import_common26.Inject)(
|
|
5837
|
-
_ts_param23(2, (0, import_common26.Inject)(
|
|
5838
|
-
_ts_param23(3, (0, import_common26.Inject)(
|
|
5923
|
+
_ts_param23(1, (0, import_common26.Inject)(import_nestjs_agent_core31.AGENT_TOOL_REGISTRY)),
|
|
5924
|
+
_ts_param23(2, (0, import_common26.Inject)(import_nestjs_agent_core31.AGENT_REGISTRY)),
|
|
5925
|
+
_ts_param23(3, (0, import_common26.Inject)(import_nestjs_agent_core31.AGENT_OPTIONS)),
|
|
5839
5926
|
_ts_metadata23("design:type", Function),
|
|
5840
5927
|
_ts_metadata23("design:paramtypes", [
|
|
5841
5928
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
@@ -5846,20 +5933,20 @@ AiToolDiscoveryService = _ts_decorate25([
|
|
|
5846
5933
|
], AiToolDiscoveryService);
|
|
5847
5934
|
|
|
5848
5935
|
// src/discovery/skill-discovery.service.ts
|
|
5849
|
-
var
|
|
5936
|
+
var import_nestjs_agent_core33 = require("@dudousxd/nestjs-agent-core");
|
|
5850
5937
|
var import_common27 = require("@nestjs/common");
|
|
5851
5938
|
var import_core3 = require("@nestjs/core");
|
|
5852
5939
|
|
|
5853
5940
|
// src/decorator/skill.decorator.ts
|
|
5854
5941
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
5855
|
-
var
|
|
5942
|
+
var import_nestjs_agent_core32 = require("@dudousxd/nestjs-agent-core");
|
|
5856
5943
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
5857
5944
|
function readSkillMetadata(target) {
|
|
5858
5945
|
return Reflect.getMetadata(SKILL_METADATA, target);
|
|
5859
5946
|
}
|
|
5860
5947
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
5861
5948
|
function skillScope(options) {
|
|
5862
|
-
return options.scope ??
|
|
5949
|
+
return options.scope ?? import_nestjs_agent_core32.GLOBAL_SCOPE;
|
|
5863
5950
|
}
|
|
5864
5951
|
__name(skillScope, "skillScope");
|
|
5865
5952
|
|
|
@@ -5935,7 +6022,7 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
5935
6022
|
};
|
|
5936
6023
|
SkillDiscoveryService = _ts_decorate26([
|
|
5937
6024
|
(0, import_common27.Injectable)(),
|
|
5938
|
-
_ts_param24(1, (0, import_common27.Inject)(
|
|
6025
|
+
_ts_param24(1, (0, import_common27.Inject)(import_nestjs_agent_core33.AGENT_SKILL_SOURCES)),
|
|
5939
6026
|
_ts_metadata24("design:type", Function),
|
|
5940
6027
|
_ts_metadata24("design:paramtypes", [
|
|
5941
6028
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
@@ -5944,7 +6031,7 @@ SkillDiscoveryService = _ts_decorate26([
|
|
|
5944
6031
|
], SkillDiscoveryService);
|
|
5945
6032
|
|
|
5946
6033
|
// src/ledger-quota-provider.ts
|
|
5947
|
-
var
|
|
6034
|
+
var import_nestjs_agent_core34 = require("@dudousxd/nestjs-agent-core");
|
|
5948
6035
|
var LedgerQuotaProvider = class {
|
|
5949
6036
|
static {
|
|
5950
6037
|
__name(this, "LedgerQuotaProvider");
|
|
@@ -5964,12 +6051,12 @@ var LedgerQuotaProvider = class {
|
|
|
5964
6051
|
await this.dayWindow(actorRef, now)
|
|
5965
6052
|
];
|
|
5966
6053
|
if (this.store.usageBetween !== void 0) {
|
|
5967
|
-
const range = (0,
|
|
6054
|
+
const range = (0, import_nestjs_agent_core34.quotaPeriodRange)("month", now);
|
|
5968
6055
|
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
5969
6056
|
windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
|
|
5970
6057
|
}
|
|
5971
|
-
const blocked = (0,
|
|
5972
|
-
const warning = (0,
|
|
6058
|
+
const blocked = (0, import_nestjs_agent_core34.exhaustedWindow)(windows);
|
|
6059
|
+
const warning = (0, import_nestjs_agent_core34.quotaWarning)(windows);
|
|
5973
6060
|
return {
|
|
5974
6061
|
windows,
|
|
5975
6062
|
...blocked !== void 0 ? {
|
|
@@ -5981,7 +6068,7 @@ var LedgerQuotaProvider = class {
|
|
|
5981
6068
|
};
|
|
5982
6069
|
}
|
|
5983
6070
|
async dayWindow(actorRef, now) {
|
|
5984
|
-
const range = (0,
|
|
6071
|
+
const range = (0, import_nestjs_agent_core34.quotaPeriodRange)("day", now);
|
|
5985
6072
|
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
5986
6073
|
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
5987
6074
|
}
|
|
@@ -6007,7 +6094,7 @@ var LedgerQuotaProvider = class {
|
|
|
6007
6094
|
|
|
6008
6095
|
// src/proposals/action-proposal-worker.service.ts
|
|
6009
6096
|
var import_node_crypto3 = require("crypto");
|
|
6010
|
-
var
|
|
6097
|
+
var import_nestjs_agent_core35 = require("@dudousxd/nestjs-agent-core");
|
|
6011
6098
|
var import_common28 = require("@nestjs/common");
|
|
6012
6099
|
function _ts_decorate27(decorators, target, key, desc) {
|
|
6013
6100
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -6051,15 +6138,15 @@ var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
|
6051
6138
|
}
|
|
6052
6139
|
onModuleInit() {
|
|
6053
6140
|
if (this.options.actionApprovalMode !== "independent") return;
|
|
6054
|
-
(0,
|
|
6141
|
+
(0, import_nestjs_agent_core35.assertIndependentActionCapabilities)(this.store, this.options.backgroundActorResolver);
|
|
6055
6142
|
if (this.options.surface === "http") return;
|
|
6056
6143
|
const resolver = this.options.backgroundActorResolver;
|
|
6057
6144
|
if (!resolver) throw new Error("BackgroundActorResolver is required");
|
|
6058
|
-
this.worker = new
|
|
6145
|
+
this.worker = new import_nestjs_agent_core35.ActionProposalWorker({
|
|
6059
6146
|
store: this.store,
|
|
6060
6147
|
workerId: (0, import_node_crypto3.randomUUID)(),
|
|
6061
6148
|
...this.options.actionProposalWorker,
|
|
6062
|
-
executor: new
|
|
6149
|
+
executor: new import_nestjs_agent_core35.ActionProposalExecutor({
|
|
6063
6150
|
resolver,
|
|
6064
6151
|
resolveExecution: /* @__PURE__ */ __name(async (proposal, actor) => {
|
|
6065
6152
|
const deps = this.deps.forProposal(proposal, actor);
|
|
@@ -6085,9 +6172,9 @@ var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
|
6085
6172
|
};
|
|
6086
6173
|
ActionProposalWorkerService = _ts_decorate27([
|
|
6087
6174
|
(0, import_common28.Injectable)(),
|
|
6088
|
-
_ts_param25(0, (0, import_common28.Inject)(
|
|
6089
|
-
_ts_param25(1, (0, import_common28.Inject)(
|
|
6090
|
-
_ts_param25(2, (0, import_common28.Inject)(
|
|
6175
|
+
_ts_param25(0, (0, import_common28.Inject)(import_nestjs_agent_core35.AGENT_STORE)),
|
|
6176
|
+
_ts_param25(1, (0, import_common28.Inject)(import_nestjs_agent_core35.AGENT_OPTIONS)),
|
|
6177
|
+
_ts_param25(2, (0, import_common28.Inject)(import_nestjs_agent_core35.AGENT_DEPS_FACTORY)),
|
|
6091
6178
|
_ts_metadata25("design:type", Function),
|
|
6092
6179
|
_ts_metadata25("design:paramtypes", [
|
|
6093
6180
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
@@ -6097,7 +6184,7 @@ ActionProposalWorkerService = _ts_decorate27([
|
|
|
6097
6184
|
], ActionProposalWorkerService);
|
|
6098
6185
|
|
|
6099
6186
|
// src/proposals/action-proposal.controller.ts
|
|
6100
|
-
var
|
|
6187
|
+
var import_nestjs_agent_core36 = require("@dudousxd/nestjs-agent-core");
|
|
6101
6188
|
var import_common29 = require("@nestjs/common");
|
|
6102
6189
|
function _ts_decorate28(decorators, target, key, desc) {
|
|
6103
6190
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -6151,7 +6238,7 @@ var ActionProposalController = class {
|
|
|
6151
6238
|
query = {
|
|
6152
6239
|
after: JSON.parse(cursor)
|
|
6153
6240
|
};
|
|
6154
|
-
(0,
|
|
6241
|
+
(0, import_nestjs_agent_core36.validateActionProposalListQuery)(query);
|
|
6155
6242
|
} catch {
|
|
6156
6243
|
throw new import_common29.BadRequestException("Invalid action proposal cursor");
|
|
6157
6244
|
}
|
|
@@ -6232,7 +6319,7 @@ _ts_decorate28([
|
|
|
6232
6319
|
], ActionProposalController.prototype, "reject", null);
|
|
6233
6320
|
ActionProposalController = _ts_decorate28([
|
|
6234
6321
|
(0, import_common29.Controller)("threads/:threadId/action-proposals"),
|
|
6235
|
-
_ts_param26(1, (0, import_common29.Inject)(
|
|
6322
|
+
_ts_param26(1, (0, import_common29.Inject)(import_nestjs_agent_core36.AGENT_ACTOR_RESOLVER)),
|
|
6236
6323
|
_ts_metadata26("design:type", Function),
|
|
6237
6324
|
_ts_metadata26("design:paramtypes", [
|
|
6238
6325
|
typeof ActionProposalService === "undefined" ? Object : ActionProposalService,
|
|
@@ -6241,7 +6328,7 @@ ActionProposalController = _ts_decorate28([
|
|
|
6241
6328
|
], ActionProposalController);
|
|
6242
6329
|
|
|
6243
6330
|
// src/runner/inline-agent-runner.ts
|
|
6244
|
-
var
|
|
6331
|
+
var import_nestjs_agent_core37 = require("@dudousxd/nestjs-agent-core");
|
|
6245
6332
|
var import_common30 = require("@nestjs/common");
|
|
6246
6333
|
function _ts_decorate29(decorators, target, key, desc) {
|
|
6247
6334
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -6325,18 +6412,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6325
6412
|
],
|
|
6326
6413
|
input
|
|
6327
6414
|
});
|
|
6328
|
-
void (0,
|
|
6415
|
+
void (0, import_nestjs_agent_core37.runAgentLoop)({
|
|
6329
6416
|
...deps,
|
|
6330
6417
|
day
|
|
6331
|
-
}, input, hooks).then(() => (0,
|
|
6332
|
-
if (error instanceof
|
|
6418
|
+
}, input, hooks).then(() => (0, import_nestjs_agent_core37.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
|
|
6419
|
+
if (error instanceof import_nestjs_agent_core37.RunCancelledError) {
|
|
6333
6420
|
await this.settleCancelled(runId, input, deps);
|
|
6334
6421
|
return;
|
|
6335
6422
|
}
|
|
6336
6423
|
const message = error instanceof Error ? error.message : String(error);
|
|
6337
|
-
const code = (0,
|
|
6424
|
+
const code = (0, import_nestjs_agent_core37.agentFailureCode)(error);
|
|
6338
6425
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
6339
|
-
(0,
|
|
6426
|
+
(0, import_nestjs_agent_core37.publishAgentRunFailed)({
|
|
6340
6427
|
runId,
|
|
6341
6428
|
code,
|
|
6342
6429
|
message
|
|
@@ -6347,11 +6434,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6347
6434
|
errorCode: code,
|
|
6348
6435
|
errorMessage: message
|
|
6349
6436
|
});
|
|
6350
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
6437
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core37.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
6351
6438
|
const writer = await deps.sink.open(runId);
|
|
6352
6439
|
await this.settleQueue(writer, input, runId, "failed", message);
|
|
6353
|
-
await (0,
|
|
6354
|
-
await writer.fail((0,
|
|
6440
|
+
await (0, import_nestjs_agent_core37.releaseThreadRun)(this.store, input.threadId, runId);
|
|
6441
|
+
await writer.fail((0, import_nestjs_agent_core37.streamFailure)(error));
|
|
6355
6442
|
}).finally(() => {
|
|
6356
6443
|
this.cancelled.delete(runId);
|
|
6357
6444
|
this.live.delete(runId);
|
|
@@ -6387,7 +6474,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6387
6474
|
for (const [key, waiter] of this.pending) {
|
|
6388
6475
|
if (key.startsWith(`${runId}:`)) {
|
|
6389
6476
|
this.pending.delete(key);
|
|
6390
|
-
waiter.reject(new
|
|
6477
|
+
waiter.reject(new import_nestjs_agent_core37.RunCancelledError());
|
|
6391
6478
|
}
|
|
6392
6479
|
}
|
|
6393
6480
|
await Promise.resolve();
|
|
@@ -6402,8 +6489,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6402
6489
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
6403
6490
|
const writer = await deps.sink.open(runId);
|
|
6404
6491
|
await this.settleQueue(writer, input, runId, "cancelled");
|
|
6405
|
-
await (0,
|
|
6406
|
-
await writer.write((0,
|
|
6492
|
+
await (0, import_nestjs_agent_core37.releaseThreadRun)(this.store, input.threadId, runId);
|
|
6493
|
+
await writer.write((0, import_nestjs_agent_core37.encodeStreamEvent)({
|
|
6407
6494
|
kind: "cancelled"
|
|
6408
6495
|
}));
|
|
6409
6496
|
await writer.end();
|
|
@@ -6438,7 +6525,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6438
6525
|
runId: nextRunId
|
|
6439
6526
|
}));
|
|
6440
6527
|
if (frame !== void 0) {
|
|
6441
|
-
await writer.write((0,
|
|
6528
|
+
await writer.write((0, import_nestjs_agent_core37.encodeStreamEvent)(frame));
|
|
6442
6529
|
}
|
|
6443
6530
|
} catch (failure) {
|
|
6444
6531
|
this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
@@ -6509,7 +6596,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6509
6596
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
6510
6597
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
6511
6598
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
6512
|
-
parallel:
|
|
6599
|
+
parallel: import_nestjs_agent_core37.settleAll,
|
|
6513
6600
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
6514
6601
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
6515
6602
|
agentName,
|
|
@@ -6560,7 +6647,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6560
6647
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
6561
6648
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
6562
6649
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
6563
|
-
parallel:
|
|
6650
|
+
parallel: import_nestjs_agent_core37.settleAll,
|
|
6564
6651
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
6565
6652
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
6566
6653
|
agentName: childName,
|
|
@@ -6593,7 +6680,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6593
6680
|
}
|
|
6594
6681
|
}), "startAgent")
|
|
6595
6682
|
};
|
|
6596
|
-
void (0,
|
|
6683
|
+
void (0, import_nestjs_agent_core37.runAgentLoop)({
|
|
6597
6684
|
...deps,
|
|
6598
6685
|
day
|
|
6599
6686
|
}, {
|
|
@@ -6607,13 +6694,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6607
6694
|
parentRunId,
|
|
6608
6695
|
deliverTo
|
|
6609
6696
|
}, hooks).catch(async (error) => {
|
|
6610
|
-
const cancelled = error instanceof
|
|
6697
|
+
const cancelled = error instanceof import_nestjs_agent_core37.RunCancelledError;
|
|
6611
6698
|
const message = error instanceof Error ? error.message : String(error);
|
|
6612
6699
|
if (!cancelled) {
|
|
6613
6700
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
6614
|
-
(0,
|
|
6701
|
+
(0, import_nestjs_agent_core37.publishAgentRunFailed)({
|
|
6615
6702
|
runId,
|
|
6616
|
-
code: (0,
|
|
6703
|
+
code: (0, import_nestjs_agent_core37.agentFailureCode)(error),
|
|
6617
6704
|
message
|
|
6618
6705
|
});
|
|
6619
6706
|
}
|
|
@@ -6621,12 +6708,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6621
6708
|
runId,
|
|
6622
6709
|
status: cancelled ? "cancelled" : "failed",
|
|
6623
6710
|
...cancelled ? {} : {
|
|
6624
|
-
errorCode: (0,
|
|
6711
|
+
errorCode: (0, import_nestjs_agent_core37.agentFailureCode)(error),
|
|
6625
6712
|
errorMessage: message
|
|
6626
6713
|
}
|
|
6627
6714
|
});
|
|
6628
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
6629
|
-
await (0,
|
|
6715
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core37.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
6716
|
+
await (0, import_nestjs_agent_core37.settleUnsettledDelegation)({
|
|
6630
6717
|
store: this.store,
|
|
6631
6718
|
delivery: deliverTo,
|
|
6632
6719
|
agent: agentName,
|
|
@@ -6665,7 +6752,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6665
6752
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
6666
6753
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
6667
6754
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
6668
|
-
parallel:
|
|
6755
|
+
parallel: import_nestjs_agent_core37.settleAll,
|
|
6669
6756
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
6670
6757
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
6671
6758
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -6700,7 +6787,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6700
6787
|
}), "startAgent")
|
|
6701
6788
|
};
|
|
6702
6789
|
try {
|
|
6703
|
-
return await (0,
|
|
6790
|
+
return await (0, import_nestjs_agent_core37.runAgentLoop)({
|
|
6704
6791
|
...deps,
|
|
6705
6792
|
day
|
|
6706
6793
|
}, {
|
|
@@ -6721,8 +6808,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6721
6808
|
};
|
|
6722
6809
|
InlineAgentRunner = _ts_decorate29([
|
|
6723
6810
|
(0, import_common30.Injectable)(),
|
|
6724
|
-
_ts_param27(0, (0, import_common30.Inject)(
|
|
6725
|
-
_ts_param27(1, (0, import_common30.Inject)(
|
|
6811
|
+
_ts_param27(0, (0, import_common30.Inject)(import_nestjs_agent_core37.AGENT_DEPS_FACTORY)),
|
|
6812
|
+
_ts_param27(1, (0, import_common30.Inject)(import_nestjs_agent_core37.AGENT_STORE)),
|
|
6726
6813
|
_ts_param27(2, (0, import_common30.Optional)()),
|
|
6727
6814
|
_ts_metadata27("design:type", Function),
|
|
6728
6815
|
_ts_metadata27("design:paramtypes", [
|
|
@@ -6737,7 +6824,7 @@ function isThreadTurn2(input) {
|
|
|
6737
6824
|
__name(isThreadTurn2, "isThreadTurn");
|
|
6738
6825
|
|
|
6739
6826
|
// src/skills-config.ts
|
|
6740
|
-
var
|
|
6827
|
+
var import_nestjs_agent_core38 = require("@dudousxd/nestjs-agent-core");
|
|
6741
6828
|
function declaredSkillProvider(declared) {
|
|
6742
6829
|
return {
|
|
6743
6830
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -6763,7 +6850,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
6763
6850
|
declaredSkillProvider(declared)
|
|
6764
6851
|
];
|
|
6765
6852
|
return {
|
|
6766
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
6853
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core38.compositeSkillProvider)(providers),
|
|
6767
6854
|
...options.scopes !== void 0 ? {
|
|
6768
6855
|
scopes: options.scopes
|
|
6769
6856
|
} : {},
|
|
@@ -6791,15 +6878,15 @@ function _ts_decorate30(decorators, target, key, desc) {
|
|
|
6791
6878
|
__name(_ts_decorate30, "_ts_decorate");
|
|
6792
6879
|
var DEFAULT_PATH = "agent";
|
|
6793
6880
|
var logger = new import_common31.Logger("AgentModule");
|
|
6794
|
-
function
|
|
6881
|
+
function externalWrapper(modules, token) {
|
|
6795
6882
|
for (const module2 of modules.values()) {
|
|
6796
6883
|
if (module2.metatype === AgentModule) continue;
|
|
6797
|
-
const wrapper = module2.providers.get(
|
|
6884
|
+
const wrapper = module2.providers.get(token);
|
|
6798
6885
|
if (wrapper !== void 0) return wrapper;
|
|
6799
6886
|
}
|
|
6800
6887
|
return void 0;
|
|
6801
6888
|
}
|
|
6802
|
-
__name(
|
|
6889
|
+
__name(externalWrapper, "externalWrapper");
|
|
6803
6890
|
function forwardingStore(wrapper) {
|
|
6804
6891
|
const target = /* @__PURE__ */ __name(() => {
|
|
6805
6892
|
const instance = wrapper.instance;
|
|
@@ -6822,118 +6909,143 @@ function forwardingStore(wrapper) {
|
|
|
6822
6909
|
__name(forwardingStore, "forwardingStore");
|
|
6823
6910
|
function resolveStore(options, modules) {
|
|
6824
6911
|
if (options.store !== void 0) return options.store;
|
|
6825
|
-
const external =
|
|
6912
|
+
const external = externalWrapper(modules, import_nestjs_agent_core39.AGENT_STORE);
|
|
6826
6913
|
if (external !== void 0) return forwardingStore(external);
|
|
6827
6914
|
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()).");
|
|
6828
|
-
return new
|
|
6915
|
+
return new import_nestjs_agent_core39.InMemoryAgentStore();
|
|
6829
6916
|
}
|
|
6830
6917
|
__name(resolveStore, "resolveStore");
|
|
6918
|
+
function resolveRolesPolicy(options, modules) {
|
|
6919
|
+
const external = externalWrapper(modules, import_nestjs_agent_core39.AGENT_ROLES_POLICY);
|
|
6920
|
+
if (options.rolesPolicy !== void 0) {
|
|
6921
|
+
if (external !== void 0) {
|
|
6922
|
+
logger.warn("Both a `rolesPolicy` option and a module binding AGENT_ROLES_POLICY (e.g. AgentAuthzModule) are configured \u2014 the `rolesPolicy` option wins.");
|
|
6923
|
+
}
|
|
6924
|
+
return options.rolesPolicy;
|
|
6925
|
+
}
|
|
6926
|
+
if (external !== void 0) return forwardingPolicy(external);
|
|
6927
|
+
return options.emptyRoles === "deny" ? new import_nestjs_agent_core39.ClosedRolesPolicy(options.defaultRoles) : new import_nestjs_agent_core39.DefaultRolesPolicy(options.defaultRoles);
|
|
6928
|
+
}
|
|
6929
|
+
__name(resolveRolesPolicy, "resolveRolesPolicy");
|
|
6930
|
+
function forwardingPolicy(wrapper) {
|
|
6931
|
+
return {
|
|
6932
|
+
can(actor, tool) {
|
|
6933
|
+
const policy = wrapper.instance;
|
|
6934
|
+
if (policy === void 0 || policy === null) {
|
|
6935
|
+
throw new Error("AgentModule: the AGENT_ROLES_POLICY bound by another module is not ready yet");
|
|
6936
|
+
}
|
|
6937
|
+
return policy.can(actor, tool);
|
|
6938
|
+
}
|
|
6939
|
+
};
|
|
6940
|
+
}
|
|
6941
|
+
__name(forwardingPolicy, "forwardingPolicy");
|
|
6831
6942
|
function isQuotaProvider(quota) {
|
|
6832
6943
|
return quota !== void 0 && typeof quota.report === "function";
|
|
6833
6944
|
}
|
|
6834
6945
|
__name(isQuotaProvider, "isQuotaProvider");
|
|
6835
6946
|
function resolveCatalog(options) {
|
|
6836
6947
|
if (options.models !== void 0) return options.models;
|
|
6837
|
-
const carried = options.model
|
|
6948
|
+
const carried = options.model?.catalog;
|
|
6838
6949
|
return carried !== void 0 && typeof carried.list === "function" ? carried : void 0;
|
|
6839
6950
|
}
|
|
6840
6951
|
__name(resolveCatalog, "resolveCatalog");
|
|
6841
|
-
function sharedProviders(durable) {
|
|
6952
|
+
function sharedProviders(durable, engine) {
|
|
6842
6953
|
const providers = [
|
|
6843
6954
|
{
|
|
6844
|
-
provide:
|
|
6845
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
6955
|
+
provide: import_nestjs_agent_core39.AGENT_TOOL_REGISTRY,
|
|
6956
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core39.ToolRegistry(), "useFactory")
|
|
6846
6957
|
},
|
|
6847
6958
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
6848
6959
|
{
|
|
6849
|
-
provide:
|
|
6850
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
6960
|
+
provide: import_nestjs_agent_core39.AGENT_REGISTRY,
|
|
6961
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core39.AgentRegistry(), "useFactory")
|
|
6851
6962
|
},
|
|
6852
6963
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
6853
6964
|
{
|
|
6854
|
-
provide:
|
|
6965
|
+
provide: import_nestjs_agent_core39.AGENT_PROMPT_CONTRIBUTORS,
|
|
6855
6966
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
6856
6967
|
},
|
|
6857
6968
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
6858
6969
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
6859
6970
|
{
|
|
6860
|
-
provide:
|
|
6971
|
+
provide: import_nestjs_agent_core39.AGENT_SKILL_SOURCES,
|
|
6861
6972
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
6862
6973
|
},
|
|
6863
6974
|
{
|
|
6864
6975
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
6865
6976
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
6866
6977
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
6867
|
-
provide:
|
|
6978
|
+
provide: import_nestjs_agent_core39.AGENT_SKILLS,
|
|
6868
6979
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
6869
6980
|
inject: [
|
|
6870
|
-
|
|
6871
|
-
|
|
6981
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
6982
|
+
import_nestjs_agent_core39.AGENT_SKILL_SOURCES
|
|
6872
6983
|
]
|
|
6873
6984
|
},
|
|
6874
6985
|
{
|
|
6875
6986
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
6876
6987
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
6877
|
-
provide:
|
|
6988
|
+
provide: import_nestjs_agent_core39.AGENT_MEMORY,
|
|
6878
6989
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
6879
6990
|
inject: [
|
|
6880
|
-
|
|
6991
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6881
6992
|
]
|
|
6882
6993
|
},
|
|
6883
6994
|
{
|
|
6884
|
-
provide:
|
|
6995
|
+
provide: import_nestjs_agent_core39.AGENT_SINK,
|
|
6885
6996
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
6886
6997
|
inject: [
|
|
6887
|
-
|
|
6998
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6888
6999
|
]
|
|
6889
7000
|
},
|
|
6890
7001
|
{
|
|
6891
|
-
provide:
|
|
6892
|
-
useFactory: /* @__PURE__ */ __name((options) =>
|
|
7002
|
+
provide: import_nestjs_agent_core39.AGENT_ROLES_POLICY,
|
|
7003
|
+
useFactory: /* @__PURE__ */ __name((options, modules) => resolveRolesPolicy(options, modules), "useFactory"),
|
|
6893
7004
|
inject: [
|
|
6894
|
-
|
|
7005
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
7006
|
+
import_core4.ModulesContainer
|
|
6895
7007
|
]
|
|
6896
7008
|
},
|
|
6897
7009
|
{
|
|
6898
|
-
provide:
|
|
7010
|
+
provide: import_nestjs_agent_core39.AGENT_ACTOR_RESOLVER,
|
|
6899
7011
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
6900
7012
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
6901
7013
|
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.");
|
|
6902
7014
|
return new AnonymousActorResolver();
|
|
6903
7015
|
}, "useFactory"),
|
|
6904
7016
|
inject: [
|
|
6905
|
-
|
|
7017
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6906
7018
|
]
|
|
6907
7019
|
},
|
|
6908
7020
|
{
|
|
6909
|
-
provide:
|
|
7021
|
+
provide: import_nestjs_agent_core39.AGENT_MODEL,
|
|
6910
7022
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
6911
7023
|
inject: [
|
|
6912
|
-
|
|
7024
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6913
7025
|
]
|
|
6914
7026
|
},
|
|
6915
7027
|
{
|
|
6916
7028
|
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
6917
7029
|
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
6918
|
-
provide:
|
|
7030
|
+
provide: import_nestjs_agent_core39.AGENT_QUOTA_PROVIDER,
|
|
6919
7031
|
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
|
|
6920
7032
|
warnAt: o.quota.warnAt
|
|
6921
7033
|
} : {}), "useFactory"),
|
|
6922
7034
|
inject: [
|
|
6923
|
-
|
|
6924
|
-
|
|
7035
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
7036
|
+
import_nestjs_agent_core39.AGENT_STORE
|
|
6925
7037
|
]
|
|
6926
7038
|
},
|
|
6927
7039
|
{
|
|
6928
|
-
provide:
|
|
7040
|
+
provide: import_nestjs_agent_core39.AGENT_MODEL_CATALOG,
|
|
6929
7041
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
6930
7042
|
inject: [
|
|
6931
|
-
|
|
7043
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6932
7044
|
]
|
|
6933
7045
|
},
|
|
6934
7046
|
AgentDepsFactory2,
|
|
6935
7047
|
{
|
|
6936
|
-
provide:
|
|
7048
|
+
provide: import_nestjs_agent_core39.AGENT_DEPS_FACTORY,
|
|
6937
7049
|
useExisting: AgentDepsFactory2
|
|
6938
7050
|
},
|
|
6939
7051
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -6956,21 +7068,26 @@ function sharedProviders(durable) {
|
|
|
6956
7068
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
6957
7069
|
AgentApprovalPortAdapter,
|
|
6958
7070
|
{
|
|
6959
|
-
provide:
|
|
7071
|
+
provide: import_nestjs_agent_core39.AGENT_APPROVAL_PORT,
|
|
6960
7072
|
useExisting: AgentApprovalPortAdapter
|
|
6961
7073
|
}
|
|
6962
7074
|
];
|
|
6963
7075
|
providers.push({
|
|
6964
|
-
provide:
|
|
7076
|
+
provide: import_nestjs_agent_core39.AGENT_STORE,
|
|
6965
7077
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
6966
7078
|
inject: [
|
|
6967
|
-
|
|
7079
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
6968
7080
|
import_core4.ModulesContainer
|
|
6969
7081
|
]
|
|
6970
7082
|
});
|
|
6971
|
-
if (
|
|
7083
|
+
if (engine !== void 0) {
|
|
7084
|
+
providers.push(...engine.providers, {
|
|
7085
|
+
provide: import_nestjs_agent_core39.AGENT_RUNNER,
|
|
7086
|
+
useExisting: engine.runner
|
|
7087
|
+
});
|
|
7088
|
+
} else if (durable) {
|
|
6972
7089
|
providers.push({
|
|
6973
|
-
provide:
|
|
7090
|
+
provide: import_nestjs_agent_core39.AGENT_RUNNER,
|
|
6974
7091
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
6975
7092
|
if (durableRunner === void 0) {
|
|
6976
7093
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -6979,36 +7096,37 @@ function sharedProviders(durable) {
|
|
|
6979
7096
|
}, "useFactory"),
|
|
6980
7097
|
inject: [
|
|
6981
7098
|
{
|
|
6982
|
-
token:
|
|
7099
|
+
token: import_nestjs_agent_core39.AGENT_DURABLE_RUNNER,
|
|
6983
7100
|
optional: true
|
|
6984
7101
|
}
|
|
6985
7102
|
]
|
|
6986
7103
|
});
|
|
6987
7104
|
} else {
|
|
6988
7105
|
providers.push({
|
|
6989
|
-
provide:
|
|
7106
|
+
provide: import_nestjs_agent_core39.AGENT_RUNNER,
|
|
6990
7107
|
useExisting: InlineAgentRunner
|
|
6991
7108
|
});
|
|
6992
7109
|
}
|
|
6993
7110
|
return providers;
|
|
6994
7111
|
}
|
|
6995
7112
|
__name(sharedProviders, "sharedProviders");
|
|
6996
|
-
function exportsFor() {
|
|
7113
|
+
function exportsFor(engine) {
|
|
6997
7114
|
return [
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7115
|
+
...engine?.exports ?? [],
|
|
7116
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
7117
|
+
import_nestjs_agent_core39.AGENT_TOOL_REGISTRY,
|
|
7118
|
+
import_nestjs_agent_core39.AGENT_REGISTRY,
|
|
7119
|
+
import_nestjs_agent_core39.AGENT_SINK,
|
|
7120
|
+
import_nestjs_agent_core39.AGENT_ROLES_POLICY,
|
|
7121
|
+
import_nestjs_agent_core39.AGENT_ACTOR_RESOLVER,
|
|
7122
|
+
import_nestjs_agent_core39.AGENT_MODEL,
|
|
7123
|
+
import_nestjs_agent_core39.AGENT_STORE,
|
|
7124
|
+
import_nestjs_agent_core39.AGENT_MODEL_CATALOG,
|
|
7125
|
+
import_nestjs_agent_core39.AGENT_QUOTA_PROVIDER,
|
|
7126
|
+
import_nestjs_agent_core39.AGENT_PROMPT_CONTRIBUTORS,
|
|
7127
|
+
import_nestjs_agent_core39.AGENT_SKILLS,
|
|
7128
|
+
import_nestjs_agent_core39.AGENT_MEMORY,
|
|
7129
|
+
import_nestjs_agent_core39.AGENT_DEPS_FACTORY,
|
|
7012
7130
|
AgentDepsFactory2,
|
|
7013
7131
|
AgentService,
|
|
7014
7132
|
ActionProposalService,
|
|
@@ -7016,7 +7134,7 @@ function exportsFor() {
|
|
|
7016
7134
|
ChatQueueService2,
|
|
7017
7135
|
AGENT_CHAT_QUEUE,
|
|
7018
7136
|
InlineAgentRunner,
|
|
7019
|
-
|
|
7137
|
+
import_nestjs_agent_core39.AGENT_APPROVAL_PORT
|
|
7020
7138
|
];
|
|
7021
7139
|
}
|
|
7022
7140
|
__name(exportsFor, "exportsFor");
|
|
@@ -7044,10 +7162,11 @@ function adapterProviders(adapters) {
|
|
|
7044
7162
|
return (adapters ?? []).flatMap((adapter) => adapter.providers ?? []);
|
|
7045
7163
|
}
|
|
7046
7164
|
__name(adapterProviders, "adapterProviders");
|
|
7047
|
-
function controllersForSurface(surface, adapters) {
|
|
7165
|
+
function controllersForSurface(surface, adapters, engine) {
|
|
7048
7166
|
return surface === "engine" ? [] : [
|
|
7049
7167
|
...BASE_CONTROLLERS,
|
|
7050
|
-
...adapterControllers(adapters)
|
|
7168
|
+
...adapterControllers(adapters),
|
|
7169
|
+
...engine?.controllers ?? []
|
|
7051
7170
|
];
|
|
7052
7171
|
}
|
|
7053
7172
|
__name(controllersForSurface, "controllersForSurface");
|
|
@@ -7077,12 +7196,22 @@ function routerFor(path) {
|
|
|
7077
7196
|
]);
|
|
7078
7197
|
}
|
|
7079
7198
|
__name(routerFor, "routerFor");
|
|
7199
|
+
function assertRunnable(options) {
|
|
7200
|
+
if (options.engine !== void 0 && options.durable === true) {
|
|
7201
|
+
throw new Error(`AgentModule: \`durable: true\` runs turns on the library's loop, but the \`${options.engine.name}\` engine runs them instead. Drop \`durable\` (the engine decides how its turns survive a restart).`);
|
|
7202
|
+
}
|
|
7203
|
+
if (options.engine === void 0 && options.model === void 0) {
|
|
7204
|
+
throw new Error("AgentModule: set `model` (the loop runs the turns) or `engine` (something else does).");
|
|
7205
|
+
}
|
|
7206
|
+
}
|
|
7207
|
+
__name(assertRunnable, "assertRunnable");
|
|
7080
7208
|
var AgentModule = class _AgentModule {
|
|
7081
7209
|
static {
|
|
7082
7210
|
__name(this, "AgentModule");
|
|
7083
7211
|
}
|
|
7084
7212
|
static forRoot(options) {
|
|
7085
7213
|
const path = options.path ?? DEFAULT_PATH;
|
|
7214
|
+
assertRunnable(options);
|
|
7086
7215
|
applyGuards(options.guards, options.adapters);
|
|
7087
7216
|
return {
|
|
7088
7217
|
module: _AgentModule,
|
|
@@ -7091,21 +7220,27 @@ var AgentModule = class _AgentModule {
|
|
|
7091
7220
|
import_core4.DiscoveryModule,
|
|
7092
7221
|
routerFor(path)
|
|
7093
7222
|
],
|
|
7094
|
-
controllers: controllersForSurface(options.surface, options.adapters),
|
|
7223
|
+
controllers: controllersForSurface(options.surface, options.adapters, options.engine),
|
|
7095
7224
|
providers: [
|
|
7096
7225
|
{
|
|
7097
|
-
provide:
|
|
7226
|
+
provide: import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
7098
7227
|
useValue: options
|
|
7099
7228
|
},
|
|
7100
|
-
...sharedProviders(options.durable ?? false),
|
|
7229
|
+
...sharedProviders(options.durable ?? false, options.engine),
|
|
7101
7230
|
...guardProviders(options.guards),
|
|
7102
7231
|
...adapterProviders(options.adapters)
|
|
7103
7232
|
],
|
|
7104
|
-
exports: exportsFor()
|
|
7233
|
+
exports: exportsFor(options.engine)
|
|
7105
7234
|
};
|
|
7106
7235
|
}
|
|
7107
7236
|
static forRootAsync(options) {
|
|
7108
7237
|
const path = options.path ?? DEFAULT_PATH;
|
|
7238
|
+
if (options.engine !== void 0) {
|
|
7239
|
+
assertRunnable({
|
|
7240
|
+
engine: options.engine,
|
|
7241
|
+
durable: options.durable ?? false
|
|
7242
|
+
});
|
|
7243
|
+
}
|
|
7109
7244
|
applyGuards(options.guards, options.adapters);
|
|
7110
7245
|
return {
|
|
7111
7246
|
module: _AgentModule,
|
|
@@ -7115,28 +7250,35 @@ var AgentModule = class _AgentModule {
|
|
|
7115
7250
|
routerFor(path),
|
|
7116
7251
|
...options.imports ?? []
|
|
7117
7252
|
],
|
|
7118
|
-
controllers: controllersForSurface(options.surface, options.adapters),
|
|
7253
|
+
controllers: controllersForSurface(options.surface, options.adapters, options.engine),
|
|
7119
7254
|
providers: [
|
|
7120
7255
|
{
|
|
7121
|
-
provide:
|
|
7256
|
+
provide: import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
7122
7257
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
7123
7258
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
7124
7259
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
7125
7260
|
// anything today (AgentDurableModule takes its own mirror option — see its doc for why),
|
|
7126
7261
|
// but it's stamped here too so the EFFECTIVE value is always observable off
|
|
7127
7262
|
// AGENT_OPTIONS, sync or async alike.
|
|
7128
|
-
useFactory: /* @__PURE__ */ __name(async (...args) =>
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7263
|
+
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
7264
|
+
const resolved = {
|
|
7265
|
+
...await options.useFactory(...args),
|
|
7266
|
+
durable: options.durable ?? false,
|
|
7267
|
+
surface: options.surface ?? "both",
|
|
7268
|
+
...options.engine !== void 0 ? {
|
|
7269
|
+
engine: options.engine
|
|
7270
|
+
} : {}
|
|
7271
|
+
};
|
|
7272
|
+
assertRunnable(resolved);
|
|
7273
|
+
return resolved;
|
|
7274
|
+
}, "useFactory"),
|
|
7133
7275
|
inject: options.inject ?? []
|
|
7134
7276
|
},
|
|
7135
|
-
...sharedProviders(options.durable ?? false),
|
|
7277
|
+
...sharedProviders(options.durable ?? false, options.engine),
|
|
7136
7278
|
...guardProviders(options.guards),
|
|
7137
7279
|
...adapterProviders(options.adapters)
|
|
7138
7280
|
],
|
|
7139
|
-
exports: exportsFor()
|
|
7281
|
+
exports: exportsFor(options.engine)
|
|
7140
7282
|
};
|
|
7141
7283
|
}
|
|
7142
7284
|
};
|